Lines Matching refs:dwmac

101 	int (*clk_prepare)(struct stm32_dwmac *dwmac, bool prepare);
102 int (*suspend)(struct stm32_dwmac *dwmac);
103 void (*resume)(struct stm32_dwmac *dwmac);
104 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->ops->clk_rx_enable_in_suspend || in stm32_dwmac_init()
126 !dwmac->dev->power.is_suspended) { in stm32_dwmac_init()
127 ret = clk_prepare_enable(dwmac->clk_rx); in stm32_dwmac_init()
129 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_init()
134 if (dwmac->ops->clk_prepare) { in stm32_dwmac_init()
135 ret = dwmac->ops->clk_prepare(dwmac, true); in stm32_dwmac_init()
137 clk_disable_unprepare(dwmac->clk_rx); in stm32_dwmac_init()
138 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_init()
145 static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare) in stm32mp1_clk_prepare() argument
150 ret = clk_prepare_enable(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
153 if (dwmac->enable_eth_ck) { in stm32mp1_clk_prepare()
154 ret = clk_prepare_enable(dwmac->clk_eth_ck); in stm32mp1_clk_prepare()
156 clk_disable_unprepare(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
161 clk_disable_unprepare(dwmac->syscfg_clk); in stm32mp1_clk_prepare()
162 if (dwmac->enable_eth_ck) in stm32mp1_clk_prepare()
163 clk_disable_unprepare(dwmac->clk_eth_ck); in stm32mp1_clk_prepare()
170 struct stm32_dwmac *dwmac = plat_dat->bsp_priv; in stm32mp1_set_mode() local
171 u32 reg = dwmac->mode_reg, clk_rate; in stm32mp1_set_mode()
174 clk_rate = clk_get_rate(dwmac->clk_eth_ck); in stm32mp1_set_mode()
175 dwmac->enable_eth_ck = false; in stm32mp1_set_mode()
178 if (clk_rate == ETH_CK_F_25M && dwmac->ext_phyclk) in stm32mp1_set_mode()
179 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
186 (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
187 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
195 (dwmac->eth_ref_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
196 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
207 (dwmac->eth_clk_sel_reg || dwmac->ext_phyclk)) { in stm32mp1_set_mode()
208 dwmac->enable_eth_ck = true; in stm32mp1_set_mode()
221 regmap_write(dwmac->regmap, reg + SYSCFG_PMCCLRR_OFFSET, in stm32mp1_set_mode()
222 dwmac->ops->syscfg_eth_mask); in stm32mp1_set_mode()
225 return regmap_update_bits(dwmac->regmap, reg, in stm32mp1_set_mode()
226 dwmac->ops->syscfg_eth_mask, val); in stm32mp1_set_mode()
231 struct stm32_dwmac *dwmac = plat_dat->bsp_priv; in stm32mcu_set_mode() local
232 u32 reg = dwmac->mode_reg; in stm32mcu_set_mode()
251 return regmap_update_bits(dwmac->regmap, reg, in stm32mcu_set_mode()
252 dwmac->ops->syscfg_eth_mask, val << 23); in stm32mcu_set_mode()
255 static void stm32_dwmac_clk_disable(struct stm32_dwmac *dwmac) in stm32_dwmac_clk_disable() argument
257 clk_disable_unprepare(dwmac->clk_tx); in stm32_dwmac_clk_disable()
258 clk_disable_unprepare(dwmac->clk_rx); in stm32_dwmac_clk_disable()
260 if (dwmac->ops->clk_prepare) in stm32_dwmac_clk_disable()
261 dwmac->ops->clk_prepare(dwmac, false); in stm32_dwmac_clk_disable()
264 static int stm32_dwmac_parse_data(struct stm32_dwmac *dwmac, in stm32_dwmac_parse_data() argument
271 dwmac->clk_tx = devm_clk_get(dev, "mac-clk-tx"); in stm32_dwmac_parse_data()
272 if (IS_ERR(dwmac->clk_tx)) { in stm32_dwmac_parse_data()
274 return PTR_ERR(dwmac->clk_tx); in stm32_dwmac_parse_data()
277 dwmac->clk_rx = devm_clk_get(dev, "mac-clk-rx"); in stm32_dwmac_parse_data()
278 if (IS_ERR(dwmac->clk_rx)) { in stm32_dwmac_parse_data()
280 return PTR_ERR(dwmac->clk_rx); in stm32_dwmac_parse_data()
283 if (dwmac->ops->parse_data) { in stm32_dwmac_parse_data()
284 err = dwmac->ops->parse_data(dwmac, dev); in stm32_dwmac_parse_data()
290 dwmac->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon"); in stm32_dwmac_parse_data()
291 if (IS_ERR(dwmac->regmap)) in stm32_dwmac_parse_data()
292 return PTR_ERR(dwmac->regmap); in stm32_dwmac_parse_data()
294 err = of_property_read_u32_index(np, "st,syscon", 1, &dwmac->mode_reg); in stm32_dwmac_parse_data()
301 static int stm32mp1_parse_data(struct stm32_dwmac *dwmac, in stm32mp1_parse_data() argument
309 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in stm32mp1_parse_data()
312 dwmac->eth_clk_sel_reg = of_property_read_bool(np, "st,eth-clk-sel"); in stm32mp1_parse_data()
315 dwmac->eth_ref_clk_sel_reg = in stm32mp1_parse_data()
319 dwmac->clk_eth_ck = devm_clk_get(dev, "eth-ck"); in stm32mp1_parse_data()
320 if (IS_ERR(dwmac->clk_eth_ck)) { in stm32mp1_parse_data()
322 dwmac->clk_eth_ck = NULL; in stm32mp1_parse_data()
326 dwmac->clk_ethstp = devm_clk_get(dev, "ethstp"); in stm32mp1_parse_data()
327 if (IS_ERR(dwmac->clk_ethstp)) { in stm32mp1_parse_data()
330 return PTR_ERR(dwmac->clk_ethstp); in stm32mp1_parse_data()
334 dwmac->syscfg_clk = devm_clk_get(dev, "syscfg-clk"); in stm32mp1_parse_data()
335 if (IS_ERR(dwmac->syscfg_clk)) in stm32mp1_parse_data()
336 dwmac->syscfg_clk = NULL; in stm32mp1_parse_data()
341 dwmac->irq_pwr_wakeup = platform_get_irq_byname_optional(pdev, in stm32mp1_parse_data()
343 if (dwmac->irq_pwr_wakeup == -EPROBE_DEFER) in stm32mp1_parse_data()
346 if (!dwmac->clk_eth_ck && dwmac->irq_pwr_wakeup >= 0) { in stm32mp1_parse_data()
353 dwmac->irq_pwr_wakeup); in stm32mp1_parse_data()
367 struct stm32_dwmac *dwmac; in stm32_dwmac_probe() local
379 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in stm32_dwmac_probe()
380 if (!dwmac) { in stm32_dwmac_probe()
392 dwmac->ops = data; in stm32_dwmac_probe()
393 dwmac->dev = &pdev->dev; in stm32_dwmac_probe()
395 ret = stm32_dwmac_parse_data(dwmac, &pdev->dev); in stm32_dwmac_probe()
401 plat_dat->bsp_priv = dwmac; in stm32_dwmac_probe()
414 stm32_dwmac_clk_disable(dwmac); in stm32_dwmac_probe()
425 struct stm32_dwmac *dwmac = priv->plat->bsp_priv; in stm32_dwmac_remove() local
431 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()