smemc.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Static Memory Controller
  4. */
  5. #include <linux/module.h>
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <linux/io.h>
  9. #include <linux/syscore_ops.h>
  10. #include <mach/hardware.h>
  11. #include <mach/smemc.h>
  12. #ifdef CONFIG_PM
  13. static unsigned long msc[2];
  14. static unsigned long sxcnfg, memclkcfg;
  15. static unsigned long csadrcfg[4];
  16. static int pxa3xx_smemc_suspend(void)
  17. {
  18. msc[0] = __raw_readl(MSC0);
  19. msc[1] = __raw_readl(MSC1);
  20. sxcnfg = __raw_readl(SXCNFG);
  21. memclkcfg = __raw_readl(MEMCLKCFG);
  22. csadrcfg[0] = __raw_readl(CSADRCFG0);
  23. csadrcfg[1] = __raw_readl(CSADRCFG1);
  24. csadrcfg[2] = __raw_readl(CSADRCFG2);
  25. csadrcfg[3] = __raw_readl(CSADRCFG3);
  26. return 0;
  27. }
  28. static void pxa3xx_smemc_resume(void)
  29. {
  30. __raw_writel(msc[0], MSC0);
  31. __raw_writel(msc[1], MSC1);
  32. __raw_writel(sxcnfg, SXCNFG);
  33. __raw_writel(memclkcfg, MEMCLKCFG);
  34. __raw_writel(csadrcfg[0], CSADRCFG0);
  35. __raw_writel(csadrcfg[1], CSADRCFG1);
  36. __raw_writel(csadrcfg[2], CSADRCFG2);
  37. __raw_writel(csadrcfg[3], CSADRCFG3);
  38. /* CSMSADRCFG wakes up in its default state (0), so we need to set it */
  39. __raw_writel(0x2, CSMSADRCFG);
  40. }
  41. static struct syscore_ops smemc_syscore_ops = {
  42. .suspend = pxa3xx_smemc_suspend,
  43. .resume = pxa3xx_smemc_resume,
  44. };
  45. static int __init smemc_init(void)
  46. {
  47. if (cpu_is_pxa3xx()) {
  48. /*
  49. * The only documentation we have on the
  50. * Chip Select Configuration Register (CSMSADRCFG) is that
  51. * it must be programmed to 0x2.
  52. * Moreover, in the bit definitions, the second bit
  53. * (CSMSADRCFG[1]) is called "SETALWAYS".
  54. * Other bits are reserved in this register.
  55. */
  56. __raw_writel(0x2, CSMSADRCFG);
  57. register_syscore_ops(&smemc_syscore_ops);
  58. }
  59. return 0;
  60. }
  61. subsys_initcall(smemc_init);
  62. #endif