* [PATCH v2 1/8] net: macb: add userio bits as platform configuration
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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] 13+ messages in thread
* [PATCH v2 2/8] net: macb: add capability to not set the clock rate
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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] 13+ messages in thread
* [PATCH v2 3/8] net: macb: add function to disable all macb clocks
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-08 18:48 ` Andrew Lunn
` (2 more replies)
2020-12-07 12:15 ` [PATCH v2 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
` (4 subsequent siblings)
7 siblings, 3 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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 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 | 62 ++++++++++++++++----------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b23e986ac6dc..6b8e1109dfd3 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3694,6 +3694,16 @@ 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)
+{
+ clk_disable_unprepare(tx_clk);
+ clk_disable_unprepare(hclk);
+ clk_disable_unprepare(pclk);
+ clk_disable_unprepare(rx_clk);
+ clk_disable_unprepare(tsu_clk);
+}
+
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)
@@ -3743,40 +3753,37 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
err = clk_prepare_enable(*hclk);
if (err) {
dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err);
- goto err_disable_pclk;
+ hclk = NULL;
+ tx_clk = NULL;
+ rx_clk = NULL;
+ goto err_disable_clks;
}
err = clk_prepare_enable(*tx_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err);
- goto err_disable_hclk;
+ tx_clk = NULL;
+ rx_clk = NULL;
+ goto err_disable_clks;
}
err = clk_prepare_enable(*rx_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err);
- goto err_disable_txclk;
+ rx_clk = NULL;
+ goto err_disable_clks;
}
err = clk_prepare_enable(*tsu_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err);
- goto err_disable_rxclk;
+ goto err_disable_clks;
}
return 0;
-err_disable_rxclk:
- clk_disable_unprepare(*rx_clk);
-
-err_disable_txclk:
- clk_disable_unprepare(*tx_clk);
-
-err_disable_hclk:
- clk_disable_unprepare(*hclk);
-
-err_disable_pclk:
- clk_disable_unprepare(*pclk);
+err_disable_clks:
+ macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL);
return err;
}
@@ -4755,11 +4762,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(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_dont_use_autosuspend(&pdev->dev);
@@ -4784,11 +4787,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);
@@ -4966,14 +4966,16 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
{
struct net_device *netdev = dev_get_drvdata(dev);
struct macb *bp = netdev_priv(netdev);
+ struct clk *pclk = NULL, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
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);
+ pclk = bp->pclk;
+ hclk = bp->hclk;
+ tx_clk = bp->tx_clk;
+ rx_clk = bp->rx_clk;
}
- clk_disable_unprepare(bp->tsu_clk);
+
+ macb_clks_disable(pclk, hclk, tx_clk, rx_clk, bp->tsu_clk);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/8] net: macb: add function to disable all macb clocks
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
@ 2020-12-08 18:48 ` Andrew Lunn
2020-12-09 0:22 ` Jakub Kicinski
2020-12-09 0:29 ` Florian Fainelli
2020-12-09 8:43 ` kernel test robot
2 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2020-12-08 18:48 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
Hi Claudiu
> 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)
> @@ -3743,40 +3753,37 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
> err = clk_prepare_enable(*hclk);
> if (err) {
> dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err);
> - goto err_disable_pclk;
> + hclk = NULL;
> + tx_clk = NULL;
> + rx_clk = NULL;
> + goto err_disable_clks;
> }
>
> err = clk_prepare_enable(*tx_clk);
> if (err) {
> dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err);
> - goto err_disable_hclk;
> + tx_clk = NULL;
> + rx_clk = NULL;
> + goto err_disable_clks;
> }
>
> err = clk_prepare_enable(*rx_clk);
> if (err) {
> dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err);
> - goto err_disable_txclk;
> + rx_clk = NULL;
> + goto err_disable_clks;
> }
>
> err = clk_prepare_enable(*tsu_clk);
> if (err) {
> dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err);
> - goto err_disable_rxclk;
> + goto err_disable_clks;
> }
>
> return 0;
>
> -err_disable_rxclk:
> - clk_disable_unprepare(*rx_clk);
> -
> -err_disable_txclk:
> - clk_disable_unprepare(*tx_clk);
> -
> -err_disable_hclk:
> - clk_disable_unprepare(*hclk);
> -
> -err_disable_pclk:
> - clk_disable_unprepare(*pclk);
> +err_disable_clks:
> + macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL);
Personal taste, but i would of not changed this.
>
> return err;
> }
> @@ -4755,11 +4762,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(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
> pm_runtime_disable(&pdev->dev);
> pm_runtime_set_suspended(&pdev->dev);
> pm_runtime_dont_use_autosuspend(&pdev->dev);
> @@ -4784,11 +4787,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);
> @@ -4966,14 +4966,16 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
> {
> struct net_device *netdev = dev_get_drvdata(dev);
> struct macb *bp = netdev_priv(netdev);
> + struct clk *pclk = NULL, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
>
> 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);
> + pclk = bp->pclk;
> + hclk = bp->hclk;
> + tx_clk = bp->tx_clk;
> + rx_clk = bp->rx_clk;
> }
> - clk_disable_unprepare(bp->tsu_clk);
> +
> + macb_clks_disable(pclk, hclk, tx_clk, rx_clk, bp->tsu_clk);
Maybe
if (!(device_may_wakeup(dev)))
macb_clks_disable(bp->pclk, bp->hclk, pb->tx_clk, bp->rx_clk, bp->tsu_clk);
else
macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk);
is more readable?
Andrew
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/8] net: macb: add function to disable all macb clocks
2020-12-08 18:48 ` Andrew Lunn
@ 2020-12-09 0:22 ` Jakub Kicinski
0 siblings, 0 replies; 13+ messages in thread
From: Jakub Kicinski @ 2020-12-09 0:22 UTC (permalink / raw)
To: Andrew Lunn
Cc: Claudiu Beznea, davem, robh+dt, nicolas.ferre, linux,
paul.walmsley, palmer, yash.shah, netdev, devicetree,
linux-kernel, linux-riscv
On Tue, 8 Dec 2020 19:48:56 +0100 Andrew Lunn wrote:
> > -err_disable_rxclk:
> > - clk_disable_unprepare(*rx_clk);
> > -
> > -err_disable_txclk:
> > - clk_disable_unprepare(*tx_clk);
> > -
> > -err_disable_hclk:
> > - clk_disable_unprepare(*hclk);
> > -
> > -err_disable_pclk:
> > - clk_disable_unprepare(*pclk);
> > +err_disable_clks:
> > + macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL);
>
> Personal taste, but i would of not changed this.
+1 FWIW
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/8] net: macb: add function to disable all macb clocks
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
2020-12-08 18:48 ` Andrew Lunn
@ 2020-12-09 0:29 ` Florian Fainelli
2020-12-09 8:43 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2020-12-09 0:29 UTC (permalink / raw)
To: Claudiu Beznea, davem, kuba, robh+dt, nicolas.ferre, linux,
paul.walmsley, palmer
Cc: yash.shah, netdev, devicetree, linux-kernel, linux-riscv
On 12/7/20 4:15 AM, 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>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 62 ++++++++++++++++----------------
> 1 file changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index b23e986ac6dc..6b8e1109dfd3 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3694,6 +3694,16 @@ 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)
> +{
> + clk_disable_unprepare(tx_clk);
> + clk_disable_unprepare(hclk);
> + clk_disable_unprepare(pclk);
> + clk_disable_unprepare(rx_clk);
> + clk_disable_unprepare(tsu_clk);
Looks like you should consider using the CLK bulk API:
clk_bulk_disable_unprepare() and friends.
--
Florian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/8] net: macb: add function to disable all macb clocks
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
2020-12-08 18:48 ` Andrew Lunn
2020-12-09 0:29 ` Florian Fainelli
@ 2020-12-09 8:43 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2020-12-09 8:43 UTC (permalink / raw)
To: Claudiu Beznea, davem, kuba, robh+dt, nicolas.ferre, linux,
paul.walmsley, palmer
Cc: kbuild-all, clang-built-linux, yash.shah, netdev, devicetree
[-- Attachment #1: Type: text/plain, Size: 15040 bytes --]
Hi Claudiu,
I love your patch! Perhaps something to improve:
[auto build test WARNING on robh/for-next]
[also build test WARNING on net-next/master net/master linus/master v5.10-rc7 next-20201208]
[cannot apply to sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Claudiu-Beznea/net-macb-add-support-for-sama7g5/20201207-201959
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: arm64-randconfig-r021-20201208 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 1968804ac726e7674d5de22bc2204b45857da344)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/7a9fff9938fe9b459aa67f4afb0e817313d3d54a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Claudiu-Beznea/net-macb-add-support-for-sama7g5/20201207-201959
git checkout 7a9fff9938fe9b459aa67f4afb0e817313d3d54a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/net/ethernet/cadence/macb_main.c:4506:6: warning: variable 'bp' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!dev) {
^~~~
drivers/net/ethernet/cadence/macb_main.c:4641:20: note: uninitialized use occurs here
macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
^~
drivers/net/ethernet/cadence/macb_main.c:4506:2: note: remove the 'if' if its condition is always false
if (!dev) {
^~~~~~~~~~~
drivers/net/ethernet/cadence/macb_main.c:4474:17: note: initialize the variable 'bp' to silence this warning
struct macb *bp;
^
= NULL
1 warning generated.
vim +4506 drivers/net/ethernet/cadence/macb_main.c
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4456
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4457 static int macb_probe(struct platform_device *pdev)
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4458 {
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4459 const struct macb_config *macb_config = &default_gem_config;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4460 int (*clk_init)(struct platform_device *, struct clk **,
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4461 struct clk **, struct clk **, struct clk **,
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4462 struct clk **) = macb_config->clk_init;
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4463 int (*init)(struct platform_device *) = macb_config->init;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4464 struct device_node *np = pdev->dev.of_node;
aead88bd0e9905 drivers/net/ethernet/cadence/macb.c shubhrajyoti.datta@xilinx.com 2016-08-16 4465 struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4466 struct clk *tsu_clk = NULL;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4467 unsigned int queue_mask, num_queues;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4468 bool native_io;
0c65b2b90d13c1 drivers/net/ethernet/cadence/macb_main.c Andrew Lunn 2019-11-04 4469 phy_interface_t interface;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4470 struct net_device *dev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4471 struct resource *regs;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4472 void __iomem *mem;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4473 const char *mac;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4474 struct macb *bp;
404cd086f29e86 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2018-07-06 4475 int err, val;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4476
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4477 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4478 mem = devm_ioremap_resource(&pdev->dev, regs);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4479 if (IS_ERR(mem))
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4480 return PTR_ERR(mem);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4481
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4482 if (np) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4483 const struct of_device_id *match;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4484
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4485 match = of_match_node(macb_dt_ids, np);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4486 if (match && match->data) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4487 macb_config = match->data;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4488 clk_init = macb_config->clk_init;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4489 init = macb_config->init;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4490 }
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4491 }
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4492
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4493 err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4494 if (err)
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4495 return err;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4496
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4497 pm_runtime_set_autosuspend_delay(&pdev->dev, MACB_PM_TIMEOUT);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4498 pm_runtime_use_autosuspend(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4499 pm_runtime_get_noresume(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4500 pm_runtime_set_active(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4501 pm_runtime_enable(&pdev->dev);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4502 native_io = hw_is_native_io(mem);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4503
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4504 macb_probe_queues(mem, native_io, &queue_mask, &num_queues);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4505 dev = alloc_etherdev_mq(sizeof(*bp), num_queues);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 @4506 if (!dev) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4507 err = -ENOMEM;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4508 goto err_disable_clocks;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4509 }
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4510
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4511 dev->base_addr = regs->start;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4512
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4513 SET_NETDEV_DEV(dev, &pdev->dev);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4514
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4515 bp = netdev_priv(dev);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4516 bp->pdev = pdev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4517 bp->dev = dev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4518 bp->regs = mem;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4519 bp->native_io = native_io;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4520 if (native_io) {
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4521 bp->macb_reg_readl = hw_readl_native;
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4522 bp->macb_reg_writel = hw_writel_native;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4523 } else {
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4524 bp->macb_reg_readl = hw_readl;
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4525 bp->macb_reg_writel = hw_writel;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4526 }
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4527 bp->num_queues = num_queues;
bfa0914afa95d4 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4528 bp->queue_mask = queue_mask;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4529 if (macb_config)
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4530 bp->dma_burst_length = macb_config->dma_burst_length;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4531 bp->pclk = pclk;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4532 bp->hclk = hclk;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4533 bp->tx_clk = tx_clk;
aead88bd0e9905 drivers/net/ethernet/cadence/macb.c shubhrajyoti.datta@xilinx.com 2016-08-16 4534 bp->rx_clk = rx_clk;
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4535 bp->tsu_clk = tsu_clk;
f36dbe6a285e06 drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4536 if (macb_config)
98b5a0f4a2282f drivers/net/ethernet/cadence/macb.c Harini Katakam 2015-05-06 4537 bp->jumbo_max_len = macb_config->jumbo_max_len;
98b5a0f4a2282f drivers/net/ethernet/cadence/macb.c Harini Katakam 2015-05-06 4538
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4539 bp->wol = 0;
7c4a1d0cfdc169 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-16 4540 if (of_get_property(np, "magic-packet", NULL))
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4541 bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
ced4799d063759 drivers/net/ethernet/cadence/macb_main.c Nicolas Ferre 2020-07-10 4542 device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4543
5c14e373350d7e drivers/net/ethernet/cadence/macb_main.c Claudiu Beznea 2020-12-07 4544 bp->usrio = macb_config->usrio;
5c14e373350d7e drivers/net/ethernet/cadence/macb_main.c Claudiu Beznea 2020-12-07 4545
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4546 spin_lock_init(&bp->lock);
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4547
ad78347f06581e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4548 /* setup capabilities */
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4549 macb_configure_caps(bp, macb_config);
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4550
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34752 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 4/8] net: macb: unprepare clocks in case of failure
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
` (2 preceding siblings ...)
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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 | 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 6b8e1109dfd3..deb232801edb 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4413,8 +4413,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;
@@ -4425,16 +4427,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] 13+ messages in thread
* [PATCH v2 5/8] dt-bindings: add documentation for sama7g5 ethernet interface
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
` (3 preceding siblings ...)
2020-12-07 12:15 ` [PATCH v2 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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] 13+ messages in thread
* [PATCH v2 6/8] dt-bindings: add documentation for sama7g5 gigabit ethernet interface
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
` (4 preceding siblings ...)
2020-12-07 12:15 ` [PATCH v2 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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] 13+ messages in thread
* [PATCH v2 7/8] net: macb: add support for sama7g5 gem interface
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
` (5 preceding siblings ...)
2020-12-07 12:15 ` [PATCH v2 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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 deb232801edb..ca56476b3a04 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4465,6 +4465,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,
@@ -4558,6 +4566,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 },
@@ -4575,6 +4591,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] 13+ messages in thread
* [PATCH v2 8/8] net: macb: add support for sama7g5 emac interface
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
` (6 preceding siblings ...)
2020-12-07 12:15 ` [PATCH v2 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
@ 2020-12-07 12:15 ` Claudiu Beznea
7 siblings, 0 replies; 13+ messages in thread
From: Claudiu Beznea @ 2020-12-07 12:15 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>
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 ca56476b3a04..bb280c55c4b3 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4574,6 +4574,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 },
@@ -4592,6 +4600,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] 13+ messages in thread