ssb_private.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #ifndef LINUX_SSB_PRIVATE_H_
  2. #define LINUX_SSB_PRIVATE_H_
  3. #include <linux/ssb/ssb.h>
  4. #include <linux/types.h>
  5. #define PFX "ssb: "
  6. #ifdef CONFIG_SSB_SILENT
  7. # define ssb_printk(fmt, x...) do { /* nothing */ } while (0)
  8. #else
  9. # define ssb_printk printk
  10. #endif /* CONFIG_SSB_SILENT */
  11. /* dprintk: Debugging printk; vanishes for non-debug compilation */
  12. #ifdef CONFIG_SSB_DEBUG
  13. # define ssb_dprintk(fmt, x...) ssb_printk(fmt , ##x)
  14. #else
  15. # define ssb_dprintk(fmt, x...) do { /* nothing */ } while (0)
  16. #endif
  17. #ifdef CONFIG_SSB_DEBUG
  18. # define SSB_WARN_ON(x) WARN_ON(x)
  19. # define SSB_BUG_ON(x) BUG_ON(x)
  20. #else
  21. static inline int __ssb_do_nothing(int x) { return x; }
  22. # define SSB_WARN_ON(x) __ssb_do_nothing(unlikely(!!(x)))
  23. # define SSB_BUG_ON(x) __ssb_do_nothing(unlikely(!!(x)))
  24. #endif
  25. /* pci.c */
  26. #ifdef CONFIG_SSB_PCIHOST
  27. extern int ssb_pci_switch_core(struct ssb_bus *bus,
  28. struct ssb_device *dev);
  29. extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
  30. u8 coreidx);
  31. extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
  32. int turn_on);
  33. extern int ssb_pci_get_invariants(struct ssb_bus *bus,
  34. struct ssb_init_invariants *iv);
  35. extern void ssb_pci_exit(struct ssb_bus *bus);
  36. extern int ssb_pci_init(struct ssb_bus *bus);
  37. extern const struct ssb_bus_ops ssb_pci_ops;
  38. #else /* CONFIG_SSB_PCIHOST */
  39. static inline int ssb_pci_switch_core(struct ssb_bus *bus,
  40. struct ssb_device *dev)
  41. {
  42. return 0;
  43. }
  44. static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
  45. u8 coreidx)
  46. {
  47. return 0;
  48. }
  49. static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
  50. int turn_on)
  51. {
  52. return 0;
  53. }
  54. static inline void ssb_pci_exit(struct ssb_bus *bus)
  55. {
  56. }
  57. static inline int ssb_pci_init(struct ssb_bus *bus)
  58. {
  59. return 0;
  60. }
  61. #endif /* CONFIG_SSB_PCIHOST */
  62. /* pcmcia.c */
  63. #ifdef CONFIG_SSB_PCMCIAHOST
  64. extern int ssb_pcmcia_switch_core(struct ssb_bus *bus,
  65. struct ssb_device *dev);
  66. extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
  67. u8 coreidx);
  68. extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
  69. u8 seg);
  70. extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
  71. struct ssb_init_invariants *iv);
  72. extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
  73. extern void ssb_pcmcia_exit(struct ssb_bus *bus);
  74. extern int ssb_pcmcia_init(struct ssb_bus *bus);
  75. extern const struct ssb_bus_ops ssb_pcmcia_ops;
  76. #else /* CONFIG_SSB_PCMCIAHOST */
  77. static inline int ssb_pcmcia_switch_core(struct ssb_bus *bus,
  78. struct ssb_device *dev)
  79. {
  80. return 0;
  81. }
  82. static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
  83. u8 coreidx)
  84. {
  85. return 0;
  86. }
  87. static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
  88. u8 seg)
  89. {
  90. return 0;
  91. }
  92. static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
  93. {
  94. return 0;
  95. }
  96. static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
  97. {
  98. }
  99. static inline int ssb_pcmcia_init(struct ssb_bus *bus)
  100. {
  101. return 0;
  102. }
  103. #endif /* CONFIG_SSB_PCMCIAHOST */
  104. /* sdio.c */
  105. #ifdef CONFIG_SSB_SDIOHOST
  106. extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
  107. struct ssb_init_invariants *iv);
  108. extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
  109. extern int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev);
  110. extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
  111. extern int ssb_sdio_hardware_setup(struct ssb_bus *bus);
  112. extern void ssb_sdio_exit(struct ssb_bus *bus);
  113. extern int ssb_sdio_init(struct ssb_bus *bus);
  114. extern const struct ssb_bus_ops ssb_sdio_ops;
  115. #else /* CONFIG_SSB_SDIOHOST */
  116. static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
  117. {
  118. return 0;
  119. }
  120. static inline int ssb_sdio_switch_core(struct ssb_bus *bus,
  121. struct ssb_device *dev)
  122. {
  123. return 0;
  124. }
  125. static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
  126. {
  127. return 0;
  128. }
  129. static inline int ssb_sdio_hardware_setup(struct ssb_bus *bus)
  130. {
  131. return 0;
  132. }
  133. static inline void ssb_sdio_exit(struct ssb_bus *bus)
  134. {
  135. }
  136. static inline int ssb_sdio_init(struct ssb_bus *bus)
  137. {
  138. return 0;
  139. }
  140. #endif /* CONFIG_SSB_SDIOHOST */
  141. /* scan.c */
  142. extern const char *ssb_core_name(u16 coreid);
  143. extern int ssb_bus_scan(struct ssb_bus *bus,
  144. unsigned long baseaddr);
  145. extern void ssb_iounmap(struct ssb_bus *ssb);
  146. /* sprom.c */
  147. extern
  148. ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
  149. int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
  150. extern
  151. ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
  152. const char *buf, size_t count,
  153. int (*sprom_check_crc)(const u16 *sprom, size_t size),
  154. int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
  155. extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
  156. struct ssb_sprom *out);
  157. /* core.c */
  158. extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
  159. extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
  160. int ssb_for_each_bus_call(unsigned long data,
  161. int (*func)(struct ssb_bus *bus, unsigned long data));
  162. extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
  163. struct ssb_freeze_context {
  164. /* Pointer to the bus */
  165. struct ssb_bus *bus;
  166. /* Boolean list to indicate whether a device is frozen on this bus. */
  167. bool device_frozen[SSB_MAX_NR_CORES];
  168. };
  169. extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
  170. extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
  171. /* b43_pci_bridge.c */
  172. #ifdef CONFIG_SSB_B43_PCI_BRIDGE
  173. extern int __init b43_pci_ssb_bridge_init(void);
  174. extern void __exit b43_pci_ssb_bridge_exit(void);
  175. #else /* CONFIG_SSB_B43_PCI_BRIDGE */
  176. static inline int b43_pci_ssb_bridge_init(void)
  177. {
  178. return 0;
  179. }
  180. static inline void b43_pci_ssb_bridge_exit(void)
  181. {
  182. }
  183. #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
  184. #endif /* LINUX_SSB_PRIVATE_H_ */