Commit 17fadd9a authored by Sekhar Nori's avatar Sekhar Nori Committed by Kevin Hilman

davinci: DA850/OMAP-L138 EVM: simplify configuration of emac in MII/RMII mode

There are multiple steps in configuring the EMAC to MII or RMII mode.
Current code implements them using multiple checks.

Consolidate the multiple checks into a single if construct.
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 797d799e
...@@ -535,23 +535,27 @@ static int __init da850_evm_config_emac(void) ...@@ -535,23 +535,27 @@ static int __init da850_evm_config_emac(void)
cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG); cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
/* configure the CFGCHIP3 register for RMII or MII */
val = __raw_readl(cfg_chip3_base); val = __raw_readl(cfg_chip3_base);
if (rmii_en)
if (rmii_en) {
val |= BIT(8); val |= BIT(8);
else ret = da8xx_pinmux_setup(da850_rmii_pins);
pr_info("EMAC: RMII PHY configured, MII PHY will not be"
" functional\n");
} else {
val &= ~BIT(8); val &= ~BIT(8);
__raw_writel(val, cfg_chip3_base);
if (!rmii_en)
ret = da8xx_pinmux_setup(da850_cpgmac_pins); ret = da8xx_pinmux_setup(da850_cpgmac_pins);
else pr_info("EMAC: MII PHY configured, RMII PHY will not be"
ret = da8xx_pinmux_setup(da850_rmii_pins); " functional\n");
}
if (ret) if (ret)
pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n", pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
ret); ret);
/* configure the CFGCHIP3 register for RMII or MII */
__raw_writel(val, cfg_chip3_base);
ret = davinci_cfg_reg(DA850_GPIO2_6); ret = davinci_cfg_reg(DA850_GPIO2_6);
if (ret) if (ret)
pr_warning("da850_evm_init:GPIO(2,6) mux setup " pr_warning("da850_evm_init:GPIO(2,6) mux setup "
...@@ -564,17 +568,8 @@ static int __init da850_evm_config_emac(void) ...@@ -564,17 +568,8 @@ static int __init da850_evm_config_emac(void)
return ret; return ret;
} }
if (rmii_en) { /* Enable/Disable MII MDIO clock */
/* Disable MII MDIO clock */ gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, 1);
pr_info("EMAC: RMII PHY configured, MII PHY will not be"
" functional\n");
} else {
/* Enable MII MDIO clock */
gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, 0);
pr_info("EMAC: MII PHY configured, RMII PHY will not be"
" functional\n");
}
soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK; soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY; soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
......
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