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