netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 12/21] net: stmmac: dwmac-sun8i: Prepare for second EMAC clock register
       [not found] <20210118020848.11721-1-andre.przywara@arm.com>
@ 2021-01-18  2:08 ` Andre Przywara
  2021-01-18 21:27   ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Przywara @ 2021-01-18  2:08 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec
  Cc: Icenowy Zheng, Linus Walleij, Rob Herring,
	Clément Péron, Samuel Holland, Shuosheng Huang,
	Yangtao Li, linux-arm-kernel, linux-kernel, linux-sunxi,
	Alexandre Torgue, David S . Miller, Giuseppe Cavallaro,
	Jakub Kicinski, Jose Abreu, netdev

The Allwinner H616 SoC has two EMAC controllers, with the second one
being tied to the internal PHY, but also using a separate EMAC clock
register.

To tell the driver about which clock register to use, we add a parameter
to our syscon phandle. The driver will use this value as an index into
the regmap, so that we can address more than the first register, if
needed.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 58e0511badba..00c10ec7b693 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1129,6 +1129,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	struct stmmac_priv *priv;
 	struct net_device *ndev;
 	struct regmap *regmap;
+	struct reg_field syscon_field;
+	u32 syscon_idx = 0;
 
 	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
 	if (ret)
@@ -1190,8 +1192,12 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	gmac->regmap_field = devm_regmap_field_alloc(dev, regmap,
-						     *gmac->variant->syscon_field);
+	syscon_field = *gmac->variant->syscon_field;
+	ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1,
+					 &syscon_idx);
+	if (!ret)
+		syscon_field.reg += syscon_idx * sizeof(u32);
+	gmac->regmap_field = devm_regmap_field_alloc(dev, regmap, syscon_field);
 	if (IS_ERR(gmac->regmap_field)) {
 		ret = PTR_ERR(gmac->regmap_field);
 		dev_err(dev, "Unable to map syscon register: %d\n", ret);
@@ -1263,6 +1269,8 @@ static const struct of_device_id sun8i_dwmac_match[] = {
 		.data = &emac_variant_a64 },
 	{ .compatible = "allwinner,sun50i-h6-emac",
 		.data = &emac_variant_h6 },
+	{ .compatible = "allwinner,sun50i-h616-emac",
+		.data = &emac_variant_h6 },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
-- 
2.17.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 12/21] net: stmmac: dwmac-sun8i: Prepare for second EMAC clock register
  2021-01-18  2:08 ` [PATCH v3 12/21] net: stmmac: dwmac-sun8i: Prepare for second EMAC clock register Andre Przywara
@ 2021-01-18 21:27   ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2021-01-18 21:27 UTC (permalink / raw)
  To: Andre Przywara
  Cc: Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Icenowy Zheng,
	Linus Walleij, Rob Herring, Clément Péron,
	Samuel Holland, Shuosheng Huang, Yangtao Li, linux-arm-kernel,
	linux-kernel, linux-sunxi, Alexandre Torgue, David S . Miller,
	Giuseppe Cavallaro, Jose Abreu, netdev

On Mon, 18 Jan 2021 02:08:39 +0000 Andre Przywara wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 58e0511badba..00c10ec7b693 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1129,6 +1129,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  	struct stmmac_priv *priv;
>  	struct net_device *ndev;
>  	struct regmap *regmap;
> +	struct reg_field syscon_field;
> +	u32 syscon_idx = 0;

nit: please keep the longest-to-shortest line ordering of variables

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-18 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210118020848.11721-1-andre.przywara@arm.com>
2021-01-18  2:08 ` [PATCH v3 12/21] net: stmmac: dwmac-sun8i: Prepare for second EMAC clock register Andre Przywara
2021-01-18 21:27   ` Jakub Kicinski

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).