ssb: Remove home-grown printk wrappers
[sfrench/cifs-2.6.git] / drivers / ssb / ssb_private.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_SSB_PRIVATE_H_
3 #define LINUX_SSB_PRIVATE_H_
4
5 #define PFX             "ssb: "
6 #define pr_fmt(fmt)     PFX fmt
7
8 #include <linux/ssb/ssb.h>
9 #include <linux/types.h>
10 #include <linux/bcm47xx_wdt.h>
11
12 #ifdef CONFIG_SSB_DEBUG
13 # define SSB_WARN_ON(x)         WARN_ON(x)
14 # define SSB_BUG_ON(x)          BUG_ON(x)
15 #else
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)))
19 #endif
20
21
22 /* pci.c */
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,
27                                   u8 coreidx);
28 extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
29                         int turn_on);
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;
35
36 #else /* CONFIG_SSB_PCIHOST */
37
38 static inline int ssb_pci_switch_core(struct ssb_bus *bus,
39                                       struct ssb_device *dev)
40 {
41         return 0;
42 }
43 static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
44                                          u8 coreidx)
45 {
46         return 0;
47 }
48 static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
49                                int turn_on)
50 {
51         return 0;
52 }
53 static inline void ssb_pci_exit(struct ssb_bus *bus)
54 {
55 }
56 static inline int ssb_pci_init(struct ssb_bus *bus)
57 {
58         return 0;
59 }
60 #endif /* CONFIG_SSB_PCIHOST */
61
62
63 /* pcmcia.c */
64 #ifdef CONFIG_SSB_PCMCIAHOST
65 extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
66                                      u8 coreidx);
67 extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
68                                      u8 seg);
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,
79                                             u8 coreidx)
80 {
81         return 0;
82 }
83 static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
84                                             u8 seg)
85 {
86         return 0;
87 }
88 static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
89 {
90         return 0;
91 }
92 static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
93 {
94 }
95 static inline int ssb_pcmcia_init(struct ssb_bus *bus)
96 {
97         return 0;
98 }
99 static inline int ssb_host_pcmcia_init(void)
100 {
101         return 0;
102 }
103 static inline void ssb_host_pcmcia_exit(void)
104 {
105 }
106 #endif /* CONFIG_SSB_PCMCIAHOST */
107
108 /* sdio.c */
109 #ifdef CONFIG_SSB_SDIOHOST
110 extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
111                                      struct ssb_init_invariants *iv);
112
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);
117
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)
121 {
122         return 0;
123 }
124 static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
125 {
126         return 0;
127 }
128 static inline void ssb_sdio_exit(struct ssb_bus *bus)
129 {
130 }
131 static inline int ssb_sdio_init(struct ssb_bus *bus)
132 {
133         return 0;
134 }
135 #endif /* CONFIG_SSB_SDIOHOST */
136
137 /**************************************************
138  * host_soc.c
139  **************************************************/
140
141 #ifdef CONFIG_SSB_HOST_SOC
142 extern const struct ssb_bus_ops ssb_host_soc_ops;
143
144 extern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
145                                        struct ssb_init_invariants *iv);
146 #endif
147
148 /* scan.c */
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);
153
154
155 /* sprom.c */
156 extern
157 ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
158                             int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
159 extern
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);
166
167
168 /* core.c */
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);
174
175 struct ssb_freeze_context {
176         /* Pointer to the bus */
177         struct ssb_bus *bus;
178         /* Boolean list to indicate whether a device is frozen on this bus. */
179         bool device_frozen[SSB_MAX_NR_CORES];
180 };
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);
183
184
185
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)
192 {
193         return 0;
194 }
195 static inline void b43_pci_ssb_bridge_exit(void)
196 {
197 }
198 #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
199
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);
204
205 extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
206                                              u32 ticks);
207 extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
208
209 /* driver_chipcommon_sflash.c */
210 #ifdef CONFIG_SSB_SFLASH
211 int ssb_sflash_init(struct ssb_chipcommon *cc);
212 #else
213 static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
214 {
215         pr_err("Serial flash not supported\n");
216         return 0;
217 }
218 #endif /* CONFIG_SSB_SFLASH */
219
220 #ifdef CONFIG_SSB_DRIVER_MIPS
221 extern struct platform_device ssb_pflash_dev;
222 #endif
223
224 #ifdef CONFIG_SSB_SFLASH
225 extern struct platform_device ssb_sflash_dev;
226 #endif
227
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);
231 #else
232 static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
233                                                    u32 ticks)
234 {
235         return 0;
236 }
237 static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
238                                                   u32 ms)
239 {
240         return 0;
241 }
242 #endif
243
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)
248 {
249         return 0;
250 }
251 #endif /* CONFIG_SSB_EMBEDDED */
252
253 #ifdef CONFIG_SSB_DRIVER_EXTIF
254 extern void ssb_extif_init(struct ssb_extif *extif);
255 #else
256 static inline void ssb_extif_init(struct ssb_extif *extif)
257 {
258 }
259 #endif
260
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)
266 {
267         return -ENOTSUPP;
268 }
269 static inline int ssb_gpio_unregister(struct ssb_bus *bus)
270 {
271         return 0;
272 }
273 #endif /* CONFIG_SSB_DRIVER_GPIO */
274
275 #endif /* LINUX_SSB_PRIVATE_H_ */