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/config.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
18 #include <asm/hardware.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/map.h>
23 #include <asm/arch/tc.h>
24 #include <asm/arch/board.h>
25 #include <asm/arch/mux.h>
26 #include <asm/arch/gpio.h>
29 static void omap_nop_release(struct device *dev)
34 /*-------------------------------------------------------------------------*/
36 #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
38 #define OMAP_I2C_BASE 0xfffb3800
40 static struct resource i2c_resources[] = {
42 .start = OMAP_I2C_BASE,
43 .end = OMAP_I2C_BASE + 0x3f,
44 .flags = IORESOURCE_MEM,
48 .flags = IORESOURCE_IRQ,
52 /* DMA not used; works around erratum writing to non-empty i2c fifo */
54 static struct platform_device omap_i2c_device = {
58 .release = omap_nop_release,
60 .num_resources = ARRAY_SIZE(i2c_resources),
61 .resource = i2c_resources,
64 static void omap_init_i2c(void)
66 /* FIXME define and use a boot tag, in case of boards that
67 * either don't wire up I2C, or chips that mux it differently...
68 * it can include clocking and address info, maybe more.
70 omap_cfg_reg(I2C_SCL);
71 omap_cfg_reg(I2C_SDA);
73 (void) platform_device_register(&omap_i2c_device);
76 static inline void omap_init_i2c(void) {}
79 /*-------------------------------------------------------------------------*/
81 #if defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE)
83 static u64 irda_dmamask = 0xffffffff;
85 static struct platform_device omap1610ir_device = {
86 .name = "omap1610-ir",
89 .release = omap_nop_release,
90 .dma_mask = &irda_dmamask,
94 static void omap_init_irda(void)
96 /* FIXME define and use a boot tag, members something like:
97 * u8 uart; // uart1, or uart3
98 * ... but driver only handles uart3 for now
99 * s16 fir_sel; // gpio for SIR vs FIR
100 * ... may prefer a callback for SIR/MIR/FIR mode select;
101 * while h2 uses a GPIO, H3 uses a gpio expander
103 if (machine_is_omap_h2()
104 || machine_is_omap_h3())
105 (void) platform_device_register(&omap1610ir_device);
108 static inline void omap_init_irda(void) {}
111 /*-------------------------------------------------------------------------*/
113 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
115 #define OMAP_MMC1_BASE 0xfffb7800
116 #define OMAP_MMC2_BASE 0xfffb7c00 /* omap16xx only */
118 static struct omap_mmc_conf mmc1_conf;
120 static u64 mmc1_dmamask = 0xffffffff;
122 static struct resource mmc1_resources[] = {
124 .start = IO_ADDRESS(OMAP_MMC1_BASE),
125 .end = IO_ADDRESS(OMAP_MMC1_BASE) + 0x7f,
126 .flags = IORESOURCE_MEM,
130 .flags = IORESOURCE_IRQ,
134 static struct platform_device mmc_omap_device1 = {
138 .release = omap_nop_release,
139 .dma_mask = &mmc1_dmamask,
140 .platform_data = &mmc1_conf,
142 .num_resources = ARRAY_SIZE(mmc1_resources),
143 .resource = mmc1_resources,
146 #ifdef CONFIG_ARCH_OMAP16XX
148 static struct omap_mmc_conf mmc2_conf;
150 static u64 mmc2_dmamask = 0xffffffff;
152 static struct resource mmc2_resources[] = {
154 .start = IO_ADDRESS(OMAP_MMC2_BASE),
155 .end = IO_ADDRESS(OMAP_MMC2_BASE) + 0x7f,
156 .flags = IORESOURCE_MEM,
159 .start = INT_1610_MMC2,
160 .flags = IORESOURCE_IRQ,
164 static struct platform_device mmc_omap_device2 = {
168 .release = omap_nop_release,
169 .dma_mask = &mmc2_dmamask,
170 .platform_data = &mmc2_conf,
172 .num_resources = ARRAY_SIZE(mmc2_resources),
173 .resource = mmc2_resources,
177 static void __init omap_init_mmc(void)
179 const struct omap_mmc_config *mmc_conf;
180 const struct omap_mmc_conf *mmc;
182 /* NOTE: assumes MMC was never (wrongly) enabled */
183 mmc_conf = omap_get_config(OMAP_TAG_MMC, struct omap_mmc_config);
187 /* block 1 is always available and has just one pinout option */
188 mmc = &mmc_conf->mmc[0];
190 omap_cfg_reg(MMC_CMD);
191 omap_cfg_reg(MMC_CLK);
192 omap_cfg_reg(MMC_DAT0);
193 if (cpu_is_omap1710()) {
194 omap_cfg_reg(M15_1710_MMC_CLKI);
195 omap_cfg_reg(P19_1710_MMC_CMDDIR);
196 omap_cfg_reg(P20_1710_MMC_DATDIR0);
199 omap_cfg_reg(MMC_DAT1);
200 /* NOTE: DAT2 can be on W10 (here) or M15 */
202 omap_cfg_reg(MMC_DAT2);
203 omap_cfg_reg(MMC_DAT3);
206 (void) platform_device_register(&mmc_omap_device1);
209 #ifdef CONFIG_ARCH_OMAP16XX
210 /* block 2 is on newer chips, and has many pinout options */
211 mmc = &mmc_conf->mmc[1];
214 omap_cfg_reg(Y8_1610_MMC2_CMD);
215 omap_cfg_reg(Y10_1610_MMC2_CLK);
216 omap_cfg_reg(R18_1610_MMC2_CLKIN);
217 omap_cfg_reg(W8_1610_MMC2_DAT0);
219 omap_cfg_reg(V8_1610_MMC2_DAT1);
220 omap_cfg_reg(W15_1610_MMC2_DAT2);
221 omap_cfg_reg(R10_1610_MMC2_DAT3);
224 /* These are needed for the level shifter */
225 omap_cfg_reg(V9_1610_MMC2_CMDDIR);
226 omap_cfg_reg(V5_1610_MMC2_DATDIR0);
227 omap_cfg_reg(W19_1610_MMC2_DATDIR1);
230 /* Feedback clock must be set on OMAP-1710 MMC2 */
231 if (cpu_is_omap1710())
232 omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24),
235 (void) platform_device_register(&mmc_omap_device2);
241 static inline void omap_init_mmc(void) {}
244 #if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC)
246 #define OMAP_RTC_BASE 0xfffb4800
248 static struct resource rtc_resources[] = {
250 .start = OMAP_RTC_BASE,
251 .end = OMAP_RTC_BASE + 0x5f,
252 .flags = IORESOURCE_MEM,
255 .start = INT_RTC_TIMER,
256 .flags = IORESOURCE_IRQ,
259 .start = INT_RTC_ALARM,
260 .flags = IORESOURCE_IRQ,
264 static struct platform_device omap_rtc_device = {
268 .release = omap_nop_release,
270 .num_resources = ARRAY_SIZE(rtc_resources),
271 .resource = rtc_resources,
274 static void omap_init_rtc(void)
276 (void) platform_device_register(&omap_rtc_device);
279 static inline void omap_init_rtc(void) {}
282 /*-------------------------------------------------------------------------*/
284 #if defined(CONFIG_OMAP16XX_WATCHDOG) || defined(CONFIG_OMAP16XX_WATCHDOG_MODULE)
286 #define OMAP_WDT_BASE 0xfffeb000
288 static struct resource wdt_resources[] = {
290 .start = OMAP_WDT_BASE,
291 .end = OMAP_WDT_BASE + 0x4f,
292 .flags = IORESOURCE_MEM,
296 static struct platform_device omap_wdt_device = {
297 .name = "omap1610_wdt",
300 .release = omap_nop_release,
302 .num_resources = ARRAY_SIZE(wdt_resources),
303 .resource = wdt_resources,
306 static void omap_init_wdt(void)
308 (void) platform_device_register(&omap_wdt_device);
311 static inline void omap_init_wdt(void) {}
315 /*-------------------------------------------------------------------------*/
318 * This gets called after board-specific INIT_MACHINE, and initializes most
319 * on-chip peripherals accessible on this board (except for few like USB):
321 * (a) Does any "standard config" pin muxing needed. Board-specific
322 * code will have muxed GPIO pins and done "nonstandard" setup;
323 * that code could live in the boot loader.
324 * (b) Populating board-specific platform_data with the data drivers
325 * rely on to handle wiring variations.
326 * (c) Creating platform devices as meaningful on this board and
327 * with this kernel configuration.
329 * Claiming GPIOs, and setting their direction and initial values, is the
330 * responsibility of the device drivers. So is responding to probe().
332 * Board-specific knowlege like creating devices or pin setup is to be
333 * kept out of drivers as much as possible. In particular, pin setup
334 * may be handled by the boot loader, and drivers should expect it will
335 * normally have been done by the time they're probed.
337 static int __init omap_init_devices(void)
339 /* please keep these calls, and their implementations above,
340 * in alphabetical order so they're easier to sort through.
350 arch_initcall(omap_init_devices);