sdhci-of-hlwd.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * drivers/mmc/host/sdhci-of-hlwd.c
  3. *
  4. * Nintendo Wii Secure Digital Host Controller Interface.
  5. * Copyright (C) 2009 The GameCube Linux Team
  6. * Copyright (C) 2009 Albert Herranz
  7. *
  8. * Based on sdhci-of-esdhc.c
  9. *
  10. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  11. * Copyright (c) 2009 MontaVista Software, Inc.
  12. *
  13. * Authors: Xiaobo Xie <X.Xie@freescale.com>
  14. * Anton Vorontsov <avorontsov@ru.mvista.com>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2 of the License, or (at
  19. * your option) any later version.
  20. */
  21. #include <linux/delay.h>
  22. #include <linux/mmc/host.h>
  23. #include "sdhci-pltfm.h"
  24. /*
  25. * Ops and quirks for the Nintendo Wii SDHCI controllers.
  26. */
  27. /*
  28. * We need a small delay after each write, or things go horribly wrong.
  29. */
  30. #define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */
  31. static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
  32. {
  33. sdhci_be32bs_writel(host, val, reg);
  34. udelay(SDHCI_HLWD_WRITE_DELAY);
  35. }
  36. static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
  37. {
  38. sdhci_be32bs_writew(host, val, reg);
  39. udelay(SDHCI_HLWD_WRITE_DELAY);
  40. }
  41. static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
  42. {
  43. sdhci_be32bs_writeb(host, val, reg);
  44. udelay(SDHCI_HLWD_WRITE_DELAY);
  45. }
  46. static struct sdhci_ops sdhci_hlwd_ops = {
  47. .read_l = sdhci_be32bs_readl,
  48. .read_w = sdhci_be32bs_readw,
  49. .read_b = sdhci_be32bs_readb,
  50. .write_l = sdhci_hlwd_writel,
  51. .write_w = sdhci_hlwd_writew,
  52. .write_b = sdhci_hlwd_writeb,
  53. };
  54. static struct sdhci_pltfm_data sdhci_hlwd_pdata = {
  55. .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
  56. SDHCI_QUIRK_32BIT_DMA_SIZE,
  57. .ops = &sdhci_hlwd_ops,
  58. };
  59. static int __devinit sdhci_hlwd_probe(struct platform_device *pdev)
  60. {
  61. return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata);
  62. }
  63. static int __devexit sdhci_hlwd_remove(struct platform_device *pdev)
  64. {
  65. return sdhci_pltfm_unregister(pdev);
  66. }
  67. static const struct of_device_id sdhci_hlwd_of_match[] = {
  68. { .compatible = "nintendo,hollywood-sdhci" },
  69. { }
  70. };
  71. MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match);
  72. static struct platform_driver sdhci_hlwd_driver = {
  73. .driver = {
  74. .name = "sdhci-hlwd",
  75. .owner = THIS_MODULE,
  76. .of_match_table = sdhci_hlwd_of_match,
  77. },
  78. .probe = sdhci_hlwd_probe,
  79. .remove = __devexit_p(sdhci_hlwd_remove),
  80. #ifdef CONFIG_PM
  81. .suspend = sdhci_pltfm_suspend,
  82. .resume = sdhci_pltfm_resume,
  83. #endif
  84. };
  85. static int __init sdhci_hlwd_init(void)
  86. {
  87. return platform_driver_register(&sdhci_hlwd_driver);
  88. }
  89. module_init(sdhci_hlwd_init);
  90. static void __exit sdhci_hlwd_exit(void)
  91. {
  92. platform_driver_unregister(&sdhci_hlwd_driver);
  93. }
  94. module_exit(sdhci_hlwd_exit);
  95. MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver");
  96. MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz");
  97. MODULE_LICENSE("GPL v2");