]> git.ipfire.org Git - thirdparty/linux.git/blame - drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.h
mt76x0: eeprom: fix chan_vs_power map in mt76x0_get_power_info
[thirdparty/linux.git] / drivers / net / wireless / mediatek / mt76 / mt76x0 / eeprom.h
CommitLineData
e87b5039
SG
1/*
2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
4 * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __MT76X0U_EEPROM_H
17#define __MT76X0U_EEPROM_H
18
eef40d20 19#include "../mt76x02_eeprom.h"
e87b5039 20
b2d871c0 21struct mt76x02_dev;
e87b5039 22
eef40d20
LB
23#define MT76X0U_EE_MAX_VER 0x0c
24#define MT76X0_EEPROM_SIZE 512
e87b5039 25
b2d871c0
LB
26int mt76x0_eeprom_init(struct mt76x02_dev *dev);
27void mt76x0_read_rx_gain(struct mt76x02_dev *dev);
28void mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev);
05672636 29void mt76x0_get_power_info(struct mt76x02_dev *dev, s8 *tp);
e87b5039 30
b37bbc8c 31static inline s8 s6_to_s8(u32 val)
e87b5039 32{
b37bbc8c 33 s8 ret = val & GENMASK(5, 0);
e87b5039 34
b37bbc8c
LB
35 if (ret & BIT(5))
36 ret -= BIT(6);
37 return ret;
e87b5039
SG
38}
39
4afeb396
LB
40static inline bool mt76x0_tssi_enabled(struct mt76x02_dev *dev)
41{
42 return (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
43 MT_EE_NIC_CONF_1_TX_ALC_EN);
44}
45
e87b5039 46#endif