18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef LINUX_BCMA_PRIVATE_H_
38c2ecf20Sopenharmony_ci#define LINUX_BCMA_PRIVATE_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef pr_fmt
68c2ecf20Sopenharmony_ci#define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
78c2ecf20Sopenharmony_ci#endif
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/bcma/bcma.h>
108c2ecf20Sopenharmony_ci#include <linux/delay.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define bcma_err(bus, fmt, ...) \
138c2ecf20Sopenharmony_ci	dev_err((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
148c2ecf20Sopenharmony_ci#define bcma_warn(bus, fmt, ...) \
158c2ecf20Sopenharmony_ci	dev_warn((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
168c2ecf20Sopenharmony_ci#define bcma_info(bus, fmt, ...) \
178c2ecf20Sopenharmony_ci	dev_info((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
188c2ecf20Sopenharmony_ci#define bcma_debug(bus, fmt, ...) \
198c2ecf20Sopenharmony_ci	dev_dbg((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct bcma_bus;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* main.c */
248c2ecf20Sopenharmony_cibool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
258c2ecf20Sopenharmony_ci		     int timeout);
268c2ecf20Sopenharmony_civoid bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
278c2ecf20Sopenharmony_civoid bcma_init_bus(struct bcma_bus *bus);
288c2ecf20Sopenharmony_civoid bcma_unregister_cores(struct bcma_bus *bus);
298c2ecf20Sopenharmony_ciint bcma_bus_register(struct bcma_bus *bus);
308c2ecf20Sopenharmony_civoid bcma_bus_unregister(struct bcma_bus *bus);
318c2ecf20Sopenharmony_ciint __init bcma_bus_early_register(struct bcma_bus *bus);
328c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
338c2ecf20Sopenharmony_ciint bcma_bus_suspend(struct bcma_bus *bus);
348c2ecf20Sopenharmony_ciint bcma_bus_resume(struct bcma_bus *bus);
358c2ecf20Sopenharmony_ci#endif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* scan.c */
388c2ecf20Sopenharmony_civoid bcma_detect_chip(struct bcma_bus *bus);
398c2ecf20Sopenharmony_ciint bcma_bus_scan(struct bcma_bus *bus);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* sprom.c */
428c2ecf20Sopenharmony_ciint bcma_sprom_get(struct bcma_bus *bus);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* driver_chipcommon.c */
458c2ecf20Sopenharmony_civoid bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
468c2ecf20Sopenharmony_civoid bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
478c2ecf20Sopenharmony_civoid bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
488c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_MIPS
498c2ecf20Sopenharmony_civoid bcma_chipco_serial_init(struct bcma_drv_cc *cc);
508c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_DRIVER_MIPS */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* driver_chipcommon_b.c */
538c2ecf20Sopenharmony_ciint bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
548c2ecf20Sopenharmony_civoid bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* driver_chipcommon_pmu.c */
578c2ecf20Sopenharmony_civoid bcma_pmu_early_init(struct bcma_drv_cc *cc);
588c2ecf20Sopenharmony_civoid bcma_pmu_init(struct bcma_drv_cc *cc);
598c2ecf20Sopenharmony_ciu32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
608c2ecf20Sopenharmony_ciu32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/**************************************************
638c2ecf20Sopenharmony_ci * driver_chipcommon_sflash.c
648c2ecf20Sopenharmony_ci **************************************************/
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_PFLASH
678c2ecf20Sopenharmony_ciextern struct platform_device bcma_pflash_dev;
688c2ecf20Sopenharmony_ciint bcma_pflash_init(struct bcma_drv_cc *cc);
698c2ecf20Sopenharmony_ci#else
708c2ecf20Sopenharmony_cistatic inline int bcma_pflash_init(struct bcma_drv_cc *cc)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	bcma_err(cc->core->bus, "Parallel flash not supported\n");
738c2ecf20Sopenharmony_ci	return 0;
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_PFLASH */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_SFLASH
788c2ecf20Sopenharmony_ci/* driver_chipcommon_sflash.c */
798c2ecf20Sopenharmony_ciint bcma_sflash_init(struct bcma_drv_cc *cc);
808c2ecf20Sopenharmony_ciextern struct platform_device bcma_sflash_dev;
818c2ecf20Sopenharmony_ci#else
828c2ecf20Sopenharmony_cistatic inline int bcma_sflash_init(struct bcma_drv_cc *cc)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	bcma_err(cc->core->bus, "Serial flash not supported\n");
858c2ecf20Sopenharmony_ci	return 0;
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_SFLASH */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_NFLASH
908c2ecf20Sopenharmony_ci/* driver_chipcommon_nflash.c */
918c2ecf20Sopenharmony_ciint bcma_nflash_init(struct bcma_drv_cc *cc);
928c2ecf20Sopenharmony_ciextern struct platform_device bcma_nflash_dev;
938c2ecf20Sopenharmony_ci#else
948c2ecf20Sopenharmony_cistatic inline int bcma_nflash_init(struct bcma_drv_cc *cc)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci	bcma_err(cc->core->bus, "NAND flash not supported\n");
978c2ecf20Sopenharmony_ci	return 0;
988c2ecf20Sopenharmony_ci}
998c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_NFLASH */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_HOST_PCI
1028c2ecf20Sopenharmony_ci/* host_pci.c */
1038c2ecf20Sopenharmony_ciextern int __init bcma_host_pci_init(void);
1048c2ecf20Sopenharmony_ciextern void __exit bcma_host_pci_exit(void);
1058c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_HOST_PCI */
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/* host_soc.c */
1088c2ecf20Sopenharmony_ci#if defined(CONFIG_BCMA_HOST_SOC) && defined(CONFIG_OF)
1098c2ecf20Sopenharmony_ciextern int __init bcma_host_soc_register_driver(void);
1108c2ecf20Sopenharmony_ciextern void __exit bcma_host_soc_unregister_driver(void);
1118c2ecf20Sopenharmony_ci#else
1128c2ecf20Sopenharmony_cistatic inline int __init bcma_host_soc_register_driver(void)
1138c2ecf20Sopenharmony_ci{
1148c2ecf20Sopenharmony_ci	return 0;
1158c2ecf20Sopenharmony_ci}
1168c2ecf20Sopenharmony_cistatic inline void __exit bcma_host_soc_unregister_driver(void)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci}
1198c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* driver_pci.c */
1228c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_PCI
1238c2ecf20Sopenharmony_ciu32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
1248c2ecf20Sopenharmony_civoid bcma_core_pci_early_init(struct bcma_drv_pci *pc);
1258c2ecf20Sopenharmony_civoid bcma_core_pci_init(struct bcma_drv_pci *pc);
1268c2ecf20Sopenharmony_civoid bcma_core_pci_up(struct bcma_drv_pci *pc);
1278c2ecf20Sopenharmony_civoid bcma_core_pci_down(struct bcma_drv_pci *pc);
1288c2ecf20Sopenharmony_ci#else
1298c2ecf20Sopenharmony_cistatic inline void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
1308c2ecf20Sopenharmony_ci{
1318c2ecf20Sopenharmony_ci	WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_cistatic inline void bcma_core_pci_init(struct bcma_drv_pci *pc)
1348c2ecf20Sopenharmony_ci{
1358c2ecf20Sopenharmony_ci	/* Initialization is required for PCI hosted bus */
1368c2ecf20Sopenharmony_ci	WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci#endif
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/* driver_pcie2.c */
1418c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_PCI
1428c2ecf20Sopenharmony_civoid bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
1438c2ecf20Sopenharmony_civoid bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2);
1448c2ecf20Sopenharmony_ci#else
1458c2ecf20Sopenharmony_cistatic inline void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
1468c2ecf20Sopenharmony_ci{
1478c2ecf20Sopenharmony_ci	/* Initialization is required for PCI hosted bus */
1488c2ecf20Sopenharmony_ci	WARN_ON(pcie2->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
1498c2ecf20Sopenharmony_ci}
1508c2ecf20Sopenharmony_ci#endif
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ciextern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
1558c2ecf20Sopenharmony_cibool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
1568c2ecf20Sopenharmony_civoid bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
1578c2ecf20Sopenharmony_ci#else
1588c2ecf20Sopenharmony_cistatic inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	return false;
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_cistatic inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
1638c2ecf20Sopenharmony_ci{
1648c2ecf20Sopenharmony_ci}
1658c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci/**************************************************
1688c2ecf20Sopenharmony_ci * driver_mips.c
1698c2ecf20Sopenharmony_ci **************************************************/
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_MIPS
1728c2ecf20Sopenharmony_ciunsigned int bcma_core_mips_irq(struct bcma_device *dev);
1738c2ecf20Sopenharmony_civoid bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
1748c2ecf20Sopenharmony_civoid bcma_core_mips_init(struct bcma_drv_mips *mcore);
1758c2ecf20Sopenharmony_ci#else
1768c2ecf20Sopenharmony_cistatic inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	return 0;
1798c2ecf20Sopenharmony_ci}
1808c2ecf20Sopenharmony_cistatic inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci}
1838c2ecf20Sopenharmony_cistatic inline void bcma_core_mips_init(struct bcma_drv_mips *mcore)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_ci#endif
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/**************************************************
1898c2ecf20Sopenharmony_ci * driver_gmac_cmn.c
1908c2ecf20Sopenharmony_ci **************************************************/
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
1938c2ecf20Sopenharmony_civoid bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
1948c2ecf20Sopenharmony_ci#else
1958c2ecf20Sopenharmony_cistatic inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
1968c2ecf20Sopenharmony_ci{
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci#endif
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_DRIVER_GPIO
2018c2ecf20Sopenharmony_ci/* driver_gpio.c */
2028c2ecf20Sopenharmony_ciint bcma_gpio_init(struct bcma_drv_cc *cc);
2038c2ecf20Sopenharmony_ciint bcma_gpio_unregister(struct bcma_drv_cc *cc);
2048c2ecf20Sopenharmony_ci#else
2058c2ecf20Sopenharmony_cistatic inline int bcma_gpio_init(struct bcma_drv_cc *cc)
2068c2ecf20Sopenharmony_ci{
2078c2ecf20Sopenharmony_ci	return -ENOTSUPP;
2088c2ecf20Sopenharmony_ci}
2098c2ecf20Sopenharmony_cistatic inline int bcma_gpio_unregister(struct bcma_drv_cc *cc)
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci	return 0;
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci#endif /* CONFIG_BCMA_DRIVER_GPIO */
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#endif
216