omap_hsmmc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /*
  2. * (C) Copyright 2008
  3. * Texas Instruments, <www.ti.com>
  4. * Sukumar Ghorai <s-ghorai@ti.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation's version 2 of
  12. * the License.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include <common.h>
  26. #include <mmc.h>
  27. #include <part.h>
  28. #include <i2c.h>
  29. #include <twl4030.h>
  30. #include <twl6030.h>
  31. #include <twl6035.h>
  32. #include <asm/io.h>
  33. #include <asm/arch/mmc_host_def.h>
  34. #include <asm/arch/sys_proto.h>
  35. /* common definitions for all OMAPs */
  36. #define SYSCTL_SRC (1 << 25)
  37. #define SYSCTL_SRD (1 << 26)
  38. /* If we fail after 1 second wait, something is really bad */
  39. #define MAX_RETRY_MS 1000
  40. static int mmc_read_data(struct hsmmc *mmc_base, char *buf, unsigned int size);
  41. static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
  42. unsigned int siz);
  43. static struct mmc hsmmc_dev[2];
  44. #if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
  45. static void omap4_vmmc_pbias_config(struct mmc *mmc)
  46. {
  47. u32 value = 0;
  48. struct omap_sys_ctrl_regs *const ctrl =
  49. (struct omap_sys_ctrl_regs *) SYSCTRL_GENERAL_CORE_BASE;
  50. value = readl(&ctrl->control_pbiaslite);
  51. value &= ~(MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ);
  52. writel(value, &ctrl->control_pbiaslite);
  53. /* set VMMC to 3V */
  54. twl6030_power_mmc_init();
  55. value = readl(&ctrl->control_pbiaslite);
  56. value |= MMC1_PBIASLITE_VMODE | MMC1_PBIASLITE_PWRDNZ | MMC1_PWRDNZ;
  57. writel(value, &ctrl->control_pbiaslite);
  58. }
  59. #endif
  60. #if defined(CONFIG_OMAP54XX) && defined(CONFIG_TWL6035_POWER)
  61. static void omap5_pbias_config(struct mmc *mmc)
  62. {
  63. u32 value = 0;
  64. struct omap_sys_ctrl_regs *const ctrl =
  65. (struct omap_sys_ctrl_regs *) SYSCTRL_GENERAL_CORE_BASE;
  66. value = readl(&ctrl->control_pbias);
  67. value &= ~(SDCARD_PWRDNZ | SDCARD_BIAS_PWRDNZ);
  68. value |= SDCARD_BIAS_HIZ_MODE;
  69. writel(value, &ctrl->control_pbias);
  70. twl6035_mmc1_poweron_ldo();
  71. value = readl(&ctrl->control_pbias);
  72. value &= ~SDCARD_BIAS_HIZ_MODE;
  73. value |= SDCARD_PBIASLITE_VMODE | SDCARD_PWRDNZ | SDCARD_BIAS_PWRDNZ;
  74. writel(value, &ctrl->control_pbias);
  75. value = readl(&ctrl->control_pbias);
  76. if (value & (1 << 23)) {
  77. value &= ~(SDCARD_PWRDNZ | SDCARD_BIAS_PWRDNZ);
  78. value |= SDCARD_BIAS_HIZ_MODE;
  79. writel(value, &ctrl->control_pbias);
  80. }
  81. }
  82. #endif
  83. unsigned char mmc_board_init(struct mmc *mmc)
  84. {
  85. #if defined(CONFIG_OMAP34XX)
  86. t2_t *t2_base = (t2_t *)T2_BASE;
  87. struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
  88. u32 pbias_lite;
  89. pbias_lite = readl(&t2_base->pbias_lite);
  90. pbias_lite &= ~(PBIASLITEPWRDNZ1 | PBIASLITEPWRDNZ0);
  91. writel(pbias_lite, &t2_base->pbias_lite);
  92. #endif
  93. #if defined(CONFIG_TWL4030_POWER)
  94. twl4030_power_mmc_init();
  95. mdelay(100); /* ramp-up delay from Linux code */
  96. #endif
  97. #if defined(CONFIG_OMAP34XX)
  98. writel(pbias_lite | PBIASLITEPWRDNZ1 |
  99. PBIASSPEEDCTRL0 | PBIASLITEPWRDNZ0,
  100. &t2_base->pbias_lite);
  101. writel(readl(&t2_base->devconf0) | MMCSDIO1ADPCLKISEL,
  102. &t2_base->devconf0);
  103. writel(readl(&t2_base->devconf1) | MMCSDIO2ADPCLKISEL,
  104. &t2_base->devconf1);
  105. /* Change from default of 52MHz to 26MHz if necessary */
  106. if (!(mmc->host_caps & MMC_MODE_HS_52MHz))
  107. writel(readl(&t2_base->ctl_prog_io1) & ~CTLPROGIO1SPEEDCTRL,
  108. &t2_base->ctl_prog_io1);
  109. writel(readl(&prcm_base->fclken1_core) |
  110. EN_MMC1 | EN_MMC2 | EN_MMC3,
  111. &prcm_base->fclken1_core);
  112. writel(readl(&prcm_base->iclken1_core) |
  113. EN_MMC1 | EN_MMC2 | EN_MMC3,
  114. &prcm_base->iclken1_core);
  115. #endif
  116. #if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
  117. /* PBIAS config needed for MMC1 only */
  118. if (mmc->block_dev.dev == 0)
  119. omap4_vmmc_pbias_config(mmc);
  120. #endif
  121. #if defined(CONFIG_OMAP54XX) && defined(CONFIG_TWL6035_POWER)
  122. if (mmc->block_dev.dev == 0)
  123. omap5_pbias_config(mmc);
  124. #endif
  125. return 0;
  126. }
  127. void mmc_init_stream(struct hsmmc *mmc_base)
  128. {
  129. ulong start;
  130. writel(readl(&mmc_base->con) | INIT_INITSTREAM, &mmc_base->con);
  131. writel(MMC_CMD0, &mmc_base->cmd);
  132. start = get_timer(0);
  133. while (!(readl(&mmc_base->stat) & CC_MASK)) {
  134. if (get_timer(0) - start > MAX_RETRY_MS) {
  135. printf("%s: timedout waiting for cc!\n", __func__);
  136. return;
  137. }
  138. }
  139. writel(CC_MASK, &mmc_base->stat)
  140. ;
  141. writel(MMC_CMD0, &mmc_base->cmd)
  142. ;
  143. start = get_timer(0);
  144. while (!(readl(&mmc_base->stat) & CC_MASK)) {
  145. if (get_timer(0) - start > MAX_RETRY_MS) {
  146. printf("%s: timedout waiting for cc2!\n", __func__);
  147. return;
  148. }
  149. }
  150. writel(readl(&mmc_base->con) & ~INIT_INITSTREAM, &mmc_base->con);
  151. }
  152. static int mmc_init_setup(struct mmc *mmc)
  153. {
  154. struct hsmmc *mmc_base = (struct hsmmc *)mmc->priv;
  155. unsigned int reg_val;
  156. unsigned int dsor;
  157. ulong start;
  158. mmc_board_init(mmc);
  159. writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
  160. &mmc_base->sysconfig);
  161. start = get_timer(0);
  162. while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) {
  163. if (get_timer(0) - start > MAX_RETRY_MS) {
  164. printf("%s: timedout waiting for cc2!\n", __func__);
  165. return TIMEOUT;
  166. }
  167. }
  168. writel(readl(&mmc_base->sysctl) | SOFTRESETALL, &mmc_base->sysctl);
  169. start = get_timer(0);
  170. while ((readl(&mmc_base->sysctl) & SOFTRESETALL) != 0x0) {
  171. if (get_timer(0) - start > MAX_RETRY_MS) {
  172. printf("%s: timedout waiting for softresetall!\n",
  173. __func__);
  174. return TIMEOUT;
  175. }
  176. }
  177. writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, &mmc_base->hctl);
  178. writel(readl(&mmc_base->capa) | VS30_3V0SUP | VS18_1V8SUP,
  179. &mmc_base->capa);
  180. reg_val = readl(&mmc_base->con) & RESERVED_MASK;
  181. writel(CTPL_MMC_SD | reg_val | WPP_ACTIVEHIGH | CDP_ACTIVEHIGH |
  182. MIT_CTO | DW8_1_4BITMODE | MODE_FUNC | STR_BLOCK |
  183. HR_NOHOSTRESP | INIT_NOINIT | NOOPENDRAIN, &mmc_base->con);
  184. dsor = 240;
  185. mmc_reg_out(&mmc_base->sysctl, (ICE_MASK | DTO_MASK | CEN_MASK),
  186. (ICE_STOP | DTO_15THDTO | CEN_DISABLE));
  187. mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK,
  188. (dsor << CLKD_OFFSET) | ICE_OSCILLATE);
  189. start = get_timer(0);
  190. while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) {
  191. if (get_timer(0) - start > MAX_RETRY_MS) {
  192. printf("%s: timedout waiting for ics!\n", __func__);
  193. return TIMEOUT;
  194. }
  195. }
  196. writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl);
  197. writel(readl(&mmc_base->hctl) | SDBP_PWRON, &mmc_base->hctl);
  198. writel(IE_BADA | IE_CERR | IE_DEB | IE_DCRC | IE_DTO | IE_CIE |
  199. IE_CEB | IE_CCRC | IE_CTO | IE_BRR | IE_BWR | IE_TC | IE_CC,
  200. &mmc_base->ie);
  201. mmc_init_stream(mmc_base);
  202. return 0;
  203. }
  204. /*
  205. * MMC controller internal finite state machine reset
  206. *
  207. * Used to reset command or data internal state machines, using respectively
  208. * SRC or SRD bit of SYSCTL register
  209. */
  210. static void mmc_reset_controller_fsm(struct hsmmc *mmc_base, u32 bit)
  211. {
  212. ulong start;
  213. mmc_reg_out(&mmc_base->sysctl, bit, bit);
  214. start = get_timer(0);
  215. while ((readl(&mmc_base->sysctl) & bit) != 0) {
  216. if (get_timer(0) - start > MAX_RETRY_MS) {
  217. printf("%s: timedout waiting for sysctl %x to clear\n",
  218. __func__, bit);
  219. return;
  220. }
  221. }
  222. }
  223. static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
  224. struct mmc_data *data)
  225. {
  226. struct hsmmc *mmc_base = (struct hsmmc *)mmc->priv;
  227. unsigned int flags, mmc_stat;
  228. ulong start;
  229. start = get_timer(0);
  230. while ((readl(&mmc_base->pstate) & (DATI_MASK | CMDI_MASK)) != 0) {
  231. if (get_timer(0) - start > MAX_RETRY_MS) {
  232. printf("%s: timedout waiting on cmd inhibit to clear\n",
  233. __func__);
  234. return TIMEOUT;
  235. }
  236. }
  237. writel(0xFFFFFFFF, &mmc_base->stat);
  238. start = get_timer(0);
  239. while (readl(&mmc_base->stat)) {
  240. if (get_timer(0) - start > MAX_RETRY_MS) {
  241. printf("%s: timedout waiting for STAT (%x) to clear\n",
  242. __func__, readl(&mmc_base->stat));
  243. return TIMEOUT;
  244. }
  245. }
  246. /*
  247. * CMDREG
  248. * CMDIDX[13:8] : Command index
  249. * DATAPRNT[5] : Data Present Select
  250. * ENCMDIDX[4] : Command Index Check Enable
  251. * ENCMDCRC[3] : Command CRC Check Enable
  252. * RSPTYP[1:0]
  253. * 00 = No Response
  254. * 01 = Length 136
  255. * 10 = Length 48
  256. * 11 = Length 48 Check busy after response
  257. */
  258. /* Delay added before checking the status of frq change
  259. * retry not supported by mmc.c(core file)
  260. */
  261. if (cmd->cmdidx == SD_CMD_APP_SEND_SCR)
  262. udelay(50000); /* wait 50 ms */
  263. if (!(cmd->resp_type & MMC_RSP_PRESENT))
  264. flags = 0;
  265. else if (cmd->resp_type & MMC_RSP_136)
  266. flags = RSP_TYPE_LGHT136 | CICE_NOCHECK;
  267. else if (cmd->resp_type & MMC_RSP_BUSY)
  268. flags = RSP_TYPE_LGHT48B;
  269. else
  270. flags = RSP_TYPE_LGHT48;
  271. /* enable default flags */
  272. flags = flags | (CMD_TYPE_NORMAL | CICE_NOCHECK | CCCE_NOCHECK |
  273. MSBS_SGLEBLK | ACEN_DISABLE | BCE_DISABLE | DE_DISABLE);
  274. if (cmd->resp_type & MMC_RSP_CRC)
  275. flags |= CCCE_CHECK;
  276. if (cmd->resp_type & MMC_RSP_OPCODE)
  277. flags |= CICE_CHECK;
  278. if (data) {
  279. if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK) ||
  280. (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)) {
  281. flags |= (MSBS_MULTIBLK | BCE_ENABLE);
  282. data->blocksize = 512;
  283. writel(data->blocksize | (data->blocks << 16),
  284. &mmc_base->blk);
  285. } else
  286. writel(data->blocksize | NBLK_STPCNT, &mmc_base->blk);
  287. if (data->flags & MMC_DATA_READ)
  288. flags |= (DP_DATA | DDIR_READ);
  289. else
  290. flags |= (DP_DATA | DDIR_WRITE);
  291. }
  292. writel(cmd->cmdarg, &mmc_base->arg);
  293. writel((cmd->cmdidx << 24) | flags, &mmc_base->cmd);
  294. start = get_timer(0);
  295. do {
  296. mmc_stat = readl(&mmc_base->stat);
  297. if (get_timer(0) - start > MAX_RETRY_MS) {
  298. printf("%s : timeout: No status update\n", __func__);
  299. return TIMEOUT;
  300. }
  301. } while (!mmc_stat);
  302. if ((mmc_stat & IE_CTO) != 0) {
  303. mmc_reset_controller_fsm(mmc_base, SYSCTL_SRC);
  304. return TIMEOUT;
  305. } else if ((mmc_stat & ERRI_MASK) != 0)
  306. return -1;
  307. if (mmc_stat & CC_MASK) {
  308. writel(CC_MASK, &mmc_base->stat);
  309. if (cmd->resp_type & MMC_RSP_PRESENT) {
  310. if (cmd->resp_type & MMC_RSP_136) {
  311. /* response type 2 */
  312. cmd->response[3] = readl(&mmc_base->rsp10);
  313. cmd->response[2] = readl(&mmc_base->rsp32);
  314. cmd->response[1] = readl(&mmc_base->rsp54);
  315. cmd->response[0] = readl(&mmc_base->rsp76);
  316. } else
  317. /* response types 1, 1b, 3, 4, 5, 6 */
  318. cmd->response[0] = readl(&mmc_base->rsp10);
  319. }
  320. }
  321. if (data && (data->flags & MMC_DATA_READ)) {
  322. mmc_read_data(mmc_base, data->dest,
  323. data->blocksize * data->blocks);
  324. } else if (data && (data->flags & MMC_DATA_WRITE)) {
  325. mmc_write_data(mmc_base, data->src,
  326. data->blocksize * data->blocks);
  327. }
  328. return 0;
  329. }
  330. static int mmc_read_data(struct hsmmc *mmc_base, char *buf, unsigned int size)
  331. {
  332. unsigned int *output_buf = (unsigned int *)buf;
  333. unsigned int mmc_stat;
  334. unsigned int count;
  335. /*
  336. * Start Polled Read
  337. */
  338. count = (size > MMCSD_SECTOR_SIZE) ? MMCSD_SECTOR_SIZE : size;
  339. count /= 4;
  340. while (size) {
  341. ulong start = get_timer(0);
  342. do {
  343. mmc_stat = readl(&mmc_base->stat);
  344. if (get_timer(0) - start > MAX_RETRY_MS) {
  345. printf("%s: timedout waiting for status!\n",
  346. __func__);
  347. return TIMEOUT;
  348. }
  349. } while (mmc_stat == 0);
  350. if ((mmc_stat & (IE_DTO | IE_DCRC | IE_DEB)) != 0)
  351. mmc_reset_controller_fsm(mmc_base, SYSCTL_SRD);
  352. if ((mmc_stat & ERRI_MASK) != 0)
  353. return 1;
  354. if (mmc_stat & BRR_MASK) {
  355. unsigned int k;
  356. writel(readl(&mmc_base->stat) | BRR_MASK,
  357. &mmc_base->stat);
  358. for (k = 0; k < count; k++) {
  359. *output_buf = readl(&mmc_base->data);
  360. output_buf++;
  361. }
  362. size -= (count*4);
  363. }
  364. if (mmc_stat & BWR_MASK)
  365. writel(readl(&mmc_base->stat) | BWR_MASK,
  366. &mmc_base->stat);
  367. if (mmc_stat & TC_MASK) {
  368. writel(readl(&mmc_base->stat) | TC_MASK,
  369. &mmc_base->stat);
  370. break;
  371. }
  372. }
  373. return 0;
  374. }
  375. static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
  376. unsigned int size)
  377. {
  378. unsigned int *input_buf = (unsigned int *)buf;
  379. unsigned int mmc_stat;
  380. unsigned int count;
  381. /*
  382. * Start Polled Read
  383. */
  384. count = (size > MMCSD_SECTOR_SIZE) ? MMCSD_SECTOR_SIZE : size;
  385. count /= 4;
  386. while (size) {
  387. ulong start = get_timer(0);
  388. do {
  389. mmc_stat = readl(&mmc_base->stat);
  390. if (get_timer(0) - start > MAX_RETRY_MS) {
  391. printf("%s: timedout waiting for status!\n",
  392. __func__);
  393. return TIMEOUT;
  394. }
  395. } while (mmc_stat == 0);
  396. if ((mmc_stat & (IE_DTO | IE_DCRC | IE_DEB)) != 0)
  397. mmc_reset_controller_fsm(mmc_base, SYSCTL_SRD);
  398. if ((mmc_stat & ERRI_MASK) != 0)
  399. return 1;
  400. if (mmc_stat & BWR_MASK) {
  401. unsigned int k;
  402. writel(readl(&mmc_base->stat) | BWR_MASK,
  403. &mmc_base->stat);
  404. for (k = 0; k < count; k++) {
  405. writel(*input_buf, &mmc_base->data);
  406. input_buf++;
  407. }
  408. size -= (count*4);
  409. }
  410. if (mmc_stat & BRR_MASK)
  411. writel(readl(&mmc_base->stat) | BRR_MASK,
  412. &mmc_base->stat);
  413. if (mmc_stat & TC_MASK) {
  414. writel(readl(&mmc_base->stat) | TC_MASK,
  415. &mmc_base->stat);
  416. break;
  417. }
  418. }
  419. return 0;
  420. }
  421. static void mmc_set_ios(struct mmc *mmc)
  422. {
  423. struct hsmmc *mmc_base = (struct hsmmc *)mmc->priv;
  424. unsigned int dsor = 0;
  425. ulong start;
  426. /* configue bus width */
  427. switch (mmc->bus_width) {
  428. case 8:
  429. writel(readl(&mmc_base->con) | DTW_8_BITMODE,
  430. &mmc_base->con);
  431. break;
  432. case 4:
  433. writel(readl(&mmc_base->con) & ~DTW_8_BITMODE,
  434. &mmc_base->con);
  435. writel(readl(&mmc_base->hctl) | DTW_4_BITMODE,
  436. &mmc_base->hctl);
  437. break;
  438. case 1:
  439. default:
  440. writel(readl(&mmc_base->con) & ~DTW_8_BITMODE,
  441. &mmc_base->con);
  442. writel(readl(&mmc_base->hctl) & ~DTW_4_BITMODE,
  443. &mmc_base->hctl);
  444. break;
  445. }
  446. /* configure clock with 96Mhz system clock.
  447. */
  448. if (mmc->clock != 0) {
  449. dsor = (MMC_CLOCK_REFERENCE * 1000000 / mmc->clock);
  450. if ((MMC_CLOCK_REFERENCE * 1000000) / dsor > mmc->clock)
  451. dsor++;
  452. }
  453. mmc_reg_out(&mmc_base->sysctl, (ICE_MASK | DTO_MASK | CEN_MASK),
  454. (ICE_STOP | DTO_15THDTO | CEN_DISABLE));
  455. mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK,
  456. (dsor << CLKD_OFFSET) | ICE_OSCILLATE);
  457. start = get_timer(0);
  458. while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) {
  459. if (get_timer(0) - start > MAX_RETRY_MS) {
  460. printf("%s: timedout waiting for ics!\n", __func__);
  461. return;
  462. }
  463. }
  464. writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl);
  465. }
  466. int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max)
  467. {
  468. struct mmc *mmc;
  469. mmc = &hsmmc_dev[dev_index];
  470. sprintf(mmc->name, "OMAP SD/MMC");
  471. mmc->send_cmd = mmc_send_cmd;
  472. mmc->set_ios = mmc_set_ios;
  473. mmc->init = mmc_init_setup;
  474. mmc->getcd = NULL;
  475. switch (dev_index) {
  476. case 0:
  477. mmc->priv = (struct hsmmc *)OMAP_HSMMC1_BASE;
  478. break;
  479. #ifdef OMAP_HSMMC2_BASE
  480. case 1:
  481. mmc->priv = (struct hsmmc *)OMAP_HSMMC2_BASE;
  482. break;
  483. #endif
  484. #ifdef OMAP_HSMMC3_BASE
  485. case 2:
  486. mmc->priv = (struct hsmmc *)OMAP_HSMMC3_BASE;
  487. break;
  488. #endif
  489. default:
  490. mmc->priv = (struct hsmmc *)OMAP_HSMMC1_BASE;
  491. return 1;
  492. }
  493. mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
  494. mmc->host_caps = (MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS |
  495. MMC_MODE_HC) & ~host_caps_mask;
  496. mmc->f_min = 400000;
  497. if (f_max != 0)
  498. mmc->f_max = f_max;
  499. else {
  500. if (mmc->host_caps & MMC_MODE_HS) {
  501. if (mmc->host_caps & MMC_MODE_HS_52MHz)
  502. mmc->f_max = 52000000;
  503. else
  504. mmc->f_max = 26000000;
  505. } else
  506. mmc->f_max = 20000000;
  507. }
  508. mmc->b_max = 0;
  509. #if defined(CONFIG_OMAP34XX)
  510. /*
  511. * Silicon revs 2.1 and older do not support multiblock transfers.
  512. */
  513. if ((get_cpu_family() == CPU_OMAP34XX) && (get_cpu_rev() <= CPU_3XX_ES21))
  514. mmc->b_max = 1;
  515. #endif
  516. mmc_register(mmc);
  517. return 0;
  518. }