ssb_private.h 7.0 KB

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