Merge branch 'ddwmac-sun8i-cleanup-and-shutdown-hook'
Samuel Holland says: ==================== dwmac-sun8i cleanup and shutdown hook 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. Changes v1 to v2: - Note the assumption of exclusive reset controller access in patch 3 ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@ -805,12 +805,12 @@ 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.
|
||||
*
|
||||
* This assumes the driver has exclusive access to the EPHY reset.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
@ -820,15 +820,14 @@ static int sun8i_dwmac_power_internal_phy(struct stmmac_priv *priv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sun8i_dwmac_unpower_internal_phy(struct sunxi_priv_data *gmac)
|
||||
static void sun8i_dwmac_unpower_internal_phy(struct sunxi_priv_data *gmac)
|
||||
{
|
||||
if (!gmac->internal_phy_powered)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
clk_disable_unprepare(gmac->ephy_clk);
|
||||
reset_control_assert(gmac->rst_ephy);
|
||||
gmac->internal_phy_powered = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* MDIO multiplexing switch function
|
||||
@ -1019,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);
|
||||
|
||||
@ -1232,6 +1229,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
|
||||
|
||||
ndev = dev_get_drvdata(&pdev->dev);
|
||||
priv = netdev_priv(ndev);
|
||||
|
||||
/* The mux must be registered after parent MDIO
|
||||
* so after stmmac_dvr_probe()
|
||||
*/
|
||||
@ -1250,7 +1248,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
|
||||
goto dwmac_remove;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
|
||||
dwmac_mux:
|
||||
reset_control_put(gmac->rst_ephy);
|
||||
clk_put(gmac->ephy_clk);
|
||||
@ -1285,6 +1284,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 },
|
||||
@ -1305,6 +1313,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,
|
||||
|
Reference in New Issue
Block a user