diff mbox series

mt76: mt7915: add debugfs knob to read efuse value from FW

Message ID 20210504125225.2536-1-shayne.chen@mediatek.com (mailing list archive)
State Changes Requested
Delegated to: Felix Fietkau
Headers show
Series mt76: mt7915: add debugfs knob to read efuse value from FW | expand

Commit Message

Shayne Chen May 4, 2021, 12:52 p.m. UTC
In efuse mode, mt7915 only reads efuse values from FW which driver need.
Add a debugfs knob to read addtional efuse values from a specific field,
which is useful in some cases such as checking if rf values in efuse
are properly burned.

An example of usage:
echo 0x400 > efuse_idx
hexdump -C eeprom

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7915/debugfs.c  | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Felix Fietkau May 28, 2021, 8:56 a.m. UTC | #1
On 2021-05-04 14:52, Shayne Chen wrote:
> In efuse mode, mt7915 only reads efuse values from FW which driver need.
> Add a debugfs knob to read addtional efuse values from a specific field,
> which is useful in some cases such as checking if rf values in efuse
> are properly burned.
> 
> An example of usage:
> echo 0x400 > efuse_idx
> hexdump -C eeprom
> 
> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
I'd prefer if we read the entire efuse and put it in a "otp" debugfs
file, like on older chips.

- Felix
Shayne Chen May 28, 2021, 2:20 p.m. UTC | #2
On Fri, 2021-05-28 at 10:56 +0200, Felix Fietkau wrote:
> On 2021-05-04 14:52, Shayne Chen wrote:
> > In efuse mode, mt7915 only reads efuse values from FW which driver
> > need.
> > Add a debugfs knob to read addtional efuse values from a specific
> > field,
> > which is useful in some cases such as checking if rf values in
> > efuse
> > are properly burned.
> > 
> > An example of usage:
> > echo 0x400 > efuse_idx
> > hexdump -C eeprom
> > 
> > Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
> 
> I'd prefer if we read the entire efuse and put it in a "otp" debugfs
> file, like on older chips.
> 
> - Felix

Hi Felix,

Got it. I'll send another patch, please drop this one.

Thanks,
Shayne
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index 6a8ddee..0526459 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -73,6 +73,21 @@  mt7915_radar_trigger(void *data, u64 val)
 DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_trigger, NULL,
 			 mt7915_radar_trigger, "%lld\n");
 
+static int
+mt7915_efuse_idx_set(void *data, u64 val)
+{
+	struct mt7915_dev *dev = data;
+	u8 *eep = dev->mt76.eeprom.data;
+
+	if (eep[val] == 0xff && !dev->flash_mode)
+		mt7915_mcu_get_eeprom(dev, val);
+
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_efuse_idx, NULL,
+			 mt7915_efuse_idx_set, "0x%llx\n");
+
 static int
 mt7915_fw_debug_set(void *data, u64 val)
 {
@@ -390,6 +405,7 @@  int mt7915_init_debugfs(struct mt7915_dev *dev)
 	debugfs_create_file("radar_trigger", 0200, dir, dev,
 			    &fops_radar_trigger);
 	debugfs_create_file("ser_trigger", 0200, dir, dev, &fops_ser_trigger);
+	debugfs_create_file("efuse_idx", 0200, dir, dev, &fops_efuse_idx);
 	debugfs_create_devm_seqfile(dev->mt76.dev, "temperature", dir,
 				    mt7915_read_temperature);
 	debugfs_create_devm_seqfile(dev->mt76.dev, "txpower_sku", dir,