Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 2 | #ifndef LINUX_SSB_PRIVATE_H_ |
| 3 | #define LINUX_SSB_PRIVATE_H_ |
| 4 | |
| 5 | #include <linux/ssb/ssb.h> |
| 6 | #include <linux/types.h> |
Hauke Mehrtens | 7ffbffe | 2012-12-05 18:46:05 +0100 | [diff] [blame] | 7 | #include <linux/bcm47xx_wdt.h> |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 8 | |
| 9 | |
| 10 | #define PFX "ssb: " |
| 11 | |
| 12 | #ifdef CONFIG_SSB_SILENT |
Joe Perches | 33a606a | 2013-02-20 12:16:13 -0800 | [diff] [blame] | 13 | # define ssb_printk(fmt, ...) \ |
| 14 | do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 15 | #else |
Joe Perches | 33a606a | 2013-02-20 12:16:13 -0800 | [diff] [blame] | 16 | # define ssb_printk(fmt, ...) \ |
| 17 | printk(fmt, ##__VA_ARGS__) |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 18 | #endif /* CONFIG_SSB_SILENT */ |
| 19 | |
Joe Perches | 33a606a | 2013-02-20 12:16:13 -0800 | [diff] [blame] | 20 | #define ssb_emerg(fmt, ...) ssb_printk(KERN_EMERG PFX fmt, ##__VA_ARGS__) |
| 21 | #define ssb_err(fmt, ...) ssb_printk(KERN_ERR PFX fmt, ##__VA_ARGS__) |
| 22 | #define ssb_warn(fmt, ...) ssb_printk(KERN_WARNING PFX fmt, ##__VA_ARGS__) |
| 23 | #define ssb_notice(fmt, ...) ssb_printk(KERN_NOTICE PFX fmt, ##__VA_ARGS__) |
| 24 | #define ssb_info(fmt, ...) ssb_printk(KERN_INFO PFX fmt, ##__VA_ARGS__) |
| 25 | #define ssb_cont(fmt, ...) ssb_printk(KERN_CONT fmt, ##__VA_ARGS__) |
| 26 | |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 27 | /* dprintk: Debugging printk; vanishes for non-debug compilation */ |
| 28 | #ifdef CONFIG_SSB_DEBUG |
Joe Perches | 33a606a | 2013-02-20 12:16:13 -0800 | [diff] [blame] | 29 | # define ssb_dbg(fmt, ...) \ |
| 30 | ssb_printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__) |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 31 | #else |
Joe Perches | 33a606a | 2013-02-20 12:16:13 -0800 | [diff] [blame] | 32 | # define ssb_dbg(fmt, ...) \ |
| 33 | do { if (0) printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__); } while (0) |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 34 | #endif |
| 35 | |
| 36 | #ifdef CONFIG_SSB_DEBUG |
| 37 | # define SSB_WARN_ON(x) WARN_ON(x) |
| 38 | # define SSB_BUG_ON(x) BUG_ON(x) |
| 39 | #else |
| 40 | static inline int __ssb_do_nothing(int x) { return x; } |
| 41 | # define SSB_WARN_ON(x) __ssb_do_nothing(unlikely(!!(x))) |
| 42 | # define SSB_BUG_ON(x) __ssb_do_nothing(unlikely(!!(x))) |
| 43 | #endif |
| 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_get_invariants(struct ssb_bus *bus, |
| 55 | struct ssb_init_invariants *iv); |
| 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 void ssb_pci_exit(struct ssb_bus *bus) |
| 78 | { |
| 79 | } |
| 80 | static inline int ssb_pci_init(struct ssb_bus *bus) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
| 84 | #endif /* CONFIG_SSB_PCIHOST */ |
| 85 | |
| 86 | |
| 87 | /* pcmcia.c */ |
| 88 | #ifdef CONFIG_SSB_PCMCIAHOST |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 89 | extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus, |
| 90 | u8 coreidx); |
| 91 | extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus, |
| 92 | u8 seg); |
| 93 | extern int ssb_pcmcia_get_invariants(struct ssb_bus *bus, |
| 94 | struct ssb_init_invariants *iv); |
Michael Buesch | 8fe2b65 | 2008-03-30 00:10:50 +0100 | [diff] [blame] | 95 | extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus); |
Michael Buesch | e7ec2e3 | 2008-03-10 17:26:32 +0100 | [diff] [blame] | 96 | extern void ssb_pcmcia_exit(struct ssb_bus *bus); |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 97 | extern int ssb_pcmcia_init(struct ssb_bus *bus); |
Rafał Miłecki | 399500da | 2015-10-15 07:23:25 +0200 | [diff] [blame] | 98 | extern int ssb_host_pcmcia_init(void); |
| 99 | extern void ssb_host_pcmcia_exit(void); |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 100 | extern const struct ssb_bus_ops ssb_pcmcia_ops; |
| 101 | #else /* CONFIG_SSB_PCMCIAHOST */ |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 102 | static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus, |
| 103 | u8 coreidx) |
| 104 | { |
| 105 | return 0; |
| 106 | } |
| 107 | static inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus, |
| 108 | u8 seg) |
| 109 | { |
| 110 | return 0; |
| 111 | } |
Michael Buesch | 8fe2b65 | 2008-03-30 00:10:50 +0100 | [diff] [blame] | 112 | static inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus) |
| 113 | { |
| 114 | return 0; |
| 115 | } |
Michael Buesch | e7ec2e3 | 2008-03-10 17:26:32 +0100 | [diff] [blame] | 116 | static inline void ssb_pcmcia_exit(struct ssb_bus *bus) |
| 117 | { |
| 118 | } |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 119 | static inline int ssb_pcmcia_init(struct ssb_bus *bus) |
| 120 | { |
| 121 | return 0; |
| 122 | } |
Rafał Miłecki | 399500da | 2015-10-15 07:23:25 +0200 | [diff] [blame] | 123 | static inline int ssb_host_pcmcia_init(void) |
| 124 | { |
| 125 | return 0; |
| 126 | } |
| 127 | static inline void ssb_host_pcmcia_exit(void) |
| 128 | { |
| 129 | } |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 130 | #endif /* CONFIG_SSB_PCMCIAHOST */ |
| 131 | |
Albert Herranz | 24ea602 | 2009-09-08 19:30:12 +0200 | [diff] [blame] | 132 | /* sdio.c */ |
| 133 | #ifdef CONFIG_SSB_SDIOHOST |
| 134 | extern int ssb_sdio_get_invariants(struct ssb_bus *bus, |
| 135 | struct ssb_init_invariants *iv); |
| 136 | |
| 137 | extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset); |
Albert Herranz | 24ea602 | 2009-09-08 19:30:12 +0200 | [diff] [blame] | 138 | extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx); |
Albert Herranz | 24ea602 | 2009-09-08 19:30:12 +0200 | [diff] [blame] | 139 | extern void ssb_sdio_exit(struct ssb_bus *bus); |
| 140 | extern int ssb_sdio_init(struct ssb_bus *bus); |
| 141 | |
| 142 | extern const struct ssb_bus_ops ssb_sdio_ops; |
| 143 | #else /* CONFIG_SSB_SDIOHOST */ |
| 144 | static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset) |
| 145 | { |
| 146 | return 0; |
| 147 | } |
Albert Herranz | 24ea602 | 2009-09-08 19:30:12 +0200 | [diff] [blame] | 148 | static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx) |
| 149 | { |
| 150 | return 0; |
| 151 | } |
Albert Herranz | 24ea602 | 2009-09-08 19:30:12 +0200 | [diff] [blame] | 152 | static inline void ssb_sdio_exit(struct ssb_bus *bus) |
| 153 | { |
| 154 | } |
| 155 | static inline int ssb_sdio_init(struct ssb_bus *bus) |
| 156 | { |
| 157 | return 0; |
| 158 | } |
| 159 | #endif /* CONFIG_SSB_SDIOHOST */ |
| 160 | |
Rafał Miłecki | 830c7df | 2015-10-25 19:32:42 +0100 | [diff] [blame] | 161 | /************************************************** |
| 162 | * host_soc.c |
| 163 | **************************************************/ |
| 164 | |
Rafał Miłecki | 845da6e | 2015-10-25 19:32:43 +0100 | [diff] [blame] | 165 | #ifdef CONFIG_SSB_HOST_SOC |
Rafał Miłecki | 830c7df | 2015-10-25 19:32:42 +0100 | [diff] [blame] | 166 | extern const struct ssb_bus_ops ssb_host_soc_ops; |
Rafał Miłecki | 541c9a8 | 2015-12-09 23:36:51 +0100 | [diff] [blame] | 167 | |
| 168 | extern int ssb_host_soc_get_invariants(struct ssb_bus *bus, |
| 169 | struct ssb_init_invariants *iv); |
Rafał Miłecki | 845da6e | 2015-10-25 19:32:43 +0100 | [diff] [blame] | 170 | #endif |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 171 | |
| 172 | /* scan.c */ |
| 173 | extern const char *ssb_core_name(u16 coreid); |
| 174 | extern int ssb_bus_scan(struct ssb_bus *bus, |
| 175 | unsigned long baseaddr); |
| 176 | extern void ssb_iounmap(struct ssb_bus *ssb); |
| 177 | |
| 178 | |
Michael Buesch | e7ec2e3 | 2008-03-10 17:26:32 +0100 | [diff] [blame] | 179 | /* sprom.c */ |
| 180 | extern |
| 181 | ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf, |
| 182 | int (*sprom_read)(struct ssb_bus *bus, u16 *sprom)); |
| 183 | extern |
| 184 | ssize_t ssb_attr_sprom_store(struct ssb_bus *bus, |
| 185 | const char *buf, size_t count, |
| 186 | int (*sprom_check_crc)(const u16 *sprom, size_t size), |
| 187 | int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom)); |
Hauke Mehrtens | b3ae52b | 2011-05-10 23:31:30 +0200 | [diff] [blame] | 188 | extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, |
| 189 | struct ssb_sprom *out); |
Michael Buesch | e7ec2e3 | 2008-03-10 17:26:32 +0100 | [diff] [blame] | 190 | |
| 191 | |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 192 | /* core.c */ |
| 193 | extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m); |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 194 | extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev); |
Michael Buesch | aab547c | 2008-02-29 11:36:12 +0100 | [diff] [blame] | 195 | int ssb_for_each_bus_call(unsigned long data, |
| 196 | int (*func)(struct ssb_bus *bus, unsigned long data)); |
Michael Buesch | e7ec2e3 | 2008-03-10 17:26:32 +0100 | [diff] [blame] | 197 | extern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev); |
| 198 | |
Michael Buesch | 3ba6018 | 2009-11-23 20:12:13 +0100 | [diff] [blame] | 199 | struct ssb_freeze_context { |
| 200 | /* Pointer to the bus */ |
| 201 | struct ssb_bus *bus; |
| 202 | /* Boolean list to indicate whether a device is frozen on this bus. */ |
| 203 | bool device_frozen[SSB_MAX_NR_CORES]; |
| 204 | }; |
| 205 | extern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx); |
| 206 | extern int ssb_devices_thaw(struct ssb_freeze_context *ctx); |
| 207 | |
| 208 | |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 209 | |
| 210 | /* b43_pci_bridge.c */ |
Alexey Zaytsev | c708453 | 2008-02-23 12:59:26 +0300 | [diff] [blame] | 211 | #ifdef CONFIG_SSB_B43_PCI_BRIDGE |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 212 | extern int __init b43_pci_ssb_bridge_init(void); |
| 213 | extern void __exit b43_pci_ssb_bridge_exit(void); |
Hauke Mehrtens | 0052b8b | 2010-02-13 18:10:54 +0100 | [diff] [blame] | 214 | #else /* CONFIG_SSB_B43_PCI_BRIDGE */ |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 215 | static inline int b43_pci_ssb_bridge_init(void) |
| 216 | { |
| 217 | return 0; |
| 218 | } |
| 219 | static inline void b43_pci_ssb_bridge_exit(void) |
| 220 | { |
| 221 | } |
Hauke Mehrtens | 0052b8b | 2010-02-13 18:10:54 +0100 | [diff] [blame] | 222 | #endif /* CONFIG_SSB_B43_PCI_BRIDGE */ |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 223 | |
Hauke Mehrtens | d486a5b | 2012-02-01 00:13:56 +0100 | [diff] [blame] | 224 | /* driver_chipcommon_pmu.c */ |
| 225 | extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc); |
| 226 | extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc); |
Hauke Mehrtens | f924e1e | 2012-12-05 18:46:03 +0100 | [diff] [blame] | 227 | extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc); |
Hauke Mehrtens | d486a5b | 2012-02-01 00:13:56 +0100 | [diff] [blame] | 228 | |
Hauke Mehrtens | 7ffbffe | 2012-12-05 18:46:05 +0100 | [diff] [blame] | 229 | extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, |
| 230 | u32 ticks); |
| 231 | extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); |
| 232 | |
Rafał Miłecki | 72a525c | 2013-01-06 21:48:50 +0100 | [diff] [blame] | 233 | /* driver_chipcommon_sflash.c */ |
| 234 | #ifdef CONFIG_SSB_SFLASH |
| 235 | int ssb_sflash_init(struct ssb_chipcommon *cc); |
| 236 | #else |
| 237 | static inline int ssb_sflash_init(struct ssb_chipcommon *cc) |
| 238 | { |
| 239 | pr_err("Serial flash not supported\n"); |
| 240 | return 0; |
| 241 | } |
| 242 | #endif /* CONFIG_SSB_SFLASH */ |
| 243 | |
Rafał Miłecki | c7a4a9e | 2013-01-25 11:36:26 +0100 | [diff] [blame] | 244 | #ifdef CONFIG_SSB_DRIVER_MIPS |
| 245 | extern struct platform_device ssb_pflash_dev; |
| 246 | #endif |
| 247 | |
Rafał Miłecki | 7b5d604 | 2013-06-18 07:33:40 +0200 | [diff] [blame] | 248 | #ifdef CONFIG_SSB_SFLASH |
| 249 | extern struct platform_device ssb_sflash_dev; |
| 250 | #endif |
| 251 | |
Hauke Mehrtens | 9f640a6 | 2012-12-05 18:46:07 +0100 | [diff] [blame] | 252 | #ifdef CONFIG_SSB_DRIVER_EXTIF |
| 253 | extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks); |
| 254 | extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); |
| 255 | #else |
| 256 | static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, |
| 257 | u32 ticks) |
| 258 | { |
| 259 | return 0; |
| 260 | } |
| 261 | static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, |
| 262 | u32 ms) |
| 263 | { |
| 264 | return 0; |
| 265 | } |
| 266 | #endif |
Hauke Mehrtens | bde327e | 2012-12-05 18:46:08 +0100 | [diff] [blame] | 267 | |
| 268 | #ifdef CONFIG_SSB_EMBEDDED |
| 269 | extern int ssb_watchdog_register(struct ssb_bus *bus); |
| 270 | #else /* CONFIG_SSB_EMBEDDED */ |
| 271 | static inline int ssb_watchdog_register(struct ssb_bus *bus) |
| 272 | { |
| 273 | return 0; |
| 274 | } |
| 275 | #endif /* CONFIG_SSB_EMBEDDED */ |
| 276 | |
Hauke Mehrtens | 394bc7e | 2012-11-20 22:24:32 +0000 | [diff] [blame] | 277 | #ifdef CONFIG_SSB_DRIVER_EXTIF |
| 278 | extern void ssb_extif_init(struct ssb_extif *extif); |
| 279 | #else |
| 280 | static inline void ssb_extif_init(struct ssb_extif *extif) |
| 281 | { |
| 282 | } |
| 283 | #endif |
| 284 | |
Hauke Mehrtens | ec43b08 | 2012-11-20 22:24:33 +0000 | [diff] [blame] | 285 | #ifdef CONFIG_SSB_DRIVER_GPIO |
| 286 | extern int ssb_gpio_init(struct ssb_bus *bus); |
Hauke Mehrtens | 600485e | 2013-02-03 23:25:34 +0100 | [diff] [blame] | 287 | extern int ssb_gpio_unregister(struct ssb_bus *bus); |
Hauke Mehrtens | ec43b08 | 2012-11-20 22:24:33 +0000 | [diff] [blame] | 288 | #else /* CONFIG_SSB_DRIVER_GPIO */ |
| 289 | static inline int ssb_gpio_init(struct ssb_bus *bus) |
| 290 | { |
| 291 | return -ENOTSUPP; |
| 292 | } |
Hauke Mehrtens | 600485e | 2013-02-03 23:25:34 +0100 | [diff] [blame] | 293 | static inline int ssb_gpio_unregister(struct ssb_bus *bus) |
| 294 | { |
| 295 | return 0; |
| 296 | } |
Hauke Mehrtens | ec43b08 | 2012-11-20 22:24:33 +0000 | [diff] [blame] | 297 | #endif /* CONFIG_SSB_DRIVER_GPIO */ |
| 298 | |
Michael Buesch | 61e115a | 2007-09-18 15:12:50 -0400 | [diff] [blame] | 299 | #endif /* LINUX_SSB_PRIVATE_H_ */ |