blob: 0a756c2519e5145d228e8b261ce4a702bed2e055 [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>
Hauke Mehrtens7ffbffe2012-12-05 18:46:05 +01006#include <linux/bcm47xx_wdt.h>
Michael Buesch61e115a2007-09-18 15:12:50 -04007
8
9#define PFX "ssb: "
10
11#ifdef CONFIG_SSB_SILENT
Joe Perches33a606a2013-02-20 12:16:13 -080012# define ssb_printk(fmt, ...) \
13 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
Michael Buesch61e115a2007-09-18 15:12:50 -040014#else
Joe Perches33a606a2013-02-20 12:16:13 -080015# define ssb_printk(fmt, ...) \
16 printk(fmt, ##__VA_ARGS__)
Michael Buesch61e115a2007-09-18 15:12:50 -040017#endif /* CONFIG_SSB_SILENT */
18
Joe Perches33a606a2013-02-20 12:16:13 -080019#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
Michael Buesch61e115a2007-09-18 15:12:50 -040026/* dprintk: Debugging printk; vanishes for non-debug compilation */
27#ifdef CONFIG_SSB_DEBUG
Joe Perches33a606a2013-02-20 12:16:13 -080028# define ssb_dbg(fmt, ...) \
29 ssb_printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__)
Michael Buesch61e115a2007-09-18 15:12:50 -040030#else
Joe Perches33a606a2013-02-20 12:16:13 -080031# define ssb_dbg(fmt, ...) \
32 do { if (0) printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__); } while (0)
Michael Buesch61e115a2007-09-18 15:12:50 -040033#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
39static 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
47extern int ssb_pci_switch_core(struct ssb_bus *bus,
48 struct ssb_device *dev);
49extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
50 u8 coreidx);
51extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
52 int turn_on);
53extern int ssb_pci_get_invariants(struct ssb_bus *bus,
54 struct ssb_init_invariants *iv);
55extern void ssb_pci_exit(struct ssb_bus *bus);
56extern int ssb_pci_init(struct ssb_bus *bus);
57extern const struct ssb_bus_ops ssb_pci_ops;
58
59#else /* CONFIG_SSB_PCIHOST */
60
61static inline int ssb_pci_switch_core(struct ssb_bus *bus,
62 struct ssb_device *dev)
63{
64 return 0;
65}
66static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
67 u8 coreidx)
68{
69 return 0;
70}
71static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
72 int turn_on)
73{
74 return 0;
75}
76static inline void ssb_pci_exit(struct ssb_bus *bus)
77{
78}
79static 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
Michael Buesch61e115a2007-09-18 15:12:50 -040088extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
89 u8 coreidx);
90extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
91 u8 seg);
92extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
93 struct ssb_init_invariants *iv);
Michael Buesch8fe2b652008-03-30 00:10:50 +010094extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
Michael Buesche7ec2e32008-03-10 17:26:32 +010095extern void ssb_pcmcia_exit(struct ssb_bus *bus);
Michael Buesch61e115a2007-09-18 15:12:50 -040096extern int ssb_pcmcia_init(struct ssb_bus *bus);
Rafał Miłecki399500da2015-10-15 07:23:25 +020097extern int ssb_host_pcmcia_init(void);
98extern void ssb_host_pcmcia_exit(void);
Michael Buesch61e115a2007-09-18 15:12:50 -040099extern const struct ssb_bus_ops ssb_pcmcia_ops;
100#else /* CONFIG_SSB_PCMCIAHOST */
Michael Buesch61e115a2007-09-18 15:12:50 -0400101static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
102 u8 coreidx)
103{
104 return 0;
105}
106static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
107 u8 seg)
108{
109 return 0;
110}
Michael Buesch8fe2b652008-03-30 00:10:50 +0100111static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
112{
113 return 0;
114}
Michael Buesche7ec2e32008-03-10 17:26:32 +0100115static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
116{
117}
Michael Buesch61e115a2007-09-18 15:12:50 -0400118static inline int ssb_pcmcia_init(struct ssb_bus *bus)
119{
120 return 0;
121}
Rafał Miłecki399500da2015-10-15 07:23:25 +0200122static inline int ssb_host_pcmcia_init(void)
123{
124 return 0;
125}
126static inline void ssb_host_pcmcia_exit(void)
127{
128}
Michael Buesch61e115a2007-09-18 15:12:50 -0400129#endif /* CONFIG_SSB_PCMCIAHOST */
130
Albert Herranz24ea6022009-09-08 19:30:12 +0200131/* sdio.c */
132#ifdef CONFIG_SSB_SDIOHOST
133extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
134 struct ssb_init_invariants *iv);
135
136extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
Albert Herranz24ea6022009-09-08 19:30:12 +0200137extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
Albert Herranz24ea6022009-09-08 19:30:12 +0200138extern void ssb_sdio_exit(struct ssb_bus *bus);
139extern int ssb_sdio_init(struct ssb_bus *bus);
140
141extern const struct ssb_bus_ops ssb_sdio_ops;
142#else /* CONFIG_SSB_SDIOHOST */
143static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
144{
145 return 0;
146}
Albert Herranz24ea6022009-09-08 19:30:12 +0200147static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
148{
149 return 0;
150}
Albert Herranz24ea6022009-09-08 19:30:12 +0200151static inline void ssb_sdio_exit(struct ssb_bus *bus)
152{
153}
154static inline int ssb_sdio_init(struct ssb_bus *bus)
155{
156 return 0;
157}
158#endif /* CONFIG_SSB_SDIOHOST */
159
Rafał Miłecki830c7df2015-10-25 19:32:42 +0100160/**************************************************
161 * host_soc.c
162 **************************************************/
163
164extern const struct ssb_bus_ops ssb_host_soc_ops;
Michael Buesch61e115a2007-09-18 15:12:50 -0400165
166/* scan.c */
167extern const char *ssb_core_name(u16 coreid);
168extern int ssb_bus_scan(struct ssb_bus *bus,
169 unsigned long baseaddr);
170extern void ssb_iounmap(struct ssb_bus *ssb);
171
172
Michael Buesche7ec2e32008-03-10 17:26:32 +0100173/* sprom.c */
174extern
175ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
176 int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
177extern
178ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
179 const char *buf, size_t count,
180 int (*sprom_check_crc)(const u16 *sprom, size_t size),
181 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
Hauke Mehrtensb3ae52b2011-05-10 23:31:30 +0200182extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
183 struct ssb_sprom *out);
Michael Buesche7ec2e32008-03-10 17:26:32 +0100184
185
Michael Buesch61e115a2007-09-18 15:12:50 -0400186/* core.c */
187extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
Michael Buesch61e115a2007-09-18 15:12:50 -0400188extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
Michael Bueschaab547c2008-02-29 11:36:12 +0100189int ssb_for_each_bus_call(unsigned long data,
190 int (*func)(struct ssb_bus *bus, unsigned long data));
Michael Buesche7ec2e32008-03-10 17:26:32 +0100191extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
192
Michael Buesch3ba60182009-11-23 20:12:13 +0100193struct ssb_freeze_context {
194 /* Pointer to the bus */
195 struct ssb_bus *bus;
196 /* Boolean list to indicate whether a device is frozen on this bus. */
197 bool device_frozen[SSB_MAX_NR_CORES];
198};
199extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
200extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
201
202
Michael Buesch61e115a2007-09-18 15:12:50 -0400203
204/* b43_pci_bridge.c */
Alexey Zaytsevc7084532008-02-23 12:59:26 +0300205#ifdef CONFIG_SSB_B43_PCI_BRIDGE
Michael Buesch61e115a2007-09-18 15:12:50 -0400206extern int __init b43_pci_ssb_bridge_init(void);
207extern void __exit b43_pci_ssb_bridge_exit(void);
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100208#else /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400209static inline int b43_pci_ssb_bridge_init(void)
210{
211 return 0;
212}
213static inline void b43_pci_ssb_bridge_exit(void)
214{
215}
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100216#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400217
Hauke Mehrtensd486a5b2012-02-01 00:13:56 +0100218/* driver_chipcommon_pmu.c */
219extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
220extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
Hauke Mehrtensf924e1e2012-12-05 18:46:03 +0100221extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
Hauke Mehrtensd486a5b2012-02-01 00:13:56 +0100222
Hauke Mehrtens7ffbffe2012-12-05 18:46:05 +0100223extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
224 u32 ticks);
225extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
226
Rafał Miłecki72a525c2013-01-06 21:48:50 +0100227/* driver_chipcommon_sflash.c */
228#ifdef CONFIG_SSB_SFLASH
229int ssb_sflash_init(struct ssb_chipcommon *cc);
230#else
231static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
232{
233 pr_err("Serial flash not supported\n");
234 return 0;
235}
236#endif /* CONFIG_SSB_SFLASH */
237
Rafał Miłeckic7a4a9e2013-01-25 11:36:26 +0100238#ifdef CONFIG_SSB_DRIVER_MIPS
239extern struct platform_device ssb_pflash_dev;
240#endif
241
Rafał Miłecki7b5d6042013-06-18 07:33:40 +0200242#ifdef CONFIG_SSB_SFLASH
243extern struct platform_device ssb_sflash_dev;
244#endif
245
Hauke Mehrtens9f640a62012-12-05 18:46:07 +0100246#ifdef CONFIG_SSB_DRIVER_EXTIF
247extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
248extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
249#else
250static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
251 u32 ticks)
252{
253 return 0;
254}
255static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
256 u32 ms)
257{
258 return 0;
259}
260#endif
Hauke Mehrtensbde327e2012-12-05 18:46:08 +0100261
262#ifdef CONFIG_SSB_EMBEDDED
263extern int ssb_watchdog_register(struct ssb_bus *bus);
264#else /* CONFIG_SSB_EMBEDDED */
265static inline int ssb_watchdog_register(struct ssb_bus *bus)
266{
267 return 0;
268}
269#endif /* CONFIG_SSB_EMBEDDED */
270
Hauke Mehrtens394bc7e2012-11-20 22:24:32 +0000271#ifdef CONFIG_SSB_DRIVER_EXTIF
272extern void ssb_extif_init(struct ssb_extif *extif);
273#else
274static inline void ssb_extif_init(struct ssb_extif *extif)
275{
276}
277#endif
278
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000279#ifdef CONFIG_SSB_DRIVER_GPIO
280extern int ssb_gpio_init(struct ssb_bus *bus);
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100281extern int ssb_gpio_unregister(struct ssb_bus *bus);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000282#else /* CONFIG_SSB_DRIVER_GPIO */
283static inline int ssb_gpio_init(struct ssb_bus *bus)
284{
285 return -ENOTSUPP;
286}
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100287static inline int ssb_gpio_unregister(struct ssb_bus *bus)
288{
289 return 0;
290}
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000291#endif /* CONFIG_SSB_DRIVER_GPIO */
292
Michael Buesch61e115a2007-09-18 15:12:50 -0400293#endif /* LINUX_SSB_PRIVATE_H_ */