Lines Matching +full:smi +full:- +full:common
11 * SPDX-License-Identifier: GPL-2.0+
33 #include <common.h>
44 #define PORT_MASK ((1 << PORT_COUNT) - 1)
53 /* SMI indirection registers for multichip addressing mode */
222 /* Wait for the current SMI indirect command to complete */
229 val = bus->read(bus, smi_addr, MDIO_DEVAD_NONE, SMI_CMD_REG); in mv88e61xx_smi_wait()
234 } while (--timeout); in mv88e61xx_smi_wait()
236 puts("SMI busy timeout\n"); in mv88e61xx_smi_wait()
237 return -ETIMEDOUT; in mv88e61xx_smi_wait()
241 * The mv88e61xx has three types of addresses: the smi bus address, the device
242 * address, and the register address. The smi bus address distinguishes it on
243 * the smi bus from other PHYs or switches. The device address determines
244 * which on-chip register set you are reading/writing (the various PHYs, their
249 * single-chip addressing mode, where it responds to all SMI addresses, using
250 * the smi address as its device address. This obviously only works when this
251 * is the only chip on the SMI bus. This allows the driver to access device
253 * non-zero address, it only responds to that SMI address and requires indirect
258 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_reg_read()
259 struct mii_dev *mdio_bus = priv->mdio_bus; in mv88e61xx_reg_read()
260 int smi_addr = priv->smi_addr; in mv88e61xx_reg_read()
263 /* In single-chip mode, the device can be addressed directly */ in mv88e61xx_reg_read()
265 return mdio_bus->read(mdio_bus, dev, MDIO_DEVAD_NONE, reg); in mv88e61xx_reg_read()
273 res = mdio_bus->write(mdio_bus, smi_addr, MDIO_DEVAD_NONE, SMI_CMD_REG, in mv88e61xx_reg_read()
284 res = mdio_bus->read(mdio_bus, smi_addr, MDIO_DEVAD_NONE, SMI_DATA_REG); in mv88e61xx_reg_read()
295 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_reg_write()
296 struct mii_dev *mdio_bus = priv->mdio_bus; in mv88e61xx_reg_write()
297 int smi_addr = priv->smi_addr; in mv88e61xx_reg_write()
300 /* In single-chip mode, the device can be addressed directly */ in mv88e61xx_reg_write()
302 return mdio_bus->write(mdio_bus, dev, MDIO_DEVAD_NONE, reg, in mv88e61xx_reg_write()
312 res = mdio_bus->write(mdio_bus, smi_addr, MDIO_DEVAD_NONE, in mv88e61xx_reg_write()
318 res = mdio_bus->write(mdio_bus, smi_addr, MDIO_DEVAD_NONE, SMI_CMD_REG, in mv88e61xx_reg_write()
343 } while (--timeout); in mv88e61xx_phy_wait()
345 return -ETIMEDOUT; in mv88e61xx_phy_wait()
354 phydev = (struct phy_device *)smi_wrapper->priv; in mv88e61xx_phy_read_indirect()
377 phydev = (struct phy_device *)smi_wrapper->priv; in mv88e61xx_phy_write_indirect()
398 return mv88e61xx_phy_read_indirect(phydev->bus, DEVADDR_PHY(phy), in mv88e61xx_phy_read()
406 return mv88e61xx_phy_write_indirect(phydev->bus, DEVADDR_PHY(phy), in mv88e61xx_phy_write()
438 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_6352_family()
440 switch (priv->id) { in mv88e61xx_6352_family()
476 phydev->link = 0; in mv88e61xx_parse_status()
490 phydev->link = 1; in mv88e61xx_parse_status()
492 phydev->link = 0; in mv88e61xx_parse_status()
496 phydev->duplex = DUPLEX_FULL; in mv88e61xx_parse_status()
498 phydev->duplex = DUPLEX_HALF; in mv88e61xx_parse_status()
504 phydev->speed = SPEED_1000; in mv88e61xx_parse_status()
507 phydev->speed = SPEED_100; in mv88e61xx_parse_status()
510 phydev->speed = SPEED_10; in mv88e61xx_parse_status()
550 for (time = 1000; time; time--) { in mv88e61xx_switch_reset()
558 return -ETIMEDOUT; in mv88e61xx_switch_reset()
659 res = -EIO; in mv88e61xx_read_port_config()
664 } while (--timeout); in mv88e61xx_read_port_config()
667 res = -ETIMEDOUT; in mv88e61xx_read_port_config()
673 phydev->duplex = DUPLEX_FULL; in mv88e61xx_read_port_config()
675 phydev->duplex = DUPLEX_HALF; in mv88e61xx_read_port_config()
681 phydev->speed = SPEED_1000; in mv88e61xx_read_port_config()
684 phydev->speed = SPEED_100; in mv88e61xx_read_port_config()
687 phydev->speed = SPEED_10; in mv88e61xx_read_port_config()
798 * Enable energy-detect sensing on PHY, used to determine when a PHY in mv88e61xx_phy_setup()
863 return -ENOMEM; in mv88e61xx_probe()
875 return -ENOMEM; in mv88e61xx_probe()
882 priv->mdio_bus = phydev->bus; in mv88e61xx_probe()
885 * Store the smi bus address in private data. This lets us use the in mv88e61xx_probe()
889 priv->smi_addr = phydev->addr; in mv88e61xx_probe()
895 smi_wrapper->priv = phydev; in mv88e61xx_probe()
896 strncpy(smi_wrapper->name, "indirect mii", sizeof(smi_wrapper->name)); in mv88e61xx_probe()
897 smi_wrapper->read = mv88e61xx_phy_read_indirect; in mv88e61xx_probe()
898 smi_wrapper->write = mv88e61xx_phy_write_indirect; in mv88e61xx_probe()
901 phydev->bus = smi_wrapper; in mv88e61xx_probe()
903 phydev->priv = priv; in mv88e61xx_probe()
905 priv->id = mv88e61xx_get_switch_id(phydev); in mv88e61xx_probe()
914 int ret = -1; in mv88e61xx_phy_config()
922 phydev->addr = i; in mv88e61xx_phy_config()
969 val = mv88e61xx_phy_read(phydev, phydev->addr, PHY_REG_STATUS1); in mv88e61xx_phy_is_connected()
986 int speed = phydev->speed; in mv88e61xx_phy_startup()
987 int duplex = phydev->duplex; in mv88e61xx_phy_startup()
991 phydev->addr = i; in mv88e61xx_phy_startup()
1000 link = (link || phydev->link); in mv88e61xx_phy_startup()
1003 phydev->link = link; in mv88e61xx_phy_startup()
1007 phydev->speed = speed; in mv88e61xx_phy_startup()
1008 phydev->duplex = duplex; in mv88e61xx_phy_startup()
1044 * Overload weak get_phy_id definition since we need non-standard functions
1065 return -EIO; in get_phy_id()
1071 return -EIO; in get_phy_id()