blob: 0fe5a0ded3eac17f4075d2cbdfcfb88153031238 [file] [log] [blame]
Michael Buesch61e115a2007-09-18 15:12:50 -04001#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
Michael Buesch61e115a2007-09-18 15:12:50 -040018struct ssb_sprom {
19 u8 revision;
Larry Fingerac82fab2007-11-09 16:54:45 -060020 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 */
Michael Buesche861b982007-12-22 21:51:30 +010025 u8 et0mdcport; /* MDIO for enet0 */
26 u8 et1mdcport; /* MDIO for enet1 */
27 u8 board_rev; /* Board revision number from SPROM. */
Larry Fingerac82fab2007-11-09 16:54:45 -060028 u8 country_code; /* Country Code */
Michael Buesche861b982007-12-22 21:51:30 +010029 u8 ant_available_a; /* A-PHY antenna available bits (up to 4) */
30 u8 ant_available_bg; /* B/G-PHY antenna available bits (up to 4) */
Larry Fingerac82fab2007-11-09 16:54:45 -060031 u16 pa0b0;
32 u16 pa0b1;
33 u16 pa0b2;
34 u16 pa1b0;
35 u16 pa1b1;
36 u16 pa1b2;
37 u8 gpio0; /* GPIO pin 0 */
38 u8 gpio1; /* GPIO pin 1 */
39 u8 gpio2; /* GPIO pin 2 */
40 u8 gpio3; /* GPIO pin 3 */
41 u16 maxpwr_a; /* A-PHY Amplifier Max Power (in dBm Q5.2) */
42 u16 maxpwr_bg; /* B/G-PHY Amplifier Max Power (in dBm Q5.2) */
43 u8 itssi_a; /* Idle TSSI Target for A-PHY */
44 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
45 u16 boardflags_lo; /* Boardflags (low 16 bits) */
Michael Bueschaf4b74502008-01-13 21:08:24 +010046 u16 boardflags_hi; /* Boardflags (high 16 bits) */
Michael Buesche861b982007-12-22 21:51:30 +010047
48 /* Antenna gain values for up to 4 antennas
49 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
50 * loss in the connectors is bigger than the gain. */
51 struct {
52 struct {
53 s8 a0, a1, a2, a3;
54 } ghz24; /* 2.4GHz band */
55 struct {
56 s8 a0, a1, a2, a3;
57 } ghz5; /* 5GHz band */
58 } antenna_gain;
Larry Fingerac82fab2007-11-09 16:54:45 -060059
60 /* TODO - add any parameters needed from rev 2, 3, or 4 SPROMs */
Michael Buesch61e115a2007-09-18 15:12:50 -040061};
62
63/* Information about the PCB the circuitry is soldered on. */
64struct ssb_boardinfo {
65 u16 vendor;
66 u16 type;
67 u16 rev;
68};
69
70
71struct ssb_device;
72/* Lowlevel read/write operations on the device MMIO.
73 * Internal, don't use that outside of ssb. */
74struct ssb_bus_ops {
Michael Bueschffc76892008-02-20 19:08:10 +010075 u8 (*read8)(struct ssb_device *dev, u16 offset);
Michael Buesch61e115a2007-09-18 15:12:50 -040076 u16 (*read16)(struct ssb_device *dev, u16 offset);
77 u32 (*read32)(struct ssb_device *dev, u16 offset);
Michael Bueschffc76892008-02-20 19:08:10 +010078 void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
Michael Buesch61e115a2007-09-18 15:12:50 -040079 void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
80 void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
Michael Bueschd625a292008-04-02 19:46:56 +020081#ifdef CONFIG_SSB_BLOCKIO
82 void (*block_read)(struct ssb_device *dev, void *buffer,
83 size_t count, u16 offset, u8 reg_width);
84 void (*block_write)(struct ssb_device *dev, const void *buffer,
85 size_t count, u16 offset, u8 reg_width);
86#endif
Michael Buesch61e115a2007-09-18 15:12:50 -040087};
88
89
90/* Core-ID values. */
91#define SSB_DEV_CHIPCOMMON 0x800
92#define SSB_DEV_ILINE20 0x801
93#define SSB_DEV_SDRAM 0x803
94#define SSB_DEV_PCI 0x804
95#define SSB_DEV_MIPS 0x805
96#define SSB_DEV_ETHERNET 0x806
97#define SSB_DEV_V90 0x807
98#define SSB_DEV_USB11_HOSTDEV 0x808
99#define SSB_DEV_ADSL 0x809
100#define SSB_DEV_ILINE100 0x80A
101#define SSB_DEV_IPSEC 0x80B
102#define SSB_DEV_PCMCIA 0x80D
103#define SSB_DEV_INTERNAL_MEM 0x80E
104#define SSB_DEV_MEMC_SDRAM 0x80F
105#define SSB_DEV_EXTIF 0x811
106#define SSB_DEV_80211 0x812
107#define SSB_DEV_MIPS_3302 0x816
108#define SSB_DEV_USB11_HOST 0x817
109#define SSB_DEV_USB11_DEV 0x818
110#define SSB_DEV_USB20_HOST 0x819
111#define SSB_DEV_USB20_DEV 0x81A
112#define SSB_DEV_SDIO_HOST 0x81B
113#define SSB_DEV_ROBOSWITCH 0x81C
114#define SSB_DEV_PARA_ATA 0x81D
115#define SSB_DEV_SATA_XORDMA 0x81E
116#define SSB_DEV_ETHERNET_GBIT 0x81F
117#define SSB_DEV_PCIE 0x820
118#define SSB_DEV_MIMO_PHY 0x821
119#define SSB_DEV_SRAM_CTRLR 0x822
120#define SSB_DEV_MINI_MACPHY 0x823
121#define SSB_DEV_ARM_1176 0x824
122#define SSB_DEV_ARM_7TDMI 0x825
123
124/* Vendor-ID values */
125#define SSB_VENDOR_BROADCOM 0x4243
126
127/* Some kernel subsystems poke with dev->drvdata, so we must use the
128 * following ugly workaround to get from struct device to struct ssb_device */
129struct __ssb_dev_wrapper {
130 struct device dev;
131 struct ssb_device *sdev;
132};
133
134struct ssb_device {
135 /* Having a copy of the ops pointer in each dev struct
136 * is an optimization. */
137 const struct ssb_bus_ops *ops;
138
139 struct device *dev;
Michael Buesch4ac58462008-04-11 11:59:00 +0200140
Michael Buesch61e115a2007-09-18 15:12:50 -0400141 struct ssb_bus *bus;
142 struct ssb_device_id id;
143
144 u8 core_index;
145 unsigned int irq;
146
147 /* Internal-only stuff follows. */
148 void *drvdata; /* Per-device data */
149 void *devtypedata; /* Per-devicetype (eg 802.11) data */
150};
151
152/* Go from struct device to struct ssb_device. */
153static inline
154struct ssb_device * dev_to_ssb_dev(struct device *dev)
155{
156 struct __ssb_dev_wrapper *wrap;
157 wrap = container_of(dev, struct __ssb_dev_wrapper, dev);
158 return wrap->sdev;
159}
160
161/* Device specific user data */
162static inline
163void ssb_set_drvdata(struct ssb_device *dev, void *data)
164{
165 dev->drvdata = data;
166}
167static inline
168void * ssb_get_drvdata(struct ssb_device *dev)
169{
170 return dev->drvdata;
171}
172
173/* Devicetype specific user data. This is per device-type (not per device) */
174void ssb_set_devtypedata(struct ssb_device *dev, void *data);
175static inline
176void * ssb_get_devtypedata(struct ssb_device *dev)
177{
178 return dev->devtypedata;
179}
180
181
182struct ssb_driver {
183 const char *name;
184 const struct ssb_device_id *id_table;
185
186 int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id);
187 void (*remove)(struct ssb_device *dev);
188 int (*suspend)(struct ssb_device *dev, pm_message_t state);
189 int (*resume)(struct ssb_device *dev);
190 void (*shutdown)(struct ssb_device *dev);
191
192 struct device_driver drv;
193};
194#define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
195
196extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
197static inline int ssb_driver_register(struct ssb_driver *drv)
198{
199 return __ssb_driver_register(drv, THIS_MODULE);
200}
201extern void ssb_driver_unregister(struct ssb_driver *drv);
202
203
204
205
206enum ssb_bustype {
207 SSB_BUSTYPE_SSB, /* This SSB bus is the system bus */
208 SSB_BUSTYPE_PCI, /* SSB is connected to PCI bus */
209 SSB_BUSTYPE_PCMCIA, /* SSB is connected to PCMCIA bus */
210};
211
212/* board_vendor */
213#define SSB_BOARDVENDOR_BCM 0x14E4 /* Broadcom */
214#define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
215#define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
216/* board_type */
217#define SSB_BOARD_BCM94306MP 0x0418
218#define SSB_BOARD_BCM4309G 0x0421
219#define SSB_BOARD_BCM4306CB 0x0417
220#define SSB_BOARD_BCM4309MP 0x040C
221#define SSB_BOARD_MP4318 0x044A
222#define SSB_BOARD_BU4306 0x0416
223#define SSB_BOARD_BU4309 0x040A
224/* chip_package */
225#define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
226#define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
227#define SSB_CHIPPACK_BCM4712L 0 /* Large 340pin 4712 */
228
229#include <linux/ssb/ssb_driver_chipcommon.h>
230#include <linux/ssb/ssb_driver_mips.h>
231#include <linux/ssb/ssb_driver_extif.h>
232#include <linux/ssb/ssb_driver_pci.h>
233
234struct ssb_bus {
235 /* The MMIO area. */
236 void __iomem *mmio;
237
238 const struct ssb_bus_ops *ops;
239
240 /* The core in the basic address register window. (PCI bus only) */
241 struct ssb_device *mapped_device;
242 /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
243 u8 mapped_pcmcia_seg;
Michael Buesch993e1c72007-12-22 22:01:36 +0100244 /* Lock for core and segment switching.
245 * On PCMCIA-host busses this is used to protect the whole MMIO access. */
Michael Buesch61e115a2007-09-18 15:12:50 -0400246 spinlock_t bar_lock;
247
248 /* The bus this backplane is running on. */
249 enum ssb_bustype bustype;
250 /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
251 struct pci_dev *host_pci;
252 /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
253 struct pcmcia_device *host_pcmcia;
254
Michael Buesche7ec2e32008-03-10 17:26:32 +0100255#ifdef CONFIG_SSB_SPROM
Michael Buesch61e115a2007-09-18 15:12:50 -0400256 /* Mutex to protect the SPROM writing. */
Michael Buesche7ec2e32008-03-10 17:26:32 +0100257 struct mutex sprom_mutex;
Michael Buesch61e115a2007-09-18 15:12:50 -0400258#endif
259
260 /* ID information about the Chip. */
261 u16 chip_id;
262 u16 chip_rev;
Larry Fingerc272ef42007-11-09 16:56:25 -0600263 u16 sprom_size; /* number of words in sprom */
Michael Buesch61e115a2007-09-18 15:12:50 -0400264 u8 chip_package;
265
266 /* List of devices (cores) on the backplane. */
267 struct ssb_device devices[SSB_MAX_NR_CORES];
268 u8 nr_devices;
269
Michael Buesch61e115a2007-09-18 15:12:50 -0400270 /* Software ID number for this bus. */
271 unsigned int busnumber;
272
273 /* The ChipCommon device (if available). */
274 struct ssb_chipcommon chipco;
275 /* The PCI-core device (if available). */
276 struct ssb_pcicore pcicore;
277 /* The MIPS-core device (if available). */
278 struct ssb_mipscore mipscore;
279 /* The EXTif-core device (if available). */
280 struct ssb_extif extif;
281
282 /* The following structure elements are not available in early
283 * SSB initialization. Though, they are available for regular
284 * registered drivers at any stage. So be careful when
285 * using them in the ssb core code. */
286
287 /* ID information about the PCB. */
288 struct ssb_boardinfo boardinfo;
289 /* Contents of the SPROM. */
290 struct ssb_sprom sprom;
Michael Buesch7cb44612008-02-19 17:46:48 +0100291 /* If the board has a cardbus slot, this is set to true. */
292 bool has_cardbus_slot;
Michael Buesch61e115a2007-09-18 15:12:50 -0400293
Michael Buesch53521d82008-02-19 16:22:50 +0100294#ifdef CONFIG_SSB_EMBEDDED
295 /* Lock for GPIO register access. */
296 spinlock_t gpio_lock;
297#endif /* EMBEDDED */
298
Michael Buesch61e115a2007-09-18 15:12:50 -0400299 /* Internal-only stuff follows. Do not touch. */
300 struct list_head list;
301#ifdef CONFIG_SSB_DEBUG
302 /* Is the bus already powered up? */
303 bool powered_up;
304 int power_warn_count;
305#endif /* DEBUG */
306};
307
308/* The initialization-invariants. */
309struct ssb_init_invariants {
Michael Buesch7cb44612008-02-19 17:46:48 +0100310 /* Versioning information about the PCB. */
Michael Buesch61e115a2007-09-18 15:12:50 -0400311 struct ssb_boardinfo boardinfo;
Michael Buesch7cb44612008-02-19 17:46:48 +0100312 /* The SPROM information. That's either stored in an
313 * EEPROM or NVRAM on the board. */
Michael Buesch61e115a2007-09-18 15:12:50 -0400314 struct ssb_sprom sprom;
Michael Buesch7cb44612008-02-19 17:46:48 +0100315 /* If the board has a cardbus slot, this is set to true. */
316 bool has_cardbus_slot;
Michael Buesch61e115a2007-09-18 15:12:50 -0400317};
318/* Type of function to fetch the invariants. */
319typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
320 struct ssb_init_invariants *iv);
321
322/* Register a SSB system bus. get_invariants() is called after the
323 * basic system devices are initialized.
324 * The invariants are usually fetched from some NVRAM.
325 * Put the invariants into the struct pointed to by iv. */
326extern int ssb_bus_ssbbus_register(struct ssb_bus *bus,
327 unsigned long baseaddr,
328 ssb_invariants_func_t get_invariants);
329#ifdef CONFIG_SSB_PCIHOST
330extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
331 struct pci_dev *host_pci);
332#endif /* CONFIG_SSB_PCIHOST */
333#ifdef CONFIG_SSB_PCMCIAHOST
334extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
335 struct pcmcia_device *pcmcia_dev,
336 unsigned long baseaddr);
337#endif /* CONFIG_SSB_PCMCIAHOST */
338
339extern void ssb_bus_unregister(struct ssb_bus *bus);
340
Michael Buesch8fe2b652008-03-30 00:10:50 +0100341/* Suspend a SSB bus.
342 * Call this from the parent bus suspend routine. */
343extern int ssb_bus_suspend(struct ssb_bus *bus);
344/* Resume a SSB bus.
345 * Call this from the parent bus resume routine. */
346extern int ssb_bus_resume(struct ssb_bus *bus);
347
Michael Buesch61e115a2007-09-18 15:12:50 -0400348extern u32 ssb_clockspeed(struct ssb_bus *bus);
349
350/* Is the device enabled in hardware? */
351int ssb_device_is_enabled(struct ssb_device *dev);
352/* Enable a device and pass device-specific SSB_TMSLOW flags.
353 * If no device-specific flags are available, use 0. */
354void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
355/* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
356void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
357
358
359/* Device MMIO register read/write functions. */
Michael Bueschffc76892008-02-20 19:08:10 +0100360static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
361{
362 return dev->ops->read8(dev, offset);
363}
Michael Buesch61e115a2007-09-18 15:12:50 -0400364static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
365{
366 return dev->ops->read16(dev, offset);
367}
368static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
369{
370 return dev->ops->read32(dev, offset);
371}
Michael Bueschffc76892008-02-20 19:08:10 +0100372static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
373{
374 dev->ops->write8(dev, offset, value);
375}
Michael Buesch61e115a2007-09-18 15:12:50 -0400376static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
377{
378 dev->ops->write16(dev, offset, value);
379}
380static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
381{
382 dev->ops->write32(dev, offset, value);
383}
Michael Bueschd625a292008-04-02 19:46:56 +0200384#ifdef CONFIG_SSB_BLOCKIO
385static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
386 size_t count, u16 offset, u8 reg_width)
387{
388 dev->ops->block_read(dev, buffer, count, offset, reg_width);
389}
390
391static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
392 size_t count, u16 offset, u8 reg_width)
393{
394 dev->ops->block_write(dev, buffer, count, offset, reg_width);
395}
396#endif /* CONFIG_SSB_BLOCKIO */
Michael Buesch61e115a2007-09-18 15:12:50 -0400397
398
Michael Bueschf2257632008-06-20 11:50:29 +0200399/* The SSB DMA API. Use this API for any DMA operation on the device.
400 * This API basically is a wrapper that calls the correct DMA API for
401 * the host device type the SSB device is attached to. */
402
Michael Buesch61e115a2007-09-18 15:12:50 -0400403/* Translation (routing) bits that need to be ORed to DMA
404 * addresses before they are given to a device. */
405extern u32 ssb_dma_translation(struct ssb_device *dev);
406#define SSB_DMA_TRANSLATION_MASK 0xC0000000
407#define SSB_DMA_TRANSLATION_SHIFT 30
408
Michael Bueschf2257632008-06-20 11:50:29 +0200409extern int ssb_dma_set_mask(struct ssb_device *dev, u64 mask);
410
411extern void * ssb_dma_alloc_consistent(struct ssb_device *dev, size_t size,
412 dma_addr_t *dma_handle, gfp_t gfp_flags);
413extern void ssb_dma_free_consistent(struct ssb_device *dev, size_t size,
414 void *vaddr, dma_addr_t dma_handle,
415 gfp_t gfp_flags);
416
417static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev)
418{
419#ifdef CONFIG_SSB_DEBUG
420 printk(KERN_ERR "SSB: BUG! Calling DMA API for "
421 "unsupported bustype %d\n", dev->bus->bustype);
422#endif /* DEBUG */
423}
424
425static inline int ssb_dma_mapping_error(struct ssb_device *dev, dma_addr_t addr)
426{
427 switch (dev->bus->bustype) {
428 case SSB_BUSTYPE_PCI:
429 return pci_dma_mapping_error(addr);
430 case SSB_BUSTYPE_SSB:
431 return dma_mapping_error(addr);
432 default:
433 __ssb_dma_not_implemented(dev);
434 }
435 return -ENOSYS;
436}
437
438static inline dma_addr_t ssb_dma_map_single(struct ssb_device *dev, void *p,
439 size_t size, enum dma_data_direction dir)
440{
441 switch (dev->bus->bustype) {
442 case SSB_BUSTYPE_PCI:
443 return pci_map_single(dev->bus->host_pci, p, size, dir);
444 case SSB_BUSTYPE_SSB:
445 return dma_map_single(dev->dev, p, size, dir);
446 default:
447 __ssb_dma_not_implemented(dev);
448 }
449 return 0;
450}
451
452static inline void ssb_dma_unmap_single(struct ssb_device *dev, dma_addr_t dma_addr,
453 size_t size, enum dma_data_direction dir)
454{
455 switch (dev->bus->bustype) {
456 case SSB_BUSTYPE_PCI:
457 pci_unmap_single(dev->bus->host_pci, dma_addr, size, dir);
458 return;
459 case SSB_BUSTYPE_SSB:
460 dma_unmap_single(dev->dev, dma_addr, size, dir);
461 return;
462 default:
463 __ssb_dma_not_implemented(dev);
464 }
465}
466
467static inline void ssb_dma_sync_single_for_cpu(struct ssb_device *dev,
468 dma_addr_t dma_addr,
469 size_t size,
470 enum dma_data_direction dir)
471{
472 switch (dev->bus->bustype) {
473 case SSB_BUSTYPE_PCI:
474 pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
475 size, dir);
476 return;
477 case SSB_BUSTYPE_SSB:
478 dma_sync_single_for_cpu(dev->dev, dma_addr, size, dir);
479 return;
480 default:
481 __ssb_dma_not_implemented(dev);
482 }
483}
484
485static inline void ssb_dma_sync_single_for_device(struct ssb_device *dev,
486 dma_addr_t dma_addr,
487 size_t size,
488 enum dma_data_direction dir)
489{
490 switch (dev->bus->bustype) {
491 case SSB_BUSTYPE_PCI:
492 pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
493 size, dir);
494 return;
495 case SSB_BUSTYPE_SSB:
496 dma_sync_single_for_device(dev->dev, dma_addr, size, dir);
497 return;
498 default:
499 __ssb_dma_not_implemented(dev);
500 }
501}
502
503static inline void ssb_dma_sync_single_range_for_cpu(struct ssb_device *dev,
504 dma_addr_t dma_addr,
505 unsigned long offset,
506 size_t size,
507 enum dma_data_direction dir)
508{
509 switch (dev->bus->bustype) {
510 case SSB_BUSTYPE_PCI:
511 /* Just sync everything. That's all the PCI API can do. */
512 pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
513 offset + size, dir);
514 return;
515 case SSB_BUSTYPE_SSB:
516 dma_sync_single_range_for_cpu(dev->dev, dma_addr, offset,
517 size, dir);
518 return;
519 default:
520 __ssb_dma_not_implemented(dev);
521 }
522}
523
524static inline void ssb_dma_sync_single_range_for_device(struct ssb_device *dev,
525 dma_addr_t dma_addr,
526 unsigned long offset,
527 size_t size,
528 enum dma_data_direction dir)
529{
530 switch (dev->bus->bustype) {
531 case SSB_BUSTYPE_PCI:
532 /* Just sync everything. That's all the PCI API can do. */
533 pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
534 offset + size, dir);
535 return;
536 case SSB_BUSTYPE_SSB:
537 dma_sync_single_range_for_device(dev->dev, dma_addr, offset,
538 size, dir);
539 return;
540 default:
541 __ssb_dma_not_implemented(dev);
542 }
543}
Michael Buesch61e115a2007-09-18 15:12:50 -0400544
545
546#ifdef CONFIG_SSB_PCIHOST
547/* PCI-host wrapper driver */
548extern int ssb_pcihost_register(struct pci_driver *driver);
549static inline void ssb_pcihost_unregister(struct pci_driver *driver)
550{
551 pci_unregister_driver(driver);
552}
Miguel Botón961d57c2008-01-01 01:16:46 +0100553
554static inline
555void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
556{
557 if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
558 pci_set_power_state(sdev->bus->host_pci, state);
559}
Andrew Morton532031d2008-02-04 23:58:42 -0800560#else
561static inline void ssb_pcihost_unregister(struct pci_driver *driver)
562{
563}
564
565static inline
566void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
567{
568}
Michael Buesch61e115a2007-09-18 15:12:50 -0400569#endif /* CONFIG_SSB_PCIHOST */
570
571
572/* If a driver is shutdown or suspended, call this to signal
573 * that the bus may be completely powered down. SSB will decide,
574 * if it's really time to power down the bus, based on if there
575 * are other devices that want to run. */
576extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
577/* Before initializing and enabling a device, call this to power-up the bus.
578 * If you want to allow use of dynamic-power-control, pass the flag.
579 * Otherwise static always-on powercontrol will be used. */
580extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
581
582
583/* Various helper functions */
584extern u32 ssb_admatch_base(u32 adm);
585extern u32 ssb_admatch_size(u32 adm);
586
Michael Bueschaab547c2008-02-29 11:36:12 +0100587/* PCI device mapping and fixup routines.
588 * Called from the architecture pcibios init code.
589 * These are only available on SSB_EMBEDDED configurations. */
590#ifdef CONFIG_SSB_EMBEDDED
591int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
592int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
593#endif /* CONFIG_SSB_EMBEDDED */
Michael Buesch61e115a2007-09-18 15:12:50 -0400594
595#endif /* LINUX_SSB_H_ */