blob: 5f31bdfbe77f7748da236151f4197da0e10be5d7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Michael Buesch61e115a2007-09-18 15:12:50 -04002#ifndef LINUX_SSB_PRIVATE_H_
3#define LINUX_SSB_PRIVATE_H_
4
Michael Büschb8b60692018-07-31 21:56:38 +02005#define PFX "ssb: "
6#define pr_fmt(fmt) PFX fmt
7
Michael Buesch61e115a2007-09-18 15:12:50 -04008#include <linux/ssb/ssb.h>
9#include <linux/types.h>
Hauke Mehrtens7ffbffe2012-12-05 18:46:05 +010010#include <linux/bcm47xx_wdt.h>
Michael Buesch61e115a2007-09-18 15:12:50 -040011
Michael Buesch61e115a2007-09-18 15:12:50 -040012
13/* pci.c */
14#ifdef CONFIG_SSB_PCIHOST
15extern int ssb_pci_switch_core(struct ssb_bus *bus,
16 struct ssb_device *dev);
17extern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
18 u8 coreidx);
19extern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
20 int turn_on);
21extern int ssb_pci_get_invariants(struct ssb_bus *bus,
22 struct ssb_init_invariants *iv);
23extern void ssb_pci_exit(struct ssb_bus *bus);
24extern int ssb_pci_init(struct ssb_bus *bus);
25extern const struct ssb_bus_ops ssb_pci_ops;
26
27#else /* CONFIG_SSB_PCIHOST */
28
29static inline int ssb_pci_switch_core(struct ssb_bus *bus,
30 struct ssb_device *dev)
31{
32 return 0;
33}
34static inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
35 u8 coreidx)
36{
37 return 0;
38}
39static inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
40 int turn_on)
41{
42 return 0;
43}
44static inline void ssb_pci_exit(struct ssb_bus *bus)
45{
46}
47static inline int ssb_pci_init(struct ssb_bus *bus)
48{
49 return 0;
50}
51#endif /* CONFIG_SSB_PCIHOST */
52
53
54/* pcmcia.c */
55#ifdef CONFIG_SSB_PCMCIAHOST
Michael Buesch61e115a2007-09-18 15:12:50 -040056extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
57 u8 coreidx);
58extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
59 u8 seg);
60extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
61 struct ssb_init_invariants *iv);
Michael Buesch8fe2b652008-03-30 00:10:50 +010062extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
Michael Buesche7ec2e32008-03-10 17:26:32 +010063extern void ssb_pcmcia_exit(struct ssb_bus *bus);
Michael Buesch61e115a2007-09-18 15:12:50 -040064extern int ssb_pcmcia_init(struct ssb_bus *bus);
Rafał Miłecki399500da2015-10-15 07:23:25 +020065extern int ssb_host_pcmcia_init(void);
66extern void ssb_host_pcmcia_exit(void);
Michael Buesch61e115a2007-09-18 15:12:50 -040067extern const struct ssb_bus_ops ssb_pcmcia_ops;
68#else /* CONFIG_SSB_PCMCIAHOST */
Michael Buesch61e115a2007-09-18 15:12:50 -040069static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
70 u8 coreidx)
71{
72 return 0;
73}
74static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
75 u8 seg)
76{
77 return 0;
78}
Michael Buesch8fe2b652008-03-30 00:10:50 +010079static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
80{
81 return 0;
82}
Michael Buesche7ec2e32008-03-10 17:26:32 +010083static inline void ssb_pcmcia_exit(struct ssb_bus *bus)
84{
85}
Michael Buesch61e115a2007-09-18 15:12:50 -040086static inline int ssb_pcmcia_init(struct ssb_bus *bus)
87{
88 return 0;
89}
Rafał Miłecki399500da2015-10-15 07:23:25 +020090static inline int ssb_host_pcmcia_init(void)
91{
92 return 0;
93}
94static inline void ssb_host_pcmcia_exit(void)
95{
96}
Michael Buesch61e115a2007-09-18 15:12:50 -040097#endif /* CONFIG_SSB_PCMCIAHOST */
98
Albert Herranz24ea6022009-09-08 19:30:12 +020099/* sdio.c */
100#ifdef CONFIG_SSB_SDIOHOST
101extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
102 struct ssb_init_invariants *iv);
103
104extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
Albert Herranz24ea6022009-09-08 19:30:12 +0200105extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
Albert Herranz24ea6022009-09-08 19:30:12 +0200106extern void ssb_sdio_exit(struct ssb_bus *bus);
107extern int ssb_sdio_init(struct ssb_bus *bus);
108
109extern const struct ssb_bus_ops ssb_sdio_ops;
110#else /* CONFIG_SSB_SDIOHOST */
111static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
112{
113 return 0;
114}
Albert Herranz24ea6022009-09-08 19:30:12 +0200115static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
116{
117 return 0;
118}
Albert Herranz24ea6022009-09-08 19:30:12 +0200119static inline void ssb_sdio_exit(struct ssb_bus *bus)
120{
121}
122static inline int ssb_sdio_init(struct ssb_bus *bus)
123{
124 return 0;
125}
126#endif /* CONFIG_SSB_SDIOHOST */
127
Rafał Miłecki830c7df2015-10-25 19:32:42 +0100128/**************************************************
129 * host_soc.c
130 **************************************************/
131
Rafał Miłecki845da6e2015-10-25 19:32:43 +0100132#ifdef CONFIG_SSB_HOST_SOC
Rafał Miłecki830c7df2015-10-25 19:32:42 +0100133extern const struct ssb_bus_ops ssb_host_soc_ops;
Rafał Miłecki541c9a82015-12-09 23:36:51 +0100134
135extern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
136 struct ssb_init_invariants *iv);
Rafał Miłecki845da6e2015-10-25 19:32:43 +0100137#endif
Michael Buesch61e115a2007-09-18 15:12:50 -0400138
139/* scan.c */
140extern const char *ssb_core_name(u16 coreid);
141extern int ssb_bus_scan(struct ssb_bus *bus,
142 unsigned long baseaddr);
143extern void ssb_iounmap(struct ssb_bus *ssb);
144
145
Michael Buesche7ec2e32008-03-10 17:26:32 +0100146/* sprom.c */
147extern
148ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
149 int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
150extern
151ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
152 const char *buf, size_t count,
153 int (*sprom_check_crc)(const u16 *sprom, size_t size),
154 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
Hauke Mehrtensb3ae52b2011-05-10 23:31:30 +0200155extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
156 struct ssb_sprom *out);
Michael Buesche7ec2e32008-03-10 17:26:32 +0100157
158
Michael Buesch61e115a2007-09-18 15:12:50 -0400159/* core.c */
160extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
Michael Buesch61e115a2007-09-18 15:12:50 -0400161extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
Michael Bueschaab547c2008-02-29 11:36:12 +0100162int ssb_for_each_bus_call(unsigned long data,
163 int (*func)(struct ssb_bus *bus, unsigned long data));
Michael Buesche7ec2e32008-03-10 17:26:32 +0100164extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
165
Michael Buesch3ba60182009-11-23 20:12:13 +0100166struct ssb_freeze_context {
167 /* Pointer to the bus */
168 struct ssb_bus *bus;
169 /* Boolean list to indicate whether a device is frozen on this bus. */
170 bool device_frozen[SSB_MAX_NR_CORES];
171};
172extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
173extern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
174
175
Michael Buesch61e115a2007-09-18 15:12:50 -0400176
177/* b43_pci_bridge.c */
Alexey Zaytsevc7084532008-02-23 12:59:26 +0300178#ifdef CONFIG_SSB_B43_PCI_BRIDGE
Michael Buesch61e115a2007-09-18 15:12:50 -0400179extern int __init b43_pci_ssb_bridge_init(void);
180extern void __exit b43_pci_ssb_bridge_exit(void);
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100181#else /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400182static inline int b43_pci_ssb_bridge_init(void)
183{
184 return 0;
185}
186static inline void b43_pci_ssb_bridge_exit(void)
187{
188}
Hauke Mehrtens0052b8b2010-02-13 18:10:54 +0100189#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
Michael Buesch61e115a2007-09-18 15:12:50 -0400190
Hauke Mehrtensd486a5b2012-02-01 00:13:56 +0100191/* driver_chipcommon_pmu.c */
192extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
193extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
Hauke Mehrtensf924e1e2012-12-05 18:46:03 +0100194extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
Hauke Mehrtensd486a5b2012-02-01 00:13:56 +0100195
Hauke Mehrtens7ffbffe2012-12-05 18:46:05 +0100196extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
197 u32 ticks);
198extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
199
Rafał Miłecki72a525c2013-01-06 21:48:50 +0100200/* driver_chipcommon_sflash.c */
201#ifdef CONFIG_SSB_SFLASH
202int ssb_sflash_init(struct ssb_chipcommon *cc);
203#else
204static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
205{
206 pr_err("Serial flash not supported\n");
207 return 0;
208}
209#endif /* CONFIG_SSB_SFLASH */
210
Rafał Miłeckic7a4a9e2013-01-25 11:36:26 +0100211#ifdef CONFIG_SSB_DRIVER_MIPS
212extern struct platform_device ssb_pflash_dev;
213#endif
214
Rafał Miłecki7b5d6042013-06-18 07:33:40 +0200215#ifdef CONFIG_SSB_SFLASH
216extern struct platform_device ssb_sflash_dev;
217#endif
218
Hauke Mehrtens9f640a62012-12-05 18:46:07 +0100219#ifdef CONFIG_SSB_DRIVER_EXTIF
220extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
221extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
222#else
223static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
224 u32 ticks)
225{
226 return 0;
227}
228static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
229 u32 ms)
230{
231 return 0;
232}
233#endif
Hauke Mehrtensbde327e2012-12-05 18:46:08 +0100234
235#ifdef CONFIG_SSB_EMBEDDED
236extern int ssb_watchdog_register(struct ssb_bus *bus);
237#else /* CONFIG_SSB_EMBEDDED */
238static inline int ssb_watchdog_register(struct ssb_bus *bus)
239{
240 return 0;
241}
242#endif /* CONFIG_SSB_EMBEDDED */
243
Hauke Mehrtens394bc7e2012-11-20 22:24:32 +0000244#ifdef CONFIG_SSB_DRIVER_EXTIF
245extern void ssb_extif_init(struct ssb_extif *extif);
246#else
247static inline void ssb_extif_init(struct ssb_extif *extif)
248{
249}
250#endif
251
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000252#ifdef CONFIG_SSB_DRIVER_GPIO
253extern int ssb_gpio_init(struct ssb_bus *bus);
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100254extern int ssb_gpio_unregister(struct ssb_bus *bus);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000255#else /* CONFIG_SSB_DRIVER_GPIO */
256static inline int ssb_gpio_init(struct ssb_bus *bus)
257{
258 return -ENOTSUPP;
259}
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100260static inline int ssb_gpio_unregister(struct ssb_bus *bus)
261{
262 return 0;
263}
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000264#endif /* CONFIG_SSB_DRIVER_GPIO */
265
Michael Buesch61e115a2007-09-18 15:12:50 -0400266#endif /* LINUX_SSB_PRIVATE_H_ */