diff --git a/Makefile b/Makefile index fc7c8c1..b4eb1cb 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ OBJ=\ mt7610.o \ mt7620.o \ mt7628.o \ - mt7662.o \ mt7663.o \ mtkeepmgr.o \ rt5592.o \ diff --git a/mt7610.c b/mt7610.c index 7ee9661..b68e472 100644 --- a/mt7610.c +++ b/mt7610.c @@ -287,18 +287,29 @@ static void mt7610_dump_rate_power(struct main_ctx *mc) } } -static void mt7610_read_tssi_tcomp_tbl(struct main_ctx *mc, - unsigned off, int8_t *tbl) +static void mt7610_read_eeprom_to_tbl(struct main_ctx *mc, + unsigned off, unsigned size, int8_t *tbl) { uint16_t val; int i; /* Read data from eeprom */ - for (i = 0; i < E_TSSI_TCOMP_N / 2; ++i) { + for (i = 0; i < size / 2; ++i) { val = eep_read_word(mc, off + 2 * i); tbl[2 * i + 0] = (val >> 8) & 0xff; tbl[2 * i + 1] = (val >> 0) & 0xff; } + if (size % 2) { + val = eep_read_word(mc, off + size - 2); + tbl[size - 1] = (val >> 0) & 0xff; + } +} + + +static void mt7610_read_tssi_tcomp_tbl(struct main_ctx *mc, + unsigned off, int8_t *tbl) +{ + mt7610_read_eeprom_to_tbl(mc, off, E_TSSI_TCOMP_N, tbl); /* Place neutral element in the middle of the table */ memmove(&tbl[E_TSSI_TCOMP_N / 2 + 1], &tbl[E_TSSI_TCOMP_N / 2], @@ -343,6 +354,51 @@ static const char *mt7610_dump_tssi_tcomp(struct main_ctx *mc, unsigned off) return mt7610_dump_tssi_tcomp_tbl(tbl); } +static const char *mt7610_dump_generic_tbl(int8_t *tbl, unsigned size) +{ + static char buf[0x100]; + char *p = buf, *e = buf + sizeof(buf); + unsigned i; + + for (i = 0; i < size; ++i) + p += snprintf(p, e - p, " %+4d", tbl[i]); + + return &buf[1]; +} + +static const char *mt7610_dump_itxbf_tank_tbl(int8_t *tbl, unsigned size) +{ + static char buf[0x100]; + char *p = buf, *e = buf + sizeof(buf); + unsigned i; + + for (i = 0; i < size / 2; ++i) + p += snprintf(p, e - p, " %+4d/%d", tbl[2*i], tbl[2*i + 1]); + + return &buf[1]; +} + +static const char *mt7610_dump_itxbf_tank(struct main_ctx *mc, unsigned off) +{ + int8_t tbl[E_ITXBF_CAL_TANK_N]; + mt7610_read_eeprom_to_tbl(mc, off, E_ITXBF_CAL_TANK_N, tbl); + return mt7610_dump_itxbf_tank_tbl(tbl, E_ITXBF_CAL_TANK_N); +} + +static const char *mt7610_dump_itxbf_divphase(struct main_ctx *mc, unsigned off) +{ + int8_t tbl[E_ITXBF_CAL_DIV_N]; + mt7610_read_eeprom_to_tbl(mc, off, E_ITXBF_CAL_DIV_N, tbl); + return mt7610_dump_generic_tbl(tbl, E_ITXBF_CAL_DIV_N); +} + +static const char *mt7610_dump_itxbf_resphase(struct main_ctx *mc, unsigned off) +{ + int8_t tbl[E_ITXBF_CAL_RES_N]; + mt7610_read_eeprom_to_tbl(mc, off, E_ITXBF_CAL_RES_N, tbl); + return mt7610_dump_generic_tbl(tbl, E_ITXBF_CAL_RES_N); +} + static int mt7610_eep_parse(struct main_ctx *mc) { static const char *ant_div_str[] = { @@ -492,7 +548,19 @@ static int mt7610_eep_parse(struct main_ctx *mc) mt7610_dump_tssi_tcomp(mc, E_TSSI_TCOMP_5G_2_BASE)); printf("\n"); + printf("[Implicit TX beamforming parameters]\n"); + printf(" CAL tank rep/iqm : {%s}\n", + mt7610_dump_itxbf_tank(mc, E_ITXBF_CAL_TANK)); + printf(" CAL divphase : {%s}\n", + mt7610_dump_itxbf_divphase(mc, E_ITXBF_CAL_DIVPHASE)); + + printf(" CAL rephase init : {%s}\n", + mt7610_dump_itxbf_resphase(mc, E_ITXBF_CAL_RESPHASE)); + printf(" CAL rephase error : {%s}\n", + mt7610_dump_itxbf_resphase(mc, E_ITXBF_CAL_RESPHASE_ERR)); return 0; } CHIP(MT7610, 0x7610, mt7610_eep_parse); +CHIP(MT7612, 0x7612, mt7610_eep_parse); +CHIP(MT7662, 0x7662, mt7610_eep_parse); diff --git a/mt7610.h b/mt7610.h index b7ee96f..773a62d 100644 --- a/mt7610.h +++ b/mt7610.h @@ -245,7 +245,17 @@ #define E_TX_AGC_STEP_VAL 0x00ff /* Tx AGC step value, 1/2 dBm */ #define E_TX_AGC_STEP_VAL_S 0 +#define E_ITXBF_CAL 0x00c0 // LNA parameters +#define E_ITXBF_CAL_TANK 0x0180 // tank code +#define E_ITXBF_CAL_DIVPHASE 0x018A // divider phase +#define E_ITXBF_CAL_RESPHASE 0x0190 // phase +#define E_ITXBF_CAL_RESPHASE_ERR 0x019E // phase error +#define E_ITXBF_CAL_TANK_N (E_ITXBF_CAL_DIVPHASE - E_ITXBF_CAL_TANK) +#define E_ITXBF_CAL_DIV_N (E_ITXBF_CAL_RESPHASE - E_ITXBF_CAL_DIVPHASE) +#define E_ITXBF_CAL_RES_N (E_ITXBF_CAL_RESPHASE_ERR - E_ITXBF_CAL_RESPHASE) + #define E_USB_VID 0x01c2 #define E_USB_PID 0x01c4 + #endif /* !_MT7610_H_ */ diff --git a/mt7662.c b/mt7662.c deleted file mode 100644 index e6fea8e..0000000 --- a/mt7662.c +++ /dev/null @@ -1,38 +0,0 @@ -/** - * MediaTek MT7662 EEPROM parser - * - * Copyright (c) 2021, Sergey Ryazanov - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include "mtkeepmgr.h" -#include "utils.h" -#include "mt7662.h" - -static int mt7662_eep_parse(struct main_ctx *mc) -{ - printf("[Device identification]\n"); - printf(" MacAddr : %s\n", get_macaddr_str(mc)); - printf(" PCIDevID : %04Xh\n", eep_read_word(mc, E_PCI_DEV_ID)); - printf(" PCIVenID : %04Xh\n", eep_read_word(mc, E_PCI_VEN_ID)); - printf(" PCISubsysDevID: %04Xh\n", eep_read_word(mc, E_PCI_SUB_DEV_ID)); - printf(" PCISubsysVenID: %04Xh\n", eep_read_word(mc, E_PCI_SUB_VEN_ID)); - printf("\n"); - - return 0; -} - -CHIP(MT7662, 0x7662, mt7662_eep_parse); diff --git a/mt7662.h b/mt7662.h deleted file mode 100644 index ba79b89..0000000 --- a/mt7662.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * MT7662 EEPROM definitions - * - * Copyright (c) 2021, Sergey Ryazanov - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MT7662_H_ -#define _MT7662_H_ - -#define E_PCI_DEV_ID 0x000a -#define E_PCI_VEN_ID 0x000c - -#define E_PCI_SUB_DEV_ID 0x0012 -#define E_PCI_SUB_VEN_ID 0x0014 - -#endif /* !_MT7662_H_ */