sdhci-dove.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * sdhci-dove.c Support for SDHCI on Marvell's Dove SoC
  3. *
  4. * Author: Saeed Bishara <saeed@marvell.com>
  5. * Mike Rapoport <mike@compulab.co.il>
  6. * Based on sdhci-cns3xxx.c
  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. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <linux/io.h>
  24. #include <linux/mmc/host.h>
  25. #include <linux/module.h>
  26. #include <linux/of.h>
  27. #include "sdhci-pltfm.h"
  28. static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
  29. {
  30. u16 ret;
  31. switch (reg) {
  32. case SDHCI_HOST_VERSION:
  33. case SDHCI_SLOT_INT_STATUS:
  34. /* those registers don't exist */
  35. return 0;
  36. default:
  37. ret = readw(host->ioaddr + reg);
  38. }
  39. return ret;
  40. }
  41. static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
  42. {
  43. u32 ret;
  44. ret = readl(host->ioaddr + reg);
  45. switch (reg) {
  46. case SDHCI_CAPABILITIES:
  47. /* Mask the support for 3.0V */
  48. ret &= ~SDHCI_CAN_VDD_300;
  49. break;
  50. }
  51. return ret;
  52. }
  53. static const struct sdhci_ops sdhci_dove_ops = {
  54. .read_w = sdhci_dove_readw,
  55. .read_l = sdhci_dove_readl,
  56. .set_clock = sdhci_set_clock,
  57. .set_bus_width = sdhci_set_bus_width,
  58. .reset = sdhci_reset,
  59. .set_uhs_signaling = sdhci_set_uhs_signaling,
  60. };
  61. static const struct sdhci_pltfm_data sdhci_dove_pdata = {
  62. .ops = &sdhci_dove_ops,
  63. .quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
  64. SDHCI_QUIRK_NO_BUSY_IRQ |
  65. SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
  66. SDHCI_QUIRK_FORCE_DMA |
  67. SDHCI_QUIRK_NO_HISPD_BIT,
  68. };
  69. static int sdhci_dove_probe(struct platform_device *pdev)
  70. {
  71. struct sdhci_host *host;
  72. struct sdhci_pltfm_host *pltfm_host;
  73. int ret;
  74. host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
  75. if (IS_ERR(host))
  76. return PTR_ERR(host);
  77. pltfm_host = sdhci_priv(host);
  78. pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
  79. if (!IS_ERR(pltfm_host->clk))
  80. clk_prepare_enable(pltfm_host->clk);
  81. ret = mmc_of_parse(host->mmc);
  82. if (ret)
  83. goto err_sdhci_add;
  84. ret = sdhci_add_host(host);
  85. if (ret)
  86. goto err_sdhci_add;
  87. return 0;
  88. err_sdhci_add:
  89. clk_disable_unprepare(pltfm_host->clk);
  90. sdhci_pltfm_free(pdev);
  91. return ret;
  92. }
  93. static const struct of_device_id sdhci_dove_of_match_table[] = {
  94. { .compatible = "marvell,dove-sdhci", },
  95. {}
  96. };
  97. MODULE_DEVICE_TABLE(of, sdhci_dove_of_match_table);
  98. static struct platform_driver sdhci_dove_driver = {
  99. .driver = {
  100. .name = "sdhci-dove",
  101. .pm = &sdhci_pltfm_pmops,
  102. .of_match_table = sdhci_dove_of_match_table,
  103. },
  104. .probe = sdhci_dove_probe,
  105. .remove = sdhci_pltfm_unregister,
  106. };
  107. module_platform_driver(sdhci_dove_driver);
  108. MODULE_DESCRIPTION("SDHCI driver for Dove");
  109. MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>, "
  110. "Mike Rapoport <mike@compulab.co.il>");
  111. MODULE_LICENSE("GPL v2");