net: stmmac: dwmac-meson8b: Make the clock enabling code re-usable
The timing adjustment clock will need similar logic as the RGMII clock: It has to be enabled in the driver conditionally and when the driver is unloaded it should be disabled again. Extract the existing code for the RGMII clock into a new function so it can be re-used. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e4227bff80
commit
a54dc4a490
@ -266,6 +266,22 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac,
|
||||||
|
struct clk *clk)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = clk_prepare_enable(clk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
devm_add_action_or_reset(dwmac->dev,
|
||||||
|
(void(*)(void *))clk_disable_unprepare,
|
||||||
|
dwmac->rgmii_tx_clk);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
|
static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -299,16 +315,13 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(dwmac->rgmii_tx_clk);
|
ret = meson8b_devm_clk_prepare_enable(dwmac,
|
||||||
|
dwmac->rgmii_tx_clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dwmac->dev,
|
dev_err(dwmac->dev,
|
||||||
"failed to enable the RGMII TX clock\n");
|
"failed to enable the RGMII TX clock\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
devm_add_action_or_reset(dwmac->dev,
|
|
||||||
(void(*)(void *))clk_disable_unprepare,
|
|
||||||
dwmac->rgmii_tx_clk);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHY_INTERFACE_MODE_RMII:
|
case PHY_INTERFACE_MODE_RMII:
|
||||||
|
Loading…
Reference in New Issue
Block a user