xref: /linux/include/linux/ssb/ssb.h (revision 4f4aa2ec24dc45881849833a439558d3a378028c)
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>
9ec43b08bSHauke Mehrtens #include <linux/gpio.h>
1061e115a5SMichael Buesch #include <linux/mod_devicetable.h>
119c0c7a42SMichael Buesch #include <linux/dma-mapping.h>
12bde327efSHauke Mehrtens #include <linux/platform_device.h>
1361e115a5SMichael Buesch 
1461e115a5SMichael Buesch #include <linux/ssb/ssb_regs.h>
1561e115a5SMichael Buesch 
1661e115a5SMichael Buesch 
1761e115a5SMichael Buesch struct pcmcia_device;
1861e115a5SMichael Buesch struct ssb_bus;
1961e115a5SMichael Buesch struct ssb_driver;
2061e115a5SMichael Buesch 
21b0f70292SRafał Miłecki struct ssb_sprom_core_pwr_info {
22b0f70292SRafał Miłecki 	u8 itssi_2g, itssi_5g;
23b0f70292SRafał Miłecki 	u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
243b64e6f9SHauke Mehrtens 	u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
25b0f70292SRafał Miłecki };
26b0f70292SRafał Miłecki 
2761e115a5SMichael Buesch struct ssb_sprom {
2861e115a5SMichael Buesch 	u8 revision;
2985249828SHauke Mehrtens 	u8 il0mac[6] __aligned(sizeof(u16));	/* MAC address for 802.11b/g */
3085249828SHauke Mehrtens 	u8 et0mac[6] __aligned(sizeof(u16));	/* MAC address for Ethernet */
3185249828SHauke Mehrtens 	u8 et1mac[6] __aligned(sizeof(u16));	/* MAC address for 802.11a */
32ac82fab4SLarry Finger 	u8 et0phyaddr;		/* MII address for enet0 */
33ac82fab4SLarry Finger 	u8 et1phyaddr;		/* MII address for enet1 */
34e861b98dSMichael Buesch 	u8 et0mdcport;		/* MDIO for enet0 */
35e861b98dSMichael Buesch 	u8 et1mdcport;		/* MDIO for enet1 */
36*4f4aa2ecSRafał Miłecki 	u16 dev_id;		/* Device ID overriding e.g. PCI ID */
37e2d646ceSRafał Miłecki 	u16 board_rev;		/* Board revision number from SPROM. */
3852aa63f5SHauke Mehrtens 	u16 board_num;		/* Board number from SPROM. */
3952aa63f5SHauke Mehrtens 	u16 board_type;		/* Board type from SPROM. */
40ac82fab4SLarry Finger 	u8 country_code;	/* Country Code */
4103a5642bSHauke Mehrtens 	char alpha2[2];		/* Country Code as two chars like EU or US */
42edd8d90bSHauke Mehrtens 	u8 leddc_on_time;	/* LED Powersave Duty Cycle On Count */
43edd8d90bSHauke Mehrtens 	u8 leddc_off_time;	/* LED Powersave Duty Cycle Off Count */
44f679056bSGábor Stefanik 	u8 ant_available_a;	/* 2GHz antenna available bits (up to 4) */
45f679056bSGábor Stefanik 	u8 ant_available_bg;	/* 5GHz antenna available bits (up to 4) */
46ac82fab4SLarry Finger 	u16 pa0b0;
47ac82fab4SLarry Finger 	u16 pa0b1;
48ac82fab4SLarry Finger 	u16 pa0b2;
49ac82fab4SLarry Finger 	u16 pa1b0;
50ac82fab4SLarry Finger 	u16 pa1b1;
51ac82fab4SLarry Finger 	u16 pa1b2;
52f679056bSGábor Stefanik 	u16 pa1lob0;
53f679056bSGábor Stefanik 	u16 pa1lob1;
54f679056bSGábor Stefanik 	u16 pa1lob2;
55f679056bSGábor Stefanik 	u16 pa1hib0;
56f679056bSGábor Stefanik 	u16 pa1hib1;
57f679056bSGábor Stefanik 	u16 pa1hib2;
58ac82fab4SLarry Finger 	u8 gpio0;		/* GPIO pin 0 */
59ac82fab4SLarry Finger 	u8 gpio1;		/* GPIO pin 1 */
60ac82fab4SLarry Finger 	u8 gpio2;		/* GPIO pin 2 */
61ac82fab4SLarry Finger 	u8 gpio3;		/* GPIO pin 3 */
62edd8d90bSHauke Mehrtens 	u8 maxpwr_bg;		/* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
63edd8d90bSHauke Mehrtens 	u8 maxpwr_al;		/* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
64edd8d90bSHauke Mehrtens 	u8 maxpwr_a;		/* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
65edd8d90bSHauke Mehrtens 	u8 maxpwr_ah;		/* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
66ac82fab4SLarry Finger 	u8 itssi_a;		/* Idle TSSI Target for A-PHY */
67ac82fab4SLarry Finger 	u8 itssi_bg;		/* Idle TSSI Target for B/G-PHY */
68f679056bSGábor Stefanik 	u8 tri2g;		/* 2.4GHz TX isolation */
69f679056bSGábor Stefanik 	u8 tri5gl;		/* 5.2GHz TX isolation */
70f679056bSGábor Stefanik 	u8 tri5g;		/* 5.3GHz TX isolation */
71f679056bSGábor Stefanik 	u8 tri5gh;		/* 5.8GHz TX isolation */
72172c69a4SRafał Miłecki 	u8 txpid2g[4];		/* 2GHz TX power index */
73172c69a4SRafał Miłecki 	u8 txpid5gl[4];		/* 4.9 - 5.1GHz TX power index */
74172c69a4SRafał Miłecki 	u8 txpid5g[4];		/* 5.1 - 5.5GHz TX power index */
75172c69a4SRafał Miłecki 	u8 txpid5gh[4];		/* 5.5 - ...GHz TX power index */
76edd8d90bSHauke Mehrtens 	s8 rxpo2g;		/* 2GHz RX power offset */
77edd8d90bSHauke Mehrtens 	s8 rxpo5g;		/* 5GHz RX power offset */
78f679056bSGábor Stefanik 	u8 rssisav2g;		/* 2GHz RSSI params */
79f679056bSGábor Stefanik 	u8 rssismc2g;
80f679056bSGábor Stefanik 	u8 rssismf2g;
81f679056bSGábor Stefanik 	u8 bxa2g;		/* 2GHz BX arch */
82f679056bSGábor Stefanik 	u8 rssisav5g;		/* 5GHz RSSI params */
83f679056bSGábor Stefanik 	u8 rssismc5g;
84f679056bSGábor Stefanik 	u8 rssismf5g;
85f679056bSGábor Stefanik 	u8 bxa5g;		/* 5GHz BX arch */
86f679056bSGábor Stefanik 	u16 cck2gpo;		/* CCK power offset */
87f679056bSGábor Stefanik 	u32 ofdm2gpo;		/* 2.4GHz OFDM power offset */
88f679056bSGábor Stefanik 	u32 ofdm5glpo;		/* 5.2GHz OFDM power offset */
89f679056bSGábor Stefanik 	u32 ofdm5gpo;		/* 5.3GHz OFDM power offset */
90f679056bSGábor Stefanik 	u32 ofdm5ghpo;		/* 5.8GHz OFDM power offset */
91f679056bSGábor Stefanik 	u16 boardflags_lo;	/* Board flags (bits 0-15) */
92f679056bSGábor Stefanik 	u16 boardflags_hi;	/* Board flags (bits 16-31) */
93f679056bSGábor Stefanik 	u16 boardflags2_lo;	/* Board flags (bits 32-47) */
94f679056bSGábor Stefanik 	u16 boardflags2_hi;	/* Board flags (bits 48-63) */
95f679056bSGábor Stefanik 	/* TODO store board flags in a single u64 */
96e861b98dSMichael Buesch 
97b0f70292SRafał Miłecki 	struct ssb_sprom_core_pwr_info core_pwr_info[4];
98b0f70292SRafał Miłecki 
99e861b98dSMichael Buesch 	/* Antenna gain values for up to 4 antennas
100e861b98dSMichael Buesch 	 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
101e861b98dSMichael Buesch 	 * loss in the connectors is bigger than the gain. */
102e861b98dSMichael Buesch 	struct {
103e861b98dSMichael Buesch 		s8 a0, a1, a2, a3;
104e861b98dSMichael Buesch 	} antenna_gain;
105ac82fab4SLarry Finger 
1068a5ac6ecSRafał Miłecki 	struct {
1078a5ac6ecSRafał Miłecki 		struct {
1088a5ac6ecSRafał Miłecki 			u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1098a5ac6ecSRafał Miłecki 		} ghz2;
1108a5ac6ecSRafał Miłecki 		struct {
1118a5ac6ecSRafał Miłecki 			u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
1128a5ac6ecSRafał Miłecki 		} ghz5;
1138a5ac6ecSRafał Miłecki 	} fem;
1148a5ac6ecSRafał Miłecki 
11552aa63f5SHauke Mehrtens 	u16 mcs2gpo[8];
11652aa63f5SHauke Mehrtens 	u16 mcs5gpo[8];
11752aa63f5SHauke Mehrtens 	u16 mcs5glpo[8];
11852aa63f5SHauke Mehrtens 	u16 mcs5ghpo[8];
11952aa63f5SHauke Mehrtens 	u8 opo;
12052aa63f5SHauke Mehrtens 
12152aa63f5SHauke Mehrtens 	u8 rxgainerr2ga[3];
12252aa63f5SHauke Mehrtens 	u8 rxgainerr5gla[3];
12352aa63f5SHauke Mehrtens 	u8 rxgainerr5gma[3];
12452aa63f5SHauke Mehrtens 	u8 rxgainerr5gha[3];
12552aa63f5SHauke Mehrtens 	u8 rxgainerr5gua[3];
12652aa63f5SHauke Mehrtens 
12752aa63f5SHauke Mehrtens 	u8 noiselvl2ga[3];
12852aa63f5SHauke Mehrtens 	u8 noiselvl5gla[3];
12952aa63f5SHauke Mehrtens 	u8 noiselvl5gma[3];
13052aa63f5SHauke Mehrtens 	u8 noiselvl5gha[3];
13152aa63f5SHauke Mehrtens 	u8 noiselvl5gua[3];
13252aa63f5SHauke Mehrtens 
13352aa63f5SHauke Mehrtens 	u8 regrev;
13452aa63f5SHauke Mehrtens 	u8 txchain;
13552aa63f5SHauke Mehrtens 	u8 rxchain;
13652aa63f5SHauke Mehrtens 	u8 antswitch;
13752aa63f5SHauke Mehrtens 	u16 cddpo;
13852aa63f5SHauke Mehrtens 	u16 stbcpo;
13952aa63f5SHauke Mehrtens 	u16 bw40po;
14052aa63f5SHauke Mehrtens 	u16 bwduppo;
14152aa63f5SHauke Mehrtens 
14252aa63f5SHauke Mehrtens 	u8 tempthresh;
14352aa63f5SHauke Mehrtens 	u8 tempoffset;
14452aa63f5SHauke Mehrtens 	u16 rawtempsense;
14552aa63f5SHauke Mehrtens 	u8 measpower;
14652aa63f5SHauke Mehrtens 	u8 tempsense_slope;
14752aa63f5SHauke Mehrtens 	u8 tempcorrx;
14852aa63f5SHauke Mehrtens 	u8 tempsense_option;
14952aa63f5SHauke Mehrtens 	u8 freqoffset_corr;
15052aa63f5SHauke Mehrtens 	u8 iqcal_swp_dis;
15152aa63f5SHauke Mehrtens 	u8 hw_iqcal_en;
15252aa63f5SHauke Mehrtens 	u8 elna2g;
15352aa63f5SHauke Mehrtens 	u8 elna5g;
15452aa63f5SHauke Mehrtens 	u8 phycal_tempdelta;
15552aa63f5SHauke Mehrtens 	u8 temps_period;
15652aa63f5SHauke Mehrtens 	u8 temps_hysteresis;
15752aa63f5SHauke Mehrtens 	u8 measpower1;
15852aa63f5SHauke Mehrtens 	u8 measpower2;
15952aa63f5SHauke Mehrtens 	u8 pcieingress_war;
16052aa63f5SHauke Mehrtens 
16152aa63f5SHauke Mehrtens 	/* power per rate from sromrev 9 */
16252aa63f5SHauke Mehrtens 	u16 cckbw202gpo;
16352aa63f5SHauke Mehrtens 	u16 cckbw20ul2gpo;
16452aa63f5SHauke Mehrtens 	u32 legofdmbw202gpo;
16552aa63f5SHauke Mehrtens 	u32 legofdmbw20ul2gpo;
16652aa63f5SHauke Mehrtens 	u32 legofdmbw205glpo;
16752aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5glpo;
16852aa63f5SHauke Mehrtens 	u32 legofdmbw205gmpo;
16952aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5gmpo;
17052aa63f5SHauke Mehrtens 	u32 legofdmbw205ghpo;
17152aa63f5SHauke Mehrtens 	u32 legofdmbw20ul5ghpo;
17252aa63f5SHauke Mehrtens 	u32 mcsbw202gpo;
17352aa63f5SHauke Mehrtens 	u32 mcsbw20ul2gpo;
17452aa63f5SHauke Mehrtens 	u32 mcsbw402gpo;
17552aa63f5SHauke Mehrtens 	u32 mcsbw205glpo;
17652aa63f5SHauke Mehrtens 	u32 mcsbw20ul5glpo;
17752aa63f5SHauke Mehrtens 	u32 mcsbw405glpo;
17852aa63f5SHauke Mehrtens 	u32 mcsbw205gmpo;
17952aa63f5SHauke Mehrtens 	u32 mcsbw20ul5gmpo;
18052aa63f5SHauke Mehrtens 	u32 mcsbw405gmpo;
18152aa63f5SHauke Mehrtens 	u32 mcsbw205ghpo;
18252aa63f5SHauke Mehrtens 	u32 mcsbw20ul5ghpo;
18352aa63f5SHauke Mehrtens 	u32 mcsbw405ghpo;
18452aa63f5SHauke Mehrtens 	u16 mcs32po;
18552aa63f5SHauke Mehrtens 	u16 legofdm40duppo;
18652aa63f5SHauke Mehrtens 	u8 sar2g;
18752aa63f5SHauke Mehrtens 	u8 sar5g;
18861e115a5SMichael Buesch };
18961e115a5SMichael Buesch 
19061e115a5SMichael Buesch /* Information about the PCB the circuitry is soldered on. */
19161e115a5SMichael Buesch struct ssb_boardinfo {
19261e115a5SMichael Buesch 	u16 vendor;
19361e115a5SMichael Buesch 	u16 type;
19461e115a5SMichael Buesch };
19561e115a5SMichael Buesch 
19661e115a5SMichael Buesch 
19761e115a5SMichael Buesch struct ssb_device;
19861e115a5SMichael Buesch /* Lowlevel read/write operations on the device MMIO.
19961e115a5SMichael Buesch  * Internal, don't use that outside of ssb. */
20061e115a5SMichael Buesch struct ssb_bus_ops {
201ffc7689dSMichael Buesch 	u8 (*read8)(struct ssb_device *dev, u16 offset);
20261e115a5SMichael Buesch 	u16 (*read16)(struct ssb_device *dev, u16 offset);
20361e115a5SMichael Buesch 	u32 (*read32)(struct ssb_device *dev, u16 offset);
204ffc7689dSMichael Buesch 	void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
20561e115a5SMichael Buesch 	void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
20661e115a5SMichael Buesch 	void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
207d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO
208d625a29bSMichael Buesch 	void (*block_read)(struct ssb_device *dev, void *buffer,
209d625a29bSMichael Buesch 			   size_t count, u16 offset, u8 reg_width);
210d625a29bSMichael Buesch 	void (*block_write)(struct ssb_device *dev, const void *buffer,
211d625a29bSMichael Buesch 			    size_t count, u16 offset, u8 reg_width);
212d625a29bSMichael Buesch #endif
21361e115a5SMichael Buesch };
21461e115a5SMichael Buesch 
21561e115a5SMichael Buesch 
21661e115a5SMichael Buesch /* Core-ID values. */
21761e115a5SMichael Buesch #define SSB_DEV_CHIPCOMMON	0x800
21861e115a5SMichael Buesch #define SSB_DEV_ILINE20		0x801
21961e115a5SMichael Buesch #define SSB_DEV_SDRAM		0x803
22061e115a5SMichael Buesch #define SSB_DEV_PCI		0x804
22161e115a5SMichael Buesch #define SSB_DEV_MIPS		0x805
22261e115a5SMichael Buesch #define SSB_DEV_ETHERNET	0x806
22361e115a5SMichael Buesch #define SSB_DEV_V90		0x807
22461e115a5SMichael Buesch #define SSB_DEV_USB11_HOSTDEV	0x808
22561e115a5SMichael Buesch #define SSB_DEV_ADSL		0x809
22661e115a5SMichael Buesch #define SSB_DEV_ILINE100	0x80A
22761e115a5SMichael Buesch #define SSB_DEV_IPSEC		0x80B
22861e115a5SMichael Buesch #define SSB_DEV_PCMCIA		0x80D
22961e115a5SMichael Buesch #define SSB_DEV_INTERNAL_MEM	0x80E
23061e115a5SMichael Buesch #define SSB_DEV_MEMC_SDRAM	0x80F
23161e115a5SMichael Buesch #define SSB_DEV_EXTIF		0x811
23261e115a5SMichael Buesch #define SSB_DEV_80211		0x812
23361e115a5SMichael Buesch #define SSB_DEV_MIPS_3302	0x816
23461e115a5SMichael Buesch #define SSB_DEV_USB11_HOST	0x817
23561e115a5SMichael Buesch #define SSB_DEV_USB11_DEV	0x818
23661e115a5SMichael Buesch #define SSB_DEV_USB20_HOST	0x819
23761e115a5SMichael Buesch #define SSB_DEV_USB20_DEV	0x81A
23861e115a5SMichael Buesch #define SSB_DEV_SDIO_HOST	0x81B
23961e115a5SMichael Buesch #define SSB_DEV_ROBOSWITCH	0x81C
24061e115a5SMichael Buesch #define SSB_DEV_PARA_ATA	0x81D
24161e115a5SMichael Buesch #define SSB_DEV_SATA_XORDMA	0x81E
24261e115a5SMichael Buesch #define SSB_DEV_ETHERNET_GBIT	0x81F
24361e115a5SMichael Buesch #define SSB_DEV_PCIE		0x820
24461e115a5SMichael Buesch #define SSB_DEV_MIMO_PHY	0x821
24561e115a5SMichael Buesch #define SSB_DEV_SRAM_CTRLR	0x822
24661e115a5SMichael Buesch #define SSB_DEV_MINI_MACPHY	0x823
24761e115a5SMichael Buesch #define SSB_DEV_ARM_1176	0x824
24861e115a5SMichael Buesch #define SSB_DEV_ARM_7TDMI	0x825
249ccaf8c32SHauke Mehrtens #define SSB_DEV_ARM_CM3		0x82A
25061e115a5SMichael Buesch 
25161e115a5SMichael Buesch /* Vendor-ID values */
25261e115a5SMichael Buesch #define SSB_VENDOR_BROADCOM	0x4243
25361e115a5SMichael Buesch 
25461e115a5SMichael Buesch /* Some kernel subsystems poke with dev->drvdata, so we must use the
25561e115a5SMichael Buesch  * following ugly workaround to get from struct device to struct ssb_device */
25661e115a5SMichael Buesch struct __ssb_dev_wrapper {
25761e115a5SMichael Buesch 	struct device dev;
25861e115a5SMichael Buesch 	struct ssb_device *sdev;
25961e115a5SMichael Buesch };
26061e115a5SMichael Buesch 
26161e115a5SMichael Buesch struct ssb_device {
26261e115a5SMichael Buesch 	/* Having a copy of the ops pointer in each dev struct
26361e115a5SMichael Buesch 	 * is an optimization. */
26461e115a5SMichael Buesch 	const struct ssb_bus_ops *ops;
26561e115a5SMichael Buesch 
26614f92952SFUJITA Tomonori 	struct device *dev, *dma_dev;
2674ac58469SMichael Buesch 
26861e115a5SMichael Buesch 	struct ssb_bus *bus;
26961e115a5SMichael Buesch 	struct ssb_device_id id;
27061e115a5SMichael Buesch 
27161e115a5SMichael Buesch 	u8 core_index;
27261e115a5SMichael Buesch 	unsigned int irq;
27361e115a5SMichael Buesch 
27461e115a5SMichael Buesch 	/* Internal-only stuff follows. */
27561e115a5SMichael Buesch 	void *drvdata;		/* Per-device data */
27661e115a5SMichael Buesch 	void *devtypedata;	/* Per-devicetype (eg 802.11) data */
27761e115a5SMichael Buesch };
27861e115a5SMichael Buesch 
27961e115a5SMichael Buesch /* Go from struct device to struct ssb_device. */
28061e115a5SMichael Buesch static inline
28161e115a5SMichael Buesch struct ssb_device * dev_to_ssb_dev(struct device *dev)
28261e115a5SMichael Buesch {
28361e115a5SMichael Buesch 	struct __ssb_dev_wrapper *wrap;
28461e115a5SMichael Buesch 	wrap = container_of(dev, struct __ssb_dev_wrapper, dev);
28561e115a5SMichael Buesch 	return wrap->sdev;
28661e115a5SMichael Buesch }
28761e115a5SMichael Buesch 
28861e115a5SMichael Buesch /* Device specific user data */
28961e115a5SMichael Buesch static inline
29061e115a5SMichael Buesch void ssb_set_drvdata(struct ssb_device *dev, void *data)
29161e115a5SMichael Buesch {
29261e115a5SMichael Buesch 	dev->drvdata = data;
29361e115a5SMichael Buesch }
29461e115a5SMichael Buesch static inline
29561e115a5SMichael Buesch void * ssb_get_drvdata(struct ssb_device *dev)
29661e115a5SMichael Buesch {
29761e115a5SMichael Buesch 	return dev->drvdata;
29861e115a5SMichael Buesch }
29961e115a5SMichael Buesch 
30061e115a5SMichael Buesch /* Devicetype specific user data. This is per device-type (not per device) */
30161e115a5SMichael Buesch void ssb_set_devtypedata(struct ssb_device *dev, void *data);
30261e115a5SMichael Buesch static inline
30361e115a5SMichael Buesch void * ssb_get_devtypedata(struct ssb_device *dev)
30461e115a5SMichael Buesch {
30561e115a5SMichael Buesch 	return dev->devtypedata;
30661e115a5SMichael Buesch }
30761e115a5SMichael Buesch 
30861e115a5SMichael Buesch 
30961e115a5SMichael Buesch struct ssb_driver {
31061e115a5SMichael Buesch 	const char *name;
31161e115a5SMichael Buesch 	const struct ssb_device_id *id_table;
31261e115a5SMichael Buesch 
31361e115a5SMichael Buesch 	int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id);
31461e115a5SMichael Buesch 	void (*remove)(struct ssb_device *dev);
31561e115a5SMichael Buesch 	int (*suspend)(struct ssb_device *dev, pm_message_t state);
31661e115a5SMichael Buesch 	int (*resume)(struct ssb_device *dev);
31761e115a5SMichael Buesch 	void (*shutdown)(struct ssb_device *dev);
31861e115a5SMichael Buesch 
31961e115a5SMichael Buesch 	struct device_driver drv;
32061e115a5SMichael Buesch };
32161e115a5SMichael Buesch #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
32261e115a5SMichael Buesch 
32361e115a5SMichael Buesch extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
324eb5589a8SPaul Gortmaker #define ssb_driver_register(drv) \
325eb5589a8SPaul Gortmaker 	__ssb_driver_register(drv, THIS_MODULE)
326eb5589a8SPaul Gortmaker 
32761e115a5SMichael Buesch extern void ssb_driver_unregister(struct ssb_driver *drv);
32861e115a5SMichael Buesch 
32961e115a5SMichael Buesch 
33061e115a5SMichael Buesch 
33161e115a5SMichael Buesch 
33261e115a5SMichael Buesch enum ssb_bustype {
33361e115a5SMichael Buesch 	SSB_BUSTYPE_SSB,	/* This SSB bus is the system bus */
33461e115a5SMichael Buesch 	SSB_BUSTYPE_PCI,	/* SSB is connected to PCI bus */
33561e115a5SMichael Buesch 	SSB_BUSTYPE_PCMCIA,	/* SSB is connected to PCMCIA bus */
33624ea602eSAlbert Herranz 	SSB_BUSTYPE_SDIO,	/* SSB is connected to SDIO bus */
33761e115a5SMichael Buesch };
33861e115a5SMichael Buesch 
33961e115a5SMichael Buesch /* board_vendor */
34061e115a5SMichael Buesch #define SSB_BOARDVENDOR_BCM	0x14E4	/* Broadcom */
34161e115a5SMichael Buesch #define SSB_BOARDVENDOR_DELL	0x1028	/* Dell */
34261e115a5SMichael Buesch #define SSB_BOARDVENDOR_HP	0x0E11	/* HP */
34361e115a5SMichael Buesch /* board_type */
344c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94301CB	0x0406
345c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94301MP	0x0407
346c5116e9dSRafał Miłecki #define SSB_BOARD_BU4309	0x040A
347c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94309CB	0x040B
348c5116e9dSRafał Miłecki #define SSB_BOARD_BCM4309MP	0x040C
349c5116e9dSRafał Miłecki #define SSB_BOARD_BU4306	0x0416
35061e115a5SMichael Buesch #define SSB_BOARD_BCM94306MP	0x0418
35161e115a5SMichael Buesch #define SSB_BOARD_BCM4309G	0x0421
35261e115a5SMichael Buesch #define SSB_BOARD_BCM4306CB	0x0417
353c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306PC	0x0425	/* pcmcia 3.3v 4306 card */
354c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306CBSG	0x042B	/* with SiGe PA */
355c5116e9dSRafał Miłecki #define SSB_BOARD_PCSG94306	0x042D	/* with SiGe PA */
356c5116e9dSRafał Miłecki #define SSB_BOARD_BU4704SD	0x042E	/* with sdram */
357c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94704AGR	0x042F	/* dual 11a/11g Router */
358c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94308MP	0x0430	/* 11a-only minipci */
359c5116e9dSRafał Miłecki #define SSB_BOARD_BU4318	0x0447
360c5116e9dSRafał Miłecki #define SSB_BOARD_CB4318	0x0448
361c5116e9dSRafał Miłecki #define SSB_BOARD_MPG4318	0x0449
36261e115a5SMichael Buesch #define SSB_BOARD_MP4318	0x044A
363c5116e9dSRafał Miłecki #define SSB_BOARD_SD4318	0x044B
364c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306P	0x044C	/* with SiGe */
365c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94303MP	0x044E
366c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPM	0x0450
367c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPL	0x0453
368c5116e9dSRafał Miłecki #define SSB_BOARD_PC4303	0x0454	/* pcmcia */
369c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPLNA	0x0457
370c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306MPH	0x045B
371c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94306PCIV	0x045C
372c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94318MPGH	0x0463
373c5116e9dSRafał Miłecki #define SSB_BOARD_BU4311	0x0464
374c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94311MC	0x0465
375c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94311MCAG	0x0466
376c5116e9dSRafał Miłecki /* 4321 boards */
377c5116e9dSRafał Miłecki #define SSB_BOARD_BU4321	0x046B
378c5116e9dSRafał Miłecki #define SSB_BOARD_BU4321E	0x047C
379c5116e9dSRafał Miłecki #define SSB_BOARD_MP4321	0x046C
380c5116e9dSRafał Miłecki #define SSB_BOARD_CB2_4321	0x046D
381c5116e9dSRafał Miłecki #define SSB_BOARD_CB2_4321_AG	0x0066
382c5116e9dSRafał Miłecki #define SSB_BOARD_MC4321	0x046E
383c5116e9dSRafał Miłecki /* 4325 boards */
384c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325DEVBU	0x0490
385c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325BGABU	0x0491
386c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGWB	0x0492
387c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL	0x04AA
388c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL2	0x04C6
389c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDGMDL3	0x04C9
390c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94325SDABGWBA	0x04E1
391c5116e9dSRafał Miłecki /* 4322 boards */
392c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322MC	0x04A4
393c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322USB	0x04A8	/* dualband */
394c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322HM	0x04B0
395c5116e9dSRafał Miłecki #define SSB_BOARD_BCM94322USB2D	0x04Bf	/* single band discrete front end */
396c5116e9dSRafał Miłecki /* 4312 boards */
397c5116e9dSRafał Miłecki #define SSB_BOARD_BU4312	0x048A
398c5116e9dSRafał Miłecki #define SSB_BOARD_BCM4312MCGSG	0x04B5
39961e115a5SMichael Buesch /* chip_package */
40061e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712S	1	/* Small 200pin 4712 */
40161e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712M	2	/* Medium 225pin 4712 */
40261e115a5SMichael Buesch #define SSB_CHIPPACK_BCM4712L	0	/* Large 340pin 4712 */
40361e115a5SMichael Buesch 
40461e115a5SMichael Buesch #include <linux/ssb/ssb_driver_chipcommon.h>
40561e115a5SMichael Buesch #include <linux/ssb/ssb_driver_mips.h>
40661e115a5SMichael Buesch #include <linux/ssb/ssb_driver_extif.h>
40761e115a5SMichael Buesch #include <linux/ssb/ssb_driver_pci.h>
40861e115a5SMichael Buesch 
40961e115a5SMichael Buesch struct ssb_bus {
41061e115a5SMichael Buesch 	/* The MMIO area. */
41161e115a5SMichael Buesch 	void __iomem *mmio;
41261e115a5SMichael Buesch 
41361e115a5SMichael Buesch 	const struct ssb_bus_ops *ops;
41461e115a5SMichael Buesch 
4158b45499cSMichael Buesch 	/* The core currently mapped into the MMIO window.
4168b45499cSMichael Buesch 	 * Not valid on all host-buses. So don't use outside of SSB. */
41761e115a5SMichael Buesch 	struct ssb_device *mapped_device;
41824ea602eSAlbert Herranz 	union {
41961e115a5SMichael Buesch 		/* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
42061e115a5SMichael Buesch 		u8 mapped_pcmcia_seg;
42124ea602eSAlbert Herranz 		/* Current SSB base address window for SDIO. */
42224ea602eSAlbert Herranz 		u32 sdio_sbaddr;
42324ea602eSAlbert Herranz 	};
424993e1c78SMichael Buesch 	/* Lock for core and segment switching.
425993e1c78SMichael Buesch 	 * On PCMCIA-host busses this is used to protect the whole MMIO access. */
42661e115a5SMichael Buesch 	spinlock_t bar_lock;
42761e115a5SMichael Buesch 
4288b45499cSMichael Buesch 	/* The host-bus this backplane is running on. */
42961e115a5SMichael Buesch 	enum ssb_bustype bustype;
4308b45499cSMichael Buesch 	/* Pointers to the host-bus. Check bustype before using any of these pointers. */
4318b45499cSMichael Buesch 	union {
43261e115a5SMichael Buesch 		/* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
43361e115a5SMichael Buesch 		struct pci_dev *host_pci;
43461e115a5SMichael Buesch 		/* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
43561e115a5SMichael Buesch 		struct pcmcia_device *host_pcmcia;
43624ea602eSAlbert Herranz 		/* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */
43724ea602eSAlbert Herranz 		struct sdio_func *host_sdio;
4388b45499cSMichael Buesch 	};
43924ea602eSAlbert Herranz 
44024ea602eSAlbert Herranz 	/* See enum ssb_quirks */
44124ea602eSAlbert Herranz 	unsigned int quirks;
44261e115a5SMichael Buesch 
443e7ec2e32SMichael Buesch #ifdef CONFIG_SSB_SPROM
44461e115a5SMichael Buesch 	/* Mutex to protect the SPROM writing. */
445e7ec2e32SMichael Buesch 	struct mutex sprom_mutex;
44661e115a5SMichael Buesch #endif
44761e115a5SMichael Buesch 
44861e115a5SMichael Buesch 	/* ID information about the Chip. */
44961e115a5SMichael Buesch 	u16 chip_id;
450ce57d9e6SRafał Miłecki 	u8 chip_rev;
451ea2db495SRafał Miłecki 	u16 sprom_offset;
452c272ef44SLarry Finger 	u16 sprom_size;		/* number of words in sprom */
45361e115a5SMichael Buesch 	u8 chip_package;
45461e115a5SMichael Buesch 
45561e115a5SMichael Buesch 	/* List of devices (cores) on the backplane. */
45661e115a5SMichael Buesch 	struct ssb_device devices[SSB_MAX_NR_CORES];
45761e115a5SMichael Buesch 	u8 nr_devices;
45861e115a5SMichael Buesch 
45961e115a5SMichael Buesch 	/* Software ID number for this bus. */
46061e115a5SMichael Buesch 	unsigned int busnumber;
46161e115a5SMichael Buesch 
46261e115a5SMichael Buesch 	/* The ChipCommon device (if available). */
46361e115a5SMichael Buesch 	struct ssb_chipcommon chipco;
46461e115a5SMichael Buesch 	/* The PCI-core device (if available). */
46561e115a5SMichael Buesch 	struct ssb_pcicore pcicore;
46661e115a5SMichael Buesch 	/* The MIPS-core device (if available). */
46761e115a5SMichael Buesch 	struct ssb_mipscore mipscore;
46861e115a5SMichael Buesch 	/* The EXTif-core device (if available). */
46961e115a5SMichael Buesch 	struct ssb_extif extif;
47061e115a5SMichael Buesch 
47161e115a5SMichael Buesch 	/* The following structure elements are not available in early
47261e115a5SMichael Buesch 	 * SSB initialization. Though, they are available for regular
47361e115a5SMichael Buesch 	 * registered drivers at any stage. So be careful when
47461e115a5SMichael Buesch 	 * using them in the ssb core code. */
47561e115a5SMichael Buesch 
47661e115a5SMichael Buesch 	/* ID information about the PCB. */
47761e115a5SMichael Buesch 	struct ssb_boardinfo boardinfo;
47861e115a5SMichael Buesch 	/* Contents of the SPROM. */
47961e115a5SMichael Buesch 	struct ssb_sprom sprom;
4807cb44615SMichael Buesch 	/* If the board has a cardbus slot, this is set to true. */
4817cb44615SMichael Buesch 	bool has_cardbus_slot;
48261e115a5SMichael Buesch 
48353521d8cSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED
48453521d8cSMichael Buesch 	/* Lock for GPIO register access. */
48553521d8cSMichael Buesch 	spinlock_t gpio_lock;
486bde327efSHauke Mehrtens 	struct platform_device *watchdog;
48753521d8cSMichael Buesch #endif /* EMBEDDED */
488ec43b08bSHauke Mehrtens #ifdef CONFIG_SSB_DRIVER_GPIO
489ec43b08bSHauke Mehrtens 	struct gpio_chip gpio;
4907c1bc0daSRafał Miłecki 	struct irq_domain *irq_domain;
491ec43b08bSHauke Mehrtens #endif /* DRIVER_GPIO */
49253521d8cSMichael Buesch 
49361e115a5SMichael Buesch 	/* Internal-only stuff follows. Do not touch. */
49461e115a5SMichael Buesch 	struct list_head list;
49561e115a5SMichael Buesch #ifdef CONFIG_SSB_DEBUG
49661e115a5SMichael Buesch 	/* Is the bus already powered up? */
49761e115a5SMichael Buesch 	bool powered_up;
49861e115a5SMichael Buesch 	int power_warn_count;
49961e115a5SMichael Buesch #endif /* DEBUG */
50061e115a5SMichael Buesch };
50161e115a5SMichael Buesch 
50224ea602eSAlbert Herranz enum ssb_quirks {
50324ea602eSAlbert Herranz 	/* SDIO connected card requires performing a read after writing a 32-bit value */
50424ea602eSAlbert Herranz 	SSB_QUIRK_SDIO_READ_AFTER_WRITE32	= (1 << 0),
50524ea602eSAlbert Herranz };
50624ea602eSAlbert Herranz 
50761e115a5SMichael Buesch /* The initialization-invariants. */
50861e115a5SMichael Buesch struct ssb_init_invariants {
5097cb44615SMichael Buesch 	/* Versioning information about the PCB. */
51061e115a5SMichael Buesch 	struct ssb_boardinfo boardinfo;
5117cb44615SMichael Buesch 	/* The SPROM information. That's either stored in an
5127cb44615SMichael Buesch 	 * EEPROM or NVRAM on the board. */
51361e115a5SMichael Buesch 	struct ssb_sprom sprom;
5147cb44615SMichael Buesch 	/* If the board has a cardbus slot, this is set to true. */
5157cb44615SMichael Buesch 	bool has_cardbus_slot;
51661e115a5SMichael Buesch };
51761e115a5SMichael Buesch /* Type of function to fetch the invariants. */
51861e115a5SMichael Buesch typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
51961e115a5SMichael Buesch 				     struct ssb_init_invariants *iv);
52061e115a5SMichael Buesch 
52161e115a5SMichael Buesch /* Register a SSB system bus. get_invariants() is called after the
52261e115a5SMichael Buesch  * basic system devices are initialized.
52361e115a5SMichael Buesch  * The invariants are usually fetched from some NVRAM.
52461e115a5SMichael Buesch  * Put the invariants into the struct pointed to by iv. */
52561e115a5SMichael Buesch extern int ssb_bus_ssbbus_register(struct ssb_bus *bus,
52661e115a5SMichael Buesch 				   unsigned long baseaddr,
52761e115a5SMichael Buesch 				   ssb_invariants_func_t get_invariants);
52861e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST
52961e115a5SMichael Buesch extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
53061e115a5SMichael Buesch 				   struct pci_dev *host_pci);
53161e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
53261e115a5SMichael Buesch #ifdef CONFIG_SSB_PCMCIAHOST
53361e115a5SMichael Buesch extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
53461e115a5SMichael Buesch 				      struct pcmcia_device *pcmcia_dev,
53561e115a5SMichael Buesch 				      unsigned long baseaddr);
53661e115a5SMichael Buesch #endif /* CONFIG_SSB_PCMCIAHOST */
53724ea602eSAlbert Herranz #ifdef CONFIG_SSB_SDIOHOST
53824ea602eSAlbert Herranz extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
53924ea602eSAlbert Herranz 				    struct sdio_func *sdio_func,
54024ea602eSAlbert Herranz 				    unsigned int quirks);
54124ea602eSAlbert Herranz #endif /* CONFIG_SSB_SDIOHOST */
54224ea602eSAlbert Herranz 
54361e115a5SMichael Buesch 
54461e115a5SMichael Buesch extern void ssb_bus_unregister(struct ssb_bus *bus);
54561e115a5SMichael Buesch 
546d53cdbb9SJohn W. Linville /* Does the device have an SPROM? */
547d53cdbb9SJohn W. Linville extern bool ssb_is_sprom_available(struct ssb_bus *bus);
548d53cdbb9SJohn W. Linville 
549e79c1ba8SMichael Buesch /* Set a fallback SPROM.
550e79c1ba8SMichael Buesch  * See kdoc at the function definition for complete documentation. */
551b3ae52b6SHauke Mehrtens extern int ssb_arch_register_fallback_sprom(
552b3ae52b6SHauke Mehrtens 		int (*sprom_callback)(struct ssb_bus *bus,
553b3ae52b6SHauke Mehrtens 		struct ssb_sprom *out));
554e79c1ba8SMichael Buesch 
5558fe2b65aSMichael Buesch /* Suspend a SSB bus.
5568fe2b65aSMichael Buesch  * Call this from the parent bus suspend routine. */
5578fe2b65aSMichael Buesch extern int ssb_bus_suspend(struct ssb_bus *bus);
5588fe2b65aSMichael Buesch /* Resume a SSB bus.
5598fe2b65aSMichael Buesch  * Call this from the parent bus resume routine. */
5608fe2b65aSMichael Buesch extern int ssb_bus_resume(struct ssb_bus *bus);
5618fe2b65aSMichael Buesch 
56261e115a5SMichael Buesch extern u32 ssb_clockspeed(struct ssb_bus *bus);
56361e115a5SMichael Buesch 
56461e115a5SMichael Buesch /* Is the device enabled in hardware? */
56561e115a5SMichael Buesch int ssb_device_is_enabled(struct ssb_device *dev);
56661e115a5SMichael Buesch /* Enable a device and pass device-specific SSB_TMSLOW flags.
56761e115a5SMichael Buesch  * If no device-specific flags are available, use 0. */
56861e115a5SMichael Buesch void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
56961e115a5SMichael Buesch /* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
57061e115a5SMichael Buesch void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
57161e115a5SMichael Buesch 
57261e115a5SMichael Buesch 
57361e115a5SMichael Buesch /* Device MMIO register read/write functions. */
574ffc7689dSMichael Buesch static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
575ffc7689dSMichael Buesch {
576ffc7689dSMichael Buesch 	return dev->ops->read8(dev, offset);
577ffc7689dSMichael Buesch }
57861e115a5SMichael Buesch static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
57961e115a5SMichael Buesch {
58061e115a5SMichael Buesch 	return dev->ops->read16(dev, offset);
58161e115a5SMichael Buesch }
58261e115a5SMichael Buesch static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
58361e115a5SMichael Buesch {
58461e115a5SMichael Buesch 	return dev->ops->read32(dev, offset);
58561e115a5SMichael Buesch }
586ffc7689dSMichael Buesch static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
587ffc7689dSMichael Buesch {
588ffc7689dSMichael Buesch 	dev->ops->write8(dev, offset, value);
589ffc7689dSMichael Buesch }
59061e115a5SMichael Buesch static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
59161e115a5SMichael Buesch {
59261e115a5SMichael Buesch 	dev->ops->write16(dev, offset, value);
59361e115a5SMichael Buesch }
59461e115a5SMichael Buesch static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
59561e115a5SMichael Buesch {
59661e115a5SMichael Buesch 	dev->ops->write32(dev, offset, value);
59761e115a5SMichael Buesch }
598d625a29bSMichael Buesch #ifdef CONFIG_SSB_BLOCKIO
599d625a29bSMichael Buesch static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
600d625a29bSMichael Buesch 				  size_t count, u16 offset, u8 reg_width)
601d625a29bSMichael Buesch {
602d625a29bSMichael Buesch 	dev->ops->block_read(dev, buffer, count, offset, reg_width);
603d625a29bSMichael Buesch }
604d625a29bSMichael Buesch 
605d625a29bSMichael Buesch static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
606d625a29bSMichael Buesch 				   size_t count, u16 offset, u8 reg_width)
607d625a29bSMichael Buesch {
608d625a29bSMichael Buesch 	dev->ops->block_write(dev, buffer, count, offset, reg_width);
609d625a29bSMichael Buesch }
610d625a29bSMichael Buesch #endif /* CONFIG_SSB_BLOCKIO */
61161e115a5SMichael Buesch 
61261e115a5SMichael Buesch 
613f225763aSMichael Buesch /* The SSB DMA API. Use this API for any DMA operation on the device.
614f225763aSMichael Buesch  * This API basically is a wrapper that calls the correct DMA API for
615f225763aSMichael Buesch  * the host device type the SSB device is attached to. */
616f225763aSMichael Buesch 
61761e115a5SMichael Buesch /* Translation (routing) bits that need to be ORed to DMA
61861e115a5SMichael Buesch  * addresses before they are given to a device. */
61961e115a5SMichael Buesch extern u32 ssb_dma_translation(struct ssb_device *dev);
62061e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_MASK	0xC0000000
62161e115a5SMichael Buesch #define SSB_DMA_TRANSLATION_SHIFT	30
62261e115a5SMichael Buesch 
623f225763aSMichael Buesch static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev)
624f225763aSMichael Buesch {
625f225763aSMichael Buesch #ifdef CONFIG_SSB_DEBUG
626f225763aSMichael Buesch 	printk(KERN_ERR "SSB: BUG! Calling DMA API for "
627f225763aSMichael Buesch 	       "unsupported bustype %d\n", dev->bus->bustype);
628f225763aSMichael Buesch #endif /* DEBUG */
629f225763aSMichael Buesch }
630f225763aSMichael Buesch 
63161e115a5SMichael Buesch #ifdef CONFIG_SSB_PCIHOST
63261e115a5SMichael Buesch /* PCI-host wrapper driver */
63361e115a5SMichael Buesch extern int ssb_pcihost_register(struct pci_driver *driver);
63461e115a5SMichael Buesch static inline void ssb_pcihost_unregister(struct pci_driver *driver)
63561e115a5SMichael Buesch {
63661e115a5SMichael Buesch 	pci_unregister_driver(driver);
63761e115a5SMichael Buesch }
638961d57c8SMiguel Botón 
639961d57c8SMiguel Botón static inline
640961d57c8SMiguel Botón void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
641961d57c8SMiguel Botón {
642961d57c8SMiguel Botón 	if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
643961d57c8SMiguel Botón 		pci_set_power_state(sdev->bus->host_pci, state);
644961d57c8SMiguel Botón }
645532031d7SAndrew Morton #else
646532031d7SAndrew Morton static inline void ssb_pcihost_unregister(struct pci_driver *driver)
647532031d7SAndrew Morton {
648532031d7SAndrew Morton }
649532031d7SAndrew Morton 
650532031d7SAndrew Morton static inline
651532031d7SAndrew Morton void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
652532031d7SAndrew Morton {
653532031d7SAndrew Morton }
65461e115a5SMichael Buesch #endif /* CONFIG_SSB_PCIHOST */
65561e115a5SMichael Buesch 
65661e115a5SMichael Buesch 
65761e115a5SMichael Buesch /* If a driver is shutdown or suspended, call this to signal
65861e115a5SMichael Buesch  * that the bus may be completely powered down. SSB will decide,
65961e115a5SMichael Buesch  * if it's really time to power down the bus, based on if there
66061e115a5SMichael Buesch  * are other devices that want to run. */
66161e115a5SMichael Buesch extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
66261e115a5SMichael Buesch /* Before initializing and enabling a device, call this to power-up the bus.
66361e115a5SMichael Buesch  * If you want to allow use of dynamic-power-control, pass the flag.
66461e115a5SMichael Buesch  * Otherwise static always-on powercontrol will be used. */
66561e115a5SMichael Buesch extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
66661e115a5SMichael Buesch 
6678576f815SRafał Miłecki extern void ssb_commit_settings(struct ssb_bus *bus);
66861e115a5SMichael Buesch 
66961e115a5SMichael Buesch /* Various helper functions */
67061e115a5SMichael Buesch extern u32 ssb_admatch_base(u32 adm);
67161e115a5SMichael Buesch extern u32 ssb_admatch_size(u32 adm);
67261e115a5SMichael Buesch 
673aab547ceSMichael Buesch /* PCI device mapping and fixup routines.
674aab547ceSMichael Buesch  * Called from the architecture pcibios init code.
675aab547ceSMichael Buesch  * These are only available on SSB_EMBEDDED configurations. */
676aab547ceSMichael Buesch #ifdef CONFIG_SSB_EMBEDDED
677aab547ceSMichael Buesch int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
678aab547ceSMichael Buesch int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
679aab547ceSMichael Buesch #endif /* CONFIG_SSB_EMBEDDED */
68061e115a5SMichael Buesch 
68161e115a5SMichael Buesch #endif /* LINUX_SSB_H_ */
682