ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
define Build/Configure
cmp $(PKG_BUILD_DIR)/include/linux/ath5k_platform.h $(LINUX_DIR)/include/linux/ath5k_platform.h
- cmp $(PKG_BUILD_DIR)/include/linux/rt2x00_platform.h $(LINUX_DIR)/include/linux/rt2x00_platform.h
endef
endif
endif
+++ /dev/null
---- /dev/null
-+++ b/include/linux/rt2x00_platform.h
-@@ -0,0 +1,19 @@
-+/*
-+ * Platform data definition for the rt2x00 driver
-+ *
-+ * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 as published
-+ * by the Free Software Foundation.
-+ *
-+ */
-+
-+#ifndef _RT2X00_PLATFORM_H
-+#define _RT2X00_PLATFORM_H
-+
-+struct rt2x00_platform_data {
-+ char *eeprom_file_name;
-+};
-+
-+#endif /* _RT2X00_PLATFORM_H */
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-@@ -28,6 +28,7 @@
- #include <linux/average.h>
- #include <linux/usb.h>
- #include <linux/clk.h>
-+#include <linux/rt2x00_platform.h>
-
- #include <net/mac80211.h>
-
.drv_init_registers = rt2800mmio_init_registers,
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-@@ -693,6 +693,7 @@ enum rt2x00_capability_flags {
+@@ -692,6 +692,7 @@ enum rt2x00_capability_flags {
REQUIRE_HT_TX_DESC,
REQUIRE_PS_AUTOWAKE,
REQUIRE_DELAYED_RFKILL,
/*
* Capabilities
-@@ -1505,4 +1506,13 @@ void rt2x00lib_remove_dev(struct rt2x00_
+@@ -1504,4 +1505,13 @@ void rt2x00lib_remove_dev(struct rt2x00_
int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev);
int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
#endif /* RT2X00_H */
--- /dev/null
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
-@@ -0,0 +1,77 @@
+@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
+ * Copyright (C) 2004 - 2009 Gertjan van Wingerde <gwingerde@gmail.com>
+
+#include <linux/kernel.h>
+#include <linux/module.h>
++#include <linux/of.h>
+
+#include "rt2x00.h"
+#include "rt2x00soc.h"
+static const char *
+rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
+{
-+ struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
++ struct device_node *np = rt2x00dev->dev->of_node;
++ const char *eep;
+
-+ if (pdata && pdata->eeprom_file_name)
-+ return pdata->eeprom_file_name;
++ if (np && !of_property_read_string(np, "ralink,eeprom", &eep))
++ return eep;
+
+ return NULL;
+}
+++ /dev/null
-From 15329d8b206d9c04ffad49aecd37f5d0bfb85768 Mon Sep 17 00:00:00 2001
-From: Christian Marangi <ansuelsmth@gmail.com>
-Date: Sun, 15 Oct 2023 14:23:19 +0200
-Subject: [PATCH 2/5] wifi: rt2x00: Add option to pass EEPROM file name from DT
-
-Add option to pass EEPROM file name from DT using ralink,eeprom binding.
-
-Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
----
- drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c | 11 +++++++++++
- 1 file changed, 11 insertions(+)
-
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
-@@ -10,6 +10,7 @@
-
- #include <linux/kernel.h>
- #include <linux/module.h>
-+#include <linux/of.h>
-
- #include "rt2x00.h"
- #include "rt2x00soc.h"
-@@ -18,10 +19,20 @@ static const char *
- rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
- {
- struct rt2x00_platform_data *pdata = rt2x00dev->dev->platform_data;
-+#ifdef CONFIG_OF
-+ struct device_node *np;
-+ const char *eep;
-+#endif
-
- if (pdata && pdata->eeprom_file_name)
- return pdata->eeprom_file_name;
-
-+#ifdef CONFIG_OF
-+ np = rt2x00dev->dev->of_node;
-+ if (np && !of_property_read_string(np, "ralink,eeprom", &eep))
-+ return eep;
-+#endif
-+
- return NULL;
- }
-
Supported chips: RT2880, RT3050, RT3052, RT3350, RT3352.
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
-@@ -10,11 +10,69 @@
-
+@@ -11,10 +11,66 @@
#include <linux/kernel.h>
#include <linux/module.h>
+ #include <linux/of.h>
+#if IS_ENABLED(CONFIG_MTD)
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#endif
- #include <linux/of.h>
#include "rt2x00.h"
#include "rt2x00soc.h"
+#if IS_ENABLED(CONFIG_MTD)
+static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
+{
-+ int ret = -EINVAL;
-+#ifdef CONFIG_OF
+ struct device_node *np = rt2x00dev->dev->of_node, *mtd_np = NULL;
+ int size, offset = 0;
+ struct mtd_info *mtd;
+ const __be32 *list;
+ phandle phandle;
+ size_t retlen;
++ int ret;
+
+ list = of_get_property(np, "ralink,mtd-eeprom", &size);
+ if (!list)
+ &retlen, (u_char *)rt2x00dev->eeprom);
+ put_mtd_device(mtd);
+
-+ if (retlen != rt2x00dev->ops->eeprom_size || ret) {
++ if (ret || retlen != rt2x00dev->ops->eeprom_size) {
+ dev_err(rt2x00dev->dev, "failed to load eeprom from device \"%s\"\n", part);
+ return ret;
+ }
+
+ dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part);
-+#endif
+
+ return ret;
+}
static const char *
rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
{
-@@ -83,6 +141,14 @@ err_exit:
+@@ -74,6 +130,14 @@ err_exit:
int rt2x00lib_read_eeprom(struct rt2x00_dev *rt2x00dev)
{
static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
{
int ret = -EINVAL;
-@@ -66,6 +79,8 @@ static int rt2800lib_read_eeprom_mtd(str
+@@ -65,6 +78,8 @@ static int rt2800lib_read_eeprom_mtd(str
return ret;
}
+ rt2800lib_eeprom_swap(rt2x00dev);
+
dev_info(rt2x00dev->dev, "loaded eeprom from mtd device \"%s\"\n", part);
- #endif
+ return ret;
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00eeprom.c
-@@ -14,12 +14,12 @@
+@@ -15,11 +15,11 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#endif
+#include <linux/nvmem-consumer.h>
- #include <linux/of.h>
#include "rt2x00.h"
#include "rt2x00soc.h"
static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
{
int ret = -EINVAL;
-@@ -88,6 +89,40 @@ static int rt2800lib_read_eeprom_mtd(str
+@@ -86,6 +87,40 @@ static int rt2800lib_read_eeprom_mtd(str
}
#endif
static const char *
rt2x00lib_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev)
{
-@@ -164,6 +199,10 @@ int rt2x00lib_read_eeprom(struct rt2x00_
+@@ -153,6 +188,10 @@ int rt2x00lib_read_eeprom(struct rt2x00_
return 0;
#endif
#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_
+@@ -182,6 +203,10 @@ int rt2x00lib_read_eeprom(struct rt2x00_
{
int ret;
+++ /dev/null
---- a/include/linux/rt2x00_platform.h
-+++ b/include/linux/rt2x00_platform.h
-@@ -14,6 +14,9 @@
-
- struct rt2x00_platform_data {
- char *eeprom_file_name;
-+
-+ int disable_2ghz;
-+ int disable_5ghz;
- };
-
- #endif /* _RT2X00_PLATFORM_H */
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1008,6 +1008,22 @@ static int rt2x00lib_probe_hw_modes(stru
- unsigned int num_rates;
- unsigned int i;
-
-+ if (rt2x00dev->dev->platform_data) {
-+ struct rt2x00_platform_data *pdata;
-+
-+ pdata = rt2x00dev->dev->platform_data;
-+ if (pdata->disable_2ghz)
-+ spec->supported_bands &= ~SUPPORT_BAND_2GHZ;
-+ if (pdata->disable_5ghz)
-+ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
-+ }
-+
-+ if ((spec->supported_bands & SUPPORT_BAND_BOTH) == 0) {
-+ rt2x00_err(rt2x00dev, "No supported bands\n");
-+ return -EINVAL;
-+ }
-+
-+
- num_rates = 0;
- if (spec->supported_rates & SUPPORT_RATE_CCK)
- num_rates += 4;
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
-@@ -398,6 +398,7 @@ struct hw_mode_spec {
- unsigned int supported_bands;
- #define SUPPORT_BAND_2GHZ 0x00000001
- #define SUPPORT_BAND_5GHZ 0x00000002
-+#define SUPPORT_BAND_BOTH (SUPPORT_BAND_2GHZ | SUPPORT_BAND_5GHZ)
-
- unsigned int supported_rates;
- #define SUPPORT_RATE_CCK 0x00000001
+++ /dev/null
---- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -990,6 +990,12 @@ static void rt2x00lib_rate(struct ieee80
-
- void rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
- {
-+ struct rt2x00_platform_data *pdata;
-+
-+ pdata = rt2x00dev->dev->platform_data;
-+ if (pdata && pdata->mac_address)
-+ ether_addr_copy(eeprom_mac_addr, pdata->mac_address);
-+
- of_get_mac_address(rt2x00dev->dev->of_node, eeprom_mac_addr);
-
- if (!is_valid_ether_addr(eeprom_mac_addr)) {
---- a/include/linux/rt2x00_platform.h
-+++ b/include/linux/rt2x00_platform.h
-@@ -14,6 +14,7 @@
-
- struct rt2x00_platform_data {
- char *eeprom_file_name;
-+ const u8 *mac_address;
-
- int disable_2ghz;
- int disable_5ghz;
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1013,6 +1013,16 @@ static int rt2x00lib_probe_hw_modes(stru
+@@ -1007,6 +1007,14 @@ static int rt2x00lib_probe_hw_modes(stru
struct ieee80211_rate *rates;
unsigned int num_rates;
unsigned int i;
-+#ifdef CONFIG_OF
+ struct device_node *np = rt2x00dev->dev->of_node;
+ unsigned int enabled;
+ if (!of_property_read_u32(np, "ralink,2ghz",
+ if (!of_property_read_u32(np, "ralink,5ghz",
+ &enabled) && !enabled)
+ spec->supported_bands &= ~SUPPORT_BAND_5GHZ;
-+#endif /* CONFIG_OF */
- if (rt2x00dev->dev->platform_data) {
- struct rt2x00_platform_data *pdata;
+ num_rates = 0;
+ if (spec->supported_rates & SUPPORT_RATE_CCK)
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
-@@ -1362,7 +1362,7 @@ static inline void rt2x00lib_set_if_comb
+@@ -1338,7 +1338,7 @@ static inline void rt2x00lib_set_if_comb
*/
if_limit = &rt2x00dev->if_limits_ap;
if_limit->max = rt2x00dev->ops->max_ap_intf;
#include <linux/usb.h>
#include <linux/clk.h>
+#include <linux/pinctrl/consumer.h>
- #include <linux/rt2x00_platform.h>
#include <net/mac80211.h>
-@@ -1017,6 +1018,11 @@ struct rt2x00_dev {
+
+@@ -1015,6 +1016,11 @@ struct rt2x00_dev {
/* Clock for System On Chip devices. */
struct clk *clk;
+++ /dev/null
-/*
- * Platform data definition for the rt2x00 driver
- *
- * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- */
-
-#ifndef _RT2X00_PLATFORM_H
-#define _RT2X00_PLATFORM_H
-
-struct rt2x00_platform_data {
- char *eeprom_file_name;
- const u8 *mac_address;
-
- int disable_2ghz;
- int disable_5ghz;
-};
-
-#endif /* _RT2X00_PLATFORM_H */