emc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2011 by Vladimir Zapolskiy <vz@mleia.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _LPC32XX_EMC_H
  7. #define _LPC32XX_EMC_H
  8. #include <asm/types.h>
  9. /* EMC Registers */
  10. struct emc_regs {
  11. u32 ctrl; /* Controls operation of the EMC */
  12. u32 status; /* Provides EMC status information */
  13. u32 config; /* Configures operation of the EMC */
  14. u32 reserved0[5];
  15. u32 control; /* Controls dyn memory operation */
  16. u32 refresh; /* Configures dyn memory refresh operation */
  17. u32 read_config; /* Configures the dyn memory read strategy */
  18. u32 reserved1;
  19. u32 t_rp; /* Precharge command period */
  20. u32 t_ras; /* Active to precharge command period */
  21. u32 t_srex; /* Self-refresh exit time */
  22. u32 reserved2[2];
  23. u32 t_wr; /* Write recovery time */
  24. u32 t_rc; /* Active to active command period */
  25. u32 t_rfc; /* Auto-refresh period */
  26. u32 t_xsr; /* Exit self-refresh to active command time */
  27. u32 t_rrd; /* Active bank A to active bank B latency */
  28. u32 t_mrd; /* Load mode register to active command time */
  29. u32 t_cdlr; /* Last data in to read command time */
  30. u32 reserved3[8];
  31. u32 extended_wait; /* time for static memory rd/wr transfers */
  32. u32 reserved4[31];
  33. u32 config0; /* Configuration information for the SDRAM */
  34. u32 rascas0; /* RAS and CAS latencies for the SDRAM */
  35. u32 reserved5[6];
  36. u32 config1; /* Configuration information for the SDRAM */
  37. u32 rascas1; /* RAS and CAS latencies for the SDRAM */
  38. u32 reserved6[54];
  39. struct emc_stat_t {
  40. u32 config; /* Static memory configuration */
  41. u32 waitwen; /* Delay from chip select to write enable */
  42. u32 waitoen; /* Delay to output enable */
  43. u32 waitrd; /* Delay to a read access */
  44. u32 waitpage; /* Delay for async page mode read */
  45. u32 waitwr; /* Delay to a write access */
  46. u32 waitturn; /* Number of bus turnaround cycles */
  47. u32 reserved;
  48. } stat[4];
  49. u32 reserved7[96];
  50. struct emc_ahb_t {
  51. u32 control; /* Control register for AHB */
  52. u32 status; /* Status register for AHB */
  53. u32 timeout; /* Timeout register for AHB */
  54. u32 reserved[5];
  55. } ahb[5];
  56. };
  57. /* Static Memory Configuration Register bits */
  58. #define EMC_STAT_CONFIG_WP (1 << 20)
  59. #define EMC_STAT_CONFIG_EW (1 << 8)
  60. #define EMC_STAT_CONFIG_PB (1 << 7)
  61. #define EMC_STAT_CONFIG_PC (1 << 6)
  62. #define EMC_STAT_CONFIG_PM (1 << 3)
  63. #define EMC_STAT_CONFIG_32BIT (2 << 0)
  64. #define EMC_STAT_CONFIG_16BIT (1 << 0)
  65. #define EMC_STAT_CONFIG_8BIT (0 << 0)
  66. /* Static Memory Delay Registers */
  67. #define EMC_STAT_WAITWEN(n) (((n) - 1) & 0x0F)
  68. #define EMC_STAT_WAITOEN(n) (((n) - 1) & 0x0F)
  69. #define EMC_STAT_WAITRD(n) (((n) - 1) & 0x1F)
  70. #define EMC_STAT_WAITPAGE(n) (((n) - 1) & 0x1F)
  71. #define EMC_STAT_WAITWR(n) (((n) - 2) & 0x1F)
  72. #define EMC_STAT_WAITTURN(n) (((n) - 1) & 0x0F)
  73. /* EMC settings for DRAM */
  74. struct emc_dram_settings {
  75. u32 cmddelay;
  76. u32 config0;
  77. u32 rascas0;
  78. u32 rdconfig;
  79. u32 trp;
  80. u32 tras;
  81. u32 tsrex;
  82. u32 twr;
  83. u32 trc;
  84. u32 trfc;
  85. u32 txsr;
  86. u32 trrd;
  87. u32 tmrd;
  88. u32 tcdlr;
  89. u32 refresh;
  90. u32 mode;
  91. u32 emode;
  92. };
  93. #endif /* _LPC32XX_EMC_H */