161e115a5SMichael Buesch #ifndef LINUX_SSB_H_ 261e115a5SMichael Buesch #define LINUX_SSB_H_ 361e115a5SMichael Buesch 461e115a5SMichael Buesch #include <linux/device.h> 561e115a5SMichael Buesch #include <linux/list.h> 661e115a5SMichael Buesch #include <linux/types.h> 761e115a5SMichael Buesch #include <linux/spinlock.h> 861e115a5SMichael Buesch #include <linux/pci.h> 961e115a5SMichael Buesch #include <linux/mod_devicetable.h> 109c0c7a42SMichael Buesch #include <linux/dma-mapping.h> 1161e115a5SMichael Buesch 1261e115a5SMichael Buesch #include <linux/ssb/ssb_regs.h> 1361e115a5SMichael Buesch 1461e115a5SMichael Buesch 1561e115a5SMichael Buesch struct pcmcia_device; 1661e115a5SMichael Buesch struct ssb_bus; 1761e115a5SMichael Buesch struct ssb_driver; 1861e115a5SMichael Buesch 1961e115a5SMichael Buesch struct ssb_sprom { 2061e115a5SMichael Buesch u8 revision; 21ac82fab4SLarry Finger u8 il0mac[6]; /* MAC address for 802.11b/g */ 22ac82fab4SLarry Finger u8 et0mac[6]; /* MAC address for Ethernet */ 23ac82fab4SLarry Finger u8 et1mac[6]; /* MAC address for 802.11a */ 24ac82fab4SLarry Finger u8 et0phyaddr; /* MII address for enet0 */ 25ac82fab4SLarry Finger u8 et1phyaddr; /* MII address for enet1 */ 26e861b98dSMichael Buesch u8 et0mdcport; /* MDIO for enet0 */ 27e861b98dSMichael Buesch u8 et1mdcport; /* MDIO for enet1 */ 28*e2d646ceSRafał Miłecki u16 board_rev; /* Board revision number from SPROM. */ 29ac82fab4SLarry Finger u8 country_code; /* Country Code */ 3009779adeSRafał Miłecki u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */ 3109779adeSRafał Miłecki u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */ 32f679056bSGábor Stefanik u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */ 33f679056bSGábor Stefanik u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */ 34ac82fab4SLarry Finger u16 pa0b0; 35ac82fab4SLarry Finger u16 pa0b1; 36ac82fab4SLarry Finger u16 pa0b2; 37ac82fab4SLarry Finger u16 pa1b0; 38ac82fab4SLarry Finger u16 pa1b1; 39ac82fab4SLarry Finger u16 pa1b2; 40f679056bSGábor Stefanik u16 pa1lob0; 41f679056bSGábor Stefanik u16 pa1lob1; 42f679056bSGábor Stefanik u16 pa1lob2; 43f679056bSGábor Stefanik u16 pa1hib0; 44f679056bSGábor Stefanik u16 pa1hib1; 45f679056bSGábor Stefanik u16 pa1hib2; 46ac82fab4SLarry Finger u8 gpio0; /* GPIO pin 0 */ 47ac82fab4SLarry Finger u8 gpio1; /* GPIO pin 1 */ 48ac82fab4SLarry Finger u8 gpio2; /* GPIO pin 2 */ 49ac82fab4SLarry Finger u8 gpio3; /* GPIO pin 3 */ 50f679056bSGábor Stefanik u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */ 51f679056bSGábor Stefanik u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */ 52f679056bSGábor Stefanik u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */ 53f679056bSGábor Stefanik u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */ 54ac82fab4SLarry Finger u8 itssi_a; /* Idle TSSI Target for A-PHY */ 55ac82fab4SLarry Finger u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */ 56f679056bSGábor Stefanik u8 tri2g; /* 2.4GHz TX isolation */ 57f679056bSGábor Stefanik u8 tri5gl; /* 5.2GHz TX isolation */ 58f679056bSGábor Stefanik u8 tri5g; /* 5.3GHz TX isolation */ 59f679056bSGábor Stefanik u8 tri5gh; /* 5.8GHz TX isolation */ 60172c69a4SRafał Miłecki u8 txpid2g[4]; /* 2GHz TX power index */ 61172c69a4SRafał Miłecki u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */ 62172c69a4SRafał Miłecki u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */ 63172c69a4SRafał Miłecki u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */ 64f679056bSGábor Stefanik u8 rxpo2g; /* 2GHz RX power offset */ 65f679056bSGábor Stefanik u8 rxpo5g; /* 5GHz RX power offset */ 66f679056bSGábor Stefanik u8 rssisav2g; /* 2GHz RSSI params */ 67f679056bSGábor Stefanik u8 rssismc2g; 68f679056bSGábor Stefanik u8 rssismf2g; 69f679056bSGábor Stefanik u8 bxa2g; /* 2GHz BX arch */ 70f679056bSGábor Stefanik u8 rssisav5g; /* 5GHz RSSI params */ 71f679056bSGábor Stefanik u8 rssismc5g; 72f679056bSGábor Stefanik u8 rssismf5g; 73f679056bSGábor Stefanik u8 bxa5g; /* 5GHz BX arch */ 74f679056bSGábor Stefanik u16 cck2gpo; /* CCK power offset */ 75f679056bSGábor Stefanik u32 ofdm2gpo; /* 2.4GHz OFDM power offset */ 76f679056bSGábor Stefanik u32 ofdm5glpo; /* 5.2GHz OFDM power offset */ 77f679056bSGábor Stefanik u32 ofdm5gpo; /* 5.3GHz OFDM power offset */ 78f679056bSGábor Stefanik u32 ofdm5ghpo; /* 5.8GHz OFDM power offset */ 79f679056bSGábor Stefanik u16 boardflags_lo; /* Board flags (bits 0-15) */ 80f679056bSGábor Stefanik u16 boardflags_hi; /* Board flags (bits 16-31) */ 81f679056bSGábor Stefanik u16 boardflags2_lo; /* Board flags (bits 32-47) */ 82f679056bSGábor Stefanik u16 boardflags2_hi; /* Board flags (bits 48-63) */ 83f679056bSGábor Stefanik /* TODO store board flags in a single u64 */ 84e861b98dSMichael Buesch 85e861b98dSMichael Buesch /* Antenna gain values for up to 4 antennas 86e861b98dSMichael Buesch * on each band. Values in dBm/4 (Q5.2). Negative gain means the 87e861b98dSMichael Buesch * loss in the connectors is bigger than the gain. */ 88e861b98dSMichael Buesch struct { 89e861b98dSMichael Buesch struct { 90e861b98dSMichael Buesch s8 a0, a1, a2, a3; 91e861b98dSMichael Buesch } ghz24; /* 2.4GHz band */ 92e861b98dSMichael Buesch struct { 93e861b98dSMichael Buesch s8 a0, a1, a2, a3; 94e861b98dSMichael Buesch } ghz5; /* 5GHz band */ 95e861b98dSMichael Buesch } antenna_gain; 96ac82fab4SLarry Finger 97f679056bSGábor Stefanik /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */ 9861e115a5SMichael Buesch }; 9961e115a5SMichael Buesch 10061e115a5SMichael Buesch /* Information about the PCB the circuitry is soldered on. */ 10161e115a5SMichael Buesch struct ssb_boardinfo { 10261e115a5SMichael Buesch u16 vendor; 10361e115a5SMichael Buesch u16 type; 104304e21bbSSergei Shtylyov u8 rev; 10561e115a5SMichael Buesch }; 10661e115a5SMichael Buesch 10761e115a5SMichael Buesch 10861e115a5SMichael Buesch struct ssb_device; 10961e115a5SMichael Buesch /* Lowlevel read/write operations on the device MMIO. 11061e115a5SMichael Buesch * Internal, don't use that outside of ssb. */ 11161e115a5SMichael Buesch struct ssb_bus_ops { 112ffc7689dSMichael Buesch u8 (*read8)(struct ssb_device *dev, u16 offset); 11361e115a5SMichael Buesch u16 (*read16)(struct ssb_device *dev, u16 offset); 11461e115a5SMichael Buesch u32 (*read32)(struct ssb_device *dev, u16 offset); 115ffc7689dSMichael Buesch void (*write8)(struct ssb_device *dev, u16 offset, u8 value); 11661e115a5SMichael Buesch void (*write16)(struct ssb_device *dev, u16 offset, u16 value); 11761e115a5SMichael Buesch void (*write32)(struct ssb_device *dev, u16 offset, u32 value); 118d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO 119d625a29bSMichael Buesch void (*block_read)(struct ssb_device *dev, void *buffer, 120d625a29bSMichael Buesch size_t count, u16 offset, u8 reg_width); 121d625a29bSMichael Buesch void (*block_write)(struct ssb_device *dev, const void *buffer, 122d625a29bSMichael Buesch size_t count, u16 offset, u8 reg_width); 123d625a29bSMichael Buesch #endif 12461e115a5SMichael Buesch }; 12561e115a5SMichael Buesch 12661e115a5SMichael Buesch 12761e115a5SMichael Buesch /* Core-ID values. */ 12861e115a5SMichael Buesch #define SSB_DEV_CHIPCOMMON 0x800 12961e115a5SMichael Buesch #define SSB_DEV_ILINE20 0x801 13061e115a5SMichael Buesch #define SSB_DEV_SDRAM 0x803 13161e115a5SMichael Buesch #define SSB_DEV_PCI 0x804 13261e115a5SMichael Buesch #define SSB_DEV_MIPS 0x805 13361e115a5SMichael Buesch #define SSB_DEV_ETHERNET 0x806 13461e115a5SMichael Buesch #define SSB_DEV_V90 0x807 13561e115a5SMichael Buesch #define SSB_DEV_USB11_HOSTDEV 0x808 13661e115a5SMichael Buesch #define SSB_DEV_ADSL 0x809 13761e115a5SMichael Buesch #define SSB_DEV_ILINE100 0x80A 13861e115a5SMichael Buesch #define SSB_DEV_IPSEC 0x80B 13961e115a5SMichael Buesch #define SSB_DEV_PCMCIA 0x80D 14061e115a5SMichael Buesch #define SSB_DEV_INTERNAL_MEM 0x80E 14161e115a5SMichael Buesch #define SSB_DEV_MEMC_SDRAM 0x80F 14261e115a5SMichael Buesch #define SSB_DEV_EXTIF 0x811 14361e115a5SMichael Buesch #define SSB_DEV_80211 0x812 14461e115a5SMichael Buesch #define SSB_DEV_MIPS_3302 0x816 14561e115a5SMichael Buesch #define SSB_DEV_USB11_HOST 0x817 14661e115a5SMichael Buesch #define SSB_DEV_USB11_DEV 0x818 14761e115a5SMichael Buesch #define SSB_DEV_USB20_HOST 0x819 14861e115a5SMichael Buesch #define SSB_DEV_USB20_DEV 0x81A 14961e115a5SMichael Buesch #define SSB_DEV_SDIO_HOST 0x81B 15061e115a5SMichael Buesch #define SSB_DEV_ROBOSWITCH 0x81C 15161e115a5SMichael Buesch #define SSB_DEV_PARA_ATA 0x81D 15261e115a5SMichael Buesch #define SSB_DEV_SATA_XORDMA 0x81E 15361e115a5SMichael Buesch #define SSB_DEV_ETHERNET_GBIT 0x81F 15461e115a5SMichael Buesch #define SSB_DEV_PCIE 0x820 15561e115a5SMichael Buesch #define SSB_DEV_MIMO_PHY 0x821 15661e115a5SMichael Buesch #define SSB_DEV_SRAM_CTRLR 0x822 15761e115a5SMichael Buesch #define SSB_DEV_MINI_MACPHY 0x823 15861e115a5SMichael Buesch #define SSB_DEV_ARM_1176 0x824 15961e115a5SMichael Buesch #define SSB_DEV_ARM_7TDMI 0x825 16061e115a5SMichael Buesch 16161e115a5SMichael Buesch /* Vendor-ID values */ 16261e115a5SMichael Buesch #define SSB_VENDOR_BROADCOM 0x4243 16361e115a5SMichael Buesch 16461e115a5SMichael Buesch /* Some kernel subsystems poke with dev->drvdata, so we must use the 16561e115a5SMichael Buesch * following ugly workaround to get from struct device to struct ssb_device */ 16661e115a5SMichael Buesch struct __ssb_dev_wrapper { 16761e115a5SMichael Buesch struct device dev; 16861e115a5SMichael Buesch struct ssb_device *sdev; 16961e115a5SMichael Buesch }; 17061e115a5SMichael Buesch 17161e115a5SMichael Buesch struct ssb_device { 17261e115a5SMichael Buesch /* Having a copy of the ops pointer in each dev struct 17361e115a5SMichael Buesch * is an optimization. */ 17461e115a5SMichael Buesch const struct ssb_bus_ops *ops; 17561e115a5SMichael Buesch 17614f92952SFUJITA Tomonori struct device *dev, *dma_dev; 1774ac58469SMichael Buesch 17861e115a5SMichael Buesch struct ssb_bus *bus; 17961e115a5SMichael Buesch struct ssb_device_id id; 18061e115a5SMichael Buesch 18161e115a5SMichael Buesch u8 core_index; 18261e115a5SMichael Buesch unsigned int irq; 18361e115a5SMichael Buesch 18461e115a5SMichael Buesch /* Internal-only stuff follows. */ 18561e115a5SMichael Buesch void *drvdata; /* Per-device data */ 18661e115a5SMichael Buesch void *devtypedata; /* Per-devicetype (eg 802.11) data */ 18761e115a5SMichael Buesch }; 18861e115a5SMichael Buesch 18961e115a5SMichael Buesch /* Go from struct device to struct ssb_device. */ 19061e115a5SMichael Buesch static inline 19161e115a5SMichael Buesch struct ssb_device * dev_to_ssb_dev(struct device *dev) 19261e115a5SMichael Buesch { 19361e115a5SMichael Buesch struct __ssb_dev_wrapper *wrap; 19461e115a5SMichael Buesch wrap = container_of(dev, struct __ssb_dev_wrapper, dev); 19561e115a5SMichael Buesch return wrap->sdev; 19661e115a5SMichael Buesch } 19761e115a5SMichael Buesch 19861e115a5SMichael Buesch /* Device specific user data */ 19961e115a5SMichael Buesch static inline 20061e115a5SMichael Buesch void ssb_set_drvdata(struct ssb_device *dev, void *data) 20161e115a5SMichael Buesch { 20261e115a5SMichael Buesch dev->drvdata = data; 20361e115a5SMichael Buesch } 20461e115a5SMichael Buesch static inline 20561e115a5SMichael Buesch void * ssb_get_drvdata(struct ssb_device *dev) 20661e115a5SMichael Buesch { 20761e115a5SMichael Buesch return dev->drvdata; 20861e115a5SMichael Buesch } 20961e115a5SMichael Buesch 21061e115a5SMichael Buesch /* Devicetype specific user data. This is per device-type (not per device) */ 21161e115a5SMichael Buesch void ssb_set_devtypedata(struct ssb_device *dev, void *data); 21261e115a5SMichael Buesch static inline 21361e115a5SMichael Buesch void * ssb_get_devtypedata(struct ssb_device *dev) 21461e115a5SMichael Buesch { 21561e115a5SMichael Buesch return dev->devtypedata; 21661e115a5SMichael Buesch } 21761e115a5SMichael Buesch 21861e115a5SMichael Buesch 21961e115a5SMichael Buesch struct ssb_driver { 22061e115a5SMichael Buesch const char *name; 22161e115a5SMichael Buesch const struct ssb_device_id *id_table; 22261e115a5SMichael Buesch 22361e115a5SMichael Buesch int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id); 22461e115a5SMichael Buesch void (*remove)(struct ssb_device *dev); 22561e115a5SMichael Buesch int (*suspend)(struct ssb_device *dev, pm_message_t state); 22661e115a5SMichael Buesch int (*resume)(struct ssb_device *dev); 22761e115a5SMichael Buesch void (*shutdown)(struct ssb_device *dev); 22861e115a5SMichael Buesch 22961e115a5SMichael Buesch struct device_driver drv; 23061e115a5SMichael Buesch }; 23161e115a5SMichael Buesch #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv) 23261e115a5SMichael Buesch 23361e115a5SMichael Buesch extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner); 23461e115a5SMichael Buesch static inline int ssb_driver_register(struct ssb_driver *drv) 23561e115a5SMichael Buesch { 23661e115a5SMichael Buesch return __ssb_driver_register(drv, THIS_MODULE); 23761e115a5SMichael Buesch } 23861e115a5SMichael Buesch extern void ssb_driver_unregister(struct ssb_driver *drv); 23961e115a5SMichael Buesch 24061e115a5SMichael Buesch 24161e115a5SMichael Buesch 24261e115a5SMichael Buesch 24361e115a5SMichael Buesch enum ssb_bustype { 24461e115a5SMichael Buesch SSB_BUSTYPE_SSB, /* This SSB bus is the system bus */ 24561e115a5SMichael Buesch SSB_BUSTYPE_PCI, /* SSB is connected to PCI bus */ 24661e115a5SMichael Buesch SSB_BUSTYPE_PCMCIA, /* SSB is connected to PCMCIA bus */ 24724ea602eSAlbert Herranz SSB_BUSTYPE_SDIO, /* SSB is connected to SDIO bus */ 24861e115a5SMichael Buesch }; 24961e115a5SMichael Buesch 25061e115a5SMichael Buesch /* board_vendor */ 25161e115a5SMichael Buesch #define SSB_BOARDVENDOR_BCM 0x14E4 /* Broadcom */ 25261e115a5SMichael Buesch #define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */ 25361e115a5SMichael Buesch #define SSB_BOARDVENDOR_HP 0x0E11 /* HP */ 25461e115a5SMichael Buesch /* board_type */ 25561e115a5SMichael Buesch #define SSB_BOARD_BCM94306MP 0x0418 25661e115a5SMichael Buesch #define SSB_BOARD_BCM4309G 0x0421 25761e115a5SMichael Buesch #define SSB_BOARD_BCM4306CB 0x0417 25861e115a5SMichael Buesch #define SSB_BOARD_BCM4309MP 0x040C 25961e115a5SMichael Buesch #define SSB_BOARD_MP4318 0x044A 26061e115a5SMichael Buesch #define SSB_BOARD_BU4306 0x0416 26161e115a5SMichael Buesch #define SSB_BOARD_BU4309 0x040A 26261e115a5SMichael Buesch /* chip_package */ 26361e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */ 26461e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */ 26561e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712L 0 /* Large 340pin 4712 */ 26661e115a5SMichael Buesch 26761e115a5SMichael Buesch #include <linux/ssb/ssb_driver_chipcommon.h> 26861e115a5SMichael Buesch #include <linux/ssb/ssb_driver_mips.h> 26961e115a5SMichael Buesch #include <linux/ssb/ssb_driver_extif.h> 27061e115a5SMichael Buesch #include <linux/ssb/ssb_driver_pci.h> 27161e115a5SMichael Buesch 27261e115a5SMichael Buesch struct ssb_bus { 27361e115a5SMichael Buesch /* The MMIO area. */ 27461e115a5SMichael Buesch void __iomem *mmio; 27561e115a5SMichael Buesch 27661e115a5SMichael Buesch const struct ssb_bus_ops *ops; 27761e115a5SMichael Buesch 2788b45499cSMichael Buesch /* The core currently mapped into the MMIO window. 2798b45499cSMichael Buesch * Not valid on all host-buses. So don't use outside of SSB. */ 28061e115a5SMichael Buesch struct ssb_device *mapped_device; 28124ea602eSAlbert Herranz union { 28261e115a5SMichael Buesch /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */ 28361e115a5SMichael Buesch u8 mapped_pcmcia_seg; 28424ea602eSAlbert Herranz /* Current SSB base address window for SDIO. */ 28524ea602eSAlbert Herranz u32 sdio_sbaddr; 28624ea602eSAlbert Herranz }; 287993e1c78SMichael Buesch /* Lock for core and segment switching. 288993e1c78SMichael Buesch * On PCMCIA-host busses this is used to protect the whole MMIO access. */ 28961e115a5SMichael Buesch spinlock_t bar_lock; 29061e115a5SMichael Buesch 2918b45499cSMichael Buesch /* The host-bus this backplane is running on. */ 29261e115a5SMichael Buesch enum ssb_bustype bustype; 2938b45499cSMichael Buesch /* Pointers to the host-bus. Check bustype before using any of these pointers. */ 2948b45499cSMichael Buesch union { 29561e115a5SMichael Buesch /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */ 29661e115a5SMichael Buesch struct pci_dev *host_pci; 29761e115a5SMichael Buesch /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */ 29861e115a5SMichael Buesch struct pcmcia_device *host_pcmcia; 29924ea602eSAlbert Herranz /* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */ 30024ea602eSAlbert Herranz struct sdio_func *host_sdio; 3018b45499cSMichael Buesch }; 30224ea602eSAlbert Herranz 30324ea602eSAlbert Herranz /* See enum ssb_quirks */ 30424ea602eSAlbert Herranz unsigned int quirks; 30561e115a5SMichael Buesch 306e7ec2e32SMichael Buesch #ifdef CONFIG_SSB_SPROM 30761e115a5SMichael Buesch /* Mutex to protect the SPROM writing. */ 308e7ec2e32SMichael Buesch struct mutex sprom_mutex; 30961e115a5SMichael Buesch #endif 31061e115a5SMichael Buesch 31161e115a5SMichael Buesch /* ID information about the Chip. */ 31261e115a5SMichael Buesch u16 chip_id; 313ce57d9e6SRafał Miłecki u8 chip_rev; 314ea2db495SRafał Miłecki u16 sprom_offset; 315c272ef44SLarry Finger u16 sprom_size; /* number of words in sprom */ 31661e115a5SMichael Buesch u8 chip_package; 31761e115a5SMichael Buesch 31861e115a5SMichael Buesch /* List of devices (cores) on the backplane. */ 31961e115a5SMichael Buesch struct ssb_device devices[SSB_MAX_NR_CORES]; 32061e115a5SMichael Buesch u8 nr_devices; 32161e115a5SMichael Buesch 32261e115a5SMichael Buesch /* Software ID number for this bus. */ 32361e115a5SMichael Buesch unsigned int busnumber; 32461e115a5SMichael Buesch 32561e115a5SMichael Buesch /* The ChipCommon device (if available). */ 32661e115a5SMichael Buesch struct ssb_chipcommon chipco; 32761e115a5SMichael Buesch /* The PCI-core device (if available). */ 32861e115a5SMichael Buesch struct ssb_pcicore pcicore; 32961e115a5SMichael Buesch /* The MIPS-core device (if available). */ 33061e115a5SMichael Buesch struct ssb_mipscore mipscore; 33161e115a5SMichael Buesch /* The EXTif-core device (if available). */ 33261e115a5SMichael Buesch struct ssb_extif extif; 33361e115a5SMichael Buesch 33461e115a5SMichael Buesch /* The following structure elements are not available in early 33561e115a5SMichael Buesch * SSB initialization. Though, they are available for regular 33661e115a5SMichael Buesch * registered drivers at any stage. So be careful when 33761e115a5SMichael Buesch * using them in the ssb core code. */ 33861e115a5SMichael Buesch 33961e115a5SMichael Buesch /* ID information about the PCB. */ 34061e115a5SMichael Buesch struct ssb_boardinfo boardinfo; 34161e115a5SMichael Buesch /* Contents of the SPROM. */ 34261e115a5SMichael Buesch struct ssb_sprom sprom; 3437cb44615SMichael Buesch /* If the board has a cardbus slot, this is set to true. */ 3447cb44615SMichael Buesch bool has_cardbus_slot; 34561e115a5SMichael Buesch 34653521d8cSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED 34753521d8cSMichael Buesch /* Lock for GPIO register access. */ 34853521d8cSMichael Buesch spinlock_t gpio_lock; 34953521d8cSMichael Buesch #endif /* EMBEDDED */ 35053521d8cSMichael Buesch 35161e115a5SMichael Buesch /* Internal-only stuff follows. Do not touch. */ 35261e115a5SMichael Buesch struct list_head list; 35361e115a5SMichael Buesch #ifdef CONFIG_SSB_DEBUG 35461e115a5SMichael Buesch /* Is the bus already powered up? */ 35561e115a5SMichael Buesch bool powered_up; 35661e115a5SMichael Buesch int power_warn_count; 35761e115a5SMichael Buesch #endif /* DEBUG */ 35861e115a5SMichael Buesch }; 35961e115a5SMichael Buesch 36024ea602eSAlbert Herranz enum ssb_quirks { 36124ea602eSAlbert Herranz /* SDIO connected card requires performing a read after writing a 32-bit value */ 36224ea602eSAlbert Herranz SSB_QUIRK_SDIO_READ_AFTER_WRITE32 = (1 << 0), 36324ea602eSAlbert Herranz }; 36424ea602eSAlbert Herranz 36561e115a5SMichael Buesch /* The initialization-invariants. */ 36661e115a5SMichael Buesch struct ssb_init_invariants { 3677cb44615SMichael Buesch /* Versioning information about the PCB. */ 36861e115a5SMichael Buesch struct ssb_boardinfo boardinfo; 3697cb44615SMichael Buesch /* The SPROM information. That's either stored in an 3707cb44615SMichael Buesch * EEPROM or NVRAM on the board. */ 37161e115a5SMichael Buesch struct ssb_sprom sprom; 3727cb44615SMichael Buesch /* If the board has a cardbus slot, this is set to true. */ 3737cb44615SMichael Buesch bool has_cardbus_slot; 37461e115a5SMichael Buesch }; 37561e115a5SMichael Buesch /* Type of function to fetch the invariants. */ 37661e115a5SMichael Buesch typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus, 37761e115a5SMichael Buesch struct ssb_init_invariants *iv); 37861e115a5SMichael Buesch 37961e115a5SMichael Buesch /* Register a SSB system bus. get_invariants() is called after the 38061e115a5SMichael Buesch * basic system devices are initialized. 38161e115a5SMichael Buesch * The invariants are usually fetched from some NVRAM. 38261e115a5SMichael Buesch * Put the invariants into the struct pointed to by iv. */ 38361e115a5SMichael Buesch extern int ssb_bus_ssbbus_register(struct ssb_bus *bus, 38461e115a5SMichael Buesch unsigned long baseaddr, 38561e115a5SMichael Buesch ssb_invariants_func_t get_invariants); 38661e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST 38761e115a5SMichael Buesch extern int ssb_bus_pcibus_register(struct ssb_bus *bus, 38861e115a5SMichael Buesch struct pci_dev *host_pci); 38961e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */ 39061e115a5SMichael Buesch #ifdef CONFIG_SSB_PCMCIAHOST 39161e115a5SMichael Buesch extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus, 39261e115a5SMichael Buesch struct pcmcia_device *pcmcia_dev, 39361e115a5SMichael Buesch unsigned long baseaddr); 39461e115a5SMichael Buesch #endif /* CONFIG_SSB_PCMCIAHOST */ 39524ea602eSAlbert Herranz #ifdef CONFIG_SSB_SDIOHOST 39624ea602eSAlbert Herranz extern int ssb_bus_sdiobus_register(struct ssb_bus *bus, 39724ea602eSAlbert Herranz struct sdio_func *sdio_func, 39824ea602eSAlbert Herranz unsigned int quirks); 39924ea602eSAlbert Herranz #endif /* CONFIG_SSB_SDIOHOST */ 40024ea602eSAlbert Herranz 40161e115a5SMichael Buesch 40261e115a5SMichael Buesch extern void ssb_bus_unregister(struct ssb_bus *bus); 40361e115a5SMichael Buesch 404d53cdbb9SJohn W. Linville /* Does the device have an SPROM? */ 405d53cdbb9SJohn W. Linville extern bool ssb_is_sprom_available(struct ssb_bus *bus); 406d53cdbb9SJohn W. Linville 407e79c1ba8SMichael Buesch /* Set a fallback SPROM. 408e79c1ba8SMichael Buesch * See kdoc at the function definition for complete documentation. */ 409b3ae52b6SHauke Mehrtens extern int ssb_arch_register_fallback_sprom( 410b3ae52b6SHauke Mehrtens int (*sprom_callback)(struct ssb_bus *bus, 411b3ae52b6SHauke Mehrtens struct ssb_sprom *out)); 412e79c1ba8SMichael Buesch 4138fe2b65aSMichael Buesch /* Suspend a SSB bus. 4148fe2b65aSMichael Buesch * Call this from the parent bus suspend routine. */ 4158fe2b65aSMichael Buesch extern int ssb_bus_suspend(struct ssb_bus *bus); 4168fe2b65aSMichael Buesch /* Resume a SSB bus. 4178fe2b65aSMichael Buesch * Call this from the parent bus resume routine. */ 4188fe2b65aSMichael Buesch extern int ssb_bus_resume(struct ssb_bus *bus); 4198fe2b65aSMichael Buesch 42061e115a5SMichael Buesch extern u32 ssb_clockspeed(struct ssb_bus *bus); 42161e115a5SMichael Buesch 42261e115a5SMichael Buesch /* Is the device enabled in hardware? */ 42361e115a5SMichael Buesch int ssb_device_is_enabled(struct ssb_device *dev); 42461e115a5SMichael Buesch /* Enable a device and pass device-specific SSB_TMSLOW flags. 42561e115a5SMichael Buesch * If no device-specific flags are available, use 0. */ 42661e115a5SMichael Buesch void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags); 42761e115a5SMichael Buesch /* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */ 42861e115a5SMichael Buesch void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags); 42961e115a5SMichael Buesch 43061e115a5SMichael Buesch 43161e115a5SMichael Buesch /* Device MMIO register read/write functions. */ 432ffc7689dSMichael Buesch static inline u8 ssb_read8(struct ssb_device *dev, u16 offset) 433ffc7689dSMichael Buesch { 434ffc7689dSMichael Buesch return dev->ops->read8(dev, offset); 435ffc7689dSMichael Buesch } 43661e115a5SMichael Buesch static inline u16 ssb_read16(struct ssb_device *dev, u16 offset) 43761e115a5SMichael Buesch { 43861e115a5SMichael Buesch return dev->ops->read16(dev, offset); 43961e115a5SMichael Buesch } 44061e115a5SMichael Buesch static inline u32 ssb_read32(struct ssb_device *dev, u16 offset) 44161e115a5SMichael Buesch { 44261e115a5SMichael Buesch return dev->ops->read32(dev, offset); 44361e115a5SMichael Buesch } 444ffc7689dSMichael Buesch static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value) 445ffc7689dSMichael Buesch { 446ffc7689dSMichael Buesch dev->ops->write8(dev, offset, value); 447ffc7689dSMichael Buesch } 44861e115a5SMichael Buesch static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value) 44961e115a5SMichael Buesch { 45061e115a5SMichael Buesch dev->ops->write16(dev, offset, value); 45161e115a5SMichael Buesch } 45261e115a5SMichael Buesch static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value) 45361e115a5SMichael Buesch { 45461e115a5SMichael Buesch dev->ops->write32(dev, offset, value); 45561e115a5SMichael Buesch } 456d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO 457d625a29bSMichael Buesch static inline void ssb_block_read(struct ssb_device *dev, void *buffer, 458d625a29bSMichael Buesch size_t count, u16 offset, u8 reg_width) 459d625a29bSMichael Buesch { 460d625a29bSMichael Buesch dev->ops->block_read(dev, buffer, count, offset, reg_width); 461d625a29bSMichael Buesch } 462d625a29bSMichael Buesch 463d625a29bSMichael Buesch static inline void ssb_block_write(struct ssb_device *dev, const void *buffer, 464d625a29bSMichael Buesch size_t count, u16 offset, u8 reg_width) 465d625a29bSMichael Buesch { 466d625a29bSMichael Buesch dev->ops->block_write(dev, buffer, count, offset, reg_width); 467d625a29bSMichael Buesch } 468d625a29bSMichael Buesch #endif /* CONFIG_SSB_BLOCKIO */ 46961e115a5SMichael Buesch 47061e115a5SMichael Buesch 471f225763aSMichael Buesch /* The SSB DMA API. Use this API for any DMA operation on the device. 472f225763aSMichael Buesch * This API basically is a wrapper that calls the correct DMA API for 473f225763aSMichael Buesch * the host device type the SSB device is attached to. */ 474f225763aSMichael Buesch 47561e115a5SMichael Buesch /* Translation (routing) bits that need to be ORed to DMA 47661e115a5SMichael Buesch * addresses before they are given to a device. */ 47761e115a5SMichael Buesch extern u32 ssb_dma_translation(struct ssb_device *dev); 47861e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_MASK 0xC0000000 47961e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_SHIFT 30 48061e115a5SMichael Buesch 481f225763aSMichael Buesch static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev) 482f225763aSMichael Buesch { 483f225763aSMichael Buesch #ifdef CONFIG_SSB_DEBUG 484f225763aSMichael Buesch printk(KERN_ERR "SSB: BUG! Calling DMA API for " 485f225763aSMichael Buesch "unsupported bustype %d\n", dev->bus->bustype); 486f225763aSMichael Buesch #endif /* DEBUG */ 487f225763aSMichael Buesch } 488f225763aSMichael Buesch 48961e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST 49061e115a5SMichael Buesch /* PCI-host wrapper driver */ 49161e115a5SMichael Buesch extern int ssb_pcihost_register(struct pci_driver *driver); 49261e115a5SMichael Buesch static inline void ssb_pcihost_unregister(struct pci_driver *driver) 49361e115a5SMichael Buesch { 49461e115a5SMichael Buesch pci_unregister_driver(driver); 49561e115a5SMichael Buesch } 496961d57c8SMiguel Botón 497961d57c8SMiguel Botón static inline 498961d57c8SMiguel Botón void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state) 499961d57c8SMiguel Botón { 500961d57c8SMiguel Botón if (sdev->bus->bustype == SSB_BUSTYPE_PCI) 501961d57c8SMiguel Botón pci_set_power_state(sdev->bus->host_pci, state); 502961d57c8SMiguel Botón } 503532031d7SAndrew Morton #else 504532031d7SAndrew Morton static inline void ssb_pcihost_unregister(struct pci_driver *driver) 505532031d7SAndrew Morton { 506532031d7SAndrew Morton } 507532031d7SAndrew Morton 508532031d7SAndrew Morton static inline 509532031d7SAndrew Morton void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state) 510532031d7SAndrew Morton { 511532031d7SAndrew Morton } 51261e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */ 51361e115a5SMichael Buesch 51461e115a5SMichael Buesch 51561e115a5SMichael Buesch /* If a driver is shutdown or suspended, call this to signal 51661e115a5SMichael Buesch * that the bus may be completely powered down. SSB will decide, 51761e115a5SMichael Buesch * if it's really time to power down the bus, based on if there 51861e115a5SMichael Buesch * are other devices that want to run. */ 51961e115a5SMichael Buesch extern int ssb_bus_may_powerdown(struct ssb_bus *bus); 52061e115a5SMichael Buesch /* Before initializing and enabling a device, call this to power-up the bus. 52161e115a5SMichael Buesch * If you want to allow use of dynamic-power-control, pass the flag. 52261e115a5SMichael Buesch * Otherwise static always-on powercontrol will be used. */ 52361e115a5SMichael Buesch extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl); 52461e115a5SMichael Buesch 5258576f815SRafał Miłecki extern void ssb_commit_settings(struct ssb_bus *bus); 52661e115a5SMichael Buesch 52761e115a5SMichael Buesch /* Various helper functions */ 52861e115a5SMichael Buesch extern u32 ssb_admatch_base(u32 adm); 52961e115a5SMichael Buesch extern u32 ssb_admatch_size(u32 adm); 53061e115a5SMichael Buesch 531aab547ceSMichael Buesch /* PCI device mapping and fixup routines. 532aab547ceSMichael Buesch * Called from the architecture pcibios init code. 533aab547ceSMichael Buesch * These are only available on SSB_EMBEDDED configurations. */ 534aab547ceSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED 535aab547ceSMichael Buesch int ssb_pcibios_plat_dev_init(struct pci_dev *dev); 536aab547ceSMichael Buesch int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin); 537aab547ceSMichael Buesch #endif /* CONFIG_SSB_EMBEDDED */ 53861e115a5SMichael Buesch 53961e115a5SMichael Buesch #endif /* LINUX_SSB_H_ */ 540