xref: /openbmc/linux/drivers/bcma/bcma_private.h (revision fbb6b31a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_BCMA_PRIVATE_H_
3 #define LINUX_BCMA_PRIVATE_H_
4 
5 #ifndef pr_fmt
6 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
7 #endif
8 
9 #include <linux/bcma/bcma.h>
10 #include <linux/delay.h>
11 
12 #define bcma_err(bus, fmt, ...) \
13 	dev_err((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
14 #define bcma_warn(bus, fmt, ...) \
15 	dev_warn((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
16 #define bcma_info(bus, fmt, ...) \
17 	dev_info((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
18 #define bcma_debug(bus, fmt, ...) \
19 	dev_dbg((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
20 
21 struct bcma_bus;
22 
23 /* main.c */
24 bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
25 		     int timeout);
26 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
27 void bcma_init_bus(struct bcma_bus *bus);
28 void bcma_unregister_cores(struct bcma_bus *bus);
29 int bcma_bus_register(struct bcma_bus *bus);
30 void bcma_bus_unregister(struct bcma_bus *bus);
31 int __init bcma_bus_early_register(struct bcma_bus *bus);
32 #ifdef CONFIG_PM
33 int bcma_bus_suspend(struct bcma_bus *bus);
34 int bcma_bus_resume(struct bcma_bus *bus);
35 #endif
36 
37 /* scan.c */
38 void bcma_detect_chip(struct bcma_bus *bus);
39 int bcma_bus_scan(struct bcma_bus *bus);
40 
41 /* sprom.c */
42 int bcma_sprom_get(struct bcma_bus *bus);
43 
44 /* driver_chipcommon.c */
45 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
46 void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
47 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
48 #ifdef CONFIG_BCMA_DRIVER_MIPS
49 void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
50 #endif /* CONFIG_BCMA_DRIVER_MIPS */
51 
52 /* driver_chipcommon_b.c */
53 int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
54 void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
55 
56 /* driver_chipcommon_pmu.c */
57 void bcma_pmu_early_init(struct bcma_drv_cc *cc);
58 void bcma_pmu_init(struct bcma_drv_cc *cc);
59 u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
60 u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
61 
62 /**************************************************
63  * driver_chipcommon_sflash.c
64  **************************************************/
65 
66 #ifdef CONFIG_BCMA_PFLASH
67 extern struct platform_device bcma_pflash_dev;
68 int bcma_pflash_init(struct bcma_drv_cc *cc);
69 #else
70 static inline int bcma_pflash_init(struct bcma_drv_cc *cc)
71 {
72 	bcma_err(cc->core->bus, "Parallel flash not supported\n");
73 	return 0;
74 }
75 #endif /* CONFIG_BCMA_PFLASH */
76 
77 #ifdef CONFIG_BCMA_SFLASH
78 /* driver_chipcommon_sflash.c */
79 int bcma_sflash_init(struct bcma_drv_cc *cc);
80 extern struct platform_device bcma_sflash_dev;
81 #else
82 static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
83 {
84 	bcma_err(cc->core->bus, "Serial flash not supported\n");
85 	return 0;
86 }
87 #endif /* CONFIG_BCMA_SFLASH */
88 
89 #ifdef CONFIG_BCMA_NFLASH
90 /* driver_chipcommon_nflash.c */
91 int bcma_nflash_init(struct bcma_drv_cc *cc);
92 extern struct platform_device bcma_nflash_dev;
93 #else
94 static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
95 {
96 	bcma_err(cc->core->bus, "NAND flash not supported\n");
97 	return 0;
98 }
99 #endif /* CONFIG_BCMA_NFLASH */
100 
101 #ifdef CONFIG_BCMA_HOST_PCI
102 /* host_pci.c */
103 extern int __init bcma_host_pci_init(void);
104 extern void __exit bcma_host_pci_exit(void);
105 #endif /* CONFIG_BCMA_HOST_PCI */
106 
107 /* host_soc.c */
108 #if defined(CONFIG_BCMA_HOST_SOC) && defined(CONFIG_OF)
109 extern int __init bcma_host_soc_register_driver(void);
110 extern void __exit bcma_host_soc_unregister_driver(void);
111 #else
112 static inline int __init bcma_host_soc_register_driver(void)
113 {
114 	return 0;
115 }
116 static inline void __exit bcma_host_soc_unregister_driver(void)
117 {
118 }
119 #endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */
120 
121 /* driver_pci.c */
122 #ifdef CONFIG_BCMA_DRIVER_PCI
123 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
124 void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
125 void bcma_core_pci_init(struct bcma_drv_pci *pc);
126 void bcma_core_pci_up(struct bcma_drv_pci *pc);
127 void bcma_core_pci_down(struct bcma_drv_pci *pc);
128 #else
129 static inline void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
130 {
131 	WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
132 }
133 static inline void bcma_core_pci_init(struct bcma_drv_pci *pc)
134 {
135 	/* Initialization is required for PCI hosted bus */
136 	WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
137 }
138 #endif
139 
140 /* driver_pcie2.c */
141 #ifdef CONFIG_BCMA_DRIVER_PCI
142 void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
143 void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2);
144 #else
145 static inline void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
146 {
147 	/* Initialization is required for PCI hosted bus */
148 	WARN_ON(pcie2->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
149 }
150 #endif
151 
152 extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
153 
154 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
155 bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
156 void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
157 #else
158 static inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
159 {
160 	return false;
161 }
162 static inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
163 {
164 }
165 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
166 
167 /**************************************************
168  * driver_mips.c
169  **************************************************/
170 
171 #ifdef CONFIG_BCMA_DRIVER_MIPS
172 unsigned int bcma_core_mips_irq(struct bcma_device *dev);
173 void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
174 void bcma_core_mips_init(struct bcma_drv_mips *mcore);
175 #else
176 static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
177 {
178 	return 0;
179 }
180 static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
181 {
182 }
183 static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore)
184 {
185 }
186 #endif
187 
188 /**************************************************
189  * driver_gmac_cmn.c
190  **************************************************/
191 
192 #ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
193 void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
194 #else
195 static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
196 {
197 }
198 #endif
199 
200 #ifdef CONFIG_BCMA_DRIVER_GPIO
201 /* driver_gpio.c */
202 int bcma_gpio_init(struct bcma_drv_cc *cc);
203 int bcma_gpio_unregister(struct bcma_drv_cc *cc);
204 #else
205 static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
206 {
207 	return -ENOTSUPP;
208 }
209 static inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
210 {
211 	return 0;
212 }
213 #endif /* CONFIG_BCMA_DRIVER_GPIO */
214 
215 #endif
216