dcr.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _PPC_BOOT_DCR_H_
  2. #define _PPC_BOOT_DCR_H_
  3. #define mfdcr(rn) \
  4. ({ \
  5. unsigned long rval; \
  6. asm volatile("mfdcr %0,%1" : "=r"(rval) : "i"(rn)); \
  7. rval; \
  8. })
  9. #define mtdcr(rn, val) \
  10. asm volatile("mtdcr %0,%1" : : "i"(rn), "r"(val))
  11. /* 440GP/440GX SDRAM controller DCRs */
  12. #define DCRN_SDRAM0_CFGADDR 0x010
  13. #define DCRN_SDRAM0_CFGDATA 0x011
  14. #define SDRAM0_B0CR 0x40
  15. #define SDRAM0_B1CR 0x44
  16. #define SDRAM0_B2CR 0x48
  17. #define SDRAM0_B3CR 0x4c
  18. static const unsigned long sdram_bxcr[] = { SDRAM0_B0CR, SDRAM0_B1CR, SDRAM0_B2CR, SDRAM0_B3CR };
  19. #define SDRAM_CONFIG_BANK_ENABLE 0x00000001
  20. #define SDRAM_CONFIG_SIZE_MASK 0x000e0000
  21. #define SDRAM_CONFIG_BANK_SIZE(reg) \
  22. (0x00400000 << ((reg & SDRAM_CONFIG_SIZE_MASK) >> 17))
  23. /* 440GP External Bus Controller (EBC) */
  24. #define DCRN_EBC0_CFGADDR 0x012
  25. #define DCRN_EBC0_CFGDATA 0x013
  26. #define EBC_NUM_BANKS 8
  27. #define EBC_B0CR 0x00
  28. #define EBC_B1CR 0x01
  29. #define EBC_B2CR 0x02
  30. #define EBC_B3CR 0x03
  31. #define EBC_B4CR 0x04
  32. #define EBC_B5CR 0x05
  33. #define EBC_B6CR 0x06
  34. #define EBC_B7CR 0x07
  35. #define EBC_BXCR(n) (n)
  36. #define EBC_BXCR_BAS 0xfff00000
  37. #define EBC_BXCR_BS 0x000e0000
  38. #define EBC_BXCR_BANK_SIZE(reg) \
  39. (0x100000 << (((reg) & EBC_BXCR_BS) >> 17))
  40. #define EBC_BXCR_BU 0x00018000
  41. #define EBC_BXCR_BU_OFF 0x00000000
  42. #define EBC_BXCR_BU_RO 0x00008000
  43. #define EBC_BXCR_BU_WO 0x00010000
  44. #define EBC_BXCR_BU_RW 0x00018000
  45. #define EBC_BXCR_BW 0x00006000
  46. #define EBC_B0AP 0x10
  47. #define EBC_B1AP 0x11
  48. #define EBC_B2AP 0x12
  49. #define EBC_B3AP 0x13
  50. #define EBC_B4AP 0x14
  51. #define EBC_B5AP 0x15
  52. #define EBC_B6AP 0x16
  53. #define EBC_B7AP 0x17
  54. #define EBC_BXAP(n) (0x10+(n))
  55. #define EBC_BEAR 0x20
  56. #define EBC_BESR 0x21
  57. #define EBC_CFG 0x23
  58. #define EBC_CID 0x24
  59. /* 440GP Clock, PM, chip control */
  60. #define DCRN_CPC0_SR 0x0b0
  61. #define DCRN_CPC0_ER 0x0b1
  62. #define DCRN_CPC0_FR 0x0b2
  63. #define DCRN_CPC0_SYS0 0x0e0
  64. #define CPC0_SYS0_TUNE 0xffc00000
  65. #define CPC0_SYS0_FBDV_MASK 0x003c0000
  66. #define CPC0_SYS0_FWDVA_MASK 0x00038000
  67. #define CPC0_SYS0_FWDVB_MASK 0x00007000
  68. #define CPC0_SYS0_OPDV_MASK 0x00000c00
  69. #define CPC0_SYS0_EPDV_MASK 0x00000300
  70. /* Helper macros to compute the actual clock divider values from the
  71. * encodings in the CPC0 register */
  72. #define CPC0_SYS0_FBDV(reg) \
  73. ((((((reg) & CPC0_SYS0_FBDV_MASK) >> 18) - 1) & 0xf) + 1)
  74. #define CPC0_SYS0_FWDVA(reg) \
  75. (8 - (((reg) & CPC0_SYS0_FWDVA_MASK) >> 15))
  76. #define CPC0_SYS0_FWDVB(reg) \
  77. (8 - (((reg) & CPC0_SYS0_FWDVB_MASK) >> 12))
  78. #define CPC0_SYS0_OPDV(reg) \
  79. ((((reg) & CPC0_SYS0_OPDV_MASK) >> 10) + 1)
  80. #define CPC0_SYS0_EPDV(reg) \
  81. ((((reg) & CPC0_SYS0_EPDV_MASK) >> 8) + 1)
  82. #define CPC0_SYS0_EXTSL 0x00000080
  83. #define CPC0_SYS0_RW_MASK 0x00000060
  84. #define CPC0_SYS0_RL 0x00000010
  85. #define CPC0_SYS0_ZMIISL_MASK 0x0000000c
  86. #define CPC0_SYS0_BYPASS 0x00000002
  87. #define CPC0_SYS0_NTO1 0x00000001
  88. #define DCRN_CPC0_SYS1 0x0e1
  89. #define DCRN_CPC0_CUST0 0x0e2
  90. #define DCRN_CPC0_CUST1 0x0e3
  91. #define DCRN_CPC0_STRP0 0x0e4
  92. #define DCRN_CPC0_STRP1 0x0e5
  93. #define DCRN_CPC0_STRP2 0x0e6
  94. #define DCRN_CPC0_STRP3 0x0e7
  95. #define DCRN_CPC0_GPIO 0x0e8
  96. #define DCRN_CPC0_PLB 0x0e9
  97. #define DCRN_CPC0_CR1 0x0ea
  98. #define DCRN_CPC0_CR0 0x0eb
  99. #define CPC0_CR0_SWE 0x80000000
  100. #define CPC0_CR0_CETE 0x40000000
  101. #define CPC0_CR0_U1FCS 0x20000000
  102. #define CPC0_CR0_U0DTE 0x10000000
  103. #define CPC0_CR0_U0DRE 0x08000000
  104. #define CPC0_CR0_U0DC 0x04000000
  105. #define CPC0_CR0_U1DTE 0x02000000
  106. #define CPC0_CR0_U1DRE 0x01000000
  107. #define CPC0_CR0_U1DC 0x00800000
  108. #define CPC0_CR0_U0EC 0x00400000
  109. #define CPC0_CR0_U1EC 0x00200000
  110. #define CPC0_CR0_UDIV_MASK 0x001f0000
  111. #define CPC0_CR0_UDIV(reg) \
  112. ((((reg) & CPC0_CR0_UDIV_MASK) >> 16) + 1)
  113. #define DCRN_CPC0_MIRQ0 0x0ec
  114. #define DCRN_CPC0_MIRQ1 0x0ed
  115. #define DCRN_CPC0_JTAGID 0x0ef
  116. #define DCRN_MAL0_CFG 0x180
  117. #define MAL_RESET 0x80000000
  118. /* 440EP Clock/Power-on Reset regs */
  119. #define DCRN_CPR0_ADDR 0xc
  120. #define DCRN_CPR0_DATA 0xd
  121. #define CPR0_PLLD0 0x60
  122. #define CPR0_OPBD0 0xc0
  123. #define CPR0_PERD0 0xe0
  124. #define CPR0_PRIMBD0 0xa0
  125. #define CPR0_SCPID 0x120
  126. #define CPR0_PLLC0 0x40
  127. /* 405GP Clocking/Power Management/Chip Control regs */
  128. #define DCRN_CPC0_PLLMR 0xb0
  129. #define DCRN_405_CPC0_CR0 0xb1
  130. #define DCRN_405_CPC0_CR1 0xb2
  131. #endif /* _PPC_BOOT_DCR_H_ */