linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] net: macb: add support for sama7g5
@ 2020-12-04 12:34 Claudiu Beznea
  2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, 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

Claudiu Beznea (7):
  net: macb: add userio bits as platform configuration
  net: macb: add capability to not set the clock rate
  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       | 99 +++++++++++++++++++++-----
 3 files changed, 93 insertions(+), 19 deletions(-)

-- 
2.7.4


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

* [PATCH 1/7] net: macb: add userio bits as platform configuration
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:30   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 2/7] net: macb: add capability to not set the clock rate Claudiu Beznea
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, 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>
---
 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] 16+ messages in thread

* [PATCH 2/7] net: macb: add capability to not set the clock rate
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
  2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:32   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 3/7] net: macb: unprepare clocks in case of failure Claudiu Beznea
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, 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>
---
 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] 16+ messages in thread

* [PATCH 3/7] net: macb: unprepare clocks in case of failure
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
  2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
  2020-12-04 12:34 ` [PATCH 2/7] net: macb: add capability to not set the clock rate Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:30   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, 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 | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b23e986ac6dc..29d144690b3b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4406,8 +4406,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_clocks;
+	}
 
 	init.name = "sifive-gemgxl-mgmt";
 	init.ops = &fu540_c000_ops;
@@ -4418,16 +4420,29 @@ 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_clocks;
+	}
 
 	err = clk_prepare_enable(*tx_clk);
-	if (err)
+	if (err) {
 		dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err);
-	else
+		goto err_disable_clocks;
+	} else {
 		dev_info(&pdev->dev, "Registered clk switch '%s'\n", init.name);
+	}
 
 	return 0;
+
+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);
+
+	return err;
 }
 
 static int fu540_c000_init(struct platform_device *pdev)
-- 
2.7.4


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

* [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (2 preceding siblings ...)
  2020-12-04 12:34 ` [PATCH 3/7] net: macb: unprepare clocks in case of failure Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:32   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, Claudiu Beznea

Add documentation for SAMA7G5 ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 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] 16+ messages in thread

* [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit ethernet interface
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (3 preceding siblings ...)
  2020-12-04 12:34 ` [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:32   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 6/7] net: macb: add support for sama7g5 gem interface Claudiu Beznea
  2020-12-04 12:34 ` [PATCH 7/7] net: macb: add support for sama7g5 emac interface Claudiu Beznea
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, Claudiu Beznea

Add documentation for SAMA7G5 gigabit ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 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] 16+ messages in thread

* [PATCH 6/7] net: macb: add support for sama7g5 gem interface
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (4 preceding siblings ...)
  2020-12-04 12:34 ` [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:33   ` Andrew Lunn
  2020-12-04 12:34 ` [PATCH 7/7] net: macb: add support for sama7g5 emac interface Claudiu Beznea
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, Claudiu Beznea

Add support for SAMA7G5 gigabit ethernet interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 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 29d144690b3b..22340e55d4b7 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4461,6 +4461,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,
@@ -4554,6 +4562,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 },
@@ -4571,6 +4587,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] 16+ messages in thread

* [PATCH 7/7] net: macb: add support for sama7g5 emac interface
  2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
                   ` (5 preceding siblings ...)
  2020-12-04 12:34 ` [PATCH 6/7] net: macb: add support for sama7g5 gem interface Claudiu Beznea
@ 2020-12-04 12:34 ` Claudiu Beznea
  2020-12-05 14:33   ` Andrew Lunn
  6 siblings, 1 reply; 16+ messages in thread
From: Claudiu Beznea @ 2020-12-04 12:34 UTC (permalink / raw)
  To: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley, palmer
  Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv, Claudiu Beznea

Add support for SAMA7G5 10/100Mbps interface.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 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 22340e55d4b7..2e1f9b28e388 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4570,6 +4570,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 },
@@ -4588,6 +4596,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] 16+ messages in thread

* Re: [PATCH 3/7] net: macb: unprepare clocks in case of failure
  2020-12-04 12:34 ` [PATCH 3/7] net: macb: unprepare clocks in case of failure Claudiu Beznea
@ 2020-12-05 14:30   ` Andrew Lunn
  2020-12-07  9:26     ` Claudiu.Beznea
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:30 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:17PM +0200, Claudiu Beznea wrote:
> Unprepare clocks in case of any failure in fu540_c000_clk_init().

Hi Claudiu

