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.
11 #include <linux/gpio.h>
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>
18 #include <linux/memblock.h>
20 #include <mach/hardware.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/map.h>
25 #include <plat/board.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 resource *res, int res_count,
38 struct omap_mcbsp_platform_data *config, int size)
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 platform_device_add_resources(new_mcbsp, &res[i * res_count],
58 new_mcbsp->dev.platform_data = &config[i];
59 ret = platform_device_add(new_mcbsp);
61 platform_device_put(new_mcbsp);
64 omap_mcbsp_devices[i] = new_mcbsp;
69 void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
70 struct omap_mcbsp_platform_data *config, int size)
74 /*-------------------------------------------------------------------------*/
76 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
77 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
79 static struct resource mcpdm_resources[] = {
82 .start = OMAP44XX_MCPDM_BASE,
83 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
84 .flags = IORESOURCE_MEM,
88 .start = OMAP44XX_IRQ_MCPDM,
89 .end = OMAP44XX_IRQ_MCPDM,
90 .flags = IORESOURCE_IRQ,
94 static struct platform_device omap_mcpdm_device = {
97 .num_resources = ARRAY_SIZE(mcpdm_resources),
98 .resource = mcpdm_resources,
101 static void omap_init_mcpdm(void)
103 (void) platform_device_register(&omap_mcpdm_device);
106 static inline void omap_init_mcpdm(void) {}
109 /*-------------------------------------------------------------------------*/
111 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
112 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
114 #define OMAP_MMC_NR_RES 2
117 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
119 int __init omap_mmc_add(const char *name, int id, unsigned long base,
120 unsigned long size, unsigned int irq,
121 struct omap_mmc_platform_data *data)
123 struct platform_device *pdev;
124 struct resource res[OMAP_MMC_NR_RES];
127 pdev = platform_device_alloc(name, id);
131 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
133 res[0].end = base + size - 1;
134 res[0].flags = IORESOURCE_MEM;
135 res[1].start = res[1].end = irq;
136 res[1].flags = IORESOURCE_IRQ;
138 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
140 ret = platform_device_add_data(pdev, data, sizeof(*data));
144 ret = platform_device_add(pdev);
148 /* return device handle to board setup code */
149 data->dev = &pdev->dev;
153 platform_device_put(pdev);
159 /*-------------------------------------------------------------------------*/
161 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
163 #ifdef CONFIG_ARCH_OMAP2
164 #define OMAP_RNG_BASE 0x480A0000
166 #define OMAP_RNG_BASE 0xfffe5000
169 static struct resource rng_resources[] = {
171 .start = OMAP_RNG_BASE,
172 .end = OMAP_RNG_BASE + 0x4f,
173 .flags = IORESOURCE_MEM,
177 static struct platform_device omap_rng_device = {
180 .num_resources = ARRAY_SIZE(rng_resources),
181 .resource = rng_resources,
184 static void omap_init_rng(void)
186 (void) platform_device_register(&omap_rng_device);
189 static inline void omap_init_rng(void) {}
192 /*-------------------------------------------------------------------------*/
194 /* Numbering for the SPI-capable controllers when used for SPI:
201 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
203 #define OMAP_UWIRE_BASE 0xfffb3000
205 static struct resource uwire_resources[] = {
207 .start = OMAP_UWIRE_BASE,
208 .end = OMAP_UWIRE_BASE + 0x20,
209 .flags = IORESOURCE_MEM,
213 static struct platform_device omap_uwire_device = {
214 .name = "omap_uwire",
216 .num_resources = ARRAY_SIZE(uwire_resources),
217 .resource = uwire_resources,
220 static void omap_init_uwire(void)
222 /* FIXME define and use a boot tag; not all boards will be hooking
223 * up devices to the microwire controller, and multi-board configs
224 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
227 /* board-specific code must configure chipselects (only a few
228 * are normally used) and SCLK/SDI/SDO (each has two choices).
230 (void) platform_device_register(&omap_uwire_device);
233 static inline void omap_init_uwire(void) {}
236 #if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
238 static phys_addr_t omap_dsp_phys_mempool_base;
240 void __init omap_dsp_reserve_sdram_memblock(void)
242 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
248 paddr = memblock_alloc(size, SZ_1M);
250 pr_err("%s: failed to reserve %x bytes\n",
254 memblock_free(paddr, size);
255 memblock_remove(paddr, size);
257 omap_dsp_phys_mempool_base = paddr;
260 phys_addr_t omap_dsp_get_mempool_base(void)
262 return omap_dsp_phys_mempool_base;
264 EXPORT_SYMBOL(omap_dsp_get_mempool_base);
268 * This gets called after board-specific INIT_MACHINE, and initializes most
269 * on-chip peripherals accessible on this board (except for few like USB):
271 * (a) Does any "standard config" pin muxing needed. Board-specific
272 * code will have muxed GPIO pins and done "nonstandard" setup;
273 * that code could live in the boot loader.
274 * (b) Populating board-specific platform_data with the data drivers
275 * rely on to handle wiring variations.
276 * (c) Creating platform devices as meaningful on this board and
277 * with this kernel configuration.
279 * Claiming GPIOs, and setting their direction and initial values, is the
280 * responsibility of the device drivers. So is responding to probe().
282 * Board-specific knowledge like creating devices or pin setup is to be
283 * kept out of drivers as much as possible. In particular, pin setup
284 * may be handled by the boot loader, and drivers should expect it will
285 * normally have been done by the time they're probed.
287 static int __init omap_init_devices(void)
289 /* please keep these calls, and their implementations above,
290 * in alphabetical order so they're easier to sort through.
297 arch_initcall(omap_init_devices);