xref: /linux/drivers/net/wireless/broadcom/b43/bus.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef B43_BUS_H_
3 #define B43_BUS_H_
4 
5 enum b43_bus_type {
6 #ifdef CONFIG_B43_BCMA
7 	B43_BUS_BCMA,
8 #endif
9 #ifdef CONFIG_B43_SSB
10 	B43_BUS_SSB,
11 #endif
12 };
13 
14 struct b43_bus_dev {
15 	enum b43_bus_type bus_type;
16 	union {
17 		struct bcma_device *bdev;
18 		struct ssb_device *sdev;
19 	};
20 
21 	int (*bus_may_powerdown)(struct b43_bus_dev *dev);
22 	int (*bus_powerup)(struct b43_bus_dev *dev, bool dynamic_pctl);
23 	int (*device_is_enabled)(struct b43_bus_dev *dev);
24 	void (*device_enable)(struct b43_bus_dev *dev,
25 			      u32 core_specific_flags);
26 	void (*device_disable)(struct b43_bus_dev *dev,
27 			       u32 core_specific_flags);
28 
29 	u16 (*read16)(struct b43_bus_dev *dev, u16 offset);
30 	u32 (*read32)(struct b43_bus_dev *dev, u16 offset);
31 	void (*write16)(struct b43_bus_dev *dev, u16 offset, u16 value);
32 	void (*write32)(struct b43_bus_dev *dev, u16 offset, u32 value);
33 	void (*block_read)(struct b43_bus_dev *dev, void *buffer,
34 			   size_t count, u16 offset, u8 reg_width);
35 	void (*block_write)(struct b43_bus_dev *dev, const void *buffer,
36 			    size_t count, u16 offset, u8 reg_width);
37 	bool flush_writes;
38 
39 	struct device *dev;
40 	struct device *dma_dev;
41 	unsigned int irq;
42 
43 	u16 board_vendor;
44 	u16 board_type;
45 	u16 board_rev;
46 
47 	u16 chip_id;
48 	u8 chip_rev;
49 	u8 chip_pkg;
50 
51 	struct ssb_sprom *bus_sprom;
52 
53 	u16 core_id;
54 	u8 core_rev;
55 };
56 
57 static inline bool b43_bus_host_is_pcmcia(struct b43_bus_dev *dev)
58 {
59 #ifdef CONFIG_B43_SSB
60 	return (dev->bus_type == B43_BUS_SSB &&
61 		dev->sdev->bus->bustype == SSB_BUSTYPE_PCMCIA);
62 #else
63 	return false;
64 #endif
65 };
66 
67 static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
68 {
69 #ifdef CONFIG_B43_BCMA
70 	if (dev->bus_type == B43_BUS_BCMA)
71 		return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
72 #endif
73 #ifdef CONFIG_B43_SSB
74 	if (dev->bus_type == B43_BUS_SSB)
75 		return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
76 #endif
77 	return false;
78 }
79 
80 static inline bool b43_bus_host_is_sdio(struct b43_bus_dev *dev)
81 {
82 #ifdef CONFIG_B43_SSB
83 	return (dev->bus_type == B43_BUS_SSB &&
84 		dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO);
85 #else
86 	return false;
87 #endif
88 }
89 
90 struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
91 struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
92 
93 void *b43_bus_get_wldev(struct b43_bus_dev *dev);
94 void b43_bus_set_wldev(struct b43_bus_dev *dev, void *data);
95 
96 #endif /* B43_BUS_H_ */
97