brcm43xx: update SSB driver * files/ now contains the wireless-dev tree version ...
[openwrt/staging/yousong.git] / target / linux / brcm47xx-2.6 / files / 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 <asm/io.h>
7
8
9 #define PFX "ssb: "
10
11 #ifdef CONFIG_SSB_SILENT
12 # define ssb_printk(fmt, x...) do { /* nothing */ } while (0)
13 #else
14 # define ssb_printk printk
15 #endif /* CONFIG_SSB_SILENT */
16
17 /* dprintk: Debugging printk; vanishes for non-debug compilation */
18 #ifdef CONFIG_SSB_DEBUG
19 # define ssb_dprintk(fmt, x...) ssb_printk(fmt ,##x)
20 #else
21 # define ssb_dprintk(fmt, x...) do { /* nothing */ } while (0)
22 #endif
23
24 /* printkl: Rate limited printk */
25 #define ssb_printkl(fmt, x...) do { \
26 if (printk_ratelimit()) \
27 ssb_printk(fmt ,##x); \
28 } while (0)
29
30 /* dprintkl: Rate limited debugging printk */
31 #ifdef CONFIG_SSB_DEBUG
32 # define ssb_dprintkl ssb_printkl
33 #else
34 # define ssb_dprintkl(fmt, x...) do { /* nothing */ } while (0)
35 #endif
36
37 #define assert(cond) do { \
38 if (unlikely(!(cond))) { \
39 ssb_dprintk(KERN_ERR PFX "BUG: Assertion failed (%s) " \
40 "at: %s:%d:%s()\n", \
41 #cond, __FILE__, __LINE__, __func__); \
42 } \
43 } while (0)
44
45
46 /* pci.c */
47 #ifdef CONFIG_SSB_PCIHOST
48 extern int ssb_pci_switch_core(struct ssb_bus *bus,
49 struct ssb_device *dev);
50 extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
51 u8 coreidx);
52 extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
53 int turn_on);
54 extern int ssb_pci_sprom_get(struct ssb_bus *bus);
55 extern void ssb_pci_get_boardtype(struct ssb_bus *bus);
56 extern void ssb_pci_exit(struct ssb_bus *bus);
57 extern int ssb_pci_init(struct ssb_bus *bus);
58 extern const struct ssb_bus_ops ssb_pci_ops;
59
60 #else /* CONFIG_SSB_PCIHOST */
61
62 static inline int ssb_pci_switch_core(struct ssb_bus *bus,
63 struct ssb_device *dev)
64 {
65 return 0;
66 }
67 static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
68 u8 coreidx)
69 {
70 return 0;
71 }
72 static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
73 int turn_on)
74 {
75 return 0;
76 }
77 static inline int ssb_pci_sprom_get(struct ssb_bus *bus)
78 {
79 return 0;
80 }
81 static inline void ssb_pci_get_boardtype(struct ssb_bus *bus)
82 {
83 }
84 static inline void ssb_pci_exit(struct ssb_bus *bus)
85 {
86 }
87 static inline int ssb_pci_init(struct ssb_bus *bus)
88 {
89 return 0;
90 }
91 #endif /* CONFIG_SSB_PCIHOST */
92
93
94 /* pcmcia.c */
95 #ifdef CONFIG_SSB_PCMCIAHOST
96 extern int ssb_pcmcia_switch_core(struct ssb_bus *bus,
97 struct ssb_device *dev);
98 extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
99 u8 coreidx);
100 extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
101 u8 seg);
102 extern int ssb_pcmcia_init(struct ssb_bus *bus);
103 extern const struct ssb_bus_ops ssb_pcmcia_ops;
104 #else /* CONFIG_SSB_PCMCIAHOST */
105 static inline int ssb_pcmcia_switch_core(struct ssb_bus *bus,
106 struct ssb_device *dev)
107 {
108 return 0;
109 }
110 static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
111 u8 coreidx)
112 {
113 return 0;
114 }
115 static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
116 u8 seg)
117 {
118 return 0;
119 }
120 static inline int ssb_pcmcia_init(struct ssb_bus *bus)
121 {
122 return 0;
123 }
124 #endif /* CONFIG_SSB_PCMCIAHOST */
125
126
127 /* scan.c */
128 extern const char * ssb_core_name(u16 coreid);
129 extern int ssb_bus_scan(struct ssb_bus *bus,
130 unsigned long baseaddr);
131 extern void ssb_iounmap(struct ssb_bus *ssb);
132
133
134 /* core.c */
135 extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
136 #ifdef CONFIG_SSB_PCIHOST
137 extern int ssb_devices_freeze(struct ssb_bus *bus);
138 extern int ssb_devices_thaw(struct ssb_bus *bus);
139 extern struct ssb_bus * ssb_pci_dev_to_bus(struct pci_dev *pdev);
140 #endif /* CONFIG_SSB_PCIHOST */
141
142
143 /* Ceiling division helper. Divides x by y. */
144 static inline
145 unsigned long ceildiv(unsigned long x, unsigned long y)
146 {
147 return ((x + (y - 1)) / y);
148 }
149
150
151 #endif /* LINUX_SSB_PRIVATE_H_ */