202 lines
3.5 KiB
C
202 lines
3.5 KiB
C
|
/* SPDX-License-Identifier: ISC */
|
||
|
/* Copyright (C) 2020 MediaTek Inc. */
|
||
|
|
||
|
#ifndef __MT7921_MCU_H
|
||
|
#define __MT7921_MCU_H
|
||
|
|
||
|
#include "../mt76_connac_mcu.h"
|
||
|
|
||
|
struct mt7921_mcu_txd {
|
||
|
__le32 txd[8];
|
||
|
|
||
|
__le16 len;
|
||
|
__le16 pq_id;
|
||
|
|
||
|
u8 cid;
|
||
|
u8 pkt_type;
|
||
|
u8 set_query; /* FW don't care */
|
||
|
u8 seq;
|
||
|
|
||
|
u8 uc_d2b0_rev;
|
||
|
u8 ext_cid;
|
||
|
u8 s2d_index;
|
||
|
u8 ext_cid_ack;
|
||
|
|
||
|
u32 reserved[5];
|
||
|
} __packed __aligned(4);
|
||
|
|
||
|
/**
|
||
|
* struct mt7921_uni_txd - mcu command descriptor for firmware v3
|
||
|
* @txd: hardware descriptor
|
||
|
* @len: total length not including txd
|
||
|
* @cid: command identifier
|
||
|
* @pkt_type: must be 0xa0 (cmd packet by long format)
|
||
|
* @frag_n: fragment number
|
||
|
* @seq: sequence number
|
||
|
* @checksum: 0 mean there is no checksum
|
||
|
* @s2d_index: index for command source and destination
|
||
|
* Definition | value | note
|
||
|
* CMD_S2D_IDX_H2N | 0x00 | command from HOST to WM
|
||
|
* CMD_S2D_IDX_C2N | 0x01 | command from WA to WM
|
||
|
* CMD_S2D_IDX_H2C | 0x02 | command from HOST to WA
|
||
|
* CMD_S2D_IDX_H2N_AND_H2C | 0x03 | command from HOST to WA and WM
|
||
|
*
|
||
|
* @option: command option
|
||
|
* BIT[0]: UNI_CMD_OPT_BIT_ACK
|
||
|
* set to 1 to request a fw reply
|
||
|
* if UNI_CMD_OPT_BIT_0_ACK is set and UNI_CMD_OPT_BIT_2_SET_QUERY
|
||
|
* is set, mcu firmware will send response event EID = 0x01
|
||
|
* (UNI_EVENT_ID_CMD_RESULT) to the host.
|
||
|
* BIT[1]: UNI_CMD_OPT_BIT_UNI_CMD
|
||
|
* 0: original command
|
||
|
* 1: unified command
|
||
|
* BIT[2]: UNI_CMD_OPT_BIT_SET_QUERY
|
||
|
* 0: QUERY command
|
||
|
* 1: SET command
|
||
|
*/
|
||
|
struct mt7921_uni_txd {
|
||
|
__le32 txd[8];
|
||
|
|
||
|
/* DW1 */
|
||
|
__le16 len;
|
||
|
__le16 cid;
|
||
|
|
||
|
/* DW2 */
|
||
|
u8 reserved;
|
||
|
u8 pkt_type;
|
||
|
u8 frag_n;
|
||
|
u8 seq;
|
||
|
|
||
|
/* DW3 */
|
||
|
__le16 checksum;
|
||
|
u8 s2d_index;
|
||
|
u8 option;
|
||
|
|
||
|
/* DW4 */
|
||
|
u8 reserved2[4];
|
||
|
} __packed __aligned(4);
|
||
|
|
||
|
struct mt7921_mcu_tx_done_event {
|
||
|
u8 pid;
|
||
|
u8 status;
|
||
|
__le16 seq;
|
||
|
|
||
|
u8 wlan_idx;
|
||
|
u8 tx_cnt;
|
||
|
__le16 tx_rate;
|
||
|
|
||
|
u8 flag;
|
||
|
u8 tid;
|
||
|
u8 rsp_rate;
|
||
|
u8 mcs;
|
||
|
|
||
|
u8 bw;
|
||
|
u8 tx_pwr;
|
||
|
u8 reason;
|
||
|
u8 rsv0[1];
|
||
|
|
||
|
__le32 delay;
|
||
|
__le32 timestamp;
|
||
|
__le32 applied_flag;
|
||
|
u8 txs[28];
|
||
|
|
||
|
u8 rsv1[32];
|
||
|
} __packed;
|
||
|
|
||
|
/* ext event table */
|
||
|
enum {
|
||
|
MCU_EXT_EVENT_RATE_REPORT = 0x87,
|
||
|
};
|
||
|
|
||
|
struct mt7921_mcu_rxd {
|
||
|
__le32 rxd[6];
|
||
|
|
||
|
__le16 len;
|
||
|
__le16 pkt_type_id;
|
||
|
|
||
|
u8 eid;
|
||
|
u8 seq;
|
||
|
__le16 __rsv;
|
||
|
|
||
|
u8 ext_eid;
|
||
|
u8 __rsv1[2];
|
||
|
u8 s2d_index;
|
||
|
};
|
||
|
|
||
|
struct mt7921_mcu_eeprom_info {
|
||
|
__le32 addr;
|
||
|
__le32 valid;
|
||
|
u8 data[16];
|
||
|
} __packed;
|
||
|
|
||
|
#define MT_RA_RATE_NSS GENMASK(8, 6)
|
||
|
#define MT_RA_RATE_MCS GENMASK(3, 0)
|
||
|
#define MT_RA_RATE_TX_MODE GENMASK(12, 9)
|
||
|
#define MT_RA_RATE_DCM_EN BIT(4)
|
||
|
#define MT_RA_RATE_BW GENMASK(14, 13)
|
||
|
|
||
|
#define MCU_PQ_ID(p, q) (((p) << 15) | ((q) << 10))
|
||
|
#define MCU_PKT_ID 0xa0
|
||
|
|
||
|
struct mt7921_mcu_uni_event {
|
||
|
u8 cid;
|
||
|
u8 pad[3];
|
||
|
__le32 status; /* 0: success, others: fail */
|
||
|
} __packed;
|
||
|
|
||
|
enum {
|
||
|
MT_EBF = BIT(0), /* explicit beamforming */
|
||
|
MT_IBF = BIT(1) /* implicit beamforming */
|
||
|
};
|
||
|
|
||
|
struct mt7921_mcu_reg_event {
|
||
|
__le32 reg;
|
||
|
__le32 val;
|
||
|
} __packed;
|
||
|
|
||
|
struct mt7921_mcu_ant_id_config {
|
||
|
u8 ant_id[4];
|
||
|
} __packed;
|
||
|
|
||
|
struct mt7921_txpwr_req {
|
||
|
u8 ver;
|
||
|
u8 action;
|
||
|
__le16 len;
|
||
|
u8 dbdc_idx;
|
||
|
u8 rsv[3];
|
||
|
} __packed;
|
||
|
|
||
|
struct mt7921_txpwr_event {
|
||
|
u8 ver;
|
||
|
u8 action;
|
||
|
__le16 len;
|
||
|
struct mt7921_txpwr txpwr;
|
||
|
} __packed;
|
||
|
|
||
|
enum {
|
||
|
TM_SWITCH_MODE,
|
||
|
TM_SET_AT_CMD,
|
||
|
TM_QUERY_AT_CMD,
|
||
|
};
|
||
|
|
||
|
enum {
|
||
|
MT7921_TM_NORMAL,
|
||
|
MT7921_TM_TESTMODE,
|
||
|
MT7921_TM_ICAP,
|
||
|
MT7921_TM_ICAP_OVERLAP,
|
||
|
MT7921_TM_WIFISPECTRUM,
|
||
|
};
|
||
|
|
||
|
struct mt7921_rftest_cmd {
|
||
|
u8 action;
|
||
|
u8 rsv[3];
|
||
|
__le32 param0;
|
||
|
__le32 param1;
|
||
|
} __packed;
|
||
|
|
||
|
struct mt7921_rftest_evt {
|
||
|
__le32 param0;
|
||
|
__le32 param1;
|
||
|
} __packed;
|
||
|
#endif
|