11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2e87b5039SStanislaw Gruszka /*
3e87b5039SStanislaw Gruszka  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4e87b5039SStanislaw Gruszka  * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5e87b5039SStanislaw Gruszka  * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
6e87b5039SStanislaw Gruszka  */
7e87b5039SStanislaw Gruszka 
8e87b5039SStanislaw Gruszka #ifndef __MT76X0U_EEPROM_H
9e87b5039SStanislaw Gruszka #define __MT76X0U_EEPROM_H
10e87b5039SStanislaw Gruszka 
11eef40d20SLorenzo Bianconi #include "../mt76x02_eeprom.h"
12eef40d20SLorenzo Bianconi 
13b2d871c0SLorenzo Bianconi struct mt76x02_dev;
14e87b5039SStanislaw Gruszka 
15e87b5039SStanislaw Gruszka #define MT76X0U_EE_MAX_VER		0x0c
16e87b5039SStanislaw Gruszka #define MT76X0_EEPROM_SIZE		512
17e87b5039SStanislaw Gruszka 
18b2d871c0SLorenzo Bianconi int mt76x0_eeprom_init(struct mt76x02_dev *dev);
19b2d871c0SLorenzo Bianconi void mt76x0_read_rx_gain(struct mt76x02_dev *dev);
201ffe410eSLorenzo Bianconi void mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev,
211ffe410eSLorenzo Bianconi 				  struct ieee80211_channel *chan,
22*b376d963SFelix Fietkau 				  struct mt76x02_rate_power *t);
231ffe410eSLorenzo Bianconi void mt76x0_get_power_info(struct mt76x02_dev *dev,
241ffe410eSLorenzo Bianconi 			   struct ieee80211_channel *chan, s8 *tp);
25e87b5039SStanislaw Gruszka 
s6_to_s8(u32 val)26b37bbc8cSLorenzo Bianconi static inline s8 s6_to_s8(u32 val)
27e87b5039SStanislaw Gruszka {
28b37bbc8cSLorenzo Bianconi 	s8 ret = val & GENMASK(5, 0);
29e87b5039SStanislaw Gruszka 
30b37bbc8cSLorenzo Bianconi 	if (ret & BIT(5))
31b37bbc8cSLorenzo Bianconi 		ret -= BIT(6);
32b37bbc8cSLorenzo Bianconi 	return ret;
33e87b5039SStanislaw Gruszka }
34e87b5039SStanislaw Gruszka 
mt76x0_tssi_enabled(struct mt76x02_dev * dev)354afeb396SLorenzo Bianconi static inline bool mt76x0_tssi_enabled(struct mt76x02_dev *dev)
364afeb396SLorenzo Bianconi {
374afeb396SLorenzo Bianconi 	return (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
384afeb396SLorenzo Bianconi 		MT_EE_NIC_CONF_1_TX_ALC_EN);
394afeb396SLorenzo Bianconi }
404afeb396SLorenzo Bianconi 
41e87b5039SStanislaw Gruszka #endif
42