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