Nice patchset. Simple to understand.
> 

> +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);

This looks correct, but it would be more symmetrical to add a

macb_clk_uninit()

function for the four main clocks. I'm surprised it does not already
exist.

	Andrew

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

* Re: [PATCH 1/7] net: macb: add userio bits as platform configuration
  2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
@ 2020-12-05 14:30   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:30 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:15PM +0200, Claudiu Beznea wrote:
> 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>

    Andrew

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

* Re: [PATCH 2/7] net: macb: add capability to not set the clock rate
  2020-12-04 12:34 ` [PATCH 2/7] net: macb: add capability to not set the clock rate Claudiu Beznea
@ 2020-12-05 14:32   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:32 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:16PM +0200, Claudiu Beznea wrote:
> 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>

    Andrew

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

* Re: [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface
  2020-12-04 12:34 ` [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
@ 2020-12-05 14:32   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:32 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:18PM +0200, Claudiu Beznea wrote:
> Add documentation for SAMA7G5 ethernet interface.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

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

    Andrew

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

* Re: [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit ethernet interface
  2020-12-04 12:34 ` [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
@ 2020-12-05 14:32   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:32 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:19PM +0200, Claudiu Beznea wrote:
> Add documentation for SAMA7G5 gigabit ethernet interface.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

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

    Andrew

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

* Re: [PATCH 6/7] net: macb: add support for sama7g5 gem interface
  2020-12-04 12:34 ` [PATCH 6/7] net: macb: add support for sama7g5 gem interface Claudiu Beznea
@ 2020-12-05 14:33   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:33 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:20PM +0200, Claudiu Beznea wrote:
> Add support for SAMA7G5 gigabit ethernet interface.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

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

    Andrew

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

* Re: [PATCH 7/7] net: macb: add support for sama7g5 emac interface
  2020-12-04 12:34 ` [PATCH 7/7] net: macb: add support for sama7g5 emac interface Claudiu Beznea
@ 2020-12-05 14:33   ` Andrew Lunn
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Lunn @ 2020-12-05 14:33 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: davem, kuba, robh+dt, nicolas.ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

On Fri, Dec 04, 2020 at 02:34:21PM +0200, Claudiu Beznea wrote:
> Add support for SAMA7G5 10/100Mbps interface.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

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

    Andrew

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

* Re: [PATCH 3/7] net: macb: unprepare clocks in case of failure
  2020-12-05 14:30   ` Andrew Lunn
@ 2020-12-07  9:26     ` Claudiu.Beznea
  0 siblings, 0 replies; 16+ messages in thread
From: Claudiu.Beznea @ 2020-12-07  9:26 UTC (permalink / raw)
  To: andrew
  Cc: davem, kuba, robh+dt, Nicolas.Ferre, linux, paul.walmsley,
	palmer, yash.shah, netdev, devicetree, linux-kernel, linux-riscv

Hi Andrew,

On 05.12.2020 16:30, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Fri, Dec 04, 2020 at 02:34:17PM +0200, Claudiu Beznea wrote:
>> Unprepare clocks in case of any failure in fu540_c000_clk_init().
> 
> Hi Claudiu
> 
> Nice patchset. Simple to understand.
>>
> 
>> +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);
> 
> This looks correct, but it would be more symmetrical to add a
> 
> macb_clk_uninit()
> 
> function for the four main clocks. I'm surprised it does not already
> exist.

I was in balance b/w added and not added it taking into account that the
disable unprepares are not taking care of all the clocks, in all the
places, in the same way. Anyway, I will add one function for the main
clocks, as you proposed, in the next version.

Thank you for your review,
Claudiu

> 
>         Andrew
> 

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

end of thread, other threads:[~2020-12-07  9:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
2020-12-05 14:30   ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 2/7] net: macb: add capability to not set the clock rate Claudiu Beznea
2020-12-05 14:32   ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 3/7] net: macb: unprepare clocks in case of failure Claudiu Beznea
2020-12-05 14:30   ` Andrew Lunn
2020-12-07  9:26     ` Claudiu.Beznea
2020-12-04 12:34 ` [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
2020-12-05 14:32   ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
2020-12-05 14:32   ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 6/7] net: macb: add support for sama7g5 gem interface Claudiu Beznea
2020-12-05 14:33   ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 7/7] net: macb: add support for sama7g5 emac interface Claudiu Beznea
2020-12-05 14:33   ` Andrew Lunn

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