mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
Unify rssi_offset parsing with mt76x2 driver using eeprom utility routines available in mt76x02-lib module Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
78 lines
1.5 KiB
C
78 lines
1.5 KiB
C
/*
|
|
* Copyright (C) 2014 Felix Fietkau <[email protected]>
|
|
* Copyright (C) 2015 Jakub Kicinski <[email protected]>
|
|
* Copyright (C) 2018 Stanislaw Gruszka <[email protected]>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2
|
|
* as published by the Free Software Foundation
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef __MT76X0U_EEPROM_H
|
|
#define __MT76X0U_EEPROM_H
|
|
|
|
#include "../mt76x02_eeprom.h"
|
|
|
|
struct mt76x0_dev;
|
|
|
|
#define MT76X0U_EE_MAX_VER 0x0c
|
|
#define MT76X0_EEPROM_SIZE 512
|
|
|
|
struct reg_channel_bounds {
|
|
u8 start;
|
|
u8 num;
|
|
};
|
|
|
|
struct mt76x0_caldata {
|
|
s8 rssi_offset[2];
|
|
s8 lna_gain;
|
|
};
|
|
|
|
struct mt76x0_eeprom_params {
|
|
u8 rf_freq_off;
|
|
s16 temp_off;
|
|
|
|
/* TX_PWR_CFG_* values from EEPROM for 20 and 40 Mhz bandwidths. */
|
|
u32 tx_pwr_cfg_2g[5][2];
|
|
u32 tx_pwr_cfg_5g[5][2];
|
|
|
|
u8 tx_pwr_per_chan[58];
|
|
};
|
|
|
|
int mt76x0_eeprom_init(struct mt76x0_dev *dev);
|
|
void mt76x0_read_rx_gain(struct mt76x0_dev *dev);
|
|
|
|
static inline u32 s6_validate(u32 reg)
|
|
{
|
|
WARN_ON(reg & ~GENMASK(5, 0));
|
|
return reg & GENMASK(5, 0);
|
|
}
|
|
|
|
static inline int s6_to_int(u32 reg)
|
|
{
|
|
int s6;
|
|
|
|
s6 = s6_validate(reg);
|
|
if (s6 & BIT(5))
|
|
s6 -= BIT(6);
|
|
|
|
return s6;
|
|
}
|
|
|
|
static inline u32 int_to_s6(int val)
|
|
{
|
|
if (val < -0x20)
|
|
return 0x20;
|
|
if (val > 0x1f)
|
|
return 0x1f;
|
|
|
|
return val & 0x3f;
|
|
}
|
|
|
|
#endif
|