* [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct
2025-06-18 10:41 [PATCH net-next 0/2] net: stmmac: loongson1: cleanups Russell King (Oracle)
@ 2025-06-18 10:41 ` Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
` (2 more replies)
2025-06-18 10:41 ` [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once Russell King (Oracle)
2025-06-19 22:30 ` [PATCH net-next 0/2] net: stmmac: loongson1: cleanups patchwork-bot+netdevbpf
2 siblings, 3 replies; 10+ messages in thread
From: Russell King (Oracle) @ 2025-06-18 10:41 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Keguang Zhang, linux-arm-kernel, linux-mips,
linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
Provide a structure for match data rather than using the function
pointer as match data. This allows stronger type-checking for the
function itself, and allows extensions to the match data.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../ethernet/stmicro/stmmac/dwmac-loongson1.c | 24 ++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index 3e86810717d3..78d9540be10c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -46,6 +46,10 @@ struct ls1x_dwmac {
struct regmap *regmap;
};
+struct ls1x_data {
+ int (*init)(struct platform_device *pdev, void *bsp_priv);
+};
+
static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
{
struct ls1x_dwmac *dwmac = priv;
@@ -143,9 +147,9 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
struct stmmac_resources stmmac_res;
+ const struct ls1x_data *data;
struct regmap *regmap;
struct ls1x_dwmac *dwmac;
- int (*init)(struct platform_device *pdev, void *priv);
int ret;
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
@@ -159,8 +163,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
"Unable to find syscon\n");
- init = of_device_get_match_data(&pdev->dev);
- if (!init) {
+ data = of_device_get_match_data(&pdev->dev);
+ if (!data) {
dev_err(&pdev->dev, "No of match data provided\n");
return -EINVAL;
}
@@ -175,21 +179,29 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
"dt configuration failed\n");
plat_dat->bsp_priv = dwmac;
- plat_dat->init = init;
+ plat_dat->init = data->init;
dwmac->plat_dat = plat_dat;
dwmac->regmap = regmap;
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
}
+static const struct ls1x_data ls1b_dwmac_data = {
+ .init = ls1b_dwmac_syscon_init,
+};
+
+static const struct ls1x_data ls1c_dwmac_data = {
+ .init = ls1c_dwmac_syscon_init,
+};
+
static const struct of_device_id ls1x_dwmac_match[] = {
{
.compatible = "loongson,ls1b-gmac",
- .data = &ls1b_dwmac_syscon_init,
+ .data = &ls1b_dwmac_data,
},
{
.compatible = "loongson,ls1c-emac",
- .data = &ls1c_dwmac_syscon_init,
+ .data = &ls1c_dwmac_data,
},
{ }
};
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once
2025-06-18 10:41 [PATCH net-next 0/2] net: stmmac: loongson1: cleanups Russell King (Oracle)
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
@ 2025-06-18 10:41 ` Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
2025-06-19 5:49 ` Keguang Zhang
2025-06-19 22:30 ` [PATCH net-next 0/2] net: stmmac: loongson1: cleanups patchwork-bot+netdevbpf
2 siblings, 2 replies; 10+ messages in thread
From: Russell King (Oracle) @ 2025-06-18 10:41 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Keguang Zhang, linux-arm-kernel, linux-mips,
linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
ls1b_dwmac_syscon_init() was getting the stmmac iomem resource to detect
which GMAC block is being used. Move this to a separate setup() function
that only runs at probe time, so it can sensibly behave with an
unrecognised resource adress. Use this to set a MAC index (id) which is
then used in place of testing the base address.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../ethernet/stmicro/stmmac/dwmac-loongson1.c | 49 ++++++++++++++-----
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index 78d9540be10c..32b5d1492e2e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -44,28 +44,50 @@
struct ls1x_dwmac {
struct plat_stmmacenet_data *plat_dat;
struct regmap *regmap;
+ unsigned int id;
};
struct ls1x_data {
+ int (*setup)(struct platform_device *pdev,
+ struct plat_stmmacenet_data *plat_dat);
int (*init)(struct platform_device *pdev, void *bsp_priv);
};
-static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
+static int ls1b_dwmac_setup(struct platform_device *pdev,
+ struct plat_stmmacenet_data *plat_dat)
{
- struct ls1x_dwmac *dwmac = priv;
- struct plat_stmmacenet_data *plat = dwmac->plat_dat;
- struct regmap *regmap = dwmac->regmap;
+ struct ls1x_dwmac *dwmac = plat_dat->bsp_priv;
struct resource *res;
- unsigned long reg_base;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
+ /* This shouldn't fail - stmmac_get_platform_resources()
+ * already mapped this resource.
+ */
dev_err(&pdev->dev, "Could not get IO_MEM resources\n");
return -EINVAL;
}
- reg_base = (unsigned long)res->start;
- if (reg_base == LS1B_GMAC0_BASE) {
+ if (res->start == LS1B_GMAC0_BASE) {
+ dwmac->id = 0;
+ } else if (res->start == LS1B_GMAC1_BASE) {
+ dwmac->id = 1;
+ } else {
+ dev_err(&pdev->dev, "Invalid Ethernet MAC base address %pR",
+ res);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
+{
+ struct ls1x_dwmac *dwmac = priv;
+ struct plat_stmmacenet_data *plat = dwmac->plat_dat;
+ struct regmap *regmap = dwmac->regmap;
+
+ if (dwmac->id == 0) {
switch (plat->phy_interface) {
case PHY_INTERFACE_MODE_RGMII_ID:
regmap_update_bits(regmap, LS1X_SYSCON0,
@@ -84,7 +106,7 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
}
regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
- } else if (reg_base == LS1B_GMAC1_BASE) {
+ } else if (dwmac->id == 1) {
regmap_update_bits(regmap, LS1X_SYSCON0,
GMAC1_USE_UART1 | GMAC1_USE_UART0,
GMAC1_USE_UART1 | GMAC1_USE_UART0);
@@ -108,10 +130,6 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
}
regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0);
- } else {
- dev_err(&pdev->dev, "Invalid Ethernet MAC base address %lx",
- reg_base);
- return -EINVAL;
}
return 0;
@@ -183,10 +201,17 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
dwmac->plat_dat = plat_dat;
dwmac->regmap = regmap;
+ if (data->setup) {
+ ret = data->setup(pdev, plat_dat);
+ if (ret)
+ return ret;
+ }
+
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
}
static const struct ls1x_data ls1b_dwmac_data = {
+ .setup = ls1b_dwmac_setup,
.init = ls1b_dwmac_syscon_init,
};
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 0/2] net: stmmac: loongson1: cleanups
@ 2025-06-18 10:41 Russell King (Oracle)
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Russell King (Oracle) @ 2025-06-18 10:41 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Keguang Zhang, linux-arm-kernel, linux-mips,
linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
Hi,
A couple of patches to cleanup loongson1. First, introducing a match
data struct to allow the per-match data to be extended beyond the init
function pointer, and then adding a setup method to allow the resource
base address to be translated to the MAC index at probe time rather
than repeatedly in the setup function.
.../net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 73 ++++++++++++++++------
1 file changed, 55 insertions(+), 18 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
@ 2025-06-18 18:33 ` Simon Horman
2025-06-19 5:46 ` Keguang Zhang
2025-06-18 19:27 ` Andrew Lunn
2025-06-19 5:48 ` Keguang Zhang
2 siblings, 1 reply; 10+ messages in thread
From: Simon Horman @ 2025-06-18 18:33 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Keguang Zhang,
linux-arm-kernel, linux-mips, linux-stm32, Maxime Coquelin,
netdev, Paolo Abeni
On Wed, Jun 18, 2025 at 11:41:09AM +0100, Russell King (Oracle) wrote:
> Provide a structure for match data rather than using the function
> pointer as match data. This allows stronger type-checking for the
> function itself, and allows extensions to the match data.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once
2025-06-18 10:41 ` [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once Russell King (Oracle)
@ 2025-06-18 18:33 ` Simon Horman
2025-06-19 5:49 ` Keguang Zhang
1 sibling, 0 replies; 10+ messages in thread
From: Simon Horman @ 2025-06-18 18:33 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Keguang Zhang,
linux-arm-kernel, linux-mips, linux-stm32, Maxime Coquelin,
netdev, Paolo Abeni
On Wed, Jun 18, 2025 at 11:41:14AM +0100, Russell King (Oracle) wrote:
> ls1b_dwmac_syscon_init() was getting the stmmac iomem resource to detect
> which GMAC block is being used. Move this to a separate setup() function
> that only runs at probe time, so it can sensibly behave with an
> unrecognised resource adress. Use this to set a MAC index (id) which is
> then used in place of testing the base address.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
@ 2025-06-18 19:27 ` Andrew Lunn
2025-06-19 5:48 ` Keguang Zhang
2 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2025-06-18 19:27 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Keguang Zhang, linux-arm-kernel,
linux-mips, linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
On Wed, Jun 18, 2025 at 11:41:09AM +0100, Russell King (Oracle) wrote:
> Provide a structure for match data rather than using the function
> pointer as match data. This allows stronger type-checking for the
> function itself, and allows extensions to the match data.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct
2025-06-18 18:33 ` Simon Horman
@ 2025-06-19 5:46 ` Keguang Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Keguang Zhang @ 2025-06-19 5:46 UTC (permalink / raw)
To: Simon Horman
Cc: Russell King (Oracle), Andrew Lunn, Heiner Kallweit,
Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, linux-arm-kernel, linux-mips, linux-stm32,
Maxime Coquelin, netdev, Paolo Abeni
On Thu, Jun 19, 2025 at 2:33 AM Simon Horman <horms@kernel.org> wrote:
>
> On Wed, Jun 18, 2025 at 11:41:09AM +0100, Russell King (Oracle) wrote:
> > Provide a structure for match data rather than using the function
> > pointer as match data. This allows stronger type-checking for the
> > function itself, and allows extensions to the match data.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>
> Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com>
Tested-by: Keguang Zhang <keguang.zhang@gmail.com> # on LS1B & LS1C
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
2025-06-18 19:27 ` Andrew Lunn
@ 2025-06-19 5:48 ` Keguang Zhang
2 siblings, 0 replies; 10+ messages in thread
From: Keguang Zhang @ 2025-06-19 5:48 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, linux-arm-kernel,
linux-mips, linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com>
Tested-by: Keguang Zhang <keguang.zhang@gmail.com> # on LS1B & LS1C
On Wed, Jun 18, 2025 at 6:41 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> Provide a structure for match data rather than using the function
> pointer as match data. This allows stronger type-checking for the
> function itself, and allows extensions to the match data.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 24 ++++++++++++++-----
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> index 3e86810717d3..78d9540be10c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> @@ -46,6 +46,10 @@ struct ls1x_dwmac {
> struct regmap *regmap;
> };
>
> +struct ls1x_data {
> + int (*init)(struct platform_device *pdev, void *bsp_priv);
> +};
> +
> static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> {
> struct ls1x_dwmac *dwmac = priv;
> @@ -143,9 +147,9 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
> {
> struct plat_stmmacenet_data *plat_dat;
> struct stmmac_resources stmmac_res;
> + const struct ls1x_data *data;
> struct regmap *regmap;
> struct ls1x_dwmac *dwmac;
> - int (*init)(struct platform_device *pdev, void *priv);
> int ret;
>
> ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> @@ -159,8 +163,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
> return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
> "Unable to find syscon\n");
>
> - init = of_device_get_match_data(&pdev->dev);
> - if (!init) {
> + data = of_device_get_match_data(&pdev->dev);
> + if (!data) {
> dev_err(&pdev->dev, "No of match data provided\n");
> return -EINVAL;
> }
> @@ -175,21 +179,29 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
> "dt configuration failed\n");
>
> plat_dat->bsp_priv = dwmac;
> - plat_dat->init = init;
> + plat_dat->init = data->init;
> dwmac->plat_dat = plat_dat;
> dwmac->regmap = regmap;
>
> return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
> }
>
> +static const struct ls1x_data ls1b_dwmac_data = {
> + .init = ls1b_dwmac_syscon_init,
> +};
> +
> +static const struct ls1x_data ls1c_dwmac_data = {
> + .init = ls1c_dwmac_syscon_init,
> +};
> +
> static const struct of_device_id ls1x_dwmac_match[] = {
> {
> .compatible = "loongson,ls1b-gmac",
> - .data = &ls1b_dwmac_syscon_init,
> + .data = &ls1b_dwmac_data,
> },
> {
> .compatible = "loongson,ls1c-emac",
> - .data = &ls1c_dwmac_syscon_init,
> + .data = &ls1c_dwmac_data,
> },
> { }
> };
> --
> 2.30.2
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once
2025-06-18 10:41 ` [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
@ 2025-06-19 5:49 ` Keguang Zhang
1 sibling, 0 replies; 10+ messages in thread
From: Keguang Zhang @ 2025-06-19 5:49 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, linux-arm-kernel,
linux-mips, linux-stm32, Maxime Coquelin, netdev, Paolo Abeni
Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com>
Tested-by: Keguang Zhang <keguang.zhang@gmail.com> # on LS1B & LS1C
On Wed, Jun 18, 2025 at 6:42 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> ls1b_dwmac_syscon_init() was getting the stmmac iomem resource to detect
> which GMAC block is being used. Move this to a separate setup() function
> that only runs at probe time, so it can sensibly behave with an
> unrecognised resource adress. Use this to set a MAC index (id) which is
> then used in place of testing the base address.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 49 ++++++++++++++-----
> 1 file changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> index 78d9540be10c..32b5d1492e2e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> @@ -44,28 +44,50 @@
> struct ls1x_dwmac {
> struct plat_stmmacenet_data *plat_dat;
> struct regmap *regmap;
> + unsigned int id;
> };
>
> struct ls1x_data {
> + int (*setup)(struct platform_device *pdev,
> + struct plat_stmmacenet_data *plat_dat);
> int (*init)(struct platform_device *pdev, void *bsp_priv);
> };
>
> -static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> +static int ls1b_dwmac_setup(struct platform_device *pdev,
> + struct plat_stmmacenet_data *plat_dat)
> {
> - struct ls1x_dwmac *dwmac = priv;
> - struct plat_stmmacenet_data *plat = dwmac->plat_dat;
> - struct regmap *regmap = dwmac->regmap;
> + struct ls1x_dwmac *dwmac = plat_dat->bsp_priv;
> struct resource *res;
> - unsigned long reg_base;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!res) {
> + /* This shouldn't fail - stmmac_get_platform_resources()
> + * already mapped this resource.
> + */
> dev_err(&pdev->dev, "Could not get IO_MEM resources\n");
> return -EINVAL;
> }
> - reg_base = (unsigned long)res->start;
>
> - if (reg_base == LS1B_GMAC0_BASE) {
> + if (res->start == LS1B_GMAC0_BASE) {
> + dwmac->id = 0;
> + } else if (res->start == LS1B_GMAC1_BASE) {
> + dwmac->id = 1;
> + } else {
> + dev_err(&pdev->dev, "Invalid Ethernet MAC base address %pR",
> + res);
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> +{
> + struct ls1x_dwmac *dwmac = priv;
> + struct plat_stmmacenet_data *plat = dwmac->plat_dat;
> + struct regmap *regmap = dwmac->regmap;
> +
> + if (dwmac->id == 0) {
> switch (plat->phy_interface) {
> case PHY_INTERFACE_MODE_RGMII_ID:
> regmap_update_bits(regmap, LS1X_SYSCON0,
> @@ -84,7 +106,7 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> }
>
> regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
> - } else if (reg_base == LS1B_GMAC1_BASE) {
> + } else if (dwmac->id == 1) {
> regmap_update_bits(regmap, LS1X_SYSCON0,
> GMAC1_USE_UART1 | GMAC1_USE_UART0,
> GMAC1_USE_UART1 | GMAC1_USE_UART0);
> @@ -108,10 +130,6 @@ static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> }
>
> regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0);
> - } else {
> - dev_err(&pdev->dev, "Invalid Ethernet MAC base address %lx",
> - reg_base);
> - return -EINVAL;
> }
>
> return 0;
> @@ -183,10 +201,17 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
> dwmac->plat_dat = plat_dat;
> dwmac->regmap = regmap;
>
> + if (data->setup) {
> + ret = data->setup(pdev, plat_dat);
> + if (ret)
> + return ret;
> + }
> +
> return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
> }
>
> static const struct ls1x_data ls1b_dwmac_data = {
> + .setup = ls1b_dwmac_setup,
> .init = ls1b_dwmac_syscon_init,
> };
>
> --
> 2.30.2
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 0/2] net: stmmac: loongson1: cleanups
2025-06-18 10:41 [PATCH net-next 0/2] net: stmmac: loongson1: cleanups Russell King (Oracle)
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
2025-06-18 10:41 ` [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once Russell King (Oracle)
@ 2025-06-19 22:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-19 22:30 UTC (permalink / raw)
To: Russell King
Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, davem,
edumazet, kuba, keguang.zhang, linux-arm-kernel, linux-mips,
linux-stm32, mcoquelin.stm32, netdev, pabeni
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 18 Jun 2025 11:41:18 +0100 you wrote:
> Hi,
>
> A couple of patches to cleanup loongson1. First, introducing a match
> data struct to allow the per-match data to be extended beyond the init
> function pointer, and then adding a setup method to allow the resource
> base address to be translated to the MAC index at probe time rather
> than repeatedly in the setup function.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: stmmac: loongson1: provide match data struct
https://git.kernel.org/netdev/net-next/c/b1cffac4792b
- [net-next,2/2] net: stmmac: loongson1: get ls1b resource only once
https://git.kernel.org/netdev/net-next/c/e3527bf4dc33
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-06-19 22:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 10:41 [PATCH net-next 0/2] net: stmmac: loongson1: cleanups Russell King (Oracle)
2025-06-18 10:41 ` [PATCH net-next 1/2] net: stmmac: loongson1: provide match data struct Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
2025-06-19 5:46 ` Keguang Zhang
2025-06-18 19:27 ` Andrew Lunn
2025-06-19 5:48 ` Keguang Zhang
2025-06-18 10:41 ` [PATCH net-next 2/2] net: stmmac: loongson1: get ls1b resource only once Russell King (Oracle)
2025-06-18 18:33 ` Simon Horman
2025-06-19 5:49 ` Keguang Zhang
2025-06-19 22:30 ` [PATCH net-next 0/2] net: stmmac: loongson1: cleanups patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).