sdhci-of-aspeed.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* Copyright (C) 2019 ASPEED Technology Inc. */
  3. /* Copyright (C) 2019 IBM Corp. */
  4. #include <linux/clk.h>
  5. #include <linux/delay.h>
  6. #include <linux/device.h>
  7. #include <linux/io.h>
  8. #include <linux/math64.h>
  9. #include <linux/mmc/host.h>
  10. #include <linux/module.h>
  11. #include <linux/of_address.h>
  12. #include <linux/of.h>
  13. #include <linux/of_platform.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/spinlock.h>
  16. #include "sdhci-pltfm.h"
  17. #define ASPEED_SDC_INFO 0x00
  18. #define ASPEED_SDC_S1_MMC8 BIT(25)
  19. #define ASPEED_SDC_S0_MMC8 BIT(24)
  20. #define ASPEED_SDC_PHASE 0xf4
  21. #define ASPEED_SDC_S1_PHASE_IN GENMASK(25, 21)
  22. #define ASPEED_SDC_S0_PHASE_IN GENMASK(20, 16)
  23. #define ASPEED_SDC_S1_PHASE_OUT GENMASK(15, 11)
  24. #define ASPEED_SDC_S1_PHASE_IN_EN BIT(10)
  25. #define ASPEED_SDC_S1_PHASE_OUT_EN GENMASK(9, 8)
  26. #define ASPEED_SDC_S0_PHASE_OUT GENMASK(7, 3)
  27. #define ASPEED_SDC_S0_PHASE_IN_EN BIT(2)
  28. #define ASPEED_SDC_S0_PHASE_OUT_EN GENMASK(1, 0)
  29. #define ASPEED_SDC_PHASE_MAX 31
  30. /* SDIO{10,20} */
  31. #define ASPEED_SDC_CAP1_1_8V (0 * 32 + 26)
  32. /* SDIO{14,24} */
  33. #define ASPEED_SDC_CAP2_SDR104 (1 * 32 + 1)
  34. struct aspeed_sdc {
  35. struct clk *clk;
  36. struct resource *res;
  37. spinlock_t lock;
  38. void __iomem *regs;
  39. };
  40. struct aspeed_sdhci_tap_param {
  41. bool valid;
  42. #define ASPEED_SDHCI_TAP_PARAM_INVERT_CLK BIT(4)
  43. u8 in;
  44. u8 out;
  45. };
  46. struct aspeed_sdhci_tap_desc {
  47. u32 tap_mask;
  48. u32 enable_mask;
  49. u8 enable_value;
  50. };
  51. struct aspeed_sdhci_phase_desc {
  52. struct aspeed_sdhci_tap_desc in;
  53. struct aspeed_sdhci_tap_desc out;
  54. };
  55. struct aspeed_sdhci_pdata {
  56. unsigned int clk_div_start;
  57. const struct aspeed_sdhci_phase_desc *phase_desc;
  58. size_t nr_phase_descs;
  59. };
  60. struct aspeed_sdhci {
  61. const struct aspeed_sdhci_pdata *pdata;
  62. struct aspeed_sdc *parent;
  63. u32 width_mask;
  64. struct mmc_clk_phase_map phase_map;
  65. const struct aspeed_sdhci_phase_desc *phase_desc;
  66. };
  67. /*
  68. * The function sets the mirror register for updating
  69. * capbilities of the current slot.
  70. *
  71. * slot | capability | caps_reg | mirror_reg
  72. * -----|-------------|----------|------------
  73. * 0 | CAP1_1_8V | SDIO140 | SDIO10
  74. * 0 | CAP2_SDR104 | SDIO144 | SDIO14
  75. * 1 | CAP1_1_8V | SDIO240 | SDIO20
  76. * 1 | CAP2_SDR104 | SDIO244 | SDIO24
  77. */
  78. static void aspeed_sdc_set_slot_capability(struct sdhci_host *host, struct aspeed_sdc *sdc,
  79. int capability, bool enable, u8 slot)
  80. {
  81. u32 mirror_reg_offset;
  82. u32 cap_val;
  83. u8 cap_reg;
  84. if (slot > 1)
  85. return;
  86. cap_reg = capability / 32;
  87. cap_val = sdhci_readl(host, 0x40 + (cap_reg * 4));
  88. if (enable)
  89. cap_val |= BIT(capability % 32);
  90. else
  91. cap_val &= ~BIT(capability % 32);
  92. mirror_reg_offset = ((slot + 1) * 0x10) + (cap_reg * 4);
  93. writel(cap_val, sdc->regs + mirror_reg_offset);
  94. }
  95. static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,
  96. struct aspeed_sdhci *sdhci,
  97. bool bus8)
  98. {
  99. u32 info;
  100. /* Set/clear 8 bit mode */
  101. spin_lock(&sdc->lock);
  102. info = readl(sdc->regs + ASPEED_SDC_INFO);
  103. if (bus8)
  104. info |= sdhci->width_mask;
  105. else
  106. info &= ~sdhci->width_mask;
  107. writel(info, sdc->regs + ASPEED_SDC_INFO);
  108. spin_unlock(&sdc->lock);
  109. }
  110. static u32
  111. aspeed_sdc_set_phase_tap(const struct aspeed_sdhci_tap_desc *desc,
  112. u8 tap, bool enable, u32 reg)
  113. {
  114. reg &= ~(desc->enable_mask | desc->tap_mask);
  115. if (enable) {
  116. reg |= tap << __ffs(desc->tap_mask);
  117. reg |= desc->enable_value << __ffs(desc->enable_mask);
  118. }
  119. return reg;
  120. }
  121. static void
  122. aspeed_sdc_set_phase_taps(struct aspeed_sdc *sdc,
  123. const struct aspeed_sdhci_phase_desc *desc,
  124. const struct aspeed_sdhci_tap_param *taps)
  125. {
  126. u32 reg;
  127. spin_lock(&sdc->lock);
  128. reg = readl(sdc->regs + ASPEED_SDC_PHASE);
  129. reg = aspeed_sdc_set_phase_tap(&desc->in, taps->in, taps->valid, reg);
  130. reg = aspeed_sdc_set_phase_tap(&desc->out, taps->out, taps->valid, reg);
  131. writel(reg, sdc->regs + ASPEED_SDC_PHASE);
  132. spin_unlock(&sdc->lock);
  133. }
  134. #define PICOSECONDS_PER_SECOND 1000000000000ULL
  135. #define ASPEED_SDHCI_NR_TAPS 15
  136. /* Measured value with *handwave* environmentals and static loading */
  137. #define ASPEED_SDHCI_MAX_TAP_DELAY_PS 1253
  138. static int aspeed_sdhci_phase_to_tap(struct device *dev, unsigned long rate_hz,
  139. int phase_deg)
  140. {
  141. u64 phase_period_ps;
  142. u64 prop_delay_ps;
  143. u64 clk_period_ps;
  144. unsigned int tap;
  145. u8 inverted;
  146. phase_deg %= 360;
  147. if (phase_deg >= 180) {
  148. inverted = ASPEED_SDHCI_TAP_PARAM_INVERT_CLK;
  149. phase_deg -= 180;
  150. dev_dbg(dev,
  151. "Inverting clock to reduce phase correction from %d to %d degrees\n",
  152. phase_deg + 180, phase_deg);
  153. } else {
  154. inverted = 0;
  155. }
  156. prop_delay_ps = ASPEED_SDHCI_MAX_TAP_DELAY_PS / ASPEED_SDHCI_NR_TAPS;
  157. clk_period_ps = div_u64(PICOSECONDS_PER_SECOND, (u64)rate_hz);
  158. phase_period_ps = div_u64((u64)phase_deg * clk_period_ps, 360ULL);
  159. tap = div_u64(phase_period_ps, prop_delay_ps);
  160. if (tap > ASPEED_SDHCI_NR_TAPS) {
  161. dev_dbg(dev,
  162. "Requested out of range phase tap %d for %d degrees of phase compensation at %luHz, clamping to tap %d\n",
  163. tap, phase_deg, rate_hz, ASPEED_SDHCI_NR_TAPS);
  164. tap = ASPEED_SDHCI_NR_TAPS;
  165. }
  166. return inverted | tap;
  167. }
  168. static void
  169. aspeed_sdhci_phases_to_taps(struct device *dev, unsigned long rate,
  170. const struct mmc_clk_phase *phases,
  171. struct aspeed_sdhci_tap_param *taps)
  172. {
  173. taps->valid = phases->valid;
  174. if (!phases->valid)
  175. return;
  176. taps->in = aspeed_sdhci_phase_to_tap(dev, rate, phases->in_deg);
  177. taps->out = aspeed_sdhci_phase_to_tap(dev, rate, phases->out_deg);
  178. }
  179. static void
  180. aspeed_sdhci_configure_phase(struct sdhci_host *host, unsigned long rate)
  181. {
  182. struct aspeed_sdhci_tap_param _taps = {0}, *taps = &_taps;
  183. struct mmc_clk_phase *params;
  184. struct aspeed_sdhci *sdhci;
  185. struct device *dev;
  186. dev = mmc_dev(host->mmc);
  187. sdhci = sdhci_pltfm_priv(sdhci_priv(host));
  188. if (!sdhci->phase_desc)
  189. return;
  190. params = &sdhci->phase_map.phase[host->timing];
  191. aspeed_sdhci_phases_to_taps(dev, rate, params, taps);
  192. aspeed_sdc_set_phase_taps(sdhci->parent, sdhci->phase_desc, taps);
  193. dev_dbg(dev,
  194. "Using taps [%d, %d] for [%d, %d] degrees of phase correction at %luHz (%d)\n",
  195. taps->in & ASPEED_SDHCI_NR_TAPS,
  196. taps->out & ASPEED_SDHCI_NR_TAPS,
  197. params->in_deg, params->out_deg, rate, host->timing);
  198. }
  199. static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
  200. {
  201. struct sdhci_pltfm_host *pltfm_host;
  202. unsigned long parent, bus;
  203. struct aspeed_sdhci *sdhci;
  204. int div;
  205. u16 clk;
  206. pltfm_host = sdhci_priv(host);
  207. sdhci = sdhci_pltfm_priv(pltfm_host);
  208. parent = clk_get_rate(pltfm_host->clk);
  209. sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
  210. if (clock == 0)
  211. return;
  212. if (WARN_ON(clock > host->max_clk))
  213. clock = host->max_clk;
  214. /*
  215. * Regarding the AST2600:
  216. *
  217. * If (EMMC12C[7:6], EMMC12C[15:8] == 0) then
  218. * period of SDCLK = period of SDMCLK.
  219. *
  220. * If (EMMC12C[7:6], EMMC12C[15:8] != 0) then
  221. * period of SDCLK = period of SDMCLK * 2 * (EMMC12C[7:6], EMMC[15:8])
  222. *
  223. * If you keep EMMC12C[7:6] = 0 and EMMC12C[15:8] as one-hot,
  224. * 0x1/0x2/0x4/etc, you will find it is compatible to AST2400 or AST2500
  225. *
  226. * Keep the one-hot behaviour for backwards compatibility except for
  227. * supporting the value 0 in (EMMC12C[7:6], EMMC12C[15:8]), and capture
  228. * the 0-value capability in clk_div_start.
  229. */
  230. for (div = sdhci->pdata->clk_div_start; div < 256; div *= 2) {
  231. bus = parent / div;
  232. if (bus <= clock)
  233. break;
  234. }
  235. div >>= 1;
  236. clk = div << SDHCI_DIVIDER_SHIFT;
  237. aspeed_sdhci_configure_phase(host, bus);
  238. sdhci_enable_clk(host, clk);
  239. }
  240. static unsigned int aspeed_sdhci_get_max_clock(struct sdhci_host *host)
  241. {
  242. if (host->mmc->f_max)
  243. return host->mmc->f_max;
  244. return sdhci_pltfm_clk_get_max_clock(host);
  245. }
  246. static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)
  247. {
  248. struct sdhci_pltfm_host *pltfm_priv;
  249. struct aspeed_sdhci *aspeed_sdhci;
  250. struct aspeed_sdc *aspeed_sdc;
  251. u8 ctrl;
  252. pltfm_priv = sdhci_priv(host);
  253. aspeed_sdhci = sdhci_pltfm_priv(pltfm_priv);
  254. aspeed_sdc = aspeed_sdhci->parent;
  255. /* Set/clear 8-bit mode */
  256. aspeed_sdc_configure_8bit_mode(aspeed_sdc, aspeed_sdhci,
  257. width == MMC_BUS_WIDTH_8);
  258. /* Set/clear 1 or 4 bit mode */
  259. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  260. if (width == MMC_BUS_WIDTH_4)
  261. ctrl |= SDHCI_CTRL_4BITBUS;
  262. else
  263. ctrl &= ~SDHCI_CTRL_4BITBUS;
  264. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  265. }
  266. static u32 aspeed_sdhci_readl(struct sdhci_host *host, int reg)
  267. {
  268. u32 val = readl(host->ioaddr + reg);
  269. if (unlikely(reg == SDHCI_PRESENT_STATE) &&
  270. (host->mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH))
  271. val ^= SDHCI_CARD_PRESENT;
  272. return val;
  273. }
  274. static const struct sdhci_ops aspeed_sdhci_ops = {
  275. .read_l = aspeed_sdhci_readl,
  276. .set_clock = aspeed_sdhci_set_clock,
  277. .get_max_clock = aspeed_sdhci_get_max_clock,
  278. .set_bus_width = aspeed_sdhci_set_bus_width,
  279. .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
  280. .reset = sdhci_reset,
  281. .set_uhs_signaling = sdhci_set_uhs_signaling,
  282. };
  283. static const struct sdhci_pltfm_data aspeed_sdhci_pdata = {
  284. .ops = &aspeed_sdhci_ops,
  285. .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
  286. };
  287. static inline int aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev,
  288. struct resource *res)
  289. {
  290. resource_size_t delta;
  291. if (!res || resource_type(res) != IORESOURCE_MEM)
  292. return -EINVAL;
  293. if (res->start < dev->parent->res->start)
  294. return -EINVAL;
  295. delta = res->start - dev->parent->res->start;
  296. if (delta & (0x100 - 1))
  297. return -EINVAL;
  298. return (delta / 0x100) - 1;
  299. }
  300. static int aspeed_sdhci_probe(struct platform_device *pdev)
  301. {
  302. const struct aspeed_sdhci_pdata *aspeed_pdata;
  303. struct device_node *np = pdev->dev.of_node;
  304. struct sdhci_pltfm_host *pltfm_host;
  305. struct aspeed_sdhci *dev;
  306. struct sdhci_host *host;
  307. struct resource *res;
  308. int slot;
  309. int ret;
  310. aspeed_pdata = of_device_get_match_data(&pdev->dev);
  311. if (!aspeed_pdata) {
  312. dev_err(&pdev->dev, "Missing platform configuration data\n");
  313. return -EINVAL;
  314. }
  315. host = sdhci_pltfm_init(pdev, &aspeed_sdhci_pdata, sizeof(*dev));
  316. if (IS_ERR(host))
  317. return PTR_ERR(host);
  318. pltfm_host = sdhci_priv(host);
  319. dev = sdhci_pltfm_priv(pltfm_host);
  320. dev->pdata = aspeed_pdata;
  321. dev->parent = dev_get_drvdata(pdev->dev.parent);
  322. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  323. slot = aspeed_sdhci_calculate_slot(dev, res);
  324. if (slot < 0)
  325. return slot;
  326. else if (slot >= 2)
  327. return -EINVAL;
  328. if (slot < dev->pdata->nr_phase_descs) {
  329. dev->phase_desc = &dev->pdata->phase_desc[slot];
  330. } else {
  331. dev_info(&pdev->dev,
  332. "Phase control not supported for slot %d\n", slot);
  333. dev->phase_desc = NULL;
  334. }
  335. dev->width_mask = !slot ? ASPEED_SDC_S0_MMC8 : ASPEED_SDC_S1_MMC8;
  336. dev_info(&pdev->dev, "Configured for slot %d\n", slot);
  337. sdhci_get_of_property(pdev);
  338. if (of_property_read_bool(np, "mmc-hs200-1_8v") ||
  339. of_property_read_bool(np, "sd-uhs-sdr104")) {
  340. aspeed_sdc_set_slot_capability(host, dev->parent, ASPEED_SDC_CAP1_1_8V,
  341. true, slot);
  342. }
  343. if (of_property_read_bool(np, "sd-uhs-sdr104")) {
  344. aspeed_sdc_set_slot_capability(host, dev->parent, ASPEED_SDC_CAP2_SDR104,
  345. true, slot);
  346. }
  347. pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
  348. if (IS_ERR(pltfm_host->clk))
  349. return PTR_ERR(pltfm_host->clk);
  350. ret = clk_prepare_enable(pltfm_host->clk);
  351. if (ret) {
  352. dev_err(&pdev->dev, "Unable to enable SDIO clock\n");
  353. goto err_pltfm_free;
  354. }
  355. ret = mmc_of_parse(host->mmc);
  356. if (ret)
  357. goto err_sdhci_add;
  358. if (dev->phase_desc)
  359. mmc_of_parse_clk_phase(host->mmc, &dev->phase_map);
  360. ret = sdhci_add_host(host);
  361. if (ret)
  362. goto err_sdhci_add;
  363. return 0;
  364. err_sdhci_add:
  365. clk_disable_unprepare(pltfm_host->clk);
  366. err_pltfm_free:
  367. sdhci_pltfm_free(pdev);
  368. return ret;
  369. }
  370. static int aspeed_sdhci_remove(struct platform_device *pdev)
  371. {
  372. struct sdhci_pltfm_host *pltfm_host;
  373. struct sdhci_host *host;
  374. int dead = 0;
  375. host = platform_get_drvdata(pdev);
  376. pltfm_host = sdhci_priv(host);
  377. sdhci_remove_host(host, dead);
  378. clk_disable_unprepare(pltfm_host->clk);
  379. sdhci_pltfm_free(pdev);
  380. return 0;
  381. }
  382. static const struct aspeed_sdhci_pdata ast2400_sdhci_pdata = {
  383. .clk_div_start = 2,
  384. };
  385. static const struct aspeed_sdhci_phase_desc ast2600_sdhci_phase[] = {
  386. /* SDHCI/Slot 0 */
  387. [0] = {
  388. .in = {
  389. .tap_mask = ASPEED_SDC_S0_PHASE_IN,
  390. .enable_mask = ASPEED_SDC_S0_PHASE_IN_EN,
  391. .enable_value = 1,
  392. },
  393. .out = {
  394. .tap_mask = ASPEED_SDC_S0_PHASE_OUT,
  395. .enable_mask = ASPEED_SDC_S0_PHASE_OUT_EN,
  396. .enable_value = 3,
  397. },
  398. },
  399. /* SDHCI/Slot 1 */
  400. [1] = {
  401. .in = {
  402. .tap_mask = ASPEED_SDC_S1_PHASE_IN,
  403. .enable_mask = ASPEED_SDC_S1_PHASE_IN_EN,
  404. .enable_value = 1,
  405. },
  406. .out = {
  407. .tap_mask = ASPEED_SDC_S1_PHASE_OUT,
  408. .enable_mask = ASPEED_SDC_S1_PHASE_OUT_EN,
  409. .enable_value = 3,
  410. },
  411. },
  412. };
  413. static const struct aspeed_sdhci_pdata ast2600_sdhci_pdata = {
  414. .clk_div_start = 1,
  415. .phase_desc = ast2600_sdhci_phase,
  416. .nr_phase_descs = ARRAY_SIZE(ast2600_sdhci_phase),
  417. };
  418. static const struct of_device_id aspeed_sdhci_of_match[] = {
  419. { .compatible = "aspeed,ast2400-sdhci", .data = &ast2400_sdhci_pdata, },
  420. { .compatible = "aspeed,ast2500-sdhci", .data = &ast2400_sdhci_pdata, },
  421. { .compatible = "aspeed,ast2600-sdhci", .data = &ast2600_sdhci_pdata, },
  422. { }
  423. };
  424. static struct platform_driver aspeed_sdhci_driver = {
  425. .driver = {
  426. .name = "sdhci-aspeed",
  427. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  428. .of_match_table = aspeed_sdhci_of_match,
  429. },
  430. .probe = aspeed_sdhci_probe,
  431. .remove = aspeed_sdhci_remove,
  432. };
  433. static int aspeed_sdc_probe(struct platform_device *pdev)
  434. {
  435. struct device_node *parent, *child;
  436. struct aspeed_sdc *sdc;
  437. int ret;
  438. sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL);
  439. if (!sdc)
  440. return -ENOMEM;
  441. spin_lock_init(&sdc->lock);
  442. sdc->clk = devm_clk_get(&pdev->dev, NULL);
  443. if (IS_ERR(sdc->clk))
  444. return PTR_ERR(sdc->clk);
  445. ret = clk_prepare_enable(sdc->clk);
  446. if (ret) {
  447. dev_err(&pdev->dev, "Unable to enable SDCLK\n");
  448. return ret;
  449. }
  450. sdc->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  451. sdc->regs = devm_ioremap_resource(&pdev->dev, sdc->res);
  452. if (IS_ERR(sdc->regs)) {
  453. ret = PTR_ERR(sdc->regs);
  454. goto err_clk;
  455. }
  456. dev_set_drvdata(&pdev->dev, sdc);
  457. parent = pdev->dev.of_node;
  458. for_each_available_child_of_node(parent, child) {
  459. struct platform_device *cpdev;
  460. cpdev = of_platform_device_create(child, NULL, &pdev->dev);
  461. if (!cpdev) {
  462. of_node_put(child);
  463. ret = -ENODEV;
  464. goto err_clk;
  465. }
  466. }
  467. return 0;
  468. err_clk:
  469. clk_disable_unprepare(sdc->clk);
  470. return ret;
  471. }
  472. static int aspeed_sdc_remove(struct platform_device *pdev)
  473. {
  474. struct aspeed_sdc *sdc = dev_get_drvdata(&pdev->dev);
  475. clk_disable_unprepare(sdc->clk);
  476. return 0;
  477. }
  478. static const struct of_device_id aspeed_sdc_of_match[] = {
  479. { .compatible = "aspeed,ast2400-sd-controller", },
  480. { .compatible = "aspeed,ast2500-sd-controller", },
  481. { .compatible = "aspeed,ast2600-sd-controller", },
  482. { }
  483. };
  484. MODULE_DEVICE_TABLE(of, aspeed_sdc_of_match);
  485. static struct platform_driver aspeed_sdc_driver = {
  486. .driver = {
  487. .name = "sd-controller-aspeed",
  488. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  489. .pm = &sdhci_pltfm_pmops,
  490. .of_match_table = aspeed_sdc_of_match,
  491. },
  492. .probe = aspeed_sdc_probe,
  493. .remove = aspeed_sdc_remove,
  494. };
  495. #if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST)
  496. #include "sdhci-of-aspeed-test.c"
  497. #endif
  498. static int __init aspeed_sdc_init(void)
  499. {
  500. int rc;
  501. rc = platform_driver_register(&aspeed_sdhci_driver);
  502. if (rc < 0)
  503. return rc;
  504. rc = platform_driver_register(&aspeed_sdc_driver);
  505. if (rc < 0)
  506. platform_driver_unregister(&aspeed_sdhci_driver);
  507. return rc;
  508. }
  509. module_init(aspeed_sdc_init);
  510. static void __exit aspeed_sdc_exit(void)
  511. {
  512. platform_driver_unregister(&aspeed_sdc_driver);
  513. platform_driver_unregister(&aspeed_sdhci_driver);
  514. }
  515. module_exit(aspeed_sdc_exit);
  516. MODULE_DESCRIPTION("Driver for the ASPEED SD/SDIO/SDHCI Controllers");
  517. MODULE_AUTHOR("Ryan Chen <[email protected]>");
  518. MODULE_AUTHOR("Andrew Jeffery <[email protected]>");
  519. MODULE_LICENSE("GPL");