Commit 92704f8c authored by Marek Vasut's avatar Marek Vasut Committed by Paolo Abeni

net: stmmac: dwmac-stm32: Extract PMCR configuration

Pull the PMCR clock mux configuration into a separate function. This is
the final change of three, which moves external clock rate validation,
external clock selector decoding, and clock mux configuration into
separate functions. This should make the code easier to understand.
No functional change intended.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarChristophe Roullier <christophe.roullier@foss.st.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 63b0aa8e
...@@ -219,15 +219,11 @@ static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat) ...@@ -219,15 +219,11 @@ static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat)
return -EINVAL; return -EINVAL;
} }
static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
{ {
struct stm32_dwmac *dwmac = plat_dat->bsp_priv; struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
u32 reg = dwmac->mode_reg; u32 reg = dwmac->mode_reg;
int val, ret; int val;
ret = stm32mp1_select_ethck_external(plat_dat);
if (ret)
return ret;
switch (plat_dat->mac_interface) { switch (plat_dat->mac_interface) {
case PHY_INTERFACE_MODE_MII: case PHY_INTERFACE_MODE_MII:
...@@ -262,10 +258,6 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) ...@@ -262,10 +258,6 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat)
return -EINVAL; return -EINVAL;
} }
ret = stm32mp1_validate_ethck_rate(plat_dat);
if (ret)
return ret;
/* Need to update PMCCLRR (clear register) */ /* Need to update PMCCLRR (clear register) */
regmap_write(dwmac->regmap, reg + SYSCFG_PMCCLRR_OFFSET, regmap_write(dwmac->regmap, reg + SYSCFG_PMCCLRR_OFFSET,
dwmac->ops->syscfg_eth_mask); dwmac->ops->syscfg_eth_mask);
...@@ -275,6 +267,21 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) ...@@ -275,6 +267,21 @@ static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat)
dwmac->ops->syscfg_eth_mask, val); dwmac->ops->syscfg_eth_mask, val);
} }
static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat)
{
int ret;
ret = stm32mp1_select_ethck_external(plat_dat);
if (ret)
return ret;
ret = stm32mp1_validate_ethck_rate(plat_dat);
if (ret)
return ret;
return stm32mp1_configure_pmcr(plat_dat);
}
static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat) static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat)
{ {
struct stm32_dwmac *dwmac = plat_dat->bsp_priv; struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
......
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