blob: bd9a06b3ee890e662077ea52dad43289b392c4a4 [file] [log] [blame]
Tony Lindgren1a8bfa12005-11-10 14:26:50 +00001/*
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
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000012#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010016#include <linux/io.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Felipe Contreras90173882010-10-04 19:09:14 +030018#include <linux/memblock.h>
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000019
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/hardware.h>
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000021#include <asm/mach-types.h>
22#include <asm/mach/map.h>
23
Tony Lindgrence491cf2009-10-20 09:40:47 -070024#include <plat/tc.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070025#include <plat/board.h>
26#include <plat/mmc.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070028#include <plat/menelaus.h>
Jorge Eduardo Candelariad6a2d9b2010-02-15 10:03:35 -080029#include <plat/omap44xx.h>
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000030
Jorge Eduardo Candelariad6a2d9b2010-02-15 10:03:35 -080031#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
32 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
33
34static struct resource mcpdm_resources[] = {
35 {
36 .name = "mcpdm_mem",
37 .start = OMAP44XX_MCPDM_BASE,
38 .end = OMAP44XX_MCPDM_BASE + SZ_4K,
39 .flags = IORESOURCE_MEM,
40 },
41 {
42 .name = "mcpdm_irq",
Santosh Shilimkar5772ca72010-02-18 03:14:12 +053043 .start = OMAP44XX_IRQ_MCPDM,
44 .end = OMAP44XX_IRQ_MCPDM,
Jorge Eduardo Candelariad6a2d9b2010-02-15 10:03:35 -080045 .flags = IORESOURCE_IRQ,
46 },
47};
48
49static struct platform_device omap_mcpdm_device = {
50 .name = "omap-mcpdm",
51 .id = -1,
52 .num_resources = ARRAY_SIZE(mcpdm_resources),
53 .resource = mcpdm_resources,
54};
55
56static void omap_init_mcpdm(void)
57{
58 (void) platform_device_register(&omap_mcpdm_device);
59}
60#else
61static inline void omap_init_mcpdm(void) {}
62#endif
63
64/*-------------------------------------------------------------------------*/
65
Tony Lindgrend8874662008-12-10 17:37:16 -080066#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
Russell King7736c092008-09-09 10:16:22 +010067 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000068
Tony Lindgrend8874662008-12-10 17:37:16 -080069#define OMAP_MMC_NR_RES 2
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000070
Tony Lindgrend8874662008-12-10 17:37:16 -080071/*
72 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
73 */
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080074int __init omap_mmc_add(const char *name, int id, unsigned long base,
75 unsigned long size, unsigned int irq,
76 struct omap_mmc_platform_data *data)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000077{
Tony Lindgrend8874662008-12-10 17:37:16 -080078 struct platform_device *pdev;
79 struct resource res[OMAP_MMC_NR_RES];
80 int ret;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000081
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080082 pdev = platform_device_alloc(name, id);
Tony Lindgrend8874662008-12-10 17:37:16 -080083 if (!pdev)
84 return -ENOMEM;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000085
Tony Lindgrend8874662008-12-10 17:37:16 -080086 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
87 res[0].start = base;
88 res[0].end = base + size - 1;
89 res[0].flags = IORESOURCE_MEM;
90 res[1].start = res[1].end = irq;
91 res[1].flags = IORESOURCE_IRQ;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000092
Tony Lindgrend8874662008-12-10 17:37:16 -080093 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
94 if (ret == 0)
95 ret = platform_device_add_data(pdev, data, sizeof(*data));
96 if (ret)
97 goto fail;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000098
Tony Lindgrend8874662008-12-10 17:37:16 -080099 ret = platform_device_add(pdev);
100 if (ret)
101 goto fail;
David Brownell01971f62009-03-23 18:23:47 -0700102
103 /* return device handle to board setup code */
104 data->dev = &pdev->dev;
Tony Lindgrend8874662008-12-10 17:37:16 -0800105 return 0;
106
107fail:
108 platform_device_put(pdev);
109 return ret;
Russell King7736c092008-09-09 10:16:22 +0100110}
111
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000112#endif
113
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100114/*-------------------------------------------------------------------------*/
115
Ladislav Michl3bfe8972009-12-11 16:16:36 -0800116#if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
117
Tony Lindgren088ef952010-02-12 12:26:47 -0800118#ifdef CONFIG_ARCH_OMAP2
Ladislav Michl3bfe8972009-12-11 16:16:36 -0800119#define OMAP_RNG_BASE 0x480A0000
120#else
121#define OMAP_RNG_BASE 0xfffe5000
122#endif
123
124static struct resource rng_resources[] = {
125 {
126 .start = OMAP_RNG_BASE,
127 .end = OMAP_RNG_BASE + 0x4f,
128 .flags = IORESOURCE_MEM,
129 },
130};
131
132static struct platform_device omap_rng_device = {
133 .name = "omap_rng",
134 .id = -1,
135 .num_resources = ARRAY_SIZE(rng_resources),
136 .resource = rng_resources,
137};
138
139static void omap_init_rng(void)
140{
141 (void) platform_device_register(&omap_rng_device);
142}
143#else
144static inline void omap_init_rng(void) {}
145#endif
146
147/*-------------------------------------------------------------------------*/
148
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100149/* Numbering for the SPI-capable controllers when used for SPI:
150 * spi = 1
151 * uwire = 2
152 * mmc1..2 = 3..4
153 * mcbsp1..3 = 5..7
154 */
155
156#if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
157
158#define OMAP_UWIRE_BASE 0xfffb3000
159
160static struct resource uwire_resources[] = {
161 {
162 .start = OMAP_UWIRE_BASE,
163 .end = OMAP_UWIRE_BASE + 0x20,
164 .flags = IORESOURCE_MEM,
165 },
166};
167
168static struct platform_device omap_uwire_device = {
169 .name = "omap_uwire",
170 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100171 .num_resources = ARRAY_SIZE(uwire_resources),
172 .resource = uwire_resources,
173};
174
175static void omap_init_uwire(void)
176{
177 /* FIXME define and use a boot tag; not all boards will be hooking
178 * up devices to the microwire controller, and multi-board configs
179 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
180 */
181
182 /* board-specific code must configure chipselects (only a few
183 * are normally used) and SCLK/SDI/SDO (each has two choices).
184 */
185 (void) platform_device_register(&omap_uwire_device);
186}
187#else
188static inline void omap_init_uwire(void) {}
189#endif
190
Felipe Contreras90173882010-10-04 19:09:14 +0300191#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
192
193static phys_addr_t omap_dsp_phys_mempool_base;
194
195void __init omap_dsp_reserve_sdram_memblock(void)
196{
197 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
198 phys_addr_t paddr;
199
200 if (!size)
201 return;
202
Felipe Contreras89346f92010-10-19 10:37:24 +0300203 paddr = memblock_alloc(size, SZ_1M);
Felipe Contreras90173882010-10-04 19:09:14 +0300204 if (!paddr) {
205 pr_err("%s: failed to reserve %x bytes\n",
206 __func__, size);
207 return;
208 }
Felipe Contreras89346f92010-10-19 10:37:24 +0300209 memblock_free(paddr, size);
210 memblock_remove(paddr, size);
Felipe Contreras90173882010-10-04 19:09:14 +0300211
212 omap_dsp_phys_mempool_base = paddr;
213}
214
215phys_addr_t omap_dsp_get_mempool_base(void)
216{
217 return omap_dsp_phys_mempool_base;
218}
219EXPORT_SYMBOL(omap_dsp_get_mempool_base);
220#endif
221
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000222/*
223 * This gets called after board-specific INIT_MACHINE, and initializes most
224 * on-chip peripherals accessible on this board (except for few like USB):
225 *
226 * (a) Does any "standard config" pin muxing needed. Board-specific
227 * code will have muxed GPIO pins and done "nonstandard" setup;
228 * that code could live in the boot loader.
229 * (b) Populating board-specific platform_data with the data drivers
230 * rely on to handle wiring variations.
231 * (c) Creating platform devices as meaningful on this board and
232 * with this kernel configuration.
233 *
234 * Claiming GPIOs, and setting their direction and initial values, is the
235 * responsibility of the device drivers. So is responding to probe().
236 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300237 * Board-specific knowledge like creating devices or pin setup is to be
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000238 * kept out of drivers as much as possible. In particular, pin setup
239 * may be handled by the boot loader, and drivers should expect it will
240 * normally have been done by the time they're probed.
241 */
242static int __init omap_init_devices(void)
243{
244 /* please keep these calls, and their implementations above,
245 * in alphabetical order so they're easier to sort through.
246 */
Ladislav Michl3bfe8972009-12-11 16:16:36 -0800247 omap_init_rng();
Jorge Eduardo Candelariad6a2d9b2010-02-15 10:03:35 -0800248 omap_init_mcpdm();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100249 omap_init_uwire();
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000250 return 0;
251}
252arch_initcall(omap_init_devices);