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/board.h>
26 #include <mach/gpio.h>
27 #include <plat/menelaus.h>
28 #include <plat/mcbsp.h>
29 #include <plat/omap44xx.h>
31 /*-------------------------------------------------------------------------*/
33 #if defined(CONFIG_OMAP_MCBSP) || defined(CONFIG_OMAP_MCBSP_MODULE)
35 static struct platform_device **omap_mcbsp_devices;
37 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
42 omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
44 if (!omap_mcbsp_devices) {
45 printk(KERN_ERR "Could not register McBSP devices\n");
49 for (i = 0; i < size; i++) {
50 struct platform_device *new_mcbsp;
53 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
56 new_mcbsp->dev.platform_data = &config[i];
57 ret = platform_device_add(new_mcbsp);
59 platform_device_put(new_mcbsp);
62 omap_mcbsp_devices[i] = new_mcbsp;
67 void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
72 /*-------------------------------------------------------------------------*/
74 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
75 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
77 static struct resource mcpdm_resources[] = {
80 .start = OMAP44XX_MCPDM_BASE,
81 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
82 .flags = IORESOURCE_MEM,
86 .start = OMAP44XX_IRQ_MCPDM,
87 .end = OMAP44XX_IRQ_MCPDM,
88 .flags = IORESOURCE_IRQ,
92 static struct platform_device omap_mcpdm_device = {
95 .num_resources = ARRAY_SIZE(mcpdm_resources),
96 .resource = mcpdm_resources,
99 static void omap_init_mcpdm(void)
101 (void) platform_device_register(&omap_mcpdm_device);
104 static inline void omap_init_mcpdm(void) {}
107 /*-------------------------------------------------------------------------*/
109 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
110 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
112 #define OMAP_MMC_NR_RES 2
115 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
117 int __init omap_mmc_add(const char *name, int id, unsigned long base,
118 unsigned long size, unsigned int irq,
119 struct omap_mmc_platform_data *data)
121 struct platform_device *pdev;
122 struct resource res[OMAP_MMC_NR_RES];
125 pdev = platform_device_alloc(name, id);
129 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
131 res[0].end = base + size - 1;
132 res[0].flags = IORESOURCE_MEM;
133 res[1].start = res[1].end = irq;
134 res[1].flags = IORESOURCE_IRQ;
136 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
138 ret = platform_device_add_data(pdev, data, sizeof(*data));
142 ret = platform_device_add(pdev);
146 /* return device handle to board setup code */
147 data->dev = &pdev->dev;
151 platform_device_put(pdev);
157 /*-------------------------------------------------------------------------*/
159 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
161 #ifdef CONFIG_ARCH_OMAP2
162 #define OMAP_RNG_BASE 0x480A0000
164 #define OMAP_RNG_BASE 0xfffe5000
167 static struct resource rng_resources[] = {
169 .start = OMAP_RNG_BASE,
170 .end = OMAP_RNG_BASE + 0x4f,
171 .flags = IORESOURCE_MEM,
175 static struct platform_device omap_rng_device = {
178 .num_resources = ARRAY_SIZE(rng_resources),
179 .resource = rng_resources,
182 static void omap_init_rng(void)
184 (void) platform_device_register(&omap_rng_device);
187 static inline void omap_init_rng(void) {}
190 /*-------------------------------------------------------------------------*/
192 /* Numbering for the SPI-capable controllers when used for SPI:
199 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
201 #define OMAP_UWIRE_BASE 0xfffb3000
203 static struct resource uwire_resources[] = {
205 .start = OMAP_UWIRE_BASE,
206 .end = OMAP_UWIRE_BASE + 0x20,
207 .flags = IORESOURCE_MEM,
211 static struct platform_device omap_uwire_device = {
212 .name = "omap_uwire",
214 .num_resources = ARRAY_SIZE(uwire_resources),
215 .resource = uwire_resources,
218 static void omap_init_uwire(void)
220 /* FIXME define and use a boot tag; not all boards will be hooking
221 * up devices to the microwire controller, and multi-board configs
222 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
225 /* board-specific code must configure chipselects (only a few
226 * are normally used) and SCLK/SDI/SDO (each has two choices).
228 (void) platform_device_register(&omap_uwire_device);
231 static inline void omap_init_uwire(void) {}
235 * This gets called after board-specific INIT_MACHINE, and initializes most
236 * on-chip peripherals accessible on this board (except for few like USB):
238 * (a) Does any "standard config" pin muxing needed. Board-specific
239 * code will have muxed GPIO pins and done "nonstandard" setup;
240 * that code could live in the boot loader.
241 * (b) Populating board-specific platform_data with the data drivers
242 * rely on to handle wiring variations.
243 * (c) Creating platform devices as meaningful on this board and
244 * with this kernel configuration.
246 * Claiming GPIOs, and setting their direction and initial values, is the
247 * responsibility of the device drivers. So is responding to probe().
249 * Board-specific knowlege like creating devices or pin setup is to be
250 * kept out of drivers as much as possible. In particular, pin setup
251 * may be handled by the boot loader, and drivers should expect it will
252 * normally have been done by the time they're probed.
254 static int __init omap_init_devices(void)
256 /* please keep these calls, and their implementations above,
257 * in alphabetical order so they're easier to sort through.
264 arch_initcall(omap_init_devices);