2 * linux/arch/arm/mach-omap1/devices.c
4 * OMAP1 platform device setup/initialization
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.
12 #include <linux/dma-mapping.h>
13 #include <linux/gpio.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/spi/spi.h>
20 #include <linux/platform_data/omap-wd-timer.h>
22 #include <asm/mach/map.h>
27 #include <mach/omap7xx.h>
28 #include <mach/camera.h>
29 #include <mach/hardware.h>
31 #include "../plat-omap/sram.h"
38 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
40 static struct platform_device omap_pcm = {
41 .name = "omap-pcm-audio",
45 static void omap_init_audio(void)
47 platform_device_register(&omap_pcm);
51 static inline void omap_init_audio(void) {}
54 /*-------------------------------------------------------------------------*/
56 #if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
58 #define OMAP_RTC_BASE 0xfffb4800
60 static struct resource rtc_resources[] = {
62 .start = OMAP_RTC_BASE,
63 .end = OMAP_RTC_BASE + 0x5f,
64 .flags = IORESOURCE_MEM,
67 .start = INT_RTC_TIMER,
68 .flags = IORESOURCE_IRQ,
71 .start = INT_RTC_ALARM,
72 .flags = IORESOURCE_IRQ,
76 static struct platform_device omap_rtc_device = {
79 .num_resources = ARRAY_SIZE(rtc_resources),
80 .resource = rtc_resources,
83 static void omap_init_rtc(void)
85 (void) platform_device_register(&omap_rtc_device);
88 static inline void omap_init_rtc(void) {}
91 static inline void omap_init_mbox(void) { }
93 /*-------------------------------------------------------------------------*/
95 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
97 static inline void omap1_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
100 if (controller_nr == 0) {
101 if (cpu_is_omap7xx()) {
102 omap_cfg_reg(MMC_7XX_CMD);
103 omap_cfg_reg(MMC_7XX_CLK);
104 omap_cfg_reg(MMC_7XX_DAT0);
106 omap_cfg_reg(MMC_CMD);
107 omap_cfg_reg(MMC_CLK);
108 omap_cfg_reg(MMC_DAT0);
111 if (cpu_is_omap1710()) {
112 omap_cfg_reg(M15_1710_MMC_CLKI);
113 omap_cfg_reg(P19_1710_MMC_CMDDIR);
114 omap_cfg_reg(P20_1710_MMC_DATDIR0);
116 if (mmc_controller->slots[0].wires == 4 && !cpu_is_omap7xx()) {
117 omap_cfg_reg(MMC_DAT1);
118 /* NOTE: DAT2 can be on W10 (here) or M15 */
119 if (!mmc_controller->slots[0].nomux)
120 omap_cfg_reg(MMC_DAT2);
121 omap_cfg_reg(MMC_DAT3);
125 /* Block 2 is on newer chips, and has many pinout options */
126 if (cpu_is_omap16xx() && controller_nr == 1) {
127 if (!mmc_controller->slots[1].nomux) {
128 omap_cfg_reg(Y8_1610_MMC2_CMD);
129 omap_cfg_reg(Y10_1610_MMC2_CLK);
130 omap_cfg_reg(R18_1610_MMC2_CLKIN);
131 omap_cfg_reg(W8_1610_MMC2_DAT0);
132 if (mmc_controller->slots[1].wires == 4) {
133 omap_cfg_reg(V8_1610_MMC2_DAT1);
134 omap_cfg_reg(W15_1610_MMC2_DAT2);
135 omap_cfg_reg(R10_1610_MMC2_DAT3);
138 /* These are needed for the level shifter */
139 omap_cfg_reg(V9_1610_MMC2_CMDDIR);
140 omap_cfg_reg(V5_1610_MMC2_DATDIR0);
141 omap_cfg_reg(W19_1610_MMC2_DATDIR1);
144 /* Feedback clock must be set on OMAP-1710 MMC2 */
145 if (cpu_is_omap1710())
146 omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24),
151 #define OMAP_MMC_NR_RES 4
154 * Register MMC devices.
156 static int __init omap_mmc_add(const char *name, int id, unsigned long base,
157 unsigned long size, unsigned int irq,
158 unsigned rx_req, unsigned tx_req,
159 struct omap_mmc_platform_data *data)
161 struct platform_device *pdev;
162 struct resource res[OMAP_MMC_NR_RES];
165 pdev = platform_device_alloc(name, id);
169 memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
171 res[0].end = base + size - 1;
172 res[0].flags = IORESOURCE_MEM;
173 res[1].start = res[1].end = irq;
174 res[1].flags = IORESOURCE_IRQ;
175 res[2].start = rx_req;
177 res[2].flags = IORESOURCE_DMA;
178 res[3].start = tx_req;
180 res[3].flags = IORESOURCE_DMA;
182 if (cpu_is_omap7xx())
183 data->slots[0].features = MMC_OMAP7XX;
184 if (cpu_is_omap15xx())
185 data->slots[0].features = MMC_OMAP15XX;
186 if (cpu_is_omap16xx())
187 data->slots[0].features = MMC_OMAP16XX;
189 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
191 ret = platform_device_add_data(pdev, data, sizeof(*data));
195 ret = platform_device_add(pdev);
199 /* return device handle to board setup code */
200 data->dev = &pdev->dev;
204 platform_device_put(pdev);
208 void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
213 for (i = 0; i < nr_controllers; i++) {
214 unsigned long base, size;
215 unsigned rx_req, tx_req;
216 unsigned int irq = 0;
221 omap1_mmc_mux(mmc_data[i], i);
225 base = OMAP1_MMC1_BASE;
227 rx_req = OMAP_DMA_MMC_RX;
228 tx_req = OMAP_DMA_MMC_TX;
231 if (!cpu_is_omap16xx())
233 base = OMAP1_MMC2_BASE;
235 rx_req = OMAP_DMA_MMC2_RX;
236 tx_req = OMAP_DMA_MMC2_TX;
241 size = OMAP1_MMC_SIZE;
243 omap_mmc_add("mmci-omap", i, base, size, irq,
244 rx_req, tx_req, mmc_data[i]);
250 /*-------------------------------------------------------------------------*/
252 /* OMAP7xx SPI support */
253 #if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
255 struct platform_device omap_spi1 = {
256 .name = "omap1_spi100k",
260 struct platform_device omap_spi2 = {
261 .name = "omap1_spi100k",
265 static void omap_init_spi100k(void)
267 omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
268 if (omap_spi1.dev.platform_data)
269 platform_device_register(&omap_spi1);
271 omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
272 if (omap_spi2.dev.platform_data)
273 platform_device_register(&omap_spi2);
277 static inline void omap_init_spi100k(void)
283 #define OMAP1_CAMERA_BASE 0xfffb6800
284 #define OMAP1_CAMERA_IOSIZE 0x1c
286 static struct resource omap1_camera_resources[] = {
288 .start = OMAP1_CAMERA_BASE,
289 .end = OMAP1_CAMERA_BASE + OMAP1_CAMERA_IOSIZE - 1,
290 .flags = IORESOURCE_MEM,
294 .flags = IORESOURCE_IRQ,
298 static u64 omap1_camera_dma_mask = DMA_BIT_MASK(32);
300 static struct platform_device omap1_camera_device = {
301 .name = "omap1-camera",
302 .id = 0, /* This is used to put cameras on this interface */
304 .dma_mask = &omap1_camera_dma_mask,
305 .coherent_dma_mask = DMA_BIT_MASK(32),
307 .num_resources = ARRAY_SIZE(omap1_camera_resources),
308 .resource = omap1_camera_resources,
311 void __init omap1_camera_init(void *info)
313 struct platform_device *dev = &omap1_camera_device;
316 dev->dev.platform_data = info;
318 ret = platform_device_register(dev);
320 dev_err(&dev->dev, "unable to register device: %d\n", ret);
324 /*-------------------------------------------------------------------------*/
326 static inline void omap_init_sti(void) {}
328 /* Numbering for the SPI-capable controllers when used for SPI:
335 #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
337 #define OMAP_UWIRE_BASE 0xfffb3000
339 static struct resource uwire_resources[] = {
341 .start = OMAP_UWIRE_BASE,
342 .end = OMAP_UWIRE_BASE + 0x20,
343 .flags = IORESOURCE_MEM,
347 static struct platform_device omap_uwire_device = {
348 .name = "omap_uwire",
350 .num_resources = ARRAY_SIZE(uwire_resources),
351 .resource = uwire_resources,
354 static void omap_init_uwire(void)
356 /* FIXME define and use a boot tag; not all boards will be hooking
357 * up devices to the microwire controller, and multi-board configs
358 * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
361 /* board-specific code must configure chipselects (only a few
362 * are normally used) and SCLK/SDI/SDO (each has two choices).
364 (void) platform_device_register(&omap_uwire_device);
367 static inline void omap_init_uwire(void) {}
371 #define OMAP1_RNG_BASE 0xfffe5000
373 static struct resource omap1_rng_resources[] = {
375 .start = OMAP1_RNG_BASE,
376 .end = OMAP1_RNG_BASE + 0x4f,
377 .flags = IORESOURCE_MEM,
381 static struct platform_device omap1_rng_device = {
384 .num_resources = ARRAY_SIZE(omap1_rng_resources),
385 .resource = omap1_rng_resources,
388 static void omap1_init_rng(void)
390 if (!cpu_is_omap16xx())
393 (void) platform_device_register(&omap1_rng_device);
396 /*-------------------------------------------------------------------------*/
399 * This gets called after board-specific INIT_MACHINE, and initializes most
400 * on-chip peripherals accessible on this board (except for few like USB):
402 * (a) Does any "standard config" pin muxing needed. Board-specific
403 * code will have muxed GPIO pins and done "nonstandard" setup;
404 * that code could live in the boot loader.
405 * (b) Populating board-specific platform_data with the data drivers
406 * rely on to handle wiring variations.
407 * (c) Creating platform devices as meaningful on this board and
408 * with this kernel configuration.
410 * Claiming GPIOs, and setting their direction and initial values, is the
411 * responsibility of the device drivers. So is responding to probe().
413 * Board-specific knowledge like creating devices or pin setup is to be
414 * kept out of drivers as much as possible. In particular, pin setup
415 * may be handled by the boot loader, and drivers should expect it will
416 * normally have been done by the time they're probed.
418 static int __init omap1_init_devices(void)
420 if (!cpu_class_is_omap1())
424 omap1_clk_late_init();
426 /* please keep these calls, and their implementations above,
427 * in alphabetical order so they're easier to sort through.
440 arch_initcall(omap1_init_devices);
442 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
444 static struct resource wdt_resources[] = {
448 .flags = IORESOURCE_MEM,
452 static struct platform_device omap_wdt_device = {
455 .num_resources = ARRAY_SIZE(wdt_resources),
456 .resource = wdt_resources,
459 static int __init omap_init_wdt(void)
461 struct omap_wd_timer_platform_data pdata;
464 if (!cpu_is_omap16xx())
467 pdata.read_reset_sources = omap1_get_reset_sources;
469 ret = platform_device_register(&omap_wdt_device);
471 ret = platform_device_add_data(&omap_wdt_device, &pdata,
474 platform_device_del(&omap_wdt_device);
479 subsys_initcall(omap_init_wdt);