]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: make use of device_get_match_data() 21866/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Wed, 4 Feb 2026 07:10:04 +0000 (08:10 +0100)
committerRobert Marko <robimarko@gmail.com>
Thu, 5 Feb 2026 10:40:24 +0000 (11:40 +0100)
The SoC specific configuration structure is currently manually
assigned depending on the family_id. This will be removed in
the future. Make use of device_get_match_data() instead.

While we are here rename the structure prefix.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21866
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/dts/rtl838x.dtsi
target/linux/realtek/dts/rtl839x.dtsi
target/linux/realtek/dts/rtl930x.dtsi
target/linux/realtek/dts/rtl931x.dtsi
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c

index 8930476d9ea7db680a7619eccbc30bf4418ddc90..3ee0b6c45deda27a72888152e87547cafebed9d5 100644 (file)
        };
 
        switch0: switch@1b000000 {
-               compatible = "realtek,rtl83xx-switch";
+               compatible = "realtek,rtl8380-switch", "realtek,otto-switch";
 
                interrupt-parent = <&intc>;
                interrupts = <20 2>;
index c1acf66f60d8b6e13231551352be3e0dd71b8732..99cca02d39efaf2c32d2795d326d91411fc3914c 100644 (file)
 
        switch0: switch@1b000000 {
                status = "okay";
-               compatible = "realtek,rtl83xx-switch";
+               compatible = "realtek,rtl8392-switch", "realtek,otto-switch";
 
                interrupt-parent = <&intc>;
                interrupts = <20 2>;
index 913101d3d095ef32824cc00af69a26d1d4df66ed..11fea099634b97a2b655e5b9c5cc83c696384ba0 100644 (file)
        };
 
        switch0: switch@1b000000 {
-               compatible = "realtek,rtl83xx-switch";
+               compatible = "realtek,rtl9301-switch", "realtek,otto-switch";
                status = "okay";
 
                interrupt-parent = <&intc>;
index 42876ee1db5b254fd293e233a5ab430973710f76..ddb95eb99dbd536c285d83836506f4a7240a58cc 100644 (file)
        };
 
        switch0: switch@1b000000 {
-               compatible = "realtek,rtl83xx-switch";
+               compatible = "realtek,rtl9311-switch", "realtek,otto-switch";
                status = "okay";
 
                interrupt-parent = <&gic>;
index 8ed55f55d797230b5df593c403e153f66a37c316..a4598e205fafb4e9a79b1a8122e3adfe8bca358f 100644 (file)
@@ -278,7 +278,7 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
        if (ret)
                return ret;
 
-       dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch");
+       dn = of_find_compatible_node(NULL, NULL, "realtek,otto-switch");
        if (!dn) {
                dev_err(priv->dev, "No RTL switch node in DTS\n");
                return -ENODEV;
@@ -1402,6 +1402,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
        if (err)
                return err;
 
+       priv->r = device_get_match_data(&pdev->dev);
        priv->family_id = soc_info.family;
        priv->id = soc_info.id;
        switch (soc_info.family) {
@@ -1411,7 +1412,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                priv->port_mask = 0x1f;
                priv->port_width = 1;
                priv->irq_mask = 0x0FFFFFFF;
-               priv->r = &rtl838x_reg;
                priv->ds->num_ports = RTL838X_CPU_PORT + 1;
                priv->fib_entries = 8192;
                priv->ds->num_lag_ids = 8;
@@ -1427,7 +1427,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                priv->port_mask = 0x3f;
                priv->port_width = 2;
                priv->irq_mask = 0xFFFFFFFFFFFFFULL;
-               priv->r = &rtl839x_reg;
                priv->ds->num_ports = RTL839X_CPU_PORT + 1;
                priv->fib_entries = 16384;
                priv->ds->num_lag_ids = 16;
@@ -1443,7 +1442,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                priv->port_mask = 0x1f;
                priv->port_width = 1;
                priv->irq_mask = 0x0FFFFFFF;
-               priv->r = &rtl930x_reg;
                priv->ds->num_ports = RTL930X_CPU_PORT + 1;
                priv->fib_entries = 16384;
                priv->ds->num_lag_ids = 16;
@@ -1460,7 +1458,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                priv->port_mask = 0x3f;
                priv->port_width = 2;
                priv->irq_mask = GENMASK_ULL(priv->cpu_port - 1, 0);
-               priv->r = &rtl931x_reg;
                priv->ds->num_ports = RTL931X_CPU_PORT + 1;
                priv->fib_entries = 16384;
                priv->ds->num_lag_ids = 16;
@@ -1634,7 +1631,22 @@ static void rtl83xx_sw_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id rtl83xx_switch_of_ids[] = {
-       { .compatible = "realtek,rtl83xx-switch"},
+       {
+               .compatible = "realtek,rtl8380-switch",
+               .data = &rtldsa_838x_cfg,
+       },
+       {
+               .compatible = "realtek,rtl8392-switch",
+               .data = &rtldsa_839x_cfg,
+       },
+       {
+               .compatible = "realtek,rtl9301-switch",
+               .data = &rtldsa_930x_cfg,
+       },
+       {
+               .compatible = "realtek,rtl9311-switch",
+               .data = &rtldsa_931x_cfg,
+       },
        { /* sentinel */ }
 };
 
index e0014c4ffcacfc60e771390aa47fe1e91d84c4c4..12382178691525d8125e774fd5fc4f2cfc7238f9 100644 (file)
@@ -1671,7 +1671,7 @@ static void rtl838x_set_receive_management_action(int port, rma_ctrl_t type, act
        }
 }
 
-const struct rtl838x_reg rtl838x_reg = {
+const struct rtldsa_config rtldsa_838x_cfg = {
        .mask_port_reg_be = rtl838x_mask_port_reg,
        .set_port_reg_be = rtl838x_set_port_reg,
        .get_port_reg_be = rtl838x_get_port_reg,
index 2d87eacdbb7cacdab15f4437aa3c20799dd06950..a3da09f57957414d3c07ec03ee0179a5743d79b9 100644 (file)
@@ -1231,7 +1231,7 @@ struct rtldsa_mirror_config {
        u32 val;
 };
 
-struct rtl838x_reg {
+struct rtldsa_config {
        void (*mask_port_reg_be)(u64 clear, u64 set, int reg);
        void (*set_port_reg_be)(u64 set, int reg);
        u64 (*get_port_reg_be)(int reg);
@@ -1355,7 +1355,7 @@ struct rtl838x_switch_priv {
        int link_state_irq;
        int mirror_group_ports[4];
        struct mii_bus *parent_bus;
-       const struct rtl838x_reg *r;
+       const struct rtldsa_config *r;
        u8 cpu_port;
        u8 port_mask;
        u8 port_width;
index ff47950cb909643ba60e0ca7a4d2fb1c3a6764f9..a7e84931d72c4434c6ff0f53287613bd796fea2a 100644 (file)
@@ -1609,7 +1609,7 @@ static void rtl839x_set_receive_management_action(int port, rma_ctrl_t type, act
        }
 }
 
-const struct rtl838x_reg rtl839x_reg = {
+const struct rtldsa_config rtldsa_839x_cfg = {
        .mask_port_reg_be = rtl839x_mask_port_reg_be,
        .set_port_reg_be = rtl839x_set_port_reg_be,
        .get_port_reg_be = rtl839x_get_port_reg_be,
index 54688883cf6a0956318d118972df5b0e6d41fc89..58bd17b417b951ae003ee6a2eef013ce53d01018 100644 (file)
@@ -202,10 +202,10 @@ void rtl931x_print_matrix(void);
 extern const struct dsa_switch_ops rtldsa_83xx_switch_ops;
 extern const struct dsa_switch_ops rtldsa_93xx_switch_ops;
 
-extern const struct rtl838x_reg rtl838x_reg;
-extern const struct rtl838x_reg rtl839x_reg;
-extern const struct rtl838x_reg rtl930x_reg;
-extern const struct rtl838x_reg rtl931x_reg;
+extern const struct rtldsa_config rtldsa_838x_cfg;
+extern const struct rtldsa_config rtldsa_839x_cfg;
+extern const struct rtldsa_config rtldsa_930x_cfg;
+extern const struct rtldsa_config rtldsa_931x_cfg;
 
 /* TODO actually from arch/mips/rtl838x/prom.c */
 extern struct rtl83xx_soc_info soc_info;
index 6d9bb3ac2f6c1178b76508fc2a29813179504348..83e38facd525e935279c6939ba96230b951c6b34 100644 (file)
@@ -2614,7 +2614,7 @@ static void rtldsa_930x_qos_init(struct rtl838x_switch_priv *priv)
        rtldsa_930x_qos_set_scheduling_queue_weights(priv);
 }
 
-const struct rtl838x_reg rtl930x_reg = {
+const struct rtldsa_config rtldsa_930x_cfg = {
        .mask_port_reg_be = rtl838x_mask_port_reg,
        .set_port_reg_be = rtl838x_set_port_reg,
        .get_port_reg_be = rtl838x_get_port_reg,
index 415cd0faedfe18f570b4dd8e5a30b3732b74f790..992dc7794fd5aee394a4d5d9f3956337edb56ff0 100644 (file)
@@ -1800,7 +1800,7 @@ void rtldsa_931x_config_phy_ability_source(struct rtl838x_switch_priv *priv)
        sw_w32(phy_ablty_sel[3], RTLDSA_931X_SMI_PHY_ABLTY_GET_SEL + 0xc);
 }
 
-const struct rtl838x_reg rtl931x_reg = {
+const struct rtldsa_config rtldsa_931x_cfg = {
        .mask_port_reg_be = rtl839x_mask_port_reg_be,
        .set_port_reg_be = rtl839x_set_port_reg_be,
        .get_port_reg_be = rtl839x_get_port_reg_be,