linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] net: macb: add support for sama7g5
@ 2020-12-09 13:03 Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Hi,

This series adds support for SAMA7G5 Ethernet interfaces: one 10/100Mbps
and one 1Gbps interfaces.

Along with it I also included a fix to disable clocks for SiFive FU540-C000
on failure path of fu540_c000_clk_init().

Thank you,
Claudiu Beznea

Changed in v3:
- use clk_bulk_disable_unprepare in patch 3/8
- corrected clang compilation warning in patch 3/8
- revert changes in macb_clk_init() in patch 3/8

Changes in v2:
- introduced patch "net: macb: add function to disable all macb clocks" and
  update patch "net: macb: unprepare clocks in case of failure" accordingly
- collected tags

Claudiu Beznea (8):
  net: macb: add userio bits as platform configuration
  net: macb: add capability to not set the clock rate
  net: macb: add function to disable all macb clocks
  net: macb: unprepare clocks in case of failure
  dt-bindings: add documentation for sama7g5 ethernet interface
  dt-bindings: add documentation for sama7g5 gigabit ethernet interface
  net: macb: add support for sama7g5 gem interface
  net: macb: add support for sama7g5 emac interface

 Documentation/devicetree/bindings/net/macb.txt |   2 +
 drivers/net/ethernet/cadence/macb.h            |  11 ++
 drivers/net/ethernet/cadence/macb_main.c       | 134 ++++++++++++++++++-------
 3 files changed, 111 insertions(+), 36 deletions(-)

-- 
2.7.4


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

* [PATCH v3 1/8] net: macb: add userio bits as platform configuration
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

This is necessary for SAMA7G5 as it uses different values for
PHY interface and also introduces hdfctlen bit.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/cadence/macb.h      | 10 ++++++++++
 drivers/net/ethernet/cadence/macb_main.c | 28 ++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 1f5da4e4f4b2..7daabffe4318 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -1147,6 +1147,14 @@ struct macb_pm_data {
 	u32 usrio;
 };
 
+struct macb_usrio_config {
+	u32 mii;
+	u32 rmii;
+	u32 rgmii;
+	u32 refclk;
+	u32 hdfctlen;
+};
+
 struct macb_config {
 	u32			caps;
 	unsigned int		dma_burst_length;
@@ -1155,6 +1163,7 @@ struct macb_config {
 			    struct clk **rx_clk, struct clk **tsu_clk);
 	int	(*init)(struct platform_device *pdev);
 	int	jumbo_max_len;
+	const struct macb_usrio_config *usrio;
 };
 
 struct tsu_incr {
@@ -1288,6 +1297,7 @@ struct macb {
 	u32	rx_intr_mask;
 
 	struct macb_pm_data pm_data;
+	const struct macb_usrio_config *usrio;
 };
 
 #ifdef CONFIG_MACB_USE_HWSTAMP
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 7b1d195787dc..6d46153a7c4b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3913,15 +3913,15 @@ static int macb_init(struct platform_device *pdev)
 	if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) {
 		val = 0;
 		if (phy_interface_mode_is_rgmii(bp->phy_interface))
-			val = GEM_BIT(RGMII);
+			val = bp->usrio->rgmii;
 		else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII &&
 			 (bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII))
-			val = MACB_BIT(RMII);
+			val = bp->usrio->rmii;
 		else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII))
-			val = MACB_BIT(MII);
+			val = bp->usrio->mii;
 
 		if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN)
-			val |= MACB_BIT(CLKEN);
+			val |= bp->usrio->refclk;
 
 		macb_or_gem_writel(bp, USRIO, val);
 	}
@@ -4439,6 +4439,13 @@ static int fu540_c000_init(struct platform_device *pdev)
 	return macb_init(pdev);
 }
 
