sdhci-of-hlwd.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * drivers/mmc/host/sdhci-of-hlwd.c
  4. *
  5. * Nintendo Wii Secure Digital Host Controller Interface.
  6. * Copyright (C) 2009 The GameCube Linux Team
  7. * Copyright (C) 2009 Albert Herranz
  8. *
  9. * Based on sdhci-of-esdhc.c
  10. *
  11. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  12. * Copyright (c) 2009 MontaVista Software, Inc.
  13. *
  14. * Authors: Xiaobo Xie <[email protected]>
  15. * Anton Vorontsov <[email protected]>
  16. */
  17. #include <linux/delay.h>
  18. #include <linux/module.h>
  19. #include <linux/mmc/host.h>
  20. #include "sdhci-pltfm.h"
  21. /*
  22. * Ops and quirks for the Nintendo Wii SDHCI controllers.
  23. */
  24. /*
  25. * We need a small delay after each write, or things go horribly wrong.
  26. */
  27. #define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */
  28. static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
  29. {
  30. sdhci_be32bs_writel(host, val, reg);
  31. udelay(SDHCI_HLWD_WRITE_DELAY);
  32. }
  33. static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
  34. {
  35. sdhci_be32bs_writew(host, val, reg);
  36. udelay(SDHCI_HLWD_WRITE_DELAY);
  37. }
  38. static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
  39. {
  40. sdhci_be32bs_writeb(host, val, reg);
  41. udelay(SDHCI_HLWD_WRITE_DELAY);
  42. }
  43. static const struct sdhci_ops sdhci_hlwd_ops = {
  44. .read_l = sdhci_be32bs_readl,
  45. .read_w = sdhci_be32bs_readw,
  46. .read_b = sdhci_be32bs_readb,
  47. .write_l = sdhci_hlwd_writel,
  48. .write_w = sdhci_hlwd_writew,
  49. .write_b = sdhci_hlwd_writeb,
  50. .set_clock = sdhci_set_clock,
  51. .set_bus_width = sdhci_set_bus_width,
  52. .reset = sdhci_reset,
  53. .set_uhs_signaling = sdhci_set_uhs_signaling,
  54. };
  55. static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
  56. .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
  57. SDHCI_QUIRK_32BIT_DMA_SIZE,
  58. .ops = &sdhci_hlwd_ops,
  59. };
  60. static int sdhci_hlwd_probe(struct platform_device *pdev)
  61. {
  62. return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
  63. }
  64. static const struct of_device_id sdhci_hlwd_of_match[] = {
  65. { .compatible = "nintendo,hollywood-sdhci" },
  66. { }
  67. };
  68. MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match);
  69. static struct platform_driver sdhci_hlwd_driver = {
  70. .driver = {
  71. .name = "sdhci-hlwd",
  72. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  73. .of_match_table = sdhci_hlwd_of_match,
  74. .pm = &sdhci_pltfm_pmops,
  75. },
  76. .probe = sdhci_hlwd_probe,
  77. .remove = sdhci_pltfm_unregister,
  78. };
  79. module_platform_driver(sdhci_hlwd_driver);
  80. MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver");
  81. MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz");
  82. MODULE_LICENSE("GPL v2");