Lines Matching refs:bsp_priv

39 	void (*set_to_rgmii)(struct rk_priv_data *bsp_priv,
41 void (*set_to_rmii)(struct rk_priv_data *bsp_priv);
42 void (*set_rgmii_speed)(struct rk_priv_data *bsp_priv, int speed);
43 void (*set_rmii_speed)(struct rk_priv_data *bsp_priv, int speed);
44 void (*integrated_phy_powerup)(struct rk_priv_data *bsp_priv);
95 static void px30_set_to_rmii(struct rk_priv_data *bsp_priv) in px30_set_to_rmii() argument
97 struct device *dev = &bsp_priv->pdev->dev; in px30_set_to_rmii()
99 if (IS_ERR(bsp_priv->grf)) { in px30_set_to_rmii()
104 regmap_write(bsp_priv->grf, PX30_GRF_GMAC_CON1, in px30_set_to_rmii()
108 static void px30_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in px30_set_rmii_speed() argument
110 struct device *dev = &bsp_priv->pdev->dev; in px30_set_rmii_speed()
113 if (IS_ERR(bsp_priv->clk_mac_speed)) { in px30_set_rmii_speed()
119 regmap_write(bsp_priv->grf, PX30_GRF_GMAC_CON1, in px30_set_rmii_speed()
122 ret = clk_set_rate(bsp_priv->clk_mac_speed, 2500000); in px30_set_rmii_speed()
127 regmap_write(bsp_priv->grf, PX30_GRF_GMAC_CON1, in px30_set_rmii_speed()
130 ret = clk_set_rate(bsp_priv->clk_mac_speed, 25000000); in px30_set_rmii_speed()
173 static void rk3128_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3128_set_to_rgmii() argument
176 struct device *dev = &bsp_priv->pdev->dev; in rk3128_set_to_rgmii()
178 if (IS_ERR(bsp_priv->grf)) { in rk3128_set_to_rgmii()
183 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_to_rgmii()
186 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON0, in rk3128_set_to_rgmii()
192 static void rk3128_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3128_set_to_rmii() argument
194 struct device *dev = &bsp_priv->pdev->dev; in rk3128_set_to_rmii()
196 if (IS_ERR(bsp_priv->grf)) { in rk3128_set_to_rmii()
201 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_to_rmii()
205 static void rk3128_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3128_set_rgmii_speed() argument
207 struct device *dev = &bsp_priv->pdev->dev; in rk3128_set_rgmii_speed()
209 if (IS_ERR(bsp_priv->grf)) { in rk3128_set_rgmii_speed()
215 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_rgmii_speed()
218 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_rgmii_speed()
221 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_rgmii_speed()
227 static void rk3128_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3128_set_rmii_speed() argument
229 struct device *dev = &bsp_priv->pdev->dev; in rk3128_set_rmii_speed()
231 if (IS_ERR(bsp_priv->grf)) { in rk3128_set_rmii_speed()
237 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_rmii_speed()
241 regmap_write(bsp_priv->grf, RK3128_GRF_MAC_CON1, in rk3128_set_rmii_speed()
289 static void rk3228_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3228_set_to_rgmii() argument
292 struct device *dev = &bsp_priv->pdev->dev; in rk3228_set_to_rgmii()
294 if (IS_ERR(bsp_priv->grf)) { in rk3228_set_to_rgmii()
299 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_to_rgmii()
304 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON0, in rk3228_set_to_rgmii()
309 static void rk3228_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3228_set_to_rmii() argument
311 struct device *dev = &bsp_priv->pdev->dev; in rk3228_set_to_rmii()
313 if (IS_ERR(bsp_priv->grf)) { in rk3228_set_to_rmii()
318 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_to_rmii()
323 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, GRF_BIT(11)); in rk3228_set_to_rmii()
326 static void rk3228_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3228_set_rgmii_speed() argument
328 struct device *dev = &bsp_priv->pdev->dev; in rk3228_set_rgmii_speed()
330 if (IS_ERR(bsp_priv->grf)) { in rk3228_set_rgmii_speed()
336 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_rgmii_speed()
339 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_rgmii_speed()
342 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_rgmii_speed()
348 static void rk3228_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3228_set_rmii_speed() argument
350 struct device *dev = &bsp_priv->pdev->dev; in rk3228_set_rmii_speed()
352 if (IS_ERR(bsp_priv->grf)) { in rk3228_set_rmii_speed()
358 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_rmii_speed()
362 regmap_write(bsp_priv->grf, RK3228_GRF_MAC_CON1, in rk3228_set_rmii_speed()
411 static void rk3288_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3288_set_to_rgmii() argument
414 struct device *dev = &bsp_priv->pdev->dev; in rk3288_set_to_rgmii()
416 if (IS_ERR(bsp_priv->grf)) { in rk3288_set_to_rgmii()
421 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_to_rgmii()
424 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON3, in rk3288_set_to_rgmii()
430 static void rk3288_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3288_set_to_rmii() argument
432 struct device *dev = &bsp_priv->pdev->dev; in rk3288_set_to_rmii()
434 if (IS_ERR(bsp_priv->grf)) { in rk3288_set_to_rmii()
439 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_to_rmii()
443 static void rk3288_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3288_set_rgmii_speed() argument
445 struct device *dev = &bsp_priv->pdev->dev; in rk3288_set_rgmii_speed()
447 if (IS_ERR(bsp_priv->grf)) { in rk3288_set_rgmii_speed()
453 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_rgmii_speed()
456 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_rgmii_speed()
459 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_rgmii_speed()
465 static void rk3288_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3288_set_rmii_speed() argument
467 struct device *dev = &bsp_priv->pdev->dev; in rk3288_set_rmii_speed()
469 if (IS_ERR(bsp_priv->grf)) { in rk3288_set_rmii_speed()
475 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_rmii_speed()
479 regmap_write(bsp_priv->grf, RK3288_GRF_SOC_CON1, in rk3288_set_rmii_speed()
527 static void rk3328_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3328_set_to_rgmii() argument
530 struct device *dev = &bsp_priv->pdev->dev; in rk3328_set_to_rgmii()
532 if (IS_ERR(bsp_priv->grf)) { in rk3328_set_to_rgmii()
537 regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1, in rk3328_set_to_rgmii()
543 regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON0, in rk3328_set_to_rgmii()
548 static void rk3328_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3328_set_to_rmii() argument
550 struct device *dev = &bsp_priv->pdev->dev; in rk3328_set_to_rmii()
553 if (IS_ERR(bsp_priv->grf)) { in rk3328_set_to_rmii()
558 reg = bsp_priv->integrated_phy ? RK3328_GRF_MAC_CON2 : in rk3328_set_to_rmii()
561 regmap_write(bsp_priv->grf, reg, in rk3328_set_to_rmii()
566 static void rk3328_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3328_set_rgmii_speed() argument
568 struct device *dev = &bsp_priv->pdev->dev; in rk3328_set_rgmii_speed()
570 if (IS_ERR(bsp_priv->grf)) { in rk3328_set_rgmii_speed()
576 regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1, in rk3328_set_rgmii_speed()
579 regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1, in rk3328_set_rgmii_speed()
582 regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1, in rk3328_set_rgmii_speed()
588 static void rk3328_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3328_set_rmii_speed() argument
590 struct device *dev = &bsp_priv->pdev->dev; in rk3328_set_rmii_speed()
593 if (IS_ERR(bsp_priv->grf)) { in rk3328_set_rmii_speed()
598 reg = bsp_priv->integrated_phy ? RK3328_GRF_MAC_CON2 : in rk3328_set_rmii_speed()
602 regmap_write(bsp_priv->grf, reg, in rk3328_set_rmii_speed()
606 regmap_write(bsp_priv->grf, reg, in rk3328_set_rmii_speed()
655 static void rk3366_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3366_set_to_rgmii() argument
658 struct device *dev = &bsp_priv->pdev->dev; in rk3366_set_to_rgmii()
660 if (IS_ERR(bsp_priv->grf)) { in rk3366_set_to_rgmii()
665 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_to_rgmii()
668 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON7, in rk3366_set_to_rgmii()
674 static void rk3366_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3366_set_to_rmii() argument
676 struct device *dev = &bsp_priv->pdev->dev; in rk3366_set_to_rmii()
678 if (IS_ERR(bsp_priv->grf)) { in rk3366_set_to_rmii()
683 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_to_rmii()
687 static void rk3366_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3366_set_rgmii_speed() argument
689 struct device *dev = &bsp_priv->pdev->dev; in rk3366_set_rgmii_speed()
691 if (IS_ERR(bsp_priv->grf)) { in rk3366_set_rgmii_speed()
697 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_rgmii_speed()
700 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_rgmii_speed()
703 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_rgmii_speed()
709 static void rk3366_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3366_set_rmii_speed() argument
711 struct device *dev = &bsp_priv->pdev->dev; in rk3366_set_rmii_speed()
713 if (IS_ERR(bsp_priv->grf)) { in rk3366_set_rmii_speed()
719 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_rmii_speed()
723 regmap_write(bsp_priv->grf, RK3366_GRF_SOC_CON6, in rk3366_set_rmii_speed()
766 static void rk3368_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3368_set_to_rgmii() argument
769 struct device *dev = &bsp_priv->pdev->dev; in rk3368_set_to_rgmii()
771 if (IS_ERR(bsp_priv->grf)) { in rk3368_set_to_rgmii()
776 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_to_rgmii()
779 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON16, in rk3368_set_to_rgmii()
785 static void rk3368_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3368_set_to_rmii() argument
787 struct device *dev = &bsp_priv->pdev->dev; in rk3368_set_to_rmii()
789 if (IS_ERR(bsp_priv->grf)) { in rk3368_set_to_rmii()
794 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_to_rmii()
798 static void rk3368_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3368_set_rgmii_speed() argument
800 struct device *dev = &bsp_priv->pdev->dev; in rk3368_set_rgmii_speed()
802 if (IS_ERR(bsp_priv->grf)) { in rk3368_set_rgmii_speed()
808 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_rgmii_speed()
811 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_rgmii_speed()
814 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_rgmii_speed()
820 static void rk3368_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3368_set_rmii_speed() argument
822 struct device *dev = &bsp_priv->pdev->dev; in rk3368_set_rmii_speed()
824 if (IS_ERR(bsp_priv->grf)) { in rk3368_set_rmii_speed()
830 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_rmii_speed()
834 regmap_write(bsp_priv->grf, RK3368_GRF_SOC_CON15, in rk3368_set_rmii_speed()
877 static void rk3399_set_to_rgmii(struct rk_priv_data *bsp_priv, in rk3399_set_to_rgmii() argument
880 struct device *dev = &bsp_priv->pdev->dev; in rk3399_set_to_rgmii()
882 if (IS_ERR(bsp_priv->grf)) { in rk3399_set_to_rgmii()
887 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_to_rgmii()
890 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON6, in rk3399_set_to_rgmii()
896 static void rk3399_set_to_rmii(struct rk_priv_data *bsp_priv) in rk3399_set_to_rmii() argument
898 struct device *dev = &bsp_priv->pdev->dev; in rk3399_set_to_rmii()
900 if (IS_ERR(bsp_priv->grf)) { in rk3399_set_to_rmii()
905 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_to_rmii()
909 static void rk3399_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3399_set_rgmii_speed() argument
911 struct device *dev = &bsp_priv->pdev->dev; in rk3399_set_rgmii_speed()
913 if (IS_ERR(bsp_priv->grf)) { in rk3399_set_rgmii_speed()
919 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_rgmii_speed()
922 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_rgmii_speed()
925 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_rgmii_speed()
931 static void rk3399_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rk3399_set_rmii_speed() argument
933 struct device *dev = &bsp_priv->pdev->dev; in rk3399_set_rmii_speed()
935 if (IS_ERR(bsp_priv->grf)) { in rk3399_set_rmii_speed()
941 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_rmii_speed()
945 regmap_write(bsp_priv->grf, RK3399_GRF_SOC_CON5, in rk3399_set_rmii_speed()
972 static void rv1108_set_to_rmii(struct rk_priv_data *bsp_priv) in rv1108_set_to_rmii() argument
974 struct device *dev = &bsp_priv->pdev->dev; in rv1108_set_to_rmii()
976 if (IS_ERR(bsp_priv->grf)) { in rv1108_set_to_rmii()
981 regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0, in rv1108_set_to_rmii()
985 static void rv1108_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) in rv1108_set_rmii_speed() argument
987 struct device *dev = &bsp_priv->pdev->dev; in rv1108_set_rmii_speed()
989 if (IS_ERR(bsp_priv->grf)) { in rv1108_set_rmii_speed()
995 regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0, in rv1108_set_rmii_speed()
999 regmap_write(bsp_priv->grf, RV1108_GRF_GMAC_CON0, in rv1108_set_rmii_speed()
1058 struct rk_priv_data *bsp_priv = plat->bsp_priv; in rk_gmac_clk_init() local
1059 struct device *dev = &bsp_priv->pdev->dev; in rk_gmac_clk_init()
1062 bsp_priv->clk_enabled = false; in rk_gmac_clk_init()
1064 bsp_priv->mac_clk_rx = devm_clk_get(dev, "mac_clk_rx"); in rk_gmac_clk_init()
1065 if (IS_ERR(bsp_priv->mac_clk_rx)) in rk_gmac_clk_init()
1069 bsp_priv->mac_clk_tx = devm_clk_get(dev, "mac_clk_tx"); in rk_gmac_clk_init()
1070 if (IS_ERR(bsp_priv->mac_clk_tx)) in rk_gmac_clk_init()
1074 bsp_priv->aclk_mac = devm_clk_get(dev, "aclk_mac"); in rk_gmac_clk_init()
1075 if (IS_ERR(bsp_priv->aclk_mac)) in rk_gmac_clk_init()
1079 bsp_priv->pclk_mac = devm_clk_get(dev, "pclk_mac"); in rk_gmac_clk_init()
1080 if (IS_ERR(bsp_priv->pclk_mac)) in rk_gmac_clk_init()
1084 bsp_priv->clk_mac = devm_clk_get(dev, "stmmaceth"); in rk_gmac_clk_init()
1085 if (IS_ERR(bsp_priv->clk_mac)) in rk_gmac_clk_init()
1089 if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) { in rk_gmac_clk_init()
1090 bsp_priv->clk_mac_ref = devm_clk_get(dev, "clk_mac_ref"); in rk_gmac_clk_init()
1091 if (IS_ERR(bsp_priv->clk_mac_ref)) in rk_gmac_clk_init()
1095 if (!bsp_priv->clock_input) { in rk_gmac_clk_init()
1096 bsp_priv->clk_mac_refout = in rk_gmac_clk_init()
1098 if (IS_ERR(bsp_priv->clk_mac_refout)) in rk_gmac_clk_init()
1104 bsp_priv->clk_mac_speed = devm_clk_get(dev, "clk_mac_speed"); in rk_gmac_clk_init()
1105 if (IS_ERR(bsp_priv->clk_mac_speed)) in rk_gmac_clk_init()
1108 if (bsp_priv->clock_input) { in rk_gmac_clk_init()
1111 if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) in rk_gmac_clk_init()
1112 clk_set_rate(bsp_priv->clk_mac, 50000000); in rk_gmac_clk_init()
1115 if (plat->phy_node && bsp_priv->integrated_phy) { in rk_gmac_clk_init()
1116 bsp_priv->clk_phy = of_clk_get(plat->phy_node, 0); in rk_gmac_clk_init()
1117 if (IS_ERR(bsp_priv->clk_phy)) { in rk_gmac_clk_init()
1118 ret = PTR_ERR(bsp_priv->clk_phy); in rk_gmac_clk_init()
1122 clk_set_rate(bsp_priv->clk_phy, 50000000); in rk_gmac_clk_init()
1128 static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable) in gmac_clk_enable() argument
1130 int phy_iface = bsp_priv->phy_iface; in gmac_clk_enable()
1133 if (!bsp_priv->clk_enabled) { in gmac_clk_enable()
1135 if (!IS_ERR(bsp_priv->mac_clk_rx)) in gmac_clk_enable()
1137 bsp_priv->mac_clk_rx); in gmac_clk_enable()
1139 if (!IS_ERR(bsp_priv->clk_mac_ref)) in gmac_clk_enable()
1141 bsp_priv->clk_mac_ref); in gmac_clk_enable()
1143 if (!IS_ERR(bsp_priv->clk_mac_refout)) in gmac_clk_enable()
1145 bsp_priv->clk_mac_refout); in gmac_clk_enable()
1148 if (!IS_ERR(bsp_priv->clk_phy)) in gmac_clk_enable()
1149 clk_prepare_enable(bsp_priv->clk_phy); in gmac_clk_enable()
1151 if (!IS_ERR(bsp_priv->aclk_mac)) in gmac_clk_enable()
1152 clk_prepare_enable(bsp_priv->aclk_mac); in gmac_clk_enable()
1154 if (!IS_ERR(bsp_priv->pclk_mac)) in gmac_clk_enable()
1155 clk_prepare_enable(bsp_priv->pclk_mac); in gmac_clk_enable()
1157 if (!IS_ERR(bsp_priv->mac_clk_tx)) in gmac_clk_enable()
1158 clk_prepare_enable(bsp_priv->mac_clk_tx); in gmac_clk_enable()
1160 if (!IS_ERR(bsp_priv->clk_mac_speed)) in gmac_clk_enable()
1161 clk_prepare_enable(bsp_priv->clk_mac_speed); in gmac_clk_enable()
1168 bsp_priv->clk_enabled = true; in gmac_clk_enable()
1171 if (bsp_priv->clk_enabled) { in gmac_clk_enable()
1173 clk_disable_unprepare(bsp_priv->mac_clk_rx); in gmac_clk_enable()
1175 clk_disable_unprepare(bsp_priv->clk_mac_ref); in gmac_clk_enable()
1177 clk_disable_unprepare(bsp_priv->clk_mac_refout); in gmac_clk_enable()
1180 clk_disable_unprepare(bsp_priv->clk_phy); in gmac_clk_enable()
1182 clk_disable_unprepare(bsp_priv->aclk_mac); in gmac_clk_enable()
1184 clk_disable_unprepare(bsp_priv->pclk_mac); in gmac_clk_enable()
1186 clk_disable_unprepare(bsp_priv->mac_clk_tx); in gmac_clk_enable()
1188 clk_disable_unprepare(bsp_priv->clk_mac_speed); in gmac_clk_enable()
1193 bsp_priv->clk_enabled = false; in gmac_clk_enable()
1200 static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable) in phy_power_on() argument
1202 struct regulator *ldo = bsp_priv->regulator; in phy_power_on()
1204 struct device *dev = &bsp_priv->pdev->dev; in phy_power_on()
1228 struct rk_priv_data *bsp_priv; in rk_gmac_setup() local
1234 bsp_priv = devm_kzalloc(dev, sizeof(*bsp_priv), GFP_KERNEL); in rk_gmac_setup()
1235 if (!bsp_priv) in rk_gmac_setup()
1238 bsp_priv->phy_iface = of_get_phy_mode(dev->of_node); in rk_gmac_setup()
1239 bsp_priv->ops = ops; in rk_gmac_setup()
1241 bsp_priv->regulator = devm_regulator_get_optional(dev, "phy"); in rk_gmac_setup()
1242 if (IS_ERR(bsp_priv->regulator)) { in rk_gmac_setup()
1243 if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) { in rk_gmac_setup()
1248 bsp_priv->regulator = NULL; in rk_gmac_setup()
1254 bsp_priv->clock_input = true; in rk_gmac_setup()
1259 bsp_priv->clock_input = true; in rk_gmac_setup()
1261 bsp_priv->clock_input = false; in rk_gmac_setup()
1266 bsp_priv->tx_delay = 0x30; in rk_gmac_setup()
1269 bsp_priv->tx_delay); in rk_gmac_setup()
1272 bsp_priv->tx_delay = value; in rk_gmac_setup()
1277 bsp_priv->rx_delay = 0x10; in rk_gmac_setup()
1280 bsp_priv->rx_delay); in rk_gmac_setup()
1283 bsp_priv->rx_delay = value; in rk_gmac_setup()
1286 bsp_priv->grf = syscon_regmap_lookup_by_phandle(dev->of_node, in rk_gmac_setup()
1290 bsp_priv->integrated_phy = of_property_read_bool(plat->phy_node, in rk_gmac_setup()
1292 if (bsp_priv->integrated_phy) { in rk_gmac_setup()
1293 bsp_priv->phy_reset = of_reset_control_get(plat->phy_node, NULL); in rk_gmac_setup()
1294 if (IS_ERR(bsp_priv->phy_reset)) { in rk_gmac_setup()
1296 bsp_priv->phy_reset = NULL; in rk_gmac_setup()
1301 bsp_priv->integrated_phy ? "yes" : "no"); in rk_gmac_setup()
1303 bsp_priv->pdev = pdev; in rk_gmac_setup()
1305 return bsp_priv; in rk_gmac_setup()
1308 static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) in rk_gmac_powerup() argument
1311 struct device *dev = &bsp_priv->pdev->dev; in rk_gmac_powerup()
1313 ret = gmac_clk_enable(bsp_priv, true); in rk_gmac_powerup()
1318 switch (bsp_priv->phy_iface) { in rk_gmac_powerup()
1321 bsp_priv->ops->set_to_rgmii(bsp_priv, bsp_priv->tx_delay, in rk_gmac_powerup()
1322 bsp_priv->rx_delay); in rk_gmac_powerup()
1326 bsp_priv->ops->set_to_rgmii(bsp_priv, 0, 0); in rk_gmac_powerup()
1330 bsp_priv->ops->set_to_rgmii(bsp_priv, bsp_priv->tx_delay, 0); in rk_gmac_powerup()
1334 bsp_priv->ops->set_to_rgmii(bsp_priv, 0, bsp_priv->rx_delay); in rk_gmac_powerup()
1338 bsp_priv->ops->set_to_rmii(bsp_priv); in rk_gmac_powerup()
1344 ret = phy_power_on(bsp_priv, true); in rk_gmac_powerup()
1351 if (bsp_priv->integrated_phy) in rk_gmac_powerup()
1352 rk_gmac_integrated_phy_powerup(bsp_priv); in rk_gmac_powerup()
1373 struct rk_priv_data *bsp_priv = priv; in rk_fix_speed() local
1374 struct device *dev = &bsp_priv->pdev->dev; in rk_fix_speed()
1376 switch (bsp_priv->phy_iface) { in rk_fix_speed()
1381 bsp_priv->ops->set_rgmii_speed(bsp_priv, speed); in rk_fix_speed()
1384 bsp_priv->ops->set_rmii_speed(bsp_priv, speed); in rk_fix_speed()
1387 dev_err(dev, "unsupported interface %d", bsp_priv->phy_iface); in rk_fix_speed()
1415 plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data); in rk_gmac_probe()
1416 if (IS_ERR(plat_dat->bsp_priv)) { in rk_gmac_probe()
1417 ret = PTR_ERR(plat_dat->bsp_priv); in rk_gmac_probe()
1425 ret = rk_gmac_powerup(plat_dat->bsp_priv); in rk_gmac_probe()
1436 rk_gmac_powerdown(plat_dat->bsp_priv); in rk_gmac_probe()
1445 struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev); in rk_gmac_remove() local
1448 rk_gmac_powerdown(bsp_priv); in rk_gmac_remove()
1456 struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev); in rk_gmac_suspend() local
1461 rk_gmac_powerdown(bsp_priv); in rk_gmac_suspend()
1462 bsp_priv->suspended = true; in rk_gmac_suspend()
1470 struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev); in rk_gmac_resume() local
1473 if (bsp_priv->suspended) { in rk_gmac_resume()
1474 rk_gmac_powerup(bsp_priv); in rk_gmac_resume()
1475 bsp_priv->suspended = false; in rk_gmac_resume()