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>
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 /*-------------------------------------------------------------------------*/
96 #if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE)
98 static struct platform_device **omap_mcbsp_devices;
100 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
105 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
107 if (!omap_mcbsp_devices) {
108 printk(KERN_ERR "Could not register McBSP devices\n");
112 for (i = 0; i < size; i++) {
113 struct platform_device *new_mcbsp;
116 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
119 new_mcbsp->dev.platform_data = &config[i];
120 ret = platform_device_add(new_mcbsp);
122 platform_device_put(new_mcbsp);
125 omap_mcbsp_devices[i] = new_mcbsp;
130 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
135 /*-------------------------------------------------------------------------*/
137 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
138 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
140 static struct resource mcpdm_resources[] = {
143 .start = OMAP44XX_MCPDM_BASE,
144 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
145 .flags = IORESOURCE_MEM,
149 .start = OMAP44XX_IRQ_MCPDM,
150 .end = OMAP44XX_IRQ_MCPDM,
151 .flags = IORESOURCE_IRQ,
155 static struct platform_device omap_mcpdm_device = {
156 .name = "omap-mcpdm",
158 .num_resources = ARRAY_SIZE(mcpdm_resources),
159 .resource = mcpdm_resources,
162 static void omap_init_mcpdm(void)
164 (void) platform_device_register(&omap_mcpdm_device);
167 static inline void omap_init_mcpdm(void) {}
170 /*-------------------------------------------------------------------------*/
172 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
173 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
175 #define OMAP_MMC_NR_RES 2
178 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
180 int __init omap_mmc_add(const char *name, int id, unsigned long base,
181 unsigned long size, unsigned int irq,
182 struct omap_mmc_platform_data *data)
184 struct platform_device *pdev;
185 struct resource res[OMAP_MMC_NR_RES];
188 pdev = platform_device_alloc(name, id);
192 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
194 res[0].end = base + size - 1;
195 res[0].flags = IORESOURCE_MEM;
196 res[1].start = res[1].end = irq;
197 res[1].flags = IORESOURCE_IRQ;
199 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
201 ret = platform_device_add_data(pdev, data, sizeof(*data));
205 ret = platform_device_add(pdev);
209 /* return device handle to board setup code */
210 data->dev = &pdev->dev;
214 platform_device_put(pdev);
220 /*-------------------------------------------------------------------------*/
222 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
224 #ifdef CONFIG_ARCH_OMAP2
225 #define OMAP_RNG_BASE 0x480A0000
227 #define OMAP_RNG_BASE 0xfffe5000
230 static struct resource rng_resources[] = {
232 .start = OMAP_RNG_BASE,
233 .end = OMAP_RNG_BASE + 0x4f,
234 .flags = IORESOURCE_MEM,
238 static struct platform_device omap_rng_device = {
241 .num_resources = ARRAY_SIZE(rng_resources),
242 .resource = rng_resources,
245 static void omap_init_rng(void)
247 (void) platform_device_register(&omap_rng_device);
250 static inline void omap_init_rng(void) {}
253 /*-------------------------------------------------------------------------*/
255 /* Numbering for the SPI-capable controllers when used for SPI:
262 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
264 #define OMAP_UWIRE_BASE 0xfffb3000
266 static struct resource uwire_resources[] = {
268 .start = OMAP_UWIRE_BASE,
269 .end = OMAP_UWIRE_BASE + 0x20,
270 .flags = IORESOURCE_MEM,
274 static struct platform_device omap_uwire_device = {
275 .name = "omap_uwire",
277 .num_resources = ARRAY_SIZE(uwire_resources),
278 .resource = uwire_resources,
281 static void omap_init_uwire(void)
283 /* FIXME define and use a boot tag; not all boards will be hooking
284 * up devices to the microwire controller, and multi-board configs
285 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
288 /* board-specific code must configure chipselects (only a few
289 * are normally used) and SCLK/SDI/SDO (each has two choices).
291 (void) platform_device_register(&omap_uwire_device);
294 static inline void omap_init_uwire(void) {}
297 /*-------------------------------------------------------------------------*/
299 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
301 static struct resource wdt_resources[] = {
303 .flags = IORESOURCE_MEM,
307 static struct platform_device omap_wdt_device = {
310 .num_resources = ARRAY_SIZE(wdt_resources),
311 .resource = wdt_resources,
314 static void omap_init_wdt(void)
316 if (cpu_is_omap16xx())
317 wdt_resources[0].start = 0xfffeb000;
318 else if (cpu_is_omap2420())
319 wdt_resources[0].start = 0x48022000; /* WDT2 */
320 else if (cpu_is_omap2430())
321 wdt_resources[0].start = 0x49016000; /* WDT2 */
322 else if (cpu_is_omap343x())
323 wdt_resources[0].start = 0x48314000; /* WDT2 */
324 else if (cpu_is_omap44xx())
325 wdt_resources[0].start = 0x4a314000;
329 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
331 (void) platform_device_register(&omap_wdt_device);
334 static inline void omap_init_wdt(void) {}
338 * This gets called after board-specific INIT_MACHINE, and initializes most
339 * on-chip peripherals accessible on this board (except for few like USB):
341 * (a) Does any "standard config" pin muxing needed. Board-specific
342 * code will have muxed GPIO pins and done "nonstandard" setup;
343 * that code could live in the boot loader.
344 * (b) Populating board-specific platform_data with the data drivers
345 * rely on to handle wiring variations.
346 * (c) Creating platform devices as meaningful on this board and
347 * with this kernel configuration.
349 * Claiming GPIOs, and setting their direction and initial values, is the
350 * responsibility of the device drivers. So is responding to probe().
352 * Board-specific knowlege like creating devices or pin setup is to be
353 * kept out of drivers as much as possible. In particular, pin setup
354 * may be handled by the boot loader, and drivers should expect it will
355 * normally have been done by the time they're probed.
357 static int __init omap_init_devices(void)
359 /* please keep these calls, and their implementations above,
360 * in alphabetical order so they're easier to sort through.
369 arch_initcall(omap_init_devices);