ssb.h 17 KB

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