12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/string.h>
17 #include <mach/hardware.h>
28 #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
30 static u16 control_pbias_offset;
31 static u16 control_devconf1_offset;
32 static u16 control_mmc1;
34 #define HSMMC_NAME_LEN 9
36 #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
38 static int hsmmc_get_context_loss(
struct device *
dev)
44 #define hsmmc_get_context_loss NULL
47 static void omap_hsmmc1_before_set_reg(
struct device *
dev,
int slot,
48 int power_on,
int vdd)
53 if (mmc->
slots[0].remux)
54 mmc->
slots[0].remux(dev, slot, power_on);
76 if (mmc->
slots[0].internal_clock) {
100 static void omap_hsmmc1_after_set_reg(
struct device *dev,
int slot,
101 int power_on,
int vdd)
124 static void omap4_hsmmc1_before_set_reg(
struct device *dev,
int slot,
125 int power_on,
int vdd)
141 static void omap4_hsmmc1_after_set_reg(
struct device *dev,
int slot,
142 int power_on,
int vdd)
167 pr_err(
"Pbias Voltage is not same as LDO\n");
180 if (mmc->
slots[0].internal_clock)
187 static void hsmmc2_before_set_reg(
struct device *dev,
int slot,
188 int power_on,
int vdd)
192 if (mmc->
slots[0].remux)
193 mmc->
slots[0].remux(dev, slot, power_on);
196 hsmmc2_select_input_clk_src(mmc);
199 static int am35x_hsmmc2_set_power(
struct device *dev,
int slot,
200 int power_on,
int vdd)
205 hsmmc2_select_input_clk_src(mmc);
210 static int nop_mmc_set_power(
struct device *dev,
int slot,
int power_on,
219 if (gpio_is_valid(mmc_controller->
slots[0].switch_pin) &&
221 omap_mux_init_gpio(mmc_controller->
slots[0].switch_pin,
223 if (gpio_is_valid(mmc_controller->
slots[0].gpio_wp) &&
225 omap_mux_init_gpio(mmc_controller->
slots[0].gpio_wp,
228 if (controller_nr == 0) {
229 omap_mux_init_signal(
"sdmmc1_clk",
231 omap_mux_init_signal(
"sdmmc1_cmd",
233 omap_mux_init_signal(
"sdmmc1_dat0",
235 if (mmc_controller->
slots[0].caps &
237 omap_mux_init_signal(
"sdmmc1_dat1",
239 omap_mux_init_signal(
"sdmmc1_dat2",
241 omap_mux_init_signal(
"sdmmc1_dat3",
244 if (mmc_controller->
slots[0].caps &
246 omap_mux_init_signal(
"sdmmc1_dat4",
248 omap_mux_init_signal(
"sdmmc1_dat5",
250 omap_mux_init_signal(
"sdmmc1_dat6",
252 omap_mux_init_signal(
"sdmmc1_dat7",
256 if (controller_nr == 1) {
258 omap_mux_init_signal(
"sdmmc2_clk",
260 omap_mux_init_signal(
"sdmmc2_cmd",
262 omap_mux_init_signal(
"sdmmc2_dat0",
269 if (mmc_controller->
slots[0].caps &
271 omap_mux_init_signal(
"sdmmc2_dat1",
273 omap_mux_init_signal(
"sdmmc2_dat2",
275 omap_mux_init_signal(
"sdmmc2_dat3",
278 if (mmc_controller->
slots[0].caps &
280 omap_mux_init_signal(
"sdmmc2_dat4.sdmmc2_dat4",
282 omap_mux_init_signal(
"sdmmc2_dat5.sdmmc2_dat5",
284 omap_mux_init_signal(
"sdmmc2_dat6.sdmmc2_dat6",
286 omap_mux_init_signal(
"sdmmc2_dat7.sdmmc2_dat7",
302 hc_name = kzalloc(
sizeof(
char) * (HSMMC_NAME_LEN + 1),
GFP_KERNEL);
304 pr_err(
"Cannot allocate memory for controller slot name\n");
312 snprintf(hc_name, (HSMMC_NAME_LEN + 1),
"mmc%islot%i",
314 mmc->
slots[0].name = hc_name;
334 mmc->
slots[0].cover = 1;
337 mmc->
slots[0].nonremovable = 1;
340 mmc->
slots[0].power_saving = 1;
343 mmc->
slots[0].no_off = 1;
349 mmc->
slots[0].vcc_aux_disable_is_sleep = 1;
379 mmc->
slots[0].before_set_reg =
380 omap4_hsmmc1_before_set_reg;
381 mmc->
slots[0].after_set_reg =
382 omap4_hsmmc1_after_set_reg;
384 mmc->
slots[0].before_set_reg =
385 omap_hsmmc1_before_set_reg;
386 mmc->
slots[0].after_set_reg =
387 omap_hsmmc1_after_set_reg;
392 mmc->
slots[0].set_power = nop_mmc_set_power;
404 mmc->
slots[0].set_power = am35x_hsmmc2_set_power;
414 mmc->
slots[0].before_set_reg = hsmmc2_before_set_reg;
425 pr_err(
"MMC%d configuration not supported!\n", c->
mmc);
432 static int omap_hsmmc_done;
440 if (omap_hsmmc_done != 1)
445 for (; c->
mmc; c++) {
453 mmc_pdata = pdev->
dev.platform_data;
462 pr_err(
"Could not late init MMC %s\n",
467 #define MAX_OMAP_MMC_HWMOD_NAME_LEN 16
476 char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
484 pr_err(
"Cannot allocate memory for mmc device!\n");
488 res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
492 omap_hsmmc_mux(mmc_data, (ctrl_nr - 1));
495 res =
snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
497 WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
498 "String buffer overflow in MMC%d device setup\n", ctrl_nr);
502 pr_err(
"Could not look up %s\n", oh_name);
520 pr_err(
"Could not allocate pdev for %s\n", name);
527 pr_err(
"Could not allocate od for %s\n", name);
534 pr_err(
"Could not add pdata for %s\n", name);
538 hsmmcinfo->
pdev = pdev;
545 pr_err(
"Could not register od for %s\n", name);
582 control_pbias_offset =
596 for (; controllers->
mmc; controllers++)
597 omap_hsmmc_init_one(controllers, controllers->
mmc);