blob: 0331139a726fb2dd44cd30c41985cfa866b2f1f2 [file] [log] [blame]
Michael Buesch61e115a2007-09-18 15:12:50 -04001#ifndef LINUX_SSB_PRIVATE_H_
2#define LINUX_SSB_PRIVATE_H_
3
4#include <linux/ssb/ssb.h>
5#include <linux/types.h>
6
7
8#define PFX "ssb: "
9
10#ifdef CONFIG_SSB_SILENT
11# define ssb_printk(fmt, x...) do { /* nothing */ } while (0)
12#else
13# define ssb_printk printk
14#endif /* CONFIG_SSB_SILENT */
15
16/* dprintk: Debugging printk; vanishes for non-debug compilation */
17#ifdef CONFIG_SSB_DEBUG
18# define ssb_dprintk(fmt, x...) ssb_printk(fmt , ##x)
19#else
20# define ssb_dprintk(fmt, x...) do { /* nothing */ } while (0)
21#endif
22
23#ifdef CONFIG_SSB_DEBUG
24# define SSB_WARN_ON(x) WARN_ON(x)
25# define SSB_BUG_ON(x) BUG_ON(x)
26#else
27static inline int __ssb_do_nothing(int x) { return x; }
28# define SSB_WARN_ON(x) __ssb_do_nothing(unlikely(!!(x)))
29# define SSB_BUG_ON(x) __ssb_do_nothing(unlikely(!!(x)))
30#endif
31
32
33/* pci.c */
34#ifdef CONFIG_SSB_PCIHOST
35extern int ssb_pci_switch_core(struct ssb_bus *bus,
36 struct ssb_device *dev);
37extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
38 u8 coreidx);
39extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
40 int turn_on);
41extern int ssb_pci_get_invariants(struct ssb_bus *bus,
42 struct ssb_init_invariants *iv);
43extern void ssb_pci_exit(struct ssb_bus *bus);
44extern int ssb_pci_init(struct ssb_bus *bus);
45extern const struct ssb_bus_ops ssb_pci_ops;
46
47#else /* CONFIG_SSB_PCIHOST */
48
49static inline int ssb_pci_switch_core(struct ssb_bus *bus,
50 struct ssb_device *dev)
51{
52 return 0;
53}
54static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
55 u8 coreidx)
56{
57 return 0;
58}
59static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
60 int turn_on)
61{
62 return 0;
63}
64static inline void ssb_pci_exit(struct ssb_bus *bus)
65{
66}
67static inline int ssb_pci_init(struct ssb_bus *bus)
68{
69 return 0;
70}
71#endif /* CONFIG_SSB_PCIHOST */
72
73
74/* pcmcia.c */
75#ifdef CONFIG_SSB_PCMCIAHOST
76extern int ssb_pcmcia_switch_core(struct ssb_bus *bus,
77 struct ssb_device *dev);
78extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
79 u8 coreidx);
80extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
81 u8 seg);
82extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
83 struct ssb_init_invariants *iv);
Michael Buesch8fe2b652008-03-30 00:10:50 +010084extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
Michael Buesche7ec2e32008-03-10 17:26:32 +010085extern void ssb_pcmcia_exit(struct ssb_bus *bus);
Michael Buesch61e115a2007-09-18 15:12:50 -040086extern int ssb_pcmcia_init(struct ssb_bus *bus);
87extern const struct ssb_bus_ops ssb_pcmcia_ops;
88#else /* CONFIG_SSB_PCMCIAHOST */
89static inline int ssb_pcmcia_switch_core(struct ssb_bus *bus,
90 struct ssb_device *dev)
91{
92 return 0;
93}
94static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
95 u8 coreidx)
96{
97 return 0;
98}
99static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
100 u8 seg)
101{
102 return 0;
103}
Michael Buesch8fe2b652008-03-30 00:10:50 +0100104static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
105{
106 return 0;
107}
Michael Buesche7ec2e32008-03-10 17:26:32 +0100108static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
109{
110}
Michael Buesch61e115a2007-09-18 15:12:50 -0400111static inline int ssb_pcmcia_init(struct ssb_bus *bus)
112{
113 return 0;
114}
115#endif /* CONFIG_SSB_PCMCIAHOST */
116
Albert Herranz24ea6022009-09-08 19:30:12 +0200117/* sdio.c */
118#ifdef CONFIG_SSB_SDIOHOST
119extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
120 struct ssb_init_invariants *iv);
121
122extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
123extern int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev);
124extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
125extern int ssb_sdio_hardware_setup(struct ssb_bus *bus);
126extern void ssb_sdio_exit(struct ssb_bus *bus);
127extern int ssb_sdio_init(struct ssb_bus *bus);
128
129extern const struct ssb_bus_ops ssb_sdio_ops;
130#else /* CONFIG_SSB_SDIOHOST */
131static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
132{
133 return 0;
134}
135static inline int ssb_sdio_switch_core(struct ssb_bus *bus,
136 struct ssb_device *dev)
137{
138 return 0;
139}
140static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
141{
142 return 0;
143}
144static inline int ssb_sdio_hardware_setup(struct ssb_bus *bus)
145{
146 return 0;
147}
148static inline void ssb_sdio_exit(struct ssb_bus *bus)
149{
150}
151static inline int ssb_sdio_init(struct ssb_bus *bus)
152{
153 return 0;
154}
155#endif /* CONFIG_SSB_SDIOHOST */
156
Michael Buesch61e115a2007-09-18 15:12:50 -0400157
158/* scan.c */
159extern const char *ssb_core_name(u16 coreid);
160extern int ssb_bus_scan(struct ssb_bus *bus,
161 unsigned long baseaddr);
162extern void ssb_iounmap(struct ssb_bus *ssb);
163
164
Michael Buesche7ec2e32008-03-10 17:26:32 +0100165/* sprom.c */
166extern
167ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
168 int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
169extern
170ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
171 const char *buf, size_t count,
172 int (*sprom_check_crc)(const u16 *sprom, size_t size),
173 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
Michael Buesche79c1ba2009-02-27 16:59:05 +0100174extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
Michael Buesche7ec2e32008-03-10 17:26:32 +0100175
176
Michael Buesch61e115a2007-09-18 15:12:50 -0400177/* core.c */
178extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
Michael Buesch61e115a2007-09-18 15:12:50 -0400179extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
Michael Bueschaab547c2008-02-29 11:36:12 +0100180int ssb_for_each_bus_call(unsigned long data,
181 int (*func)(struct ssb_bus *bus, unsigned long data));
Michael Buesche7ec2e32008-03-10 17:26:32 +0100182extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
183
Michael Buesch3ba60182009-11-23 20:12:13 +0100184struct ssb_freeze_context {
185 /* Pointer to the bus */
186 struct ssb_bus *bus;
187 /* Boolean list to indicate whether a device is frozen on this bus. */
188 bool device_frozen[SSB_MAX_NR_CORES];
189};
190extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
191extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
192
193
Michael Buesch61e115a2007-09-18 15:12:50 -0400194
195/* b43_pci_bridge.c */
Alexey Zaytsevc7084532008-02-23 12:59:26 +0300196#ifdef CONFIG_SSB_B43_PCI_BRIDGE
Michael Buesch61e115a2007-09-18 15:12:50 -0400197extern int __init b43_pci_ssb_bridge_init(void);
198extern void __exit b43_pci_ssb_bridge_exit(void);
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100199#else /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400200static inline int b43_pci_ssb_bridge_init(void)
201{
202 return 0;
203}
204static inline void b43_pci_ssb_bridge_exit(void)
205{
206}
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100207#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400208
209#endif /* LINUX_SSB_PRIVATE_H_ */