linux/include/linux/ssb/ssb.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef LINUX_SSB_H_
#define LINUX_SSB_H_

#include <linux/device.h>
#include <linux/list.h>
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include <linux/gpio/driver.h>
#include <linux/mod_devicetable.h>
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>

#include <linux/ssb/ssb_regs.h>


struct pcmcia_device;
struct ssb_bus;
struct ssb_driver;

struct ssb_sprom_core_pwr_info {};

struct ssb_sprom {};

/* Information about the PCB the circuitry is soldered on. */
struct ssb_boardinfo {};


struct ssb_device;
/* Lowlevel read/write operations on the device MMIO.
 * Internal, don't use that outside of ssb. */
struct ssb_bus_ops {};


/* Core-ID values. */
#define SSB_DEV_CHIPCOMMON
#define SSB_DEV_ILINE20
#define SSB_DEV_SDRAM
#define SSB_DEV_PCI
#define SSB_DEV_MIPS
#define SSB_DEV_ETHERNET
#define SSB_DEV_V90
#define SSB_DEV_USB11_HOSTDEV
#define SSB_DEV_ADSL
#define SSB_DEV_ILINE100
#define SSB_DEV_IPSEC
#define SSB_DEV_PCMCIA
#define SSB_DEV_INTERNAL_MEM
#define SSB_DEV_MEMC_SDRAM
#define SSB_DEV_EXTIF
#define SSB_DEV_80211
#define SSB_DEV_MIPS_3302
#define SSB_DEV_USB11_HOST
#define SSB_DEV_USB11_DEV
#define SSB_DEV_USB20_HOST
#define SSB_DEV_USB20_DEV
#define SSB_DEV_SDIO_HOST
#define SSB_DEV_ROBOSWITCH
#define SSB_DEV_PARA_ATA
#define SSB_DEV_SATA_XORDMA
#define SSB_DEV_ETHERNET_GBIT
#define SSB_DEV_PCIE
#define SSB_DEV_MIMO_PHY
#define SSB_DEV_SRAM_CTRLR
#define SSB_DEV_MINI_MACPHY
#define SSB_DEV_ARM_1176
#define SSB_DEV_ARM_7TDMI
#define SSB_DEV_ARM_CM3

/* Vendor-ID values */
#define SSB_VENDOR_BROADCOM

/* Some kernel subsystems poke with dev->drvdata, so we must use the
 * following ugly workaround to get from struct device to struct ssb_device */
struct __ssb_dev_wrapper {};

struct ssb_device {};

/* Go from struct device to struct ssb_device. */
static inline
struct ssb_device * dev_to_ssb_dev(const struct device *dev)
{}

/* Device specific user data */
static inline
void ssb_set_drvdata(struct ssb_device *dev, void *data)
{}
static inline
void * ssb_get_drvdata(struct ssb_device *dev)
{}

/* Devicetype specific user data. This is per device-type (not per device) */
void ssb_set_devtypedata(struct ssb_device *dev, void *data);
static inline
void * ssb_get_devtypedata(struct ssb_device *dev)
{}


struct ssb_driver {};
#define drv_to_ssb_drv(_drv)

extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
#define ssb_driver_register(drv)

extern void ssb_driver_unregister(struct ssb_driver *drv);




enum ssb_bustype {};

/* board_vendor */
#define SSB_BOARDVENDOR_BCM
#define SSB_BOARDVENDOR_DELL
#define SSB_BOARDVENDOR_HP
/* board_type */
#define SSB_BOARD_BCM94301CB
#define SSB_BOARD_BCM94301MP
#define SSB_BOARD_BU4309
#define SSB_BOARD_BCM94309CB
#define SSB_BOARD_BCM4309MP
#define SSB_BOARD_BU4306
#define SSB_BOARD_BCM94306MP
#define SSB_BOARD_BCM4309G
#define SSB_BOARD_BCM4306CB
#define SSB_BOARD_BCM94306PC
#define SSB_BOARD_BCM94306CBSG
#define SSB_BOARD_PCSG94306
#define SSB_BOARD_BU4704SD
#define SSB_BOARD_BCM94704AGR
#define SSB_BOARD_BCM94308MP
#define SSB_BOARD_BU4318
#define SSB_BOARD_CB4318
#define SSB_BOARD_MPG4318
#define SSB_BOARD_MP4318
#define SSB_BOARD_SD4318
#define SSB_BOARD_BCM94306P
#define SSB_BOARD_BCM94303MP
#define SSB_BOARD_BCM94306MPM
#define SSB_BOARD_BCM94306MPL
#define SSB_BOARD_PC4303
#define SSB_BOARD_BCM94306MPLNA
#define SSB_BOARD_BCM94306MPH
#define SSB_BOARD_BCM94306PCIV
#define SSB_BOARD_BCM94318MPGH
#define SSB_BOARD_BU4311
#define SSB_BOARD_BCM94311MC
#define SSB_BOARD_BCM94311MCAG
/* 4321 boards */
#define SSB_BOARD_BU4321
#define SSB_BOARD_BU4321E
#define SSB_BOARD_MP4321
#define SSB_BOARD_CB2_4321
#define SSB_BOARD_CB2_4321_AG
#define SSB_BOARD_MC4321
/* 4325 boards */
#define SSB_BOARD_BCM94325DEVBU
#define SSB_BOARD_BCM94325BGABU
#define SSB_BOARD_BCM94325SDGWB
#define SSB_BOARD_BCM94325SDGMDL
#define SSB_BOARD_BCM94325SDGMDL2
#define SSB_BOARD_BCM94325SDGMDL3
#define SSB_BOARD_BCM94325SDABGWBA
/* 4322 boards */
#define SSB_BOARD_BCM94322MC
#define SSB_BOARD_BCM94322USB
#define SSB_BOARD_BCM94322HM
#define SSB_BOARD_BCM94322USB2D
/* 4312 boards */
#define SSB_BOARD_BU4312
#define SSB_BOARD_BCM4312MCGSG
/* chip_package */
#define SSB_CHIPPACK_BCM4712S
#define SSB_CHIPPACK_BCM4712M
#define SSB_CHIPPACK_BCM4712L

