Skip to contentSkip to conversation

mt76: support reading EEPROM data embedded in fdt

PATCH In review Daniel Golle 1 participant 1 message Aug 25, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mt76: support reading EEPROM data embedded in fdt

Some platforms boot from SD card and don't come with calibration data stored anywhere on the board.
As EEPROM data is rather small it can be embedded into the device tree to be loaded from there by the mt76.

---
 drivers/net/wireless/mediatek/mt76/eeprom.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/wireless/mediatek/mt76/eeprom.c +11 -0
index 3b47e85e95e7c..01bc42dc71c26 100644
@@ -15,6 +15,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
 	struct device_node *np = dev->dev->of_node;
 	struct mtd_info *mtd;
 	const __be32 *list;
+	const void *data;
 	const char *part;
 	phandle phandle;
 	int size;
@@ -24,6 +25,16 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
 	if (!np)
 		return -ENOENT;
 
+	data = of_get_property(np, "mediatek,eeprom-data", &size);
+	if (data) {
+		if (size > len)
+			return -EINVAL;
+
+		memcpy(eep, data, size);
+
+		return 0;
+	}
+
 	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
 	if (!list)
 		return -ENOENT;
Signature · 7 lines
2.32.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek