blob: 60278f47c0bdd71953cc5c1483a68a7a02a0b50f [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>
Russell King716a3dc2012-01-13 15:00:51 +000023#include <asm/memblock.h>
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000024
Tony Lindgrence491cf2009-10-20 09:40:47 -070025#include <plat/tc.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070026#include <plat/board.h>
27#include <plat/mmc.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
Tony Lindgrend8874662008-12-10 17:37:16 -080031#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
Russell King7736c092008-09-09 10:16:22 +010032 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000033
Tony Lindgrend8874662008-12-10 17:37:16 -080034#define OMAP_MMC_NR_RES 2
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000035
Tony Lindgrend8874662008-12-10 17:37:16 -080036/*
37 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
38 */
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080039int __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)
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000042{
Tony Lindgrend8874662008-12-10 17:37:16 -080043 struct platform_device *pdev;
44 struct resource res[OMAP_MMC_NR_RES];
45 int ret;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000046
Tony Lindgren0dffb5c2009-01-29 08:57:16 -080047 pdev = platform_device_alloc(name, id);
Tony Lindgrend8874662008-12-10 17:37:16 -080048 if (!pdev)
49 return -ENOMEM;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000050
Tony Lindgrend8874662008-12-10 17:37:16 -080051 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;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000057
Tony Lindgrend8874662008-12-10 17:37:16 -080058 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;
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000063
Tony Lindgrend8874662008-12-10 17:37:16 -080064 ret = platform_device_add(pdev);
65 if (ret)
66 goto fail;
David Brownell01971f62009-03-23 18:23:47 -070067
68 /* return device handle to board setup code */
69 data->dev = &pdev->dev;
Tony Lindgrend8874662008-12-10 17:37:16 -080070 return 0;
71
72fail:
73 platform_device_put(pdev);
74 return ret;
Russell King7736c092008-09-09 10:16:22 +010075}
76
Tony Lindgren1a8bfa12005-11-10 14:26:50 +000077#endif
78
Tony Lindgren9b6553c2006-04-02 17:46:30 +010079/*-------------------------------------------------------------------------*/
80
Ladislav Michl3bfe8972009-12-11 16:16:36 -080081#if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
82
Tony Lindgren088ef952010-02-12 12:26:47 -080083#ifdef CONFIG_ARCH_OMAP2
Ladislav Michl3bfe8972009-12-11 16:16:36 -080084#define OMAP_RNG_BASE 0x480A0000
85#else
86#define OMAP_RNG_BASE 0xfffe5000
87#endif
88
89static struct resource rng_resources[] = {
90 {
91 .start = OMAP_RNG_BASE,
92 .end = OMAP_RNG_BASE + 0x4f,
93 .flags = IORESOURCE_MEM,
94 },
95};
96
97static 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
104static void omap_init_rng(void)
105{
106 (void) platform_device_register(&omap_rng_device);
107}
108#else
109static inline void omap_init_rng(void) {}
110#endif
111
112/*-------------------------------------------------------------------------*/
113
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100114/* Numbering for the SPI-capable controllers when used for SPI:
115 * spi = 1
116 * uwire = 2
117 * mmc1..2 = 3..4
118 * mcbsp1..3 = 5..7
119 */
120
121#if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
122
123#define OMAP_UWIRE_BASE 0xfffb3000
124
125static struct resource uwire_resources[] = {
126 {
127 .start = OMAP_UWIRE_BASE,
128 .end = OMAP_UWIRE_BASE + 0x20,
129 .flags = IORESOURCE_MEM,
130 },
131};
132
133static struct platform_device omap_uwire_device = {
134 .name = "omap_uwire",
135 .id = -1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100136 .num_resources = ARRAY_SIZE(uwire_resources),
137 .resource = uwire_resources,
138};
139
140static void omap_init_uwire(void)
141{
142 /* FIXME define and use a boot tag; not all boards will be hooking
143 * up devices to the microwire controller, and multi-board configs
144 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
145 */
146
147 /* board-specific code must configure chipselects (only a few
148 * are normally used) and SCLK/SDI/SDO (each has two choices).
149 */
150 (void) platform_device_register(&omap_uwire_device);
151}
152#else
153static inline void omap_init_uwire(void) {}
154#endif
155
Felipe Contreras90173882010-10-04 19:09:14 +0300156#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
157
158static phys_addr_t omap_dsp_phys_mempool_base;
159
160void __init omap_dsp_reserve_sdram_memblock(void)
161{
162 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
163 phys_addr_t paddr;
164
165 if (!size)
166 return;
167
Russell King716a3dc2012-01-13 15:00:51 +0000168 paddr = arm_memblock_steal(size, SZ_1M);
Felipe Contreras90173882010-10-04 19:09:14 +0300169 if (!paddr) {
170 pr_err("%s: failed to reserve %x bytes\n",
171 __func__, size);
172 return;
173 }
174
175 omap_dsp_phys_mempool_base = paddr;
176}
177
178phys_addr_t omap_dsp_get_mempool_base(void)
179{
180 return omap_dsp_phys_mempool_base;
181}
182EXPORT_SYMBOL(omap_dsp_get_mempool_base);
183#endif
184
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000185/*
186 * This gets called after board-specific INIT_MACHINE, and initializes most
187 * on-chip peripherals accessible on this board (except for few like USB):
188 *
189 * (a) Does any "standard config" pin muxing needed. Board-specific
190 * code will have muxed GPIO pins and done "nonstandard" setup;
191 * that code could live in the boot loader.
192 * (b) Populating board-specific platform_data with the data drivers
193 * rely on to handle wiring variations.
194 * (c) Creating platform devices as meaningful on this board and
195 * with this kernel configuration.
196 *
197 * Claiming GPIOs, and setting their direction and initial values, is the
198 * responsibility of the device drivers. So is responding to probe().
199 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300200 * Board-specific knowledge like creating devices or pin setup is to be
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000201 * kept out of drivers as much as possible. In particular, pin setup
202 * may be handled by the boot loader, and drivers should expect it will
203 * normally have been done by the time they're probed.
204 */
205static int __init omap_init_devices(void)
206{
207 /* please keep these calls, and their implementations above,
208 * in alphabetical order so they're easier to sort through.
209 */
Ladislav Michl3bfe8972009-12-11 16:16:36 -0800210 omap_init_rng();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100211 omap_init_uwire();
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000212 return 0;
213}
214arch_initcall(omap_init_devices);