ssb_private.h 7.5 KB

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