xref: /linux/drivers/ssb/ssb_private.h (revision 8fe2b65a)
161e115a5SMichael Buesch #ifndef LINUX_SSB_PRIVATE_H_
261e115a5SMichael Buesch #define LINUX_SSB_PRIVATE_H_
361e115a5SMichael Buesch 
461e115a5SMichael Buesch #include <linux/ssb/ssb.h>
561e115a5SMichael Buesch #include <linux/types.h>
661e115a5SMichael Buesch 
761e115a5SMichael Buesch 
861e115a5SMichael Buesch #define PFX	"ssb: "
961e115a5SMichael Buesch 
1061e115a5SMichael Buesch #ifdef CONFIG_SSB_SILENT
1161e115a5SMichael Buesch # define ssb_printk(fmt, x...)	do { /* nothing */ } while (0)
1261e115a5SMichael Buesch #else
1361e115a5SMichael Buesch # define ssb_printk		printk
1461e115a5SMichael Buesch #endif /* CONFIG_SSB_SILENT */
1561e115a5SMichael Buesch 
1661e115a5SMichael Buesch /* dprintk: Debugging printk; vanishes for non-debug compilation */
1761e115a5SMichael Buesch #ifdef CONFIG_SSB_DEBUG
1861e115a5SMichael Buesch # define ssb_dprintk(fmt, x...)	ssb_printk(fmt , ##x)
1961e115a5SMichael Buesch #else
2061e115a5SMichael Buesch # define ssb_dprintk(fmt, x...)	do { /* nothing */ } while (0)
2161e115a5SMichael Buesch #endif
2261e115a5SMichael Buesch 
2361e115a5SMichael Buesch #ifdef CONFIG_SSB_DEBUG
2461e115a5SMichael Buesch # define SSB_WARN_ON(x)		WARN_ON(x)
2561e115a5SMichael Buesch # define SSB_BUG_ON(x)		BUG_ON(x)
2661e115a5SMichael Buesch #else
2761e115a5SMichael Buesch static inline int __ssb_do_nothing(int x) { return x; }
2861e115a5SMichael Buesch # define SSB_WARN_ON(x)		__ssb_do_nothing(unlikely(!!(x)))
2961e115a5SMichael Buesch # define SSB_BUG_ON(x)		__ssb_do_nothing(unlikely(!!(x)))
3061e115a5SMichael Buesch #endif
3161e115a5SMichael Buesch 
3261e115a5SMichael Buesch 
3361e115a5SMichael Buesch /* pci.c */
3461e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST
3561e115a5SMichael Buesch extern int ssb_pci_switch_core(struct ssb_bus *bus,
3661e115a5SMichael Buesch 			       struct ssb_device *dev);
3761e115a5SMichael Buesch extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
3861e115a5SMichael Buesch 				  u8 coreidx);
3961e115a5SMichael Buesch extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
4061e115a5SMichael Buesch 			int turn_on);
4161e115a5SMichael Buesch extern int ssb_pci_get_invariants(struct ssb_bus *bus,
4261e115a5SMichael Buesch 				  struct ssb_init_invariants *iv);
4361e115a5SMichael Buesch extern void ssb_pci_exit(struct ssb_bus *bus);
4461e115a5SMichael Buesch extern int ssb_pci_init(struct ssb_bus *bus);
4561e115a5SMichael Buesch extern const struct ssb_bus_ops ssb_pci_ops;
4661e115a5SMichael Buesch 
4761e115a5SMichael Buesch #else /* CONFIG_SSB_PCIHOST */
4861e115a5SMichael Buesch 
4961e115a5SMichael Buesch static inline int ssb_pci_switch_core(struct ssb_bus *bus,
5061e115a5SMichael Buesch 				      struct ssb_device *dev)
5161e115a5SMichael Buesch {
5261e115a5SMichael Buesch 	return 0;
5361e115a5SMichael Buesch }
5461e115a5SMichael Buesch static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
5561e115a5SMichael Buesch 					 u8 coreidx)
5661e115a5SMichael Buesch {
5761e115a5SMichael Buesch 	return 0;
5861e115a5SMichael Buesch }
5961e115a5SMichael Buesch static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
6061e115a5SMichael Buesch 			       int turn_on)
6161e115a5SMichael Buesch {
6261e115a5SMichael Buesch 	return 0;
6361e115a5SMichael Buesch }
6461e115a5SMichael Buesch static inline void ssb_pci_exit(struct ssb_bus *bus)
6561e115a5SMichael Buesch {
6661e115a5SMichael Buesch }
6761e115a5SMichael Buesch static inline int ssb_pci_init(struct ssb_bus *bus)
6861e115a5SMichael Buesch {
6961e115a5SMichael Buesch 	return 0;
7061e115a5SMichael Buesch }
7161e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
7261e115a5SMichael Buesch 
7361e115a5SMichael Buesch 
7461e115a5SMichael Buesch /* pcmcia.c */
7561e115a5SMichael Buesch #ifdef CONFIG_SSB_PCMCIAHOST
7661e115a5SMichael Buesch extern int ssb_pcmcia_switch_core(struct ssb_bus *bus,
7761e115a5SMichael Buesch 				  struct ssb_device *dev);
7861e115a5SMichael Buesch extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
7961e115a5SMichael Buesch 				     u8 coreidx);
8061e115a5SMichael Buesch extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
8161e115a5SMichael Buesch 				     u8 seg);
8261e115a5SMichael Buesch extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
8361e115a5SMichael Buesch 				     struct ssb_init_invariants *iv);
84*8fe2b65aSMichael Buesch extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
85e7ec2e32SMichael Buesch extern void ssb_pcmcia_exit(struct ssb_bus *bus);
8661e115a5SMichael Buesch extern int ssb_pcmcia_init(struct ssb_bus *bus);
8761e115a5SMichael Buesch extern const struct ssb_bus_ops ssb_pcmcia_ops;
8861e115a5SMichael Buesch #else /* CONFIG_SSB_PCMCIAHOST */
8961e115a5SMichael Buesch static inline int ssb_pcmcia_switch_core(struct ssb_bus *bus,
9061e115a5SMichael Buesch 					 struct ssb_device *dev)
9161e115a5SMichael Buesch {
9261e115a5SMichael Buesch 	return 0;
9361e115a5SMichael Buesch }
9461e115a5SMichael Buesch static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
9561e115a5SMichael Buesch 					    u8 coreidx)
9661e115a5SMichael Buesch {
9761e115a5SMichael Buesch 	return 0;
9861e115a5SMichael Buesch }
9961e115a5SMichael Buesch static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
10061e115a5SMichael Buesch 					    u8 seg)
10161e115a5SMichael Buesch {
10261e115a5SMichael Buesch 	return 0;
10361e115a5SMichael Buesch }
104*8fe2b65aSMichael Buesch static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
105*8fe2b65aSMichael Buesch {
106*8fe2b65aSMichael Buesch 	return 0;
107*8fe2b65aSMichael Buesch }
108e7ec2e32SMichael Buesch static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
109e7ec2e32SMichael Buesch {
110e7ec2e32SMichael Buesch }
11161e115a5SMichael Buesch static inline int ssb_pcmcia_init(struct ssb_bus *bus)
11261e115a5SMichael Buesch {
11361e115a5SMichael Buesch 	return 0;
11461e115a5SMichael Buesch }
11561e115a5SMichael Buesch #endif /* CONFIG_SSB_PCMCIAHOST */
11661e115a5SMichael Buesch 
11761e115a5SMichael Buesch 
11861e115a5SMichael Buesch /* scan.c */
11961e115a5SMichael Buesch extern const char *ssb_core_name(u16 coreid);
12061e115a5SMichael Buesch extern int ssb_bus_scan(struct ssb_bus *bus,
12161e115a5SMichael Buesch 			unsigned long baseaddr);
12261e115a5SMichael Buesch extern void ssb_iounmap(struct ssb_bus *ssb);
12361e115a5SMichael Buesch 
12461e115a5SMichael Buesch 
125e7ec2e32SMichael Buesch /* sprom.c */
126e7ec2e32SMichael Buesch extern
127e7ec2e32SMichael Buesch ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
128e7ec2e32SMichael Buesch 			    int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
129e7ec2e32SMichael Buesch extern
130e7ec2e32SMichael Buesch ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
131e7ec2e32SMichael Buesch 			     const char *buf, size_t count,
132e7ec2e32SMichael Buesch 			     int (*sprom_check_crc)(const u16 *sprom, size_t size),
133e7ec2e32SMichael Buesch 			     int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
134e7ec2e32SMichael Buesch 
135e7ec2e32SMichael Buesch 
13661e115a5SMichael Buesch /* core.c */
13761e115a5SMichael Buesch extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
13861e115a5SMichael Buesch extern int ssb_devices_freeze(struct ssb_bus *bus);
13961e115a5SMichael Buesch extern int ssb_devices_thaw(struct ssb_bus *bus);
14061e115a5SMichael Buesch extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
141aab547ceSMichael Buesch int ssb_for_each_bus_call(unsigned long data,
142aab547ceSMichael Buesch 			  int (*func)(struct ssb_bus *bus, unsigned long data));
143e7ec2e32SMichael Buesch extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
144e7ec2e32SMichael Buesch 
14561e115a5SMichael Buesch 
14661e115a5SMichael Buesch /* b43_pci_bridge.c */
147c7084535SAlexey Zaytsev #ifdef CONFIG_SSB_B43_PCI_BRIDGE
14861e115a5SMichael Buesch extern int __init b43_pci_ssb_bridge_init(void);
14961e115a5SMichael Buesch extern void __exit b43_pci_ssb_bridge_exit(void);
150c7084535SAlexey Zaytsev #else /* CONFIG_SSB_B43_PCI_BRIDGR */
15161e115a5SMichael Buesch static inline int b43_pci_ssb_bridge_init(void)
15261e115a5SMichael Buesch {
15361e115a5SMichael Buesch 	return 0;
15461e115a5SMichael Buesch }
15561e115a5SMichael Buesch static inline void b43_pci_ssb_bridge_exit(void)
15661e115a5SMichael Buesch {
15761e115a5SMichael Buesch }
15861e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
15961e115a5SMichael Buesch 
16061e115a5SMichael Buesch #endif /* LINUX_SSB_PRIVATE_H_ */
161