-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathfirmware.h
More file actions
209 lines (182 loc) · 5.63 KB
/
firmware.h
File metadata and controls
209 lines (182 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#ifndef _MORSE_FW_H_
#define _MORSE_FW_H_
/*
* Copyright 2017-2022 Morse Micro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#include <linux/firmware.h>
#include <linux/completion.h>
#include "capabilities.h"
#include "misc.h"
#include "yaps-hw.h"
#define BCF_DATABASE_SIZE (1024) /* From firmware */
#define MORSE_FW_DIR "morse"
#define MORSE_FW_FULLMAC_STRING "-flm"
#define MORSE_FW_THIN_LMAC_STRING "-tlm"
#define MORSE_FW_VIRTUAL_STA_STRING "-vst"
#define MORSE_FW_EXT ".bin"
#define IFLASH_BASE_ADDR 0x400000
#define DFLASH_BASE_ADDR 0xC00000
#define MAX_BCF_NAME_LEN 64
/* FW_CAPABILITIES_FLAGS_WIDTH = ceil(MORSE_CAPS_MAX_HW_LEN / 32) */
#define FW_CAPABILITIES_FLAGS_WIDTH (4)
#if (FW_CAPABILITIES_FLAGS_WIDTH > CAPABILITIES_FLAGS_WIDTH)
#error "Capability subset filled by firmware is to big"
#endif
enum morse_fw_info_tlv_type {
MORSE_FW_INFO_TLV_BCF_ADDR = 1,
MORSE_FW_INFO_TLV_COREDUMP_MEM_REGION = 2,
};
struct morse_fw_info_tlv_coredump_mem {
/* region type (see morse_coredump_mem_region_type) */
__le32 region_type;
/* on-chip start address of the region */
__le32 start;
/* the length of the region */
__le32 len;
} __packed;
struct morse_fw_info_tlv {
__le16 type;
__le16 length;
u8 val[];
} __packed;
enum morse_fw_extended_host_table_tag {
/* The S1G capability tag */
MORSE_FW_HOST_TABLE_TAG_S1G_CAPABILITIES = 0,
MORSE_FW_HOST_TABLE_TAG_PAGER_BYPASS_TX_STATUS = 1,
MORSE_FW_HOST_TABLE_TAG_INSERT_SKB_CHECKSUM = 2,
MORSE_FW_HOST_TABLE_TAG_YAPS_TABLE = 3,
MORSE_FW_HOST_TABLE_TAG_PAGER_PKT_MEMORY = 4,
MORSE_FW_HOST_TABLE_TAG_PAGER_BYPASS_CMD_RESP = 5,
};
struct extended_host_table_tlv_hdr {
/** The tag used to identify which capability this represents */
__le16 tag;
/** The length of the capability structure including this header */
__le16 length;
} __packed;
struct extended_host_table_capabilities_s1g {
/** The common header for the capabilities */
struct extended_host_table_tlv_hdr header;
/** The capability flags */
__le32 flags[FW_CAPABILITIES_FLAGS_WIDTH];
/**
* The minimum A-MPDU start spacing required by firmware.
* Value | Description
* ------|------------
* 0 | No restriction
* 1 | 1/4 us
* 2 | 1/2 us
* 3 | 1 us
* 4 | 2 us
* 5 | 4 us
* 6 | 8 us
* 7 | 16 us
*/
u8 ampdu_mss;
/** The beamformee STS capability value */
u8 beamformee_sts_capability;
/* Number of sounding dimensions */
u8 number_sounding_dimensions;
/**
* The maximum A-MPDU length. This is the exponent value such that
* (2^(13 + exponent) - 1) is the length
*/
u8 maximum_ampdu_length;
/**
* Offset to apply to the specification's mmss table to signal further
* minimum mpdu start spacing.
*/
u8 morse_mmss_offset;
} __packed;
struct extended_host_table_pager_bypass_tx_status {
struct extended_host_table_tlv_hdr header;
__le32 tx_status_buffer_addr;
};
struct extended_host_table_pager_bypass_cmd_resp {
struct extended_host_table_tlv_hdr header;
__le32 cmd_resp_buffer_addr;
};
struct extended_host_table_insert_skb_checksum {
struct extended_host_table_tlv_hdr header;
u8 insert_and_validate_checksum;
};
struct extended_host_table_yaps_table {
struct extended_host_table_tlv_hdr header;
struct morse_yaps_hw_table yaps_table;
} __packed;
struct extended_host_table_pager_pkt_memory {
struct extended_host_table_tlv_hdr header;
/** Base address of packet memory */
__le32 base_addr;
/** Length (bytes) of one page */
u16 page_len;
/** Length (bytes) reserved at start of page (should not be modified) */
u8 page_len_reserved;
/** Number of pages */
u8 num;
};
struct extended_host_table {
/** The length of this table */
__le32 extended_host_table_length;
/** Device MAC address */
u8 dev_mac_addr[6];
/** Data TLVs in the extended host table*/
u8 ext_host_table_data_tlvs[];
} __packed;
int morse_firmware_init(struct morse *mors, uint test_mode);
/**
* @brief Do necessary preparation and then initialise firmware
*
* @param mors The global morse config object
* @param reset_hw Perform non-destructive reset of the chip,
* preserving the existing sdio enumeration whilst
* resetting the firmware state
* @param reattach_hw Reattach to running hardware
* @return 0 if success else error code
*/
int morse_firmware_prepare_and_init(struct morse *mors, bool reset_hw, bool reattach_hw);
/**
* morse_firmware_build_fw_path() - Build path to the firmware image.
* @mors: The global morse config object.
*
* Caller must kfree() the returned value.
*
* Return: allocated firmware path, or %NULL on error
*/
char *morse_firmware_build_fw_path(struct morse *mors);
/**
* morse_firmware_parse_extended_host_table - Read and parse the firmware's extended host table
*
* @mors pointer to the chip object
*
* Return: 0 if the table was read successfully, error otherwise.
*/
int morse_firmware_parse_extended_host_table(struct morse *mors);
/**
* morse_firmware_get_host_table_ptr - Read the host table
*
* @mors pointer to the chip object
*
* Return: 0 if the table was read successfully, error otherwise.
*/
int morse_firmware_get_host_table_ptr(struct morse *mors);
/**
* morse_firmware_magic_verify - Verify magic number from host table
*
* @mors pointer to the chip object
*
* Return: 0 if successfully verified, error otherwise.
*/
int morse_firmware_magic_verify(struct morse *mors);
/**
* morse_firmware_check_compatibility - Verify that the driver is compatible with the firmware
*
* @mors pointer to the chip object
*
* Return: 0 if compatible, error otherwise.
*/
int morse_firmware_check_compatibility(struct morse *mors);
#endif /* !_MORSE_FW_H_ */