bcma_private.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef LINUX_BCMA_PRIVATE_H_
  3. #define LINUX_BCMA_PRIVATE_H_
  4. #ifndef pr_fmt
  5. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  6. #endif
  7. #include <linux/bcma/bcma.h>
  8. #include <linux/delay.h>
  9. #define bcma_err(bus, fmt, ...) \
  10. pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  11. #define bcma_warn(bus, fmt, ...) \
  12. pr_warn("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  13. #define bcma_info(bus, fmt, ...) \
  14. pr_info("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  15. #define bcma_debug(bus, fmt, ...) \
  16. pr_debug("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  17. struct bcma_bus;
  18. /* main.c */
  19. bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
  20. int timeout);
  21. void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
  22. void bcma_init_bus(struct bcma_bus *bus);
  23. void bcma_unregister_cores(struct bcma_bus *bus);
  24. int bcma_bus_register(struct bcma_bus *bus);
  25. void bcma_bus_unregister(struct bcma_bus *bus);
  26. int __init bcma_bus_early_register(struct bcma_bus *bus);
  27. #ifdef CONFIG_PM
  28. int bcma_bus_suspend(struct bcma_bus *bus);
  29. int bcma_bus_resume(struct bcma_bus *bus);
  30. #endif
  31. struct device *bcma_bus_get_host_dev(struct bcma_bus *bus);
  32. /* scan.c */
  33. void bcma_detect_chip(struct bcma_bus *bus);
  34. int bcma_bus_scan(struct bcma_bus *bus);
  35. /* sprom.c */
  36. int bcma_sprom_get(struct bcma_bus *bus);
  37. /* driver_chipcommon.c */
  38. void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
  39. void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
  40. void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
  41. #ifdef CONFIG_BCMA_DRIVER_MIPS
  42. void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
  43. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  44. /* driver_chipcommon_b.c */
  45. int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
  46. void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
  47. /* driver_chipcommon_pmu.c */
  48. void bcma_pmu_early_init(struct bcma_drv_cc *cc);
  49. void bcma_pmu_init(struct bcma_drv_cc *cc);
  50. u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
  51. u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
  52. /**************************************************
  53. * driver_chipcommon_sflash.c
  54. **************************************************/
  55. #ifdef CONFIG_BCMA_PFLASH
  56. extern struct platform_device bcma_pflash_dev;
  57. int bcma_pflash_init(struct bcma_drv_cc *cc);
  58. #else
  59. static inline int bcma_pflash_init(struct bcma_drv_cc *cc)
  60. {
  61. bcma_err(cc->core->bus, "Parallel flash not supported\n");
  62. return 0;
  63. }
  64. #endif /* CONFIG_BCMA_PFLASH */
  65. #ifdef CONFIG_BCMA_SFLASH
  66. /* driver_chipcommon_sflash.c */
  67. int bcma_sflash_init(struct bcma_drv_cc *cc);
  68. extern struct platform_device bcma_sflash_dev;
  69. #else
  70. static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
  71. {
  72. bcma_err(cc->core->bus, "Serial flash not supported\n");
  73. return 0;
  74. }
  75. #endif /* CONFIG_BCMA_SFLASH */
  76. #ifdef CONFIG_BCMA_NFLASH
  77. /* driver_chipcommon_nflash.c */
  78. int bcma_nflash_init(struct bcma_drv_cc *cc);
  79. extern struct platform_device bcma_nflash_dev;
  80. #else
  81. static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
  82. {
  83. bcma_err(cc->core->bus, "NAND flash not supported\n");
  84. return 0;
  85. }
  86. #endif /* CONFIG_BCMA_NFLASH */
  87. #ifdef CONFIG_BCMA_HOST_PCI
  88. /* host_pci.c */
  89. extern int __init bcma_host_pci_init(void);
  90. extern void __exit bcma_host_pci_exit(void);
  91. #endif /* CONFIG_BCMA_HOST_PCI */
  92. /* host_soc.c */
  93. #if defined(CONFIG_BCMA_HOST_SOC) && defined(CONFIG_OF)
  94. extern int __init bcma_host_soc_register_driver(void);
  95. extern void __exit bcma_host_soc_unregister_driver(void);
  96. #else
  97. static inline int __init bcma_host_soc_register_driver(void)
  98. {
  99. return 0;
  100. }
  101. static inline void __exit bcma_host_soc_unregister_driver(void)
  102. {
  103. }
  104. #endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */
  105. /* driver_pci.c */
  106. #ifdef CONFIG_BCMA_DRIVER_PCI
  107. u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
  108. void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
  109. void bcma_core_pci_init(struct bcma_drv_pci *pc);
  110. void bcma_core_pci_up(struct bcma_drv_pci *pc);
  111. void bcma_core_pci_down(struct bcma_drv_pci *pc);
  112. #else
  113. static inline void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
  114. {
  115. WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
  116. }
  117. static inline void bcma_core_pci_init(struct bcma_drv_pci *pc)
  118. {
  119. /* Initialization is required for PCI hosted bus */
  120. WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
  121. }
  122. #endif
  123. /* driver_pcie2.c */
  124. #ifdef CONFIG_BCMA_DRIVER_PCI
  125. void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
  126. void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2);
  127. #else
  128. static inline void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
  129. {
  130. /* Initialization is required for PCI hosted bus */
  131. WARN_ON(pcie2->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
  132. }
  133. #endif
  134. extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
  135. #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  136. bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
  137. void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
  138. #else
  139. static inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
  140. {
  141. return false;
  142. }
  143. static inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
  144. {
  145. }
  146. #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
  147. /**************************************************
  148. * driver_mips.c
  149. **************************************************/
  150. #ifdef CONFIG_BCMA_DRIVER_MIPS
  151. unsigned int bcma_core_mips_irq(struct bcma_device *dev);
  152. void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
  153. void bcma_core_mips_init(struct bcma_drv_mips *mcore);
  154. #else
  155. static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
  156. {
  157. return 0;
  158. }
  159. static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
  160. {
  161. }
  162. static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore)
  163. {
  164. }
  165. #endif
  166. /**************************************************
  167. * driver_gmac_cmn.c
  168. **************************************************/
  169. #ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
  170. void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
  171. #else
  172. static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
  173. {
  174. }
  175. #endif
  176. #ifdef CONFIG_BCMA_DRIVER_GPIO
  177. /* driver_gpio.c */
  178. int bcma_gpio_init(struct bcma_drv_cc *cc);
  179. int bcma_gpio_unregister(struct bcma_drv_cc *cc);
  180. #else
  181. static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
  182. {
  183. return -ENOTSUPP;
  184. }
  185. static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
  186. {
  187. return 0;
  188. }
  189. #endif /* CONFIG_BCMA_DRIVER_GPIO */
  190. #endif