Lines Matching full:dwmac
4 * Adopted from dwmac-sti.c
67 struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)bsp_priv; in socfpga_dwmac_fix_mac_speed() local
68 struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dwmac->dev)); in socfpga_dwmac_fix_mac_speed()
69 void __iomem *splitter_base = dwmac->splitter_base; in socfpga_dwmac_fix_mac_speed()
70 void __iomem *sgmii_adapter_base = dwmac->sgmii_adapter_base; in socfpga_dwmac_fix_mac_speed()
104 static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *dev) in socfpga_dwmac_parse_data() argument
135 dwmac->f2h_ptp_ref_clk = of_property_read_bool(np, "altr,f2h_ptp_ref_clk"); in socfpga_dwmac_parse_data()
146 dwmac->splitter_base = devm_ioremap_resource(dev, &res_splitter); in socfpga_dwmac_parse_data()
147 if (IS_ERR(dwmac->splitter_base)) { in socfpga_dwmac_parse_data()
149 return PTR_ERR(dwmac->splitter_base); in socfpga_dwmac_parse_data()
169 dwmac->splitter_base = in socfpga_dwmac_parse_data()
172 if (IS_ERR(dwmac->splitter_base)) { in socfpga_dwmac_parse_data()
173 ret = PTR_ERR(dwmac->splitter_base); in socfpga_dwmac_parse_data()
191 dwmac->sgmii_adapter_base = in socfpga_dwmac_parse_data()
194 if (IS_ERR(dwmac->sgmii_adapter_base)) { in socfpga_dwmac_parse_data()
195 ret = PTR_ERR(dwmac->sgmii_adapter_base); in socfpga_dwmac_parse_data()
213 dwmac->tse_pcs_base = in socfpga_dwmac_parse_data()
216 if (IS_ERR(dwmac->tse_pcs_base)) { in socfpga_dwmac_parse_data()
217 ret = PTR_ERR(dwmac->tse_pcs_base); in socfpga_dwmac_parse_data()
222 dwmac->reg_offset = reg_offset; in socfpga_dwmac_parse_data()
223 dwmac->reg_shift = reg_shift; in socfpga_dwmac_parse_data()
224 dwmac->sys_mgr_base_addr = sys_mgr_base_addr; in socfpga_dwmac_parse_data()
225 dwmac->dev = dev; in socfpga_dwmac_parse_data()
235 static int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac) in socfpga_get_plat_phymode() argument
237 return dwmac->plat_dat->mac_interface; in socfpga_get_plat_phymode()
240 static void socfpga_sgmii_config(struct socfpga_dwmac *dwmac, bool enable) in socfpga_sgmii_config() argument
244 writew(val, dwmac->sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG); in socfpga_sgmii_config()
271 static int socfpga_gen5_set_phy_mode(struct socfpga_dwmac *dwmac) in socfpga_gen5_set_phy_mode() argument
273 struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr; in socfpga_gen5_set_phy_mode()
274 int phymode = socfpga_get_plat_phymode(dwmac); in socfpga_gen5_set_phy_mode()
275 u32 reg_offset = dwmac->reg_offset; in socfpga_gen5_set_phy_mode()
276 u32 reg_shift = dwmac->reg_shift; in socfpga_gen5_set_phy_mode()
280 dev_err(dwmac->dev, "bad phy mode %d\n", phymode); in socfpga_gen5_set_phy_mode()
288 if (dwmac->splitter_base) in socfpga_gen5_set_phy_mode()
292 reset_control_assert(dwmac->stmmac_ocp_rst); in socfpga_gen5_set_phy_mode()
293 reset_control_assert(dwmac->stmmac_rst); in socfpga_gen5_set_phy_mode()
299 if (dwmac->f2h_ptp_ref_clk || in socfpga_gen5_set_phy_mode()
310 if (dwmac->f2h_ptp_ref_clk) in socfpga_gen5_set_phy_mode()
321 reset_control_deassert(dwmac->stmmac_ocp_rst); in socfpga_gen5_set_phy_mode()
322 reset_control_deassert(dwmac->stmmac_rst); in socfpga_gen5_set_phy_mode()
324 socfpga_sgmii_config(dwmac, true); in socfpga_gen5_set_phy_mode()
329 static int socfpga_gen10_set_phy_mode(struct socfpga_dwmac *dwmac) in socfpga_gen10_set_phy_mode() argument
331 struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr; in socfpga_gen10_set_phy_mode()
332 int phymode = socfpga_get_plat_phymode(dwmac); in socfpga_gen10_set_phy_mode()
333 u32 reg_offset = dwmac->reg_offset; in socfpga_gen10_set_phy_mode()
334 u32 reg_shift = dwmac->reg_shift; in socfpga_gen10_set_phy_mode()
344 if (dwmac->splitter_base) in socfpga_gen10_set_phy_mode()
348 reset_control_assert(dwmac->stmmac_ocp_rst); in socfpga_gen10_set_phy_mode()
349 reset_control_assert(dwmac->stmmac_rst); in socfpga_gen10_set_phy_mode()
355 if (dwmac->f2h_ptp_ref_clk || in socfpga_gen10_set_phy_mode()
374 reset_control_deassert(dwmac->stmmac_ocp_rst); in socfpga_gen10_set_phy_mode()
375 reset_control_deassert(dwmac->stmmac_rst); in socfpga_gen10_set_phy_mode()
377 socfpga_sgmii_config(dwmac, true); in socfpga_gen10_set_phy_mode()
383 struct socfpga_dwmac *dwmac = priv->plat->bsp_priv; in socfpga_dwmac_pcs_init() local
394 if (!dwmac->tse_pcs_base) in socfpga_dwmac_pcs_init()
397 pcs_regmap = devm_regmap_init_mmio(priv->device, dwmac->tse_pcs_base, in socfpga_dwmac_pcs_init()
439 struct socfpga_dwmac *dwmac = bsp_priv; in socfpga_dwmac_init() local
441 return dwmac->ops->set_phy_mode(dwmac); in socfpga_dwmac_init()
450 struct socfpga_dwmac *dwmac; in socfpga_dwmac_probe() local
467 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); in socfpga_dwmac_probe()
468 if (!dwmac) in socfpga_dwmac_probe()
471 dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp"); in socfpga_dwmac_probe()
472 if (IS_ERR(dwmac->stmmac_ocp_rst)) { in socfpga_dwmac_probe()
473 ret = PTR_ERR(dwmac->stmmac_ocp_rst); in socfpga_dwmac_probe()
478 reset_control_deassert(dwmac->stmmac_ocp_rst); in socfpga_dwmac_probe()
480 ret = socfpga_dwmac_parse_data(dwmac, dev); in socfpga_dwmac_probe()
490 dwmac->stmmac_rst = plat_dat->stmmac_rst; in socfpga_dwmac_probe()
491 dwmac->ops = ops; in socfpga_dwmac_probe()
492 dwmac->plat_dat = plat_dat; in socfpga_dwmac_probe()
494 plat_dat->bsp_priv = dwmac; in socfpga_dwmac_probe()
526 .name = "socfpga-dwmac",
533 MODULE_DESCRIPTION("Altera SOC DWMAC Specific Glue layer");