blob: 19719329a47b0fb96a4b75e42f8103f505c00c84 [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 */
Russell King2f8163b2011-07-26 10:53:52 +010011#include <linux/gpio.h>
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>
Tony Lindgrence491cf2009-10-20 09:40:47 -070027#include <plat/menelaus.h>
Jorge Eduardo Candelariad6a2d9b2010-02-15 10:03:35 -080028#include <plat/omap44xx.h>
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000029
Tony Lindgrend8874662008-12-10 17:37:16 -080030#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
Russell King7736c092008-09-09 10:16:22 +010031 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000032
Tony Lindgrend8874662008-12-10 17:37:16 -080033#define OMAP_MMC_NR_RES 2
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000034
Tony Lindgrend8874662008-12-10 17:37:16 -080035/*
36 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
37 */
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080038int __init omap_mmc_add(const char *name, int id, unsigned long base,
39 unsigned long size, unsigned int irq,
40 struct omap_mmc_platform_data *data)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000041{
Tony Lindgrend8874662008-12-10 17:37:16 -080042 struct platform_device *pdev;
43 struct resource res[OMAP_MMC_NR_RES];
44 int ret;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000045
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080046 pdev = platform_device_alloc(name, id);
Tony Lindgrend8874662008-12-10 17:37:16 -080047 if (!pdev)
48 return -ENOMEM;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000049
Tony Lindgrend8874662008-12-10 17:37:16 -080050 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
51 res[0].start = base;
52 res[0].end = base + size - 1;
53 res[0].flags = IORESOURCE_MEM;
54 res[1].start = res[1].end = irq;
55 res[1].flags = IORESOURCE_IRQ;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000056
Tony Lindgrend8874662008-12-10 17:37:16 -080057 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
58 if (ret == 0)
59 ret = platform_device_add_data(pdev, data, sizeof(*data));
60 if (ret)
61 goto fail;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000062
Tony Lindgrend8874662008-12-10 17:37:16 -080063 ret = platform_device_add(pdev);
64 if (ret)
65 goto fail;
David Brownell01971f62009-03-23 18:23:47 -070066
67 /* return device handle to board setup code */
68 data->dev = &pdev->dev;
Tony Lindgrend8874662008-12-10 17:37:16 -080069 return 0;
70
71fail:
72 platform_device_put(pdev);
73 return ret;
Russell King7736c092008-09-09 10:16:22 +010074}
75
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000076#endif
77
Tony Lindgren9b6553c2006-04-02 17:46:30 +010078/*-------------------------------------------------------------------------*/
79
Ladislav Michl3bfe8972009-12-11 16:16:36 -080080#if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
81
Tony Lindgren088ef952010-02-12 12:26:47 -080082#ifdef CONFIG_ARCH_OMAP2
Ladislav Michl3bfe8972009-12-11 16:16:36 -080083#define OMAP_RNG_BASE 0x480A0000
84#else
85#define OMAP_RNG_BASE 0xfffe5000
86#endif
87
88static struct resource rng_resources[] = {
89 {
90 .start = OMAP_RNG_BASE,
91 .end = OMAP_RNG_BASE + 0x4f,
92 .flags = IORESOURCE_MEM,
93 },
94};
95
96static struct platform_device omap_rng_device = {
97 .name = "omap_rng",
98 .id = -1,
99 .num_resources = ARRAY_SIZE(rng_resources),
100 .resource = rng_resources,
101};
102
103static void omap_init_rng(void)
104{
105 (void) platform_device_register(&omap_rng_device);
106}
107#else
108static inline void omap_init_rng(void) {}
109#endif
110
111/*-------------------------------------------------------------------------*/
112
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100113/* Numbering for the SPI-capable controllers when used for SPI:
114 * spi = 1
115 * uwire = 2
116 * mmc1..2 = 3..4
117 * mcbsp1..3 = 5..7
118 */
119
120#if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
121
122#define OMAP_UWIRE_BASE 0xfffb3000
123
124static struct resource uwire_resources[] = {
125 {
126 .start = OMAP_UWIRE_BASE,
127 .end = OMAP_UWIRE_BASE + 0x20,
128 .flags = IORESOURCE_MEM,
129 },
130};
131
132static struct platform_device omap_uwire_device = {
133 .name = "omap_uwire",
134 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100135 .num_resources = ARRAY_SIZE(uwire_resources),
136 .resource = uwire_resources,
137};
138
139static void omap_init_uwire(void)
140{
141 /* FIXME define and use a boot tag; not all boards will be hooking
142 * up devices to the microwire controller, and multi-board configs
143 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
144 */
145
146 /* board-specific code must configure chipselects (only a few
147 * are normally used) and SCLK/SDI/SDO (each has two choices).
148 */
149 (void) platform_device_register(&omap_uwire_device);
150}
151#else
152static inline void omap_init_uwire(void) {}
153#endif
154
Felipe Contreras90173882010-10-04 19:09:14 +0300155#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
156
157static phys_addr_t omap_dsp_phys_mempool_base;
158
159void __init omap_dsp_reserve_sdram_memblock(void)
160{
161 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
162 phys_addr_t paddr;
163
164 if (!size)
165 return;
166
Felipe Contreras89346f92010-10-19 10:37:24 +0300167 paddr = memblock_alloc(size, SZ_1M);
Felipe Contreras90173882010-10-04 19:09:14 +0300168 if (!paddr) {
169 pr_err("%s: failed to reserve %x bytes\n",
170 __func__, size);
171 return;
172 }
Felipe Contreras89346f92010-10-19 10:37:24 +0300173 memblock_free(paddr, size);
174 memblock_remove(paddr, size);
Felipe Contreras90173882010-10-04 19:09:14 +0300175
176 omap_dsp_phys_mempool_base = paddr;
177}
178
179phys_addr_t omap_dsp_get_mempool_base(void)
180{
181 return omap_dsp_phys_mempool_base;
182}
183EXPORT_SYMBOL(omap_dsp_get_mempool_base);
184#endif
185
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000186/*
187 * This gets called after board-specific INIT_MACHINE, and initializes most
188 * on-chip peripherals accessible on this board (except for few like USB):
189 *
190 * (a) Does any "standard config" pin muxing needed. Board-specific
191 * code will have muxed GPIO pins and done "nonstandard" setup;
192 * that code could live in the boot loader.
193 * (b) Populating board-specific platform_data with the data drivers
194 * rely on to handle wiring variations.
195 * (c) Creating platform devices as meaningful on this board and
196 * with this kernel configuration.
197 *
198 * Claiming GPIOs, and setting their direction and initial values, is the
199 * responsibility of the device drivers. So is responding to probe().
200 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300201 * Board-specific knowledge like creating devices or pin setup is to be
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000202 * kept out of drivers as much as possible. In particular, pin setup
203 * may be handled by the boot loader, and drivers should expect it will
204 * normally have been done by the time they're probed.
205 */
206static int __init omap_init_devices(void)
207{
208 /* please keep these calls, and their implementations above,
209 * in alphabetical order so they're easier to sort through.
210 */
Ladislav Michl3bfe8972009-12-11 16:16:36 -0800211 omap_init_rng();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100212 omap_init_uwire();
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000213 return 0;
214}
215arch_initcall(omap_init_devices);