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>
17 #include <linux/slab.h>
19 #include <mach/hardware.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/map.h>
24 #include <plat/control.h>
25 #include <plat/board.h>
28 #include <mach/gpio.h>
29 #include <plat/menelaus.h>
30 #include <plat/mcbsp.h>
31 #include <plat/dsp_common.h>
32 #include <plat/omap44xx.h>
34 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
36 static struct dsp_platform_data dsp_pdata = {
37 .kdev_list = LIST_HEAD_INIT(dsp_pdata.kdev_list),
40 static struct resource omap_dsp_resources[] = {
44 .flags = IORESOURCE_IRQ,
48 static struct platform_device omap_dsp_device = {
51 .num_resources = ARRAY_SIZE(omap_dsp_resources),
52 .resource = omap_dsp_resources,
54 .platform_data = &dsp_pdata,
58 static inline void omap_init_dsp(void)
63 if (cpu_is_omap15xx())
64 irq = INT_1510_DSP_MMU;
65 else if (cpu_is_omap16xx())
66 irq = INT_1610_DSP_MMU;
67 else if (cpu_is_omap24xx())
68 irq = INT_24XX_DSP_MMU;
70 res = platform_get_resource_byname(&omap_dsp_device,
71 IORESOURCE_IRQ, "dsp_mmu");
74 platform_device_register(&omap_dsp_device);
77 int dsp_kfunc_device_register(struct dsp_kfunc_device *kdev)
79 static DEFINE_MUTEX(dsp_pdata_lock);
81 spin_lock_init(&kdev->lock);
83 mutex_lock(&dsp_pdata_lock);
84 list_add_tail(&kdev->entry, &dsp_pdata.kdev_list);
85 mutex_unlock(&dsp_pdata_lock);
89 EXPORT_SYMBOL(dsp_kfunc_device_register);
92 static inline void omap_init_dsp(void) { }
93 #endif /* CONFIG_OMAP_DSP */
95 /*-------------------------------------------------------------------------*/
96 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
98 static void omap_init_kp(void)
100 /* 2430 and 34xx keypad is on TWL4030 */
101 if (cpu_is_omap2430() || cpu_is_omap34xx())
104 if (machine_is_omap_h2() || machine_is_omap_h3()) {
105 omap_cfg_reg(F18_1610_KBC0);
106 omap_cfg_reg(D20_1610_KBC1);
107 omap_cfg_reg(D19_1610_KBC2);
108 omap_cfg_reg(E18_1610_KBC3);
109 omap_cfg_reg(C21_1610_KBC4);
111 omap_cfg_reg(G18_1610_KBR0);
112 omap_cfg_reg(F19_1610_KBR1);
113 omap_cfg_reg(H14_1610_KBR2);
114 omap_cfg_reg(E20_1610_KBR3);
115 omap_cfg_reg(E19_1610_KBR4);
116 omap_cfg_reg(N19_1610_KBR5);
117 } else if (machine_is_omap_perseus2() || machine_is_omap_fsample()) {
118 omap_cfg_reg(E2_7XX_KBR0);
119 omap_cfg_reg(J7_7XX_KBR1);
120 omap_cfg_reg(E1_7XX_KBR2);
121 omap_cfg_reg(F3_7XX_KBR3);
122 omap_cfg_reg(D2_7XX_KBR4);
124 omap_cfg_reg(C2_7XX_KBC0);
125 omap_cfg_reg(D3_7XX_KBC1);
126 omap_cfg_reg(E4_7XX_KBC2);
127 omap_cfg_reg(F4_7XX_KBC3);
128 omap_cfg_reg(E3_7XX_KBC4);
129 } else if (machine_is_omap_h4()) {
130 omap_cfg_reg(T19_24XX_KBR0);
131 omap_cfg_reg(R19_24XX_KBR1);
132 omap_cfg_reg(V18_24XX_KBR2);
133 omap_cfg_reg(M21_24XX_KBR3);
134 omap_cfg_reg(E5__24XX_KBR4);
135 if (omap_has_menelaus()) {
136 omap_cfg_reg(B3__24XX_KBR5);
137 omap_cfg_reg(AA4_24XX_KBC2);
138 omap_cfg_reg(B13_24XX_KBC6);
140 omap_cfg_reg(M18_24XX_KBR5);
141 omap_cfg_reg(H19_24XX_KBC2);
142 omap_cfg_reg(N19_24XX_KBC6);
144 omap_cfg_reg(R20_24XX_KBC0);
145 omap_cfg_reg(M14_24XX_KBC1);
146 omap_cfg_reg(V17_24XX_KBC3);
147 omap_cfg_reg(P21_24XX_KBC4);
148 omap_cfg_reg(L14_24XX_KBC5);
152 static inline void omap_init_kp(void) {}
155 /*-------------------------------------------------------------------------*/
156 #if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE)
158 static struct platform_device **omap_mcbsp_devices;
160 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
165 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
167 if (!omap_mcbsp_devices) {
168 printk(KERN_ERR "Could not register McBSP devices\n");
172 for (i = 0; i < size; i++) {
173 struct platform_device *new_mcbsp;
176 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
179 new_mcbsp->dev.platform_data = &config[i];
180 ret = platform_device_add(new_mcbsp);
182 platform_device_put(new_mcbsp);
185 omap_mcbsp_devices[i] = new_mcbsp;
190 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
195 /*-------------------------------------------------------------------------*/
197 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
198 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
200 static struct resource mcpdm_resources[] = {
203 .start = OMAP44XX_MCPDM_BASE,
204 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
205 .flags = IORESOURCE_MEM,
209 .start = OMAP44XX_IRQ_MCPDM,
210 .end = OMAP44XX_IRQ_MCPDM,
211 .flags = IORESOURCE_IRQ,
215 static struct platform_device omap_mcpdm_device = {
216 .name = "omap-mcpdm",
218 .num_resources = ARRAY_SIZE(mcpdm_resources),
219 .resource = mcpdm_resources,
222 static void omap_init_mcpdm(void)
224 (void) platform_device_register(&omap_mcpdm_device);
227 static inline void omap_init_mcpdm(void) {}
230 /*-------------------------------------------------------------------------*/
232 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
233 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
235 #define OMAP_MMC_NR_RES 2
238 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
240 int __init omap_mmc_add(const char *name, int id, unsigned long base,
241 unsigned long size, unsigned int irq,
242 struct omap_mmc_platform_data *data)
244 struct platform_device *pdev;
245 struct resource res[OMAP_MMC_NR_RES];
248 pdev = platform_device_alloc(name, id);
252 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
254 res[0].end = base + size - 1;
255 res[0].flags = IORESOURCE_MEM;
256 res[1].start = res[1].end = irq;
257 res[1].flags = IORESOURCE_IRQ;
259 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
261 ret = platform_device_add_data(pdev, data, sizeof(*data));
265 ret = platform_device_add(pdev);
269 /* return device handle to board setup code */
270 data->dev = &pdev->dev;
274 platform_device_put(pdev);
280 /*-------------------------------------------------------------------------*/
282 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
284 #ifdef CONFIG_ARCH_OMAP2
285 #define OMAP_RNG_BASE 0x480A0000
287 #define OMAP_RNG_BASE 0xfffe5000
290 static struct resource rng_resources[] = {
292 .start = OMAP_RNG_BASE,
293 .end = OMAP_RNG_BASE + 0x4f,
294 .flags = IORESOURCE_MEM,
298 static struct platform_device omap_rng_device = {
301 .num_resources = ARRAY_SIZE(rng_resources),
302 .resource = rng_resources,
305 static void omap_init_rng(void)
307 (void) platform_device_register(&omap_rng_device);
310 static inline void omap_init_rng(void) {}
313 /*-------------------------------------------------------------------------*/
315 /* Numbering for the SPI-capable controllers when used for SPI:
322 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
324 #define OMAP_UWIRE_BASE 0xfffb3000
326 static struct resource uwire_resources[] = {
328 .start = OMAP_UWIRE_BASE,
329 .end = OMAP_UWIRE_BASE + 0x20,
330 .flags = IORESOURCE_MEM,
334 static struct platform_device omap_uwire_device = {
335 .name = "omap_uwire",
337 .num_resources = ARRAY_SIZE(uwire_resources),
338 .resource = uwire_resources,
341 static void omap_init_uwire(void)
343 /* FIXME define and use a boot tag; not all boards will be hooking
344 * up devices to the microwire controller, and multi-board configs
345 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
348 /* board-specific code must configure chipselects (only a few
349 * are normally used) and SCLK/SDI/SDO (each has two choices).
351 (void) platform_device_register(&omap_uwire_device);
354 static inline void omap_init_uwire(void) {}
357 /*-------------------------------------------------------------------------*/
359 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
361 static struct resource wdt_resources[] = {
363 .flags = IORESOURCE_MEM,
367 static struct platform_device omap_wdt_device = {
370 .num_resources = ARRAY_SIZE(wdt_resources),
371 .resource = wdt_resources,
374 static void omap_init_wdt(void)
376 if (cpu_is_omap16xx())
377 wdt_resources[0].start = 0xfffeb000;
378 else if (cpu_is_omap2420())
379 wdt_resources[0].start = 0x48022000; /* WDT2 */
380 else if (cpu_is_omap2430())
381 wdt_resources[0].start = 0x49016000; /* WDT2 */
382 else if (cpu_is_omap343x())
383 wdt_resources[0].start = 0x48314000; /* WDT2 */
384 else if (cpu_is_omap44xx())
385 wdt_resources[0].start = 0x4a314000;
389 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
391 (void) platform_device_register(&omap_wdt_device);
394 static inline void omap_init_wdt(void) {}
398 * This gets called after board-specific INIT_MACHINE, and initializes most
399 * on-chip peripherals accessible on this board (except for few like USB):
401 * (a) Does any "standard config" pin muxing needed. Board-specific
402 * code will have muxed GPIO pins and done "nonstandard" setup;
403 * that code could live in the boot loader.
404 * (b) Populating board-specific platform_data with the data drivers
405 * rely on to handle wiring variations.
406 * (c) Creating platform devices as meaningful on this board and
407 * with this kernel configuration.
409 * Claiming GPIOs, and setting their direction and initial values, is the
410 * responsibility of the device drivers. So is responding to probe().
412 * Board-specific knowlege like creating devices or pin setup is to be
413 * kept out of drivers as much as possible. In particular, pin setup
414 * may be handled by the boot loader, and drivers should expect it will
415 * normally have been done by the time they're probed.
417 static int __init omap_init_devices(void)
419 /* please keep these calls, and their implementations above,
420 * in alphabetical order so they're easier to sort through.
430 arch_initcall(omap_init_devices);