Skip to contentSkip to conversation

mt76: mt76x0: reduce duplication in setting rf bandwidth parameters

PATCH In review Felix Fietkau 2 participants 4 messages Oct 18, 2018 – Oct 19, 2018

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/2 mt76: mt76x0: reduce duplication in setting rf bandwidth parameters

Remove initval table with duplicated registers and driver specific flags in favor of a function that sets the registers directly

---
 .../mediatek/mt76/mt76x0/initvals_phy.h       | 45 ------------
 .../net/wireless/mediatek/mt76/mt76x0/phy.c   | 73 +++++++++++++------
 2 files changed, 49 insertions(+), 69 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/initvals_phy.h +0 -45
index 56c6fa73daf5..755dd6749b65 100644
@@ -233,51 +233,6 @@ static const struct mt76_reg_pair mt76x0_rf_vga_channel_0_tab[] = {
 	{ MT_RF(7, 74), 0x00 },
 };
 
-static const struct mt76x0_rf_switch_item mt76x0_rf_bw_switch_tab[] = {
-	/* bank, reg	bw/band			value */
-	{ MT_RF(0, 17),	RF_G_BAND | RF_BW_20,	0x00 },
-	{ MT_RF(0, 17),	RF_G_BAND | RF_BW_40,	0x00 },
-	{ MT_RF(0, 17),	RF_A_BAND | RF_BW_20,	0x00 },
-	{ MT_RF(0, 17),	RF_A_BAND | RF_BW_40,	0x00 },
-	{ MT_RF(0, 17),	RF_A_BAND | RF_BW_80,	0x00 },
-	{ MT_RF(7,  6),	RF_G_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7,  6),	RF_G_BAND | RF_BW_40,	0x1C },
-	{ MT_RF(7,  6),	RF_A_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7,  6),	RF_A_BAND | RF_BW_40,	0x20 },
-	{ MT_RF(7,  6),	RF_A_BAND | RF_BW_80,	0x10 },
-	{ MT_RF(7,  7),	RF_G_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7,  7),	RF_G_BAND | RF_BW_40,	0x20 },
-	{ MT_RF(7,  7),	RF_A_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7,  7),	RF_A_BAND | RF_BW_40,	0x20 },
-	{ MT_RF(7,  7),	RF_A_BAND | RF_BW_80,	0x10 },
-	{ MT_RF(7,  8),	RF_G_BAND | RF_BW_20,	0x03 },
-	{ MT_RF(7,  8),	RF_G_BAND | RF_BW_40,	0x01 },
-	{ MT_RF(7,  8),	RF_A_BAND | RF_BW_20,	0x03 },
-	{ MT_RF(7,  8),	RF_A_BAND | RF_BW_40,	0x01 },
-	{ MT_RF(7,  8),	RF_A_BAND | RF_BW_80,	0x00 },
-	{ MT_RF(7, 58),	RF_G_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7, 58),	RF_G_BAND | RF_BW_40,	0x40 },
-	{ MT_RF(7, 58),	RF_A_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7, 58),	RF_A_BAND | RF_BW_40,	0x40 },
-	{ MT_RF(7, 58),	RF_A_BAND | RF_BW_80,	0x10 },
-	{ MT_RF(7, 59),	RF_G_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7, 59),	RF_G_BAND | RF_BW_40,	0x40 },
-	{ MT_RF(7, 59),	RF_A_BAND | RF_BW_20,	0x40 },
-	{ MT_RF(7, 59),	RF_A_BAND | RF_BW_40,	0x40 },
-	{ MT_RF(7, 59),	RF_A_BAND | RF_BW_80,	0x10 },
-	{ MT_RF(7, 60),	RF_G_BAND | RF_BW_20,	0xAA },
-	{ MT_RF(7, 60),	RF_G_BAND | RF_BW_40,	0xAA },
-	{ MT_RF(7, 60),	RF_A_BAND | RF_BW_20,	0xAA },
-	{ MT_RF(7, 60),	RF_A_BAND | RF_BW_40,	0xAA },
-	{ MT_RF(7, 60),	RF_A_BAND | RF_BW_80,	0xAA },
-	{ MT_RF(7, 76),	RF_BW_20,		0x40 },
-	{ MT_RF(7, 76),	RF_BW_40,		0x40 },
-	{ MT_RF(7, 76),	RF_BW_80,		0x10 },
-	{ MT_RF(7, 77),	RF_BW_20,		0x40 },
-	{ MT_RF(7, 77),	RF_BW_40,		0x40 },
-	{ MT_RF(7, 77),	RF_BW_80,		0x10 },
-};
-
 static const struct mt76x0_rf_switch_item mt76x0_rf_band_switch_tab[] = {
 	/* bank, reg		bw/band		value */
 	{ MT_RF(0,  16),	RF_G_BAND,	0x20 },
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +49 -24

106 lines not on this page · raw message

Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH 2/2 mt76: mt76x0: handle chip specific initval differences

Some RF registers need different values for various chips. For at least mt76x0_rf_central_tab registers, overwriting them later does not work, as the wrong values can cause the entire system to hang on some devices with MT7610E

---
 .../wireless/mediatek/mt76/mt76x0/mt76x0.h    |  6 ++-
 .../net/wireless/mediatek/mt76/mt76x0/phy.c   | 47 ++++++++++++++++++-
 2 files changed, 49 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h +4 -2
index 33475788bc26..989ed00c0b7a 100644
@@ -33,8 +33,10 @@
 
 static inline bool is_mt7610e(struct mt76x02_dev *dev)
 {
-	/* TODO */
-	return false;
+	if (!mt76_is_mmio(dev))
+		return false;
+
+	return mt76_chip(&dev->mt76) == 0x7610;
 }
 
 static inline bool is_mt7630(struct mt76x02_dev *dev)
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +45 -2

58 lines not on this page · raw message

Signature · 1 line
2.17.0
#2 lore raw
In reply to Felix Fietkau
Quoted 2 lines · Felix Fietkau

Remove initval table with duplicated registers and driver specific flags in favor of a function that sets the registers directly

There are few problems with this patch: MT_RF(7, 77) is missing and band is not taken directly from chandef but overwriteen in 'rf_band = mt76x0_frequency_plan[i].band' . But even after fixing that I can not make MT7610U associate with AP on 5GHz. So please drop this patch.

Thanks
Stanislaw

author maintainer
#3 lore raw
Quoted 9 lines · Stanislaw Gruszka
Quoted 2 lines · Felix Fietkau

Remove initval table with duplicated registers and driver specific flags in favor of a function that sets the registers directly

There are few problems with this patch: MT_RF(7, 77) is missing and band is not taken directly from chandef but overwriteen in 'rf_band = mt76x0_frequency_plan[i].band' . But even after fixing that I can not make MT7610U associate with AP on 5GHz. So please drop this patch.

Will do, thanks.

- Felix