bus.h 2.3 KB

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