* [PATCH net-next 0/3] net: systemport: Clock support
@ 2020-09-01 21:43 Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 1/3] dt-bindings: net: Document Broadcom SYSTEMPORT clocks Florian Fainelli
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-09-01 21:43 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, David S. Miller, Jakub Kicinski, Rob Herring,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list, open list:BROADCOM SYSTEMPORT ETHERNET DRIVER
Hi David,
This patch series makes the SYSTEMPORT driver request and manage its
main and Wake-on-LAN clocks appropriately.
Florian Fainelli (3):
dt-bindings: net: Document Broadcom SYSTEMPORT clocks
net: systemport: fetch and use clock resources
net: systemport: Manage Wake-on-LAN clock
.../bindings/net/brcm,systemport.txt | 5 +++
drivers/net/ethernet/broadcom/bcmsysport.c | 40 ++++++++++++++++++-
drivers/net/ethernet/broadcom/bcmsysport.h | 2 +
3 files changed, 45 insertions(+), 2 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/3] dt-bindings: net: Document Broadcom SYSTEMPORT clocks
2020-09-01 21:43 [PATCH net-next 0/3] net: systemport: Clock support Florian Fainelli
@ 2020-09-01 21:43 ` Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 2/3] net: systemport: fetch and use clock resources Florian Fainelli
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-09-01 21:43 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, David S. Miller, Jakub Kicinski, Rob Herring,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list, open list:BROADCOM SYSTEMPORT ETHERNET DRIVER
The Broadcom SYSTEMPORT adapters require the use of two clocks for
normal operations and during Wake-on-LAN, document those in the binding
document.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Documentation/devicetree/bindings/net/brcm,systemport.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/brcm,systemport.txt b/Documentation/devicetree/bindings/net/brcm,systemport.txt
index 83f29e0e11ba..745bb1776572 100644
--- a/Documentation/devicetree/bindings/net/brcm,systemport.txt
+++ b/Documentation/devicetree/bindings/net/brcm,systemport.txt
@@ -20,6 +20,11 @@ Optional properties:
- systemport,num-tier1-arb: number of tier 1 arbiters, an integer
- systemport,num-txq: number of HW transmit queues, an integer
- systemport,num-rxq: number of HW receive queues, an integer
+- clocks: When provided, must be two phandles to the functional clocks nodes of
+ the SYSTEMPORT block. The first phandle is the main SYSTEMPORT clock used
+ during normal operation, while the second phandle is the Wake-on-LAN clock.
+- clock-names: When provided, names of the functional clock phandles, first
+ name should be "sw_sysport" and second should be "sw_sysportwol".
Example:
ethernet@f04a0000 {
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/3] net: systemport: fetch and use clock resources
2020-09-01 21:43 [PATCH net-next 0/3] net: systemport: Clock support Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 1/3] dt-bindings: net: Document Broadcom SYSTEMPORT clocks Florian Fainelli
@ 2020-09-01 21:43 ` Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 3/3] net: systemport: Manage Wake-on-LAN clock Florian Fainelli
2020-09-03 22:06 ` [PATCH net-next 0/3] net: systemport: Clock support David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-09-01 21:43 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, David S. Miller, Jakub Kicinski, Rob Herring,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list, open list:BROADCOM SYSTEMPORT ETHERNET DRIVER
We disable clocks shortly after probing the device to save as much power as
possible in case the interface is never used. When bcm_sysport_open() is
invoked, clocks are enabled, and disabled in bcm_sysport_stop().
A similar scheme is applied to the suspend/resume functions.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 30 +++++++++++++++++++++-
drivers/net/ethernet/broadcom/bcmsysport.h | 1 +
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index dfed9ade6950..91eadba5540c 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -20,6 +20,7 @@
#include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <net/dsa.h>
+#include <linux/clk.h>
#include <net/ip.h>
#include <net/ipv6.h>
@@ -186,6 +187,11 @@ static int bcm_sysport_set_features(struct net_device *dev,
netdev_features_t features)
{
struct bcm_sysport_priv *priv = netdev_priv(dev);
+ int ret;
+
+ ret = clk_prepare_enable(priv->clk);
+ if (ret)
+ return ret;
/* Read CRC forward */
if (!priv->is_lite)
@@ -197,6 +203,8 @@ static int bcm_sysport_set_features(struct net_device *dev,
bcm_sysport_set_rx_csum(dev, features);
bcm_sysport_set_tx_csum(dev, features);
+ clk_disable_unprepare(priv->clk);
+
return 0;
}
@@ -1940,6 +1948,8 @@ static int bcm_sysport_open(struct net_device *dev)
unsigned int i;
int ret;
+ clk_prepare_enable(priv->clk);
+
/* Reset UniMAC */
umac_reset(priv);
@@ -1970,7 +1980,8 @@ static int bcm_sysport_open(struct net_device *dev)
0, priv->phy_interface);
if (!phydev) {
netdev_err(dev, "could not attach to PHY\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_clk_disable;
}
/* Reset house keeping link status */
@@ -2048,6 +2059,8 @@ static int bcm_sysport_open(struct net_device *dev)
free_irq(priv->irq0, dev);
out_phy_disconnect:
phy_disconnect(phydev);
+out_clk_disable:
+ clk_disable_unprepare(priv->clk);
return ret;
}
@@ -2106,6 +2119,8 @@ static int bcm_sysport_stop(struct net_device *dev)
/* Disconnect from PHY */
phy_disconnect(dev->phydev);
+ clk_disable_unprepare(priv->clk);
+
return 0;
}
@@ -2487,6 +2502,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
/* Initialize private members */
priv = netdev_priv(dev);
+ priv->clk = devm_clk_get_optional(&pdev->dev, "sw_sysport");
+ if (IS_ERR(priv->clk))
+ return PTR_ERR(priv->clk);
+
/* Allocate number of TX rings */
priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
sizeof(struct bcm_sysport_tx_ring),
@@ -2588,6 +2607,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)
goto err_deregister_notifier;
}
+ clk_prepare_enable(priv->clk);
+
priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK;
dev_info(&pdev->dev,
"Broadcom SYSTEMPORT%s " REV_FMT
@@ -2596,6 +2617,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)
(priv->rev >> 8) & 0xff, priv->rev & 0xff,
priv->irq0, priv->irq1, txq, rxq);
+ clk_disable_unprepare(priv->clk);
+
return 0;
err_deregister_notifier:
@@ -2752,6 +2775,8 @@ static int __maybe_unused bcm_sysport_suspend(struct device *d)
if (device_may_wakeup(d) && priv->wolopts)
ret = bcm_sysport_suspend_to_wol(priv);
+ clk_disable_unprepare(priv->clk);
+
return ret;
}
@@ -2765,6 +2790,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
if (!netif_running(dev))
return 0;
+ clk_prepare_enable(priv->clk);
+
umac_reset(priv);
/* Disable the UniMAC RX/TX */
@@ -2844,6 +2871,7 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
out_free_tx_rings:
for (i = 0; i < dev->num_tx_queues; i++)
bcm_sysport_fini_tx_ring(priv, i);
+ clk_disable_unprepare(priv->clk);
return ret;
}
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index 6d80735fbc7f..51800053e88c 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -770,6 +770,7 @@ struct bcm_sysport_priv {
u32 wolopts;
u8 sopass[SOPASS_MAX];
unsigned int wol_irq_disabled:1;
+ struct clk *clk;
/* MIB related fields */
struct bcm_sysport_mib mib;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 3/3] net: systemport: Manage Wake-on-LAN clock
2020-09-01 21:43 [PATCH net-next 0/3] net: systemport: Clock support Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 1/3] dt-bindings: net: Document Broadcom SYSTEMPORT clocks Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 2/3] net: systemport: fetch and use clock resources Florian Fainelli
@ 2020-09-01 21:43 ` Florian Fainelli
2020-09-03 22:06 ` [PATCH net-next 0/3] net: systemport: Clock support David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-09-01 21:43 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Blair Prescott, David S. Miller,
Jakub Kicinski, Rob Herring,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list, open list:BROADCOM SYSTEMPORT ETHERNET DRIVER
It is necessary to manage the Wake-on-LAN clock to turn on the
appropriate blocks for MPD or CFP-based packet matching to work
otherwise we will not be able to reliably match packets during suspend.
Reported-by: Blair Prescott <blair.prescott@broadcom.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 10 +++++++++-
drivers/net/ethernet/broadcom/bcmsysport.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 91eadba5540c..b25c70b74c92 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2583,6 +2583,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
if (!ret)
device_set_wakeup_capable(&pdev->dev, 1);
+ priv->wol_clk = devm_clk_get_optional(&pdev->dev, "sw_sysportwol");
+ if (IS_ERR(priv->wol_clk))
+ return PTR_ERR(priv->wol_clk);
+
/* Set the needed headroom once and for all */
BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8);
dev->needed_headroom += sizeof(struct bcm_tsb);
@@ -2772,8 +2776,10 @@ static int __maybe_unused bcm_sysport_suspend(struct device *d)
bcm_sysport_fini_rx_ring(priv);
/* Get prepared for Wake-on-LAN */
- if (device_may_wakeup(d) && priv->wolopts)
+ if (device_may_wakeup(d) && priv->wolopts) {
+ clk_prepare_enable(priv->wol_clk);
ret = bcm_sysport_suspend_to_wol(priv);
+ }
clk_disable_unprepare(priv->clk);
@@ -2791,6 +2797,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
return 0;
clk_prepare_enable(priv->clk);
+ if (priv->wolopts)
+ clk_disable_unprepare(priv->wol_clk);
umac_reset(priv);
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index 51800053e88c..3a5cb6f128f5 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -771,6 +771,7 @@ struct bcm_sysport_priv {
u8 sopass[SOPASS_MAX];
unsigned int wol_irq_disabled:1;
struct clk *clk;
+ struct clk *wol_clk;
/* MIB related fields */
struct bcm_sysport_mib mib;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/3] net: systemport: Clock support
2020-09-01 21:43 [PATCH net-next 0/3] net: systemport: Clock support Florian Fainelli
` (2 preceding siblings ...)
2020-09-01 21:43 ` [PATCH net-next 3/3] net: systemport: Manage Wake-on-LAN clock Florian Fainelli
@ 2020-09-03 22:06 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-09-03 22:06 UTC (permalink / raw)
To: f.fainelli
Cc: netdev, kuba, robh+dt, devicetree, linux-kernel,
bcm-kernel-feedback-list
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 1 Sep 2020 14:43:45 -0700
> This patch series makes the SYSTEMPORT driver request and manage its
> main and Wake-on-LAN clocks appropriately.
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-03 22:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 21:43 [PATCH net-next 0/3] net: systemport: Clock support Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 1/3] dt-bindings: net: Document Broadcom SYSTEMPORT clocks Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 2/3] net: systemport: fetch and use clock resources Florian Fainelli
2020-09-01 21:43 ` [PATCH net-next 3/3] net: systemport: Manage Wake-on-LAN clock Florian Fainelli
2020-09-03 22:06 ` [PATCH net-next 0/3] net: systemport: Clock support David Miller
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).