bus.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef B43_BUS_H_
  3. #define B43_BUS_H_
  4. enum b43_bus_type {
  5. #ifdef CONFIG_B43_BCMA
  6. B43_BUS_BCMA,
  7. #endif
  8. #ifdef CONFIG_B43_SSB
  9. B43_BUS_SSB,
  10. #endif
  11. };
  12. struct b43_bus_dev {
  13. enum b43_bus_type bus_type;
  14. union {
  15. struct bcma_device *bdev;
  16. struct ssb_device *sdev;
  17. };
  18. int (*bus_may_powerdown)(struct b43_bus_dev *dev);
  19. int (*bus_powerup)(struct b43_bus_dev *dev, bool dynamic_pctl);
  20. int (*device_is_enabled)(struct b43_bus_dev *dev);
  21. void (*device_enable)(struct b43_bus_dev *dev,
  22. u32 core_specific_flags);
  23. void (*device_disable)(struct b43_bus_dev *dev,
  24. u32 core_specific_flags);
  25. u16 (*read16)(struct b43_bus_dev *dev, u16 offset);
  26. u32 (*read32)(struct b43_bus_dev *dev, u16 offset);
  27. void (*write16)(struct b43_bus_dev *dev, u16 offset, u16 value);
  28. void (*write32)(struct b43_bus_dev *dev, u16 offset, u32 value);
  29. void (*block_read)(struct b43_bus_dev *dev, void *buffer,
  30. size_t count, u16 offset, u8 reg_width);
  31. void (*block_write)(struct b43_bus_dev *dev, const void *buffer,
  32. size_t count, u16 offset, u8 reg_width);
  33. bool flush_writes;
  34. struct device *dev;
  35. struct device *dma_dev;
  36. unsigned int irq;
  37. u16 board_vendor;
  38. u16 board_type;
  39. u16 board_rev;
  40. u16 chip_id;
  41. u8 chip_rev;
  42. u8 chip_pkg;
  43. struct ssb_sprom *bus_sprom;
  44. u16 core_id;
  45. u8 core_rev;
  46. };
  47. static inline bool b43_bus_host_is_pcmcia(struct b43_bus_dev *dev)
  48. {
  49. #ifdef CONFIG_B43_SSB
  50. return (dev->bus_type == B43_BUS_SSB &&
  51. dev->sdev->bus->bustype == SSB_BUSTYPE_PCMCIA);
  52. #else
  53. return false;
  54. #endif
  55. };
  56. static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
  57. {
  58. #ifdef CONFIG_B43_BCMA
  59. if (dev->bus_type == B43_BUS_BCMA)
  60. return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
  61. #endif
  62. #ifdef CONFIG_B43_SSB
  63. if (dev->bus_type == B43_BUS_SSB)
  64. return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
  65. #endif
  66. return false;
  67. }
  68. static inline bool b43_bus_host_is_sdio(struct b43_bus_dev *dev)
  69. {
  70. #ifdef CONFIG_B43_SSB
  71. return (dev->bus_type == B43_BUS_SSB &&
  72. dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO);
  73. #else
  74. return false;
  75. #endif
  76. }
  77. struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
  78. struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
  79. void *b43_bus_get_wldev(struct b43_bus_dev *dev);
  80. void b43_bus_set_wldev(struct b43_bus_dev *dev, void *data);
  81. #endif /* B43_BUS_H_ */