]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/ssb/ssb.h
ssb: Remove the old, now unused, data structures
[mirror_ubuntu-bionic-kernel.git] / include / linux / ssb / ssb.h
CommitLineData
61e115a5
MB
1#ifndef LINUX_SSB_H_
2#define LINUX_SSB_H_
3
4#include <linux/device.h>
5#include <linux/list.h>
6#include <linux/types.h>
7#include <linux/spinlock.h>
8#include <linux/pci.h>
9#include <linux/mod_devicetable.h>
10
11#include <linux/ssb/ssb_regs.h>
12
13
14struct pcmcia_device;
15struct ssb_bus;
16struct ssb_driver;
17
61e115a5
MB
18struct ssb_sprom {
19 u8 revision;
ac82fab4
LF
20 u8 il0mac[6]; /* MAC address for 802.11b/g */
21 u8 et0mac[6]; /* MAC address for Ethernet */
22 u8 et1mac[6]; /* MAC address for 802.11a */
23 u8 et0phyaddr; /* MII address for enet0 */
24 u8 et1phyaddr; /* MII address for enet1 */
25 u8 country_code; /* Country Code */
26 u16 pa0b0;
27 u16 pa0b1;
28 u16 pa0b2;
29 u16 pa1b0;
30 u16 pa1b1;
31 u16 pa1b2;
32 u8 gpio0; /* GPIO pin 0 */
33 u8 gpio1; /* GPIO pin 1 */
34 u8 gpio2; /* GPIO pin 2 */
35 u8 gpio3; /* GPIO pin 3 */
36 u16 maxpwr_a; /* A-PHY Amplifier Max Power (in dBm Q5.2) */
37 u16 maxpwr_bg; /* B/G-PHY Amplifier Max Power (in dBm Q5.2) */
38 u8 itssi_a; /* Idle TSSI Target for A-PHY */
39 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
40 u16 boardflags_lo; /* Boardflags (low 16 bits) */
41 u8 antenna_gain_a; /* A-PHY Antenna gain (in dBm Q5.2) */
42 u8 antenna_gain_bg; /* B/G-PHY Antenna gain (in dBm Q5.2) */
43
44 /* TODO - add any parameters needed from rev 2, 3, or 4 SPROMs */
61e115a5
MB
45};
46
47/* Information about the PCB the circuitry is soldered on. */
48struct ssb_boardinfo {
49 u16 vendor;
50 u16 type;
51 u16 rev;
52};
53
54
55struct ssb_device;
56/* Lowlevel read/write operations on the device MMIO.
57 * Internal, don't use that outside of ssb. */
58struct ssb_bus_ops {
59 u16 (*read16)(struct ssb_device *dev, u16 offset);
60 u32 (*read32)(struct ssb_device *dev, u16 offset);
61 void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
62 void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
63};
64
65
66/* Core-ID values. */
67#define SSB_DEV_CHIPCOMMON 0x800
68#define SSB_DEV_ILINE20 0x801
69#define SSB_DEV_SDRAM 0x803
70#define SSB_DEV_PCI 0x804
71#define SSB_DEV_MIPS 0x805
72#define SSB_DEV_ETHERNET 0x806
73#define SSB_DEV_V90 0x807
74#define SSB_DEV_USB11_HOSTDEV 0x808
75#define SSB_DEV_ADSL 0x809
76#define SSB_DEV_ILINE100 0x80A
77#define SSB_DEV_IPSEC 0x80B
78#define SSB_DEV_PCMCIA 0x80D
79#define SSB_DEV_INTERNAL_MEM 0x80E
80#define SSB_DEV_MEMC_SDRAM 0x80F
81#define SSB_DEV_EXTIF 0x811
82#define SSB_DEV_80211 0x812
83#define SSB_DEV_MIPS_3302 0x816
84#define SSB_DEV_USB11_HOST 0x817
85#define SSB_DEV_USB11_DEV 0x818
86#define SSB_DEV_USB20_HOST 0x819
87#define SSB_DEV_USB20_DEV 0x81A
88#define SSB_DEV_SDIO_HOST 0x81B
89#define SSB_DEV_ROBOSWITCH 0x81C
90#define SSB_DEV_PARA_ATA 0x81D
91#define SSB_DEV_SATA_XORDMA 0x81E
92#define SSB_DEV_ETHERNET_GBIT 0x81F
93#define SSB_DEV_PCIE 0x820
94#define SSB_DEV_MIMO_PHY 0x821
95#define SSB_DEV_SRAM_CTRLR 0x822
96#define SSB_DEV_MINI_MACPHY 0x823
97#define SSB_DEV_ARM_1176 0x824
98#define SSB_DEV_ARM_7TDMI 0x825
99
100/* Vendor-ID values */
101#define SSB_VENDOR_BROADCOM 0x4243
102
103/* Some kernel subsystems poke with dev->drvdata, so we must use the
104 * following ugly workaround to get from struct device to struct ssb_device */
105struct __ssb_dev_wrapper {
106 struct device dev;
107 struct ssb_device *sdev;
108};
109
110struct ssb_device {
111 /* Having a copy of the ops pointer in each dev struct
112 * is an optimization. */
113 const struct ssb_bus_ops *ops;
114
115 struct device *dev;
116 struct ssb_bus *bus;
117 struct ssb_device_id id;
118
119 u8 core_index;
120 unsigned int irq;
121
122 /* Internal-only stuff follows. */
123 void *drvdata; /* Per-device data */
124 void *devtypedata; /* Per-devicetype (eg 802.11) data */
125};
126
127/* Go from struct device to struct ssb_device. */
128static inline
129struct ssb_device * dev_to_ssb_dev(struct device *dev)
130{
131 struct __ssb_dev_wrapper *wrap;
132 wrap = container_of(dev, struct __ssb_dev_wrapper, dev);
133 return wrap->sdev;
134}
135
136/* Device specific user data */
137static inline
138void ssb_set_drvdata(struct ssb_device *dev, void *data)
139{
140 dev->drvdata = data;
141}
142static inline
143void * ssb_get_drvdata(struct ssb_device *dev)
144{
145 return dev->drvdata;
146}
147
148/* Devicetype specific user data. This is per device-type (not per device) */
149void ssb_set_devtypedata(struct ssb_device *dev, void *data);
150static inline
151void * ssb_get_devtypedata(struct ssb_device *dev)
152{
153 return dev->devtypedata;
154}
155
156
157struct ssb_driver {
158 const char *name;
159 const struct ssb_device_id *id_table;
160
161 int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id);
162 void (*remove)(struct ssb_device *dev);
163 int (*suspend)(struct ssb_device *dev, pm_message_t state);
164 int (*resume)(struct ssb_device *dev);
165 void (*shutdown)(struct ssb_device *dev);
166
167 struct device_driver drv;
168};
169#define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
170
171extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
172static inline int ssb_driver_register(struct ssb_driver *drv)
173{
174 return __ssb_driver_register(drv, THIS_MODULE);
175}
176extern void ssb_driver_unregister(struct ssb_driver *drv);
177
178
179
180
181enum ssb_bustype {
182 SSB_BUSTYPE_SSB, /* This SSB bus is the system bus */
183 SSB_BUSTYPE_PCI, /* SSB is connected to PCI bus */
184 SSB_BUSTYPE_PCMCIA, /* SSB is connected to PCMCIA bus */
185};
186
187/* board_vendor */
188#define SSB_BOARDVENDOR_BCM 0x14E4 /* Broadcom */
189#define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
190#define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
191/* board_type */
192#define SSB_BOARD_BCM94306MP 0x0418
193#define SSB_BOARD_BCM4309G 0x0421
194#define SSB_BOARD_BCM4306CB 0x0417
195#define SSB_BOARD_BCM4309MP 0x040C
196#define SSB_BOARD_MP4318 0x044A
197#define SSB_BOARD_BU4306 0x0416
198#define SSB_BOARD_BU4309 0x040A
199/* chip_package */
200#define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
201#define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
202#define SSB_CHIPPACK_BCM4712L 0 /* Large 340pin 4712 */
203
204#include <linux/ssb/ssb_driver_chipcommon.h>
205#include <linux/ssb/ssb_driver_mips.h>
206#include <linux/ssb/ssb_driver_extif.h>
207#include <linux/ssb/ssb_driver_pci.h>
208
209struct ssb_bus {
210 /* The MMIO area. */
211 void __iomem *mmio;
212
213 const struct ssb_bus_ops *ops;
214
215 /* The core in the basic address register window. (PCI bus only) */
216 struct ssb_device *mapped_device;
217 /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
218 u8 mapped_pcmcia_seg;
219 /* Lock for core and segment switching. */
220 spinlock_t bar_lock;
221
222 /* The bus this backplane is running on. */
223 enum ssb_bustype bustype;
224 /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
225 struct pci_dev *host_pci;
226 /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
227 struct pcmcia_device *host_pcmcia;
228
229#ifdef CONFIG_SSB_PCIHOST
230 /* Mutex to protect the SPROM writing. */
231 struct mutex pci_sprom_mutex;
232#endif
233
234 /* ID information about the Chip. */
235 u16 chip_id;
236 u16 chip_rev;
c272ef44 237 u16 sprom_size; /* number of words in sprom */
61e115a5
MB
238 u8 chip_package;
239
240 /* List of devices (cores) on the backplane. */
241 struct ssb_device devices[SSB_MAX_NR_CORES];
242 u8 nr_devices;
243
244 /* Reference count. Number of suspended devices. */
245 u8 suspend_cnt;
246
247 /* Software ID number for this bus. */
248 unsigned int busnumber;
249
250 /* The ChipCommon device (if available). */
251 struct ssb_chipcommon chipco;
252 /* The PCI-core device (if available). */
253 struct ssb_pcicore pcicore;
254 /* The MIPS-core device (if available). */
255 struct ssb_mipscore mipscore;
256 /* The EXTif-core device (if available). */
257 struct ssb_extif extif;
258
259 /* The following structure elements are not available in early
260 * SSB initialization. Though, they are available for regular
261 * registered drivers at any stage. So be careful when
262 * using them in the ssb core code. */
263
264 /* ID information about the PCB. */
265 struct ssb_boardinfo boardinfo;
266 /* Contents of the SPROM. */
267 struct ssb_sprom sprom;
268
269 /* Internal-only stuff follows. Do not touch. */
270 struct list_head list;
271#ifdef CONFIG_SSB_DEBUG
272 /* Is the bus already powered up? */
273 bool powered_up;
274 int power_warn_count;
275#endif /* DEBUG */
276};
277
278/* The initialization-invariants. */
279struct ssb_init_invariants {
280 struct ssb_boardinfo boardinfo;
281 struct ssb_sprom sprom;
282};
283/* Type of function to fetch the invariants. */
284typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
285 struct ssb_init_invariants *iv);
286
287/* Register a SSB system bus. get_invariants() is called after the
288 * basic system devices are initialized.
289 * The invariants are usually fetched from some NVRAM.
290 * Put the invariants into the struct pointed to by iv. */
291extern int ssb_bus_ssbbus_register(struct ssb_bus *bus,
292 unsigned long baseaddr,
293 ssb_invariants_func_t get_invariants);
294#ifdef CONFIG_SSB_PCIHOST
295extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
296 struct pci_dev *host_pci);
297#endif /* CONFIG_SSB_PCIHOST */
298#ifdef CONFIG_SSB_PCMCIAHOST
299extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
300 struct pcmcia_device *pcmcia_dev,
301 unsigned long baseaddr);
302#endif /* CONFIG_SSB_PCMCIAHOST */
303
304extern void ssb_bus_unregister(struct ssb_bus *bus);
305
306extern u32 ssb_clockspeed(struct ssb_bus *bus);
307
308/* Is the device enabled in hardware? */
309int ssb_device_is_enabled(struct ssb_device *dev);
310/* Enable a device and pass device-specific SSB_TMSLOW flags.
311 * If no device-specific flags are available, use 0. */
312void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
313/* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
314void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
315
316
317/* Device MMIO register read/write functions. */
318static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
319{
320 return dev->ops->read16(dev, offset);
321}
322static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
323{
324 return dev->ops->read32(dev, offset);
325}
326static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
327{
328 dev->ops->write16(dev, offset, value);
329}
330static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
331{
332 dev->ops->write32(dev, offset, value);
333}
334
335
336/* Translation (routing) bits that need to be ORed to DMA
337 * addresses before they are given to a device. */
338extern u32 ssb_dma_translation(struct ssb_device *dev);
339#define SSB_DMA_TRANSLATION_MASK 0xC0000000
340#define SSB_DMA_TRANSLATION_SHIFT 30
341
342extern int ssb_dma_set_mask(struct ssb_device *ssb_dev, u64 mask);
343
344
345#ifdef CONFIG_SSB_PCIHOST
346/* PCI-host wrapper driver */
347extern int ssb_pcihost_register(struct pci_driver *driver);
348static inline void ssb_pcihost_unregister(struct pci_driver *driver)
349{
350 pci_unregister_driver(driver);
351}
352#endif /* CONFIG_SSB_PCIHOST */
353
354
355/* If a driver is shutdown or suspended, call this to signal
356 * that the bus may be completely powered down. SSB will decide,
357 * if it's really time to power down the bus, based on if there
358 * are other devices that want to run. */
359extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
360/* Before initializing and enabling a device, call this to power-up the bus.
361 * If you want to allow use of dynamic-power-control, pass the flag.
362 * Otherwise static always-on powercontrol will be used. */
363extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
364
365
366/* Various helper functions */
367extern u32 ssb_admatch_base(u32 adm);
368extern u32 ssb_admatch_size(u32 adm);
369
370
371#endif /* LINUX_SSB_H_ */