1 #ifndef LINUX_SSB_PRIVATE_H_
2 #define LINUX_SSB_PRIVATE_H_
4 #include <linux/ssb/ssb.h>
5 #include <linux/types.h>
6 #include <linux/bcm47xx_wdt.h>
11 #ifdef CONFIG_SSB_SILENT
12 # define ssb_printk(fmt, ...) \
13 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
15 # define ssb_printk(fmt, ...) \
16 printk(fmt, ##__VA_ARGS__)
17 #endif /* CONFIG_SSB_SILENT */
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__)
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__)
31 # define ssb_dbg(fmt, ...) \
32 do { if (0) printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__); } while (0)
35 #ifdef CONFIG_SSB_DEBUG
36 # define SSB_WARN_ON(x) WARN_ON(x)
37 # define SSB_BUG_ON(x) BUG_ON(x)
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)))
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
,
51 extern int ssb_pci_xtal(struct ssb_bus
*bus
, u32 what
,
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
;
59 #else /* CONFIG_SSB_PCIHOST */
61 static inline int ssb_pci_switch_core(struct ssb_bus
*bus
,
62 struct ssb_device
*dev
)
66 static inline int ssb_pci_switch_coreidx(struct ssb_bus
*bus
,
71 static inline int ssb_pci_xtal(struct ssb_bus
*bus
, u32 what
,
76 static inline void ssb_pci_exit(struct ssb_bus
*bus
)
79 static inline int ssb_pci_init(struct ssb_bus
*bus
)
83 #endif /* CONFIG_SSB_PCIHOST */
87 #ifdef CONFIG_SSB_PCMCIAHOST
88 extern int ssb_pcmcia_switch_coreidx(struct ssb_bus
*bus
,
90 extern int ssb_pcmcia_switch_segment(struct ssb_bus
*bus
,
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 int ssb_host_pcmcia_init(void);
98 extern void ssb_host_pcmcia_exit(void);
99 extern const struct ssb_bus_ops ssb_pcmcia_ops
;
100 #else /* CONFIG_SSB_PCMCIAHOST */
101 static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus
*bus
,
106 static inline int ssb_pcmcia_switch_segment(struct ssb_bus
*bus
,
111 static inline int ssb_pcmcia_hardware_setup(struct ssb_bus
*bus
)
115 static inline void ssb_pcmcia_exit(struct ssb_bus
*bus
)
118 static inline int ssb_pcmcia_init(struct ssb_bus
*bus
)
122 static inline int ssb_host_pcmcia_init(void)
126 static inline void ssb_host_pcmcia_exit(void)
129 #endif /* CONFIG_SSB_PCMCIAHOST */
132 #ifdef CONFIG_SSB_SDIOHOST
133 extern int ssb_sdio_get_invariants(struct ssb_bus
*bus
,
134 struct ssb_init_invariants
*iv
);
136 extern u32
ssb_sdio_scan_read32(struct ssb_bus
*bus
, u16 offset
);
137 extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus
*bus
, u8 coreidx
);
138 extern void ssb_sdio_exit(struct ssb_bus
*bus
);
139 extern int ssb_sdio_init(struct ssb_bus
*bus
);
141 extern const struct ssb_bus_ops ssb_sdio_ops
;
142 #else /* CONFIG_SSB_SDIOHOST */
143 static inline u32
ssb_sdio_scan_read32(struct ssb_bus
*bus
, u16 offset
)
147 static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus
*bus
, u8 coreidx
)
151 static inline void ssb_sdio_exit(struct ssb_bus
*bus
)
154 static inline int ssb_sdio_init(struct ssb_bus
*bus
)
158 #endif /* CONFIG_SSB_SDIOHOST */
160 /**************************************************
162 **************************************************/
164 #ifdef CONFIG_SSB_HOST_SOC
165 extern const struct ssb_bus_ops ssb_host_soc_ops
;
169 extern const char *ssb_core_name(u16 coreid
);
170 extern int ssb_bus_scan(struct ssb_bus
*bus
,
171 unsigned long baseaddr
);
172 extern void ssb_iounmap(struct ssb_bus
*ssb
);
177 ssize_t
ssb_attr_sprom_show(struct ssb_bus
*bus
, char *buf
,
178 int (*sprom_read
)(struct ssb_bus
*bus
, u16
*sprom
));
180 ssize_t
ssb_attr_sprom_store(struct ssb_bus
*bus
,
181 const char *buf
, size_t count
,
182 int (*sprom_check_crc
)(const u16
*sprom
, size_t size
),
183 int (*sprom_write
)(struct ssb_bus
*bus
, const u16
*sprom
));
184 extern int ssb_fill_sprom_with_fallback(struct ssb_bus
*bus
,
185 struct ssb_sprom
*out
);
189 extern u32
ssb_calc_clock_rate(u32 plltype
, u32 n
, u32 m
);
190 extern struct ssb_bus
*ssb_pci_dev_to_bus(struct pci_dev
*pdev
);
191 int ssb_for_each_bus_call(unsigned long data
,
192 int (*func
)(struct ssb_bus
*bus
, unsigned long data
));
193 extern struct ssb_bus
*ssb_pcmcia_dev_to_bus(struct pcmcia_device
*pdev
);
195 struct ssb_freeze_context
{
196 /* Pointer to the bus */
198 /* Boolean list to indicate whether a device is frozen on this bus. */
199 bool device_frozen
[SSB_MAX_NR_CORES
];
201 extern int ssb_devices_freeze(struct ssb_bus
*bus
, struct ssb_freeze_context
*ctx
);
202 extern int ssb_devices_thaw(struct ssb_freeze_context
*ctx
);
206 /* b43_pci_bridge.c */
207 #ifdef CONFIG_SSB_B43_PCI_BRIDGE
208 extern int __init
b43_pci_ssb_bridge_init(void);
209 extern void __exit
b43_pci_ssb_bridge_exit(void);
210 #else /* CONFIG_SSB_B43_PCI_BRIDGE */
211 static inline int b43_pci_ssb_bridge_init(void)
215 static inline void b43_pci_ssb_bridge_exit(void)
218 #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
220 /* driver_chipcommon_pmu.c */
221 extern u32
ssb_pmu_get_cpu_clock(struct ssb_chipcommon
*cc
);
222 extern u32
ssb_pmu_get_controlclock(struct ssb_chipcommon
*cc
);
223 extern u32
ssb_pmu_get_alp_clock(struct ssb_chipcommon
*cc
);
225 extern u32
ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt
*wdt
,
227 extern u32
ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt
*wdt
, u32 ms
);
229 /* driver_chipcommon_sflash.c */
230 #ifdef CONFIG_SSB_SFLASH
231 int ssb_sflash_init(struct ssb_chipcommon
*cc
);
233 static inline int ssb_sflash_init(struct ssb_chipcommon
*cc
)
235 pr_err("Serial flash not supported\n");
238 #endif /* CONFIG_SSB_SFLASH */
240 #ifdef CONFIG_SSB_DRIVER_MIPS
241 extern struct platform_device ssb_pflash_dev
;
244 #ifdef CONFIG_SSB_SFLASH
245 extern struct platform_device ssb_sflash_dev
;
248 #ifdef CONFIG_SSB_DRIVER_EXTIF
249 extern u32
ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt
*wdt
, u32 ticks
);
250 extern u32
ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt
*wdt
, u32 ms
);
252 static inline u32
ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt
*wdt
,
257 static inline u32
ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt
*wdt
,
264 #ifdef CONFIG_SSB_EMBEDDED
265 extern int ssb_watchdog_register(struct ssb_bus
*bus
);
266 #else /* CONFIG_SSB_EMBEDDED */
267 static inline int ssb_watchdog_register(struct ssb_bus
*bus
)
271 #endif /* CONFIG_SSB_EMBEDDED */
273 #ifdef CONFIG_SSB_DRIVER_EXTIF
274 extern void ssb_extif_init(struct ssb_extif
*extif
);
276 static inline void ssb_extif_init(struct ssb_extif
*extif
)
281 #ifdef CONFIG_SSB_DRIVER_GPIO
282 extern int ssb_gpio_init(struct ssb_bus
*bus
);
283 extern int ssb_gpio_unregister(struct ssb_bus
*bus
);
284 #else /* CONFIG_SSB_DRIVER_GPIO */
285 static inline int ssb_gpio_init(struct ssb_bus
*bus
)
289 static inline int ssb_gpio_unregister(struct ssb_bus
*bus
)
293 #endif /* CONFIG_SSB_DRIVER_GPIO */
295 #endif /* LINUX_SSB_PRIVATE_H_ */