Lines Matching refs:dwmac
162 struct sti_dwmac *dwmac = priv; in stih4xx_fix_retime_src() local
163 u32 src = dwmac->tx_retime_src; in stih4xx_fix_retime_src()
164 u32 reg = dwmac->ctrl_reg; in stih4xx_fix_retime_src()
167 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { in stih4xx_fix_retime_src()
169 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { in stih4xx_fix_retime_src()
170 if (dwmac->ext_phyclk) { in stih4xx_fix_retime_src()
176 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { in stih4xx_fix_retime_src()
191 clk_set_rate(dwmac->clk, freq); in stih4xx_fix_retime_src()
193 regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, in stih4xx_fix_retime_src()
199 struct sti_dwmac *dwmac = priv; in stid127_fix_retime_src() local
200 u32 reg = dwmac->ctrl_reg; in stid127_fix_retime_src()
204 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { in stid127_fix_retime_src()
206 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { in stid127_fix_retime_src()
207 if (!dwmac->ext_phyclk) { in stid127_fix_retime_src()
211 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { in stid127_fix_retime_src()
222 clk_set_rate(dwmac->clk, freq); in stid127_fix_retime_src()
224 regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val); in stid127_fix_retime_src()
227 static int sti_dwmac_set_mode(struct sti_dwmac *dwmac) in sti_dwmac_set_mode() argument
229 struct regmap *regmap = dwmac->regmap; in sti_dwmac_set_mode()
230 int iface = dwmac->interface; in sti_dwmac_set_mode()
231 u32 reg = dwmac->ctrl_reg; in sti_dwmac_set_mode()
234 if (dwmac->gmac_en) in sti_dwmac_set_mode()
242 dwmac->fix_retime_src(dwmac, dwmac->speed); in sti_dwmac_set_mode()
247 static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, in sti_dwmac_parse_data() argument
257 dwmac->clk_sel_reg = -ENXIO; in sti_dwmac_parse_data()
260 dwmac->clk_sel_reg = res->start; in sti_dwmac_parse_data()
266 err = of_property_read_u32_index(np, "st,syscon", 1, &dwmac->ctrl_reg); in sti_dwmac_parse_data()
272 err = of_get_phy_mode(np, &dwmac->interface); in sti_dwmac_parse_data()
278 dwmac->regmap = regmap; in sti_dwmac_parse_data()
279 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); in sti_dwmac_parse_data()
280 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in sti_dwmac_parse_data()
281 dwmac->tx_retime_src = TX_RETIME_SRC_NA; in sti_dwmac_parse_data()
282 dwmac->speed = SPEED_100; in sti_dwmac_parse_data()
284 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { in sti_dwmac_parse_data()
287 dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; in sti_dwmac_parse_data()
294 dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; in sti_dwmac_parse_data()
296 dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; in sti_dwmac_parse_data()
298 dwmac->speed = SPEED_1000; in sti_dwmac_parse_data()
301 dwmac->clk = devm_clk_get(dev, "sti-ethclk"); in sti_dwmac_parse_data()
302 if (IS_ERR(dwmac->clk)) { in sti_dwmac_parse_data()
304 dwmac->clk = NULL; in sti_dwmac_parse_data()
315 struct sti_dwmac *dwmac; in sti_dwmac_probe() local
332 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in sti_dwmac_probe()
333 if (!dwmac) { in sti_dwmac_probe()
338 ret = sti_dwmac_parse_data(dwmac, pdev); in sti_dwmac_probe()
344 dwmac->fix_retime_src = data->fix_retime_src; in sti_dwmac_probe()
346 plat_dat->bsp_priv = dwmac; in sti_dwmac_probe()
349 ret = clk_prepare_enable(dwmac->clk); in sti_dwmac_probe()
353 ret = sti_dwmac_set_mode(dwmac); in sti_dwmac_probe()
364 clk_disable_unprepare(dwmac->clk); in sti_dwmac_probe()
373 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); in sti_dwmac_remove() local
376 clk_disable_unprepare(dwmac->clk); in sti_dwmac_remove()
384 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_suspend() local
387 clk_disable_unprepare(dwmac->clk); in sti_dwmac_suspend()
394 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_resume() local
396 clk_prepare_enable(dwmac->clk); in sti_dwmac_resume()
397 sti_dwmac_set_mode(dwmac); in sti_dwmac_resume()