isl_38xx.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2002 Intersil Americas Inc.
  4. */
  5. #ifndef _ISL_38XX_H
  6. #define _ISL_38XX_H
  7. #include <asm/io.h>
  8. #include <asm/byteorder.h>
  9. #define ISL38XX_CB_RX_QSIZE 8
  10. #define ISL38XX_CB_TX_QSIZE 32
  11. /* ISL38XX Access Point Specific definitions */
  12. #define ISL38XX_MAX_WDS_LINKS 8
  13. /* ISL38xx Client Specific definitions */
  14. #define ISL38XX_PSM_ACTIVE_STATE 0
  15. #define ISL38XX_PSM_POWERSAVE_STATE 1
  16. /* ISL38XX Host Interface Definitions */
  17. #define ISL38XX_PCI_MEM_SIZE 0x02000
  18. #define ISL38XX_MEMORY_WINDOW_SIZE 0x01000
  19. #define ISL38XX_DEV_FIRMWARE_ADDRES 0x20000
  20. #define ISL38XX_WRITEIO_DELAY 10 /* in us */
  21. #define ISL38XX_RESET_DELAY 50 /* in ms */
  22. #define ISL38XX_WAIT_CYCLE 10 /* in 10ms */
  23. #define ISL38XX_MAX_WAIT_CYCLES 10
  24. /* PCI Memory Area */
  25. #define ISL38XX_HARDWARE_REG 0x0000
  26. #define ISL38XX_CARDBUS_CIS 0x0800
  27. #define ISL38XX_DIRECT_MEM_WIN 0x1000
  28. /* Hardware registers */
  29. #define ISL38XX_DEV_INT_REG 0x0000
  30. #define ISL38XX_INT_IDENT_REG 0x0010
  31. #define ISL38XX_INT_ACK_REG 0x0014
  32. #define ISL38XX_INT_EN_REG 0x0018
  33. #define ISL38XX_GEN_PURP_COM_REG_1 0x0020
  34. #define ISL38XX_GEN_PURP_COM_REG_2 0x0024
  35. #define ISL38XX_CTRL_BLK_BASE_REG ISL38XX_GEN_PURP_COM_REG_1
  36. #define ISL38XX_DIR_MEM_BASE_REG 0x0030
  37. #define ISL38XX_CTRL_STAT_REG 0x0078
  38. /* High end mobos queue up pci writes, the following
  39. * is used to "read" from after a write to force flush */
  40. #define ISL38XX_PCI_POSTING_FLUSH ISL38XX_INT_EN_REG
  41. /**
  42. * isl38xx_w32_flush - PCI iomem write helper
  43. * @base: (host) memory base address of the device
  44. * @val: 32bit value (host order) to write
  45. * @offset: byte offset into @base to write value to
  46. *
  47. * This helper takes care of writing a 32bit datum to the
  48. * specified offset into the device's pci memory space, and making sure
  49. * the pci memory buffers get flushed by performing one harmless read
  50. * from the %ISL38XX_PCI_POSTING_FLUSH offset.
  51. */
  52. static inline void
  53. isl38xx_w32_flush(void __iomem *base, u32 val, unsigned long offset)
  54. {
  55. writel(val, base + offset);
  56. (void) readl(base + ISL38XX_PCI_POSTING_FLUSH);
  57. }
  58. /* Device Interrupt register bits */
  59. #define ISL38XX_DEV_INT_RESET 0x0001
  60. #define ISL38XX_DEV_INT_UPDATE 0x0002
  61. #define ISL38XX_DEV_INT_WAKEUP 0x0008
  62. #define ISL38XX_DEV_INT_SLEEP 0x0010
  63. /* Interrupt Identification/Acknowledge/Enable register bits */
  64. #define ISL38XX_INT_IDENT_UPDATE 0x0002
  65. #define ISL38XX_INT_IDENT_INIT 0x0004
  66. #define ISL38XX_INT_IDENT_WAKEUP 0x0008
  67. #define ISL38XX_INT_IDENT_SLEEP 0x0010
  68. #define ISL38XX_INT_SOURCES 0x001E
  69. /* Control/Status register bits */
  70. /* Looks like there are other meaningful bits
  71. 0x20004400 seen in normal operation,
  72. 0x200044db at 'timeout waiting for mgmt response'
  73. */
  74. #define ISL38XX_CTRL_STAT_SLEEPMODE 0x00000200
  75. #define ISL38XX_CTRL_STAT_CLKRUN 0x00800000
  76. #define ISL38XX_CTRL_STAT_RESET 0x10000000
  77. #define ISL38XX_CTRL_STAT_RAMBOOT 0x20000000
  78. #define ISL38XX_CTRL_STAT_STARTHALTED 0x40000000
  79. #define ISL38XX_CTRL_STAT_HOST_OVERRIDE 0x80000000
  80. /* Control Block definitions */
  81. #define ISL38XX_CB_RX_DATA_LQ 0
  82. #define ISL38XX_CB_TX_DATA_LQ 1
  83. #define ISL38XX_CB_RX_DATA_HQ 2
  84. #define ISL38XX_CB_TX_DATA_HQ 3
  85. #define ISL38XX_CB_RX_MGMTQ 4
  86. #define ISL38XX_CB_TX_MGMTQ 5
  87. #define ISL38XX_CB_QCOUNT 6
  88. #define ISL38XX_CB_MGMT_QSIZE 4
  89. #define ISL38XX_MIN_QTHRESHOLD 4 /* fragments */
  90. /* Memory Manager definitions */
  91. #define MGMT_FRAME_SIZE 1500 /* >= size struct obj_bsslist */
  92. #define MGMT_TX_FRAME_COUNT 24 /* max 4 + spare 4 + 8 init */
  93. #define MGMT_RX_FRAME_COUNT 24 /* 4*4 + spare 8 */
  94. #define MGMT_FRAME_COUNT (MGMT_TX_FRAME_COUNT + MGMT_RX_FRAME_COUNT)
  95. #define CONTROL_BLOCK_SIZE 1024 /* should be enough */
  96. #define PSM_FRAME_SIZE 1536
  97. #define PSM_MINIMAL_STATION_COUNT 64
  98. #define PSM_FRAME_COUNT PSM_MINIMAL_STATION_COUNT
  99. #define PSM_BUFFER_SIZE PSM_FRAME_SIZE * PSM_FRAME_COUNT
  100. #define MAX_TRAP_RX_QUEUE 4
  101. #define HOST_MEM_BLOCK CONTROL_BLOCK_SIZE + PSM_BUFFER_SIZE
  102. /* Fragment package definitions */
  103. #define FRAGMENT_FLAG_MF 0x0001
  104. #define MAX_FRAGMENT_SIZE 1536
  105. /* In monitor mode frames have a header. I don't know exactly how big those
  106. * frame can be but I've never seen any frame bigger than 1584... :
  107. */
  108. #define MAX_FRAGMENT_SIZE_RX 1600
  109. typedef struct {
  110. __le32 address; /* physical address on host */
  111. __le16 size; /* packet size */
  112. __le16 flags; /* set of bit-wise flags */
  113. } isl38xx_fragment;
  114. struct isl38xx_cb {
  115. __le32 driver_curr_frag[ISL38XX_CB_QCOUNT];
  116. __le32 device_curr_frag[ISL38XX_CB_QCOUNT];
  117. isl38xx_fragment rx_data_low[ISL38XX_CB_RX_QSIZE];
  118. isl38xx_fragment tx_data_low[ISL38XX_CB_TX_QSIZE];
  119. isl38xx_fragment rx_data_high[ISL38XX_CB_RX_QSIZE];
  120. isl38xx_fragment tx_data_high[ISL38XX_CB_TX_QSIZE];
  121. isl38xx_fragment rx_data_mgmt[ISL38XX_CB_MGMT_QSIZE];
  122. isl38xx_fragment tx_data_mgmt[ISL38XX_CB_MGMT_QSIZE];
  123. };
  124. typedef struct isl38xx_cb isl38xx_control_block;
  125. /* determine number of entries currently in queue */
  126. int isl38xx_in_queue(isl38xx_control_block *cb, int queue);
  127. void isl38xx_disable_interrupts(void __iomem *);
  128. void isl38xx_enable_common_interrupts(void __iomem *);
  129. void isl38xx_handle_sleep_request(isl38xx_control_block *, int *,
  130. void __iomem *);
  131. void isl38xx_handle_wakeup(isl38xx_control_block *, int *, void __iomem *);
  132. void isl38xx_trigger_device(int, void __iomem *);
  133. void isl38xx_interface_reset(void __iomem *, dma_addr_t);
  134. #endif /* _ISL_38XX_H */