1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_SSB_PRIVATE_H_
3 #define LINUX_SSB_PRIVATE_H_
6 #define pr_fmt(fmt) PFX fmt
8 #include <linux/ssb/ssb.h>
9 #include <linux/types.h>
10 #include <linux/bcm47xx_wdt.h>
12 #ifdef CONFIG_SSB_DEBUG
13 # define SSB_WARN_ON(x) WARN_ON(x)
14 # define SSB_BUG_ON(x) BUG_ON(x)
16 static inline int __ssb_do_nothing(int x) { return x; }
17 # define SSB_WARN_ON(x) __ssb_do_nothing(unlikely(!!(x)))
18 # define SSB_BUG_ON(x) __ssb_do_nothing(unlikely(!!(x)))
23 #ifdef CONFIG_SSB_PCIHOST
24 extern int ssb_pci_switch_core(struct ssb_bus *bus,
25 struct ssb_device *dev);
26 extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
28 extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
30 extern int ssb_pci_get_invariants(struct ssb_bus *bus,
31 struct ssb_init_invariants *iv);
32 extern void ssb_pci_exit(struct ssb_bus *bus);
33 extern int ssb_pci_init(struct ssb_bus *bus);
34 extern const struct ssb_bus_ops ssb_pci_ops;
36 #else /* CONFIG_SSB_PCIHOST */
38 static inline int ssb_pci_switch_core(struct ssb_bus *bus,
39 struct ssb_device *dev)
43 static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
48 static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
53 static inline void ssb_pci_exit(struct ssb_bus *bus)
56 static inline int ssb_pci_init(struct ssb_bus *bus)
60 #endif /* CONFIG_SSB_PCIHOST */
64 #ifdef CONFIG_SSB_PCMCIAHOST
65 extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
67 extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
69 extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
70 struct ssb_init_invariants *iv);
71 extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
72 extern void ssb_pcmcia_exit(struct ssb_bus *bus);
73 extern int ssb_pcmcia_init(struct ssb_bus *bus);
74 extern int ssb_host_pcmcia_init(void);
75 extern void ssb_host_pcmcia_exit(void);
76 extern const struct ssb_bus_ops ssb_pcmcia_ops;
77 #else /* CONFIG_SSB_PCMCIAHOST */
78 static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
83 static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
88 static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
92 static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
95 static inline int ssb_pcmcia_init(struct ssb_bus *bus)
99 static inline int ssb_host_pcmcia_init(void)
103 static inline void ssb_host_pcmcia_exit(void)
106 #endif /* CONFIG_SSB_PCMCIAHOST */
109 #ifdef CONFIG_SSB_SDIOHOST
110 extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
111 struct ssb_init_invariants *iv);
113 extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
114 extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
115 extern void ssb_sdio_exit(struct ssb_bus *bus);
116 extern int ssb_sdio_init(struct ssb_bus *bus);
118 extern const struct ssb_bus_ops ssb_sdio_ops;
119 #else /* CONFIG_SSB_SDIOHOST */
120 static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
124 static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
128 static inline void ssb_sdio_exit(struct ssb_bus *bus)
131 static inline int ssb_sdio_init(struct ssb_bus *bus)
135 #endif /* CONFIG_SSB_SDIOHOST */
137 /**************************************************
139 **************************************************/
141 #ifdef CONFIG_SSB_HOST_SOC
142 extern const struct ssb_bus_ops ssb_host_soc_ops;
144 extern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
145 struct ssb_init_invariants *iv);
149 extern const char *ssb_core_name(u16 coreid);
150 extern int ssb_bus_scan(struct ssb_bus *bus,
151 unsigned long baseaddr);
152 extern void ssb_iounmap(struct ssb_bus *ssb);
157 ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
158 int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
160 ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
161 const char *buf, size_t count,
162 int (*sprom_check_crc)(const u16 *sprom, size_t size),
163 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
164 extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
165 struct ssb_sprom *out);
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);
175 struct ssb_freeze_context {
176 /* Pointer to the bus */
178 /* Boolean list to indicate whether a device is frozen on this bus. */
179 bool device_frozen[SSB_MAX_NR_CORES];
181 extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
182 extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
186 /* b43_pci_bridge.c */
187 #ifdef CONFIG_SSB_B43_PCI_BRIDGE
188 extern int __init b43_pci_ssb_bridge_init(void);
189 extern void __exit b43_pci_ssb_bridge_exit(void);
190 #else /* CONFIG_SSB_B43_PCI_BRIDGE */
191 static inline int b43_pci_ssb_bridge_init(void)
195 static inline void b43_pci_ssb_bridge_exit(void)
198 #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
200 /* driver_chipcommon_pmu.c */
201 extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
202 extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
203 extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
205 extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
207 extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
209 /* driver_chipcommon_sflash.c */
210 #ifdef CONFIG_SSB_SFLASH
211 int ssb_sflash_init(struct ssb_chipcommon *cc);
213 static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
215 pr_err("Serial flash not supported\n");
218 #endif /* CONFIG_SSB_SFLASH */
220 #ifdef CONFIG_SSB_DRIVER_MIPS
221 extern struct platform_device ssb_pflash_dev;
224 #ifdef CONFIG_SSB_SFLASH
225 extern struct platform_device ssb_sflash_dev;
228 #ifdef CONFIG_SSB_DRIVER_EXTIF
229 extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
230 extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
232 static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
237 static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
244 #ifdef CONFIG_SSB_EMBEDDED
245 extern int ssb_watchdog_register(struct ssb_bus *bus);
246 #else /* CONFIG_SSB_EMBEDDED */
247 static inline int ssb_watchdog_register(struct ssb_bus *bus)
251 #endif /* CONFIG_SSB_EMBEDDED */
253 #ifdef CONFIG_SSB_DRIVER_EXTIF
254 extern void ssb_extif_init(struct ssb_extif *extif);
256 static inline void ssb_extif_init(struct ssb_extif *extif)
261 #ifdef CONFIG_SSB_DRIVER_GPIO
262 extern int ssb_gpio_init(struct ssb_bus *bus);
263 extern int ssb_gpio_unregister(struct ssb_bus *bus);
264 #else /* CONFIG_SSB_DRIVER_GPIO */
265 static inline int ssb_gpio_init(struct ssb_bus *bus)
269 static inline int ssb_gpio_unregister(struct ssb_bus *bus)
273 #endif /* CONFIG_SSB_DRIVER_GPIO */
275 #endif /* LINUX_SSB_PRIVATE_H_ */