Lines Matching refs:dwmac

102 	int (*clk_prepare)(struct stm32_dwmac *dwmac, bool prepare);
103 int (*suspend)(struct stm32_dwmac *dwmac);
104 void (*resume)(struct stm32_dwmac *dwmac);
105 int (*parse_data)(struct stm32_dwmac *dwmac,
112 struct stm32_dwmac *dwmac = plat_dat->bsp_priv; in stm32_dwmac_init() local
115 if (dwmac->ops->set_mode) { in stm32_dwmac_init()
116 ret = dwmac->ops->set_mode(plat_dat); in stm32_dwmac_init()
121 ret = clk_prepare_enable(dwmac->clk_tx); in stm32_dwmac_init()
125 if (!dwmac->dev->power.is_suspended) { in stm32_dwmac_init()
126 ret = clk_prepare_enable(dwmac->clk_rx); in stm32_dwmac_init()
128 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_init()
133 if (dwmac->ops->clk_prepare) { in stm32_dwmac_init()
134 ret = dwmac->ops->clk_prepare(dwmac, true); in stm32_dwmac_init()
136 clk_disable_unprepare(dwmac->clk_rx); in stm32_dwmac_init()
137 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_init()
144 static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare) in stm32mp1_clk_prepare() argument
149 ret = clk_prepare_enable(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
152 if (dwmac->enable_eth_ck) { in stm32mp1_clk_prepare()
153 ret = clk_prepare_enable(dwmac->clk_eth_ck); in stm32mp1_clk_prepare()
155 clk_disable_unprepare(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
160 clk_disable_unprepare(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
161 if (dwmac->enable_eth_ck) in stm32mp1_clk_prepare()
162 clk_disable_unprepare(dwmac->clk_eth_ck); in stm32mp1_clk_prepare()
169 struct stm32_dwmac *dwmac = plat_dat->bsp_priv; in stm32mp1_set_mode() local
170 u32 reg = dwmac->mode_reg, clk_rate; in stm32mp1_set_mode()
173 clk_rate = clk_get_rate(dwmac->clk_eth_ck); in stm32mp1_set_mode()
174 dwmac->enable_eth_ck = false; in stm32mp1_set_mode()
177 if (clk_rate == ETH_CK_F_25M && dwmac->ext_phyclk) in stm32mp1_set_mode()
178 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
185 (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
186 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
194 (dwmac->eth_ref_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
195 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
206 (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
207 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
220 regmap_write(dwmac->regmap, reg + SYSCFG_PMCCLRR_OFFSET, in stm32mp1_set_mode()
221 dwmac->ops->syscfg_eth_mask); in stm32mp1_set_mode()
224 return regmap_update_bits(dwmac->regmap, reg, in stm32mp1_set_mode()
225 dwmac->ops->syscfg_eth_mask, val); in stm32mp1_set_mode()
230 struct stm32_dwmac *dwmac = plat_dat->bsp_priv; in stm32mcu_set_mode() local
231 u32 reg = dwmac->mode_reg; in stm32mcu_set_mode()
250 return regmap_update_bits(dwmac->regmap, reg, in stm32mcu_set_mode()
251 dwmac->ops->syscfg_eth_mask, val << 23); in stm32mcu_set_mode()
254 static void stm32_dwmac_clk_disable(struct stm32_dwmac *dwmac) in stm32_dwmac_clk_disable() argument
256 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_clk_disable()
257 clk_disable_unprepare(dwmac->clk_rx); in stm32_dwmac_clk_disable()
259 if (dwmac->ops->clk_prepare) in stm32_dwmac_clk_disable()
260 dwmac->ops->clk_prepare(dwmac, false); in stm32_dwmac_clk_disable()
263 static int stm32_dwmac_parse_data(struct stm32_dwmac *dwmac, in stm32_dwmac_parse_data() argument
270 dwmac->clk_tx = devm_clk_get(dev, "mac-clk-tx"); in stm32_dwmac_parse_data()
271 if (IS_ERR(dwmac->clk_tx)) { in stm32_dwmac_parse_data()
273 return PTR_ERR(dwmac->clk_tx); in stm32_dwmac_parse_data()
276 dwmac->clk_rx = devm_clk_get(dev, "mac-clk-rx"); in stm32_dwmac_parse_data()
277 if (IS_ERR(dwmac->clk_rx)) { in stm32_dwmac_parse_data()
279 return PTR_ERR(dwmac->clk_rx); in stm32_dwmac_parse_data()
282 if (dwmac->ops->parse_data) { in stm32_dwmac_parse_data()
283 err = dwmac->ops->parse_data(dwmac, dev); in stm32_dwmac_parse_data()
289 dwmac->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon"); in stm32_dwmac_parse_data()
290 if (IS_ERR(dwmac->regmap)) in stm32_dwmac_parse_data()
291 return PTR_ERR(dwmac->regmap); in stm32_dwmac_parse_data()
293 err = of_property_read_u32_index(np, "st,syscon", 1, &dwmac->mode_reg); in stm32_dwmac_parse_data()
300 static int stm32mp1_parse_data(struct stm32_dwmac *dwmac, in stm32mp1_parse_data() argument
308 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in stm32mp1_parse_data()
311 dwmac->eth_clk_sel_reg = of_property_read_bool(np, "st,eth-clk-sel"); in stm32mp1_parse_data()
314 dwmac->eth_ref_clk_sel_reg = in stm32mp1_parse_data()
318 dwmac->clk_eth_ck = devm_clk_get(dev, "eth-ck"); in stm32mp1_parse_data()
319 if (IS_ERR(dwmac->clk_eth_ck)) { in stm32mp1_parse_data()
321 dwmac->clk_eth_ck = NULL; in stm32mp1_parse_data()
325 dwmac->clk_ethstp = devm_clk_get(dev, "ethstp"); in stm32mp1_parse_data()
326 if (IS_ERR(dwmac->clk_ethstp)) { in stm32mp1_parse_data()
329 return PTR_ERR(dwmac->clk_ethstp); in stm32mp1_parse_data()
333 dwmac->syscfg_clk = devm_clk_get(dev, "syscfg-clk"); in stm32mp1_parse_data()
334 if (IS_ERR(dwmac->syscfg_clk)) in stm32mp1_parse_data()
335 dwmac->syscfg_clk = NULL; in stm32mp1_parse_data()
340 dwmac->irq_pwr_wakeup = platform_get_irq_byname_optional(pdev, in stm32mp1_parse_data()
342 if (dwmac->irq_pwr_wakeup == -EPROBE_DEFER) in stm32mp1_parse_data()
345 if (!dwmac->clk_eth_ck && dwmac->irq_pwr_wakeup >= 0) { in stm32mp1_parse_data()
352 dwmac->irq_pwr_wakeup); in stm32mp1_parse_data()
366 struct stm32_dwmac *dwmac; in stm32_dwmac_probe() local
378 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in stm32_dwmac_probe()
379 if (!dwmac) { in stm32_dwmac_probe()
391 dwmac->ops = data; in stm32_dwmac_probe()
392 dwmac->dev = &pdev->dev; in stm32_dwmac_probe()
394 ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); in stm32_dwmac_probe()
400 plat_dat->bsp_priv = dwmac; in stm32_dwmac_probe()
413 stm32_dwmac_clk_disable(dwmac); in stm32_dwmac_probe()
425 struct stm32_dwmac *dwmac = priv->plat->bsp_priv; in stm32_dwmac_remove() local
429 if (dwmac->irq_pwr_wakeup >= 0) { in stm32_dwmac_remove()
437 static int stm32mp1_suspend(struct stm32_dwmac *dwmac) in stm32mp1_suspend() argument
441 ret = clk_prepare_enable(dwmac->clk_ethstp); in stm32mp1_suspend()
445 clk_disable_unprepare(dwmac->clk_tx); in stm32mp1_suspend()
446 clk_disable_unprepare(dwmac->syscfg_clk); in stm32mp1_suspend()
447 if (dwmac->enable_eth_ck) in stm32mp1_suspend()
448 clk_disable_unprepare(dwmac->clk_eth_ck); in stm32mp1_suspend()
453 static void stm32mp1_resume(struct stm32_dwmac *dwmac) in stm32mp1_resume() argument
455 clk_disable_unprepare(dwmac->clk_ethstp); in stm32mp1_resume()
458 static int stm32mcu_suspend(struct stm32_dwmac *dwmac) in stm32mcu_suspend() argument
460 clk_disable_unprepare(dwmac->clk_tx); in stm32mcu_suspend()
461 clk_disable_unprepare(dwmac->clk_rx); in stm32mcu_suspend()
471 struct stm32_dwmac *dwmac = priv->plat->bsp_priv; in stm32_dwmac_suspend() local
477 if (dwmac->ops->suspend) in stm32_dwmac_suspend()
478 ret = dwmac->ops->suspend(dwmac); in stm32_dwmac_suspend()
487 struct stm32_dwmac *dwmac = priv->plat->bsp_priv; in stm32_dwmac_resume() local
490 if (dwmac->ops->resume) in stm32_dwmac_resume()
491 dwmac->ops->resume(dwmac); in stm32_dwmac_resume()