Lines Matching full:gmac
38 * @syscon_field reg_field for the syscon's gmac register
588 struct sunxi_priv_data *gmac = priv; in sun8i_dwmac_init() local
591 if (gmac->regulator) { in sun8i_dwmac_init()
592 ret = regulator_enable(gmac->regulator); in sun8i_dwmac_init()
599 if (gmac->use_internal_phy) { in sun8i_dwmac_init()
608 if (gmac->regulator) in sun8i_dwmac_init()
609 regulator_disable(gmac->regulator); in sun8i_dwmac_init()
776 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in get_ephy_nodes() local
797 gmac->ephy_clk = of_clk_get(iphynode, 0); in get_ephy_nodes()
798 if (IS_ERR(gmac->ephy_clk)) in get_ephy_nodes()
800 gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); in get_ephy_nodes()
801 if (IS_ERR(gmac->rst_ephy)) { in get_ephy_nodes()
802 ret = PTR_ERR(gmac->rst_ephy); in get_ephy_nodes()
822 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_power_internal_phy() local
825 if (gmac->internal_phy_powered) { in sun8i_dwmac_power_internal_phy()
831 ret = clk_prepare_enable(gmac->ephy_clk); in sun8i_dwmac_power_internal_phy()
842 ret = reset_control_reset(gmac->rst_ephy); in sun8i_dwmac_power_internal_phy()
845 clk_disable_unprepare(gmac->ephy_clk); in sun8i_dwmac_power_internal_phy()
849 gmac->internal_phy_powered = true; in sun8i_dwmac_power_internal_phy()
854 static void sun8i_dwmac_unpower_internal_phy(struct sunxi_priv_data *gmac) in sun8i_dwmac_unpower_internal_phy() argument
856 if (!gmac->internal_phy_powered) in sun8i_dwmac_unpower_internal_phy()
859 clk_disable_unprepare(gmac->ephy_clk); in sun8i_dwmac_unpower_internal_phy()
860 reset_control_assert(gmac->rst_ephy); in sun8i_dwmac_unpower_internal_phy()
861 gmac->internal_phy_powered = false; in sun8i_dwmac_unpower_internal_phy()
878 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in mdio_mux_syscon_switch_fn() local
883 regmap_field_read(gmac->regmap_field, ®); in mdio_mux_syscon_switch_fn()
888 gmac->use_internal_phy = true; in mdio_mux_syscon_switch_fn()
893 gmac->use_internal_phy = false; in mdio_mux_syscon_switch_fn()
900 regmap_field_write(gmac->regmap_field, val); in mdio_mux_syscon_switch_fn()
901 if (gmac->use_internal_phy) { in mdio_mux_syscon_switch_fn()
906 sun8i_dwmac_unpower_internal_phy(gmac); in mdio_mux_syscon_switch_fn()
920 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_register_mdio_mux() local
927 &gmac->mux_handle, priv, priv->mii); in sun8i_dwmac_register_mdio_mux()
935 struct sunxi_priv_data *gmac = plat->bsp_priv; in sun8i_dwmac_set_syscon() local
940 ret = regmap_field_read(gmac->regmap_field, &val); in sun8i_dwmac_set_syscon()
946 reg = gmac->variant->default_syscon_value; in sun8i_dwmac_set_syscon()
952 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_set_syscon()
984 if (val <= gmac->variant->tx_delay_max) { in sun8i_dwmac_set_syscon()
985 reg &= ~(gmac->variant->tx_delay_max << in sun8i_dwmac_set_syscon()
1002 if (val <= gmac->variant->rx_delay_max) { in sun8i_dwmac_set_syscon()
1003 reg &= ~(gmac->variant->rx_delay_max << in sun8i_dwmac_set_syscon()
1015 if (gmac->variant->support_rmii) in sun8i_dwmac_set_syscon()
1037 regmap_field_write(gmac->regmap_field, reg); in sun8i_dwmac_set_syscon()
1042 static void sun8i_dwmac_unset_syscon(struct sunxi_priv_data *gmac) in sun8i_dwmac_unset_syscon() argument
1044 u32 reg = gmac->variant->default_syscon_value; in sun8i_dwmac_unset_syscon()
1046 regmap_field_write(gmac->regmap_field, reg); in sun8i_dwmac_unset_syscon()
1051 struct sunxi_priv_data *gmac = priv; in sun8i_dwmac_exit() local
1053 if (gmac->variant->soc_has_internal_phy) in sun8i_dwmac_exit()
1054 sun8i_dwmac_unpower_internal_phy(gmac); in sun8i_dwmac_exit()
1056 if (gmac->regulator) in sun8i_dwmac_exit()
1057 regulator_disable(gmac->regulator); in sun8i_dwmac_exit()
1158 struct sunxi_priv_data *gmac; in sun8i_dwmac_probe() local
1170 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); in sun8i_dwmac_probe()
1171 if (!gmac) in sun8i_dwmac_probe()
1174 gmac->variant = of_device_get_match_data(&pdev->dev); in sun8i_dwmac_probe()
1175 if (!gmac->variant) { in sun8i_dwmac_probe()
1181 gmac->regulator = devm_regulator_get_optional(dev, "phy"); in sun8i_dwmac_probe()
1182 if (IS_ERR(gmac->regulator)) { in sun8i_dwmac_probe()
1183 if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) in sun8i_dwmac_probe()
1186 gmac->regulator = NULL; in sun8i_dwmac_probe()
1189 /* The "GMAC clock control" register might be located in the in sun8i_dwmac_probe()
1216 gmac->regmap_field = devm_regmap_field_alloc(dev, regmap, in sun8i_dwmac_probe()
1217 *gmac->variant->syscon_field); in sun8i_dwmac_probe()
1218 if (IS_ERR(gmac->regmap_field)) { in sun8i_dwmac_probe()
1219 ret = PTR_ERR(gmac->regmap_field); in sun8i_dwmac_probe()
1239 plat_dat->bsp_priv = gmac; in sun8i_dwmac_probe()
1270 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_probe()
1290 reset_control_put(gmac->rst_ephy); in sun8i_dwmac_probe()
1291 clk_put(gmac->ephy_clk); in sun8i_dwmac_probe()
1296 sun8i_dwmac_exit(pdev, gmac); in sun8i_dwmac_probe()
1298 sun8i_dwmac_unset_syscon(gmac); in sun8i_dwmac_probe()
1309 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_remove() local
1311 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_remove()
1312 mdio_mux_uninit(gmac->mux_handle); in sun8i_dwmac_remove()
1313 sun8i_dwmac_unpower_internal_phy(gmac); in sun8i_dwmac_remove()
1314 reset_control_put(gmac->rst_ephy); in sun8i_dwmac_remove()
1315 clk_put(gmac->ephy_clk); in sun8i_dwmac_remove()
1319 sun8i_dwmac_unset_syscon(gmac); in sun8i_dwmac_remove()
1326 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_shutdown() local
1328 sun8i_dwmac_exit(pdev, gmac); in sun8i_dwmac_shutdown()
1338 { .compatible = "allwinner,sun8i-r40-gmac",