18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef LINUX_SSB_PRIVATE_H_
38c2ecf20Sopenharmony_ci#define LINUX_SSB_PRIVATE_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define PFX		"ssb: "
68c2ecf20Sopenharmony_ci#define pr_fmt(fmt)	PFX fmt
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/ssb/ssb.h>
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci#include <linux/bcm47xx_wdt.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* pci.c */
148c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_PCIHOST
158c2ecf20Sopenharmony_ciextern int ssb_pci_switch_core(struct ssb_bus *bus,
168c2ecf20Sopenharmony_ci			       struct ssb_device *dev);
178c2ecf20Sopenharmony_ciextern int ssb_pci_switch_coreidx(struct ssb_bus *bus,
188c2ecf20Sopenharmony_ci				  u8 coreidx);
198c2ecf20Sopenharmony_ciextern int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
208c2ecf20Sopenharmony_ci			int turn_on);
218c2ecf20Sopenharmony_ciextern int ssb_pci_get_invariants(struct ssb_bus *bus,
228c2ecf20Sopenharmony_ci				  struct ssb_init_invariants *iv);
238c2ecf20Sopenharmony_ciextern void ssb_pci_exit(struct ssb_bus *bus);
248c2ecf20Sopenharmony_ciextern int ssb_pci_init(struct ssb_bus *bus);
258c2ecf20Sopenharmony_ciextern const struct ssb_bus_ops ssb_pci_ops;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_PCIHOST */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic inline int ssb_pci_switch_core(struct ssb_bus *bus,
308c2ecf20Sopenharmony_ci				      struct ssb_device *dev)
318c2ecf20Sopenharmony_ci{
328c2ecf20Sopenharmony_ci	return 0;
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_cistatic inline int ssb_pci_switch_coreidx(struct ssb_bus *bus,
358c2ecf20Sopenharmony_ci					 u8 coreidx)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	return 0;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_cistatic inline int ssb_pci_xtal(struct ssb_bus *bus, u32 what,
408c2ecf20Sopenharmony_ci			       int turn_on)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	return 0;
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_cistatic inline void ssb_pci_exit(struct ssb_bus *bus)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci}
478c2ecf20Sopenharmony_cistatic inline int ssb_pci_init(struct ssb_bus *bus)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	return 0;
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_PCIHOST */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* pcmcia.c */
558c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_PCMCIAHOST
568c2ecf20Sopenharmony_ciextern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
578c2ecf20Sopenharmony_ci				     u8 coreidx);
588c2ecf20Sopenharmony_ciextern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
598c2ecf20Sopenharmony_ci				     u8 seg);
608c2ecf20Sopenharmony_ciextern int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
618c2ecf20Sopenharmony_ci				     struct ssb_init_invariants *iv);
628c2ecf20Sopenharmony_ciextern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
638c2ecf20Sopenharmony_ciextern void ssb_pcmcia_exit(struct ssb_bus *bus);
648c2ecf20Sopenharmony_ciextern int ssb_pcmcia_init(struct ssb_bus *bus);
658c2ecf20Sopenharmony_ciextern int ssb_host_pcmcia_init(void);
668c2ecf20Sopenharmony_ciextern void ssb_host_pcmcia_exit(void);
678c2ecf20Sopenharmony_ciextern const struct ssb_bus_ops ssb_pcmcia_ops;
688c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_PCMCIAHOST */
698c2ecf20Sopenharmony_cistatic inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
708c2ecf20Sopenharmony_ci					    u8 coreidx)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	return 0;
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_cistatic inline int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
758c2ecf20Sopenharmony_ci					    u8 seg)
768c2ecf20Sopenharmony_ci{
778c2ecf20Sopenharmony_ci	return 0;
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_cistatic inline int ssb_pcmcia_hardware_setup(struct ssb_bus *bus)
808c2ecf20Sopenharmony_ci{
818c2ecf20Sopenharmony_ci	return 0;
828c2ecf20Sopenharmony_ci}
838c2ecf20Sopenharmony_cistatic inline void ssb_pcmcia_exit(struct ssb_bus *bus)
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci}
868c2ecf20Sopenharmony_cistatic inline int ssb_pcmcia_init(struct ssb_bus *bus)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	return 0;
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_cistatic inline int ssb_host_pcmcia_init(void)
918c2ecf20Sopenharmony_ci{
928c2ecf20Sopenharmony_ci	return 0;
938c2ecf20Sopenharmony_ci}
948c2ecf20Sopenharmony_cistatic inline void ssb_host_pcmcia_exit(void)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_PCMCIAHOST */
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/* sdio.c */
1008c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_SDIOHOST
1018c2ecf20Sopenharmony_ciextern int ssb_sdio_get_invariants(struct ssb_bus *bus,
1028c2ecf20Sopenharmony_ci				     struct ssb_init_invariants *iv);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciextern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
1058c2ecf20Sopenharmony_ciextern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
1068c2ecf20Sopenharmony_ciextern void ssb_sdio_exit(struct ssb_bus *bus);
1078c2ecf20Sopenharmony_ciextern int ssb_sdio_init(struct ssb_bus *bus);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciextern const struct ssb_bus_ops ssb_sdio_ops;
1108c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_SDIOHOST */
1118c2ecf20Sopenharmony_cistatic inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
1128c2ecf20Sopenharmony_ci{
1138c2ecf20Sopenharmony_ci	return 0;
1148c2ecf20Sopenharmony_ci}
1158c2ecf20Sopenharmony_cistatic inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
1168c2ecf20Sopenharmony_ci{
1178c2ecf20Sopenharmony_ci	return 0;
1188c2ecf20Sopenharmony_ci}
1198c2ecf20Sopenharmony_cistatic inline void ssb_sdio_exit(struct ssb_bus *bus)
1208c2ecf20Sopenharmony_ci{
1218c2ecf20Sopenharmony_ci}
1228c2ecf20Sopenharmony_cistatic inline int ssb_sdio_init(struct ssb_bus *bus)
1238c2ecf20Sopenharmony_ci{
1248c2ecf20Sopenharmony_ci	return 0;
1258c2ecf20Sopenharmony_ci}
1268c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_SDIOHOST */
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/**************************************************
1298c2ecf20Sopenharmony_ci * host_soc.c
1308c2ecf20Sopenharmony_ci **************************************************/
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_HOST_SOC
1338c2ecf20Sopenharmony_ciextern const struct ssb_bus_ops ssb_host_soc_ops;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ciextern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
1368c2ecf20Sopenharmony_ci				       struct ssb_init_invariants *iv);
1378c2ecf20Sopenharmony_ci#endif
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* scan.c */
1408c2ecf20Sopenharmony_ciextern const char *ssb_core_name(u16 coreid);
1418c2ecf20Sopenharmony_ciextern int ssb_bus_scan(struct ssb_bus *bus,
1428c2ecf20Sopenharmony_ci			unsigned long baseaddr);
1438c2ecf20Sopenharmony_ciextern void ssb_iounmap(struct ssb_bus *ssb);
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci/* sprom.c */
1478c2ecf20Sopenharmony_ciextern
1488c2ecf20Sopenharmony_cissize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,
1498c2ecf20Sopenharmony_ci			    int (*sprom_read)(struct ssb_bus *bus, u16 *sprom));
1508c2ecf20Sopenharmony_ciextern
1518c2ecf20Sopenharmony_cissize_t ssb_attr_sprom_store(struct ssb_bus *bus,
1528c2ecf20Sopenharmony_ci			     const char *buf, size_t count,
1538c2ecf20Sopenharmony_ci			     int (*sprom_check_crc)(const u16 *sprom, size_t size),
1548c2ecf20Sopenharmony_ci			     int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
1558c2ecf20Sopenharmony_ciextern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus,
1568c2ecf20Sopenharmony_ci					struct ssb_sprom *out);
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/* core.c */
1608c2ecf20Sopenharmony_ciextern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
1618c2ecf20Sopenharmony_ciextern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
1628c2ecf20Sopenharmony_ciint ssb_for_each_bus_call(unsigned long data,
1638c2ecf20Sopenharmony_ci			  int (*func)(struct ssb_bus *bus, unsigned long data));
1648c2ecf20Sopenharmony_ciextern struct ssb_bus *ssb_pcmcia_dev_to_bus(struct pcmcia_device *pdev);
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistruct ssb_freeze_context {
1678c2ecf20Sopenharmony_ci	/* Pointer to the bus */
1688c2ecf20Sopenharmony_ci	struct ssb_bus *bus;
1698c2ecf20Sopenharmony_ci	/* Boolean list to indicate whether a device is frozen on this bus. */
1708c2ecf20Sopenharmony_ci	bool device_frozen[SSB_MAX_NR_CORES];
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ciextern int ssb_devices_freeze(struct ssb_bus *bus, struct ssb_freeze_context *ctx);
1738c2ecf20Sopenharmony_ciextern int ssb_devices_thaw(struct ssb_freeze_context *ctx);
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/* b43_pci_bridge.c */
1788c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_B43_PCI_BRIDGE
1798c2ecf20Sopenharmony_ciextern int __init b43_pci_ssb_bridge_init(void);
1808c2ecf20Sopenharmony_ciextern void __exit b43_pci_ssb_bridge_exit(void);
1818c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_B43_PCI_BRIDGE */
1828c2ecf20Sopenharmony_cistatic inline int b43_pci_ssb_bridge_init(void)
1838c2ecf20Sopenharmony_ci{
1848c2ecf20Sopenharmony_ci	return 0;
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_cistatic inline void b43_pci_ssb_bridge_exit(void)
1878c2ecf20Sopenharmony_ci{
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/* driver_chipcommon_pmu.c */
1928c2ecf20Sopenharmony_ciextern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
1938c2ecf20Sopenharmony_ciextern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
1948c2ecf20Sopenharmony_ciextern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ciextern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
1978c2ecf20Sopenharmony_ci					     u32 ticks);
1988c2ecf20Sopenharmony_ciextern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* driver_chipcommon_sflash.c */
2018c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_SFLASH
2028c2ecf20Sopenharmony_ciint ssb_sflash_init(struct ssb_chipcommon *cc);
2038c2ecf20Sopenharmony_ci#else
2048c2ecf20Sopenharmony_cistatic inline int ssb_sflash_init(struct ssb_chipcommon *cc)
2058c2ecf20Sopenharmony_ci{
2068c2ecf20Sopenharmony_ci	pr_err("Serial flash not supported\n");
2078c2ecf20Sopenharmony_ci	return 0;
2088c2ecf20Sopenharmony_ci}
2098c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_SFLASH */
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_DRIVER_MIPS
2128c2ecf20Sopenharmony_ciextern struct platform_device ssb_pflash_dev;
2138c2ecf20Sopenharmony_ci#endif
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_SFLASH
2168c2ecf20Sopenharmony_ciextern struct platform_device ssb_sflash_dev;
2178c2ecf20Sopenharmony_ci#endif
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_DRIVER_EXTIF
2208c2ecf20Sopenharmony_ciextern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
2218c2ecf20Sopenharmony_ciextern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
2228c2ecf20Sopenharmony_ci#else
2238c2ecf20Sopenharmony_cistatic inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
2248c2ecf20Sopenharmony_ci						   u32 ticks)
2258c2ecf20Sopenharmony_ci{
2268c2ecf20Sopenharmony_ci	return 0;
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_cistatic inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
2298c2ecf20Sopenharmony_ci						  u32 ms)
2308c2ecf20Sopenharmony_ci{
2318c2ecf20Sopenharmony_ci	return 0;
2328c2ecf20Sopenharmony_ci}
2338c2ecf20Sopenharmony_ci#endif
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_EMBEDDED
2368c2ecf20Sopenharmony_ciextern int ssb_watchdog_register(struct ssb_bus *bus);
2378c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_EMBEDDED */
2388c2ecf20Sopenharmony_cistatic inline int ssb_watchdog_register(struct ssb_bus *bus)
2398c2ecf20Sopenharmony_ci{
2408c2ecf20Sopenharmony_ci	return 0;
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_EMBEDDED */
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_DRIVER_EXTIF
2458c2ecf20Sopenharmony_ciextern void ssb_extif_init(struct ssb_extif *extif);
2468c2ecf20Sopenharmony_ci#else
2478c2ecf20Sopenharmony_cistatic inline void ssb_extif_init(struct ssb_extif *extif)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci}
2508c2ecf20Sopenharmony_ci#endif
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci#ifdef CONFIG_SSB_DRIVER_GPIO
2538c2ecf20Sopenharmony_ciextern int ssb_gpio_init(struct ssb_bus *bus);
2548c2ecf20Sopenharmony_ciextern int ssb_gpio_unregister(struct ssb_bus *bus);
2558c2ecf20Sopenharmony_ci#else /* CONFIG_SSB_DRIVER_GPIO */
2568c2ecf20Sopenharmony_cistatic inline int ssb_gpio_init(struct ssb_bus *bus)
2578c2ecf20Sopenharmony_ci{
2588c2ecf20Sopenharmony_ci	return -ENOTSUPP;
2598c2ecf20Sopenharmony_ci}
2608c2ecf20Sopenharmony_cistatic inline int ssb_gpio_unregister(struct ssb_bus *bus)
2618c2ecf20Sopenharmony_ci{
2628c2ecf20Sopenharmony_ci	return 0;
2638c2ecf20Sopenharmony_ci}
2648c2ecf20Sopenharmony_ci#endif /* CONFIG_SSB_DRIVER_GPIO */
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci#endif /* LINUX_SSB_PRIVATE_H_ */
267