Commit 94edc86b authored by David S. Miller's avatar David S. Miller

Merge branch 'dwmac-sti-refactor-cleanup'

Joachim Eastwood says:

====================
stmmac: dwmac-sti refactor+cleanup

This patch set aims to remove the init/exit callbacks from the
dwmac-sti driver and instead use standard PM callbacks. Doing this
will also allow us to cleanup the driver.

Eventually the init/exit callbacks will be deprecated and removed
from all drivers dwmac-* except for dwmac-generic. Drivers will be
refactored to use standard PM and remove callbacks.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9811d1e3 cb42d4b6
...@@ -126,8 +126,8 @@ struct sti_dwmac { ...@@ -126,8 +126,8 @@ struct sti_dwmac {
struct clk *clk; /* PHY clock */ struct clk *clk; /* PHY clock */
u32 ctrl_reg; /* GMAC glue-logic control register */ u32 ctrl_reg; /* GMAC glue-logic control register */
int clk_sel_reg; /* GMAC ext clk selection register */ int clk_sel_reg; /* GMAC ext clk selection register */
struct device *dev;
struct regmap *regmap; struct regmap *regmap;
bool gmac_en;
u32 speed; u32 speed;
void (*fix_retime_src)(void *priv, unsigned int speed); void (*fix_retime_src)(void *priv, unsigned int speed);
}; };
...@@ -191,7 +191,7 @@ static void stih4xx_fix_retime_src(void *priv, u32 spd) ...@@ -191,7 +191,7 @@ static void stih4xx_fix_retime_src(void *priv, u32 spd)
} }
} }
if (src == TX_RETIME_SRC_CLKGEN && dwmac->clk && freq) if (src == TX_RETIME_SRC_CLKGEN && freq)
clk_set_rate(dwmac->clk, freq); clk_set_rate(dwmac->clk, freq);
regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK,
...@@ -222,26 +222,20 @@ static void stid127_fix_retime_src(void *priv, u32 spd) ...@@ -222,26 +222,20 @@ static void stid127_fix_retime_src(void *priv, u32 spd)
freq = DWMAC_2_5MHZ; freq = DWMAC_2_5MHZ;
} }
if (dwmac->clk && freq) if (freq)
clk_set_rate(dwmac->clk, freq); clk_set_rate(dwmac->clk, freq);
regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val); regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val);
} }
static int sti_dwmac_init(struct platform_device *pdev, void *priv) static int sti_dwmac_set_mode(struct sti_dwmac *dwmac)
{ {
struct sti_dwmac *dwmac = priv;
struct regmap *regmap = dwmac->regmap; struct regmap *regmap = dwmac->regmap;
int iface = dwmac->interface; int iface = dwmac->interface;
struct device *dev = dwmac->dev;
struct device_node *np = dev->of_node;
u32 reg = dwmac->ctrl_reg; u32 reg = dwmac->ctrl_reg;
u32 val; u32 val;
if (dwmac->clk) if (dwmac->gmac_en)
clk_prepare_enable(dwmac->clk);
if (of_property_read_bool(np, "st,gmac_en"))
regmap_update_bits(regmap, reg, EN_MASK, EN); regmap_update_bits(regmap, reg, EN_MASK, EN);
regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]); regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]);
...@@ -249,18 +243,11 @@ static int sti_dwmac_init(struct platform_device *pdev, void *priv) ...@@ -249,18 +243,11 @@ static int sti_dwmac_init(struct platform_device *pdev, void *priv)
val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII; val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
regmap_update_bits(regmap, reg, ENMII_MASK, val); regmap_update_bits(regmap, reg, ENMII_MASK, val);
dwmac->fix_retime_src(priv, dwmac->speed); dwmac->fix_retime_src(dwmac, dwmac->speed);
return 0; return 0;
} }
static void sti_dwmac_exit(struct platform_device *pdev, void *priv)
{
struct sti_dwmac *dwmac = priv;
if (dwmac->clk)
clk_disable_unprepare(dwmac->clk);
}
static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
struct platform_device *pdev) struct platform_device *pdev)
{ {
...@@ -270,9 +257,6 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, ...@@ -270,9 +257,6 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
struct regmap *regmap; struct regmap *regmap;
int err; int err;
if (!np)
return -EINVAL;
/* clk selection from extra syscfg register */ /* clk selection from extra syscfg register */
dwmac->clk_sel_reg = -ENXIO; dwmac->clk_sel_reg = -ENXIO;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf");
...@@ -289,9 +273,9 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, ...@@ -289,9 +273,9 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
return err; return err;
} }
dwmac->dev = dev;
dwmac->interface = of_get_phy_mode(np); dwmac->interface = of_get_phy_mode(np);
dwmac->regmap = regmap; dwmac->regmap = regmap;
dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en");
dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk");
dwmac->tx_retime_src = TX_RETIME_SRC_NA; dwmac->tx_retime_src = TX_RETIME_SRC_NA;
dwmac->speed = SPEED_100; dwmac->speed = SPEED_100;
...@@ -357,17 +341,62 @@ static int sti_dwmac_probe(struct platform_device *pdev) ...@@ -357,17 +341,62 @@ static int sti_dwmac_probe(struct platform_device *pdev)
dwmac->fix_retime_src = data->fix_retime_src; dwmac->fix_retime_src = data->fix_retime_src;
plat_dat->bsp_priv = dwmac; plat_dat->bsp_priv = dwmac;
plat_dat->init = sti_dwmac_init;
plat_dat->exit = sti_dwmac_exit;
plat_dat->fix_mac_speed = data->fix_retime_src; plat_dat->fix_mac_speed = data->fix_retime_src;
ret = sti_dwmac_init(pdev, plat_dat->bsp_priv); ret = clk_prepare_enable(dwmac->clk);
if (ret) if (ret)
return ret; return ret;
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); ret = sti_dwmac_set_mode(dwmac);
if (ret)
goto disable_clk;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
if (ret)
goto disable_clk;
return 0;
disable_clk:
clk_disable_unprepare(dwmac->clk);
return ret;
} }
static int sti_dwmac_remove(struct platform_device *pdev)
{
struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
int ret = stmmac_dvr_remove(&pdev->dev);
clk_disable_unprepare(dwmac->clk);
return ret;
}
#ifdef CONFIG_PM_SLEEP
static int sti_dwmac_suspend(struct device *dev)
{
struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev);
int ret = stmmac_suspend(dev);
clk_disable_unprepare(dwmac->clk);
return ret;
}
static int sti_dwmac_resume(struct device *dev)
{
struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev);
clk_prepare_enable(dwmac->clk);
sti_dwmac_set_mode(dwmac);
return stmmac_resume(dev);
}
#endif /* CONFIG_PM_SLEEP */
static SIMPLE_DEV_PM_OPS(sti_dwmac_pm_ops, sti_dwmac_suspend,
sti_dwmac_resume);
static const struct sti_dwmac_of_data stih4xx_dwmac_data = { static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
.fix_retime_src = stih4xx_fix_retime_src, .fix_retime_src = stih4xx_fix_retime_src,
}; };
...@@ -387,10 +416,10 @@ MODULE_DEVICE_TABLE(of, sti_dwmac_match); ...@@ -387,10 +416,10 @@ MODULE_DEVICE_TABLE(of, sti_dwmac_match);
static struct platform_driver sti_dwmac_driver = { static struct platform_driver sti_dwmac_driver = {
.probe = sti_dwmac_probe, .probe = sti_dwmac_probe,
.remove = stmmac_pltfr_remove, .remove = sti_dwmac_remove,
.driver = { .driver = {
.name = "sti-dwmac", .name = "sti-dwmac",
.pm = &stmmac_pltfr_pm_ops, .pm = &sti_dwmac_pm_ops,
.of_match_table = sti_dwmac_match, .of_match_table = sti_dwmac_match,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment