ssb.h 18 KB

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