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/omap44xx.h>
32 /*-------------------------------------------------------------------------*/
34 #if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE)
36 static struct platform_device **omap_mcbsp_devices;
38 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
43 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
45 if (!omap_mcbsp_devices) {
46 printk(KERN_ERR "Could not register McBSP devices\n");
50 for (i = 0; i < size; i++) {
51 struct platform_device *new_mcbsp;
54 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
57 new_mcbsp->dev.platform_data = &config[i];
58 ret = platform_device_add(new_mcbsp);
60 platform_device_put(new_mcbsp);
63 omap_mcbsp_devices[i] = new_mcbsp;
68 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
73 /*-------------------------------------------------------------------------*/
75 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
76 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
78 static struct resource mcpdm_resources[] = {
81 .start = OMAP44XX_MCPDM_BASE,
82 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
83 .flags = IORESOURCE_MEM,
87 .start = OMAP44XX_IRQ_MCPDM,
88 .end = OMAP44XX_IRQ_MCPDM,
89 .flags = IORESOURCE_IRQ,
93 static struct platform_device omap_mcpdm_device = {
96 .num_resources = ARRAY_SIZE(mcpdm_resources),
97 .resource = mcpdm_resources,
100 static void omap_init_mcpdm(void)
102 (void) platform_device_register(&omap_mcpdm_device);
105 static inline void omap_init_mcpdm(void) {}
108 /*-------------------------------------------------------------------------*/
110 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
111 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
113 #define OMAP_MMC_NR_RES 2
116 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
118 int __init omap_mmc_add(const char *name, int id, unsigned long base,
119 unsigned long size, unsigned int irq,
120 struct omap_mmc_platform_data *data)
122 struct platform_device *pdev;
123 struct resource res[OMAP_MMC_NR_RES];
126 pdev = platform_device_alloc(name, id);
130 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
132 res[0].end = base + size - 1;
133 res[0].flags = IORESOURCE_MEM;
134 res[1].start = res[1].end = irq;
135 res[1].flags = IORESOURCE_IRQ;
137 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
139 ret = platform_device_add_data(pdev, data, sizeof(*data));
143 ret = platform_device_add(pdev);
147 /* return device handle to board setup code */
148 data->dev = &pdev->dev;
152 platform_device_put(pdev);
158 /*-------------------------------------------------------------------------*/
160 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
162 #ifdef CONFIG_ARCH_OMAP2
163 #define OMAP_RNG_BASE 0x480A0000
165 #define OMAP_RNG_BASE 0xfffe5000
168 static struct resource rng_resources[] = {
170 .start = OMAP_RNG_BASE,
171 .end = OMAP_RNG_BASE + 0x4f,
172 .flags = IORESOURCE_MEM,
176 static struct platform_device omap_rng_device = {
179 .num_resources = ARRAY_SIZE(rng_resources),
180 .resource = rng_resources,
183 static void omap_init_rng(void)
185 (void) platform_device_register(&omap_rng_device);
188 static inline void omap_init_rng(void) {}
191 /*-------------------------------------------------------------------------*/
193 /* Numbering for the SPI-capable controllers when used for SPI:
200 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
202 #define OMAP_UWIRE_BASE 0xfffb3000
204 static struct resource uwire_resources[] = {
206 .start = OMAP_UWIRE_BASE,
207 .end = OMAP_UWIRE_BASE + 0x20,
208 .flags = IORESOURCE_MEM,
212 static struct platform_device omap_uwire_device = {
213 .name = "omap_uwire",
215 .num_resources = ARRAY_SIZE(uwire_resources),
216 .resource = uwire_resources,
219 static void omap_init_uwire(void)
221 /* FIXME define and use a boot tag; not all boards will be hooking
222 * up devices to the microwire controller, and multi-board configs
223 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
226 /* board-specific code must configure chipselects (only a few
227 * are normally used) and SCLK/SDI/SDO (each has two choices).
229 (void) platform_device_register(&omap_uwire_device);
232 static inline void omap_init_uwire(void) {}
235 /*-------------------------------------------------------------------------*/
237 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
239 static struct resource wdt_resources[] = {
241 .flags = IORESOURCE_MEM,
245 static struct platform_device omap_wdt_device = {
248 .num_resources = ARRAY_SIZE(wdt_resources),
249 .resource = wdt_resources,
252 static void omap_init_wdt(void)
254 if (cpu_is_omap16xx())
255 wdt_resources[0].start = 0xfffeb000;
256 else if (cpu_is_omap2420())
257 wdt_resources[0].start = 0x48022000; /* WDT2 */
258 else if (cpu_is_omap2430())
259 wdt_resources[0].start = 0x49016000; /* WDT2 */
260 else if (cpu_is_omap343x())
261 wdt_resources[0].start = 0x48314000; /* WDT2 */
262 else if (cpu_is_omap44xx())
263 wdt_resources[0].start = 0x4a314000;
267 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
269 (void) platform_device_register(&omap_wdt_device);
272 static inline void omap_init_wdt(void) {}
276 * This gets called after board-specific INIT_MACHINE, and initializes most
277 * on-chip peripherals accessible on this board (except for few like USB):
279 * (a) Does any "standard config" pin muxing needed. Board-specific
280 * code will have muxed GPIO pins and done "nonstandard" setup;
281 * that code could live in the boot loader.
282 * (b) Populating board-specific platform_data with the data drivers
283 * rely on to handle wiring variations.
284 * (c) Creating platform devices as meaningful on this board and
285 * with this kernel configuration.
287 * Claiming GPIOs, and setting their direction and initial values, is the
288 * responsibility of the device drivers. So is responding to probe().
290 * Board-specific knowlege like creating devices or pin setup is to be
291 * kept out of drivers as much as possible. In particular, pin setup
292 * may be handled by the boot loader, and drivers should expect it will
293 * normally have been done by the time they're probed.
295 static int __init omap_init_devices(void)
297 /* please keep these calls, and their implementations above,
298 * in alphabetical order so they're easier to sort through.
306 arch_initcall(omap_init_devices);