2 * linux/arch/arm/plat-omap/devices.c
4 * Common platform device setup/initialization for OMAP1 and OMAP2
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/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 void omap_nop_release(struct device *dev)
34 /*-------------------------------------------------------------------------*/
36 #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
38 #define OMAP1_I2C_BASE 0xfffb3800
39 #define OMAP2_I2C_BASE1 0x48070000
40 #define OMAP2_I2C_BASE2 0x48072000
41 #define OMAP_I2C_SIZE 0x3f
42 #define OMAP1_I2C_INT INT_I2C
43 #define OMAP2_I2C_INT1 56
44 #define OMAP2_I2C_INT2 57
46 static struct resource i2c_resources1[] = {
50 .flags = IORESOURCE_MEM,
54 .flags = IORESOURCE_IRQ,
58 /* DMA not used; works around erratum writing to non-empty i2c fifo */
60 static struct platform_device omap_i2c_device1 = {
64 .release = omap_nop_release,
66 .num_resources = ARRAY_SIZE(i2c_resources1),
67 .resource = i2c_resources1,
70 #ifdef CONFIG_ARCH_OMAP24XX
71 static struct resource i2c_resources2[] = {
73 .start = OMAP2_I2C_BASE2,
74 .end = OMAP2_I2C_BASE2 + OMAP_I2C_SIZE,
75 .flags = IORESOURCE_MEM,
78 .start = OMAP2_I2C_INT2,
79 .flags = IORESOURCE_IRQ,
83 static struct platform_device omap_i2c_device2 = {
87 .release = omap_nop_release,
89 .num_resources = ARRAY_SIZE(i2c_resources2),
90 .resource = i2c_resources2,
93 #define omap_i2c_device2 NULL
96 static void omap_init_i2c(void)
98 if (cpu_is_omap24xx()) {
99 i2c_resources1[0].start = OMAP2_I2C_BASE1;
100 i2c_resources1[0].end = OMAP2_I2C_BASE1 + OMAP_I2C_SIZE;
101 i2c_resources1[1].start = OMAP2_I2C_INT1;
103 i2c_resources1[0].start = OMAP1_I2C_BASE;
104 i2c_resources1[0].end = OMAP1_I2C_BASE + OMAP_I2C_SIZE;
105 i2c_resources1[1].start = OMAP1_I2C_INT;
108 /* FIXME define and use a boot tag, in case of boards that
109 * either don't wire up I2C, or chips that mux it differently...
110 * it can include clocking and address info, maybe more.
112 if (cpu_is_omap24xx()) {
113 omap_cfg_reg(M19_24XX_I2C1_SCL);
114 omap_cfg_reg(L15_24XX_I2C1_SDA);
115 omap_cfg_reg(J15_24XX_I2C2_SCL);
116 omap_cfg_reg(H19_24XX_I2C2_SDA);
118 omap_cfg_reg(I2C_SCL);
119 omap_cfg_reg(I2C_SDA);
122 (void) platform_device_register(&omap_i2c_device1);
124 //if (cpu_is_omap24xx())
125 // (void) platform_device_register(&omap_i2c_device2);
128 static inline void omap_init_i2c(void) {}
131 /*-------------------------------------------------------------------------*/
133 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
135 #ifdef CONFIG_ARCH_OMAP24XX
136 #define OMAP_MMC1_BASE 0x4809c000
137 #define OMAP_MMC1_INT 83
139 #define OMAP_MMC1_BASE 0xfffb7800
140 #define OMAP_MMC1_INT INT_MMC
142 #define OMAP_MMC2_BASE 0xfffb7c00 /* omap16xx only */
144 static struct omap_mmc_conf mmc1_conf;
146 static u64 mmc1_dmamask = 0xffffffff;
148 static struct resource mmc1_resources[] = {
150 .start = IO_ADDRESS(OMAP_MMC1_BASE),
151 .end = IO_ADDRESS(OMAP_MMC1_BASE) + 0x7f,
152 .flags = IORESOURCE_MEM,
155 .start = OMAP_MMC1_INT,
156 .flags = IORESOURCE_IRQ,
160 static struct platform_device mmc_omap_device1 = {
164 .release = omap_nop_release,
165 .dma_mask = &mmc1_dmamask,
166 .platform_data = &mmc1_conf,
168 .num_resources = ARRAY_SIZE(mmc1_resources),
169 .resource = mmc1_resources,
172 #ifdef CONFIG_ARCH_OMAP16XX
174 static struct omap_mmc_conf mmc2_conf;
176 static u64 mmc2_dmamask = 0xffffffff;
178 static struct resource mmc2_resources[] = {
180 .start = IO_ADDRESS(OMAP_MMC2_BASE),
181 .end = IO_ADDRESS(OMAP_MMC2_BASE) + 0x7f,
182 .flags = IORESOURCE_MEM,
185 .start = INT_1610_MMC2,
186 .flags = IORESOURCE_IRQ,
190 static struct platform_device mmc_omap_device2 = {
194 .release = omap_nop_release,
195 .dma_mask = &mmc2_dmamask,
196 .platform_data = &mmc2_conf,
198 .num_resources = ARRAY_SIZE(mmc2_resources),
199 .resource = mmc2_resources,
203 static void __init omap_init_mmc(void)
205 const struct omap_mmc_config *mmc_conf;
206 const struct omap_mmc_conf *mmc;
208 /* NOTE: assumes MMC was never (wrongly) enabled */
209 mmc_conf = omap_get_config(OMAP_TAG_MMC, struct omap_mmc_config);
213 /* block 1 is always available and has just one pinout option */
214 mmc = &mmc_conf->mmc[0];
216 if (!cpu_is_omap24xx()) {
217 omap_cfg_reg(MMC_CMD);
218 omap_cfg_reg(MMC_CLK);
219 omap_cfg_reg(MMC_DAT0);
220 if (cpu_is_omap1710()) {
221 omap_cfg_reg(M15_1710_MMC_CLKI);
222 omap_cfg_reg(P19_1710_MMC_CMDDIR);
223 omap_cfg_reg(P20_1710_MMC_DATDIR0);
227 if (!cpu_is_omap24xx()) {
228 omap_cfg_reg(MMC_DAT1);
229 /* NOTE: DAT2 can be on W10 (here) or M15 */
231 omap_cfg_reg(MMC_DAT2);
232 omap_cfg_reg(MMC_DAT3);
236 (void) platform_device_register(&mmc_omap_device1);
239 #ifdef CONFIG_ARCH_OMAP16XX
240 /* block 2 is on newer chips, and has many pinout options */
241 mmc = &mmc_conf->mmc[1];
244 omap_cfg_reg(Y8_1610_MMC2_CMD);
245 omap_cfg_reg(Y10_1610_MMC2_CLK);
246 omap_cfg_reg(R18_1610_MMC2_CLKIN);
247 omap_cfg_reg(W8_1610_MMC2_DAT0);
249 omap_cfg_reg(V8_1610_MMC2_DAT1);
250 omap_cfg_reg(W15_1610_MMC2_DAT2);
251 omap_cfg_reg(R10_1610_MMC2_DAT3);
254 /* These are needed for the level shifter */
255 omap_cfg_reg(V9_1610_MMC2_CMDDIR);
256 omap_cfg_reg(V5_1610_MMC2_DATDIR0);
257 omap_cfg_reg(W19_1610_MMC2_DATDIR1);
260 /* Feedback clock must be set on OMAP-1710 MMC2 */
261 if (cpu_is_omap1710())
262 omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24),
265 (void) platform_device_register(&mmc_omap_device2);
271 static inline void omap_init_mmc(void) {}
275 * This gets called after board-specific INIT_MACHINE, and initializes most
276 * on-chip peripherals accessible on this board (except for few like USB):
278 * (a) Does any "standard config" pin muxing needed. Board-specific
279 * code will have muxed GPIO pins and done "nonstandard" setup;
280 * that code could live in the boot loader.
281 * (b) Populating board-specific platform_data with the data drivers
282 * rely on to handle wiring variations.
283 * (c) Creating platform devices as meaningful on this board and
284 * with this kernel configuration.
286 * Claiming GPIOs, and setting their direction and initial values, is the
287 * responsibility of the device drivers. So is responding to probe().
289 * Board-specific knowlege like creating devices or pin setup is to be
290 * kept out of drivers as much as possible. In particular, pin setup
291 * may be handled by the boot loader, and drivers should expect it will
292 * normally have been done by the time they're probed.
294 static int __init omap_init_devices(void)
296 /* please keep these calls, and their implementations above,
297 * in alphabetical order so they're easier to sort through.
304 arch_initcall(omap_init_devices);