xref: /linux/include/linux/ssb/ssb.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
261e115a5SMichael Buesch #ifndef LINUX_SSB_H_
361e115a5SMichael Buesch #define LINUX_SSB_H_
461e115a5SMichael Buesch 
561e115a5SMichael Buesch #include <linux/device.h>
661e115a5SMichael Buesch #include <linux/list.h>
761e115a5SMichael Buesch #include <linux/types.h>
861e115a5SMichael Buesch #include <linux/spinlock.h>
961e115a5SMichael Buesch #include <linux/pci.h>
1081f9ebd4SLinus Walleij #include <linux/gpio/driver.h>
1161e115a5SMichael Buesch #include <linux/mod_devicetable.h>
129c0c7a42SMichael Buesch #include <linux/dma-mapping.h>
13bde327efSHauke Mehrtens #include <linux/platform_device.h>
1461e115a5SMichael Buesch 
1561e115a5SMichael Buesch #include <linux/ssb/ssb_regs.h>
1661e115a5SMichael Buesch 
1761e115a5SMichael Buesch 
1861e115a5SMichael Buesch struct pcmcia_device;
1961e115a5SMichael Buesch struct ssb_bus;
2061e115a5SMichael Buesch struct ssb_driver;
2161e115a5SMichael Buesch 
22b0f70292SRafał Miłecki struct ssb_sprom_core_pwr_info {
23b0f70292SRafał Miłecki 	u8 itssi_2g, itssi_5g;
24b0f70292SRafał Miłecki 	u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
253b64e6f9SHauke Mehrtens 	u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
26b0f70292SRafał Miłecki };
27b0f70292SRafał Miłecki 
2861e115a5SMichael Buesch struct ssb_sprom {
2961e115a5SMichael Buesch 	u8 revision;
3085249828SHauke Mehrtens 	u8 il0mac[6] __aligned(sizeof(u16));	/* MAC address for 802.11b/g */
3185249828SHauke Mehrtens 	u8 et0mac[6] __aligned(sizeof(u16));	/* MAC address for Ethernet */
3285249828SHauke Mehrtens 	u8 et1mac[6] __aligned(sizeof(u16));	/* MAC address for 802.11a */
336e122ac0SRafał Miłecki 	u8 et2mac[6] __aligned(sizeof(u16));	/* MAC address for extra Ethernet */
34ac82fab4SLarry Finger 	u8 et0phyaddr;		/* MII address for enet0 */
35ac82fab4SLarry Finger 	u8 et1phyaddr;		/* MII address for enet1 */
366e122ac0SRafał Miłecki 	u8 et2phyaddr;		/* MII address for enet2 */
37e861b98dSMichael Buesch 	u8 et0mdcport;		/* MDIO for enet0 */
38e861b98dSMichael Buesch 	u8 et1mdcport;		/* MDIO for enet1 */
396e122ac0SRafał Miłecki 	u8 et2mdcport;		/* MDIO for enet2 */
404f4aa2ecSRafał Miłecki 	u16 dev_id;		/* Device ID overriding e.g. PCI ID */
41e2d646ceSRafał Miłecki 	u16 board_rev;		/* Board revision number from SPROM. */
4252aa63f5SHauke Mehrtens 	u16 board_num;		/* Board number from SPROM. */
4352aa63f5SHauke Mehrtens 	u16 board_type;		/* Board type from SPROM. */
44ac82fab4SLarry Finger 	u8 country_code;	/* Country Code */
4503a5642bSHauke Mehrtens 	char alpha2[2];		/* Country Code as two chars like EU or US */
46edd8d90bSHauke Mehrtens 	u8 leddc_on_time;	/* LED Powersave Duty Cycle On Count */
47edd8d90bSHauke Mehrtens 	u8 leddc_off_time;	/* LED Powersave Duty Cycle Off Count */
48f679056bSGábor Stefanik 	u8 ant_available_a;	/* 2GHz antenna available bits (up to 4) */
49f679056bSGábor Stefanik 	u8 ant_available_bg;	/* 5GHz antenna available bits (up to 4) */
50ac82fab4SLarry Finger 	u16 pa0b0;
51ac82fab4SLarry Finger 	u16 pa0b1;
52ac82fab4SLarry Finger 	u16 pa0b2;
53ac82fab4SLarry Finger 	u16 pa1b0;
54ac82fab4SLarry Finger 	u16 pa1b1;
55ac82fab4SLarry Finger 	u16 pa1b2;
56f679056bSGábor Stefanik 	u16 pa1lob0;
57f679056bSGábor Stefanik 	u16 pa1lob1;
58f679056bSGábor Stefanik 	u16 pa1lob2;
59f679056bSGábor Stefanik 	u16 pa1hib0;
60f679056bSGábor Stefanik 	u16 pa1hib1;
61f679056bSGábor Stefanik 	u16 pa1hib2;
62ac82fab4SLarry Finger 	u8 gpio0;		/* GPIO pin 0 */
63ac82fab4SLarry Finger 	u8 gpio1;		/* GPIO pin 1 */
64ac82fab4SLarry Finger 	u8 gpio2;		/* GPIO pin 2 */
65ac82fab4SLarry Finger 	u8 gpio3;		/* GPIO pin 3 */
66edd8d90bSHauke Mehrtens 	u8 maxpwr_bg;		/* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
67edd8d90bSHauke Mehrtens 	u8 maxpwr_al;		/* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
68edd8d90bSHauke Mehrtens 	u8 maxpwr_a;		/* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
69edd8d90bSHauke Mehrtens 	u8 maxpwr_ah;		/* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
70ac82fab4SLarry Finger 	u8 itssi_a;		/* Idle TSSI Target for A-PHY */
71ac82fab4SLarry Finger 	u8 itssi_bg;		/* Idle TSSI Target for B/G-PHY */
72f679056bSGábor Stefanik 	u8 tri2g;		/* 2.4GHz TX isolation */
73f679056bSGábor Stefanik 	u8 tri5gl;		/* 5.2GHz TX isolation */
74f679056bSGábor Stefanik 	u8 tri5g;		/* 5.3GHz TX isolation */
75f679056bSGábor Stefanik 	u8 tri5gh;		/* 5.8GHz TX isolation */
76172c69a4SRafał Miłecki 	u8 txpid2g[4];		/* 2GHz TX power index */
77172c69a4SRafał Miłecki 	u8 txpid5gl[4];		/* 4.9 - 5.1GHz TX power index */
78172c69a4SRafał Miłecki 	u8 txpid5g[4];		/* 5.1 - 5.5GHz TX power index */
79172c69a4SRafał Miłecki 	u8 txpid5gh[4];		/* 5.5 - ...GHz TX power index */
80edd8d90bSHauke Mehrtens 	s8 rxpo2g;		/* 2GHz RX power offset */
81edd8d90bSHauke Mehrtens 	s8 rxpo5g;		/* 5GHz RX power offset */
82f679056bSGábor Stefanik 	u8 rssisav2g;		/* 2GHz RSSI params */
83f679056bSGábor Stefanik 	u8 rssismc2g;
84f679056bSGábor Stefanik 	u8 rssismf2g;
85f679056bSGábor Stefanik 	u8 bxa2g;		/* 2GHz BX arch */
86f679056bSGábor Stefanik 	u8 rssisav5g;		/* 5GHz RSSI params */
87f679056bSGábor Stefanik 	u8 rssismc5g;
88f679056bSGábor Stefanik 	u8 rssismf5g;
89f679056bSGábor Stefanik 	u8 bxa5g;		/* 5GHz BX arch */
90f679056bSGábor Stefanik 	u16 cck2gpo;		/* CCK power offset */
91f679056bSGábor Stefanik 	u32 ofdm2gpo;		/* 2.4GHz OFDM power offset */
92f679056bSGábor Stefanik 	u32 ofdm5glpo;		/* 5.2GHz OFDM power offset */
93f679056bSGábor Stefanik 	u32 ofdm5gpo;		/* 5.3GHz OFDM power offset */
94f679056bSGábor Stefanik 	u32 ofdm5ghpo;		/* 5.8GHz OFDM power offset */
951387fe7dSRafał Miłecki 	u32 boardflags;
961387fe7dSRafał Miłecki 	u32 boardflags2;
971387fe7dSRafał Miłecki 	u32 boardflags3;
981387fe7dSRafał Miłecki 	/* TODO: Switch all drivers to new u32 fields and drop below ones */
99f679056bSGábor Stefanik 	u16 boardflags_lo;	/* Board flags (bits 0-15) */
100f679056bSGábor Stefanik 	u16 boardflags_hi;	/* Board flags (bits 16-31) */
101f679056bSGábor Stefanik 	u16 boardflags2_lo;	/* Board flags (bits 32-47) */
102f679056bSGábor Stefanik 	u16 boardflags2_hi;	/* Board flags (bits 48-63) */
103e861b98dSMichael Buesch 
104b0f70292SRafał Miłecki 	struct ssb_sprom_core_pwr_info core_pwr_info[4];
105b0f70292SRafał Miłecki 
106e861b98dSMichael Buesch 	/* Antenna gain values for up to 4 antennas
107e861b98dSMichael Buesch 	 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
108e861b98dSMichael Buesch 	 * loss in the connectors is bigger than the gain. */
109e861b98dSMichael Buesch 	struct {
110e861b98dSMichael Buesch 		s8 a0, a1, a2, a3;
111e861b98dSMichael Buesch 	} antenna_gain;
112ac82fab4SLarry Finger 
1138a5ac6ecSRafał Miłecki 	struct {
1148a5ac6ecSRafał Miłecki 		struct {
1158a5ac6ecSRafał Miłecki 			u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1168a5ac6ecSRafał Miłecki 		} ghz2;
1178a5ac6ecSRafał Miłecki 		struct {
1188a5ac6ecSRafał Miłecki 			u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1198a5ac6ecSRafał Miłecki 		} ghz5;
1208a5ac6ecSRafał Miłecki 	} fem;
1218a5ac6ecSRafał Miłecki 
12252aa63f5SHauke Mehrtens 	u16 mcs2gpo[8];
12352aa63f5SHauke Mehrtens 	u16 mcs5gpo[8];
12452aa63f5SHauke Mehrtens 	u16 mcs5glpo[8];
12552aa63f5SHauke Mehrtens 	u16 mcs5ghpo[8];
12652aa63f5SHauke Mehrtens 	u8 opo;
12752aa63f5SHauke Mehrtens 
12852aa63f5SHauke Mehrtens 	u8 rxgainerr2ga[3];
12952aa63f5SHauke Mehrtens 	u8 rxgainerr5gla[3];
13052aa63f5SHauke Mehrtens 	u8 rxgainerr5gma[3];
13152aa63f5SHauke Mehrtens 	u8 rxgainerr5gha[3];
13252aa63f5SHauke Mehrtens 	u8 rxgainerr5gua[3];
13352aa63f5SHauke Mehrtens 
13452aa63f5SHauke Mehrtens 	u8 noiselvl2ga[3];
13552aa63f5SHauke Mehrtens 	u8 noiselvl5gla[3];
13652aa63f5SHauke Mehrtens 	u8 noiselvl5gma[3];
13752aa63f5SHauke Mehrtens 	u8 noiselvl5gha[3];
13852aa63f5SHauke Mehrtens 	u8 noiselvl5gua[3];
13952aa63f5SHauke Mehrtens 
14052aa63f5SHauke Mehrtens 	u8 regrev;
14152aa63f5SHauke Mehrtens 	u8 txchain;
14252aa63f5SHauke Mehrtens 	u8 rxchain;
14352aa63f5SHauke Mehrtens 	u8 antswitch;
14452aa63f5SHauke Mehrtens 	u16 cddpo;
14552aa63f5SHauke Mehrtens 	u16 stbcpo;
14652aa63f5SHauke Mehrtens 	u16 bw40po;
14752aa63f5SHauke Mehrtens 	u16 bwduppo;
14852aa63f5SHauke Mehrtens 
14952aa63f5SHauke Mehrtens 	u8 tempthresh;
15052aa63f5SHauke Mehrtens 	u8 tempoffset;
15152aa63f5SHauke Mehrtens 	u16 rawtempsense;
15252aa63f5SHauke Mehrtens 	u8 measpower;
15352aa63f5SHauke Mehrtens 	u8 tempsense_slope;
15452aa63f5SHauke Mehrtens 	u8 tempcorrx;
15552aa63f5SHauke Mehrtens 	u8 tempsense_option;
15652aa63f5SHauke Mehrtens 	u8 freqoffset_corr;
15752aa63f5SHauke Mehrtens 	u8 iqcal_swp_dis;
15852aa63f5SHauke Mehrtens 	u8 hw_iqcal_en;
15952aa63f5SHauke Mehrtens 	u8 elna2g;
16052aa63f5SHauke Mehrtens 	u8 elna5g;
16152aa63f5SHauke Mehrtens 	u8 phycal_tempdelta;
16252aa63f5SHauke Mehrtens 	u8 temps_period;
16352aa63f5SHauke Mehrtens 	u8 temps_hysteresis;
16452aa63f5SHauke Mehrtens 	u8 measpower1;
16552aa63f5SHauke Mehrtens 	u8 measpower2;
16652aa63f5SHauke Mehrtens 	u8 pcieingress_war;
16752aa63f5SHauke Mehrtens 
16852aa63f5SHauke Mehrtens 	/* power per rate from sromrev 9 */
16952aa63f5SHauke Mehrtens 	u16 cckbw202gpo;
17052aa63f5SHauke Mehrtens 	u16 cckbw20ul2gpo;
17152aa63f5SHauke Mehrtens 	u32 legofdmbw202gpo;
17252aa63f5SHauke Mehrtens 	u32 legofdmbw20ul2gpo;
17352aa63f5SHauke Mehrtens 	u32 legofdmbw205glpo;
17452aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5glpo;
17552aa63f5SHauke Mehrtens 	u32 legofdmbw205gmpo;
17652aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5gmpo;
17752aa63f5SHauke Mehrtens 	u32 legofdmbw205ghpo;
17852aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5ghpo;
17952aa63f5SHauke Mehrtens 	u32 mcsbw202gpo;
18052aa63f5SHauke Mehrtens 	u32 mcsbw20ul2gpo;
18152aa63f5SHauke Mehrtens 	u32 mcsbw402gpo;
18252aa63f5SHauke Mehrtens 	u32 mcsbw205glpo;
18352aa63f5SHauke Mehrtens 	u32 mcsbw20ul5glpo;
18452aa63f5SHauke Mehrtens 	u32 mcsbw405glpo;
18552aa63f5SHauke Mehrtens 	u32 mcsbw205gmpo;
18652aa63f5SHauke Mehrtens 	u32 mcsbw20ul5gmpo;
18752aa63f5SHauke Mehrtens 	u32 mcsbw405gmpo;
18852aa63f5SHauke Mehrtens 	u32 mcsbw205ghpo;
18952aa63f5SHauke Mehrtens 	u32 mcsbw20ul5ghpo;
19052aa63f5SHauke Mehrtens 	u32 mcsbw405ghpo;
19152aa63f5SHauke Mehrtens 	u16 mcs32po;
19252aa63f5SHauke Mehrtens 	u16 legofdm40duppo;
19352aa63f5SHauke Mehrtens 	u8 sar2g;
19452aa63f5SHauke Mehrtens 	u8 sar5g;
19561e115a5SMichael Buesch };
19661e115a5SMichael Buesch 
19761e115a5SMichael Buesch /* Information about the PCB the circuitry is soldered on. */
19861e115a5SMichael Buesch struct ssb_boardinfo {
19961e115a5SMichael Buesch 	u16 vendor;
20061e115a5SMichael Buesch 	u16 type;
20161e115a5SMichael Buesch };
20261e115a5SMichael Buesch 
20361e115a5SMichael Buesch 
20461e115a5SMichael Buesch struct ssb_device;
20561e115a5SMichael Buesch /* Lowlevel read/write operations on the device MMIO.
20661e115a5SMichael Buesch  * Internal, don't use that outside of ssb. */
20761e115a5SMichael Buesch struct ssb_bus_ops {
208ffc7689dSMichael Buesch 	u8 (*read8)(struct ssb_device *dev, u16 offset);
20961e115a5SMichael Buesch 	u16 (*read16)(struct ssb_device *dev, u16 offset);
21061e115a5SMichael Buesch 	u32 (*read32)(struct ssb_device *dev, u16 offset);
211ffc7689dSMichael Buesch 	void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
21261e115a5SMichael Buesch 	void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
21361e115a5SMichael Buesch 	void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
214d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO
215d625a29bSMichael Buesch 	void (*block_read)(struct ssb_device *dev, void *buffer,
216d625a29bSMichael Buesch 			   size_t count, u16 offset, u8 reg_width);
217d625a29bSMichael Buesch 	void (*block_write)(struct ssb_device *dev, const void *buffer,
218d625a29bSMichael Buesch 			    size_t count, u16 offset, u8 reg_width);
219d625a29bSMichael Buesch #endif
22061e115a5SMichael Buesch };
22161e115a5SMichael Buesch 
22261e115a5SMichael Buesch 
22361e115a5SMichael Buesch /* Core-ID values. */
22461e115a5SMichael Buesch #define SSB_DEV_CHIPCOMMON	0x800
22561e115a5SMichael Buesch #define SSB_DEV_ILINE20		0x801
22661e115a5SMichael Buesch #define SSB_DEV_SDRAM		0x803
22761e115a5SMichael Buesch #define SSB_DEV_PCI		0x804
22861e115a5SMichael Buesch #define SSB_DEV_MIPS		0x805
22961e115a5SMichael Buesch #define SSB_DEV_ETHERNET	0x806
23061e115a5SMichael Buesch #define SSB_DEV_V90		0x807
23161e115a5SMichael Buesch #define SSB_DEV_USB11_HOSTDEV	0x808
23261e115a5SMichael Buesch #define SSB_DEV_ADSL		0x809
23361e115a5SMichael Buesch #define SSB_DEV_ILINE100	0x80A
23461e115a5SMichael Buesch #define SSB_DEV_IPSEC		0x80B
23561e115a5SMichael Buesch #define SSB_DEV_PCMCIA		0x80D
23661e115a5SMichael Buesch #define SSB_DEV_INTERNAL_MEM	0x80E
23761e115a5SMichael Buesch #define SSB_DEV_MEMC_SDRAM	0x80F
23861e115a5SMichael Buesch #define SSB_DEV_EXTIF		0x811
23961e115a5SMichael Buesch #define SSB_DEV_80211		0x812
24061e115a5SMichael Buesch #define SSB_DEV_MIPS_3302	0x816
24161e115a5SMichael Buesch #define SSB_DEV_USB11_HOST	0x817
24261e115a5SMichael Buesch #define SSB_DEV_USB11_DEV	0x818
24361e115a5SMichael Buesch #define SSB_DEV_USB20_HOST	0x819
24461e115a5SMichael Buesch #define SSB_DEV_USB20_DEV	0x81A
24561e115a5SMichael Buesch #define SSB_DEV_SDIO_HOST	0x81B
24661e115a5SMichael Buesch #define SSB_DEV_ROBOSWITCH	0x81C
24761e115a5SMichael Buesch #define SSB_DEV_PARA_ATA	0x81D
24861e115a5SMichael Buesch #define SSB_DEV_SATA_XORDMA	0x81E
24961e115a5SMichael Buesch #define SSB_DEV_ETHERNET_GBIT	0x81F
25061e115a5SMichael Buesch #define SSB_DEV_PCIE		0x820
25161e115a5SMichael Buesch #define SSB_DEV_MIMO_PHY	0x821
25261e115a5SMichael Buesch #define SSB_DEV_SRAM_CTRLR	0x822
25361e115a5SMichael Buesch #define SSB_DEV_MINI_MACPHY	0x823
25461e115a5SMichael Buesch #define SSB_DEV_ARM_1176	0x824
25561e115a5SMichael Buesch #define SSB_DEV_ARM_7TDMI	0x825
256ccaf8c32SHauke Mehrtens #define SSB_DEV_ARM_CM3		0x82A
25761e115a5SMichael Buesch 
25861e115a5SMichael Buesch /* Vendor-ID values */
25961e115a5SMichael Buesch #define SSB_VENDOR_BROADCOM	0x4243
26061e115a5SMichael Buesch 
26161e115a5SMichael Buesch /* Some kernel subsystems poke with dev->drvdata, so we must use the
26261e115a5SMichael Buesch  * following ugly workaround to get from struct device to struct ssb_device */
26361e115a5SMichael Buesch struct __ssb_dev_wrapper {
26461e115a5SMichael Buesch 	struct device dev;
26561e115a5SMichael Buesch 	struct ssb_device *sdev;
26661e115a5SMichael Buesch };
26761e115a5SMichael Buesch 
26861e115a5SMichael Buesch struct ssb_device {
26961e115a5SMichael Buesch 	/* Having a copy of the ops pointer in each dev struct
27061e115a5SMichael Buesch 	 * is an optimization. */
27161e115a5SMichael Buesch 	const struct ssb_bus_ops *ops;
27261e115a5SMichael Buesch 
27314f92952SFUJITA Tomonori 	struct device *dev, *dma_dev;
2744ac58469SMichael Buesch 
27561e115a5SMichael Buesch 	struct ssb_bus *bus;
27661e115a5SMichael Buesch 	struct ssb_device_id id;
27761e115a5SMichael Buesch 
27861e115a5SMichael Buesch 	u8 core_index;
27961e115a5SMichael Buesch 	unsigned int irq;
28061e115a5SMichael Buesch 
28161e115a5SMichael Buesch 	/* Internal-only stuff follows. */
28261e115a5SMichael Buesch 	void *drvdata;		/* Per-device data */
28361e115a5SMichael Buesch 	void *devtypedata;	/* Per-devicetype (eg 802.11) data */
28461e115a5SMichael Buesch };
28561e115a5SMichael Buesch 
28661e115a5SMichael Buesch /* Go from struct device to struct ssb_device. */
28761e115a5SMichael Buesch static inline
dev_to_ssb_dev(const struct device * dev)2882a81ada3SGreg Kroah-Hartman struct ssb_device * dev_to_ssb_dev(const struct device *dev)
28961e115a5SMichael Buesch {
29061e115a5SMichael Buesch 	struct __ssb_dev_wrapper *wrap;
29161e115a5SMichael Buesch 	wrap = container_of(dev, struct __ssb_dev_wrapper, dev);
29261e115a5SMichael Buesch 	return wrap->sdev;
29361e115a5SMichael Buesch }
29461e115a5SMichael Buesch 
29561e115a5SMichael Buesch /* Device specific user data */
29661e115a5SMichael Buesch static inline
ssb_set_drvdata(struct ssb_device * dev,void * data)29761e115a5SMichael Buesch void ssb_set_drvdata(struct ssb_device *dev, void *data)
29861e115a5SMichael Buesch {
29961e115a5SMichael Buesch 	dev->drvdata = data;
30061e115a5SMichael Buesch }
30161e115a5SMichael Buesch static inline
ssb_get_drvdata(struct ssb_device * dev)30261e115a5SMichael Buesch void * ssb_get_drvdata(struct ssb_device *dev)
30361e115a5SMichael Buesch {
30461e115a5SMichael Buesch 	return dev->drvdata;
30561e115a5SMichael Buesch }
30661e115a5SMichael Buesch 
30761e115a5SMichael Buesch /* Devicetype specific user data. This is per device-type (not per device) */
30861e115a5SMichael Buesch void ssb_set_devtypedata(struct ssb_device *dev, void *data);
30961e115a5SMichael Buesch static inline
ssb_get_devtypedata(struct ssb_device * dev)31061e115a5SMichael Buesch void * ssb_get_devtypedata(struct ssb_device *dev)
31161e115a5SMichael Buesch {
31261e115a5SMichael Buesch 	return dev->devtypedata;
31361e115a5SMichael Buesch }
31461e115a5SMichael Buesch 
31561e115a5SMichael Buesch 
31661e115a5SMichael Buesch struct ssb_driver {
31761e115a5SMichael Buesch 	const char *name;
31861e115a5SMichael Buesch 	const struct ssb_device_id *id_table;
31961e115a5SMichael Buesch 
32061e115a5SMichael Buesch 	int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id);
32161e115a5SMichael Buesch 	void (*remove)(struct ssb_device *dev);
32261e115a5SMichael Buesch 	int (*suspend)(struct ssb_device *dev, pm_message_t state);
32361e115a5SMichael Buesch 	int (*resume)(struct ssb_device *dev);
32461e115a5SMichael Buesch 	void (*shutdown)(struct ssb_device *dev);
32561e115a5SMichael Buesch 
32661e115a5SMichael Buesch 	struct device_driver drv;
32761e115a5SMichael Buesch };
328*d69d8048SGreg Kroah-Hartman #define drv_to_ssb_drv(_drv) container_of_const(_drv, struct ssb_driver, drv)
32961e115a5SMichael Buesch 
33061e115a5SMichael Buesch extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
331eb5589a8SPaul Gortmaker #define ssb_driver_register(drv) \
332eb5589a8SPaul Gortmaker 	__ssb_driver_register(drv, THIS_MODULE)
333eb5589a8SPaul Gortmaker 
33461e115a5SMichael Buesch extern void ssb_driver_unregister(struct ssb_driver *drv);
33561e115a5SMichael Buesch 
33661e115a5SMichael Buesch 
33761e115a5SMichael Buesch 
33861e115a5SMichael Buesch 
33961e115a5SMichael Buesch enum ssb_bustype {
34061e115a5SMichael Buesch 	SSB_BUSTYPE_SSB,	/* This SSB bus is the system bus */
34161e115a5SMichael Buesch 	SSB_BUSTYPE_PCI,	/* SSB is connected to PCI bus */
34261e115a5SMichael Buesch 	SSB_BUSTYPE_PCMCIA,	/* SSB is connected to PCMCIA bus */
34324ea602eSAlbert Herranz 	SSB_BUSTYPE_SDIO,	/* SSB is connected to SDIO bus */
34461e115a5SMichael Buesch };
34561e115a5SMichael Buesch 
34661e115a5SMichael Buesch /* board_vendor */
34761e115a5SMichael Buesch #define SSB_BOARDVENDOR_BCM	0x14E4	/* Broadcom */
34861e115a5SMichael Buesch #define SSB_BOARDVENDOR_DELL	0x1028	/* Dell */
34961e115a5SMichael Buesch #define SSB_BOARDVENDOR_HP	0x0E11	/* HP */
35061e115a5SMichael Buesch /* board_type */
351c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94301CB	0x0406
352c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94301MP	0x0407
353c5116e9dSRafał Miłecki #define SSB_BOARD_BU4309	0x040A
354c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94309CB	0x040B
355c5116e9dSRafał Miłecki #define SSB_BOARD_BCM4309MP	0x040C
356c5116e9dSRafał Miłecki #define SSB_BOARD_BU4306	0x0416
35761e115a5SMichael Buesch #define SSB_BOARD_BCM94306MP	0x0418
35861e115a5SMichael Buesch #define SSB_BOARD_BCM4309G	0x0421
35961e115a5SMichael Buesch #define SSB_BOARD_BCM4306CB	0x0417
360c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306PC	0x0425	/* pcmcia 3.3v 4306 card */
361c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306CBSG	0x042B	/* with SiGe PA */
362c5116e9dSRafał Miłecki #define SSB_BOARD_PCSG94306	0x042D	/* with SiGe PA */
363c5116e9dSRafał Miłecki #define SSB_BOARD_BU4704SD	0x042E	/* with sdram */
364c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94704AGR	0x042F	/* dual 11a/11g Router */
365c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94308MP	0x0430	/* 11a-only minipci */
366c5116e9dSRafał Miłecki #define SSB_BOARD_BU4318	0x0447
367c5116e9dSRafał Miłecki #define SSB_BOARD_CB4318	0x0448
368c5116e9dSRafał Miłecki #define SSB_BOARD_MPG4318	0x0449
36961e115a5SMichael Buesch #define SSB_BOARD_MP4318	0x044A
370c5116e9dSRafał Miłecki #define SSB_BOARD_SD4318	0x044B
371c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306P	0x044C	/* with SiGe */
372c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94303MP	0x044E
373c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPM	0x0450
374c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPL	0x0453
375c5116e9dSRafał Miłecki #define SSB_BOARD_PC4303	0x0454	/* pcmcia */
376c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPLNA	0x0457
377c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPH	0x045B
378c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306PCIV	0x045C
379c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94318MPGH	0x0463
380c5116e9dSRafał Miłecki #define SSB_BOARD_BU4311	0x0464
381c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94311MC	0x0465
382c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94311MCAG	0x0466
383c5116e9dSRafał Miłecki /* 4321 boards */
384c5116e9dSRafał Miłecki #define SSB_BOARD_BU4321	0x046B
385c5116e9dSRafał Miłecki #define SSB_BOARD_BU4321E	0x047C
386c5116e9dSRafał Miłecki #define SSB_BOARD_MP4321	0x046C
387c5116e9dSRafał Miłecki #define SSB_BOARD_CB2_4321	0x046D
388c5116e9dSRafał Miłecki #define SSB_BOARD_CB2_4321_AG	0x0066
389c5116e9dSRafał Miłecki #define SSB_BOARD_MC4321	0x046E
390c5116e9dSRafał Miłecki /* 4325 boards */
391c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325DEVBU	0x0490
392c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325BGABU	0x0491
393c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGWB	0x0492
394c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL	0x04AA
395c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL2	0x04C6
396c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL3	0x04C9
397c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDABGWBA	0x04E1
398c5116e9dSRafał Miłecki /* 4322 boards */
399c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322MC	0x04A4
400c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322USB	0x04A8	/* dualband */
401c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322HM	0x04B0
402c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322USB2D	0x04Bf	/* single band discrete front end */
403c5116e9dSRafał Miłecki /* 4312 boards */
404c5116e9dSRafał Miłecki #define SSB_BOARD_BU4312	0x048A
405c5116e9dSRafał Miłecki #define SSB_BOARD_BCM4312MCGSG	0x04B5
40661e115a5SMichael Buesch /* chip_package */
40761e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712S	1	/* Small 200pin 4712 */
40861e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712M	2	/* Medium 225pin 4712 */
40961e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712L	0	/* Large 340pin 4712 */
41061e115a5SMichael Buesch 
41161e115a5SMichael Buesch #include <linux/ssb/ssb_driver_chipcommon.h>
41261e115a5SMichael Buesch #include <linux/ssb/ssb_driver_mips.h>
41361e115a5SMichael Buesch #include <linux/ssb/ssb_driver_extif.h>
41461e115a5SMichael Buesch #include <linux/ssb/ssb_driver_pci.h>
41561e115a5SMichael Buesch 
41661e115a5SMichael Buesch struct ssb_bus {
41761e115a5SMichael Buesch 	/* The MMIO area. */
41861e115a5SMichael Buesch 	void __iomem *mmio;
41961e115a5SMichael Buesch 
42061e115a5SMichael Buesch 	const struct ssb_bus_ops *ops;
42161e115a5SMichael Buesch 
4228b45499cSMichael Buesch 	/* The core currently mapped into the MMIO window.
4238b45499cSMichael Buesch 	 * Not valid on all host-buses. So don't use outside of SSB. */
42461e115a5SMichael Buesch 	struct ssb_device *mapped_device;
42524ea602eSAlbert Herranz 	union {
42661e115a5SMichael Buesch 		/* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
42761e115a5SMichael Buesch 		u8 mapped_pcmcia_seg;
42824ea602eSAlbert Herranz 		/* Current SSB base address window for SDIO. */
42924ea602eSAlbert Herranz 		u32 sdio_sbaddr;
43024ea602eSAlbert Herranz 	};
431993e1c78SMichael Buesch 	/* Lock for core and segment switching.
432993e1c78SMichael Buesch 	 * On PCMCIA-host busses this is used to protect the whole MMIO access. */
43361e115a5SMichael Buesch 	spinlock_t bar_lock;
43461e115a5SMichael Buesch 
4358b45499cSMichael Buesch 	/* The host-bus this backplane is running on. */
43661e115a5SMichael Buesch 	enum ssb_bustype bustype;
4378b45499cSMichael Buesch 	/* Pointers to the host-bus. Check bustype before using any of these pointers. */
4388b45499cSMichael Buesch 	union {
43961e115a5SMichael Buesch 		/* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
44061e115a5SMichael Buesch 		struct pci_dev *host_pci;
44161e115a5SMichael Buesch 		/* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
44261e115a5SMichael Buesch 		struct pcmcia_device *host_pcmcia;
44324ea602eSAlbert Herranz 		/* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */
44424ea602eSAlbert Herranz 		struct sdio_func *host_sdio;
4458b45499cSMichael Buesch 	};
44624ea602eSAlbert Herranz 
44724ea602eSAlbert Herranz 	/* See enum ssb_quirks */
44824ea602eSAlbert Herranz 	unsigned int quirks;
44961e115a5SMichael Buesch 
450e7ec2e32SMichael Buesch #ifdef CONFIG_SSB_SPROM
45161e115a5SMichael Buesch 	/* Mutex to protect the SPROM writing. */
452e7ec2e32SMichael Buesch 	struct mutex sprom_mutex;
45361e115a5SMichael Buesch #endif
45461e115a5SMichael Buesch 
45561e115a5SMichael Buesch 	/* ID information about the Chip. */
45661e115a5SMichael Buesch 	u16 chip_id;
457ce57d9e6SRafał Miłecki 	u8 chip_rev;
458ea2db495SRafał Miłecki 	u16 sprom_offset;
459c272ef44SLarry Finger 	u16 sprom_size;		/* number of words in sprom */
46061e115a5SMichael Buesch 	u8 chip_package;
46161e115a5SMichael Buesch 
46261e115a5SMichael Buesch 	/* List of devices (cores) on the backplane. */
46361e115a5SMichael Buesch 	struct ssb_device devices[SSB_MAX_NR_CORES];
46461e115a5SMichael Buesch 	u8 nr_devices;
46561e115a5SMichael Buesch 
46661e115a5SMichael Buesch 	/* Software ID number for this bus. */
46761e115a5SMichael Buesch 	unsigned int busnumber;
46861e115a5SMichael Buesch 
46961e115a5SMichael Buesch 	/* The ChipCommon device (if available). */
47061e115a5SMichael Buesch 	struct ssb_chipcommon chipco;
47161e115a5SMichael Buesch 	/* The PCI-core device (if available). */
47261e115a5SMichael Buesch 	struct ssb_pcicore pcicore;
47361e115a5SMichael Buesch 	/* The MIPS-core device (if available). */
47461e115a5SMichael Buesch 	struct ssb_mipscore mipscore;
47561e115a5SMichael Buesch 	/* The EXTif-core device (if available). */
47661e115a5SMichael Buesch 	struct ssb_extif extif;
47761e115a5SMichael Buesch 
47861e115a5SMichael Buesch 	/* The following structure elements are not available in early
47961e115a5SMichael Buesch 	 * SSB initialization. Though, they are available for regular
48061e115a5SMichael Buesch 	 * registered drivers at any stage. So be careful when
48161e115a5SMichael Buesch 	 * using them in the ssb core code. */
48261e115a5SMichael Buesch 
48361e115a5SMichael Buesch 	/* ID information about the PCB. */
48461e115a5SMichael Buesch 	struct ssb_boardinfo boardinfo;
48561e115a5SMichael Buesch 	/* Contents of the SPROM. */
48661e115a5SMichael Buesch 	struct ssb_sprom sprom;
4877cb44615SMichael Buesch 	/* If the board has a cardbus slot, this is set to true. */
4887cb44615SMichael Buesch 	bool has_cardbus_slot;
48961e115a5SMichael Buesch 
49053521d8cSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED
49153521d8cSMichael Buesch 	/* Lock for GPIO register access. */
49253521d8cSMichael Buesch 	spinlock_t gpio_lock;
493bde327efSHauke Mehrtens 	struct platform_device *watchdog;
49453521d8cSMichael Buesch #endif /* EMBEDDED */
495ec43b08bSHauke Mehrtens #ifdef CONFIG_SSB_DRIVER_GPIO
496ec43b08bSHauke Mehrtens 	struct gpio_chip gpio;
4977c1bc0daSRafał Miłecki 	struct irq_domain *irq_domain;
498ec43b08bSHauke Mehrtens #endif /* DRIVER_GPIO */
49953521d8cSMichael Buesch 
50061e115a5SMichael Buesch 	/* Internal-only stuff follows. Do not touch. */
50161e115a5SMichael Buesch 	struct list_head list;
50261e115a5SMichael Buesch 	/* Is the bus already powered up? */
50361e115a5SMichael Buesch 	bool powered_up;
50461e115a5SMichael Buesch 	int power_warn_count;
50561e115a5SMichael Buesch };
50661e115a5SMichael Buesch 
50724ea602eSAlbert Herranz enum ssb_quirks {
50824ea602eSAlbert Herranz 	/* SDIO connected card requires performing a read after writing a 32-bit value */
50924ea602eSAlbert Herranz 	SSB_QUIRK_SDIO_READ_AFTER_WRITE32	= (1 << 0),
51024ea602eSAlbert Herranz };
51124ea602eSAlbert Herranz 
51261e115a5SMichael Buesch /* The initialization-invariants. */
51361e115a5SMichael Buesch struct ssb_init_invariants {
5147cb44615SMichael Buesch 	/* Versioning information about the PCB. */
51561e115a5SMichael Buesch 	struct ssb_boardinfo boardinfo;
5167cb44615SMichael Buesch 	/* The SPROM information. That's either stored in an
5177cb44615SMichael Buesch 	 * EEPROM or NVRAM on the board. */
51861e115a5SMichael Buesch 	struct ssb_sprom sprom;
5197cb44615SMichael Buesch 	/* If the board has a cardbus slot, this is set to true. */
5207cb44615SMichael Buesch 	bool has_cardbus_slot;
52161e115a5SMichael Buesch };
52261e115a5SMichael Buesch /* Type of function to fetch the invariants. */
52361e115a5SMichael Buesch typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
52461e115a5SMichael Buesch 				     struct ssb_init_invariants *iv);
52561e115a5SMichael Buesch 
526541c9a84SRafał Miłecki /* Register SoC bus. */
527541c9a84SRafał Miłecki extern int ssb_bus_host_soc_register(struct ssb_bus *bus,
528541c9a84SRafał Miłecki 				     unsigned long baseaddr);
52961e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST
53061e115a5SMichael Buesch extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
53161e115a5SMichael Buesch 				   struct pci_dev *host_pci);
53261e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
53361e115a5SMichael Buesch #ifdef CONFIG_SSB_PCMCIAHOST
53461e115a5SMichael Buesch extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
53561e115a5SMichael Buesch 				      struct pcmcia_device *pcmcia_dev,
53661e115a5SMichael Buesch 				      unsigned long baseaddr);
53761e115a5SMichael Buesch #endif /* CONFIG_SSB_PCMCIAHOST */
53824ea602eSAlbert Herranz #ifdef CONFIG_SSB_SDIOHOST
53924ea602eSAlbert Herranz extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
54024ea602eSAlbert Herranz 				    struct sdio_func *sdio_func,
54124ea602eSAlbert Herranz 				    unsigned int quirks);
54224ea602eSAlbert Herranz #endif /* CONFIG_SSB_SDIOHOST */
54324ea602eSAlbert Herranz 
54461e115a5SMichael Buesch 
54561e115a5SMichael Buesch extern void ssb_bus_unregister(struct ssb_bus *bus);
54661e115a5SMichael Buesch 
547d53cdbb9SJohn W. Linville /* Does the device have an SPROM? */
548d53cdbb9SJohn W. Linville extern bool ssb_is_sprom_available(struct ssb_bus *bus);
549d53cdbb9SJohn W. Linville 
550e79c1ba8SMichael Buesch /* Set a fallback SPROM.
551e79c1ba8SMichael Buesch  * See kdoc at the function definition for complete documentation. */
552b3ae52b6SHauke Mehrtens extern int ssb_arch_register_fallback_sprom(
553b3ae52b6SHauke Mehrtens 		int (*sprom_callback)(struct ssb_bus *bus,
554b3ae52b6SHauke Mehrtens 		struct ssb_sprom *out));
555e79c1ba8SMichael Buesch 
5568fe2b65aSMichael Buesch /* Suspend a SSB bus.
5578fe2b65aSMichael Buesch  * Call this from the parent bus suspend routine. */
5588fe2b65aSMichael Buesch extern int ssb_bus_suspend(struct ssb_bus *bus);
5598fe2b65aSMichael Buesch /* Resume a SSB bus.
5608fe2b65aSMichael Buesch  * Call this from the parent bus resume routine. */
5618fe2b65aSMichael Buesch extern int ssb_bus_resume(struct ssb_bus *bus);
5628fe2b65aSMichael Buesch 
56361e115a5SMichael Buesch extern u32 ssb_clockspeed(struct ssb_bus *bus);
56461e115a5SMichael Buesch 
56561e115a5SMichael Buesch /* Is the device enabled in hardware? */
56661e115a5SMichael Buesch int ssb_device_is_enabled(struct ssb_device *dev);
56761e115a5SMichael Buesch /* Enable a device and pass device-specific SSB_TMSLOW flags.
56861e115a5SMichael Buesch  * If no device-specific flags are available, use 0. */
56961e115a5SMichael Buesch void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
57061e115a5SMichael Buesch /* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
57161e115a5SMichael Buesch void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
57261e115a5SMichael Buesch 
57361e115a5SMichael Buesch 
57461e115a5SMichael Buesch /* Device MMIO register read/write functions. */
ssb_read8(struct ssb_device * dev,u16 offset)575ffc7689dSMichael Buesch static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
576ffc7689dSMichael Buesch {
577ffc7689dSMichael Buesch 	return dev->ops->read8(dev, offset);
578ffc7689dSMichael Buesch }
ssb_read16(struct ssb_device * dev,u16 offset)57961e115a5SMichael Buesch static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
58061e115a5SMichael Buesch {
58161e115a5SMichael Buesch 	return dev->ops->read16(dev, offset);
58261e115a5SMichael Buesch }
ssb_read32(struct ssb_device * dev,u16 offset)58361e115a5SMichael Buesch static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
58461e115a5SMichael Buesch {
58561e115a5SMichael Buesch 	return dev->ops->read32(dev, offset);
58661e115a5SMichael Buesch }
ssb_write8(struct ssb_device * dev,u16 offset,u8 value)587ffc7689dSMichael Buesch static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
588ffc7689dSMichael Buesch {
589ffc7689dSMichael Buesch 	dev->ops->write8(dev, offset, value);
590ffc7689dSMichael Buesch }
ssb_write16(struct ssb_device * dev,u16 offset,u16 value)59161e115a5SMichael Buesch static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
59261e115a5SMichael Buesch {
59361e115a5SMichael Buesch 	dev->ops->write16(dev, offset, value);
59461e115a5SMichael Buesch }
ssb_write32(struct ssb_device * dev,u16 offset,u32 value)59561e115a5SMichael Buesch static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
59661e115a5SMichael Buesch {
59761e115a5SMichael Buesch 	dev->ops->write32(dev, offset, value);
59861e115a5SMichael Buesch }
599d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO
ssb_block_read(struct ssb_device * dev,void * buffer,size_t count,u16 offset,u8 reg_width)600d625a29bSMichael Buesch static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
601d625a29bSMichael Buesch 				  size_t count, u16 offset, u8 reg_width)
602d625a29bSMichael Buesch {
603d625a29bSMichael Buesch 	dev->ops->block_read(dev, buffer, count, offset, reg_width);
604d625a29bSMichael Buesch }
605d625a29bSMichael Buesch 
ssb_block_write(struct ssb_device * dev,const void * buffer,size_t count,u16 offset,u8 reg_width)606d625a29bSMichael Buesch static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
607d625a29bSMichael Buesch 				   size_t count, u16 offset, u8 reg_width)
608d625a29bSMichael Buesch {
609d625a29bSMichael Buesch 	dev->ops->block_write(dev, buffer, count, offset, reg_width);
610d625a29bSMichael Buesch }
611d625a29bSMichael Buesch #endif /* CONFIG_SSB_BLOCKIO */
61261e115a5SMichael Buesch 
61361e115a5SMichael Buesch 
614f225763aSMichael Buesch /* The SSB DMA API. Use this API for any DMA operation on the device.
615f225763aSMichael Buesch  * This API basically is a wrapper that calls the correct DMA API for
616f225763aSMichael Buesch  * the host device type the SSB device is attached to. */
617f225763aSMichael Buesch 
61861e115a5SMichael Buesch /* Translation (routing) bits that need to be ORed to DMA
61961e115a5SMichael Buesch  * addresses before they are given to a device. */
62061e115a5SMichael Buesch extern u32 ssb_dma_translation(struct ssb_device *dev);
62161e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_MASK	0xC0000000
62261e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_SHIFT	30
62361e115a5SMichael Buesch 
62461e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST
62561e115a5SMichael Buesch /* PCI-host wrapper driver */
62661e115a5SMichael Buesch extern int ssb_pcihost_register(struct pci_driver *driver);
ssb_pcihost_unregister(struct pci_driver * driver)62761e115a5SMichael Buesch static inline void ssb_pcihost_unregister(struct pci_driver *driver)
62861e115a5SMichael Buesch {
62961e115a5SMichael Buesch 	pci_unregister_driver(driver);
63061e115a5SMichael Buesch }
631961d57c8SMiguel Botón 
632961d57c8SMiguel Botón static inline
ssb_pcihost_set_power_state(struct ssb_device * sdev,pci_power_t state)633961d57c8SMiguel Botón void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
634961d57c8SMiguel Botón {
635961d57c8SMiguel Botón 	if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
636961d57c8SMiguel Botón 		pci_set_power_state(sdev->bus->host_pci, state);
637961d57c8SMiguel Botón }
638532031d7SAndrew Morton #else
ssb_pcihost_unregister(struct pci_driver * driver)639532031d7SAndrew Morton static inline void ssb_pcihost_unregister(struct pci_driver *driver)
640532031d7SAndrew Morton {
641532031d7SAndrew Morton }
642532031d7SAndrew Morton 
643532031d7SAndrew Morton static inline
ssb_pcihost_set_power_state(struct ssb_device * sdev,pci_power_t state)644532031d7SAndrew Morton void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
645532031d7SAndrew Morton {
646532031d7SAndrew Morton }
64761e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
64861e115a5SMichael Buesch 
64961e115a5SMichael Buesch 
65061e115a5SMichael Buesch /* If a driver is shutdown or suspended, call this to signal
65161e115a5SMichael Buesch  * that the bus may be completely powered down. SSB will decide,
65261e115a5SMichael Buesch  * if it's really time to power down the bus, based on if there
65361e115a5SMichael Buesch  * are other devices that want to run. */
65461e115a5SMichael Buesch extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
65561e115a5SMichael Buesch /* Before initializing and enabling a device, call this to power-up the bus.
65661e115a5SMichael Buesch  * If you want to allow use of dynamic-power-control, pass the flag.
65761e115a5SMichael Buesch  * Otherwise static always-on powercontrol will be used. */
65861e115a5SMichael Buesch extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
65961e115a5SMichael Buesch 
6608576f815SRafał Miłecki extern void ssb_commit_settings(struct ssb_bus *bus);
66161e115a5SMichael Buesch 
66261e115a5SMichael Buesch /* Various helper functions */
66361e115a5SMichael Buesch extern u32 ssb_admatch_base(u32 adm);
66461e115a5SMichael Buesch extern u32 ssb_admatch_size(u32 adm);
66561e115a5SMichael Buesch 
666aab547ceSMichael Buesch /* PCI device mapping and fixup routines.
667aab547ceSMichael Buesch  * Called from the architecture pcibios init code.
668aab547ceSMichael Buesch  * These are only available on SSB_EMBEDDED configurations. */
669aab547ceSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED
670aab547ceSMichael Buesch int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
671aab547ceSMichael Buesch int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
672aab547ceSMichael Buesch #endif /* CONFIG_SSB_EMBEDDED */
67361e115a5SMichael Buesch 
67461e115a5SMichael Buesch #endif /* LINUX_SSB_H_ */
675