ssb_driver_extif.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Hardware-specific External Interface I/O core definitions
  4. * for the BCM47xx family of SiliconBackplane-based chips.
  5. *
  6. * The External Interface core supports a total of three external chip selects
  7. * supporting external interfaces. One of the external chip selects is
  8. * used for Flash, one is used for PCMCIA, and the other may be
  9. * programmed to support either a synchronous interface or an
  10. * asynchronous interface. The asynchronous interface can be used to
  11. * support external devices such as UARTs and the BCM2019 Bluetooth
  12. * baseband processor.
  13. * The external interface core also contains 2 on-chip 16550 UARTs, clock
  14. * frequency control, a watchdog interrupt timer, and a GPIO interface.
  15. *
  16. * Copyright 2005, Broadcom Corporation
  17. * Copyright 2006, Michael Buesch
  18. */
  19. #ifndef LINUX_SSB_EXTIFCORE_H_
  20. #define LINUX_SSB_EXTIFCORE_H_
  21. /* external interface address space */
  22. #define SSB_EXTIF_PCMCIA_MEMBASE(x) (x)
  23. #define SSB_EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
  24. #define SSB_EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
  25. #define SSB_EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
  26. #define SSB_EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
  27. #define SSB_EXTIF_NR_GPIOOUT 5
  28. /* GPIO NOTE:
  29. * The multiple instances of output and output enable registers
  30. * are present to allow driver software for multiple cores to control
  31. * gpio outputs without needing to share a single register pair.
  32. * Use the following helper macro to get a register offset value.
  33. */
  34. #define SSB_EXTIF_GPIO_OUT(index) ({ \
  35. BUILD_BUG_ON(index >= SSB_EXTIF_NR_GPIOOUT); \
  36. SSB_EXTIF_GPIO_OUT_BASE + ((index) * 8); \
  37. })
  38. #define SSB_EXTIF_GPIO_OUTEN(index) ({ \
  39. BUILD_BUG_ON(index >= SSB_EXTIF_NR_GPIOOUT); \
  40. SSB_EXTIF_GPIO_OUTEN_BASE + ((index) * 8); \
  41. })
  42. /** EXTIF core registers **/
  43. #define SSB_EXTIF_CTL 0x0000
  44. #define SSB_EXTIF_CTL_UARTEN (1 << 0) /* UART enable */
  45. #define SSB_EXTIF_EXTSTAT 0x0004
  46. #define SSB_EXTIF_EXTSTAT_EMODE (1 << 0) /* Endian mode (ro) */
  47. #define SSB_EXTIF_EXTSTAT_EIRQPIN (1 << 1) /* External interrupt pin (ro) */
  48. #define SSB_EXTIF_EXTSTAT_GPIOIRQPIN (1 << 2) /* GPIO interrupt pin (ro) */
  49. #define SSB_EXTIF_PCMCIA_CFG 0x0010
  50. #define SSB_EXTIF_PCMCIA_MEMWAIT 0x0014
  51. #define SSB_EXTIF_PCMCIA_ATTRWAIT 0x0018
  52. #define SSB_EXTIF_PCMCIA_IOWAIT 0x001C
  53. #define SSB_EXTIF_PROG_CFG 0x0020
  54. #define SSB_EXTIF_PROG_WAITCNT 0x0024
  55. #define SSB_EXTIF_FLASH_CFG 0x0028
  56. #define SSB_EXTIF_FLASH_WAITCNT 0x002C
  57. #define SSB_EXTIF_WATCHDOG 0x0040
  58. #define SSB_EXTIF_CLOCK_N 0x0044
  59. #define SSB_EXTIF_CLOCK_SB 0x0048
  60. #define SSB_EXTIF_CLOCK_PCI 0x004C
  61. #define SSB_EXTIF_CLOCK_MII 0x0050
  62. #define SSB_EXTIF_GPIO_IN 0x0060
  63. #define SSB_EXTIF_GPIO_OUT_BASE 0x0064
  64. #define SSB_EXTIF_GPIO_OUTEN_BASE 0x0068
  65. #define SSB_EXTIF_EJTAG_OUTEN 0x0090
  66. #define SSB_EXTIF_GPIO_INTPOL 0x0094
  67. #define SSB_EXTIF_GPIO_INTMASK 0x0098
  68. #define SSB_EXTIF_UART_DATA 0x0300
  69. #define SSB_EXTIF_UART_TIMER 0x0310
  70. #define SSB_EXTIF_UART_FCR 0x0320
  71. #define SSB_EXTIF_UART_LCR 0x0330
  72. #define SSB_EXTIF_UART_MCR 0x0340
  73. #define SSB_EXTIF_UART_LSR 0x0350
  74. #define SSB_EXTIF_UART_MSR 0x0360
  75. #define SSB_EXTIF_UART_SCRATCH 0x0370
  76. /* pcmcia/prog/flash_config */
  77. #define SSB_EXTCFG_EN (1 << 0) /* enable */
  78. #define SSB_EXTCFG_MODE 0xE /* mode */
  79. #define SSB_EXTCFG_MODE_SHIFT 1
  80. #define SSB_EXTCFG_MODE_FLASH 0x0 /* flash/asynchronous mode */
  81. #define SSB_EXTCFG_MODE_SYNC 0x2 /* synchronous mode */
  82. #define SSB_EXTCFG_MODE_PCMCIA 0x4 /* pcmcia mode */
  83. #define SSB_EXTCFG_DS16 (1 << 4) /* destsize: 0=8bit, 1=16bit */
  84. #define SSB_EXTCFG_BSWAP (1 << 5) /* byteswap */
  85. #define SSB_EXTCFG_CLKDIV 0xC0 /* clock divider */
  86. #define SSB_EXTCFG_CLKDIV_SHIFT 6
  87. #define SSB_EXTCFG_CLKDIV_2 0x0 /* backplane/2 */
  88. #define SSB_EXTCFG_CLKDIV_3 0x40 /* backplane/3 */
  89. #define SSB_EXTCFG_CLKDIV_4 0x80 /* backplane/4 */
  90. #define SSB_EXTCFG_CLKEN (1 << 8) /* clock enable */
  91. #define SSB_EXTCFG_STROBE (1 << 9) /* size/bytestrobe (synch only) */
  92. /* pcmcia_memwait */
  93. #define SSB_PCMCIA_MEMW_0 0x0000003F /* waitcount0 */
  94. #define SSB_PCMCIA_MEMW_1 0x00001F00 /* waitcount1 */
  95. #define SSB_PCMCIA_MEMW_1_SHIFT 8
  96. #define SSB_PCMCIA_MEMW_2 0x001F0000 /* waitcount2 */
  97. #define SSB_PCMCIA_MEMW_2_SHIFT 16
  98. #define SSB_PCMCIA_MEMW_3 0x1F000000 /* waitcount3 */
  99. #define SSB_PCMCIA_MEMW_3_SHIFT 24
  100. /* pcmcia_attrwait */
  101. #define SSB_PCMCIA_ATTW_0 0x0000003F /* waitcount0 */
  102. #define SSB_PCMCIA_ATTW_1 0x00001F00 /* waitcount1 */
  103. #define SSB_PCMCIA_ATTW_1_SHIFT 8
  104. #define SSB_PCMCIA_ATTW_2 0x001F0000 /* waitcount2 */
  105. #define SSB_PCMCIA_ATTW_2_SHIFT 16
  106. #define SSB_PCMCIA_ATTW_3 0x1F000000 /* waitcount3 */
  107. #define SSB_PCMCIA_ATTW_3_SHIFT 24
  108. /* pcmcia_iowait */
  109. #define SSB_PCMCIA_IOW_0 0x0000003F /* waitcount0 */
  110. #define SSB_PCMCIA_IOW_1 0x00001F00 /* waitcount1 */
  111. #define SSB_PCMCIA_IOW_1_SHIFT 8
  112. #define SSB_PCMCIA_IOW_2 0x001F0000 /* waitcount2 */
  113. #define SSB_PCMCIA_IOW_2_SHIFT 16
  114. #define SSB_PCMCIA_IOW_3 0x1F000000 /* waitcount3 */
  115. #define SSB_PCMCIA_IOW_3_SHIFT 24
  116. /* prog_waitcount */
  117. #define SSB_PROG_WCNT_0 0x0000001F /* waitcount0 */
  118. #define SSB_PROG_WCNT_1 0x00001F00 /* waitcount1 */
  119. #define SSB_PROG_WCNT_1_SHIFT 8
  120. #define SSB_PROG_WCNT_2 0x001F0000 /* waitcount2 */
  121. #define SSB_PROG_WCNT_2_SHIFT 16
  122. #define SSB_PROG_WCNT_3 0x1F000000 /* waitcount3 */
  123. #define SSB_PROG_WCNT_3_SHIFT 24
  124. #define SSB_PROG_W0 0x0000000C
  125. #define SSB_PROG_W1 0x00000A00
  126. #define SSB_PROG_W2 0x00020000
  127. #define SSB_PROG_W3 0x01000000
  128. /* flash_waitcount */
  129. #define SSB_FLASH_WCNT_0 0x0000001F /* waitcount0 */
  130. #define SSB_FLASH_WCNT_1 0x00001F00 /* waitcount1 */
  131. #define SSB_FLASH_WCNT_1_SHIFT 8
  132. #define SSB_FLASH_WCNT_2 0x001F0000 /* waitcount2 */
  133. #define SSB_FLASH_WCNT_2_SHIFT 16
  134. #define SSB_FLASH_WCNT_3 0x1F000000 /* waitcount3 */
  135. #define SSB_FLASH_WCNT_3_SHIFT 24
  136. /* watchdog */
  137. #define SSB_EXTIF_WATCHDOG_CLK 48000000 /* Hz */
  138. #define SSB_EXTIF_WATCHDOG_MAX_TIMER ((1 << 28) - 1)
  139. #define SSB_EXTIF_WATCHDOG_MAX_TIMER_MS (SSB_EXTIF_WATCHDOG_MAX_TIMER \
  140. / (SSB_EXTIF_WATCHDOG_CLK / 1000))
  141. #ifdef CONFIG_SSB_DRIVER_EXTIF
  142. struct ssb_extif {
  143. struct ssb_device *dev;
  144. spinlock_t gpio_lock;
  145. };
  146. static inline bool ssb_extif_available(struct ssb_extif *extif)
  147. {
  148. return (extif->dev != NULL);
  149. }
  150. extern void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
  151. u32 *plltype, u32 *n, u32 *m);
  152. extern void ssb_extif_timing_init(struct ssb_extif *extif,
  153. unsigned long ns);
  154. extern u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks);
  155. /* Extif GPIO pin access */
  156. u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask);
  157. u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value);
  158. u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value);
  159. u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value);
  160. u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value);
  161. #ifdef CONFIG_SSB_SERIAL
  162. extern int ssb_extif_serial_init(struct ssb_extif *extif,
  163. struct ssb_serial_port *ports);
  164. #endif /* CONFIG_SSB_SERIAL */
  165. #else /* CONFIG_SSB_DRIVER_EXTIF */
  166. /* extif disabled */
  167. struct ssb_extif {
  168. };
  169. static inline bool ssb_extif_available(struct ssb_extif *extif)
  170. {
  171. return false;
  172. }
  173. static inline
  174. void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
  175. u32 *plltype, u32 *n, u32 *m)
  176. {
  177. }
  178. static inline
  179. void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns)
  180. {
  181. }
  182. static inline
  183. u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks)
  184. {
  185. return 0;
  186. }
  187. static inline u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
  188. {
  189. return 0;
  190. }
  191. static inline u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask,
  192. u32 value)
  193. {
  194. return 0;
  195. }
  196. static inline u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask,
  197. u32 value)
  198. {
  199. return 0;
  200. }
  201. static inline u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask,
  202. u32 value)
  203. {
  204. return 0;
  205. }
  206. static inline u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask,
  207. u32 value)
  208. {
  209. return 0;
  210. }
  211. #ifdef CONFIG_SSB_SERIAL
  212. static inline int ssb_extif_serial_init(struct ssb_extif *extif,
  213. struct ssb_serial_port *ports)
  214. {
  215. return 0;
  216. }
  217. #endif /* CONFIG_SSB_SERIAL */
  218. #endif /* CONFIG_SSB_DRIVER_EXTIF */
  219. #endif /* LINUX_SSB_EXTIFCORE_H_ */