if (sgmii_adapter_base)
writew(SGMII_ADAPTER_DISABLE,
sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
if (splitter_base) {
val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG);
val &= ~EMAC_SPLITTER_CTRL_SPEED_MASK;
switch (speed) { case 1000:
val |= EMAC_SPLITTER_CTRL_SPEED_1000; break; case 100:
val |= EMAC_SPLITTER_CTRL_SPEED_100; break; case 10:
val |= EMAC_SPLITTER_CTRL_SPEED_10; break; default: return;
}
writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
}
sys_mgr_base_addr =
altr_sysmgr_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon"); if (IS_ERR(sys_mgr_base_addr)) {
dev_info(dev, "No sysmgr-syscon node found\n"); return PTR_ERR(sys_mgr_base_addr);
}
ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 1, ®_offset); if (ret) {
dev_info(dev, "Could not read reg_offset from sysmgr-syscon!\n"); return -EINVAL;
}
ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 2, ®_shift); if (ret) {
dev_info(dev, "Could not read reg_shift from sysmgr-syscon!\n"); return -EINVAL;
}
/* Overwrite val to GMII if splitter core is enabled. The phymode here * is the actual phy mode on phy hardware, but phy interface from * EMAC core is GMII.
*/ if (dwmac->splitter_base)
val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
/* Assert reset to the enet controller before changing the phy mode */
reset_control_assert(dwmac->stmmac_ocp_rst);
reset_control_assert(dwmac->stmmac_rst);
/* Deassert reset for the phy configuration to be sampled by * the enet controller, and operation to start in requested mode
*/
reset_control_deassert(dwmac->stmmac_ocp_rst);
reset_control_deassert(dwmac->stmmac_rst); if (phymode == PHY_INTERFACE_MODE_SGMII)
socfpga_sgmii_config(dwmac, true);
if (socfpga_set_phy_mode_common(phymode, &val)) return -EINVAL;
/* Overwrite val to GMII if splitter core is enabled. The phymode here * is the actual phy mode on phy hardware, but phy interface from * EMAC core is GMII.
*/ if (dwmac->splitter_base)
val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
/* Assert reset to the enet controller before changing the phy mode */
reset_control_assert(dwmac->stmmac_ocp_rst);
reset_control_assert(dwmac->stmmac_rst);
/* Deassert reset for the phy configuration to be sampled by * the enet controller, and operation to start in requested mode
*/
reset_control_deassert(dwmac->stmmac_ocp_rst);
reset_control_deassert(dwmac->stmmac_rst); if (phymode == PHY_INTERFACE_MODE_SGMII)
socfpga_sgmii_config(dwmac, true); return 0;
}
/* Can't use ndev->name here because it will not have been initialised, * and in any case, the user can rename network interfaces at runtime.
*/
snprintf(mrc.name, MII_BUS_ID_SIZE, "%s-pcs-mii",
dev_name(priv->device));
pcs_bus = devm_mdio_regmap_register(priv->device, &mrc); if (IS_ERR(pcs_bus)) return PTR_ERR(pcs_bus);
pcs = lynx_pcs_create_mdiodev(pcs_bus, 0); if (IS_ERR(pcs)) return PTR_ERR(pcs);
priv->hw->phylink_pcs = pcs; return 0;
}
staticvoid socfpga_dwmac_pcs_exit(struct stmmac_priv *priv)
{ if (priv->hw->phylink_pcs)
lynx_pcs_destroy(priv->hw->phylink_pcs);
}
ops = device_get_match_data(&pdev->dev); if (!ops) {
dev_err(&pdev->dev, "no of match data provided\n"); return -EINVAL;
}
ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) return ret;
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); if (IS_ERR(plat_dat)) return PTR_ERR(plat_dat);
dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); if (!dwmac) return -ENOMEM;
dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp"); if (IS_ERR(dwmac->stmmac_ocp_rst)) {
ret = PTR_ERR(dwmac->stmmac_ocp_rst);
dev_err(dev, "error getting reset control of ocp %d\n", ret); return ret;
}
reset_control_deassert(dwmac->stmmac_ocp_rst);
ret = socfpga_dwmac_parse_data(dwmac, dev); if (ret) {
dev_err(dev, "Unable to parse OF data\n"); return ret;
}
/* The socfpga driver needs to control the stmmac reset to set the phy * mode. Create a copy of the core reset handle so it can be used by * the driver later.
*/
dwmac->stmmac_rst = plat_dat->stmmac_rst;
dwmac->ops = ops;
dwmac->plat_dat = plat_dat;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.