static int ksz9031_config(struct phy_device *phydev) { int ret; ret = ksz9031_of_config(phydev); if (ret) return ret; ret = ksz9031_center_flp_timing(phydev); if (ret) return ret; /* add an option to disable the gigabit feature of this PHY */ if (env_get("disable_giga")) { unsigned features; unsigned bmcr; /* disable speed 1000 in features supported by the PHY */ features = phydev->drv->features; features &= ~(SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full); phydev->advertising = phydev->supported = features; /* disable speed 1000 in Basic Control Register */ bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR); bmcr &= ~(1 << 6); phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr); /* disable speed 1000 in 1000Base-T Control Register */ phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, 0); /* start autoneg */ genphy_config_aneg(phydev); genphy_restart_aneg(phydev); return 0; } return genphy_config(phydev); }
static int ksz9031_config_init(struct phy_device *phydev) { const struct device_d *dev = &phydev->dev; const struct device_node *of_node = dev->device_node; static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; static const char *rx_data_skews[4] = { "rxd0-skew-ps", "rxd1-skew-ps", "rxd2-skew-ps", "rxd3-skew-ps" }; static const char *tx_data_skews[4] = { "txd0-skew-ps", "txd1-skew-ps", "txd2-skew-ps", "txd3-skew-ps" }; static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; if (!of_node && dev->parent->device_node) of_node = dev->parent->device_node; if (of_node) { ksz9031_of_load_skew_values(phydev, of_node, MII_KSZ9031RN_CLK_PAD_SKEW, 5, clk_skews, 2); ksz9031_of_load_skew_values(phydev, of_node, MII_KSZ9031RN_CONTROL_PAD_SKEW, 4, control_skews, 2); ksz9031_of_load_skew_values(phydev, of_node, MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4, rx_data_skews, 4); ksz9031_of_load_skew_values(phydev, of_node, MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4, tx_data_skews, 4); } return ksz9031_center_flp_timing(phydev); }