ssb_private.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef LINUX_SSB_PRIVATE_H_
  3. #define LINUX_SSB_PRIVATE_H_
  4. #include <linux/ssb/ssb.h>
  5. #include <linux/types.h>
  6. #include <linux/bcm47xx_wdt.h>
  7. #define PFX "ssb: "
  8. #ifdef CONFIG_SSB_SILENT
  9. # define ssb_printk(fmt, ...) \
  10. do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
  11. #else
  12. # define ssb_printk(fmt, ...) \
  13. printk(fmt, ##__VA_ARGS__)
  14. #endif /* CONFIG_SSB_SILENT */
  15. #define ssb_emerg(fmt, ...) ssb_printk(KERN_EMERG PFX fmt, ##__VA_ARGS__)
  16. #define ssb_err(fmt, ...) ssb_printk(KERN_ERR PFX fmt, ##__VA_ARGS__)
  17. #define ssb_warn(fmt, ...) ssb_printk(KERN_WARNING PFX fmt, ##__VA_ARGS__)
  18. #define ssb_notice(fmt, ...) ssb_printk(KERN_NOTICE PFX fmt, ##__VA_ARGS__)
  19. #define ssb_info(fmt, ...) ssb_printk(KERN_INFO PFX fmt, ##__VA_ARGS__)
  20. #define ssb_cont(fmt, ...) ssb_printk(KERN_CONT fmt, ##__VA_ARGS__)
  21. /* dprintk: Debugging printk; vanishes for non-debug compilation */
  22. #ifdef CONFIG_SSB_DEBUG
  23. # define ssb_dbg(fmt, ...) \
  24. ssb_printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__)
  25. #else
  26. # define ssb_dbg(fmt, ...) \
  27. do { if (0) printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__); } while (0)
  28. #endif
  29. #ifdef CONFIG_SSB_DEBUG
  30. # define SSB_WARN_ON(x) WARN_ON(x)
  31. # define SSB_BUG_ON(x) BUG_ON(x)
  32. #else
  33. static inline int __ssb_do_nothing(int x) { return x; }
  34. # define SSB_WARN_ON(x) __ssb_do_nothing(unlikely(!!(x)))
  35. # define SSB_BUG_ON(x) __ssb_do_nothing(unlikely(!!(x)))
  36. #endif
  37. /* pci.c */
  38. #ifdef CONFIG_SSB_PCIHOST
  39. extern int ssb_pci_switch_core(struct ssb_bus *bus,
  40. struct ssb_device *dev);
  41. extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
  42. u8 coreidx);
  43. extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
  44. int turn_on);
  45. extern int ssb_pci_get_invariants(struct ssb_bus *bus,
  46. struct ssb_init_invariants *iv);
  47. extern void ssb_pci_exit(struct ssb_bus *bus);
  48. extern int ssb_pci_init(struct ssb_bus *bus);
  49. extern const struct ssb_bus_ops ssb_pci_ops;
  50. #else /* CONFIG_SSB_PCIHOST */
  51. static inline int ssb_pci_switch_core(struct ssb_bus *bus,
  52. struct ssb_device *dev)
  53. {
  54. return 0;
  55. }
  56. static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
  57. u8 coreidx)
  58. {
  59. return 0;
  60. }
  61. static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
  62. int turn_on)
  63. {
  64. return 0;
  65. }
  66. static inline void ssb_pci_exit(struct ssb_bus *bus)
  67. {
  68. }
  69. static inline int ssb_pci_init(struct ssb_bus *bus)
  70. {
  71. return 0;
  72. }
  73. #endif /* CONFIG_SSB_PCIHOST */
  74. /* pcmcia.c */
  75. #ifdef CONFIG_SSB_PCMCIAHOST
  76. extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
  77. u8 coreidx);
  78. extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
  79. u8 seg);
  80. extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
  81. struct ssb_init_invariants *iv);
  82. extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
  83. extern void ssb_pcmcia_exit(struct ssb_bus *bus);
  84. extern int ssb_pcmcia_init(struct ssb_bus *bus);
  85. extern int ssb_host_pcmcia_init(void);
  86. extern void ssb_host_pcmcia_exit(void);
  87. extern const struct ssb_bus_ops ssb_pcmcia_ops;
  88. #else /* CONFIG_SSB_PCMCIAHOST */
  89. static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
  90. u8 coreidx)
  91. {
  92. return 0;
  93. }
  94. static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
  95. u8 seg)
  96. {
  97. return 0;
  98. }
  99. static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
  100. {
  101. return 0;
  102. }
  103. static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
  104. {
  105. }
  106. static inline int ssb_pcmcia_init(struct ssb_bus *bus)
  107. {
  108. return 0;
  109. }
  110. static inline int ssb_host_pcmcia_init(void)
  111. {
  112. return 0;
  113. }
  114. static inline void ssb_host_pcmcia_exit(void)
  115. {
  116. }
  117. #endif /* CONFIG_SSB_PCMCIAHOST */
  118. /* sdio.c */
  119. #ifdef CONFIG_SSB_SDIOHOST
  120. extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
  121. struct ssb_init_invariants *iv);
  122. extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
  123. extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
  124. extern void ssb_sdio_exit(struct ssb_bus *bus);
  125. extern int ssb_sdio_init(struct ssb_bus *bus);
  126. extern const struct ssb_bus_ops ssb_sdio_ops;
  127. #else /* CONFIG_SSB_SDIOHOST */
  128. static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
  129. {
  130. return 0;
  131. }
  132. static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
  133. {
  134. return 0;
  135. }
  136. static inline void ssb_sdio_exit(struct ssb_bus *bus)
  137. {
  138. }
  139. static inline int ssb_sdio_init(struct ssb_bus *bus)
  140. {
  141. return 0;
  142. }
  143. #endif /* CONFIG_SSB_SDIOHOST */
  144. /**************************************************
  145. * host_soc.c
  146. **************************************************/
  147. #ifdef CONFIG_SSB_HOST_SOC
  148. extern const struct ssb_bus_ops ssb_host_soc_ops;
  149. extern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
  150. struct ssb_init_invariants *iv);
  151. #endif
  152. /* scan.c */
  153. extern const char *ssb_core_name(u16 coreid);
  154. extern int ssb_bus_scan(struct ssb_bus *bus,
  155. unsigned long baseaddr);
  156. extern void ssb_iounmap(struct ssb_bus *ssb);
  157. /* sprom.c */
  158. extern
  159. ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
  160. int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
  161. extern
  162. ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
  163. const char *buf, size_t count,
  164. int (*sprom_check_crc)(const u16 *sprom, size_t size),
  165. int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
  166. extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
  167. struct ssb_sprom *out);
  168. /* core.c */
  169. extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
  170. extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
  171. int ssb_for_each_bus_call(unsigned long data,
  172. int (*func)(struct ssb_bus *bus, unsigned long data));
  173. extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
  174. struct ssb_freeze_context {
  175. /* Pointer to the bus */
  176. struct ssb_bus *bus;
  177. /* Boolean list to indicate whether a device is frozen on this bus. */
  178. bool device_frozen[SSB_MAX_NR_CORES];
  179. };
  180. extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
  181. extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
  182. /* b43_pci_bridge.c */
  183. #ifdef CONFIG_SSB_B43_PCI_BRIDGE
  184. extern int __init b43_pci_ssb_bridge_init(void);
  185. extern void __exit b43_pci_ssb_bridge_exit(void);
  186. #else /* CONFIG_SSB_B43_PCI_BRIDGE */
  187. static inline int b43_pci_ssb_bridge_init(void)
  188. {
  189. return 0;
  190. }
  191. static inline void b43_pci_ssb_bridge_exit(void)
  192. {
  193. }
  194. #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
  195. /* driver_chipcommon_pmu.c */
  196. extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
  197. extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
  198. extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
  199. extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  200. u32 ticks);
  201. extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
  202. /* driver_chipcommon_sflash.c */
  203. #ifdef CONFIG_SSB_SFLASH
  204. int ssb_sflash_init(struct ssb_chipcommon *cc);
  205. #else
  206. static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
  207. {
  208. pr_err("Serial flash not supported\n");
  209. return 0;
  210. }
  211. #endif /* CONFIG_SSB_SFLASH */
  212. #ifdef CONFIG_SSB_DRIVER_MIPS
  213. extern struct platform_device ssb_pflash_dev;
  214. #endif
  215. #ifdef CONFIG_SSB_SFLASH
  216. extern struct platform_device ssb_sflash_dev;
  217. #endif
  218. #ifdef CONFIG_SSB_DRIVER_EXTIF
  219. extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
  220. extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
  221. #else
  222. static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  223. u32 ticks)
  224. {
  225. return 0;
  226. }
  227. static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
  228. u32 ms)
  229. {
  230. return 0;
  231. }
  232. #endif
  233. #ifdef CONFIG_SSB_EMBEDDED
  234. extern int ssb_watchdog_register(struct ssb_bus *bus);
  235. #else /* CONFIG_SSB_EMBEDDED */
  236. static inline int ssb_watchdog_register(struct ssb_bus *bus)
  237. {
  238. return 0;
  239. }
  240. #endif /* CONFIG_SSB_EMBEDDED */
  241. #ifdef CONFIG_SSB_DRIVER_EXTIF
  242. extern void ssb_extif_init(struct ssb_extif *extif);
  243. #else
  244. static inline void ssb_extif_init(struct ssb_extif *extif)
  245. {
  246. }
  247. #endif
  248. #ifdef CONFIG_SSB_DRIVER_GPIO
  249. extern int ssb_gpio_init(struct ssb_bus *bus);
  250. extern int ssb_gpio_unregister(struct ssb_bus *bus);
  251. #else /* CONFIG_SSB_DRIVER_GPIO */
  252. static inline int ssb_gpio_init(struct ssb_bus *bus)
  253. {
  254. return -ENOTSUPP;
  255. }
  256. static inline int ssb_gpio_unregister(struct ssb_bus *bus)
  257. {
  258. return 0;
  259. }
  260. #endif /* CONFIG_SSB_DRIVER_GPIO */
  261. #endif /* LINUX_SSB_PRIVATE_H_ */