xref: /linux/drivers/net/wireless/morsemicro/mm81x/fw.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2017-2026 Morse Micro
4  */
5 
6 #ifndef _MM81X_FW_H_
7 #define _MM81X_FW_H_
8 
9 #include <linux/firmware.h>
10 #include <linux/completion.h>
11 #include <linux/elf.h>
12 #include "command_defs.h"
13 #include "yaps_hw.h"
14 
15 #define BCF_DATABASE_SIZE (1024)
16 #define MM81X_FW_DIR "morsemicro/mm81x"
17 #define MM81X_FW_EXT ".bin"
18 
19 #define MM81X_FW_VER_MAX HOST_CMD_SEMVER_MAJOR
20 #define MM81X_FW_VER_MIN 56
21 
22 /* FW_CAPABILITIES_FLAGS_WIDTH = ceil(MM81X_CAPS_MAX_HW_LEN / 32) */
23 #define FW_CAPABILITIES_FLAGS_WIDTH (4)
24 
25 struct mm81x_elf32_ehdr {
26 	unsigned char e_ident[EI_NIDENT];
27 	__le16 e_type;
28 	__le16 e_machine;
29 	__le32 e_version;
30 	__le32 e_entry;
31 	__le32 e_phoff;
32 	__le32 e_shoff;
33 	__le32 e_flags;
34 	__le16 e_ehsize;
35 	__le16 e_phentsize;
36 	__le16 e_phnum;
37 	__le16 e_shentsize;
38 	__le16 e_shnum;
39 	__le16 e_shstrndx;
40 } __packed;
41 
42 struct mm81x_elf32_shdr {
43 	__le32 sh_name;
44 	__le32 sh_type;
45 	__le32 sh_flags;
46 	__le32 sh_addr;
47 	__le32 sh_offset;
48 	__le32 sh_size;
49 	__le32 sh_link;
50 	__le32 sh_info;
51 	__le32 sh_addralign;
52 	__le32 sh_entsize;
53 } __packed;
54 
55 struct mm81x_elf32_phdr {
56 	__le32 p_type;
57 	__le32 p_offset;
58 	__le32 p_vaddr;
59 	__le32 p_paddr;
60 	__le32 p_filesz;
61 	__le32 p_memsz;
62 	__le32 p_flags;
63 	__le32 p_align;
64 } __packed;
65 
66 enum mm81x_fw_info_tlv_type {
67 	MM81X_FW_INFO_TLV_BCF_ADDR = 1,
68 };
69 
70 struct mm81x_fw_info_tlv {
71 	__le16 type;
72 	__le16 length;
73 	u8 val[];
74 } __packed;
75 
76 enum mm81x_fw_ext_host_tbl_tag {
77 	/* The S1G capability tag */
78 	MM81X_FW_HOST_TABLE_TAG_S1G_CAPABILITIES = 0,
79 	MM81X_FW_HOST_TABLE_TAG_PAGER_BYPASS_TX_STATUS = 1,
80 	MM81X_FW_HOST_TABLE_TAG_INSERT_SKB_CHECKSUM = 2,
81 	MM81X_FW_HOST_TABLE_TAG_YAPS_TABLE = 3,
82 	MM81X_FW_HOST_TABLE_TAG_PAGER_PKT_MEMORY = 4,
83 	MM81X_FW_HOST_TABLE_TAG_PAGER_BYPASS_CMD_RESP = 5,
84 };
85 
86 struct ext_host_tbl_tlv_hdr {
87 	/* The tag used to identify which capability this represents */
88 	__le16 tag;
89 	/* The length of the capability structure including this header */
90 	__le16 length;
91 } __packed;
92 
93 struct ext_host_tbl_s1g_caps {
94 	struct ext_host_tbl_tlv_hdr header;
95 	__le32 flags[FW_CAPABILITIES_FLAGS_WIDTH];
96 	/*
97 	 * The minimum A-MPDU start spacing required by firmware.
98 	 * Value | Description
99 	 * ------|------------
100 	 * 0     | No restriction
101 	 * 1     | 1/4 us
102 	 * 2     | 1/2 us
103 	 * 3     | 1 us
104 	 * 4     | 2 us
105 	 * 5     | 4 us
106 	 * 6     | 8 us
107 	 * 7     | 16 us
108 	 */
109 	u8 ampdu_mss;
110 	u8 beamformee_sts_capability;
111 	u8 number_sounding_dimensions;
112 	/*
113 	 * The maximum A-MPDU length. This is the exponent value such that
114 	 * (2^(13 + exponent) - 1) is the length
115 	 */
116 	u8 maximum_ampdu_length;
117 	/*
118 	 * Offset to apply to the specification's MMSS table to signal further
119 	 * minimum MPDU start spacing.
120 	 */
121 	u8 mm81x_mmss_offset;
122 } __packed;
123 
124 struct ext_host_tbl_insert_skb_checksum {
125 	struct ext_host_tbl_tlv_hdr header;
126 	u8 insert_and_validate_checksum;
127 };
128 
129 struct ext_host_tbl_yaps_table {
130 	struct ext_host_tbl_tlv_hdr header;
131 	struct mm81x_yaps_hw_table yaps_table;
132 } __packed;
133 
134 struct ext_host_tbl {
135 	__le32 ext_host_tbl_length;
136 	u8 dev_mac_addr[6];
137 	u8 ext_host_table_data_tlvs[];
138 } __packed;
139 
140 int mm81x_fw_init(struct mm81x *mors, bool reset);
141 int mm81x_fw_parse_ext_host_tbl(struct mm81x *mors);
142 
143 #endif /* !_MM81X_FW_H_ */
144