Lines Matching full:dwmac
3 * dwmac-sti.c - STMicroelectronics DWMAC Specific Glue layer
137 struct sti_dwmac *dwmac = priv; in stih4xx_fix_retime_src() local
138 u32 src = dwmac->tx_retime_src; in stih4xx_fix_retime_src()
139 u32 reg = dwmac->ctrl_reg; in stih4xx_fix_retime_src()
142 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { in stih4xx_fix_retime_src()
144 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { in stih4xx_fix_retime_src()
145 if (dwmac->ext_phyclk) { in stih4xx_fix_retime_src()
151 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { in stih4xx_fix_retime_src()
161 clk_set_rate(dwmac->clk, freq); in stih4xx_fix_retime_src()
163 regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, in stih4xx_fix_retime_src()
167 static int sti_dwmac_set_mode(struct sti_dwmac *dwmac) in sti_dwmac_set_mode() argument
169 struct regmap *regmap = dwmac->regmap; in sti_dwmac_set_mode()
170 int iface = dwmac->interface; in sti_dwmac_set_mode()
171 u32 reg = dwmac->ctrl_reg; in sti_dwmac_set_mode()
174 if (dwmac->gmac_en) in sti_dwmac_set_mode()
182 dwmac->fix_retime_src(dwmac, dwmac->speed, 0); in sti_dwmac_set_mode()
187 static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, in sti_dwmac_parse_data() argument
197 dwmac->clk_sel_reg = -ENXIO; in sti_dwmac_parse_data()
200 dwmac->clk_sel_reg = res->start; in sti_dwmac_parse_data()
203 1, &dwmac->ctrl_reg); in sti_dwmac_parse_data()
207 err = of_get_phy_mode(np, &dwmac->interface); in sti_dwmac_parse_data()
213 dwmac->regmap = regmap; in sti_dwmac_parse_data()
214 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); in sti_dwmac_parse_data()
215 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in sti_dwmac_parse_data()
216 dwmac->tx_retime_src = TX_RETIME_SRC_NA; in sti_dwmac_parse_data()
217 dwmac->speed = SPEED_100; in sti_dwmac_parse_data()
219 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { in sti_dwmac_parse_data()
222 dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; in sti_dwmac_parse_data()
229 dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; in sti_dwmac_parse_data()
231 dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; in sti_dwmac_parse_data()
233 dwmac->speed = SPEED_1000; in sti_dwmac_parse_data()
236 dwmac->clk = devm_clk_get(dev, "sti-ethclk"); in sti_dwmac_parse_data()
237 if (IS_ERR(dwmac->clk)) { in sti_dwmac_parse_data()
239 dwmac->clk = NULL; in sti_dwmac_parse_data()
250 struct sti_dwmac *dwmac; in sti_dwmac_probe() local
267 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in sti_dwmac_probe()
268 if (!dwmac) in sti_dwmac_probe()
271 ret = sti_dwmac_parse_data(dwmac, pdev); in sti_dwmac_probe()
277 dwmac->fix_retime_src = data->fix_retime_src; in sti_dwmac_probe()
279 plat_dat->bsp_priv = dwmac; in sti_dwmac_probe()
282 ret = clk_prepare_enable(dwmac->clk); in sti_dwmac_probe()
286 ret = sti_dwmac_set_mode(dwmac); in sti_dwmac_probe()
297 clk_disable_unprepare(dwmac->clk); in sti_dwmac_probe()
304 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); in sti_dwmac_remove() local
308 clk_disable_unprepare(dwmac->clk); in sti_dwmac_remove()
313 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_suspend() local
316 clk_disable_unprepare(dwmac->clk); in sti_dwmac_suspend()
323 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_resume() local
325 clk_prepare_enable(dwmac->clk); in sti_dwmac_resume()
326 sti_dwmac_set_mode(dwmac); in sti_dwmac_resume()
339 { .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
348 .name = "sti-dwmac",
356 MODULE_DESCRIPTION("STMicroelectronics DWMAC Specific Glue layer");