[PATCH net-next 2/5] net: stmmac: dwmac-sun8i: Remove unnecessary PHY power check

18 views
Skip to first unread message

Samuel Holland

unread,
Jan 3, 2021, 6:25:51 AM1/3/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
sun8i_dwmac_unpower_internal_phy already checks if the PHY is powered,
so there is no need to do it again here.

Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 8e505019adf8..3c3d0b99d3e8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1018,10 +1018,8 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
{
struct sunxi_priv_data *gmac = priv;

- if (gmac->variant->soc_has_internal_phy) {
- if (gmac->internal_phy_powered)
- sun8i_dwmac_unpower_internal_phy(gmac);
- }
+ if (gmac->variant->soc_has_internal_phy)
+ sun8i_dwmac_unpower_internal_phy(gmac);

clk_disable_unprepare(gmac->tx_clk);

--
2.26.2

Samuel Holland

unread,
Jan 3, 2021, 6:25:51 AM1/3/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
Use the appropriate function instead of reimplementing it,
and update the error message to match the code.

Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 3c3d0b99d3e8..0e8d88417251 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -806,11 +806,9 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)
/* Make sure the EPHY is properly reseted, as U-Boot may leave
* it at deasserted state, and thus it may fail to reset EMAC.
*/
- reset_control_assert(gmac->rst_ephy);
-
- ret = reset_control_deassert(gmac->rst_ephy);
+ ret = reset_control_reset(gmac->rst_ephy);
if (ret) {
- dev_err(priv->device, "Cannot deassert internal phy\n");
+ dev_err(priv->device, "Cannot reset internal PHY\n");
clk_disable_unprepare(gmac->ephy_clk);
return ret;
}
--
2.26.2

Samuel Holland

unread,
Jan 3, 2021, 6:25:51 AM1/3/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
These patches clean up some things I noticed while fixing suspend/resume
behavior. The first four are minor code improvements. The last one adds
a shutdown hook to minimize power consumption on boards without a PMIC.

Samuel Holland (5):
net: stmmac: dwmac-sun8i: Return void from PHY unpower
net: stmmac: dwmac-sun8i: Remove unnecessary PHY power check
net: stmmac: dwmac-sun8i: Use reset_control_reset
net: stmmac: dwmac-sun8i: Minor probe function cleanup
net: stmmac: dwmac-sun8i: Add a shutdown callback

.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 31 ++++++++++++-------
1 file changed, 19 insertions(+), 12 deletions(-)

--
2.26.2

Samuel Holland

unread,
Jan 3, 2021, 6:25:53 AM1/3/21
to Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, net...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com, Samuel Holland
The Ethernet MAC and PHY are usually major consumers of power on boards
which may not be able to fully power off (that have no PMIC). Powering
down the MAC and internal PHY saves power while these boards are "off".

Signed-off-by: Samuel Holland <sam...@sholland.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 4638d4203af5..926e8d5e8963 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1282,6 +1282,15 @@ static int sun8i_dwmac_remove(struct platform_device *pdev)
return 0;
}

+static void sun8i_dwmac_shutdown(struct platform_device *pdev)
+{
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct stmmac_priv *priv = netdev_priv(ndev);
+ struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
+
+ sun8i_dwmac_exit(pdev, gmac);
+}
+
static const struct of_device_id sun8i_dwmac_match[] = {
{ .compatible = "allwinner,sun8i-h3-emac",
.data = &emac_variant_h3 },
@@ -1302,6 +1311,7 @@ MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
static struct platform_driver sun8i_dwmac_driver = {
.probe = sun8i_dwmac_probe,
.remove = sun8i_dwmac_remove,
+ .shutdown = sun8i_dwmac_shutdown,
.driver = {
.name = "dwmac-sun8i",
.pm = &stmmac_pltfr_pm_ops,
--
2.26.2

Chen-Yu Tsai

unread,
Jan 6, 2021, 5:00:44 AM1/6/21
to Samuel Holland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, netdev, linux-arm-kernel, linux-kernel, linux-sunxi
On Sun, Jan 3, 2021 at 7:25 PM Samuel Holland <sam...@sholland.org> wrote:
>
> sun8i_dwmac_unpower_internal_phy already checks if the PHY is powered,
> so there is no need to do it again here.
>
> Signed-off-by: Samuel Holland <sam...@sholland.org>

Reviewed-by: Chen-Yu Tsai <we...@csie.org>

Chen-Yu Tsai

unread,
Jan 6, 2021, 5:01:01 AM1/6/21
to Samuel Holland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, netdev, linux-arm-kernel, linux-kernel, linux-sunxi
On Sun, Jan 3, 2021 at 7:25 PM Samuel Holland <sam...@sholland.org> wrote:
>
> Use the appropriate function instead of reimplementing it,
> and update the error message to match the code.
>
> Signed-off-by: Samuel Holland <sam...@sholland.org>

Reviewed-by: Chen-Yu Tsai <we...@csie.org>

Chen-Yu Tsai

unread,
Jan 6, 2021, 5:07:26 AM1/6/21
to Samuel Holland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Jakub Kicinski, Maxime Ripard, Jernej Skrabec, Corentin Labbe, Ondrej Jirman, netdev, linux-arm-kernel, linux-kernel, linux-sunxi
On Sun, Jan 3, 2021 at 7:25 PM Samuel Holland <sam...@sholland.org> wrote:
>
> The Ethernet MAC and PHY are usually major consumers of power on boards
> which may not be able to fully power off (that have no PMIC). Powering
> down the MAC and internal PHY saves power while these boards are "off".
>
> Signed-off-by: Samuel Holland <sam...@sholland.org>

Reviewed-by: Chen-Yu Tsai <we...@csie.org>
Reply all
Reply to author
Forward
0 new messages