Lines Matching full:dwmac
3 * dwmac-imx.c - DWMAC Specific Glue layer for NXP imx8
70 struct imx_priv_data *dwmac = plat_dat->bsp_priv; in imx8mp_set_intf_mode() local
79 val |= (dwmac->rmii_refclk_ext ? 0 : GPR_ENET_QOS_CLK_TX_CLK_SEL); in imx8mp_set_intf_mode()
89 pr_debug("imx dwmac doesn't support %d interface\n", in imx8mp_set_intf_mode()
95 return regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, in imx8mp_set_intf_mode()
110 struct imx_priv_data *dwmac = plat_dat->bsp_priv; in imx93_set_intf_mode() local
127 dev_dbg(dwmac->dev, "imx dwmac doesn't support %d interface\n", in imx93_set_intf_mode()
133 return regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, in imx93_set_intf_mode()
139 struct imx_priv_data *dwmac = priv; in imx_dwmac_clks_config() local
143 ret = clk_prepare_enable(dwmac->clk_mem); in imx_dwmac_clks_config()
145 dev_err(dwmac->dev, "mem clock enable failed\n"); in imx_dwmac_clks_config()
149 ret = clk_prepare_enable(dwmac->clk_tx); in imx_dwmac_clks_config()
151 dev_err(dwmac->dev, "tx clock enable failed\n"); in imx_dwmac_clks_config()
152 clk_disable_unprepare(dwmac->clk_mem); in imx_dwmac_clks_config()
156 clk_disable_unprepare(dwmac->clk_tx); in imx_dwmac_clks_config()
157 clk_disable_unprepare(dwmac->clk_mem); in imx_dwmac_clks_config()
166 struct imx_priv_data *dwmac = priv; in imx_dwmac_init() local
169 plat_dat = dwmac->plat_dat; in imx_dwmac_init()
171 if (dwmac->ops->set_intf_mode) { in imx_dwmac_init()
172 ret = dwmac->ops->set_intf_mode(plat_dat); in imx_dwmac_init()
188 struct imx_priv_data *dwmac = priv; in imx_dwmac_fix_speed() local
192 plat_dat = dwmac->plat_dat; in imx_dwmac_fix_speed()
194 if (dwmac->ops->mac_rgmii_txclk_auto_adj || in imx_dwmac_fix_speed()
210 dev_err(dwmac->dev, "invalid speed %u\n", speed); in imx_dwmac_fix_speed()
214 err = clk_set_rate(dwmac->clk_tx, rate); in imx_dwmac_fix_speed()
216 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); in imx_dwmac_fix_speed()
221 struct imx_priv_data *dwmac = priv; in imx93_dwmac_fix_speed() local
227 if (!dwmac || mode != MLO_AN_FIXED) in imx93_dwmac_fix_speed()
230 if (regmap_read(dwmac->intf_regmap, dwmac->intf_reg_off, &iface)) in imx93_dwmac_fix_speed()
237 old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG); in imx93_dwmac_fix_speed()
239 regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, in imx93_dwmac_fix_speed()
241 writel(ctrl, dwmac->base_addr + MAC_CTRL_REG); in imx93_dwmac_fix_speed()
244 readl(dwmac->base_addr + MAC_CTRL_REG); in imx93_dwmac_fix_speed()
248 regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, in imx93_dwmac_fix_speed()
251 writel(old_ctrl, dwmac->base_addr + MAC_CTRL_REG); in imx93_dwmac_fix_speed()
274 imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) in imx_dwmac_parse_dt() argument
279 dwmac->rmii_refclk_ext = of_property_read_bool(np, "snps,rmii_refclk_ext"); in imx_dwmac_parse_dt()
281 dwmac->clk_tx = devm_clk_get(dev, "tx"); in imx_dwmac_parse_dt()
282 if (IS_ERR(dwmac->clk_tx)) { in imx_dwmac_parse_dt()
284 return PTR_ERR(dwmac->clk_tx); in imx_dwmac_parse_dt()
287 dwmac->clk_mem = NULL; in imx_dwmac_parse_dt()
291 dwmac->clk_mem = devm_clk_get(dev, "mem"); in imx_dwmac_parse_dt()
292 if (IS_ERR(dwmac->clk_mem)) { in imx_dwmac_parse_dt()
294 return PTR_ERR(dwmac->clk_mem); in imx_dwmac_parse_dt()
304 dwmac->intf_regmap = syscon_regmap_lookup_by_phandle(np, "intf_mode"); in imx_dwmac_parse_dt()
305 if (IS_ERR(dwmac->intf_regmap)) in imx_dwmac_parse_dt()
306 return PTR_ERR(dwmac->intf_regmap); in imx_dwmac_parse_dt()
308 err = of_property_read_u32_index(np, "intf_mode", 1, &dwmac->intf_reg_off); in imx_dwmac_parse_dt()
322 struct imx_priv_data *dwmac; in imx_dwmac_probe() local
330 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in imx_dwmac_probe()
331 if (!dwmac) in imx_dwmac_probe()
344 dwmac->ops = data; in imx_dwmac_probe()
345 dwmac->dev = &pdev->dev; in imx_dwmac_probe()
347 ret = imx_dwmac_parse_dt(dwmac, &pdev->dev); in imx_dwmac_probe()
360 plat_dat->host_dma_width = dwmac->ops->addr_width; in imx_dwmac_probe()
365 plat_dat->bsp_priv = dwmac; in imx_dwmac_probe()
366 dwmac->plat_dat = plat_dat; in imx_dwmac_probe()
367 dwmac->base_addr = stmmac_res.addr; in imx_dwmac_probe()
369 ret = imx_dwmac_clks_config(dwmac, true); in imx_dwmac_probe()
373 ret = imx_dwmac_init(pdev, dwmac); in imx_dwmac_probe()
377 if (dwmac->ops->fix_mac_speed) in imx_dwmac_probe()
378 plat_dat->fix_mac_speed = dwmac->ops->fix_mac_speed; in imx_dwmac_probe()
379 dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset; in imx_dwmac_probe()
390 imx_dwmac_clks_config(dwmac, false); in imx_dwmac_probe()
416 { .compatible = "nxp,imx8mp-dwmac-eqos", .data = &imx8mp_dwmac_data },
417 { .compatible = "nxp,imx8dxl-dwmac-eqos", .data = &imx8dxl_dwmac_data },
418 { .compatible = "nxp,imx93-dwmac-eqos", .data = &imx93_dwmac_data },
427 .name = "imx-dwmac",
435 MODULE_DESCRIPTION("NXP imx8 DWMAC Specific Glue layer");