smemc.c 1.7 KB

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