blob: 8afe9dd3f150933f37a2222db24c5abf369464d1 [file] [log] [blame]
Tony Lindgren90c62bf2008-12-10 17:37:17 -08001/*
2 * linux/arch/arm/mach-omap2/mmc-twl4030.c
3 *
4 * Copyright (C) 2007-2008 Texas Instruments
5 * Copyright (C) 2008 Nokia Corporation
6 * Author: Texas Instruments
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/interrupt.h>
17#include <linux/delay.h>
18#include <linux/gpio.h>
David Brownellb583f262009-05-28 14:04:03 -070019#include <linux/mmc/host.h>
20#include <linux/regulator/consumer.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080021
22#include <mach/hardware.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070023#include <plat/control.h>
24#include <plat/mmc.h>
25#include <plat/board.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080026
27#include "mmc-twl4030.h"
28
David Brownellb583f262009-05-28 14:04:03 -070029
30#if defined(CONFIG_REGULATOR) && \
Tony Lindgren90c62bf2008-12-10 17:37:17 -080031 (defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE))
32
Tony Lindgren90c62bf2008-12-10 17:37:17 -080033static u16 control_pbias_offset;
34static u16 control_devconf1_offset;
35
36#define HSMMC_NAME_LEN 9
37
38static struct twl_mmc_controller {
39 struct omap_mmc_platform_data *mmc;
David Brownellb583f262009-05-28 14:04:03 -070040 /* Vcc == configured supply
41 * Vcc_alt == optional
42 * - MMC1, supply for DAT4..DAT7
43 * - MMC2/MMC2, external level shifter voltage supply, for
44 * chip (SDIO, eMMC, etc) or transceiver (MMC2 only)
45 */
46 struct regulator *vcc;
47 struct regulator *vcc_aux;
48 char name[HSMMC_NAME_LEN + 1];
49} hsmmc[OMAP34XX_NR_MMC];
Tony Lindgren90c62bf2008-12-10 17:37:17 -080050
51static int twl_mmc_card_detect(int irq)
52{
53 unsigned i;
54
55 for (i = 0; i < ARRAY_SIZE(hsmmc); i++) {
56 struct omap_mmc_platform_data *mmc;
57
58 mmc = hsmmc[i].mmc;
59 if (!mmc)
60 continue;
61 if (irq != mmc->slots[0].card_detect_irq)
62 continue;
63
64 /* NOTE: assumes card detect signal is active-low */
65 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
66 }
67 return -ENOSYS;
68}
69
70static int twl_mmc_get_ro(struct device *dev, int slot)
71{
72 struct omap_mmc_platform_data *mmc = dev->platform_data;
73
74 /* NOTE: assumes write protect signal is active-high */
75 return gpio_get_value_cansleep(mmc->slots[0].gpio_wp);
76}
77
Adrian Hunter8d75e982009-03-23 18:23:48 -070078static int twl_mmc_get_cover_state(struct device *dev, int slot)
79{
80 struct omap_mmc_platform_data *mmc = dev->platform_data;
81
82 /* NOTE: assumes card detect signal is active-low */
83 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
84}
85
Tony Lindgren90c62bf2008-12-10 17:37:17 -080086/*
87 * MMC Slot Initialization.
88 */
89static int twl_mmc_late_init(struct device *dev)
90{
91 struct omap_mmc_platform_data *mmc = dev->platform_data;
92 int ret = 0;
93 int i;
94
David Brownellb583f262009-05-28 14:04:03 -070095 /* MMC/SD/SDIO doesn't require a card detect switch */
96 if (gpio_is_valid(mmc->slots[0].switch_pin)) {
97 ret = gpio_request(mmc->slots[0].switch_pin, "mmc_cd");
98 if (ret)
99 goto done;
100 ret = gpio_direction_input(mmc->slots[0].switch_pin);
101 if (ret)
102 goto err;
103 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800104
David Brownellb583f262009-05-28 14:04:03 -0700105 /* require at least main regulator */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800106 for (i = 0; i < ARRAY_SIZE(hsmmc); i++) {
107 if (hsmmc[i].name == mmc->slots[0].name) {
David Brownellb583f262009-05-28 14:04:03 -0700108 struct regulator *reg;
109
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800110 hsmmc[i].mmc = mmc;
David Brownellb583f262009-05-28 14:04:03 -0700111
112 reg = regulator_get(dev, "vmmc");
113 if (IS_ERR(reg)) {
114 dev_dbg(dev, "vmmc regulator missing\n");
115 /* HACK: until fixed.c regulator is usable,
116 * we don't require a main regulator
117 * for MMC2 or MMC3
118 */
119 if (i != 0)
120 break;
121 ret = PTR_ERR(reg);
Roger Quadros22833042009-08-10 14:49:51 +0300122 hsmmc[i].vcc = NULL;
David Brownellb583f262009-05-28 14:04:03 -0700123 goto err;
124 }
125 hsmmc[i].vcc = reg;
126 mmc->slots[0].ocr_mask = mmc_regulator_get_ocrmask(reg);
127
128 /* allow an aux regulator */
129 reg = regulator_get(dev, "vmmc_aux");
130 hsmmc[i].vcc_aux = IS_ERR(reg) ? NULL : reg;
131
132 /* UGLY HACK: workaround regulator framework bugs.
133 * When the bootloader leaves a supply active, it's
134 * initialized with zero usecount ... and we can't
135 * disable it without first enabling it. Until the
136 * framework is fixed, we need a workaround like this
137 * (which is safe for MMC, but not in general).
138 */
139 if (regulator_is_enabled(hsmmc[i].vcc) > 0) {
140 regulator_enable(hsmmc[i].vcc);
141 regulator_disable(hsmmc[i].vcc);
142 }
143 if (hsmmc[i].vcc_aux) {
144 if (regulator_is_enabled(reg) > 0) {
145 regulator_enable(reg);
146 regulator_disable(reg);
147 }
148 }
149
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800150 break;
151 }
152 }
153
154 return 0;
155
156err:
157 gpio_free(mmc->slots[0].switch_pin);
158done:
159 mmc->slots[0].card_detect_irq = 0;
160 mmc->slots[0].card_detect = NULL;
161
162 dev_err(dev, "err %d configuring card detect\n", ret);
163 return ret;
164}
165
166static void twl_mmc_cleanup(struct device *dev)
167{
168 struct omap_mmc_platform_data *mmc = dev->platform_data;
Roger Quadros22833042009-08-10 14:49:51 +0300169 int i;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800170
171 gpio_free(mmc->slots[0].switch_pin);
Roger Quadros22833042009-08-10 14:49:51 +0300172 for(i = 0; i < ARRAY_SIZE(hsmmc); i++) {
173 regulator_put(hsmmc[i].vcc);
174 regulator_put(hsmmc[i].vcc_aux);
175 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800176}
177
178#ifdef CONFIG_PM
179
180static int twl_mmc_suspend(struct device *dev, int slot)
181{
182 struct omap_mmc_platform_data *mmc = dev->platform_data;
183
184 disable_irq(mmc->slots[0].card_detect_irq);
185 return 0;
186}
187
188static int twl_mmc_resume(struct device *dev, int slot)
189{
190 struct omap_mmc_platform_data *mmc = dev->platform_data;
191
192 enable_irq(mmc->slots[0].card_detect_irq);
193 return 0;
194}
195
196#else
197#define twl_mmc_suspend NULL
198#define twl_mmc_resume NULL
199#endif
200
Denis Karpov1887bde2009-09-22 16:44:40 -0700201#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
202
203static int twl4030_mmc_get_context_loss(struct device *dev)
204{
205 /* FIXME: PM DPS not implemented yet */
206 return 0;
207}
208
209#else
210#define twl4030_mmc_get_context_loss NULL
211#endif
212
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800213static int twl_mmc1_set_power(struct device *dev, int slot, int power_on,
214 int vdd)
215{
Madhu555d5032009-11-22 10:11:08 -0800216 u32 reg, prog_io;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800217 int ret = 0;
218 struct twl_mmc_controller *c = &hsmmc[0];
219 struct omap_mmc_platform_data *mmc = dev->platform_data;
220
David Brownell0329c372009-03-23 18:23:47 -0700221 /*
222 * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
David Brownellb583f262009-05-28 14:04:03 -0700223 * card with Vcc regulator (from twl4030 or whatever). OMAP has both
David Brownell0329c372009-03-23 18:23:47 -0700224 * 1.8V and 3.0V modes, controlled by the PBIAS register.
225 *
226 * In 8-bit modes, OMAP VMMC1A (for DAT4..7) needs a supply, which
227 * is most naturally TWL VSIM; those pins also use PBIAS.
David Brownellb583f262009-05-28 14:04:03 -0700228 *
229 * FIXME handle VMMC1A as needed ...
David Brownell0329c372009-03-23 18:23:47 -0700230 */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800231 if (power_on) {
232 if (cpu_is_omap2430()) {
233 reg = omap_ctrl_readl(OMAP243X_CONTROL_DEVCONF1);
234 if ((1 << vdd) >= MMC_VDD_30_31)
235 reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
236 else
237 reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
238 omap_ctrl_writel(reg, OMAP243X_CONTROL_DEVCONF1);
239 }
240
241 if (mmc->slots[0].internal_clock) {
242 reg = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
243 reg |= OMAP2_MMCSDIO1ADPCLKISEL;
244 omap_ctrl_writel(reg, OMAP2_CONTROL_DEVCONF0);
245 }
246
247 reg = omap_ctrl_readl(control_pbias_offset);
Madhu555d5032009-11-22 10:11:08 -0800248 if (cpu_is_omap3630()) {
249 /* Set MMC I/O to 52Mhz */
250 prog_io = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
251 prog_io |= OMAP3630_PRG_SDMMC1_SPEEDCTRL;
252 omap_ctrl_writel(prog_io, OMAP343X_CONTROL_PROG_IO1);
253 } else {
254 reg |= OMAP2_PBIASSPEEDCTRL0;
255 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800256 reg &= ~OMAP2_PBIASLITEPWRDNZ0;
257 omap_ctrl_writel(reg, control_pbias_offset);
258
David Brownellb583f262009-05-28 14:04:03 -0700259 ret = mmc_regulator_set_ocr(c->vcc, vdd);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800260
261 /* 100ms delay required for PBIAS configuration */
262 msleep(100);
263 reg = omap_ctrl_readl(control_pbias_offset);
264 reg |= (OMAP2_PBIASLITEPWRDNZ0 | OMAP2_PBIASSPEEDCTRL0);
265 if ((1 << vdd) <= MMC_VDD_165_195)
266 reg &= ~OMAP2_PBIASLITEVMODE0;
267 else
268 reg |= OMAP2_PBIASLITEVMODE0;
269 omap_ctrl_writel(reg, control_pbias_offset);
270 } else {
271 reg = omap_ctrl_readl(control_pbias_offset);
272 reg &= ~OMAP2_PBIASLITEPWRDNZ0;
273 omap_ctrl_writel(reg, control_pbias_offset);
274
David Brownellb583f262009-05-28 14:04:03 -0700275 ret = mmc_regulator_set_ocr(c->vcc, 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800276
277 /* 100ms delay required for PBIAS configuration */
278 msleep(100);
279 reg = omap_ctrl_readl(control_pbias_offset);
280 reg |= (OMAP2_PBIASSPEEDCTRL0 | OMAP2_PBIASLITEPWRDNZ0 |
281 OMAP2_PBIASLITEVMODE0);
282 omap_ctrl_writel(reg, control_pbias_offset);
283 }
284
285 return ret;
286}
287
David Brownellb583f262009-05-28 14:04:03 -0700288static int twl_mmc23_set_power(struct device *dev, int slot, int power_on, int vdd)
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800289{
David Brownellb583f262009-05-28 14:04:03 -0700290 int ret = 0;
Grazvydas Ignotas762ad3a42009-06-23 13:30:22 +0300291 struct twl_mmc_controller *c = NULL;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800292 struct omap_mmc_platform_data *mmc = dev->platform_data;
Grazvydas Ignotas762ad3a42009-06-23 13:30:22 +0300293 int i;
294
295 for (i = 1; i < ARRAY_SIZE(hsmmc); i++) {
296 if (mmc == hsmmc[i].mmc) {
297 c = &hsmmc[i];
298 break;
299 }
300 }
301
302 if (c == NULL)
303 return -ENODEV;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800304
David Brownellb583f262009-05-28 14:04:03 -0700305 /* If we don't see a Vcc regulator, assume it's a fixed
306 * voltage always-on regulator.
307 */
308 if (!c->vcc)
309 return 0;
310
David Brownell0329c372009-03-23 18:23:47 -0700311 /*
David Brownellb583f262009-05-28 14:04:03 -0700312 * Assume Vcc regulator is used only to power the card ... OMAP
David Brownell0329c372009-03-23 18:23:47 -0700313 * VDDS is used to power the pins, optionally with a transceiver to
314 * support cards using voltages other than VDDS (1.8V nominal). When a
315 * transceiver is used, DAT3..7 are muxed as transceiver control pins.
David Brownellb583f262009-05-28 14:04:03 -0700316 *
317 * In some cases this regulator won't support enable/disable;
318 * e.g. it's a fixed rail for a WLAN chip.
319 *
320 * In other cases vcc_aux switches interface power. Example, for
321 * eMMC cards it represents VccQ. Sometimes transceivers or SDIO
322 * chips/cards need an interface voltage rail too.
David Brownell0329c372009-03-23 18:23:47 -0700323 */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800324 if (power_on) {
David Brownellb583f262009-05-28 14:04:03 -0700325 /* only MMC2 supports a CLKIN */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800326 if (mmc->slots[0].internal_clock) {
327 u32 reg;
328
329 reg = omap_ctrl_readl(control_devconf1_offset);
330 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
331 omap_ctrl_writel(reg, control_devconf1_offset);
332 }
David Brownellb583f262009-05-28 14:04:03 -0700333 ret = mmc_regulator_set_ocr(c->vcc, vdd);
334 /* enable interface voltage rail, if needed */
335 if (ret == 0 && c->vcc_aux) {
336 ret = regulator_enable(c->vcc_aux);
337 if (ret < 0)
338 ret = mmc_regulator_set_ocr(c->vcc, 0);
339 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800340 } else {
David Brownellb583f262009-05-28 14:04:03 -0700341 if (c->vcc_aux && (ret = regulator_is_enabled(c->vcc_aux)) > 0)
342 ret = regulator_disable(c->vcc_aux);
343 if (ret == 0)
344 ret = mmc_regulator_set_ocr(c->vcc, 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800345 }
346
347 return ret;
348}
349
Adrian Hunter9b7c18e2009-09-22 16:44:50 -0700350static int twl_mmc1_set_sleep(struct device *dev, int slot, int sleep, int vdd,
351 int cardsleep)
352{
353 struct twl_mmc_controller *c = &hsmmc[0];
354 int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;
355
356 return regulator_set_mode(c->vcc, mode);
357}
358
359static int twl_mmc23_set_sleep(struct device *dev, int slot, int sleep, int vdd,
360 int cardsleep)
361{
362 struct twl_mmc_controller *c = NULL;
363 struct omap_mmc_platform_data *mmc = dev->platform_data;
364 int i, err, mode;
365
366 for (i = 1; i < ARRAY_SIZE(hsmmc); i++) {
367 if (mmc == hsmmc[i].mmc) {
368 c = &hsmmc[i];
369 break;
370 }
371 }
372
373 if (c == NULL)
374 return -ENODEV;
375
376 /*
377 * If we don't see a Vcc regulator, assume it's a fixed
378 * voltage always-on regulator.
379 */
380 if (!c->vcc)
381 return 0;
382
383 mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL;
384
385 if (!c->vcc_aux)
386 return regulator_set_mode(c->vcc, mode);
387
388 if (cardsleep) {
389 /* VCC can be turned off if card is asleep */
390 struct regulator *vcc_aux = c->vcc_aux;
391
392 c->vcc_aux = NULL;
393 if (sleep)
394 err = twl_mmc23_set_power(dev, slot, 0, 0);
395 else
396 err = twl_mmc23_set_power(dev, slot, 1, vdd);
397 c->vcc_aux = vcc_aux;
398 } else
399 err = regulator_set_mode(c->vcc, mode);
400 if (err)
401 return err;
402 return regulator_set_mode(c->vcc_aux, mode);
403}
404
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800405static struct omap_mmc_platform_data *hsmmc_data[OMAP34XX_NR_MMC] __initdata;
406
407void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
408{
409 struct twl4030_hsmmc_info *c;
410 int nr_hsmmc = ARRAY_SIZE(hsmmc_data);
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200411 int i;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800412
413 if (cpu_is_omap2430()) {
414 control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
415 control_devconf1_offset = OMAP243X_CONTROL_DEVCONF1;
416 nr_hsmmc = 2;
417 } else {
418 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
419 control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1;
420 }
421
422 for (c = controllers; c->mmc; c++) {
423 struct twl_mmc_controller *twl = hsmmc + c->mmc - 1;
424 struct omap_mmc_platform_data *mmc = hsmmc_data[c->mmc - 1];
425
426 if (!c->mmc || c->mmc > nr_hsmmc) {
427 pr_debug("MMC%d: no such controller\n", c->mmc);
428 continue;
429 }
430 if (mmc) {
431 pr_debug("MMC%d: already configured\n", c->mmc);
432 continue;
433 }
434
435 mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
436 if (!mmc) {
437 pr_err("Cannot allocate memory for mmc device!\n");
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200438 goto done;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800439 }
440
Adrian Huntere51151a2009-03-23 18:23:48 -0700441 if (c->name)
442 strncpy(twl->name, c->name, HSMMC_NAME_LEN);
443 else
444 snprintf(twl->name, ARRAY_SIZE(twl->name),
445 "mmc%islot%i", c->mmc, 1);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800446 mmc->slots[0].name = twl->name;
447 mmc->nr_slots = 1;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800448 mmc->slots[0].wires = c->wires;
449 mmc->slots[0].internal_clock = !c->ext_clock;
450 mmc->dma_mask = 0xffffffff;
David Brownellb583f262009-05-28 14:04:03 -0700451 mmc->init = twl_mmc_late_init;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800452
David Brownellb583f262009-05-28 14:04:03 -0700453 /* note: twl4030 card detect GPIOs can disable VMMCx ... */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800454 if (gpio_is_valid(c->gpio_cd)) {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800455 mmc->cleanup = twl_mmc_cleanup;
456 mmc->suspend = twl_mmc_suspend;
457 mmc->resume = twl_mmc_resume;
458
459 mmc->slots[0].switch_pin = c->gpio_cd;
460 mmc->slots[0].card_detect_irq = gpio_to_irq(c->gpio_cd);
Adrian Hunter8d75e982009-03-23 18:23:48 -0700461 if (c->cover_only)
462 mmc->slots[0].get_cover_state = twl_mmc_get_cover_state;
463 else
464 mmc->slots[0].card_detect = twl_mmc_card_detect;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800465 } else
466 mmc->slots[0].switch_pin = -EINVAL;
467
Denis Karpov1887bde2009-09-22 16:44:40 -0700468 mmc->get_context_loss_count =
469 twl4030_mmc_get_context_loss;
470
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800471 /* write protect normally uses an OMAP gpio */
472 if (gpio_is_valid(c->gpio_wp)) {
473 gpio_request(c->gpio_wp, "mmc_wp");
474 gpio_direction_input(c->gpio_wp);
475
476 mmc->slots[0].gpio_wp = c->gpio_wp;
477 mmc->slots[0].get_ro = twl_mmc_get_ro;
478 } else
479 mmc->slots[0].gpio_wp = -EINVAL;
480
Adrian Hunter23d99bb2009-09-22 16:44:48 -0700481 if (c->nonremovable)
482 mmc->slots[0].nonremovable = 1;
483
Denis Karpovdd498ef2009-09-22 16:44:49 -0700484 if (c->power_saving)
485 mmc->slots[0].power_saving = 1;
486
David Brownellb583f262009-05-28 14:04:03 -0700487 /* NOTE: MMC slots should have a Vcc regulator set up.
488 * This may be from a TWL4030-family chip, another
489 * controllable regulator, or a fixed supply.
490 *
491 * temporary HACK: ocr_mask instead of fixed supply
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800492 */
David Brownellb583f262009-05-28 14:04:03 -0700493 mmc->slots[0].ocr_mask = c->ocr_mask;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800494
495 switch (c->mmc) {
496 case 1:
David Brownellb583f262009-05-28 14:04:03 -0700497 /* on-chip level shifting via PBIAS0/PBIAS1 */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800498 mmc->slots[0].set_power = twl_mmc1_set_power;
Adrian Hunter9b7c18e2009-09-22 16:44:50 -0700499 mmc->slots[0].set_sleep = twl_mmc1_set_sleep;
Madhu41fd03d2009-11-22 10:11:07 -0800500
501 /* Omap3630 HSMMC1 supports only 4-bit */
502 if (cpu_is_omap3630() && c->wires > 4) {
503 c->wires = 4;
504 mmc->slots[0].wires = c->wires;
505 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800506 break;
507 case 2:
David Brownellb583f262009-05-28 14:04:03 -0700508 if (c->ext_clock)
509 c->transceiver = 1;
510 if (c->transceiver && c->wires > 4)
511 c->wires = 4;
512 /* FALLTHROUGH */
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700513 case 3:
David Brownellb583f262009-05-28 14:04:03 -0700514 /* off-chip level shifting, or none */
515 mmc->slots[0].set_power = twl_mmc23_set_power;
Adrian Hunter9b7c18e2009-09-22 16:44:50 -0700516 mmc->slots[0].set_sleep = twl_mmc23_set_sleep;
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700517 break;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800518 default:
519 pr_err("MMC%d configuration not supported!\n", c->mmc);
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700520 kfree(mmc);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800521 continue;
522 }
523 hsmmc_data[c->mmc - 1] = mmc;
524 }
525
526 omap2_init_mmc(hsmmc_data, OMAP34XX_NR_MMC);
David Brownell01971f62009-03-23 18:23:47 -0700527
528 /* pass the device nodes back to board setup code */
529 for (c = controllers; c->mmc; c++) {
530 struct omap_mmc_platform_data *mmc = hsmmc_data[c->mmc - 1];
531
532 if (!c->mmc || c->mmc > nr_hsmmc)
533 continue;
534 c->dev = mmc->dev;
535 }
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200536
537done:
538 for (i = 0; i < nr_hsmmc; i++)
539 kfree(hsmmc_data[i]);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800540}
541
542#endif