18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
48c2ecf20Sopenharmony_ci * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
58c2ecf20Sopenharmony_ci * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __MT76X0U_EEPROM_H
98c2ecf20Sopenharmony_ci#define __MT76X0U_EEPROM_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "../mt76x02_eeprom.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistruct mt76x02_dev;
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define MT76X0U_EE_MAX_VER		0x0c
168c2ecf20Sopenharmony_ci#define MT76X0_EEPROM_SIZE		512
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciint mt76x0_eeprom_init(struct mt76x02_dev *dev);
198c2ecf20Sopenharmony_civoid mt76x0_read_rx_gain(struct mt76x02_dev *dev);
208c2ecf20Sopenharmony_civoid mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev,
218c2ecf20Sopenharmony_ci				  struct ieee80211_channel *chan,
228c2ecf20Sopenharmony_ci				  struct mt76_rate_power *t);
238c2ecf20Sopenharmony_civoid mt76x0_get_power_info(struct mt76x02_dev *dev,
248c2ecf20Sopenharmony_ci			   struct ieee80211_channel *chan, s8 *tp);
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic inline s8 s6_to_s8(u32 val)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci	s8 ret = val & GENMASK(5, 0);
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	if (ret & BIT(5))
318c2ecf20Sopenharmony_ci		ret -= BIT(6);
328c2ecf20Sopenharmony_ci	return ret;
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline bool mt76x0_tssi_enabled(struct mt76x02_dev *dev)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	return (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
388c2ecf20Sopenharmony_ci		MT_EE_NIC_CONF_1_TX_ALC_EN);
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#endif
42