Linux-libre 5.4.48-gnu
[librecmc/linux-libre.git] / drivers / net / wireless / ti / wl18xx / wl18xx.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * This file is part of wl18xx
4  *
5  * Copyright (C) 2011 Texas Instruments Inc.
6  */
7
8 #ifndef __WL18XX_PRIV_H__
9 #define __WL18XX_PRIV_H__
10
11 #include "conf.h"
12
13 /* minimum FW required for driver */
14 #define WL18XX_CHIP_VER         8
15 #define WL18XX_IFTYPE_VER       9
16 #define WL18XX_MAJOR_VER        WLCORE_FW_VER_IGNORE
17 #define WL18XX_SUBTYPE_VER      WLCORE_FW_VER_IGNORE
18 #define WL18XX_MINOR_VER        58
19
20 #define WL18XX_CMD_MAX_SIZE          740
21
22 #define WL18XX_AGGR_BUFFER_SIZE         (13 * PAGE_SIZE)
23
24 #define WL18XX_NUM_TX_DESCRIPTORS 32
25 #define WL18XX_NUM_RX_DESCRIPTORS 32
26
27 #define WL18XX_NUM_MAC_ADDRESSES 2
28
29 #define WL18XX_RX_BA_MAX_SESSIONS 13
30
31 #define WL18XX_MAX_AP_STATIONS 10
32 #define WL18XX_MAX_LINKS 16
33
34 struct wl18xx_priv {
35         /* buffer for sending commands to FW */
36         u8 cmd_buf[WL18XX_CMD_MAX_SIZE];
37
38         struct wl18xx_priv_conf conf;
39
40         /* Index of last released Tx desc in FW */
41         u8 last_fw_rls_idx;
42
43         /* number of keys requiring extra spare mem-blocks */
44         int extra_spare_key_count;
45 };
46
47 #define WL18XX_FW_MAX_TX_STATUS_DESC 33
48
49 struct wl18xx_fw_status_priv {
50         /*
51          * Index in released_tx_desc for first byte that holds
52          * released tx host desc
53          */
54         u8 fw_release_idx;
55
56         /*
57          * Array of host Tx descriptors, where fw_release_idx
58          * indicated the first released idx.
59          */
60         u8 released_tx_desc[WL18XX_FW_MAX_TX_STATUS_DESC];
61
62         /* A bitmap representing the currently suspended links. The suspend
63          * is short lived, for multi-channel Tx requirements.
64          */
65         __le32 link_suspend_bitmap;
66
67         /* packet threshold for an "almost empty" AC,
68          * for Tx schedulng purposes
69          */
70         u8 tx_ac_threshold;
71
72         /* number of packets to queue up for a link in PS */
73         u8 tx_ps_threshold;
74
75         /* number of packet to queue up for a suspended link */
76         u8 tx_suspend_threshold;
77
78         /* Should have less than this number of packets in queue of a slow
79          * link to qualify as high priority link
80          */
81         u8 tx_slow_link_prio_threshold;
82
83         /* Should have less than this number of packets in queue of a fast
84          * link to qualify as high priority link
85          */
86         u8 tx_fast_link_prio_threshold;
87
88         /* Should have less than this number of packets in queue of a slow
89          * link before we stop queuing up packets for it.
90          */
91         u8 tx_slow_stop_threshold;
92
93         /* Should have less than this number of packets in queue of a fast
94          * link before we stop queuing up packets for it.
95          */
96         u8 tx_fast_stop_threshold;
97
98         u8 padding[3];
99 };
100
101 struct wl18xx_fw_packet_counters {
102         /* Cumulative counter of released packets per AC */
103         u8 tx_released_pkts[NUM_TX_QUEUES];
104
105         /* Cumulative counter of freed packets per HLID */
106         u8 tx_lnk_free_pkts[WL18XX_MAX_LINKS];
107
108         /* Cumulative counter of released Voice memory blocks */
109         u8 tx_voice_released_blks;
110
111         /* Tx rate of the last transmitted packet */
112         u8 tx_last_rate;
113
114         /* Tx rate or Tx rate estimate pre-calculated by fw in mbps units */
115         u8 tx_last_rate_mbps;
116
117         /* hlid for which the rates were reported */
118         u8 hlid;
119 } __packed;
120
121 /* FW status registers */
122 struct wl18xx_fw_status {
123         __le32 intr;
124         u8  fw_rx_counter;
125         u8  drv_rx_counter;
126         u8  reserved;
127         u8  tx_results_counter;
128         __le32 rx_pkt_descs[WL18XX_NUM_RX_DESCRIPTORS];
129
130         __le32 fw_localtime;
131
132         /*
133          * A bitmap (where each bit represents a single HLID)
134          * to indicate if the station is in PS mode.
135          */
136         __le32 link_ps_bitmap;
137
138         /*
139          * A bitmap (where each bit represents a single HLID) to indicate
140          * if the station is in Fast mode
141          */
142         __le32 link_fast_bitmap;
143
144         /* Cumulative counter of total released mem blocks since FW-reset */
145         __le32 total_released_blks;
146
147         /* Size (in Memory Blocks) of TX pool */
148         __le32 tx_total;
149
150         struct wl18xx_fw_packet_counters counters;
151
152         __le32 log_start_addr;
153
154         /* Private status to be used by the lower drivers */
155         struct wl18xx_fw_status_priv priv;
156 } __packed;
157
158 #define WL18XX_PHY_VERSION_MAX_LEN 20
159
160 struct wl18xx_static_data_priv {
161         char phy_version[WL18XX_PHY_VERSION_MAX_LEN];
162 };
163
164 struct wl18xx_clk_cfg {
165         u32 n;
166         u32 m;
167         u32 p;
168         u32 q;
169         bool swallow;
170 };
171
172 enum {
173         CLOCK_CONFIG_16_2_M     = 1,
174         CLOCK_CONFIG_16_368_M,
175         CLOCK_CONFIG_16_8_M,
176         CLOCK_CONFIG_19_2_M,
177         CLOCK_CONFIG_26_M,
178         CLOCK_CONFIG_32_736_M,
179         CLOCK_CONFIG_33_6_M,
180         CLOCK_CONFIG_38_468_M,
181         CLOCK_CONFIG_52_M,
182
183         NUM_CLOCK_CONFIGS,
184 };
185
186 #endif /* __WL18XX_PRIV_H__ */