Lines Matching refs:gmac
571 struct sunxi_priv_data *gmac = priv; in sun8i_dwmac_init() local
574 if (gmac->regulator) { in sun8i_dwmac_init()
575 ret = regulator_enable(gmac->regulator); in sun8i_dwmac_init()
582 ret = clk_prepare_enable(gmac->tx_clk); in sun8i_dwmac_init()
588 if (gmac->use_internal_phy) { in sun8i_dwmac_init()
597 clk_disable_unprepare(gmac->tx_clk); in sun8i_dwmac_init()
599 if (gmac->regulator) in sun8i_dwmac_init()
600 regulator_disable(gmac->regulator); in sun8i_dwmac_init()
767 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in get_ephy_nodes() local
788 gmac->ephy_clk = of_clk_get(iphynode, 0); in get_ephy_nodes()
789 if (IS_ERR(gmac->ephy_clk)) in get_ephy_nodes()
791 gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); in get_ephy_nodes()
792 if (IS_ERR(gmac->rst_ephy)) { in get_ephy_nodes()
793 ret = PTR_ERR(gmac->rst_ephy); in get_ephy_nodes()
813 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_power_internal_phy() local
816 if (gmac->internal_phy_powered) { in sun8i_dwmac_power_internal_phy()
822 ret = clk_prepare_enable(gmac->ephy_clk); in sun8i_dwmac_power_internal_phy()
833 ret = reset_control_reset(gmac->rst_ephy); in sun8i_dwmac_power_internal_phy()
836 clk_disable_unprepare(gmac->ephy_clk); in sun8i_dwmac_power_internal_phy()
840 gmac->internal_phy_powered = true; in sun8i_dwmac_power_internal_phy()
845 static void sun8i_dwmac_unpower_internal_phy(struct sunxi_priv_data *gmac) in sun8i_dwmac_unpower_internal_phy() argument
847 if (!gmac->internal_phy_powered) in sun8i_dwmac_unpower_internal_phy()
850 clk_disable_unprepare(gmac->ephy_clk); in sun8i_dwmac_unpower_internal_phy()
851 reset_control_assert(gmac->rst_ephy); in sun8i_dwmac_unpower_internal_phy()
852 gmac->internal_phy_powered = false; in sun8i_dwmac_unpower_internal_phy()
869 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in mdio_mux_syscon_switch_fn() local
874 regmap_field_read(gmac->regmap_field, ®); in mdio_mux_syscon_switch_fn()
879 gmac->use_internal_phy = true; in mdio_mux_syscon_switch_fn()
884 gmac->use_internal_phy = false; in mdio_mux_syscon_switch_fn()
891 regmap_field_write(gmac->regmap_field, val); in mdio_mux_syscon_switch_fn()
892 if (gmac->use_internal_phy) { in mdio_mux_syscon_switch_fn()
897 sun8i_dwmac_unpower_internal_phy(gmac); in mdio_mux_syscon_switch_fn()
911 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_register_mdio_mux() local
918 &gmac->mux_handle, priv, priv->mii); in sun8i_dwmac_register_mdio_mux()
926 struct sunxi_priv_data *gmac = plat->bsp_priv; in sun8i_dwmac_set_syscon() local
931 ret = regmap_field_read(gmac->regmap_field, &val); in sun8i_dwmac_set_syscon()
937 reg = gmac->variant->default_syscon_value; in sun8i_dwmac_set_syscon()
943 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_set_syscon()
975 if (val <= gmac->variant->tx_delay_max) { in sun8i_dwmac_set_syscon()
976 reg &= ~(gmac->variant->tx_delay_max << in sun8i_dwmac_set_syscon()
993 if (val <= gmac->variant->rx_delay_max) { in sun8i_dwmac_set_syscon()
994 reg &= ~(gmac->variant->rx_delay_max << in sun8i_dwmac_set_syscon()
1006 if (gmac->variant->support_rmii) in sun8i_dwmac_set_syscon()
1028 regmap_field_write(gmac->regmap_field, reg); in sun8i_dwmac_set_syscon()
1033 static void sun8i_dwmac_unset_syscon(struct sunxi_priv_data *gmac) in sun8i_dwmac_unset_syscon() argument
1035 u32 reg = gmac->variant->default_syscon_value; in sun8i_dwmac_unset_syscon()
1037 regmap_field_write(gmac->regmap_field, reg); in sun8i_dwmac_unset_syscon()
1042 struct sunxi_priv_data *gmac = priv; in sun8i_dwmac_exit() local
1044 if (gmac->variant->soc_has_internal_phy) in sun8i_dwmac_exit()
1045 sun8i_dwmac_unpower_internal_phy(gmac); in sun8i_dwmac_exit()
1047 clk_disable_unprepare(gmac->tx_clk); in sun8i_dwmac_exit()
1049 if (gmac->regulator) in sun8i_dwmac_exit()
1050 regulator_disable(gmac->regulator); in sun8i_dwmac_exit()
1149 struct sunxi_priv_data *gmac; in sun8i_dwmac_probe() local
1161 gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL); in sun8i_dwmac_probe()
1162 if (!gmac) in sun8i_dwmac_probe()
1165 gmac->variant = of_device_get_match_data(&pdev->dev); in sun8i_dwmac_probe()
1166 if (!gmac->variant) { in sun8i_dwmac_probe()
1171 gmac->tx_clk = devm_clk_get(dev, "stmmaceth"); in sun8i_dwmac_probe()
1172 if (IS_ERR(gmac->tx_clk)) { in sun8i_dwmac_probe()
1174 return PTR_ERR(gmac->tx_clk); in sun8i_dwmac_probe()
1178 gmac->regulator = devm_regulator_get_optional(dev, "phy"); in sun8i_dwmac_probe()
1179 if (IS_ERR(gmac->regulator)) { in sun8i_dwmac_probe()
1180 if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER) in sun8i_dwmac_probe()
1183 gmac->regulator = NULL; in sun8i_dwmac_probe()
1213 gmac->regmap_field = devm_regmap_field_alloc(dev, regmap, in sun8i_dwmac_probe()
1214 *gmac->variant->syscon_field); in sun8i_dwmac_probe()
1215 if (IS_ERR(gmac->regmap_field)) { in sun8i_dwmac_probe()
1216 ret = PTR_ERR(gmac->regmap_field); in sun8i_dwmac_probe()
1236 plat_dat->bsp_priv = gmac; in sun8i_dwmac_probe()
1261 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_probe()
1279 reset_control_put(gmac->rst_ephy); in sun8i_dwmac_probe()
1280 clk_put(gmac->ephy_clk); in sun8i_dwmac_probe()
1284 sun8i_dwmac_exit(pdev, gmac); in sun8i_dwmac_probe()
1286 sun8i_dwmac_unset_syscon(gmac); in sun8i_dwmac_probe()
1297 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_remove() local
1299 if (gmac->variant->soc_has_internal_phy) { in sun8i_dwmac_remove()
1300 mdio_mux_uninit(gmac->mux_handle); in sun8i_dwmac_remove()
1301 sun8i_dwmac_unpower_internal_phy(gmac); in sun8i_dwmac_remove()
1302 reset_control_put(gmac->rst_ephy); in sun8i_dwmac_remove()
1303 clk_put(gmac->ephy_clk); in sun8i_dwmac_remove()
1307 sun8i_dwmac_unset_syscon(gmac); in sun8i_dwmac_remove()
1316 struct sunxi_priv_data *gmac = priv->plat->bsp_priv; in sun8i_dwmac_shutdown() local
1318 sun8i_dwmac_exit(pdev, gmac); in sun8i_dwmac_shutdown()