1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4 * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
7 #include <linux/kernel.h>
8 #include <linux/firmware.h>
9 #include <linux/delay.h>
15 int mt76x2_mcu_set_channel(struct mt76x02_dev
*dev
, u8 channel
, u8 bw
,
16 u8 bw_index
, bool scan
)
28 } __packed
__aligned(4) msg
= {
32 .chainmask
= cpu_to_le16(dev
->mt76
.chainmask
),
35 /* first set the channel without the extension channel info */
36 mt76_mcu_send_msg(dev
, CMD_SWITCH_CHANNEL_OP
, &msg
, sizeof(msg
), true);
38 usleep_range(5000, 10000);
40 msg
.ext_chan
= 0xe0 + bw_index
;
41 return mt76_mcu_send_msg(dev
, CMD_SWITCH_CHANNEL_OP
, &msg
, sizeof(msg
),
44 EXPORT_SYMBOL_GPL(mt76x2_mcu_set_channel
);
46 int mt76x2_mcu_load_cr(struct mt76x02_dev
*dev
, u8 type
, u8 temp_level
,
56 } __packed
__aligned(4) msg
= {
64 val
|= (mt76x02_eeprom_get(dev
, MT_EE_NIC_CONF_0
) >> 8) & 0x00ff;
65 val
|= (mt76x02_eeprom_get(dev
, MT_EE_NIC_CONF_1
) << 8) & 0xff00;
66 msg
.cfg
= cpu_to_le32(val
);
68 /* first set the channel without the extension channel info */
69 return mt76_mcu_send_msg(dev
, CMD_LOAD_CR
, &msg
, sizeof(msg
), true);
71 EXPORT_SYMBOL_GPL(mt76x2_mcu_load_cr
);
73 int mt76x2_mcu_init_gain(struct mt76x02_dev
*dev
, u8 channel
, u32 gain
,
79 } __packed
__aligned(4) msg
= {
80 .channel
= cpu_to_le32(channel
),
81 .gain_val
= cpu_to_le32(gain
),
85 msg
.channel
|= cpu_to_le32(BIT(31));
87 return mt76_mcu_send_msg(dev
, CMD_INIT_GAIN_OP
, &msg
, sizeof(msg
),
90 EXPORT_SYMBOL_GPL(mt76x2_mcu_init_gain
);
92 int mt76x2_mcu_tssi_comp(struct mt76x02_dev
*dev
,
93 struct mt76x2_tssi_comp
*tssi_data
)
97 struct mt76x2_tssi_comp data
;
98 } __packed
__aligned(4) msg
= {
99 .id
= cpu_to_le32(MCU_CAL_TSSI_COMP
),
103 return mt76_mcu_send_msg(dev
, CMD_CALIBRATION_OP
, &msg
, sizeof(msg
),
106 EXPORT_SYMBOL_GPL(mt76x2_mcu_tssi_comp
);