dw_mmc-pltfm.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Synopsys DesignWare Multimedia Card Interface driver
  3. *
  4. * Copyright (C) 2009 NXP Semiconductors
  5. * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/interrupt.h>
  13. #include <linux/module.h>
  14. #include <linux/io.h>
  15. #include <linux/irq.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/slab.h>
  18. #include <linux/mmc/host.h>
  19. #include <linux/mmc/mmc.h>
  20. #include <linux/mmc/dw_mmc.h>
  21. #include "dw_mmc.h"
  22. static int __devinit dw_mci_pltfm_probe(struct platform_device *pdev)
  23. {
  24. struct dw_mci *host;
  25. struct resource *regs;
  26. int ret;
  27. host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
  28. if (!host)
  29. return -ENOMEM;
  30. regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  31. if (!regs)
  32. return -ENXIO;
  33. host->irq = platform_get_irq(pdev, 0);
  34. if (host->irq < 0)
  35. return host->irq;
  36. host->dev = &pdev->dev;
  37. host->irq_flags = 0;
  38. host->pdata = pdev->dev.platform_data;
  39. host->regs = devm_request_and_ioremap(&pdev->dev, regs);
  40. if (!host->regs)
  41. return -ENOMEM;
  42. platform_set_drvdata(pdev, host);
  43. ret = dw_mci_probe(host);
  44. return ret;
  45. }
  46. static int __devexit dw_mci_pltfm_remove(struct platform_device *pdev)
  47. {
  48. struct dw_mci *host = platform_get_drvdata(pdev);
  49. platform_set_drvdata(pdev, NULL);
  50. dw_mci_remove(host);
  51. return 0;
  52. }
  53. #ifdef CONFIG_PM_SLEEP
  54. /*
  55. * TODO: we should probably disable the clock to the card in the suspend path.
  56. */
  57. static int dw_mci_pltfm_suspend(struct device *dev)
  58. {
  59. int ret;
  60. struct dw_mci *host = dev_get_drvdata(dev);
  61. ret = dw_mci_suspend(host);
  62. if (ret)
  63. return ret;
  64. return 0;
  65. }
  66. static int dw_mci_pltfm_resume(struct device *dev)
  67. {
  68. int ret;
  69. struct dw_mci *host = dev_get_drvdata(dev);
  70. ret = dw_mci_resume(host);
  71. if (ret)
  72. return ret;
  73. return 0;
  74. }
  75. #else
  76. #define dw_mci_pltfm_suspend NULL
  77. #define dw_mci_pltfm_resume NULL
  78. #endif /* CONFIG_PM_SLEEP */
  79. static SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume);
  80. static struct platform_driver dw_mci_pltfm_driver = {
  81. .remove = __exit_p(dw_mci_pltfm_remove),
  82. .driver = {
  83. .name = "dw_mmc",
  84. .pm = &dw_mci_pltfm_pmops,
  85. },
  86. };
  87. static int __init dw_mci_init(void)
  88. {
  89. return platform_driver_probe(&dw_mci_pltfm_driver, dw_mci_pltfm_probe);
  90. }
  91. static void __exit dw_mci_exit(void)
  92. {
  93. platform_driver_unregister(&dw_mci_pltfm_driver);
  94. }
  95. module_init(dw_mci_init);
  96. module_exit(dw_mci_exit);
  97. MODULE_DESCRIPTION("DW Multimedia Card Interface driver");
  98. MODULE_AUTHOR("NXP Semiconductor VietNam");
  99. MODULE_AUTHOR("Imagination Technologies Ltd");
  100. MODULE_LICENSE("GPL v2");