mmdc.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/module.h>
  15. #include <linux/of.h>
  16. #include <linux/of_address.h>
  17. #include <linux/of_device.h>
  18. #define MMDC_MAPSR 0x404
  19. #define BP_MMDC_MAPSR_PSD 0
  20. #define BP_MMDC_MAPSR_PSS 4
  21. static int __devinit imx_mmdc_probe(struct platform_device *pdev)
  22. {
  23. struct device_node *np = pdev->dev.of_node;
  24. void __iomem *mmdc_base, *reg;
  25. u32 val;
  26. int timeout = 0x400;
  27. mmdc_base = of_iomap(np, 0);
  28. WARN_ON(!mmdc_base);
  29. reg = mmdc_base + MMDC_MAPSR;
  30. /* Enable automatic power saving */
  31. val = readl_relaxed(reg);
  32. val &= ~(1 << BP_MMDC_MAPSR_PSD);
  33. writel_relaxed(val, reg);
  34. /* Ensure it's successfully enabled */
  35. while (!(readl_relaxed(reg) & 1 << BP_MMDC_MAPSR_PSS) && --timeout)
  36. cpu_relax();
  37. if (unlikely(!timeout)) {
  38. pr_warn("%s: failed to enable automatic power saving\n",
  39. __func__);
  40. return -EBUSY;
  41. }
  42. return 0;
  43. }
  44. static struct of_device_id imx_mmdc_dt_ids[] = {
  45. { .compatible = "fsl,imx6q-mmdc", },
  46. { /* sentinel */ }
  47. };
  48. static struct platform_driver imx_mmdc_driver = {
  49. .driver = {
  50. .name = "imx-mmdc",
  51. .owner = THIS_MODULE,
  52. .of_match_table = imx_mmdc_dt_ids,
  53. },
  54. .probe = imx_mmdc_probe,
  55. };
  56. static int __init imx_mmdc_init(void)
  57. {
  58. return platform_driver_register(&imx_mmdc_driver);
  59. }
  60. postcore_initcall(imx_mmdc_init);