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