mirror of
https://github.com/openwrt/openwrt.git
synced 2025-03-14 00:06:46 +00:00
mac80211: rt2x00: load the eeprom data from devicetree embedded data on Ralink SoCs
It will allow loading eeprom from eeprom-data embedded in device tree. Ported from mediatek mt76 wireless driver (drivers/net/wireless/mediatek/mt76/eeprom.c) Signed-off-by: Coia Prant <coiaprant@gmail.com> Link: https://github.com/openwrt/openwrt/pull/17472 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
6da7352ebe
commit
5d266b55ed
@ -0,0 +1,76 @@
|
||||
From adf957124a115bdf3e4728e1ea8c70a632648cf0 Mon Sep 17 00:00:00 2001
|
||||
From: Coia Prant <coiaprant@gmail.com>
|
||||
Date: Fri, 14 Feb 2025 15:49:55 +0800
|
||||
Subject: [PATCH] wifi: rt2x00: Add support for loading EEPROM from devicetree
|
||||
embedded data
|
||||
|
||||
This patch allows rt2x00 to load eeprom from devicetree embedded data.
|
||||
|
||||
Example:
|
||||
|
||||
/* load eeprom from embedded data 'eeprom-data' */
|
||||
&wmac {
|
||||
ralink,eeprom-data = <0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
|
||||
0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff>;
|
||||
};
|
||||
|
||||
Signed-off-by: Coia Prant <coiaprant@gmail.com>
|
||||
---
|
||||
.../net/wireless/ralink/rt2x00/rt2x00eeprom.c | 25 +++++++++++++++++++
|
||||
1 file changed, 25 insertions(+)
|
||||
|
||||
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
|
||||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
|
||||
@@ -33,6 +33,27 @@ static void rt2800lib_eeprom_swap(struct
|
||||
rt2x00dev->eeprom[i] = swab16(rt2x00dev->eeprom[i]);
|
||||
}
|
||||
|
||||
+static int rt2800lib_read_eeprom_data(struct rt2x00_dev *rt2x00dev)
|
||||
+{
|
||||
+ struct device_node *np = rt2x00dev->dev->of_node;
|
||||
+ unsigned int len = rt2x00dev->ops->eeprom_size;
|
||||
+ const void *data;
|
||||
+ int size;
|
||||
+
|
||||
+ data = of_get_property(np, "ralink,eeprom-data", &size);
|
||||
+ if (!data)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ if (size != len) {
|
||||
+ dev_err(rt2x00dev->dev, "invalid eeprom size, required: 0x%04x\n", len);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(rt2x00dev->eeprom, data, size);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
#if IS_ENABLED(CONFIG_MTD)
|
||||
static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
|
||||
{
|
||||
@@ -193,6 +214,10 @@ int rt2x00lib_read_eeprom(struct rt2x00_
|
||||
{
|
||||
int ret;
|
||||
|
||||
+ ret = rt2800lib_read_eeprom_data(rt2x00dev);
|
||||
+ if (!ret)
|
||||
+ return 0;
|
||||
+
|
||||
#if IS_ENABLED(CONFIG_MTD)
|
||||
ret = rt2800lib_read_eeprom_mtd(rt2x00dev);
|
||||
if (!ret)
|
Loading…
x
Reference in New Issue
Block a user