[openwrt/openwrt] kernel: rtl8366_smi: explicitly set phy addr for switch
LEDE Commits
lede-commits at lists.infradead.org
Sat Feb 24 10:22:43 PST 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/dca146cc778cdab2858b46e4ef3a3073fd02ab50
commit dca146cc778cdab2858b46e4ef3a3073fd02ab50
Author: Mieczyslaw Nalewaj <namiltd at yahoo.com>
AuthorDate: Wed Feb 14 13:14:10 2024 +0100
kernel: rtl8366_smi: explicitly set phy addr for switch
By default rtl8366_smi use phy addr 0 at mii-bus to access switch registers.
This patch allow to set it explicitly in dts-file:
rtl8367 {
compatible = "realtek,rtl8367b";
phy-id = <29>; /* switch address at mii-bus */
realtek,extif2 = <1 0 1 1 1 1 1 1 2>;
mii-bus = <&mdio>;
cpu-port = <7>;
}
Use default 0 address if not set.
Backward compatibility tested on tplink archer c2 v1 (rtl8367rb switch)
Signed-off-by: Serge Vasilugin <vasilugin at yandex.ru>
[code style fixes, add explicit phy_id assignment in probe_plat, use
phy-id instead of phy_id for of property name]
Signed-off-by: Chuanhong Guo <gch981213 at gmail.com>
[rebase]
Signed-off-by: Gaspare Bruno <gaspare at anlix.io>
[added phy_id to struct rtl8366_smi]
Signed-off-by: Mieczyslaw Nalewaj <namiltd at yahoo.com>
---
target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | 8 ++++++--
target/linux/generic/files/drivers/net/phy/rtl8366_smi.h | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
index 028b9916e7..a26fd204cb 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -256,7 +256,7 @@ static int __rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
{
- u32 phy_id = MDC_REALTEK_PHY_ADDR;
+ u32 phy_id = smi->phy_id;
struct mii_bus *mbus = smi->ext_mbus;
BUG_ON(in_interrupt());
@@ -293,7 +293,7 @@ int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
static int __rtl8366_mdio_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data)
{
- u32 phy_id = MDC_REALTEK_PHY_ADDR;
+ u32 phy_id = smi->phy_id;
struct mii_bus *mbus = smi->ext_mbus;
BUG_ON(in_interrupt());
@@ -1547,6 +1547,9 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
goto try_gpio;
}
+ if (of_property_read_u32(np, "phy-id", &smi->phy_id))
+ smi->phy_id = MDC_REALTEK_PHY_ADDR;
+
return 0;
try_gpio:
@@ -1586,6 +1589,7 @@ int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
smi->hw_reset = pdata->hw_reset;
+ smi->phy_id = MDC_REALTEK_PHY_ADDR;
return 0;
}
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
index fabc940278..3fcae81fa4 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -63,6 +63,7 @@ struct rtl8366_smi {
u16 dbg_reg;
u8 dbg_vlan_4k_page;
#endif
+ u32 phy_id;
struct mii_bus *ext_mbus;
};
More information about the lede-commits
mailing list