7fdeae71cb760a6d65b641a760041a65faf431c4
5 #include <linux/device.h>
6 #include <linux/list.h>
7 #include <linux/types.h>
8 #include <linux/spinlock.h>
10 #include <linux/ssb/ssb_regs.h>
19 u16 pci_spid
; /* Subsystem Product ID for PCI */
20 u16 pci_svid
; /* Subsystem Vendor ID for PCI */
21 u16 pci_pid
; /* Product ID for PCI */
22 u8 il0mac
[6]; /* MAC address for 802.11b/g */
23 u8 et0mac
[6]; /* MAC address for Ethernet */
24 u8 et1mac
[6]; /* MAC address for 802.11a */
25 u8 et0phyaddr
:5; /* MII address for enet0 */
26 u8 et1phyaddr
:5; /* MII address for enet1 */
27 u8 et0mdcport
:1; /* MDIO for enet0 */
28 u8 et1mdcport
:1; /* MDIO for enet1 */
29 u8 board_rev
; /* Board revision */
30 u8 country_code
:4; /* Country Code */
31 u8 antenna_a
:2; /* Antenna 0/1 available for A-PHY */
32 u8 antenna_bg
:2; /* Antenna 0/1 available for B-PHY and G-PHY */
39 u8 gpio0
; /* GPIO pin 0 */
40 u8 gpio1
; /* GPIO pin 1 */
41 u8 gpio2
; /* GPIO pin 2 */
42 u8 gpio3
; /* GPIO pin 3 */
43 u16 maxpwr_a
; /* A-PHY Power Amplifier Max Power (in dBm Q5.2) */
44 u16 maxpwr_bg
; /* B/G-PHY Power Amplifier Max Power (in dBm Q5.2) */
45 u8 itssi_a
; /* Idle TSSI Target for A-PHY */
46 u8 itssi_bg
; /* Idle TSSI Target for B/G-PHY */
47 u16 boardflags_lo
; /* Boardflags (low 16 bits) */
48 u8 antenna_gain_a
; /* A-PHY Antenna gain (in dBm Q5.2) */
49 u8 antenna_gain_bg
; /* B/G-PHY Antenna gain (in dBm Q5.2) */
50 u8 oem
[8]; /* OEM string (rev 1 only) */
54 u16 boardflags_hi
; /* Boardflags (high 16 bits) */
55 u8 maxpwr_a_lo
; /* A-PHY Max Power Low */
56 u8 maxpwr_a_hi
; /* A-PHY Max Power High */
57 u16 pa1lob0
; /* A-PHY PA Low Settings */
58 u16 pa1lob1
; /* A-PHY PA Low Settings */
59 u16 pa1lob2
; /* A-PHY PA Low Settings */
60 u16 pa1hib0
; /* A-PHY PA High Settings */
61 u16 pa1hib1
; /* A-PHY PA High Settings */
62 u16 pa1hib2
; /* A-PHY PA High Settings */
63 u8 ofdm_pwr_off
; /* OFDM Power Offset from CCK Level */
64 u8 country_str
[2]; /* Two char Country Code */
68 u32 ofdmapo
; /* A-PHY OFDM Mid Power Offset */
69 u32 ofdmalpo
; /* A-PHY OFDM Low Power Offset */
70 u32 ofdmahpo
; /* A-PHY OFDM High Power Offset */
71 u8 gpioldc_on_cnt
; /* GPIO LED Powersave Duty Cycle ON count */
72 u8 gpioldc_off_cnt
; /* GPIO LED Powersave Duty Cycle OFF count */
73 u8 cckpo_1M
:4; /* CCK Power Offset for Rate 1M */
74 u8 cckpo_2M
:4; /* CCK Power Offset for Rate 2M */
75 u8 cckpo_55M
:4; /* CCK Power Offset for Rate 5.5M */
76 u8 cckpo_11M
:4; /* CCK Power Offset for Rate 11M */
77 u32 ofdmgpo
; /* G-PHY OFDM Power Offset */
87 /* The valid r# fields are selected by the "revision".
88 * Revision 3 and lower inherit from lower revisions.
92 struct ssb_sprom_r1 r1
;
93 struct ssb_sprom_r2 r2
;
94 struct ssb_sprom_r3 r3
;
96 struct ssb_sprom_r4 r4
;
101 /* Core-ID values. */
102 #define SSB_DEV_CHIPCOMMON 0x800
103 #define SSB_DEV_ILINE20 0x801
104 #define SSB_DEV_SDRAM 0x803
105 #define SSB_DEV_PCI 0x804
106 #define SSB_DEV_MIPS 0x805
107 #define SSB_DEV_ETHERNET 0x806
108 #define SSB_DEV_V90 0x807
109 #define SSB_DEV_USB11_HOSTDEV 0x808
110 #define SSB_DEV_ADSL 0x809
111 #define SSB_DEV_ILINE100 0x80A
112 #define SSB_DEV_IPSEC 0x80B
113 #define SSB_DEV_PCMCIA 0x80D
114 #define SSB_DEV_INTERNAL_MEM 0x80E
115 #define SSB_DEV_MEMC_SDRAM 0x80F
116 #define SSB_DEV_EXTIF 0x811
117 #define SSB_DEV_80211 0x812
118 #define SSB_DEV_MIPS_3302 0x816
119 #define SSB_DEV_USB11_HOST 0x817
120 #define SSB_DEV_USB11_DEV 0x818
121 #define SSB_DEV_USB20_HOST 0x819
122 #define SSB_DEV_USB20_DEV 0x81A
123 #define SSB_DEV_SDIO_HOST 0x81B
124 #define SSB_DEV_ROBOSWITCH 0x81C
125 #define SSB_DEV_PARA_ATA 0x81D
126 #define SSB_DEV_SATA_XORDMA 0x81E
127 #define SSB_DEV_ETHERNET_GBIT 0x81F
128 #define SSB_DEV_PCIE 0x820
129 #define SSB_DEV_MIMO_PHY 0x821
130 #define SSB_DEV_SRAM_CTRLR 0x822
131 #define SSB_DEV_MINI_MACPHY 0x823
132 #define SSB_DEV_ARM_1176 0x824
133 #define SSB_DEV_ARM_7TDMI 0x825
135 /* Vendor-ID values */
136 #define SSB_VENDOR_BROADCOM 0x4243
138 struct ssb_device_id
{
143 #define SSB_DEVICE(_vendor, _coreid, _revision) \
144 { .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
145 #define SSB_DEVTABLE_END \
148 #define SSB_ANY_VENDOR 0xFFFF
149 #define SSB_ANY_ID 0xFFFF
150 #define SSB_ANY_REV 0xFF
156 struct ssb_device_id id
;
160 void *drvdata
; /* Per-device data */
161 void *devtypedata
; /* Per-devicetype (eg 802.11) data */
163 #define dev_to_ssb_dev(_dev) container_of(_dev, struct ssb_device, dev)
165 /* Device specific user data */
167 void ssb_set_drvdata(struct ssb_device
*dev
, void *data
)
172 void * ssb_get_drvdata(struct ssb_device
*dev
)
177 /* Devicetype specific user data. This is per device-type (not per device) */
178 void ssb_set_devtypedata(struct ssb_device
*dev
, void *data
);
180 void * ssb_get_devtypedata(struct ssb_device
*dev
)
182 return dev
->devtypedata
;
186 u16 (*read16
)(struct ssb_device
*dev
, u16 offset
);
187 u32 (*read32
)(struct ssb_device
*dev
, u16 offset
);
188 void (*write16
)(struct ssb_device
*dev
, u16 offset
, u16 value
);
189 void (*write32
)(struct ssb_device
*dev
, u16 offset
, u32 value
);
195 const struct ssb_device_id
*id_table
;
197 int (*probe
)(struct ssb_device
*dev
, const struct ssb_device_id
*id
);
198 void (*remove
)(struct ssb_device
*dev
);
199 int (*suspend
)(struct ssb_device
*dev
, pm_message_t state
);
200 int (*resume
)(struct ssb_device
*dev
);
201 void (*shutdown
)(struct ssb_device
*dev
);
203 struct device_driver drv
;
205 #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
207 extern int __ssb_driver_register(struct ssb_driver
*drv
, struct module
*owner
);
208 static inline int ssb_driver_register(struct ssb_driver
*drv
)
210 return __ssb_driver_register(drv
, THIS_MODULE
);
212 extern void ssb_driver_unregister(struct ssb_driver
*drv
);
218 SSB_BUSTYPE_SSB
, /* This SSB bus is the system bus */
219 SSB_BUSTYPE_PCI
, /* SSB is connected to PCI bus */
220 SSB_BUSTYPE_PCMCIA
, /* SSB is connected to PCMCIA bus */
221 //TODO SSB_BUSTYPE_JTAG,
225 #define SSB_BOARDVENDOR_BCM 0x14E4 /* Broadcom */
226 #define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
227 #define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
229 #define SSB_BOARD_BCM94306MP 0x0418
230 #define SSB_BOARD_BCM4309G 0x0421
231 #define SSB_BOARD_BCM4306CB 0x0417
232 #define SSB_BOARD_BCM4309MP 0x040C
233 #define SSB_BOARD_MP4318 0x044A
234 #define SSB_BOARD_BU4306 0x0416
235 #define SSB_BOARD_BU4309 0x040A
237 #define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
238 #define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
239 #define SSB_CHIPPACK_BCM4712L 0 /* Large 340pin 4712 */
241 static inline u16
ssb_read16(struct ssb_device
*dev
, u16 offset
);
242 static inline u32
ssb_read32(struct ssb_device
*dev
, u16 offset
);
243 static inline void ssb_write16(struct ssb_device
*dev
, u16 offset
, u16 value
);
244 static inline void ssb_write32(struct ssb_device
*dev
, u16 offset
, u32 value
);
245 static inline u32
ssb_write32_masked(struct ssb_device
*dev
, u16 offset
, u32 mask
, u32 value
);
247 #include <linux/ssb/ssb_driver_chipcommon.h>
248 #include <linux/ssb/ssb_driver_mips.h>
249 #include <linux/ssb/ssb_driver_extif.h>
250 #include <linux/ssb/ssb_driver_pci.h>
256 const struct ssb_bus_ops
*ops
;
258 /* The core in the basic address register window. (PCI bus only) */
259 struct ssb_device
*mapped_device
;
260 /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
261 u8 mapped_pcmcia_seg
;
262 /* Lock for core and segment switching. */
265 /* The bus this backplane is running on. */
266 enum ssb_bustype bustype
;
267 /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
268 struct pci_dev
*host_pci
;
269 /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
270 struct pcmcia_device
*host_pcmcia
;
272 /* ID information about the PCB. */
276 /* ID information about the Chip. */
281 /* Contents of the SPROM.
282 * If there is no sprom (not on PCI-bus), this is emulated. */
283 struct ssb_sprom sprom
;
285 /* List of devices (cores) on the backplane. */
286 struct ssb_device devices
[SSB_MAX_NR_CORES
];
289 /* Reference count. Number of suspended devices. */
292 /* Software ID number for this bus. */
295 /* The ChipCommon device (if available). */
296 struct ssb_chipcommon chipco
;
297 /* The PCI-core device (if available). */
298 struct ssb_pcicore pcicore
;
299 /* The MIPS-core device (if available). */
300 struct ssb_mipscore mipscore
;
301 /* The EXTif-core device (if available). */
302 struct ssb_extif extif
;
305 struct list_head list
;
308 extern int ssb_bus_ssbbus_register(struct ssb_bus
*bus
,
309 unsigned long baseaddr
,
310 void (*fill_sprom
)(struct ssb_sprom
*sprom
));
311 #ifdef CONFIG_SSB_PCIHOST
312 extern int ssb_bus_pcibus_register(struct ssb_bus
*bus
,
313 struct pci_dev
*host_pci
);
314 #endif /* CONFIG_SSB_PCIHOST */
315 #ifdef CONFIG_SSB_PCMCIAHOST
316 extern int ssb_bus_pcmciabus_register(struct ssb_bus
*bus
,
317 struct pcmcia_device
*pcmcia_dev
,
318 unsigned long baseaddr
,
319 void (*fill_sprom
)(struct ssb_sprom
*sprom
));
320 #endif /* CONFIG_SSB_PCMCIAHOST */
322 extern void ssb_bus_unregister(struct ssb_bus
*bus
);
324 extern u32
ssb_clockspeed(struct ssb_bus
*bus
);
326 int ssb_device_is_enabled(struct ssb_device
*dev
);
327 void ssb_device_enable(struct ssb_device
*dev
, u32 core_specific_flags
);
328 void ssb_device_disable(struct ssb_device
*dev
, u32 core_specific_flags
);
331 static inline u16
ssb_read16(struct ssb_device
*dev
, u16 offset
)
333 return dev
->bus
->ops
->read16(dev
, offset
);
335 static inline u32
ssb_read32(struct ssb_device
*dev
, u16 offset
)
337 return dev
->bus
->ops
->read32(dev
, offset
);
339 static inline void ssb_write16(struct ssb_device
*dev
, u16 offset
, u16 value
)
341 dev
->bus
->ops
->write16(dev
, offset
, value
);
343 static inline void ssb_write32(struct ssb_device
*dev
, u16 offset
, u32 value
)
345 dev
->bus
->ops
->write32(dev
, offset
, value
);
348 static inline u32
ssb_write32_masked(struct ssb_device
*dev
,
354 value
|= ssb_read32(dev
, offset
) & ~mask
;
355 ssb_write32(dev
, offset
, value
);
360 /* Translation (routing) bits that need to be ORed to DMA
361 * addresses before they are given to a device. */
362 extern u32
ssb_dma_translation(struct ssb_device
*dev
);
363 #define SSB_DMA_TRANSLATION_MASK 0xC0000000
364 #define SSB_DMA_TRANSLATION_SHIFT 30
366 extern int ssb_dma_set_mask(struct ssb_device
*ssb_dev
, u64 mask
);
369 /* Various helper functions */
370 extern u32
ssb_admatch_base(u32 adm
);
371 extern u32
ssb_admatch_size(u32 adm
);
374 #endif /* __KERNEL__ */
375 #endif /* LINUX_SSB_H_ */