dcr.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 Clock, PM, chip control */
  24. #define DCRN_CPC0_SR 0x0b0
  25. #define DCRN_CPC0_ER 0x0b1
  26. #define DCRN_CPC0_FR 0x0b2
  27. #define DCRN_CPC0_SYS0 0x0e0
  28. #define CPC0_SYS0_TUNE 0xffc00000
  29. #define CPC0_SYS0_FBDV_MASK 0x003c0000
  30. #define CPC0_SYS0_FWDVA_MASK 0x00038000
  31. #define CPC0_SYS0_FWDVB_MASK 0x00007000
  32. #define CPC0_SYS0_OPDV_MASK 0x00000c00
  33. #define CPC0_SYS0_EPDV_MASK 0x00000300
  34. /* Helper macros to compute the actual clock divider values from the
  35. * encodings in the CPC0 register */
  36. #define CPC0_SYS0_FBDV(reg) \
  37. ((((((reg) & CPC0_SYS0_FBDV_MASK) >> 18) - 1) & 0xf) + 1)
  38. #define CPC0_SYS0_FWDVA(reg) \
  39. (8 - (((reg) & CPC0_SYS0_FWDVA_MASK) >> 15))
  40. #define CPC0_SYS0_FWDVB(reg) \
  41. (8 - (((reg) & CPC0_SYS0_FWDVB_MASK) >> 12))
  42. #define CPC0_SYS0_OPDV(reg) \
  43. ((((reg) & CPC0_SYS0_OPDV_MASK) >> 10) + 1)
  44. #define CPC0_SYS0_EPDV(reg) \
  45. ((((reg) & CPC0_SYS0_EPDV_MASK) >> 8) + 1)
  46. #define CPC0_SYS0_EXTSL 0x00000080
  47. #define CPC0_SYS0_RW_MASK 0x00000060
  48. #define CPC0_SYS0_RL 0x00000010
  49. #define CPC0_SYS0_ZMIISL_MASK 0x0000000c
  50. #define CPC0_SYS0_BYPASS 0x00000002
  51. #define CPC0_SYS0_NTO1 0x00000001
  52. #define DCRN_CPC0_SYS1 0x0e1
  53. #define DCRN_CPC0_CUST0 0x0e2
  54. #define DCRN_CPC0_CUST1 0x0e3
  55. #define DCRN_CPC0_STRP0 0x0e4
  56. #define DCRN_CPC0_STRP1 0x0e5
  57. #define DCRN_CPC0_STRP2 0x0e6
  58. #define DCRN_CPC0_STRP3 0x0e7
  59. #define DCRN_CPC0_GPIO 0x0e8
  60. #define DCRN_CPC0_PLB 0x0e9
  61. #define DCRN_CPC0_CR1 0x0ea
  62. #define DCRN_CPC0_CR0 0x0eb
  63. #define CPC0_CR0_SWE 0x80000000
  64. #define CPC0_CR0_CETE 0x40000000
  65. #define CPC0_CR0_U1FCS 0x20000000
  66. #define CPC0_CR0_U0DTE 0x10000000
  67. #define CPC0_CR0_U0DRE 0x08000000
  68. #define CPC0_CR0_U0DC 0x04000000
  69. #define CPC0_CR0_U1DTE 0x02000000
  70. #define CPC0_CR0_U1DRE 0x01000000
  71. #define CPC0_CR0_U1DC 0x00800000
  72. #define CPC0_CR0_U0EC 0x00400000
  73. #define CPC0_CR0_U1EC 0x00200000
  74. #define CPC0_CR0_UDIV_MASK 0x001f0000
  75. #define CPC0_CR0_UDIV(reg) \
  76. ((((reg) & CPC0_CR0_UDIV_MASK) >> 16) + 1)
  77. #define DCRN_CPC0_MIRQ0 0x0ec
  78. #define DCRN_CPC0_MIRQ1 0x0ed
  79. #define DCRN_CPC0_JTAGID 0x0ef
  80. #endif /* _PPC_BOOT_DCR_H_ */