#include <linux/ssb/ssb_driver_chipcommon.h>
#include <linux/ssb/ssb_driver_mips.h>
#include <linux/ssb/ssb_driver_extif.h>
#include <linux/ssb/ssb_driver_pci.h>

struct ssb_bus {};

enum ssb_quirks {};

/* The initialization-invariants. */
struct ssb_init_invariants {};
/* Type of function to fetch the invariants. */
ssb_invariants_func_t;

/* Register SoC bus. */
extern int ssb_bus_host_soc_register(struct ssb_bus *bus,
				     unsigned long baseaddr);
#ifdef CONFIG_SSB_PCIHOST
extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
				   struct pci_dev *host_pci);
#endif /* CONFIG_SSB_PCIHOST */
#ifdef CONFIG_SSB_PCMCIAHOST
extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
				      struct pcmcia_device *pcmcia_dev,
				      unsigned long baseaddr);
#endif /* CONFIG_SSB_PCMCIAHOST */
#ifdef CONFIG_SSB_SDIOHOST
extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
				    struct sdio_func *sdio_func,
				    unsigned int quirks);
#endif /* CONFIG_SSB_SDIOHOST */


extern void ssb_bus_unregister(struct ssb_bus *bus);

/* Does the device have an SPROM? */
extern bool ssb_is_sprom_available(struct ssb_bus *bus);

/* Set a fallback SPROM.
 * See kdoc at the function definition for complete documentation. */
extern int ssb_arch_register_fallback_sprom(
		int (*sprom_callback)(struct ssb_bus *bus,
		struct ssb_sprom *out));

/* Suspend a SSB bus.
 * Call this from the parent bus suspend routine. */
extern int ssb_bus_suspend(struct ssb_bus *bus);
/* Resume a SSB bus.
 * Call this from the parent bus resume routine. */
extern int ssb_bus_resume(struct ssb_bus *bus);

extern u32 ssb_clockspeed(struct ssb_bus *bus);

/* Is the device enabled in hardware? */
int ssb_device_is_enabled(struct ssb_device *dev);
/* Enable a device and pass device-specific SSB_TMSLOW flags.
 * If no device-specific flags are available, use 0. */
void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
/* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);


/* Device MMIO register read/write functions. */
static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
{}
static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
{}
static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
{}
static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
{}
static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
{}
static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
{}
#ifdef CONFIG_SSB_BLOCKIO
static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
				  size_t count, u16 offset, u8 reg_width)
{}

static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
				   size_t count, u16 offset, u8 reg_width)
{}
#endif /* CONFIG_SSB_BLOCKIO */


/* The SSB DMA API. Use this API for any DMA operation on the device.
 * This API basically is a wrapper that calls the correct DMA API for
 * the host device type the SSB device is attached to. */

/* Translation (routing) bits that need to be ORed to DMA
 * addresses before they are given to a device. */
extern u32 ssb_dma_translation(struct ssb_device *dev);
#define SSB_DMA_TRANSLATION_MASK
#define SSB_DMA_TRANSLATION_SHIFT

#ifdef CONFIG_SSB_PCIHOST
/* PCI-host wrapper driver */
extern int ssb_pcihost_register(struct pci_driver *driver);
static inline void ssb_pcihost_unregister(struct pci_driver *driver)
{}

static inline
void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
{}
#else
static inline void ssb_pcihost_unregister(struct pci_driver *driver)
{
}

static inline
void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
{
}
#endif /* CONFIG_SSB_PCIHOST */


/* If a driver is shutdown or suspended, call this to signal
 * that the bus may be completely powered down. SSB will decide,
 * if it's really time to power down the bus, based on if there
 * are other devices that want to run. */
extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
/* Before initializing and enabling a device, call this to power-up the bus.
 * If you want to allow use of dynamic-power-control, pass the flag.
 * Otherwise static always-on powercontrol will be used. */
extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);

extern void ssb_commit_settings(struct ssb_bus *bus);

/* Various helper functions */
extern u32 ssb_admatch_base(u32 adm);
extern u32 ssb_admatch_size(u32 adm);

/* PCI device mapping and fixup routines.
 * Called from the architecture pcibios init code.
 * These are only available on SSB_EMBEDDED configurations. */
#ifdef CONFIG_SSB_EMBEDDED
int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
#endif /* CONFIG_SSB_EMBEDDED */

#endif /* LINUX_SSB_H_ */