hsmmc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * linux/arch/arm/mach-omap2/hsmmc.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/kernel.h>
  13. #include <linux/slab.h>
  14. #include <linux/string.h>
  15. #include <linux/delay.h>
  16. #include <linux/gpio.h>
  17. #include <mach/hardware.h>
  18. #include <linux/platform_data/gpio-omap.h>
  19. #include <plat/mmc.h>
  20. #include <plat/omap-pm.h>
  21. #include <plat/mux.h>
  22. #include <plat/omap_device.h>
  23. #include "mux.h"
  24. #include "hsmmc.h"
  25. #include "control.h"
  26. #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  27. static u16 control_pbias_offset;
  28. static u16 control_devconf1_offset;
  29. static u16 control_mmc1;
  30. #define HSMMC_NAME_LEN 9
  31. #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
  32. static int hsmmc_get_context_loss(struct device *dev)
  33. {
  34. return omap_pm_get_dev_context_loss_count(dev);
  35. }
  36. #else
  37. #define hsmmc_get_context_loss NULL
  38. #endif
  39. static void omap_hsmmc1_before_set_reg(struct device *dev, int slot,
  40. int power_on, int vdd)
  41. {
  42. u32 reg, prog_io;
  43. struct omap_mmc_platform_data *mmc = dev->platform_data;
  44. if (mmc->slots[0].remux)
  45. mmc->slots[0].remux(dev, slot, power_on);
  46. /*
  47. * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
  48. * card with Vcc regulator (from twl4030 or whatever). OMAP has both
  49. * 1.8V and 3.0V modes, controlled by the PBIAS register.
  50. *
  51. * In 8-bit modes, OMAP VMMC1A (for DAT4..7) needs a supply, which
  52. * is most naturally TWL VSIM; those pins also use PBIAS.
  53. *
  54. * FIXME handle VMMC1A as needed ...
  55. */
  56. if (power_on) {
  57. if (cpu_is_omap2430()) {
  58. reg = omap_ctrl_readl(OMAP243X_CONTROL_DEVCONF1);
  59. if ((1 << vdd) >= MMC_VDD_30_31)
  60. reg |= OMAP243X_MMC1_ACTIVE_OVERWRITE;
  61. else
  62. reg &= ~OMAP243X_MMC1_ACTIVE_OVERWRITE;
  63. omap_ctrl_writel(reg, OMAP243X_CONTROL_DEVCONF1);
  64. }
  65. if (mmc->slots[0].internal_clock) {
  66. reg = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  67. reg |= OMAP2_MMCSDIO1ADPCLKISEL;
  68. omap_ctrl_writel(reg, OMAP2_CONTROL_DEVCONF0);
  69. }
  70. reg = omap_ctrl_readl(control_pbias_offset);
  71. if (cpu_is_omap3630()) {
  72. /* Set MMC I/O to 52Mhz */
  73. prog_io = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
  74. prog_io |= OMAP3630_PRG_SDMMC1_SPEEDCTRL;
  75. omap_ctrl_writel(prog_io, OMAP343X_CONTROL_PROG_IO1);
  76. } else {
  77. reg |= OMAP2_PBIASSPEEDCTRL0;
  78. }
  79. reg &= ~OMAP2_PBIASLITEPWRDNZ0;
  80. omap_ctrl_writel(reg, control_pbias_offset);
  81. } else {
  82. reg = omap_ctrl_readl(control_pbias_offset);
  83. reg &= ~OMAP2_PBIASLITEPWRDNZ0;
  84. omap_ctrl_writel(reg, control_pbias_offset);
  85. }
  86. }
  87. static void omap_hsmmc1_after_set_reg(struct device *dev, int slot,
  88. int power_on, int vdd)
  89. {
  90. u32 reg;
  91. /* 100ms delay required for PBIAS configuration */
  92. msleep(100);
  93. if (power_on) {
  94. reg = omap_ctrl_readl(control_pbias_offset);
  95. reg |= (OMAP2_PBIASLITEPWRDNZ0 | OMAP2_PBIASSPEEDCTRL0);
  96. if ((1 << vdd) <= MMC_VDD_165_195)
  97. reg &= ~OMAP2_PBIASLITEVMODE0;
  98. else
  99. reg |= OMAP2_PBIASLITEVMODE0;
  100. omap_ctrl_writel(reg, control_pbias_offset);
  101. } else {
  102. reg = omap_ctrl_readl(control_pbias_offset);
  103. reg |= (OMAP2_PBIASSPEEDCTRL0 | OMAP2_PBIASLITEPWRDNZ0 |
  104. OMAP2_PBIASLITEVMODE0);
  105. omap_ctrl_writel(reg, control_pbias_offset);
  106. }
  107. }
  108. static void omap4_hsmmc1_before_set_reg(struct device *dev, int slot,
  109. int power_on, int vdd)
  110. {
  111. u32 reg;
  112. /*
  113. * Assume we power both OMAP VMMC1 (for CMD, CLK, DAT0..3) and the
  114. * card with Vcc regulator (from twl4030 or whatever). OMAP has both
  115. * 1.8V and 3.0V modes, controlled by the PBIAS register.
  116. */
  117. reg = omap4_ctrl_pad_readl(control_pbias_offset);
  118. reg &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
  119. OMAP4_MMC1_PWRDNZ_MASK |
  120. OMAP4_MMC1_PBIASLITE_VMODE_MASK);
  121. omap4_ctrl_pad_writel(reg, control_pbias_offset);
  122. }
  123. static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot,
  124. int power_on, int vdd)
  125. {
  126. u32 reg;
  127. unsigned long timeout;
  128. if (power_on) {
  129. reg = omap4_ctrl_pad_readl(control_pbias_offset);
  130. reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK;
  131. if ((1 << vdd) <= MMC_VDD_165_195)
  132. reg &= ~OMAP4_MMC1_PBIASLITE_VMODE_MASK;
  133. else
  134. reg |= OMAP4_MMC1_PBIASLITE_VMODE_MASK;
  135. reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
  136. OMAP4_MMC1_PWRDNZ_MASK);
  137. omap4_ctrl_pad_writel(reg, control_pbias_offset);
  138. timeout = jiffies + msecs_to_jiffies(5);
  139. do {
  140. reg = omap4_ctrl_pad_readl(control_pbias_offset);
  141. if (!(reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK))
  142. break;
  143. usleep_range(100, 200);
  144. } while (!time_after(jiffies, timeout));
  145. if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK) {
  146. pr_err("Pbias Voltage is not same as LDO\n");
  147. /* Caution : On VMODE_ERROR Power Down MMC IO */
  148. reg &= ~(OMAP4_MMC1_PWRDNZ_MASK);
  149. omap4_ctrl_pad_writel(reg, control_pbias_offset);
  150. }
  151. }
  152. }
  153. static void hsmmc2_select_input_clk_src(struct omap_mmc_platform_data *mmc)
  154. {
  155. u32 reg;
  156. reg = omap_ctrl_readl(control_devconf1_offset);
  157. if (mmc->slots[0].internal_clock)
  158. reg |= OMAP2_MMCSDIO2ADPCLKISEL;
  159. else
  160. reg &= ~OMAP2_MMCSDIO2ADPCLKISEL;
  161. omap_ctrl_writel(reg, control_devconf1_offset);
  162. }
  163. static void hsmmc2_before_set_reg(struct device *dev, int slot,
  164. int power_on, int vdd)
  165. {
  166. struct omap_mmc_platform_data *mmc = dev->platform_data;
  167. if (mmc->slots[0].remux)
  168. mmc->slots[0].remux(dev, slot, power_on);
  169. if (power_on)
  170. hsmmc2_select_input_clk_src(mmc);
  171. }
  172. static int am35x_hsmmc2_set_power(struct device *dev, int slot,
  173. int power_on, int vdd)
  174. {
  175. struct omap_mmc_platform_data *mmc = dev->platform_data;
  176. if (power_on)
  177. hsmmc2_select_input_clk_src(mmc);
  178. return 0;
  179. }
  180. static int nop_mmc_set_power(struct device *dev, int slot, int power_on,
  181. int vdd)
  182. {
  183. return 0;
  184. }
  185. static inline void omap_hsmmc_mux(struct omap_mmc_platform_data *mmc_controller,
  186. int controller_nr)
  187. {
  188. if (gpio_is_valid(mmc_controller->slots[0].switch_pin) &&
  189. (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
  190. omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
  191. OMAP_PIN_INPUT_PULLUP);
  192. if (gpio_is_valid(mmc_controller->slots[0].gpio_wp) &&
  193. (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
  194. omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
  195. OMAP_PIN_INPUT_PULLUP);
  196. if (cpu_is_omap34xx()) {
  197. if (controller_nr == 0) {
  198. omap_mux_init_signal("sdmmc1_clk",
  199. OMAP_PIN_INPUT_PULLUP);
  200. omap_mux_init_signal("sdmmc1_cmd",
  201. OMAP_PIN_INPUT_PULLUP);
  202. omap_mux_init_signal("sdmmc1_dat0",
  203. OMAP_PIN_INPUT_PULLUP);
  204. if (mmc_controller->slots[0].caps &
  205. (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
  206. omap_mux_init_signal("sdmmc1_dat1",
  207. OMAP_PIN_INPUT_PULLUP);
  208. omap_mux_init_signal("sdmmc1_dat2",
  209. OMAP_PIN_INPUT_PULLUP);
  210. omap_mux_init_signal("sdmmc1_dat3",
  211. OMAP_PIN_INPUT_PULLUP);
  212. }
  213. if (mmc_controller->slots[0].caps &
  214. MMC_CAP_8_BIT_DATA) {
  215. omap_mux_init_signal("sdmmc1_dat4",
  216. OMAP_PIN_INPUT_PULLUP);
  217. omap_mux_init_signal("sdmmc1_dat5",
  218. OMAP_PIN_INPUT_PULLUP);
  219. omap_mux_init_signal("sdmmc1_dat6",
  220. OMAP_PIN_INPUT_PULLUP);
  221. omap_mux_init_signal("sdmmc1_dat7",
  222. OMAP_PIN_INPUT_PULLUP);
  223. }
  224. }
  225. if (controller_nr == 1) {
  226. /* MMC2 */
  227. omap_mux_init_signal("sdmmc2_clk",
  228. OMAP_PIN_INPUT_PULLUP);
  229. omap_mux_init_signal("sdmmc2_cmd",
  230. OMAP_PIN_INPUT_PULLUP);
  231. omap_mux_init_signal("sdmmc2_dat0",
  232. OMAP_PIN_INPUT_PULLUP);
  233. /*
  234. * For 8 wire configurations, Lines DAT4, 5, 6 and 7
  235. * need to be muxed in the board-*.c files
  236. */
  237. if (mmc_controller->slots[0].caps &
  238. (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
  239. omap_mux_init_signal("sdmmc2_dat1",
  240. OMAP_PIN_INPUT_PULLUP);
  241. omap_mux_init_signal("sdmmc2_dat2",
  242. OMAP_PIN_INPUT_PULLUP);
  243. omap_mux_init_signal("sdmmc2_dat3",
  244. OMAP_PIN_INPUT_PULLUP);
  245. }
  246. if (mmc_controller->slots[0].caps &
  247. MMC_CAP_8_BIT_DATA) {
  248. omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
  249. OMAP_PIN_INPUT_PULLUP);
  250. omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
  251. OMAP_PIN_INPUT_PULLUP);
  252. omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
  253. OMAP_PIN_INPUT_PULLUP);
  254. omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
  255. OMAP_PIN_INPUT_PULLUP);
  256. }
  257. }
  258. /*
  259. * For MMC3 the pins need to be muxed in the board-*.c files
  260. */
  261. }
  262. }
  263. static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
  264. struct omap_mmc_platform_data *mmc)
  265. {
  266. char *hc_name;
  267. hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
  268. if (!hc_name) {
  269. pr_err("Cannot allocate memory for controller slot name\n");
  270. kfree(hc_name);
  271. return -ENOMEM;
  272. }
  273. if (c->name)
  274. strncpy(hc_name, c->name, HSMMC_NAME_LEN);
  275. else
  276. snprintf(hc_name, (HSMMC_NAME_LEN + 1), "mmc%islot%i",
  277. c->mmc, 1);
  278. mmc->slots[0].name = hc_name;
  279. mmc->nr_slots = 1;
  280. mmc->slots[0].caps = c->caps;
  281. mmc->slots[0].pm_caps = c->pm_caps;
  282. mmc->slots[0].internal_clock = !c->ext_clock;
  283. mmc->max_freq = c->max_freq;
  284. if (cpu_is_omap44xx())
  285. mmc->reg_offset = OMAP4_MMC_REG_OFFSET;
  286. else
  287. mmc->reg_offset = 0;
  288. mmc->get_context_loss_count = hsmmc_get_context_loss;
  289. mmc->slots[0].switch_pin = c->gpio_cd;
  290. mmc->slots[0].gpio_wp = c->gpio_wp;
  291. mmc->slots[0].remux = c->remux;
  292. mmc->slots[0].init_card = c->init_card;
  293. if (c->cover_only)
  294. mmc->slots[0].cover = 1;
  295. if (c->nonremovable)
  296. mmc->slots[0].nonremovable = 1;
  297. if (c->power_saving)
  298. mmc->slots[0].power_saving = 1;
  299. if (c->no_off)
  300. mmc->slots[0].no_off = 1;
  301. if (c->no_off_init)
  302. mmc->slots[0].no_regulator_off_init = c->no_off_init;
  303. if (c->vcc_aux_disable_is_sleep)
  304. mmc->slots[0].vcc_aux_disable_is_sleep = 1;
  305. /*
  306. * NOTE: MMC slots should have a Vcc regulator set up.
  307. * This may be from a TWL4030-family chip, another
  308. * controllable regulator, or a fixed supply.
  309. *
  310. * temporary HACK: ocr_mask instead of fixed supply
  311. */
  312. if (soc_is_am35xx())
  313. mmc->slots[0].ocr_mask = MMC_VDD_165_195 |
  314. MMC_VDD_26_27 |
  315. MMC_VDD_27_28 |
  316. MMC_VDD_29_30 |
  317. MMC_VDD_30_31 |
  318. MMC_VDD_31_32;
  319. else
  320. mmc->slots[0].ocr_mask = c->ocr_mask;
  321. if (!soc_is_am35xx())
  322. mmc->slots[0].features |= HSMMC_HAS_PBIAS;
  323. if (cpu_is_omap44xx() && (omap_rev() > OMAP4430_REV_ES1_0))
  324. mmc->slots[0].features |= HSMMC_HAS_UPDATED_RESET;
  325. switch (c->mmc) {
  326. case 1:
  327. if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
  328. /* on-chip level shifting via PBIAS0/PBIAS1 */
  329. if (cpu_is_omap44xx()) {
  330. mmc->slots[0].before_set_reg =
  331. omap4_hsmmc1_before_set_reg;
  332. mmc->slots[0].after_set_reg =
  333. omap4_hsmmc1_after_set_reg;
  334. } else {
  335. mmc->slots[0].before_set_reg =
  336. omap_hsmmc1_before_set_reg;
  337. mmc->slots[0].after_set_reg =
  338. omap_hsmmc1_after_set_reg;
  339. }
  340. }
  341. if (soc_is_am35xx())
  342. mmc->slots[0].set_power = nop_mmc_set_power;
  343. /* OMAP3630 HSMMC1 supports only 4-bit */
  344. if (cpu_is_omap3630() &&
  345. (c->caps & MMC_CAP_8_BIT_DATA)) {
  346. c->caps &= ~MMC_CAP_8_BIT_DATA;
  347. c->caps |= MMC_CAP_4_BIT_DATA;
  348. mmc->slots[0].caps = c->caps;
  349. }
  350. break;
  351. case 2:
  352. if (soc_is_am35xx())
  353. mmc->slots[0].set_power = am35x_hsmmc2_set_power;
  354. if (c->ext_clock)
  355. c->transceiver = 1;
  356. if (c->transceiver && (c->caps & MMC_CAP_8_BIT_DATA)) {
  357. c->caps &= ~MMC_CAP_8_BIT_DATA;
  358. c->caps |= MMC_CAP_4_BIT_DATA;
  359. }
  360. if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
  361. /* off-chip level shifting, or none */
  362. mmc->slots[0].before_set_reg = hsmmc2_before_set_reg;
  363. mmc->slots[0].after_set_reg = NULL;
  364. }
  365. break;
  366. case 3:
  367. case 4:
  368. case 5:
  369. mmc->slots[0].before_set_reg = NULL;
  370. mmc->slots[0].after_set_reg = NULL;
  371. break;
  372. default:
  373. pr_err("MMC%d configuration not supported!\n", c->mmc);
  374. kfree(hc_name);
  375. return -ENODEV;
  376. }
  377. return 0;
  378. }
  379. static int omap_hsmmc_done;
  380. void omap_hsmmc_late_init(struct omap2_hsmmc_info *c)
  381. {
  382. struct platform_device *pdev;
  383. struct omap_mmc_platform_data *mmc_pdata;
  384. int res;
  385. if (omap_hsmmc_done != 1)
  386. return;
  387. omap_hsmmc_done++;
  388. for (; c->mmc; c++) {
  389. if (!c->deferred)
  390. continue;
  391. pdev = c->pdev;
  392. if (!pdev)
  393. continue;
  394. mmc_pdata = pdev->dev.platform_data;
  395. if (!mmc_pdata)
  396. continue;
  397. mmc_pdata->slots[0].switch_pin = c->gpio_cd;
  398. mmc_pdata->slots[0].gpio_wp = c->gpio_wp;
  399. res = omap_device_register(pdev);
  400. if (res)
  401. pr_err("Could not late init MMC %s\n",
  402. c->name);
  403. }
  404. }
  405. #define MAX_OMAP_MMC_HWMOD_NAME_LEN 16
  406. static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
  407. int ctrl_nr)
  408. {
  409. struct omap_hwmod *oh;
  410. struct omap_hwmod *ohs[1];
  411. struct omap_device *od;
  412. struct platform_device *pdev;
  413. char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
  414. struct omap_mmc_platform_data *mmc_data;
  415. struct omap_mmc_dev_attr *mmc_dev_attr;
  416. char *name;
  417. int res;
  418. mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
  419. if (!mmc_data) {
  420. pr_err("Cannot allocate memory for mmc device!\n");
  421. return;
  422. }
  423. res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
  424. if (res < 0)
  425. goto free_mmc;
  426. omap_hsmmc_mux(mmc_data, (ctrl_nr - 1));
  427. name = "omap_hsmmc";
  428. res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
  429. "mmc%d", ctrl_nr);
  430. WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
  431. "String buffer overflow in MMC%d device setup\n", ctrl_nr);
  432. oh = omap_hwmod_lookup(oh_name);
  433. if (!oh) {
  434. pr_err("Could not look up %s\n", oh_name);
  435. goto free_name;
  436. }
  437. ohs[0] = oh;
  438. if (oh->dev_attr != NULL) {
  439. mmc_dev_attr = oh->dev_attr;
  440. mmc_data->controller_flags = mmc_dev_attr->flags;
  441. /*
  442. * erratum 2.1.1.128 doesn't apply if board has
  443. * a transceiver is attached
  444. */
  445. if (hsmmcinfo->transceiver)
  446. mmc_data->controller_flags &=
  447. ~OMAP_HSMMC_BROKEN_MULTIBLOCK_READ;
  448. }
  449. pdev = platform_device_alloc(name, ctrl_nr - 1);
  450. if (!pdev) {
  451. pr_err("Could not allocate pdev for %s\n", name);
  452. goto free_name;
  453. }
  454. dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);
  455. od = omap_device_alloc(pdev, ohs, 1, NULL, 0);
  456. if (!od) {
  457. pr_err("Could not allocate od for %s\n", name);
  458. goto put_pdev;
  459. }
  460. res = platform_device_add_data(pdev, mmc_data,
  461. sizeof(struct omap_mmc_platform_data));
  462. if (res) {
  463. pr_err("Could not add pdata for %s\n", name);
  464. goto put_pdev;
  465. }
  466. hsmmcinfo->pdev = pdev;
  467. if (hsmmcinfo->deferred)
  468. goto free_mmc;
  469. res = omap_device_register(pdev);
  470. if (res) {
  471. pr_err("Could not register od for %s\n", name);
  472. goto free_od;
  473. }
  474. goto free_mmc;
  475. free_od:
  476. omap_device_delete(od);
  477. put_pdev:
  478. platform_device_put(pdev);
  479. free_name:
  480. kfree(mmc_data->slots[0].name);
  481. free_mmc:
  482. kfree(mmc_data);
  483. }
  484. void __init omap_hsmmc_init(struct omap2_hsmmc_info *controllers)
  485. {
  486. u32 reg;
  487. if (omap_hsmmc_done)
  488. return;
  489. omap_hsmmc_done = 1;
  490. if (!cpu_is_omap44xx()) {
  491. if (cpu_is_omap2430()) {
  492. control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
  493. control_devconf1_offset = OMAP243X_CONTROL_DEVCONF1;
  494. } else {
  495. control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
  496. control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1;
  497. }
  498. } else {
  499. control_pbias_offset =
  500. OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PBIASLITE;
  501. control_mmc1 = OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MMC1;
  502. reg = omap4_ctrl_pad_readl(control_mmc1);
  503. reg |= (OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK |
  504. OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK);
  505. reg &= ~(OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK |
  506. OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK);
  507. reg |= (OMAP4_SDMMC1_DR0_SPEEDCTRL_MASK |
  508. OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK |
  509. OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK);
  510. omap4_ctrl_pad_writel(reg, control_mmc1);
  511. }
  512. for (; controllers->mmc; controllers++)
  513. omap_hsmmc_init_one(controllers, controllers->mmc);
  514. }
  515. #endif