fpga.h 4.1 KB

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