2 * linux/arch/arm/plat-omap/devices.c
4 * Common platform device setup/initialization for OMAP1 and OMAP2
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
18 #include <mach/hardware.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/map.h>
23 #include <plat/control.h>
24 #include <plat/board.h>
27 #include <mach/gpio.h>
28 #include <plat/menelaus.h>
29 #include <plat/mcbsp.h>
30 #include <plat/dsp_common.h>
31 #include <plat/omap44xx.h>
33 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
35 static struct dsp_platform_data dsp_pdata = {
36 .kdev_list = LIST_HEAD_INIT(dsp_pdata.kdev_list),
39 static struct resource omap_dsp_resources[] = {
43 .flags = IORESOURCE_IRQ,
47 static struct platform_device omap_dsp_device = {
50 .num_resources = ARRAY_SIZE(omap_dsp_resources),
51 .resource = omap_dsp_resources,
53 .platform_data = &dsp_pdata,
57 static inline void omap_init_dsp(void)
62 if (cpu_is_omap15xx())
63 irq = INT_1510_DSP_MMU;
64 else if (cpu_is_omap16xx())
65 irq = INT_1610_DSP_MMU;
66 else if (cpu_is_omap24xx())
67 irq = INT_24XX_DSP_MMU;
69 res = platform_get_resource_byname(&omap_dsp_device,
70 IORESOURCE_IRQ, "dsp_mmu");
73 platform_device_register(&omap_dsp_device);
76 int dsp_kfunc_device_register(struct dsp_kfunc_device *kdev)
78 static DEFINE_MUTEX(dsp_pdata_lock);
80 spin_lock_init(&kdev->lock);
82 mutex_lock(&dsp_pdata_lock);
83 list_add_tail(&kdev->entry, &dsp_pdata.kdev_list);
84 mutex_unlock(&dsp_pdata_lock);
88 EXPORT_SYMBOL(dsp_kfunc_device_register);
91 static inline void omap_init_dsp(void) { }
92 #endif /* CONFIG_OMAP_DSP */
94 /*-------------------------------------------------------------------------*/
95 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
97 static void omap_init_kp(void)
99 /* 2430 and 34xx keypad is on TWL4030 */
100 if (cpu_is_omap2430() || cpu_is_omap34xx())
103 if (machine_is_omap_h2() || machine_is_omap_h3()) {
104 omap_cfg_reg(F18_1610_KBC0);
105 omap_cfg_reg(D20_1610_KBC1);
106 omap_cfg_reg(D19_1610_KBC2);
107 omap_cfg_reg(E18_1610_KBC3);
108 omap_cfg_reg(C21_1610_KBC4);
110 omap_cfg_reg(G18_1610_KBR0);
111 omap_cfg_reg(F19_1610_KBR1);
112 omap_cfg_reg(H14_1610_KBR2);
113 omap_cfg_reg(E20_1610_KBR3);
114 omap_cfg_reg(E19_1610_KBR4);
115 omap_cfg_reg(N19_1610_KBR5);
116 } else if (machine_is_omap_perseus2() || machine_is_omap_fsample()) {
117 omap_cfg_reg(E2_7XX_KBR0);
118 omap_cfg_reg(J7_7XX_KBR1);
119 omap_cfg_reg(E1_7XX_KBR2);
120 omap_cfg_reg(F3_7XX_KBR3);
121 omap_cfg_reg(D2_7XX_KBR4);
123 omap_cfg_reg(C2_7XX_KBC0);
124 omap_cfg_reg(D3_7XX_KBC1);
125 omap_cfg_reg(E4_7XX_KBC2);
126 omap_cfg_reg(F4_7XX_KBC3);
127 omap_cfg_reg(E3_7XX_KBC4);
128 } else if (machine_is_omap_h4()) {
129 omap_cfg_reg(T19_24XX_KBR0);
130 omap_cfg_reg(R19_24XX_KBR1);
131 omap_cfg_reg(V18_24XX_KBR2);
132 omap_cfg_reg(M21_24XX_KBR3);
133 omap_cfg_reg(E5__24XX_KBR4);
134 if (omap_has_menelaus()) {
135 omap_cfg_reg(B3__24XX_KBR5);
136 omap_cfg_reg(AA4_24XX_KBC2);
137 omap_cfg_reg(B13_24XX_KBC6);
139 omap_cfg_reg(M18_24XX_KBR5);
140 omap_cfg_reg(H19_24XX_KBC2);
141 omap_cfg_reg(N19_24XX_KBC6);
143 omap_cfg_reg(R20_24XX_KBC0);
144 omap_cfg_reg(M14_24XX_KBC1);
145 omap_cfg_reg(V17_24XX_KBC3);
146 omap_cfg_reg(P21_24XX_KBC4);
147 omap_cfg_reg(L14_24XX_KBC5);
151 static inline void omap_init_kp(void) {}
154 /*-------------------------------------------------------------------------*/
155 #if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE)
157 static struct platform_device **omap_mcbsp_devices;
159 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
164 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
166 if (!omap_mcbsp_devices) {
167 printk(KERN_ERR "Could not register McBSP devices\n");
171 for (i = 0; i < size; i++) {
172 struct platform_device *new_mcbsp;
175 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
178 new_mcbsp->dev.platform_data = &config[i];
179 ret = platform_device_add(new_mcbsp);
181 platform_device_put(new_mcbsp);
184 omap_mcbsp_devices[i] = new_mcbsp;
189 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
194 /*-------------------------------------------------------------------------*/
196 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
197 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
199 static struct resource mcpdm_resources[] = {
202 .start = OMAP44XX_MCPDM_BASE,
203 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
204 .flags = IORESOURCE_MEM,
208 .start = OMAP44XX_IRQ_MCPDM,
209 .end = OMAP44XX_IRQ_MCPDM,
210 .flags = IORESOURCE_IRQ,
214 static struct platform_device omap_mcpdm_device = {
215 .name = "omap-mcpdm",
217 .num_resources = ARRAY_SIZE(mcpdm_resources),
218 .resource = mcpdm_resources,
221 static void omap_init_mcpdm(void)
223 (void) platform_device_register(&omap_mcpdm_device);
226 static inline void omap_init_mcpdm(void) {}
229 /*-------------------------------------------------------------------------*/
231 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
232 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
234 #define OMAP_MMC_NR_RES 2
237 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
239 int __init omap_mmc_add(const char *name, int id, unsigned long base,
240 unsigned long size, unsigned int irq,
241 struct omap_mmc_platform_data *data)
243 struct platform_device *pdev;
244 struct resource res[OMAP_MMC_NR_RES];
247 pdev = platform_device_alloc(name, id);
251 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
253 res[0].end = base + size - 1;
254 res[0].flags = IORESOURCE_MEM;
255 res[1].start = res[1].end = irq;
256 res[1].flags = IORESOURCE_IRQ;
258 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
260 ret = platform_device_add_data(pdev, data, sizeof(*data));
264 ret = platform_device_add(pdev);
268 /* return device handle to board setup code */
269 data->dev = &pdev->dev;
273 platform_device_put(pdev);
279 /*-------------------------------------------------------------------------*/
281 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
283 #ifdef CONFIG_ARCH_OMAP2
284 #define OMAP_RNG_BASE 0x480A0000
286 #define OMAP_RNG_BASE 0xfffe5000
289 static struct resource rng_resources[] = {
291 .start = OMAP_RNG_BASE,
292 .end = OMAP_RNG_BASE + 0x4f,
293 .flags = IORESOURCE_MEM,
297 static struct platform_device omap_rng_device = {
300 .num_resources = ARRAY_SIZE(rng_resources),
301 .resource = rng_resources,
304 static void omap_init_rng(void)
306 (void) platform_device_register(&omap_rng_device);
309 static inline void omap_init_rng(void) {}
312 /*-------------------------------------------------------------------------*/
314 /* Numbering for the SPI-capable controllers when used for SPI:
321 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
323 #define OMAP_UWIRE_BASE 0xfffb3000
325 static struct resource uwire_resources[] = {
327 .start = OMAP_UWIRE_BASE,
328 .end = OMAP_UWIRE_BASE + 0x20,
329 .flags = IORESOURCE_MEM,
333 static struct platform_device omap_uwire_device = {
334 .name = "omap_uwire",
336 .num_resources = ARRAY_SIZE(uwire_resources),
337 .resource = uwire_resources,
340 static void omap_init_uwire(void)
342 /* FIXME define and use a boot tag; not all boards will be hooking
343 * up devices to the microwire controller, and multi-board configs
344 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
347 /* board-specific code must configure chipselects (only a few
348 * are normally used) and SCLK/SDI/SDO (each has two choices).
350 (void) platform_device_register(&omap_uwire_device);
353 static inline void omap_init_uwire(void) {}
356 /*-------------------------------------------------------------------------*/
358 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
360 static struct resource wdt_resources[] = {
362 .flags = IORESOURCE_MEM,
366 static struct platform_device omap_wdt_device = {
369 .num_resources = ARRAY_SIZE(wdt_resources),
370 .resource = wdt_resources,
373 static void omap_init_wdt(void)
375 if (cpu_is_omap16xx())
376 wdt_resources[0].start = 0xfffeb000;
377 else if (cpu_is_omap2420())
378 wdt_resources[0].start = 0x48022000; /* WDT2 */
379 else if (cpu_is_omap2430())
380 wdt_resources[0].start = 0x49016000; /* WDT2 */
381 else if (cpu_is_omap343x())
382 wdt_resources[0].start = 0x48314000; /* WDT2 */
383 else if (cpu_is_omap44xx())
384 wdt_resources[0].start = 0x4a314000;
388 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
390 (void) platform_device_register(&omap_wdt_device);
393 static inline void omap_init_wdt(void) {}
397 * This gets called after board-specific INIT_MACHINE, and initializes most
398 * on-chip peripherals accessible on this board (except for few like USB):
400 * (a) Does any "standard config" pin muxing needed. Board-specific
401 * code will have muxed GPIO pins and done "nonstandard" setup;
402 * that code could live in the boot loader.
403 * (b) Populating board-specific platform_data with the data drivers
404 * rely on to handle wiring variations.
405 * (c) Creating platform devices as meaningful on this board and
406 * with this kernel configuration.
408 * Claiming GPIOs, and setting their direction and initial values, is the
409 * responsibility of the device drivers. So is responding to probe().
411 * Board-specific knowlege like creating devices or pin setup is to be
412 * kept out of drivers as much as possible. In particular, pin setup
413 * may be handled by the boot loader, and drivers should expect it will
414 * normally have been done by the time they're probed.
416 static int __init omap_init_devices(void)
418 /* please keep these calls, and their implementations above,
419 * in alphabetical order so they're easier to sort through.
429 arch_initcall(omap_init_devices);