aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-davinci/board-dm355-evm.c29
-rw-r--r--arch/arm/mach-davinci/board-dm355-leopard.c28
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c24
-rw-r--r--arch/arm/mach-davinci/devices.c157
-rw-r--r--arch/arm/mach-davinci/include/mach/mmc.h33
5 files changed, 271 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 6af3c6c863ab..087441313dd7 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -36,6 +36,7 @@
36#include <mach/i2c.h> 36#include <mach/i2c.h>
37#include <mach/serial.h> 37#include <mach/serial.h>
38#include <mach/nand.h> 38#include <mach/nand.h>
39#include <mach/mmc.h>
39 40
40#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000 41#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
41#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 42#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
@@ -191,6 +192,31 @@ static void __init dm355_evm_map_io(void)
191 dm355_init(); 192 dm355_init();
192} 193}
193 194
195static int dm355evm_mmc_get_cd(int module)
196{
197 if (!gpio_is_valid(dm355evm_mmc_gpios))
198 return -ENXIO;
199 /* low == card present */
200 return !gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 1);
201}
202
203static int dm355evm_mmc_get_ro(int module)
204{
205 if (!gpio_is_valid(dm355evm_mmc_gpios))
206 return -ENXIO;
207 /* high == card's write protect switch active */
208 return gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 0);
209}
210
211static struct davinci_mmc_config dm355evm_mmc_config = {
212 .get_cd = dm355evm_mmc_get_cd,
213 .get_ro = dm355evm_mmc_get_ro,
214 .wires = 4,
215 .max_freq = 50000000,
216 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
217 .version = MMC_CTLR_VERSION_1,
218};
219
194/* Don't connect anything to J10 unless you're only using USB host 220/* Don't connect anything to J10 unless you're only using USB host
195 * mode *and* have to do so with some kind of gender-bender. If 221 * mode *and* have to do so with some kind of gender-bender. If
196 * you have proper Mini-B or Mini-A cables (or Mini-A adapters) 222 * you have proper Mini-B or Mini-A cables (or Mini-A adapters)
@@ -249,6 +275,9 @@ static __init void dm355_evm_init(void)
249 /* irlml6401 switches over 1A in under 8 msec */ 275 /* irlml6401 switches over 1A in under 8 msec */
250 setup_usb(500, 8); 276 setup_usb(500, 8);
251 277
278 davinci_setup_mmc(0, &dm355evm_mmc_config);
279 davinci_setup_mmc(1, &dm355evm_mmc_config);
280
252 dm355_init_spi0(BIT(0), dm355_evm_spi_info, 281 dm355_init_spi0(BIT(0), dm355_evm_spi_info,
253 ARRAY_SIZE(dm355_evm_spi_info)); 282 ARRAY_SIZE(dm355_evm_spi_info));
254} 283}
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index 22f16f38a0ba..d4562f5ff93b 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -35,6 +35,7 @@
35#include <mach/i2c.h> 35#include <mach/i2c.h>
36#include <mach/serial.h> 36#include <mach/serial.h>
37#include <mach/nand.h> 37#include <mach/nand.h>
38#include <mach/mmc.h>
38 39
39#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000 40#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
40#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 41#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
@@ -190,6 +191,30 @@ static void __init dm355_leopard_map_io(void)
190 dm355_init(); 191 dm355_init();
191} 192}
192 193
194static int dm355leopard_mmc_get_cd(int module)
195{
196 if (!gpio_is_valid(leopard_mmc_gpio))
197 return -ENXIO;
198 /* low == card present */
199 return !gpio_get_value_cansleep(leopard_mmc_gpio + 2 * module + 1);
200}
201
202static int dm355leopard_mmc_get_ro(int module)
203{
204 if (!gpio_is_valid(leopard_mmc_gpio))
205 return -ENXIO;
206 /* high == card's write protect switch active */
207 return gpio_get_value_cansleep(leopard_mmc_gpio + 2 * module + 0);
208}
209
210static struct davinci_mmc_config dm355leopard_mmc_config = {
211 .get_cd = dm355leopard_mmc_get_cd,
212 .get_ro = dm355leopard_mmc_get_ro,
213 .wires = 4,
214 .max_freq = 50000000,
215 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
216};
217
193/* Don't connect anything to J10 unless you're only using USB host 218/* Don't connect anything to J10 unless you're only using USB host
194 * mode *and* have to do so with some kind of gender-bender. If 219 * mode *and* have to do so with some kind of gender-bender. If
195 * you have proper Mini-B or Mini-A cables (or Mini-A adapters) 220 * you have proper Mini-B or Mini-A cables (or Mini-A adapters)
@@ -248,6 +273,9 @@ static __init void dm355_leopard_init(void)
248 /* irlml6401 switches over 1A in under 8 msec */ 273 /* irlml6401 switches over 1A in under 8 msec */
249 setup_usb(500, 8); 274 setup_usb(500, 8);
250 275
276 davinci_setup_mmc(0, &dm355leopard_mmc_config);
277 davinci_setup_mmc(1, &dm355leopard_mmc_config);
278
251 dm355_init_spi0(BIT(0), dm355_leopard_spi_info, 279 dm355_init_spi0(BIT(0), dm355_leopard_spi_info,
252 ARRAY_SIZE(dm355_leopard_spi_info)); 280 ARRAY_SIZE(dm355_leopard_spi_info));
253} 281}
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index b2e7f9c63bc5..9c3ce311d5d7 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -44,6 +44,7 @@
44#include <mach/mux.h> 44#include <mach/mux.h>
45#include <mach/psc.h> 45#include <mach/psc.h>
46#include <mach/nand.h> 46#include <mach/nand.h>
47#include <mach/mmc.h>
47 48
48#define DM644X_EVM_PHY_MASK (0x2) 49#define DM644X_EVM_PHY_MASK (0x2)
49#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ 50#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
@@ -545,6 +546,27 @@ static int dm6444evm_msp430_get_pins(void)
545 return (buf[3] << 8) | buf[2]; 546 return (buf[3] << 8) | buf[2];
546} 547}
547 548
549static int dm6444evm_mmc_get_cd(int module)
550{
551 int status = dm6444evm_msp430_get_pins();
552
553 return (status < 0) ? status : !(status & BIT(1));
554}
555
556static int dm6444evm_mmc_get_ro(int module)
557{
558 int status = dm6444evm_msp430_get_pins();
559
560 return (status < 0) ? status : status & BIT(6 + 8);
561}
562
563static struct davinci_mmc_config dm6446evm_mmc_config = {
564 .get_cd = dm6444evm_mmc_get_cd,
565 .get_ro = dm6444evm_mmc_get_ro,
566 .wires = 4,
567 .version = MMC_CTLR_VERSION_1
568};
569
548static struct i2c_board_info __initdata i2c_info[] = { 570static struct i2c_board_info __initdata i2c_info[] = {
549 { 571 {
550 I2C_BOARD_INFO("dm6446evm_msp", 0x23), 572 I2C_BOARD_INFO("dm6446evm_msp", 0x23),
@@ -671,6 +693,8 @@ static __init void davinci_evm_init(void)
671 ARRAY_SIZE(davinci_evm_devices)); 693 ARRAY_SIZE(davinci_evm_devices));
672 evm_init_i2c(); 694 evm_init_i2c();
673 695
696 davinci_setup_mmc(0, &dm6446evm_mmc_config);
697
674 davinci_serial_init(&uart_config); 698 davinci_serial_init(&uart_config);
675 699
676 /* Register the fixup for PHY on DaVinci */ 700 /* Register the fixup for PHY on DaVinci */
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index 7fdc408105b2..56c19319a7d2 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -23,8 +23,13 @@
23#include <mach/irqs.h> 23#include <mach/irqs.h>
24#include <mach/cputype.h> 24#include <mach/cputype.h>
25#include <mach/mux.h> 25#include <mach/mux.h>
26#include <mach/edma.h>
27#include <mach/mmc.h>
26 28
27#define DAVINCI_I2C_BASE 0x01C21000 29#define DAVINCI_I2C_BASE 0x01C21000
30#define DAVINCI_MMCSD0_BASE 0x01E10000
31#define DM355_MMCSD0_BASE 0x01E11000
32#define DM355_MMCSD1_BASE 0x01E00000
28 33
29static struct resource i2c_resources[] = { 34static struct resource i2c_resources[] = {
30 { 35 {
@@ -54,6 +59,158 @@ void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
54 (void) platform_device_register(&davinci_i2c_device); 59 (void) platform_device_register(&davinci_i2c_device);
55} 60}
56 61
62#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
63
64static u64 mmcsd0_dma_mask = DMA_32BIT_MASK;
65
66static struct resource mmcsd0_resources[] = {
67 {
68 /* different on dm355 */
69 .start = DAVINCI_MMCSD0_BASE,
70 .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
71 .flags = IORESOURCE_MEM,
72 },
73 /* IRQs: MMC/SD, then SDIO */
74 {
75 .start = IRQ_MMCINT,
76 .flags = IORESOURCE_IRQ,
77 }, {
78 /* different on dm355 */
79 .start = IRQ_SDIOINT,
80 .flags = IORESOURCE_IRQ,
81 },
82 /* DMA channels: RX, then TX */
83 {
84 .start = DAVINCI_DMA_MMCRXEVT,
85 .flags = IORESOURCE_DMA,
86 }, {
87 .start = DAVINCI_DMA_MMCTXEVT,
88 .flags = IORESOURCE_DMA,
89 },
90};
91
92static struct platform_device davinci_mmcsd0_device = {
93 .name = "davinci_mmc",
94 .id = 0,
95 .dev = {
96 .dma_mask = &mmcsd0_dma_mask,
97 .coherent_dma_mask = DMA_32BIT_MASK,
98 },
99 .num_resources = ARRAY_SIZE(mmcsd0_resources),
100 .resource = mmcsd0_resources,
101};
102
103static u64 mmcsd1_dma_mask = DMA_32BIT_MASK;
104
105static struct resource mmcsd1_resources[] = {
106 {
107 .start = DM355_MMCSD1_BASE,
108 .end = DM355_MMCSD1_BASE + SZ_4K - 1,
109 .flags = IORESOURCE_MEM,
110 },
111 /* IRQs: MMC/SD, then SDIO */
112 {
113 .start = IRQ_DM355_MMCINT1,
114 .flags = IORESOURCE_IRQ,
115 }, {
116 .start = IRQ_DM355_SDIOINT1,
117 .flags = IORESOURCE_IRQ,
118 },
119 /* DMA channels: RX, then TX */
120 {
121 .start = 30, /* rx */
122 .flags = IORESOURCE_DMA,
123 }, {
124 .start = 31, /* tx */
125 .flags = IORESOURCE_DMA,
126 },
127};
128
129static struct platform_device davinci_mmcsd1_device = {
130 .name = "davinci_mmc",
131 .id = 1,
132 .dev = {
133 .dma_mask = &mmcsd1_dma_mask,
134 .coherent_dma_mask = DMA_32BIT_MASK,
135 },
136 .num_resources = ARRAY_SIZE(mmcsd1_resources),
137 .resource = mmcsd1_resources,
138};
139
140
141void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
142{
143 struct platform_device *pdev = NULL;
144
145 if (WARN_ON(cpu_is_davinci_dm646x()))
146 return;
147
148 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
149 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
150 *
151 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
152 * not handled right here ...
153 */
154 switch (module) {
155 case 1:
156 if (!cpu_is_davinci_dm355())
157 break;
158
159 /* REVISIT we may not need all these pins if e.g. this
160 * is a hard-wired SDIO device...
161 */
162 davinci_cfg_reg(DM355_SD1_CMD);
163 davinci_cfg_reg(DM355_SD1_CLK);
164 davinci_cfg_reg(DM355_SD1_DATA0);
165 davinci_cfg_reg(DM355_SD1_DATA1);
166 davinci_cfg_reg(DM355_SD1_DATA2);
167 davinci_cfg_reg(DM355_SD1_DATA3);
168
169 pdev = &davinci_mmcsd1_device;
170 break;
171 case 0:
172 if (cpu_is_davinci_dm355()) {
173 mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
174 mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
175 mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
176
177 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
178 davinci_cfg_reg(DM355_MMCSD0);
179
180 /* enable RX EDMA */
181 davinci_cfg_reg(DM355_EVT26_MMC0_RX);
182 }
183
184 else if (cpu_is_davinci_dm644x()) {
185 /* REVISIT: should this be in board-init code? */
186 void __iomem *base =
187 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
188
189 /* Power-on 3.3V IO cells */
190 __raw_writel(0, base + DM64XX_VDD3P3V_PWDN);
191 /*Set up the pull regiter for MMC */
192 davinci_cfg_reg(DM644X_MSTK);
193 }
194
195 pdev = &davinci_mmcsd0_device;
196 break;
197 }
198
199 if (WARN_ON(!pdev))
200 return;
201
202 pdev->dev.platform_data = config;
203 platform_device_register(pdev);
204}
205
206#else
207
208void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
209{
210}
211
212#endif
213
57/*-------------------------------------------------------------------------*/ 214/*-------------------------------------------------------------------------*/
58 215
59static struct resource wdt_resources[] = { 216static struct resource wdt_resources[] = {
diff --git a/arch/arm/mach-davinci/include/mach/mmc.h b/arch/arm/mach-davinci/include/mach/mmc.h
new file mode 100644
index 000000000000..5a85e24f3673
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/mmc.h
@@ -0,0 +1,33 @@
1/*
2 * Board-specific MMC configuration
3 */
4
5#ifndef _DAVINCI_MMC_H
6#define _DAVINCI_MMC_H
7
8#include <linux/types.h>
9#include <linux/mmc/host.h>
10
11struct davinci_mmc_config {
12 /* get_cd()/get_wp() may sleep */
13 int (*get_cd)(int module);
14 int (*get_ro)(int module);
15 /* wires == 0 is equivalent to wires == 4 (4-bit parallel) */
16 u8 wires;
17
18 u32 max_freq;
19
20 /* any additional host capabilities: OR'd in to mmc->f_caps */
21 u32 caps;
22
23 /* Version of the MMC/SD controller */
24 u8 version;
25};
26void davinci_setup_mmc(int module, struct davinci_mmc_config *config);
27
28enum {
29 MMC_CTLR_VERSION_1 = 0, /* DM644x and DM355 */
30 MMC_CTLR_VERSION_2, /* DA830 */
31};
32
33#endif