fpga.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #ifndef __MACH_SDK7786_FPGA_H
  2. #define __MACH_SDK7786_FPGA_H
  3. #include <linux/io.h>
  4. #include <linux/types.h>
  5. #include <linux/bitops.h>
  6. #define SRSTR 0x000
  7. #define SRSTR_MAGIC 0x1971 /* Fixed magical read value */
  8. #define INTASR 0x010
  9. #define INTAMR 0x020
  10. #define MODSWR 0x030
  11. #define INTTESTR 0x040
  12. #define SYSSR 0x050
  13. #define NRGPR 0x060
  14. #define NMISR 0x070
  15. #define NMISR_MAN_NMI BIT(0)
  16. #define NMISR_AUX_NMI BIT(1)
  17. #define NMISR_MASK (NMISR_MAN_NMI | NMISR_AUX_NMI)
  18. #define NMIMR 0x080
  19. #define NMIMR_MAN_NMIM BIT(0) /* Manual NMI mask */
  20. #define NMIMR_AUX_NMIM BIT(1) /* Auxiliary NMI mask */
  21. #define NMIMR_MASK (NMIMR_MAN_NMIM | NMIMR_AUX_NMIM)
  22. #define INTBSR 0x090
  23. #define INTBMR 0x0a0
  24. #define USRLEDR 0x0b0
  25. #define MAPSWR 0x0c0
  26. #define FPGAVR 0x0d0
  27. #define FPGADR 0x0e0
  28. #define PCBRR 0x0f0
  29. #define RSR 0x100
  30. #define EXTASR 0x110
  31. #define SPCAR 0x120
  32. #define INTMSR 0x130
  33. #define PCIECR 0x140
  34. #define PCIECR_PCIEMUX1 BIT(15)
  35. #define PCIECR_PCIEMUX0 BIT(14)
  36. #define PCIECR_PRST4 BIT(12) /* slot 4 card present */
  37. #define PCIECR_PRST3 BIT(11) /* slot 3 card present */
  38. #define PCIECR_PRST2 BIT(10) /* slot 2 card present */
  39. #define PCIECR_PRST1 BIT(9) /* slot 1 card present */
  40. #define PCIECR_CLKEN BIT(4) /* oscillator enable */
  41. #define FAER 0x150
  42. #define USRGPIR 0x160
  43. /* 0x170 reserved */
  44. #define LCLASR 0x180
  45. #define LCLASR_FRAMEN BIT(15)
  46. #define LCLASR_FPGA_SEL_SHIFT 12
  47. #define LCLASR_NAND_SEL_SHIFT 8
  48. #define LCLASR_NORB_SEL_SHIFT 4
  49. #define LCLASR_NORA_SEL_SHIFT 0
  50. #define LCLASR_AREA_MASK 0x7
  51. #define LCLASR_FPGA_SEL_MASK (LCLASR_AREA_MASK << LCLASR_FPGA_SEL_SHIFT)
  52. #define LCLASR_NAND_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NAND_SEL_SHIFT)
  53. #define LCLASR_NORB_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NORB_SEL_SHIFT)
  54. #define LCLASR_NORA_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NORA_SEL_SHIFT)
  55. #define SBCR 0x190
  56. #define SCBR_I2CMEN BIT(0) /* FPGA I2C master enable */
  57. #define SCBR_I2CCEN BIT(1) /* CPU I2C master enable */
  58. #define PWRCR 0x1a0
  59. #define PWRCR_SCISEL0 BIT(0)
  60. #define PWRCR_SCISEL1 BIT(1)
  61. #define PWRCR_SCIEN BIT(2) /* Serial port enable */
  62. #define PWRCR_PDWNACK BIT(5) /* Power down acknowledge */
  63. #define PWRCR_PDWNREQ BIT(7) /* Power down request */
  64. #define PWRCR_INT2 BIT(11) /* INT2 connection to power manager */
  65. #define PWRCR_BUPINIT BIT(13) /* DDR backup initialize */
  66. #define PWRCR_BKPRST BIT(15) /* Backup power reset */
  67. #define SPCBR 0x1b0
  68. #define SPICR 0x1c0
  69. #define SPIDR 0x1d0
  70. #define I2CCR 0x1e0
  71. #define I2CDR 0x1f0
  72. #define FPGACR 0x200
  73. #define IASELR1 0x210
  74. #define IASELR2 0x220
  75. #define IASELR3 0x230
  76. #define IASELR4 0x240
  77. #define IASELR5 0x250
  78. #define IASELR6 0x260
  79. #define IASELR7 0x270
  80. #define IASELR8 0x280
  81. #define IASELR9 0x290
  82. #define IASELR10 0x2a0
  83. #define IASELR11 0x2b0
  84. #define IASELR12 0x2c0
  85. #define IASELR13 0x2d0
  86. #define IASELR14 0x2e0
  87. #define IASELR15 0x2f0
  88. /* 0x300 reserved */
  89. #define IBSELR1 0x310
  90. #define IBSELR2 0x320
  91. #define IBSELR3 0x330
  92. #define IBSELR4 0x340
  93. #define IBSELR5 0x350
  94. #define IBSELR6 0x360
  95. #define IBSELR7 0x370
  96. #define IBSELR8 0x380
  97. #define IBSELR9 0x390
  98. #define IBSELR10 0x3a0
  99. #define IBSELR11 0x3b0
  100. #define IBSELR12 0x3c0
  101. #define IBSELR13 0x3d0
  102. #define IBSELR14 0x3e0
  103. #define IBSELR15 0x3f0
  104. #define USRACR 0x400
  105. #define BEEPR 0x410
  106. #define USRLCDR 0x420
  107. #define SMBCR 0x430
  108. #define SMBDR 0x440
  109. #define USBCR 0x450
  110. #define AMSR 0x460
  111. #define ACCR 0x470
  112. #define SDIFCR 0x480
  113. /* arch/sh/boards/mach-sdk7786/fpga.c */
  114. extern void __iomem *sdk7786_fpga_base;
  115. extern void sdk7786_fpga_init(void);
  116. /* arch/sh/boards/mach-sdk7786/nmi.c */
  117. extern void sdk7786_nmi_init(void);
  118. #define SDK7786_FPGA_REGADDR(reg) (sdk7786_fpga_base + (reg))
  119. /*
  120. * A convenience wrapper from register offset to internal I2C address,
  121. * when the FPGA is in I2C slave mode.
  122. */
  123. #define SDK7786_FPGA_I2CADDR(reg) ((reg) >> 3)
  124. static inline u16 fpga_read_reg(unsigned int reg)
  125. {
  126. return ioread16(sdk7786_fpga_base + reg);
  127. }
  128. static inline void fpga_write_reg(u16 val, unsigned int reg)
  129. {
  130. iowrite16(val, sdk7786_fpga_base + reg);
  131. }
  132. #endif /* __MACH_SDK7786_FPGA_H */