+static const struct macb_usrio_config macb_default_usrio = {
+	.mii = MACB_BIT(MII),
+	.rmii = MACB_BIT(RMII),
+	.rgmii = GEM_BIT(RGMII),
+	.refclk = MACB_BIT(CLKEN),
+};
+
 static const struct macb_config fu540_c000_config = {
 	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
 		MACB_CAPS_GEM_HAS_PTP,
@@ -4446,12 +4453,14 @@ static const struct macb_config fu540_c000_config = {
 	.clk_init = fu540_c000_clk_init,
 	.init = fu540_c000_init,
 	.jumbo_max_len = 10240,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config at91sam9260_config = {
 	.caps = MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config sama5d3macb_config = {
@@ -4459,6 +4468,7 @@ static const struct macb_config sama5d3macb_config = {
 	      | MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config pc302gem_config = {
@@ -4466,6 +4476,7 @@ static const struct macb_config pc302gem_config = {
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config sama5d2_config = {
@@ -4473,6 +4484,7 @@ static const struct macb_config sama5d2_config = {
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config sama5d3_config = {
@@ -4482,6 +4494,7 @@ static const struct macb_config sama5d3_config = {
 	.clk_init = macb_clk_init,
 	.init = macb_init,
 	.jumbo_max_len = 10240,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config sama5d4_config = {
@@ -4489,18 +4502,21 @@ static const struct macb_config sama5d4_config = {
 	.dma_burst_length = 4,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config emac_config = {
 	.caps = MACB_CAPS_NEEDS_RSTONUBR | MACB_CAPS_MACB_IS_EMAC,
 	.clk_init = at91ether_clk_init,
 	.init = at91ether_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config np4_config = {
 	.caps = MACB_CAPS_USRIO_DISABLED,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config zynqmp_config = {
@@ -4511,6 +4527,7 @@ static const struct macb_config zynqmp_config = {
 	.clk_init = macb_clk_init,
 	.init = macb_init,
 	.jumbo_max_len = 10240,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct macb_config zynq_config = {
@@ -4519,6 +4536,7 @@ static const struct macb_config zynq_config = {
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
+	.usrio = &macb_default_usrio,
 };
 
 static const struct of_device_id macb_dt_ids[] = {
@@ -4640,6 +4658,8 @@ static int macb_probe(struct platform_device *pdev)
 		bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
 	device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
 
+	bp->usrio = macb_config->usrio;
+
 	spin_lock_init(&bp->lock);
 
 	/* setup capabilities */
-- 
2.7.4


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

* [PATCH v3 2/8] net: macb: add capability to not set the clock rate
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

SAMA7G5's ethernet IPs TX clock could be provided by its generic clock or
by the external clock provided by the PHY. The internal IP logic divides
properly this clock depending on the link speed. The patch adds a new
capability so that macb_set_tx_clock() to not be called for IPs having
this capability (the clock rate, in case of generic clock, is set at the
boot time via device tree and the driver only enables it).

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/cadence/macb.h      |  1 +
 drivers/net/ethernet/cadence/macb_main.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 7daabffe4318..769694c7f86c 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -699,6 +699,7 @@
 #define MACB_CAPS_GEM_HAS_PTP			0x00000040
 #define MACB_CAPS_BD_RD_PREFETCH		0x00000080
 #define MACB_CAPS_NEEDS_RSTONUBR		0x00000100
+#define MACB_CAPS_CLK_HW_CHG			0x04000000
 #define MACB_CAPS_MACB_IS_EMAC			0x08000000
 #define MACB_CAPS_FIFO_MODE			0x10000000
 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE	0x20000000
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 6d46153a7c4b..b23e986ac6dc 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -460,15 +460,14 @@ static void macb_init_buffers(struct macb *bp)
 
 /**
  * macb_set_tx_clk() - Set a clock to a new frequency
- * @clk:	Pointer to the clock to change
+ * @bp:		pointer to struct macb
  * @speed:	New frequency in Hz
- * @dev:	Pointer to the struct net_device
  */
-static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
+static void macb_set_tx_clk(struct macb *bp, int speed)
 {
 	long ferr, rate, rate_rounded;
 
-	if (!clk)
+	if (!bp->tx_clk || !(bp->caps & MACB_CAPS_CLK_HW_CHG))
 		return;
 
 	switch (speed) {
@@ -485,7 +484,7 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
 		return;
 	}
 
-	rate_rounded = clk_round_rate(clk, rate);
+	rate_rounded = clk_round_rate(bp->tx_clk, rate);
 	if (rate_rounded < 0)
 		return;
 
@@ -495,11 +494,12 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
 	ferr = abs(rate_rounded - rate);
 	ferr = DIV_ROUND_UP(ferr, rate / 100000);
 	if (ferr > 5)
-		netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
+		netdev_warn(bp->dev,
+			    "unable to generate target frequency: %ld Hz\n",
 			    rate);
 
-	if (clk_set_rate(clk, rate_rounded))
-		netdev_err(dev, "adjusting tx_clk failed.\n");
+	if (clk_set_rate(bp->tx_clk, rate_rounded))
+		netdev_err(bp->dev, "adjusting tx_clk failed.\n");
 }
 
 static void macb_validate(struct phylink_config *config,
@@ -751,7 +751,7 @@ static void macb_mac_link_up(struct phylink_config *config,
 		if (rx_pause)
 			ctrl |= MACB_BIT(PAE);
 
-		macb_set_tx_clk(bp->tx_clk, speed, ndev);
+		macb_set_tx_clk(bp, speed);
 
 		/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
 		 * cleared the pipeline and control registers.
-- 
2.7.4


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

* [PATCH v3 3/8] net: macb: add function to disable all macb clocks
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-10  2:15   ` Andrew Lunn
  2020-12-09 13:03 ` [PATCH v3 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Add function to disable all macb clocks.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Suggested-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/cadence/macb_main.c | 38 ++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b23e986ac6dc..81704985a79b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3694,6 +3694,20 @@ static void macb_probe_queues(void __iomem *mem,
 	*num_queues = hweight32(*queue_mask);
 }
 
+static void macb_clks_disable(struct clk *pclk, struct clk *hclk, struct clk *tx_clk,
+			      struct clk *rx_clk, struct clk *tsu_clk)
+{
+	struct clk_bulk_data clks[] = {
+		{ .clk = tsu_clk, },
+		{ .clk = rx_clk, },
+		{ .clk = pclk, },
+		{ .clk = hclk, },
+		{ .clk = tx_clk },
+	};
+
+	clk_bulk_disable_unprepare(ARRAY_SIZE(clks), clks);
+}
+
 static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
 			 struct clk **hclk, struct clk **tx_clk,
 			 struct clk **rx_clk, struct clk **tsu_clk)
@@ -4755,11 +4769,7 @@ static int macb_probe(struct platform_device *pdev)
 	free_netdev(dev);
 
 err_disable_clocks:
-	clk_disable_unprepare(tx_clk);
-	clk_disable_unprepare(hclk);
-	clk_disable_unprepare(pclk);
-	clk_disable_unprepare(rx_clk);
-	clk_disable_unprepare(tsu_clk);
+	macb_clks_disable(pclk, hclk, tx_clk, rx_clk, tsu_clk);
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_set_suspended(&pdev->dev);
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
@@ -4784,11 +4794,8 @@ static int macb_remove(struct platform_device *pdev)
 		pm_runtime_disable(&pdev->dev);
 		pm_runtime_dont_use_autosuspend(&pdev->dev);
 		if (!pm_runtime_suspended(&pdev->dev)) {
-			clk_disable_unprepare(bp->tx_clk);
-			clk_disable_unprepare(bp->hclk);
-			clk_disable_unprepare(bp->pclk);
-			clk_disable_unprepare(bp->rx_clk);
-			clk_disable_unprepare(bp->tsu_clk);
+			macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk,
+					  bp->rx_clk, bp->tsu_clk);
 			pm_runtime_set_suspended(&pdev->dev);
 		}
 		phylink_destroy(bp->phylink);
@@ -4967,13 +4974,10 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
 	struct net_device *netdev = dev_get_drvdata(dev);
 	struct macb *bp = netdev_priv(netdev);
 
-	if (!(device_may_wakeup(dev))) {
-		clk_disable_unprepare(bp->tx_clk);
-		clk_disable_unprepare(bp->hclk);
-		clk_disable_unprepare(bp->pclk);
-		clk_disable_unprepare(bp->rx_clk);
-	}
-	clk_disable_unprepare(bp->tsu_clk);
+	if (!(device_may_wakeup(dev)))
+		macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
+	else
+		macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk);
 
 	return 0;
 }
-- 
2.7.4


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

* [PATCH v3 4/8] net: macb: unprepare clocks in case of failure
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (2 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-10  2:16   ` Andrew Lunn
  2020-12-09 13:03 ` [PATCH v3 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Unprepare clocks in case of any failure in fu540_c000_clk_init().

Fixes: c218ad559020 ("macb: Add support for SiFive FU540-C000")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 81704985a79b..11bf4f8d32e1 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4420,8 +4420,10 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
 		return err;
 
 	mgmt = devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL);
-	if (!mgmt)
-		return -ENOMEM;
+	if (!mgmt) {
+		err = -ENOMEM;
+		goto err_disable_clks;
+	}
 
 	init.name = "sifive-gemgxl-mgmt";
 	init.ops = &fu540_c000_ops;
@@ -4432,16 +4434,26 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
 	mgmt->hw.init = &init;
 
 	*tx_clk = devm_clk_register(&pdev->dev, &mgmt->hw);
-	if (IS_ERR(*tx_clk))
-		return PTR_ERR(*tx_clk);
+	if (IS_ERR(*tx_clk)) {
+		err = PTR_ERR(*tx_clk);
+		goto err_disable_clks;
+	}
 
 	err = clk_prepare_enable(*tx_clk);
-	if (err)
+	if (err) {
 		dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err);
-	else
+		*tx_clk = NULL;
+		goto err_disable_clks;
+	} else {
 		dev_info(&pdev->dev, "Registered clk switch '%s'\n", init.name);
+	}
 
 	return 0;
+
+err_disable_clks:
+	macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, *tsu_clk);
+
+	return err;
 }
 
 static int fu540_c000_init(struct platform_device *pdev)
-- 
2.7.4


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

* [PATCH v3 5/8] dt-bindings: add documentation for sama7g5 ethernet interface
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (3 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Add documentation for SAMA7G5 ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/net/macb.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index 0b61a90f1592..26543a4e15d5 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -16,6 +16,7 @@ Required properties:
   Use "cdns,zynq-gem" Xilinx Zynq-7xxx SoC.
   Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC.
   Use "sifive,fu540-c000-gem" for SiFive FU540-C000 SoC.
+  Use "microchip,sama7g5-emac" for Microchip SAMA7G5 ethernet interface.
   Or the generic form: "cdns,emac".
 - reg: Address and length of the register set for the device
 	For "sifive,fu540-c000-gem", second range is required to specify the
-- 
2.7.4


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

* [PATCH v3 6/8] dt-bindings: add documentation for sama7g5 gigabit ethernet interface
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (4 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Add documentation for SAMA7G5 gigabit ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/net/macb.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index 26543a4e15d5..e08c5a9d53da 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -17,6 +17,7 @@ Required properties:
   Use "cdns,zynqmp-gem" for Zynq Ultrascale+ MPSoC.
   Use "sifive,fu540-c000-gem" for SiFive FU540-C000 SoC.
   Use "microchip,sama7g5-emac" for Microchip SAMA7G5 ethernet interface.
+  Use "microchip,sama7g5-gem" for Microchip SAMA7G5 gigabit ethernet interface.
   Or the generic form: "cdns,emac".
 - reg: Address and length of the register set for the device
 	For "sifive,fu540-c000-gem", second range is required to specify the
-- 
2.7.4


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

* [PATCH v3 7/8] net: macb: add support for sama7g5 gem interface
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (5 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-09 13:03 ` [PATCH v3 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea
  2020-12-17 10:13 ` [PATCH v3 0/8] net: macb: add support for sama7g5 Nicolas Ferre
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Add support for SAMA7G5 gigabit ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/cadence/macb_main.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 11bf4f8d32e1..5bae44931282 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4472,6 +4472,14 @@ static const struct macb_usrio_config macb_default_usrio = {
 	.refclk = MACB_BIT(CLKEN),
 };
 
+static const struct macb_usrio_config sama7g5_usrio = {
+	.mii = 0,
+	.rmii = 1,
+	.rgmii = 2,
+	.refclk = BIT(2),
+	.hdfctlen = BIT(6),
+};
+
 static const struct macb_config fu540_c000_config = {
 	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
 		MACB_CAPS_GEM_HAS_PTP,
@@ -4565,6 +4573,14 @@ static const struct macb_config zynq_config = {
 	.usrio = &macb_default_usrio,
 };
 
+static const struct macb_config sama7g5_gem_config = {
+	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_CLK_HW_CHG,
+	.dma_burst_length = 16,
+	.clk_init = macb_clk_init,
+	.init = macb_init,
+	.usrio = &sama7g5_usrio,
+};
+
 static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,at32ap7000-macb" },
 	{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
@@ -4582,6 +4598,7 @@ static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,zynqmp-gem", .data = &zynqmp_config},
 	{ .compatible = "cdns,zynq-gem", .data = &zynq_config },
 	{ .compatible = "sifive,fu540-c000-gem", .data = &fu540_c000_config },
+	{ .compatible = "microchip,sama7g5-gem", .data = &sama7g5_gem_config },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
-- 
2.7.4


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

* [PATCH v3 8/8] net: macb: add support for sama7g5 emac interface
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (6 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
@ 2020-12-09 13:03 ` Claudiu Beznea
  2020-12-17 10:13 ` [PATCH v3 0/8] net: macb: add support for sama7g5 Nicolas Ferre
  8 siblings, 0 replies; 12+ messages in thread
From: Claudiu Beznea @ 2020-12-09 13:03 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux, Claudiu Beznea

Add support for SAMA7G5 10/100Mbps interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/cadence/macb_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5bae44931282..995a13489276 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4581,6 +4581,14 @@ static const struct macb_config sama7g5_gem_config = {
 	.usrio = &sama7g5_usrio,
 };
 
+static const struct macb_config sama7g5_emac_config = {
+	.caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | MACB_CAPS_USRIO_HAS_CLKEN,
+	.dma_burst_length = 16,
+	.clk_init = macb_clk_init,
+	.init = macb_init,
+	.usrio = &sama7g5_usrio,
+};
+
 static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,at32ap7000-macb" },
 	{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
@@ -4599,6 +4607,7 @@ static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,zynq-gem", .data = &zynq_config },
 	{ .compatible = "sifive,fu540-c000-gem", .data = &fu540_c000_config },
 	{ .compatible = "microchip,sama7g5-gem", .data = &sama7g5_gem_config },
+	{ .compatible = "microchip,sama7g5-emac", .data = &sama7g5_emac_config },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
-- 
2.7.4


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

* Re: [PATCH v3 3/8] net: macb: add function to disable all macb clocks
  2020-12-09 13:03 ` [PATCH v3 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
@ 2020-12-10  2:15   ` Andrew Lunn
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2020-12-10  2:15 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers, yash.shah, netdev,
	devicetree, linux-kernel, linux-riscv, clang-built-linux

On Wed, Dec 09, 2020 at 03:03:34PM +0200, Claudiu Beznea wrote:
> Add function to disable all macb clocks.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> Suggested-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 4/8] net: macb: unprepare clocks in case of failure
  2020-12-09 13:03 ` [PATCH v3 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
@ 2020-12-10  2:16   ` Andrew Lunn
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Lunn @ 2020-12-10  2:16 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers, yash.shah, netdev,
	devicetree, linux-kernel, linux-riscv, clang-built-linux

On Wed, Dec 09, 2020 at 03:03:35PM +0200, Claudiu Beznea wrote:
> Unprepare clocks in case of any failure in fu540_c000_clk_init().
> 
> Fixes: c218ad559020 ("macb: Add support for SiFive FU540-C000")
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 0/8] net: macb: add support for sama7g5
  2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (7 preceding siblings ...)
  2020-12-09 13:03 ` [PATCH v3 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea
@ 2020-12-17 10:13 ` Nicolas Ferre
  8 siblings, 0 replies; 12+ messages in thread
From: Nicolas Ferre @ 2020-12-17 10:13 UTC (permalink / raw)
  To: Claudiu Beznea, davem, kuba, robh+dt, linux, paul.walmsley,
	palmer, natechancellor, ndesaulniers
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv,
	clang-built-linux

On 09/12/2020 at 14:03, Claudiu Beznea wrote:
> Hi,
> 
> This series adds support for SAMA7G5 Ethernet interfaces: one 10/100Mbps
> and one 1Gbps interfaces.
> 
> Along with it I also included a fix to disable clocks for SiFive FU540-C000
> on failure path of fu540_c000_clk_init().
> 
> Thank you,
> Claudiu Beznea
> 
> Changed in v3:
> - use clk_bulk_disable_unprepare in patch 3/8
> - corrected clang compilation warning in patch 3/8
> - revert changes in macb_clk_init() in patch 3/8
> 
> Changes in v2:
> - introduced patch "net: macb: add function to disable all macb clocks" and
>    update patch "net: macb: unprepare clocks in case of failure" accordingly
> - collected tags
> 
> Claudiu Beznea (8):
>    net: macb: add userio bits as platform configuration
>    net: macb: add capability to not set the clock rate
>    net: macb: add function to disable all macb clocks
>    net: macb: unprepare clocks in case of failure
>    dt-bindings: add documentation for sama7g5 ethernet interface
>    dt-bindings: add documentation for sama7g5 gigabit ethernet interface
>    net: macb: add support for sama7g5 gem interface
>    net: macb: add support for sama7g5 emac interface

For the whole series:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Thanks Claudiu, best regards,
   Nicolas

>   Documentation/devicetree/bindings/net/macb.txt |   2 +
>   drivers/net/ethernet/cadence/macb.h            |  11 ++
>   drivers/net/ethernet/cadence/macb_main.c       | 134 ++++++++++++++++++-------
>   3 files changed, 111 insertions(+), 36 deletions(-)
> 


-- 
Nicolas Ferre

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

end of thread, other threads:[~2020-12-17 10:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 13:03 [PATCH v3 0/8] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
2020-12-10  2:15   ` Andrew Lunn
2020-12-09 13:03 ` [PATCH v3 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
2020-12-10  2:16   ` Andrew Lunn
2020-12-09 13:03 ` [PATCH v3 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
2020-12-09 13:03 ` [PATCH v3 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea
2020-12-17 10:13 ` [PATCH v3 0/8] net: macb: add support for sama7g5 Nicolas Ferre

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