aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965-hw.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-hw.h634
1 files changed, 32 insertions, 602 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index 1a66b508a8ea..fce950f4163c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -62,13 +62,18 @@
62 *****************************************************************************/ 62 *****************************************************************************/
63/* 63/*
64 * Please use this file (iwl-4965-hw.h) only for hardware-related definitions. 64 * Please use this file (iwl-4965-hw.h) only for hardware-related definitions.
65 * Use iwl-4965-commands.h for uCode API definitions. 65 * Use iwl-commands.h for uCode API definitions.
66 * Use iwl-4965.h for driver implementation definitions. 66 * Use iwl-dev.h for driver implementation definitions.
67 */ 67 */
68 68
69#ifndef __iwl_4965_hw_h__ 69#ifndef __iwl_4965_hw_h__
70#define __iwl_4965_hw_h__ 70#define __iwl_4965_hw_h__
71 71
72#include "iwl-fh.h"
73
74/* EERPROM */
75#define IWL4965_EEPROM_IMG_SIZE 1024
76
72/* 77/*
73 * uCode queue management definitions ... 78 * uCode queue management definitions ...
74 * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4. 79 * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4.
@@ -77,7 +82,7 @@
77 */ 82 */
78#define IWL_CMD_QUEUE_NUM 4 83#define IWL_CMD_QUEUE_NUM 4
79#define IWL_CMD_FIFO_NUM 4 84#define IWL_CMD_FIFO_NUM 4
80#define IWL_BACK_QUEUE_FIRST_ID 7 85#define IWL49_FIRST_AMPDU_QUEUE 7
81 86
82/* Tx rates */ 87/* Tx rates */
83#define IWL_CCK_RATES 4 88#define IWL_CCK_RATES 4
@@ -93,11 +98,16 @@
93#define IWL_RSSI_OFFSET 44 98#define IWL_RSSI_OFFSET 44
94 99
95 100
96#include "iwl-4965-commands.h" 101#include "iwl-commands.h"
97 102
98#define PCI_LINK_CTRL 0x0F0 103/* PCI registers */
104#define PCI_LINK_CTRL 0x0F0 /* 1 byte */
99#define PCI_POWER_SOURCE 0x0C8 105#define PCI_POWER_SOURCE 0x0C8
100#define PCI_REG_WUM8 0x0E8 106#define PCI_REG_WUM8 0x0E8
107
108/* PCI register values */
109#define PCI_LINK_VAL_L0S_EN 0x01
110#define PCI_LINK_VAL_L1_EN 0x02
101#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) 111#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
102 112
103#define TFD_QUEUE_SIZE_MAX (256) 113#define TFD_QUEUE_SIZE_MAX (256)
@@ -131,10 +141,8 @@
131#define RTC_DATA_LOWER_BOUND (0x800000) 141#define RTC_DATA_LOWER_BOUND (0x800000)
132#define IWL49_RTC_DATA_UPPER_BOUND (0x80A000) 142#define IWL49_RTC_DATA_UPPER_BOUND (0x80A000)
133 143
134#define IWL49_RTC_INST_SIZE \ 144#define IWL49_RTC_INST_SIZE (IWL49_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
135 (IWL49_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND) 145#define IWL49_RTC_DATA_SIZE (IWL49_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
136#define IWL49_RTC_DATA_SIZE \
137 (IWL49_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
138 146
139#define IWL_MAX_INST_SIZE IWL49_RTC_INST_SIZE 147#define IWL_MAX_INST_SIZE IWL49_RTC_INST_SIZE
140#define IWL_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE 148#define IWL_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE
@@ -785,585 +793,6 @@ enum {
785 793
786/********************* END TXPOWER *****************************************/ 794/********************* END TXPOWER *****************************************/
787 795
788/****************************/
789/* Flow Handler Definitions */
790/****************************/
791
792/**
793 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
794 * Addresses are offsets from device's PCI hardware base address.
795 */
796#define FH_MEM_LOWER_BOUND (0x1000)
797#define FH_MEM_UPPER_BOUND (0x1EF0)
798
799/**
800 * Keep-Warm (KW) buffer base address.
801 *
802 * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
803 * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
804 * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host
805 * from going into a power-savings mode that would cause higher DRAM latency,
806 * and possible data over/under-runs, before all Tx/Rx is complete.
807 *
808 * Driver loads IWL_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
809 * of the buffer, which must be 4K aligned. Once this is set up, the 4965
810 * automatically invokes keep-warm accesses when normal accesses might not
811 * be sufficient to maintain fast DRAM response.
812 *
813 * Bit fields:
814 * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
815 */
816#define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
817
818
819/**
820 * TFD Circular Buffers Base (CBBC) addresses
821 *
822 * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
823 * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
824 * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04
825 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
826 * aligned (address bits 0-7 must be 0).
827 *
828 * Bit fields in each pointer register:
829 * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
830 */
831#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
832#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
833
834/* Find TFD CB base pointer for given queue (range 0-15). */
835#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
836
837
838/**
839 * Rx SRAM Control and Status Registers (RSCSR)
840 *
841 * These registers provide handshake between driver and 4965 for the Rx queue
842 * (this queue handles *all* command responses, notifications, Rx data, etc.
843 * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx
844 * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
845 * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
846 * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
847 * mapping between RBDs and RBs.
848 *
849 * Driver must allocate host DRAM memory for the following, and set the
850 * physical address of each into 4965 registers:
851 *
852 * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
853 * entries (although any power of 2, up to 4096, is selectable by driver).
854 * Each entry (1 dword) points to a receive buffer (RB) of consistent size
855 * (typically 4K, although 8K or 16K are also selectable by driver).
856 * Driver sets up RB size and number of RBDs in the CB via Rx config
857 * register FH_MEM_RCSR_CHNL0_CONFIG_REG.
858 *
859 * Bit fields within one RBD:
860 * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
861 *
862 * Driver sets physical address [35:8] of base of RBD circular buffer
863 * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
864 *
865 * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
866 * (RBs) have been filled, via a "write pointer", actually the index of
867 * the RB's corresponding RBD within the circular buffer. Driver sets
868 * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
869 *
870 * Bit fields in lower dword of Rx status buffer (upper dword not used
871 * by driver; see struct iwl4965_shared, val0):
872 * 31-12: Not used by driver
873 * 11- 0: Index of last filled Rx buffer descriptor
874 * (4965 writes, driver reads this value)
875 *
876 * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
877 * enter pointers to these RBs into contiguous RBD circular buffer entries,
878 * and update the 4965's "write" index register, FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
879 *
880 * This "write" index corresponds to the *next* RBD that the driver will make
881 * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
882 * the circular buffer. This value should initially be 0 (before preparing any
883 * RBs), should be 8 after preparing the first 8 RBs (for example), and must
884 * wrap back to 0 at the end of the circular buffer (but don't wrap before
885 * "read" index has advanced past 1! See below).
886 * NOTE: 4965 EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
887 *
888 * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
889 * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
890 * to tell the driver the index of the latest filled RBD. The driver must
891 * read this "read" index from DRAM after receiving an Rx interrupt from 4965.
892 *
893 * The driver must also internally keep track of a third index, which is the
894 * next RBD to process. When receiving an Rx interrupt, driver should process
895 * all filled but unprocessed RBs up to, but not including, the RB
896 * corresponding to the "read" index. For example, if "read" index becomes "1",
897 * driver may process the RB pointed to by RBD 0. Depending on volume of
898 * traffic, there may be many RBs to process.
899 *
900 * If read index == write index, 4965 thinks there is no room to put new data.
901 * Due to this, the maximum number of filled RBs is 255, instead of 256. To
902 * be safe, make sure that there is a gap of at least 2 RBDs between "write"
903 * and "read" indexes; that is, make sure that there are no more than 254
904 * buffers waiting to be filled.
905 */
906#define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
907#define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
908#define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
909
910/**
911 * Physical base address of 8-byte Rx Status buffer.
912 * Bit fields:
913 * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
914 */
915#define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
916
917/**
918 * Physical base address of Rx Buffer Descriptor Circular Buffer.
919 * Bit fields:
920 * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
921 */
922#define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
923
924/**
925 * Rx write pointer (index, really!).
926 * Bit fields:
927 * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
928 * NOTE: For 256-entry circular buffer, use only bits [7:0].
929 */
930#define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
931#define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
932
933
934/**
935 * Rx Config/Status Registers (RCSR)
936 * Rx Config Reg for channel 0 (only channel used)
937 *
938 * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
939 * normal operation (see bit fields).
940 *
941 * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
942 * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for
943 * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
944 *
945 * Bit fields:
946 * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
947 * '10' operate normally
948 * 29-24: reserved
949 * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
950 * min "5" for 32 RBDs, max "12" for 4096 RBDs.
951 * 19-18: reserved
952 * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
953 * '10' 12K, '11' 16K.
954 * 15-14: reserved
955 * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
956 * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
957 * typical value 0x10 (about 1/2 msec)
958 * 3- 0: reserved
959 */
960#define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
961#define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
962#define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
963
964#define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
965
966#define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
967#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
968#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
969#define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
970#define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
971#define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
972
973#define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
974#define FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_BITSHIFT (4)
975#define RX_RB_TIMEOUT (0x10)
976
977#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
978#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
979#define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
980
981#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
982#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000)
983#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000)
984#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000)
985
986#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
987#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
988
989
990/**
991 * Rx Shared Status Registers (RSSR)
992 *
993 * After stopping Rx DMA channel (writing 0 to FH_MEM_RCSR_CHNL0_CONFIG_REG),
994 * driver must poll FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
995 *
996 * Bit fields:
997 * 24: 1 = Channel 0 is idle
998 *
999 * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV contain
1000 * default values that should not be altered by the driver.
1001 */
1002#define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
1003#define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
1004
1005#define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
1006#define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
1007#define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
1008
1009#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
1010
1011
1012/**
1013 * Transmit DMA Channel Control/Status Registers (TCSR)
1014 *
1015 * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
1016 * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1017 * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1018 *
1019 * To use a Tx DMA channel, driver must initialize its
1020 * IWL_FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1021 *
1022 * IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1023 * IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1024 *
1025 * All other bits should be 0.
1026 *
1027 * Bit fields:
1028 * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1029 * '10' operate normally
1030 * 29- 4: Reserved, set to "0"
1031 * 3: Enable internal DMA requests (1, normal operation), disable (0)
1032 * 2- 0: Reserved, set to "0"
1033 */
1034#define IWL_FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
1035#define IWL_FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60)
1036
1037/* Find Control/Status reg for given Tx DMA/FIFO channel */
1038#define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1039 (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
1040
1041#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
1042#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
1043
1044#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1045#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1046#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1047
1048/**
1049 * Tx Shared Status Registers (TSSR)
1050 *
1051 * After stopping Tx DMA channel (writing 0 to
1052 * IWL_FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1053 * IWL_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
1054 * (channel's buffers empty | no pending requests).
1055 *
1056 * Bit fields:
1057 * 31-24: 1 = Channel buffers empty (channel 7:0)
1058 * 23-16: 1 = No pending requests (channel 7:0)
1059 */
1060#define IWL_FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0)
1061#define IWL_FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0)
1062
1063#define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
1064
1065#define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
1066 ((1 << (_chnl)) << 24)
1067#define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
1068 ((1 << (_chnl)) << 16)
1069
1070#define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
1071 (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
1072 IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
1073
1074
1075/********************* START TX SCHEDULER *************************************/
1076
1077/**
1078 * 4965 Tx Scheduler
1079 *
1080 * The Tx Scheduler selects the next frame to be transmitted, chosing TFDs
1081 * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
1082 * host DRAM. It steers each frame's Tx command (which contains the frame
1083 * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
1084 * device. A queue maps to only one (selectable by driver) Tx DMA channel,
1085 * but one DMA channel may take input from several queues.
1086 *
1087 * Tx DMA channels have dedicated purposes. For 4965, they are used as follows:
1088 *
1089 * 0 -- EDCA BK (background) frames, lowest priority
1090 * 1 -- EDCA BE (best effort) frames, normal priority
1091 * 2 -- EDCA VI (video) frames, higher priority
1092 * 3 -- EDCA VO (voice) and management frames, highest priority
1093 * 4 -- Commands (e.g. RXON, etc.)
1094 * 5 -- HCCA short frames
1095 * 6 -- HCCA long frames
1096 * 7 -- not used by driver (device-internal only)
1097 *
1098 * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
1099 * In addition, driver can map queues 7-15 to Tx DMA/FIFO channels 0-3 to
1100 * support 11n aggregation via EDCA DMA channels.
1101 *
1102 * The driver sets up each queue to work in one of two modes:
1103 *
1104 * 1) Scheduler-Ack, in which the scheduler automatically supports a
1105 * block-ack (BA) window of up to 64 TFDs. In this mode, each queue
1106 * contains TFDs for a unique combination of Recipient Address (RA)
1107 * and Traffic Identifier (TID), that is, traffic of a given
1108 * Quality-Of-Service (QOS) priority, destined for a single station.
1109 *
1110 * In scheduler-ack mode, the scheduler keeps track of the Tx status of
1111 * each frame within the BA window, including whether it's been transmitted,
1112 * and whether it's been acknowledged by the receiving station. The device
1113 * automatically processes block-acks received from the receiving STA,
1114 * and reschedules un-acked frames to be retransmitted (successful
1115 * Tx completion may end up being out-of-order).
1116 *
1117 * The driver must maintain the queue's Byte Count table in host DRAM
1118 * (struct iwl4965_sched_queue_byte_cnt_tbl) for this mode.
1119 * This mode does not support fragmentation.
1120 *
1121 * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
1122 * The device may automatically retry Tx, but will retry only one frame
1123 * at a time, until receiving ACK from receiving station, or reaching
1124 * retry limit and giving up.
1125 *
1126 * The command queue (#4) must use this mode!
1127 * This mode does not require use of the Byte Count table in host DRAM.
1128 *
1129 * Driver controls scheduler operation via 3 means:
1130 * 1) Scheduler registers
1131 * 2) Shared scheduler data base in internal 4956 SRAM
1132 * 3) Shared data in host DRAM
1133 *
1134 * Initialization:
1135 *
1136 * When loading, driver should allocate memory for:
1137 * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs.
1138 * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory
1139 * (1024 bytes for each queue).
1140 *
1141 * After receiving "Alive" response from uCode, driver must initialize
1142 * the scheduler (especially for queue #4, the command queue, otherwise
1143 * the driver can't issue commands!):
1144 */
1145
1146/**
1147 * Max Tx window size is the max number of contiguous TFDs that the scheduler
1148 * can keep track of at one time when creating block-ack chains of frames.
1149 * Note that "64" matches the number of ack bits in a block-ack packet.
1150 * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize
1151 * SCD_CONTEXT_QUEUE_OFFSET(x) values.
1152 */
1153#define SCD_WIN_SIZE 64
1154#define SCD_FRAME_LIMIT 64
1155
1156/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */
1157#define SCD_START_OFFSET 0xa02c00
1158
1159/*
1160 * 4965 tells driver SRAM address for internal scheduler structs via this reg.
1161 * Value is valid only after "Alive" response from uCode.
1162 */
1163#define SCD_SRAM_BASE_ADDR (SCD_START_OFFSET + 0x0)
1164
1165/*
1166 * Driver may need to update queue-empty bits after changing queue's
1167 * write and read pointers (indexes) during (re-)initialization (i.e. when
1168 * scheduler is not tracking what's happening).
1169 * Bit fields:
1170 * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit
1171 * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty
1172 * NOTE: This register is not used by Linux driver.
1173 */
1174#define SCD_EMPTY_BITS (SCD_START_OFFSET + 0x4)
1175
1176/*
1177 * Physical base address of array of byte count (BC) circular buffers (CBs).
1178 * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode.
1179 * This register points to BC CB for queue 0, must be on 1024-byte boundary.
1180 * Others are spaced by 1024 bytes.
1181 * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad.
1182 * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff).
1183 * Bit fields:
1184 * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned.
1185 */
1186#define SCD_DRAM_BASE_ADDR (SCD_START_OFFSET + 0x10)
1187
1188/*
1189 * Enables any/all Tx DMA/FIFO channels.
1190 * Scheduler generates requests for only the active channels.
1191 * Set this to 0xff to enable all 8 channels (normal usage).
1192 * Bit fields:
1193 * 7- 0: Enable (1), disable (0), one bit for each channel 0-7
1194 */
1195#define SCD_TXFACT (SCD_START_OFFSET + 0x1c)
1196
1197/* Mask to enable contiguous Tx DMA/FIFO channels between "lo" and "hi". */
1198#define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
1199 ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
1200
1201/*
1202 * Queue (x) Write Pointers (indexes, really!), one for each Tx queue.
1203 * Initialized and updated by driver as new TFDs are added to queue.
1204 * NOTE: If using Block Ack, index must correspond to frame's
1205 * Start Sequence Number; index = (SSN & 0xff)
1206 * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses?
1207 */
1208#define SCD_QUEUE_WRPTR(x) (SCD_START_OFFSET + 0x24 + (x) * 4)
1209
1210/*
1211 * Queue (x) Read Pointers (indexes, really!), one for each Tx queue.
1212 * For FIFO mode, index indicates next frame to transmit.
1213 * For Scheduler-ACK mode, index indicates first frame in Tx window.
1214 * Initialized by driver, updated by scheduler.
1215 */
1216#define SCD_QUEUE_RDPTR(x) (SCD_START_OFFSET + 0x64 + (x) * 4)
1217
1218/*
1219 * Select which queues work in chain mode (1) vs. not (0).
1220 * Use chain mode to build chains of aggregated frames.
1221 * Bit fields:
1222 * 31-16: Reserved
1223 * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time
1224 * NOTE: If driver sets up queue for chain mode, it should be also set up
1225 * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x).
1226 */
1227#define SCD_QUEUECHAIN_SEL (SCD_START_OFFSET + 0xd0)
1228
1229/*
1230 * Select which queues interrupt driver when scheduler increments
1231 * a queue's read pointer (index).
1232 * Bit fields:
1233 * 31-16: Reserved
1234 * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled
1235 * NOTE: This functionality is apparently a no-op; driver relies on interrupts
1236 * from Rx queue to read Tx command responses and update Tx queues.
1237 */
1238#define SCD_INTERRUPT_MASK (SCD_START_OFFSET + 0xe4)
1239
1240/*
1241 * Queue search status registers. One for each queue.
1242 * Sets up queue mode and assigns queue to Tx DMA channel.
1243 * Bit fields:
1244 * 19-10: Write mask/enable bits for bits 0-9
1245 * 9: Driver should init to "0"
1246 * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0).
1247 * Driver should init to "1" for aggregation mode, or "0" otherwise.
1248 * 7-6: Driver should init to "0"
1249 * 5: Window Size Left; indicates whether scheduler can request
1250 * another TFD, based on window size, etc. Driver should init
1251 * this bit to "1" for aggregation mode, or "0" for non-agg.
1252 * 4-1: Tx FIFO to use (range 0-7).
1253 * 0: Queue is active (1), not active (0).
1254 * Other bits should be written as "0"
1255 *
1256 * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled
1257 * via SCD_QUEUECHAIN_SEL.
1258 */
1259#define SCD_QUEUE_STATUS_BITS(x) (SCD_START_OFFSET + 0x104 + (x) * 4)
1260
1261/* Bit field positions */
1262#define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
1263#define SCD_QUEUE_STTS_REG_POS_TXF (1)
1264#define SCD_QUEUE_STTS_REG_POS_WSL (5)
1265#define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
1266
1267/* Write masks */
1268#define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
1269#define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
1270
1271/**
1272 * 4965 internal SRAM structures for scheduler, shared with driver ...
1273 *
1274 * Driver should clear and initialize the following areas after receiving
1275 * "Alive" response from 4965 uCode, i.e. after initial
1276 * uCode load, or after a uCode load done for error recovery:
1277 *
1278 * SCD_CONTEXT_DATA_OFFSET (size 128 bytes)
1279 * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes)
1280 * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
1281 *
1282 * Driver accesses SRAM via HBUS_TARG_MEM_* registers.
1283 * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR.
1284 * All OFFSET values must be added to this base address.
1285 */
1286
1287/*
1288 * Queue context. One 8-byte entry for each of 16 queues.
1289 *
1290 * Driver should clear this entire area (size 0x80) to 0 after receiving
1291 * "Alive" notification from uCode. Additionally, driver should init
1292 * each queue's entry as follows:
1293 *
1294 * LS Dword bit fields:
1295 * 0-06: Max Tx window size for Scheduler-ACK. Driver should init to 64.
1296 *
1297 * MS Dword bit fields:
1298 * 16-22: Frame limit. Driver should init to 10 (0xa).
1299 *
1300 * Driver should init all other bits to 0.
1301 *
1302 * Init must be done after driver receives "Alive" response from 4965 uCode,
1303 * and when setting up queue for aggregation.
1304 */
1305#define SCD_CONTEXT_DATA_OFFSET 0x380
1306#define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
1307
1308#define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
1309#define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
1310#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
1311#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
1312
1313/*
1314 * Tx Status Bitmap
1315 *
1316 * Driver should clear this entire area (size 0x100) to 0 after receiving
1317 * "Alive" notification from uCode. Area is used only by device itself;
1318 * no other support (besides clearing) is required from driver.
1319 */
1320#define SCD_TX_STTS_BITMAP_OFFSET 0x400
1321
1322/*
1323 * RAxTID to queue translation mapping.
1324 *
1325 * When queue is in Scheduler-ACK mode, frames placed in a that queue must be
1326 * for only one combination of receiver address (RA) and traffic ID (TID), i.e.
1327 * one QOS priority level destined for one station (for this wireless link,
1328 * not final destination). The SCD_TRANSLATE_TABLE area provides 16 16-bit
1329 * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK
1330 * mode, the device ignores the mapping value.
1331 *
1332 * Bit fields, for each 16-bit map:
1333 * 15-9: Reserved, set to 0
1334 * 8-4: Index into device's station table for recipient station
1335 * 3-0: Traffic ID (tid), range 0-15
1336 *
1337 * Driver should clear this entire area (size 32 bytes) to 0 after receiving
1338 * "Alive" notification from uCode. To update a 16-bit map value, driver
1339 * must read a dword-aligned value from device SRAM, replace the 16-bit map
1340 * value of interest, and write the dword value back into device SRAM.
1341 */
1342#define SCD_TRANSLATE_TBL_OFFSET 0x500
1343
1344/* Find translation table dword to read/write for given queue */
1345#define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
1346 ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
1347
1348#define SCD_TXFIFO_POS_TID (0)
1349#define SCD_TXFIFO_POS_RA (4)
1350#define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
1351
1352/*********************** END TX SCHEDULER *************************************/
1353
1354static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
1355{
1356 return le32_to_cpu(rate_n_flags) & 0xFF;
1357}
1358static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags)
1359{
1360 return le32_to_cpu(rate_n_flags) & 0xFFFF;
1361}
1362static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
1363{
1364 return cpu_to_le32(flags|(u16)rate);
1365}
1366
1367 796
1368/** 797/**
1369 * Tx/Rx Queues 798 * Tx/Rx Queues
@@ -1385,14 +814,15 @@ static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
1385 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array 814 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array
1386 * in DRAM containing 256 Transmit Frame Descriptors (TFDs). 815 * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
1387 */ 816 */
1388#define IWL4965_MAX_WIN_SIZE 64 817#define IWL49_MAX_WIN_SIZE 64
1389#define IWL4965_QUEUE_SIZE 256 818#define IWL49_QUEUE_SIZE 256
1390#define IWL4965_NUM_FIFOS 7 819#define IWL49_NUM_FIFOS 7
1391#define IWL4965_MAX_NUM_QUEUES 16 820#define IWL49_CMD_FIFO_NUM 4
1392 821#define IWL49_NUM_QUEUES 16
822#define IWL49_NUM_AMPDU_QUEUES 8
1393 823
1394/** 824/**
1395 * struct iwl4965_tfd_frame_data 825 * struct iwl_tfd_frame_data
1396 * 826 *
1397 * Describes up to 2 buffers containing (contiguous) portions of a Tx frame. 827 * Describes up to 2 buffers containing (contiguous) portions of a Tx frame.
1398 * Each buffer must be on dword boundary. 828 * Each buffer must be on dword boundary.
@@ -1411,7 +841,7 @@ static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
1411 * 31-20: Tx buffer 2 length (bytes) 841 * 31-20: Tx buffer 2 length (bytes)
1412 * 19- 0: Tx buffer 2 address bits [35:16] 842 * 19- 0: Tx buffer 2 address bits [35:16]
1413 */ 843 */
1414struct iwl4965_tfd_frame_data { 844struct iwl_tfd_frame_data {
1415 __le32 tb1_addr; 845 __le32 tb1_addr;
1416 846
1417 __le32 val1; 847 __le32 val1;
@@ -1441,7 +871,7 @@ struct iwl4965_tfd_frame_data {
1441 871
1442 872
1443/** 873/**
1444 * struct iwl4965_tfd_frame 874 * struct iwl_tfd_frame
1445 * 875 *
1446 * Transmit Frame Descriptor (TFD) 876 * Transmit Frame Descriptor (TFD)
1447 * 877 *
@@ -1468,7 +898,7 @@ struct iwl4965_tfd_frame_data {
1468 * 898 *
1469 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. 899 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
1470 */ 900 */
1471struct iwl4965_tfd_frame { 901struct iwl_tfd_frame {
1472 __le32 val0; 902 __le32 val0;
1473 /* __le32 rsvd1:24; */ 903 /* __le32 rsvd1:24; */
1474 /* __le32 num_tbs:5; */ 904 /* __le32 num_tbs:5; */
@@ -1477,7 +907,7 @@ struct iwl4965_tfd_frame {
1477#define IWL_num_tbs_SYM val0 907#define IWL_num_tbs_SYM val0
1478 /* __le32 rsvd2:1; */ 908 /* __le32 rsvd2:1; */
1479 /* __le32 padding:2; */ 909 /* __le32 padding:2; */
1480 struct iwl4965_tfd_frame_data pa[10]; 910 struct iwl_tfd_frame_data pa[10];
1481 __le32 reserved; 911 __le32 reserved;
1482} __attribute__ ((packed)); 912} __attribute__ ((packed));
1483 913
@@ -1520,10 +950,10 @@ struct iwl4965_queue_byte_cnt_entry {
1520 * 4965 assumes tables are separated by 1024 bytes. 950 * 4965 assumes tables are separated by 1024 bytes.
1521 */ 951 */
1522struct iwl4965_sched_queue_byte_cnt_tbl { 952struct iwl4965_sched_queue_byte_cnt_tbl {
1523 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE + 953 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL49_QUEUE_SIZE +
1524 IWL4965_MAX_WIN_SIZE]; 954 IWL49_MAX_WIN_SIZE];
1525 u8 dont_care[1024 - 955 u8 dont_care[1024 -
1526 (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) * 956 (IWL49_QUEUE_SIZE + IWL49_MAX_WIN_SIZE) *
1527 sizeof(__le16)]; 957 sizeof(__le16)];
1528} __attribute__ ((packed)); 958} __attribute__ ((packed));
1529 959
@@ -1553,7 +983,7 @@ struct iwl4965_sched_queue_byte_cnt_tbl {
1553 */ 983 */
1554struct iwl4965_shared { 984struct iwl4965_shared {
1555 struct iwl4965_sched_queue_byte_cnt_tbl 985 struct iwl4965_sched_queue_byte_cnt_tbl
1556 queues_byte_cnt_tbls[IWL4965_MAX_NUM_QUEUES]; 986 queues_byte_cnt_tbls[IWL49_NUM_QUEUES];
1557 __le32 rb_closed; 987 __le32 rb_closed;
1558 988
1559 /* __le32 rb_closed_stts_rb_num:12; */ 989 /* __le32 rb_closed_stts_rb_num:12; */