ARM: OMAP1: Move omap_init_uwire to mach-omap1
[deliverable/linux.git] / arch / arm / plat-omap / devices.c
1 /*
2 * linux/arch/arm/plat-omap/devices.c
3 *
4 * Common platform device setup/initialization for OMAP1 and OMAP2
5 *
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.
10 */
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>
16 #include <linux/io.h>
17 #include <linux/slab.h>
18 #include <linux/memblock.h>
19
20 #include <mach/hardware.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/map.h>
23 #include <asm/memblock.h>
24
25 #include <plat/tc.h>
26 #include <plat/board.h>
27 #include <plat/mmc.h>
28 #include <plat/menelaus.h>
29 #include <plat/omap44xx.h>
30
31 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
32 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
33
34 #define OMAP_MMC_NR_RES 2
35
36 /*
37 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
38 */
39 int __init omap_mmc_add(const char *name, int id, unsigned long base,
40 unsigned long size, unsigned int irq,
41 struct omap_mmc_platform_data *data)
42 {
43 struct platform_device *pdev;
44 struct resource res[OMAP_MMC_NR_RES];
45 int ret;
46
47 pdev = platform_device_alloc(name, id);
48 if (!pdev)
49 return -ENOMEM;
50
51 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
52 res[0].start = base;
53 res[0].end = base + size - 1;
54 res[0].flags = IORESOURCE_MEM;
55 res[1].start = res[1].end = irq;
56 res[1].flags = IORESOURCE_IRQ;
57
58 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
59 if (ret == 0)
60 ret = platform_device_add_data(pdev, data, sizeof(*data));
61 if (ret)
62 goto fail;
63
64 ret = platform_device_add(pdev);
65 if (ret)
66 goto fail;
67
68 /* return device handle to board setup code */
69 data->dev = &pdev->dev;
70 return 0;
71
72 fail:
73 platform_device_put(pdev);
74 return ret;
75 }
76
77 #endif
78
79 /*-------------------------------------------------------------------------*/
80
81 #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
82
83 #ifdef CONFIG_ARCH_OMAP2
84 #define OMAP_RNG_BASE 0x480A0000
85 #else
86 #define OMAP_RNG_BASE 0xfffe5000
87 #endif
88
89 static struct resource rng_resources[] = {
90 {
91 .start = OMAP_RNG_BASE,
92 .end = OMAP_RNG_BASE + 0x4f,
93 .flags = IORESOURCE_MEM,
94 },
95 };
96
97 static struct platform_device omap_rng_device = {
98 .name = "omap_rng",
99 .id = -1,
100 .num_resources = ARRAY_SIZE(rng_resources),
101 .resource = rng_resources,
102 };
103
104 static void omap_init_rng(void)
105 {
106 (void) platform_device_register(&omap_rng_device);
107 }
108 #else
109 static inline void omap_init_rng(void) {}
110 #endif
111
112 #if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
113
114 static phys_addr_t omap_dsp_phys_mempool_base;
115
116 void __init omap_dsp_reserve_sdram_memblock(void)
117 {
118 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
119 phys_addr_t paddr;
120
121 if (!size)
122 return;
123
124 paddr = arm_memblock_steal(size, SZ_1M);
125 if (!paddr) {
126 pr_err("%s: failed to reserve %llx bytes\n",
127 __func__, (unsigned long long)size);
128 return;
129 }
130
131 omap_dsp_phys_mempool_base = paddr;
132 }
133
134 phys_addr_t omap_dsp_get_mempool_base(void)
135 {
136 return omap_dsp_phys_mempool_base;
137 }
138 EXPORT_SYMBOL(omap_dsp_get_mempool_base);
139 #endif
140
141 /*
142 * This gets called after board-specific INIT_MACHINE, and initializes most
143 * on-chip peripherals accessible on this board (except for few like USB):
144 *
145 * (a) Does any "standard config" pin muxing needed. Board-specific
146 * code will have muxed GPIO pins and done "nonstandard" setup;
147 * that code could live in the boot loader.
148 * (b) Populating board-specific platform_data with the data drivers
149 * rely on to handle wiring variations.
150 * (c) Creating platform devices as meaningful on this board and
151 * with this kernel configuration.
152 *
153 * Claiming GPIOs, and setting their direction and initial values, is the
154 * responsibility of the device drivers. So is responding to probe().
155 *
156 * Board-specific knowledge like creating devices or pin setup is to be
157 * kept out of drivers as much as possible. In particular, pin setup
158 * may be handled by the boot loader, and drivers should expect it will
159 * normally have been done by the time they're probed.
160 */
161 static int __init omap_init_devices(void)
162 {
163 /* please keep these calls, and their implementations above,
164 * in alphabetical order so they're easier to sort through.
165 */
166 omap_init_rng();
167 return 0;
168 }
169 arch_initcall(omap_init_devices);
This page took 0.052278 seconds and 5 git commands to generate.