[openwrt/openwrt] kernel: rtl8367: use realtek,extif property
LEDE Commits
lede-commits at lists.infradead.org
Mon Aug 5 15:35:27 PDT 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/343f4f3c54ab6db98528b3b6a7e989eafaff788c
commit 343f4f3c54ab6db98528b3b6a7e989eafaff788c
Author: Mieczyslaw Nalewaj <namiltd at yahoo.com>
AuthorDate: Sun Jul 21 21:46:49 2024 +0200
kernel: rtl8367: use realtek,extif property
Use realtek,extif property instead of realtek,extif0 and realtek,extif1
by extending it with the cpu_port parameter.
The extif number is automatically calculated based on cpu_port.
Signed-off-by: Mieczyslaw Nalewaj <namiltd at yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/15749
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
.../linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts | 2 +-
.../linux/generic/files/drivers/net/phy/rtl8367.c | 47 +++++++++++++---------
target/linux/ramips/dts/rt3662_asus_rt-n56u.dts | 2 +-
.../linux/ramips/dts/rt3662_edimax_br-6475nd.dts | 2 +-
.../linux/ramips/dts/rt3662_samsung_cy-swr1100.dts | 2 +-
5 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts b/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts
index 77eeedc588..0124ddff87 100644
--- a/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts
+++ b/target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts
@@ -78,7 +78,7 @@
compatible = "realtek,rtl8367";
gpio-sda = <&gpio 1 GPIO_ACTIVE_HIGH>;
gpio-sck = <&gpio 6 GPIO_ACTIVE_HIGH>;
- realtek,extif0 = <1 0 1 1 1 1 1 1 2>;
+ realtek,extif = <9 1 0 1 1 1 1 1 1 2>;
mdio-bus {
#address-cells = <1>;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c
index b14b63e036..0acfeb54bb 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8367.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c
@@ -1077,21 +1077,37 @@ static int rtl8367_led_blinkrate_set(struct rtl8366_smi *smi, unsigned int rate)
}
#ifdef CONFIG_OF
-static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id,
+static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
const char *name)
{
struct rtl8367_extif_config *cfg;
const __be32 *prop;
int size;
int err;
+ unsigned cpu_port;
+ unsigned id = UINT_MAX;
prop = of_get_property(smi->parent->of_node, name, &size);
- if (!prop)
- return rtl8367_extif_init(smi, id, NULL);
+ if (!prop || (size != (10 * sizeof(*prop)))) {
+ dev_err(smi->parent, "%s property is not defined or invalid\n", name);
+ err = -EINVAL;
+ goto err_init;
+ }
- if (size != (9 * sizeof(*prop))) {
- dev_err(smi->parent, "%s property is invalid\n", name);
- return -EINVAL;
+ cpu_port = be32_to_cpup(prop++);
+ switch (cpu_port) {
+ case RTL8367_CPU_PORT_NUM - 1:
+ case RTL8367_CPU_PORT_NUM:
+ id = RTL8367_CPU_PORT_NUM - cpu_port;
+ if (smi->cpu_port == UINT_MAX) {
+ dev_info(smi->parent, "cpu_port:%u, assigned to extif%u\n", cpu_port, id);
+ smi->cpu_port = cpu_port;
+ }
+ break;
+ default:
+ dev_err(smi->parent, "wrong cpu_port %u in %s property\n", cpu_port, name);
+ err = -EINVAL;
+ goto err_init;
}
cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL);
@@ -1111,10 +1127,14 @@ static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id,
err = rtl8367_extif_init(smi, id, cfg);
kfree(cfg);
+err_init:
+ if (id != 0) rtl8367_extif_init(smi, 0, NULL);
+ if (id != 1) rtl8367_extif_init(smi, 1, NULL);
+
return err;
}
#else
-static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id,
+static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
const char *name)
{
return -EINVAL;
@@ -1135,11 +1155,7 @@ static int rtl8367_setup(struct rtl8366_smi *smi)
/* initialize external interfaces */
if (smi->parent->of_node) {
- err = rtl8367_extif_init_of(smi, 0, "realtek,extif0");
- if (err)
- return err;
-
- err = rtl8367_extif_init_of(smi, 1, "realtek,extif1");
+ err = rtl8367_extif_init_of(smi, "realtek,extif");
if (err)
return err;
} else {
@@ -1722,11 +1738,6 @@ static int rtl8367_detect(struct rtl8366_smi *smi)
dev_info(smi->parent, "RTL%s ver. %u chip found\n",
chip_name, rtl_ver & RTL8367_RTL_VER_MASK);
- if (of_property_present(smi->parent->of_node, "realtek,extif1"))
- smi->cpu_port = RTL8367_CPU_PORT_NUM - 1;
-
- dev_info(smi->parent, "CPU port: %u\n", smi->cpu_port);
-
return 0;
}
@@ -1764,7 +1775,7 @@ static int rtl8367_probe(struct platform_device *pdev)
smi->cmd_read = 0xb9;
smi->cmd_write = 0xb8;
smi->ops = &rtl8367_smi_ops;
- smi->cpu_port = RTL8367_CPU_PORT_NUM;
+ smi->cpu_port = UINT_MAX; /* not defined yet */
smi->num_ports = RTL8367_NUM_PORTS;
smi->num_vlan_mc = RTL8367_NUM_VLANS;
smi->mib_counters = rtl8367_mib_counters;
diff --git a/target/linux/ramips/dts/rt3662_asus_rt-n56u.dts b/target/linux/ramips/dts/rt3662_asus_rt-n56u.dts
index 391076cee9..c381aa3e03 100644
--- a/target/linux/ramips/dts/rt3662_asus_rt-n56u.dts
+++ b/target/linux/ramips/dts/rt3662_asus_rt-n56u.dts
@@ -73,7 +73,7 @@
compatible = "realtek,rtl8367";
gpio-sda = <&gpio0 1 GPIO_ACTIVE_HIGH>;
gpio-sck = <&gpio0 2 GPIO_ACTIVE_HIGH>;
- realtek,extif1 = <1 0 1 1 1 1 1 1 2>;
+ realtek,extif = <8 1 0 1 1 1 1 1 1 2>;
};
keys {
diff --git a/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts b/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts
index 051e28da8f..fbc795b24f 100644
--- a/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts
+++ b/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts
@@ -127,7 +127,7 @@
compatible = "realtek,rtl8367";
gpio-sda = <&gpio0 5 GPIO_ACTIVE_HIGH>;
gpio-sck = <&gpio0 4 GPIO_ACTIVE_HIGH>;
- realtek,extif0 = <1 0 1 1 1 1 1 1 2>;
+ realtek,extif = <9 1 0 1 1 1 1 1 1 2>;
};
/*
diff --git a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts
index 9964fcf600..bcc215c17a 100644
--- a/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts
+++ b/target/linux/ramips/dts/rt3662_samsung_cy-swr1100.dts
@@ -81,7 +81,7 @@
compatible = "realtek,rtl8367";
gpio-sda = <&gpio0 1 GPIO_ACTIVE_HIGH>;
gpio-sck = <&gpio0 2 GPIO_ACTIVE_HIGH>;
- realtek,extif0 = <1 0 1 1 1 1 1 1 2>;
+ realtek,extif = <9 1 0 1 1 1 1 1 1 2>;
};
keys {
More information about the lede-commits
mailing list