blob: 1348ac3d60e3580d5609ce2ac0193795cbfcc812 [file] [log] [blame]
Tony Lindgren90c62bf2008-12-10 17:37:17 -08001/*
Adrian Hunterd02a900b2010-02-15 10:03:34 -08002 * linux/arch/arm/mach-omap2/hsmmc.c
Tony Lindgren90c62bf2008-12-10 17:37:17 -08003 *
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 */
Adrian Hunterdb0fefc2010-02-15 10:03:34 -080012#include <linux/kernel.h>
13#include <linux/slab.h>
14#include <linux/string.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080015#include <linux/delay.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080016#include <mach/hardware.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070017#include <plat/mmc.h>
Adrian Huntere3df0fb2010-02-15 10:03:34 -080018#include <plat/omap-pm.h>
Kishore Kadiyalad8d0a612011-02-28 20:48:03 +053019#include <plat/mux.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080020
Kishore Kadiyalad8d0a612011-02-28 20:48:03 +053021#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080022#include "hsmmc.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060023#include "control.h"
Tony Lindgren90c62bf2008-12-10 17:37:17 -080024
Adrian Hunterdb0fefc2010-02-15 10:03:34 -080025#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
Tony Lindgren90c62bf2008-12-10 17:37:17 -080026
Tony Lindgren90c62bf2008-12-10 17:37:17 -080027static u16 control_pbias_offset;
28static u16 control_devconf1_offset;
kishore kadiyalac83c8e62010-05-15 18:21:25 +000029static u16 control_mmc1;
Tony Lindgren90c62bf2008-12-10 17:37:17 -080030
31#define HSMMC_NAME_LEN 9
32
Adrian Hunter68ff0422010-02-15 10:03:34 -080033static struct hsmmc_controller {
David Brownellb583f262009-05-28 14:04:03 -070034 char name[HSMMC_NAME_LEN + 1];
35} hsmmc[OMAP34XX_NR_MMC];
Tony Lindgren90c62bf2008-12-10 17:37:17 -080036
Denis Karpov1887bde2009-09-22 16:44:40 -070037#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
38
Adrian Hunter68ff0422010-02-15 10:03:34 -080039static int hsmmc_get_context_loss(struct device *dev)
Denis Karpov1887bde2009-09-22 16:44:40 -070040{
Adrian Huntere3df0fb2010-02-15 10:03:34 -080041 return omap_pm_get_dev_context_loss_count(dev);
Denis Karpov1887bde2009-09-22 16:44:40 -070042}
43
44#else
Adrian Hunter68ff0422010-02-15 10:03:34 -080045#define hsmmc_get_context_loss NULL
Denis Karpov1887bde2009-09-22 16:44:40 -070046#endif
47
kishore kadiyalac83c8e62010-05-15 18:21:25 +000048static void omap_hsmmc1_before_set_reg(struct device *dev, int slot,
Adrian Hunterdb0fefc2010-02-15 10:03:34 -080049 int power_on, int vdd)
Tony Lindgren90c62bf2008-12-10 17:37:17 -080050{
Madhu555d5032009-11-22 10:11:08 -080051 u32 reg, prog_io;
Tony Lindgren90c62bf2008-12-10 17:37:17 -080052 struct omap_mmc_platform_data *mmc = dev->platform_data;
53
Adrian Hunterce6f0012010-02-15 10:03:34 -080054 if (mmc->slots[0].remux)
55 mmc->slots[0].remux(dev, slot, power_on);
56
David Brownell0329c372009-03-23 18:23:47 -070057 /*
58 * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
David Brownellb583f262009-05-28 14:04:03 -070059 * card with Vcc regulator (from twl4030 or whatever). OMAP has both
David Brownell0329c372009-03-23 18:23:47 -070060 * 1.8V and 3.0V modes, controlled by the PBIAS register.
61 *
62 * In 8-bit modes, OMAP VMMC1A (for DAT4..7) needs a supply, which
63 * is most naturally TWL VSIM; those pins also use PBIAS.
David Brownellb583f262009-05-28 14:04:03 -070064 *
65 * FIXME handle VMMC1A as needed ...
David Brownell0329c372009-03-23 18:23:47 -070066 */
Tony Lindgren90c62bf2008-12-10 17:37:17 -080067 if (power_on) {
68 if (cpu_is_omap2430()) {
69 reg = omap_ctrl_readl(OMAP243X_CONTROL_DEVCONF1);
70 if ((1 << vdd) >= MMC_VDD_30_31)
71 reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
72 else
73 reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
74 omap_ctrl_writel(reg, OMAP243X_CONTROL_DEVCONF1);
75 }
76
77 if (mmc->slots[0].internal_clock) {
78 reg = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
79 reg |= OMAP2_MMCSDIO1ADPCLKISEL;
80 omap_ctrl_writel(reg, OMAP2_CONTROL_DEVCONF0);
81 }
82
83 reg = omap_ctrl_readl(control_pbias_offset);
Madhu555d5032009-11-22 10:11:08 -080084 if (cpu_is_omap3630()) {
85 /* Set MMC I/O to 52Mhz */
86 prog_io = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
87 prog_io |= OMAP3630_PRG_SDMMC1_SPEEDCTRL;
88 omap_ctrl_writel(prog_io, OMAP343X_CONTROL_PROG_IO1);
89 } else {
90 reg |= OMAP2_PBIASSPEEDCTRL0;
91 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -080092 reg &= ~OMAP2_PBIASLITEPWRDNZ0;
93 omap_ctrl_writel(reg, control_pbias_offset);
Adrian Hunterdb0fefc2010-02-15 10:03:34 -080094 } else {
95 reg = omap_ctrl_readl(control_pbias_offset);
96 reg &= ~OMAP2_PBIASLITEPWRDNZ0;
97 omap_ctrl_writel(reg, control_pbias_offset);
98 }
99}
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800100
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000101static void omap_hsmmc1_after_set_reg(struct device *dev, int slot,
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800102 int power_on, int vdd)
103{
104 u32 reg;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800105
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800106 /* 100ms delay required for PBIAS configuration */
107 msleep(100);
108
109 if (power_on) {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800110 reg = omap_ctrl_readl(control_pbias_offset);
111 reg |= (OMAP2_PBIASLITEPWRDNZ0 | OMAP2_PBIASSPEEDCTRL0);
112 if ((1 << vdd) <= MMC_VDD_165_195)
113 reg &= ~OMAP2_PBIASLITEVMODE0;
114 else
115 reg |= OMAP2_PBIASLITEVMODE0;
116 omap_ctrl_writel(reg, control_pbias_offset);
117 } else {
118 reg = omap_ctrl_readl(control_pbias_offset);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800119 reg |= (OMAP2_PBIASSPEEDCTRL0 | OMAP2_PBIASLITEPWRDNZ0 |
120 OMAP2_PBIASLITEVMODE0);
121 omap_ctrl_writel(reg, control_pbias_offset);
122 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800123}
124
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000125static void omap4_hsmmc1_before_set_reg(struct device *dev, int slot,
126 int power_on, int vdd)
127{
128 u32 reg;
129
130 /*
131 * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
132 * card with Vcc regulator (from twl4030 or whatever). OMAP has both
133 * 1.8V and 3.0V modes, controlled by the PBIAS register.
134 *
135 * In 8-bit modes, OMAP VMMC1A (for DAT4..7) needs a supply, which
136 * is most naturally TWL VSIM; those pins also use PBIAS.
137 *
138 * FIXME handle VMMC1A as needed ...
139 */
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600140 reg = omap4_ctrl_pad_readl(control_pbias_offset);
141 reg &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
142 OMAP4_MMC1_PWRDNZ_MASK |
143 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
144 omap4_ctrl_pad_writel(reg, control_pbias_offset);
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000145}
146
147static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot,
148 int power_on, int vdd)
149{
150 u32 reg;
151
152 if (power_on) {
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600153 reg = omap4_ctrl_pad_readl(control_pbias_offset);
154 reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK;
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000155 if ((1 << vdd) <= MMC_VDD_165_195)
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600156 reg &= ~OMAP4_MMC1_PBIASLITE_VMODE_MASK;
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000157 else
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600158 reg |= OMAP4_MMC1_PBIASLITE_VMODE_MASK;
159 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
160 OMAP4_MMC1_PWRDNZ_MASK |
161 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
162 omap4_ctrl_pad_writel(reg, control_pbias_offset);
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000163 /* 4 microsec delay for comparator to generate an error*/
164 udelay(4);
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600165 reg = omap4_ctrl_pad_readl(control_pbias_offset);
166 if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK) {
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000167 pr_err("Pbias Voltage is not same as LDO\n");
168 /* Caution : On VMODE_ERROR Power Down MMC IO */
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600169 reg &= ~(OMAP4_MMC1_PWRDNZ_MASK |
170 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
171 omap4_ctrl_pad_writel(reg, control_pbias_offset);
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000172 }
173 } else {
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600174 reg = omap4_ctrl_pad_readl(control_pbias_offset);
175 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
176 OMAP4_MMC1_PWRDNZ_MASK |
177 OMAP4_MMC1_PBIASLITE_VMODE_MASK |
178 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
179 omap4_ctrl_pad_writel(reg, control_pbias_offset);
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000180 }
181}
182
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800183static void hsmmc23_before_set_reg(struct device *dev, int slot,
184 int power_on, int vdd)
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800185{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800186 struct omap_mmc_platform_data *mmc = dev->platform_data;
Grazvydas Ignotas762ad3a42009-06-23 13:30:22 +0300187
Adrian Hunterce6f0012010-02-15 10:03:34 -0800188 if (mmc->slots[0].remux)
189 mmc->slots[0].remux(dev, slot, power_on);
190
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800191 if (power_on) {
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800192 /* Only MMC2 supports a CLKIN */
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800193 if (mmc->slots[0].internal_clock) {
194 u32 reg;
195
196 reg = omap_ctrl_readl(control_devconf1_offset);
197 reg |= OMAP2_MMCSDIO2ADPCLKISEL;
198 omap_ctrl_writel(reg, control_devconf1_offset);
199 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800200 }
Adrian Hunter9b7c18e2009-09-22 16:44:50 -0700201}
202
stanley.miao03e7e172010-05-13 12:39:31 +0000203static int nop_mmc_set_power(struct device *dev, int slot, int power_on,
204 int vdd)
205{
206 return 0;
207}
208
Kishore Kadiyalad8d0a612011-02-28 20:48:03 +0530209static inline void omap_hsmmc_mux(struct omap_mmc_platform_data *mmc_controller,
210 int controller_nr)
211{
212 if ((mmc_controller->slots[0].switch_pin > 0) && \
213 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
214 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
215 OMAP_PIN_INPUT_PULLUP);
216 if ((mmc_controller->slots[0].gpio_wp > 0) && \
217 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
218 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
219 OMAP_PIN_INPUT_PULLUP);
220 if (cpu_is_omap34xx()) {
221 if (controller_nr == 0) {
222 omap_mux_init_signal("sdmmc1_clk",
223 OMAP_PIN_INPUT_PULLUP);
224 omap_mux_init_signal("sdmmc1_cmd",
225 OMAP_PIN_INPUT_PULLUP);
226 omap_mux_init_signal("sdmmc1_dat0",
227 OMAP_PIN_INPUT_PULLUP);
228 if (mmc_controller->slots[0].caps &
229 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
230 omap_mux_init_signal("sdmmc1_dat1",
231 OMAP_PIN_INPUT_PULLUP);
232 omap_mux_init_signal("sdmmc1_dat2",
233 OMAP_PIN_INPUT_PULLUP);
234 omap_mux_init_signal("sdmmc1_dat3",
235 OMAP_PIN_INPUT_PULLUP);
236 }
237 if (mmc_controller->slots[0].caps &
238 MMC_CAP_8_BIT_DATA) {
239 omap_mux_init_signal("sdmmc1_dat4",
240 OMAP_PIN_INPUT_PULLUP);
241 omap_mux_init_signal("sdmmc1_dat5",
242 OMAP_PIN_INPUT_PULLUP);
243 omap_mux_init_signal("sdmmc1_dat6",
244 OMAP_PIN_INPUT_PULLUP);
245 omap_mux_init_signal("sdmmc1_dat7",
246 OMAP_PIN_INPUT_PULLUP);
247 }
248 }
249 if (controller_nr == 1) {
250 /* MMC2 */
251 omap_mux_init_signal("sdmmc2_clk",
252 OMAP_PIN_INPUT_PULLUP);
253 omap_mux_init_signal("sdmmc2_cmd",
254 OMAP_PIN_INPUT_PULLUP);
255 omap_mux_init_signal("sdmmc2_dat0",
256 OMAP_PIN_INPUT_PULLUP);
257
258 /*
259 * For 8 wire configurations, Lines DAT4, 5, 6 and 7
260 * need to be muxed in the board-*.c files
261 */
262 if (mmc_controller->slots[0].caps &
263 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
264 omap_mux_init_signal("sdmmc2_dat1",
265 OMAP_PIN_INPUT_PULLUP);
266 omap_mux_init_signal("sdmmc2_dat2",
267 OMAP_PIN_INPUT_PULLUP);
268 omap_mux_init_signal("sdmmc2_dat3",
269 OMAP_PIN_INPUT_PULLUP);
270 }
271 if (mmc_controller->slots[0].caps &
272 MMC_CAP_8_BIT_DATA) {
273 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
274 OMAP_PIN_INPUT_PULLUP);
275 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
276 OMAP_PIN_INPUT_PULLUP);
277 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
278 OMAP_PIN_INPUT_PULLUP);
279 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
280 OMAP_PIN_INPUT_PULLUP);
281 }
282 }
283
284 /*
285 * For MMC3 the pins need to be muxed in the board-*.c files
286 */
287 }
288}
289
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800290static struct omap_mmc_platform_data *hsmmc_data[OMAP34XX_NR_MMC] __initdata;
291
Adrian Hunter68ff0422010-02-15 10:03:34 -0800292void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800293{
Adrian Hunter68ff0422010-02-15 10:03:34 -0800294 struct omap2_hsmmc_info *c;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800295 int nr_hsmmc = ARRAY_SIZE(hsmmc_data);
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200296 int i;
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000297 u32 reg;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800298
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000299 if (!cpu_is_omap44xx()) {
300 if (cpu_is_omap2430()) {
301 control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
302 control_devconf1_offset = OMAP243X_CONTROL_DEVCONF1;
303 } else {
304 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
305 control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1;
306 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800307 } else {
Santosh Shilimkardcf5ef32010-09-27 14:02:58 -0600308 control_pbias_offset =
309 OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PBIASLITE;
310 control_mmc1 = OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MMC1;
311 reg = omap4_ctrl_pad_readl(control_mmc1);
312 reg |= (OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK |
313 OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK);
314 reg &= ~(OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK |
315 OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK);
316 reg |= (OMAP4_USBC1_DR0_SPEEDCTRL_MASK|
317 OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK |
318 OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK);
319 omap4_ctrl_pad_writel(reg, control_mmc1);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800320 }
321
322 for (c = controllers; c->mmc; c++) {
Adrian Hunter68ff0422010-02-15 10:03:34 -0800323 struct hsmmc_controller *hc = hsmmc + c->mmc - 1;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800324 struct omap_mmc_platform_data *mmc = hsmmc_data[c->mmc - 1];
325
326 if (!c->mmc || c->mmc > nr_hsmmc) {
327 pr_debug("MMC%d: no such controller\n", c->mmc);
328 continue;
329 }
330 if (mmc) {
331 pr_debug("MMC%d: already configured\n", c->mmc);
332 continue;
333 }
334
Adrian Hunter68ff0422010-02-15 10:03:34 -0800335 mmc = kzalloc(sizeof(struct omap_mmc_platform_data),
336 GFP_KERNEL);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800337 if (!mmc) {
338 pr_err("Cannot allocate memory for mmc device!\n");
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200339 goto done;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800340 }
341
Adrian Huntere51151a2009-03-23 18:23:48 -0700342 if (c->name)
Adrian Hunter68ff0422010-02-15 10:03:34 -0800343 strncpy(hc->name, c->name, HSMMC_NAME_LEN);
Adrian Huntere51151a2009-03-23 18:23:48 -0700344 else
Adrian Hunter68ff0422010-02-15 10:03:34 -0800345 snprintf(hc->name, ARRAY_SIZE(hc->name),
Adrian Huntere51151a2009-03-23 18:23:48 -0700346 "mmc%islot%i", c->mmc, 1);
Adrian Hunter68ff0422010-02-15 10:03:34 -0800347 mmc->slots[0].name = hc->name;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800348 mmc->nr_slots = 1;
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000349 mmc->slots[0].caps = c->caps;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800350 mmc->slots[0].internal_clock = !c->ext_clock;
351 mmc->dma_mask = 0xffffffff;
kishore kadiyala91a0b082010-10-01 16:35:28 -0700352 if (cpu_is_omap44xx())
353 mmc->reg_offset = OMAP4_MMC_REG_OFFSET;
354 else
355 mmc->reg_offset = 0;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800356
Adrian Hunter68ff0422010-02-15 10:03:34 -0800357 mmc->get_context_loss_count = hsmmc_get_context_loss;
Denis Karpov1887bde2009-09-22 16:44:40 -0700358
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800359 mmc->slots[0].switch_pin = c->gpio_cd;
360 mmc->slots[0].gpio_wp = c->gpio_wp;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800361
Adrian Hunterce6f0012010-02-15 10:03:34 -0800362 mmc->slots[0].remux = c->remux;
Grazvydas Ignotased199f72010-08-10 18:01:52 -0700363 mmc->slots[0].init_card = c->init_card;
Adrian Hunterce6f0012010-02-15 10:03:34 -0800364
Adrian Hunterdb0fefc2010-02-15 10:03:34 -0800365 if (c->cover_only)
366 mmc->slots[0].cover = 1;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800367
Adrian Hunter23d99bb2009-09-22 16:44:48 -0700368 if (c->nonremovable)
369 mmc->slots[0].nonremovable = 1;
370
Denis Karpovdd498ef2009-09-22 16:44:49 -0700371 if (c->power_saving)
372 mmc->slots[0].power_saving = 1;
373
Adrian Hunter1df58db2010-02-15 10:03:34 -0800374 if (c->no_off)
375 mmc->slots[0].no_off = 1;
376
Adrian Huntere0eb2422010-02-15 10:03:34 -0800377 if (c->vcc_aux_disable_is_sleep)
378 mmc->slots[0].vcc_aux_disable_is_sleep = 1;
379
David Brownellb583f262009-05-28 14:04:03 -0700380 /* NOTE: MMC slots should have a Vcc regulator set up.
381 * This may be from a TWL4030-family chip, another
382 * controllable regulator, or a fixed supply.
383 *
384 * temporary HACK: ocr_mask instead of fixed supply
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800385 */
David Brownellb583f262009-05-28 14:04:03 -0700386 mmc->slots[0].ocr_mask = c->ocr_mask;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800387
stanley.miao03e7e172010-05-13 12:39:31 +0000388 if (cpu_is_omap3517() || cpu_is_omap3505())
389 mmc->slots[0].set_power = nop_mmc_set_power;
390 else
391 mmc->slots[0].features |= HSMMC_HAS_PBIAS;
392
Madhusudhan Chikkature07ad64b2010-10-01 16:35:25 -0700393 if (cpu_is_omap44xx() && (omap_rev() > OMAP4430_REV_ES1_0))
394 mmc->slots[0].features |= HSMMC_HAS_UPDATED_RESET;
395
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800396 switch (c->mmc) {
397 case 1:
stanley.miao03e7e172010-05-13 12:39:31 +0000398 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
399 /* on-chip level shifting via PBIAS0/PBIAS1 */
kishore kadiyalac83c8e62010-05-15 18:21:25 +0000400 if (cpu_is_omap44xx()) {
401 mmc->slots[0].before_set_reg =
402 omap4_hsmmc1_before_set_reg;
403 mmc->slots[0].after_set_reg =
404 omap4_hsmmc1_after_set_reg;
405 } else {
406 mmc->slots[0].before_set_reg =
407 omap_hsmmc1_before_set_reg;
408 mmc->slots[0].after_set_reg =
409 omap_hsmmc1_after_set_reg;
410 }
stanley.miao03e7e172010-05-13 12:39:31 +0000411 }
Madhu41fd03d2009-11-22 10:11:07 -0800412
413 /* Omap3630 HSMMC1 supports only 4-bit */
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000414 if (cpu_is_omap3630() &&
415 (c->caps & MMC_CAP_8_BIT_DATA)) {
416 c->caps &= ~MMC_CAP_8_BIT_DATA;
417 c->caps |= MMC_CAP_4_BIT_DATA;
418 mmc->slots[0].caps = c->caps;
Madhu41fd03d2009-11-22 10:11:07 -0800419 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800420 break;
421 case 2:
David Brownellb583f262009-05-28 14:04:03 -0700422 if (c->ext_clock)
423 c->transceiver = 1;
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000424 if (c->transceiver && (c->caps & MMC_CAP_8_BIT_DATA)) {
425 c->caps &= ~MMC_CAP_8_BIT_DATA;
426 c->caps |= MMC_CAP_4_BIT_DATA;
427 }
David Brownellb583f262009-05-28 14:04:03 -0700428 /* FALLTHROUGH */
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700429 case 3:
stanley.miao03e7e172010-05-13 12:39:31 +0000430 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
431 /* off-chip level shifting, or none */
432 mmc->slots[0].before_set_reg = hsmmc23_before_set_reg;
433 mmc->slots[0].after_set_reg = NULL;
434 }
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700435 break;
Kishore Kadiyala7715db52011-02-15 03:40:36 -0500436 case 4:
437 case 5:
438 mmc->slots[0].before_set_reg = NULL;
439 mmc->slots[0].after_set_reg = NULL;
440 break;
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800441 default:
442 pr_err("MMC%d configuration not supported!\n", c->mmc);
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -0700443 kfree(mmc);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800444 continue;
445 }
446 hsmmc_data[c->mmc - 1] = mmc;
Kishore Kadiyalad8d0a612011-02-28 20:48:03 +0530447 omap_hsmmc_mux(hsmmc_data[c->mmc - 1], (c->mmc - 1));
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800448 }
449
450 omap2_init_mmc(hsmmc_data, OMAP34XX_NR_MMC);
David Brownell01971f62009-03-23 18:23:47 -0700451
452 /* pass the device nodes back to board setup code */
453 for (c = controllers; c->mmc; c++) {
454 struct omap_mmc_platform_data *mmc = hsmmc_data[c->mmc - 1];
455
456 if (!c->mmc || c->mmc > nr_hsmmc)
457 continue;
458 c->dev = mmc->dev;
459 }
Aaro Koskinena6c7fdd2010-02-04 13:06:59 +0200460
461done:
462 for (i = 0; i < nr_hsmmc; i++)
463 kfree(hsmmc_data[i]);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800464}
465
466#endif