aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Panizzo <alberto@amarulasolutions.com>2011-03-07 05:45:07 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2011-03-08 07:24:20 -0500
commit0ce88b34ea5a1b48438848739a72da6b4fe7a5fa (patch)
treef2ac787deedd2c2c2aaa929a12807c8399f9bcb7
parentbeb859645a8a9dfa089bef05206c844d9d34f307 (diff)
mach-mx31_3ds: Add support for the MMC slot of the personality board
Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/mach-mx3/mach-mx31_3ds.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c
index f1dbb9d4a84..cff920696e7 100644
--- a/arch/arm/mach-mx3/mach-mx31_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx31_3ds.c
@@ -35,6 +35,7 @@
35#include <mach/iomux-mx3.h> 35#include <mach/iomux-mx3.h>
36#include <mach/3ds_debugboard.h> 36#include <mach/3ds_debugboard.h>
37#include <mach/ulpi.h> 37#include <mach/ulpi.h>
38#include <mach/mmc.h>
38 39
39#include "devices-imx31.h" 40#include "devices-imx31.h"
40#include "devices.h" 41#include "devices.h"
@@ -99,6 +100,85 @@ static int mx31_3ds_pins[] = {
99 /* I2C1 */ 100 /* I2C1 */
100 MX31_PIN_I2C_CLK__I2C1_SCL, 101 MX31_PIN_I2C_CLK__I2C1_SCL,
101 MX31_PIN_I2C_DAT__I2C1_SDA, 102 MX31_PIN_I2C_DAT__I2C1_SDA,
103 /* SDHC1 */
104 MX31_PIN_SD1_DATA3__SD1_DATA3,
105 MX31_PIN_SD1_DATA2__SD1_DATA2,
106 MX31_PIN_SD1_DATA1__SD1_DATA1,
107 MX31_PIN_SD1_DATA0__SD1_DATA0,
108 MX31_PIN_SD1_CLK__SD1_CLK,
109 MX31_PIN_SD1_CMD__SD1_CMD,
110 MX31_PIN_GPIO3_1__GPIO3_1, /* Card detect */
111 MX31_PIN_GPIO3_0__GPIO3_0, /* OE */
112};
113
114/*
115 * Support for SD card slot in personality board
116 */
117#define MX31_3DS_GPIO_SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)
118#define MX31_3DS_GPIO_SDHC1_BE IOMUX_TO_GPIO(MX31_PIN_GPIO3_0)
119
120static struct gpio mx31_3ds_sdhc1_gpios[] = {
121 { MX31_3DS_GPIO_SDHC1_CD, GPIOF_IN, "sdhc1-card-detect" },
122 { MX31_3DS_GPIO_SDHC1_BE, GPIOF_OUT_INIT_LOW, "sdhc1-bus-en" },
123};
124
125static int mx31_3ds_sdhc1_init(struct device *dev,
126 irq_handler_t detect_irq,
127 void *data)
128{
129 int ret;
130
131 ret = gpio_request_array(mx31_3ds_sdhc1_gpios,
132 ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
133 if (ret) {
134 pr_warning("Unable to request the SD/MMC GPIOs.\n");
135 return ret;
136 }
137
138 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
139 detect_irq, IRQF_DISABLED |
140 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
141 "sdhc1-detect", data);
142 if (ret) {
143 pr_warning("Unable to request the SD/MMC card-detect IRQ.\n");
144 goto gpio_free;
145 }
146
147 return 0;
148
149gpio_free:
150 gpio_free_array(mx31_3ds_sdhc1_gpios,
151 ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
152 return ret;
153}
154
155static void mx31_3ds_sdhc1_exit(struct device *dev, void *data)
156{
157 free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), data);
158 gpio_free_array(mx31_3ds_sdhc1_gpios,
159 ARRAY_SIZE(mx31_3ds_sdhc1_gpios));
160}
161
162static void mx31_3ds_sdhc1_setpower(struct device *dev, unsigned int vdd)
163{
164 /*
165 * While the voltage stuff is done by the driver, activate the
166 * Buffer Enable Pin only if there is a card in slot to fix the card
167 * voltage issue caused by bi-directional chip TXB0108 on 3Stack.
168 * Done here because at this stage we have for sure a debounced value
169 * of the presence of the card, showed by the value of vdd.
170 * 7 == ilog2(MMC_VDD_165_195)
171 */
172 if (vdd > 7)
173 gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 1);
174 else
175 gpio_set_value(MX31_3DS_GPIO_SDHC1_BE, 0);
176}
177
178static struct imxmmc_platform_data sdhc1_pdata = {
179 .init = mx31_3ds_sdhc1_init,
180 .exit = mx31_3ds_sdhc1_exit,
181 .setpower = mx31_3ds_sdhc1_setpower,
102}; 182};
103 183
104/* 184/*
@@ -137,6 +217,21 @@ static struct regulator_init_data gpo_init = {
137 } 217 }
138}; 218};
139 219
220static struct regulator_consumer_supply vmmc2_consumers[] = {
221 REGULATOR_SUPPLY("vmmc", "mxc-mmc.0"),
222};
223
224static struct regulator_init_data vmmc2_init = {
225 .constraints = {
226 .min_uV = 3000000,
227 .max_uV = 3000000,
228 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
229 REGULATOR_CHANGE_STATUS,
230 },
231 .num_consumer_supplies = ARRAY_SIZE(vmmc2_consumers),
232 .consumer_supplies = vmmc2_consumers,
233};
234
140static struct mc13xxx_regulator_init_data mx31_3ds_regulators[] = { 235static struct mc13xxx_regulator_init_data mx31_3ds_regulators[] = {
141 { 236 {
142 .id = MC13783_REG_PWGT1SPI, /* Power Gate for ARM core. */ 237 .id = MC13783_REG_PWGT1SPI, /* Power Gate for ARM core. */
@@ -151,6 +246,9 @@ static struct mc13xxx_regulator_init_data mx31_3ds_regulators[] = {
151 }, { 246 }, {
152 .id = MC13783_REG_GPO3, /* Turn on 3.3V */ 247 .id = MC13783_REG_GPO3, /* Turn on 3.3V */
153 .init_data = &gpo_init, 248 .init_data = &gpo_init,
249 }, {
250 .id = MC13783_REG_VMMC2, /* Power MMC/SD, WiFi/Bluetooth. */
251 .init_data = &vmmc2_init,
154 }, 252 },
155}; 253};
156 254
@@ -362,6 +460,7 @@ static void __init mx31_3ds_init(void)
362 "devices on the debug board are unusable.\n"); 460 "devices on the debug board are unusable.\n");
363 imx31_add_imx2_wdt(NULL); 461 imx31_add_imx2_wdt(NULL);
364 imx31_add_imx_i2c0(&mx31_3ds_i2c0_data); 462 imx31_add_imx_i2c0(&mx31_3ds_i2c0_data);
463 imx31_add_mxc_mmc(0, &sdhc1_pdata);
365} 464}
366 465
367static void __init mx31_3ds_timer_init(void) 466static void __init mx31_3ds_timer_init(void)