1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
|
/*
* Author: MontaVista Software, Inc.
* <source@mvista.com>
*
* Based on the OMAP devices.c
*
* 2005 (c) MontaVista Software, Inc. This file is licensed under the
* terms of the GNU General Public License version 2. This program is
* licensed "as is" without any warranty of any kind, whether express
* or implied.
*
* Copyright 2006-2008 Freescale Semiconductor, Inc. All Rights Reserved.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <asm/hardware.h>
#include <asm/arch/pmic_external.h>
#include <asm/arch/pmic_power.h>
#include <asm/arch/mmc.h>
/*!
* @file mach-mx27/devices.c
* @brief device configurations including nor/nand/watchdog for mx27.
*
* @ingroup MSL_MX27
*/
#ifndef CONFIG_MX27_DPTC
extern struct dptc_wp dptc_wp_allfreq[DPTC_WP_SUPPORTED];
#endif
static void mxc_nop_release(struct device *dev)
{
/* Nothing */
}
#if defined(CONFIG_W1_MASTER_MXC) || defined(CONFIG_W1_MASTER_MXC_MODULE)
static struct mxc_w1_config mxc_w1_data = {
.search_rom_accelerator = 0,
};
static struct platform_device mxc_w1_devices = {
.name = "mxc_w1",
.dev = {
.release = mxc_nop_release,
.platform_data = &mxc_w1_data,
},
.id = 0
};
static void mxc_init_owire(void)
{
(void)platform_device_register(&mxc_w1_devices);
}
#else
static inline void mxc_init_owire(void)
{
}
#endif
#if defined(CONFIG_RTC_MXC) || defined(CONFIG_RTC_MXC_MODULE)
static struct resource rtc_resources[] = {
{
.start = RTC_BASE_ADDR,
.end = RTC_BASE_ADDR + 0x30,
.flags = IORESOURCE_MEM,
},
{
.start = MXC_INT_RTC,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device mxc_rtc_device = {
.name = "mxc_rtc",
.id = 0,
.dev = {
.release = mxc_nop_release,
},
.num_resources = ARRAY_SIZE(rtc_resources),
.resource = rtc_resources,
};
static void mxc_init_rtc(void)
{
(void)platform_device_register(&mxc_rtc_device);
}
#else
static inline void mxc_init_rtc(void)
{
}
#endif
#if defined(CONFIG_MXC_WATCHDOG) || defined(CONFIG_MXC_WATCHDOG_MODULE)
static struct resource wdt_resources[] = {
{
.start = WDOG1_BASE_ADDR,
.end = WDOG1_BASE_ADDR + 0x30,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device mxc_wdt_device = {
.name = "mxc_wdt",
.id = 0,
.dev = {
.release = mxc_nop_release,
},
.num_resources = ARRAY_SIZE(wdt_resources),
.resource = wdt_resources,
};
static void mxc_init_wdt(void)
{
(void)platform_device_register(&mxc_wdt_device);
}
#else
static inline void mxc_init_wdt(void)
{
}
#endif
/*!
* This is platform device structure for adding SCC
*/
#if defined(CONFIG_MXC_SECURITY_SCC) || defined(CONFIG_MXC_SECURITY_SCC_MODULE)
static struct platform_device mxc_scc_device = {
.name = "mxc_scc",
.id = 0,
};
static void mxc_init_scc(void)
{
platform_device_register(&mxc_scc_device);
}
#else
static inline void mxc_init_scc(void)
{
}
#endif
/* MMC device data */
#if defined(CONFIG_MMC_MXC) || defined(CONFIG_MMC_MXC_MODULE)
extern unsigned int sdhc_get_card_det_status(struct device *dev);
extern int sdhc_init_card_det(int id);
static struct mxc_mmc_platform_data mmc_data = {
.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30,
.min_clk = 150000,
.max_clk = 25000000,
.card_inserted_state = 0,
.status = sdhc_get_card_det_status,
};
/*!
* Resource definition for the SDHC1
*/
static struct resource mxcsdhc1_resources[] = {
[0] = {
.start = SDHC1_BASE_ADDR,
.end = SDHC1_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_SDHC1,
.end = MXC_INT_SDHC1,
.flags = IORESOURCE_IRQ,
},
[2] = {
.start = 0,
.end = 0,
.flags = IORESOURCE_IRQ,
},
};
/*!
* Resource definition for the SDHC2
*/
static struct resource mxcsdhc2_resources[] = {
[0] = {
.start = SDHC2_BASE_ADDR,
.end = SDHC2_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_SDHC2,
.end = MXC_INT_SDHC2,
.flags = IORESOURCE_IRQ,
},
[2] = {
.start = 0,
.end = 0,
.flags = IORESOURCE_IRQ,
},
};
/*! Device Definition for MXC SDHC1 */
static struct platform_device mxcsdhc1_device = {
.name = "mxcmci",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mmc_data,
},
.num_resources = ARRAY_SIZE(mxcsdhc1_resources),
.resource = mxcsdhc1_resources,
};
/*! Device Definition for MXC SDHC2 */
static struct platform_device mxcsdhc2_device = {
.name = "mxcmci",
.id = 1,
.dev = {
.release = mxc_nop_release,
.platform_data = &mmc_data,
},
.num_resources = ARRAY_SIZE(mxcsdhc2_resources),
.resource = mxcsdhc2_resources,
};
#ifdef CONFIG_MXC_SDHC3
/*!
* Resource definition for the SDHC3
*/
static struct resource mxcsdhc3_resources[] = {
[0] = {
.start = SDHC3_BASE_ADDR,
.end = SDHC3_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_SDHC3,
.end = MXC_INT_SDHC3,
.flags = IORESOURCE_IRQ,
},
[2] = {
.start = 0,
.end = 0,
.flags = IORESOURCE_IRQ,
},
[3] = {
.start = MXC_SDIO3_CARD_IRQ,
.end = MXC_SDIO3_CARD_IRQ,
.flags = IORESOURCE_IRQ,
},
};
/*! Device Definition for MXC SDHC3 */
static struct platform_device mxcsdhc3_device = {
.name = "mxcmci",
.id = 2,
.dev = {
.release = mxc_nop_release,
.platform_data = &mmc_data,
},
.num_resources = ARRAY_SIZE(mxcsdhc3_resources),
.resource = mxcsdhc3_resources,
};
#endif
static inline void mxc_init_mmc(void)
{
int cd_irq;
cd_irq = sdhc_init_card_det(0);
if (cd_irq) {
mxcsdhc1_device.resource[2].start = cd_irq;
mxcsdhc1_device.resource[2].end = cd_irq;
}
cd_irq = sdhc_init_card_det(1);
if (cd_irq) {
mxcsdhc2_device.resource[2].start = cd_irq;
mxcsdhc2_device.resource[2].end = cd_irq;
}
(void)platform_device_register(&mxcsdhc1_device);
(void)platform_device_register(&mxcsdhc2_device);
#ifdef CONFIG_MXC_SDHC3
(void)platform_device_register(&mxcsdhc3_device);
#endif
}
#else
static inline void mxc_init_mmc(void)
{
}
#endif
/* SPI controller and device data */
#if defined(CONFIG_SPI_MXC) || defined(CONFIG_SPI_MXC_MODULE)
#ifdef CONFIG_SPI_MXC_SELECT1
/*!
* Resource definition for the CSPI1
*/
static struct resource mxcspi1_resources[] = {
[0] = {
.start = CSPI1_BASE_ADDR,
.end = CSPI1_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_CSPI1,
.end = MXC_INT_CSPI1,
.flags = IORESOURCE_IRQ,
},
};
/*! Platform Data for MXC CSPI1 */
static struct mxc_spi_master mxcspi1_data = {
.maxchipselect = 4,
.spi_version = 0,
};
/*! Device Definition for MXC CSPI1 */
static struct platform_device mxcspi1_device = {
.name = "mxc_spi",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxcspi1_data,
},
.num_resources = ARRAY_SIZE(mxcspi1_resources),
.resource = mxcspi1_resources,
};
#endif /* CONFIG_SPI_MXC_SELECT1 */
#ifdef CONFIG_SPI_MXC_SELECT2
/*!
* Resource definition for the CSPI2
*/
static struct resource mxcspi2_resources[] = {
[0] = {
.start = CSPI2_BASE_ADDR,
.end = CSPI2_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_CSPI2,
.end = MXC_INT_CSPI2,
.flags = IORESOURCE_IRQ,
},
};
/*! Platform Data for MXC CSPI2 */
static struct mxc_spi_master mxcspi2_data = {
.maxchipselect = 4,
.spi_version = 0,
};
/*! Device Definition for MXC CSPI2 */
static struct platform_device mxcspi2_device = {
.name = "mxc_spi",
.id = 1,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxcspi2_data,
},
.num_resources = ARRAY_SIZE(mxcspi2_resources),
.resource = mxcspi2_resources,
};
#endif /* CONFIG_SPI_MXC_SELECT2 */
#ifdef CONFIG_SPI_MXC_SELECT3
/*!
* Resource definition for the CSPI3
*/
static struct resource mxcspi3_resources[] = {
[0] = {
.start = CSPI3_BASE_ADDR,
.end = CSPI3_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_CSPI3,
.end = MXC_INT_CSPI3,
.flags = IORESOURCE_IRQ,
},
};
/*! Platform Data for MXC CSPI3 */
static struct mxc_spi_master mxcspi3_data = {
.maxchipselect = 4,
.spi_version = 0,
};
/*! Device Definition for MXC CSPI3 */
static struct platform_device mxcspi3_device = {
.name = "mxc_spi",
.id = 2,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxcspi3_data,
},
.num_resources = ARRAY_SIZE(mxcspi3_resources),
.resource = mxcspi3_resources,
};
#endif /* CONFIG_SPI_MXC_SELECT3 */
static inline void mxc_init_spi(void)
{
#ifdef CONFIG_SPI_MXC_SELECT1
if (platform_device_register(&mxcspi1_device) < 0)
printk(KERN_ERR "Registering the SPI Controller_1\n");
#endif /* CONFIG_SPI_MXC_SELECT1 */
#ifdef CONFIG_SPI_MXC_SELECT2
if (platform_device_register(&mxcspi2_device) < 0)
printk(KERN_ERR "Registering the SPI Controller_2\n");
#endif /* CONFIG_SPI_MXC_SELECT2 */
#ifdef CONFIG_SPI_MXC_SELECT3
if (platform_device_register(&mxcspi3_device) < 0)
printk(KERN_ERR "Registering the SPI Controller_3\n");
#endif /* CONFIG_SPI_MXC_SELECT3 */
}
#else
static inline void mxc_init_spi(void)
{
}
#endif
#if defined(CONFIG_SND_MXC_PMIC) || defined(CONFIG_SND_MXC_PMIC_MODULE)
static struct mxc_audio_platform_data mxc_audio_data;
static struct platform_device mxc_alsa_device = {
.name = "mxc_alsa",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxc_audio_data,
},
};
static void mxc_init_audio(void)
{
mxc_audio_data.ssi_clk[0] = clk_get(NULL, "ssi_clk.0");
clk_put(audio_data->ssi_clk[0]);
mxc_audio_data.ssi_clk[1] = clk_get(NULL, "ssi_clk.1");
clk_put(audio_data->ssi_clk[1]);
mxc_audio_data.ssi_num = 2;
mxc_audio_data.src_port = 0;
platform_device_register(&mxc_alsa_device);
}
#else
static void mxc_init_audio(void)
{
}
#endif
#if defined(CONFIG_MXC_SSI) || defined(CONFIG_MXC_SSI_MODULE)
/*!
* Resource definition for the SSI
*/
static struct resource mxcssi2_resources[] = {
[0] = {
.start = SSI2_BASE_ADDR,
.end = SSI2_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
};
static struct resource mxcssi1_resources[] = {
[0] = {
.start = SSI1_BASE_ADDR,
.end = SSI1_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
};
/*! Device Definition for MXC SSI */
static struct platform_device mxc_ssi1_device = {
.name = "mxc_ssi",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxc_audio_data,
},
.num_resources = ARRAY_SIZE(mxcssi1_resources),
.resource = mxcssi1_resources,
};
static struct platform_device mxc_ssi2_device = {
.name = "mxc_ssi",
.id = 1,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxc_audio_data,
},
.num_resources = ARRAY_SIZE(mxcssi2_resources),
.resource = mxcssi2_resources,
};
static void mxc_init_ssi(void)
{
platform_device_register(&mxc_ssi1_device);
platform_device_register(&mxc_ssi2_device);
}
#else
static void mxc_init_ssi(void)
{
}
#endif
/* I2C controller and device data */
#if defined(CONFIG_I2C_MXC) || defined(CONFIG_I2C_MXC_MODULE)
#ifdef CONFIG_I2C_MXC_SELECT1
/*!
* Resource definition for the I2C1
*/
static struct resource mxci2c1_resources[] = {
[0] = {
.start = I2C_BASE_ADDR,
.end = I2C_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_I2C,
.end = MXC_INT_I2C,
.flags = IORESOURCE_IRQ,
},
};
/*! Platform Data for MXC I2C */
static struct mxc_i2c_platform_data mxci2c1_data = {
.i2c_clk = 100000,
};
#endif
#ifdef CONFIG_I2C_MXC_SELECT2
/*!
* Resource definition for the I2C2
*/
static struct resource mxci2c2_resources[] = {
[0] = {
.start = I2C2_BASE_ADDR,
.end = I2C2_BASE_ADDR + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MXC_INT_I2C2,
.end = MXC_INT_I2C2,
.flags = IORESOURCE_IRQ,
},
};
/*! Platform Data for MXC I2C */
static struct mxc_i2c_platform_data mxci2c2_data = {
.i2c_clk = 100000,
};
#endif
/*! Device Definition for MXC I2C */
static struct platform_device mxci2c_devices[] = {
#ifdef CONFIG_I2C_MXC_SELECT1
{
.name = "mxc_i2c",
.id = 0,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxci2c1_data,
},
.num_resources = ARRAY_SIZE(mxci2c1_resources),
.resource = mxci2c1_resources,},
#endif
#ifdef CONFIG_I2C_MXC_SELECT2
{
.name = "mxc_i2c",
.id = 1,
.dev = {
.release = mxc_nop_release,
.platform_data = &mxci2c2_data,
},
.num_resources = ARRAY_SIZE(mxci2c2_resources),
.resource = mxci2c2_resources,},
#endif
};
static inline void mxc_init_i2c(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(mxci2c_devices); i++) {
if (platform_device_register(&mxci2c_devices[i]) < 0)
dev_err(&mxci2c_devices[i].dev,
"Unable to register I2C device\n");
}
}
#else
static inline void mxc_init_i2c(void)
{
}
#endif
#ifdef CONFIG_MXC_VPU
/*! Platform Data for MXC VPU */
static struct platform_device mxcvpu_device = {
.name = "mxc_vpu",
.dev = {
.release = mxc_nop_release,
},
.id = 0,
};
static inline void mxc_init_vpu(void)
{
if (platform_device_register(&mxcvpu_device) < 0)
printk(KERN_ERR "Error: Registering the VPU.\n");
}
#else
static inline void mxc_init_vpu(void)
{
}
#endif
struct mxc_gpio_port mxc_gpio_ports[GPIO_PORT_NUM] = {
{
.num = 0,
.base = IO_ADDRESS(GPIO_BASE_ADDR),
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE,
},
{
.num = 1,
.base = IO_ADDRESS(GPIO_BASE_ADDR) + 0x100,
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN,
},
{
.num = 2,
.base = IO_ADDRESS(GPIO_BASE_ADDR) + 0x200,
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN * 2,
},
{
.num = 3,
.base = IO_ADDRESS(GPIO_BASE_ADDR) + 0x300,
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN * 3,
},
{
.num = 4,
.base = IO_ADDRESS(GPIO_BASE_ADDR) + 0x400,
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN * 4,
},
{
.num = 5,
.base = IO_ADDRESS(GPIO_BASE_ADDR) + 0x500,
.irq = MXC_INT_GPIO,
.virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN * 5,
},
};
#ifndef CONFIG_MX27_DPTC
/*! Device Definition for DPTC */
static struct platform_device mxc_dptc_device = {
.name = "mxc_dptc",
.dev = {
.release = mxc_nop_release,
.platform_data = &dptc_wp_allfreq,
},
};
static inline void mxc_init_dptc(void)
{
(void)platform_device_register(&mxc_dptc_device);
}
#endif
static int __init mxc_init_devices(void)
{
mxc_init_wdt();
mxc_init_mmc();
mxc_init_spi();
mxc_init_i2c();
mxc_init_rtc();
mxc_init_ssi();
mxc_init_audio();
mxc_init_scc();
mxc_init_owire();
mxc_init_vpu();
#ifndef CONFIG_MX27_DPTC
mxc_init_dptc();
#endif
return 0;
}
arch_initcall(mxc_init_devices);
|