Lines Matching refs:phydev

217 __weak int mv88e61xx_hw_reset(struct phy_device *phydev)  in mv88e61xx_hw_reset()  argument
256 static int mv88e61xx_reg_read(struct phy_device *phydev, int dev, int reg) in mv88e61xx_reg_read() argument
258 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_reg_read()
292 static int mv88e61xx_reg_write(struct phy_device *phydev, int dev, int reg, in mv88e61xx_reg_write() argument
295 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_reg_write()
331 static int mv88e61xx_phy_wait(struct phy_device *phydev) in mv88e61xx_phy_wait() argument
337 val = mv88e61xx_reg_read(phydev, DEVADDR_GLOBAL_2, in mv88e61xx_phy_wait()
351 struct phy_device *phydev; in mv88e61xx_phy_read_indirect() local
354 phydev = (struct phy_device *)smi_wrapper->priv; in mv88e61xx_phy_read_indirect()
357 res = mv88e61xx_reg_write(phydev, DEVADDR_GLOBAL_2, in mv88e61xx_phy_read_indirect()
362 res = mv88e61xx_phy_wait(phydev); in mv88e61xx_phy_read_indirect()
367 return mv88e61xx_reg_read(phydev, DEVADDR_GLOBAL_2, in mv88e61xx_phy_read_indirect()
374 struct phy_device *phydev; in mv88e61xx_phy_write_indirect() local
377 phydev = (struct phy_device *)smi_wrapper->priv; in mv88e61xx_phy_write_indirect()
380 res = mv88e61xx_reg_write(phydev, DEVADDR_GLOBAL_2, in mv88e61xx_phy_write_indirect()
385 res = mv88e61xx_reg_write(phydev, DEVADDR_GLOBAL_2, in mv88e61xx_phy_write_indirect()
392 return mv88e61xx_phy_wait(phydev); in mv88e61xx_phy_write_indirect()
396 static int mv88e61xx_phy_read(struct phy_device *phydev, int phy, int reg) in mv88e61xx_phy_read() argument
398 return mv88e61xx_phy_read_indirect(phydev->bus, DEVADDR_PHY(phy), in mv88e61xx_phy_read()
403 static int mv88e61xx_phy_write(struct phy_device *phydev, int phy, in mv88e61xx_phy_write() argument
406 return mv88e61xx_phy_write_indirect(phydev->bus, DEVADDR_PHY(phy), in mv88e61xx_phy_write()
410 static int mv88e61xx_port_read(struct phy_device *phydev, u8 port, u8 reg) in mv88e61xx_port_read() argument
412 return mv88e61xx_reg_read(phydev, DEVADDR_PORT(port), reg); in mv88e61xx_port_read()
415 static int mv88e61xx_port_write(struct phy_device *phydev, u8 port, u8 reg, in mv88e61xx_port_write() argument
418 return mv88e61xx_reg_write(phydev, DEVADDR_PORT(port), reg, val); in mv88e61xx_port_write()
421 static int mv88e61xx_set_page(struct phy_device *phydev, u8 phy, u8 page) in mv88e61xx_set_page() argument
423 return mv88e61xx_phy_write(phydev, phy, PHY_REG_PAGE, page); in mv88e61xx_set_page()
426 static int mv88e61xx_get_switch_id(struct phy_device *phydev) in mv88e61xx_get_switch_id() argument
430 res = mv88e61xx_port_read(phydev, 0, PORT_REG_SWITCH_ID); in mv88e61xx_get_switch_id()
436 static bool mv88e61xx_6352_family(struct phy_device *phydev) in mv88e61xx_6352_family() argument
438 struct mv88e61xx_phy_priv *priv = phydev->priv; in mv88e61xx_6352_family()
450 static int mv88e61xx_get_cmode(struct phy_device *phydev, u8 port) in mv88e61xx_get_cmode() argument
454 res = mv88e61xx_port_read(phydev, port, PORT_REG_STATUS); in mv88e61xx_get_cmode()
460 static int mv88e61xx_parse_status(struct phy_device *phydev) in mv88e61xx_parse_status() argument
465 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, PHY_REG_STATUS1); in mv88e61xx_parse_status()
476 phydev->link = 0; in mv88e61xx_parse_status()
483 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, 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()
517 static int mv88e61xx_switch_reset(struct phy_device *phydev) in mv88e61xx_switch_reset() argument
525 val = mv88e61xx_port_read(phydev, port, PORT_REG_CTRL); in mv88e61xx_switch_reset()
531 val = mv88e61xx_port_write(phydev, port, PORT_REG_CTRL, val); in mv88e61xx_switch_reset()
540 val = mv88e61xx_reg_read(phydev, DEVADDR_GLOBAL_1, GLOBAL1_CTRL); in mv88e61xx_switch_reset()
544 val = mv88e61xx_reg_write(phydev, DEVADDR_GLOBAL_1, in mv88e61xx_switch_reset()
551 val = mv88e61xx_reg_read(phydev, DEVADDR_GLOBAL_1, in mv88e61xx_switch_reset()
563 static int mv88e61xx_serdes_init(struct phy_device *phydev) in mv88e61xx_serdes_init() argument
567 val = mv88e61xx_set_page(phydev, DEVADDR_SERDES, PHY_PAGE_SERDES); in mv88e61xx_serdes_init()
572 val = mv88e61xx_phy_read(phydev, DEVADDR_SERDES, MII_BMCR); in mv88e61xx_serdes_init()
576 val = mv88e61xx_phy_write(phydev, DEVADDR_SERDES, MII_BMCR, val); in mv88e61xx_serdes_init()
583 static int mv88e61xx_port_enable(struct phy_device *phydev, u8 port) in mv88e61xx_port_enable() argument
587 val = mv88e61xx_port_read(phydev, port, PORT_REG_CTRL); in mv88e61xx_port_enable()
593 val = mv88e61xx_port_write(phydev, port, PORT_REG_CTRL, val); in mv88e61xx_port_enable()
600 static int mv88e61xx_port_set_vlan(struct phy_device *phydev, u8 port, in mv88e61xx_port_set_vlan() argument
606 val = mv88e61xx_port_read(phydev, port, PORT_REG_VLAN_ID); in mv88e61xx_port_set_vlan()
612 val = mv88e61xx_port_write(phydev, port, PORT_REG_VLAN_ID, val); in mv88e61xx_port_set_vlan()
617 val = mv88e61xx_port_read(phydev, port, PORT_REG_VLAN_MAP); in mv88e61xx_port_set_vlan()
623 val = mv88e61xx_port_write(phydev, port, PORT_REG_VLAN_MAP, val); in mv88e61xx_port_set_vlan()
630 static int mv88e61xx_read_port_config(struct phy_device *phydev, u8 port) in mv88e61xx_read_port_config() argument
636 val = mv88e61xx_port_read(phydev, port, PORT_REG_STATUS); in mv88e61xx_read_port_config()
644 val = mv88e61xx_port_read(phydev, port, PORT_REG_PHYS_CTRL); in mv88e61xx_read_port_config()
649 val = mv88e61xx_port_write(phydev, port, PORT_REG_PHYS_CTRL, in mv88e61xx_read_port_config()
656 val = mv88e61xx_port_read(phydev, port, 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()
695 val = mv88e61xx_port_read(phydev, port, PORT_REG_PHYS_CTRL); in mv88e61xx_read_port_config()
700 val = mv88e61xx_port_write(phydev, port, PORT_REG_PHYS_CTRL, in mv88e61xx_read_port_config()
709 static int mv88e61xx_set_cpu_port(struct phy_device *phydev) in mv88e61xx_set_cpu_port() argument
714 val = mv88e61xx_reg_read(phydev, DEVADDR_GLOBAL_1, GLOBAL1_MON_CTRL); in mv88e61xx_set_cpu_port()
720 val = mv88e61xx_reg_write(phydev, DEVADDR_GLOBAL_1, in mv88e61xx_set_cpu_port()
727 val = mv88e61xx_port_set_vlan(phydev, CONFIG_MV88E61XX_CPU_PORT, val); in mv88e61xx_set_cpu_port()
732 val = mv88e61xx_port_enable(phydev, CONFIG_MV88E61XX_CPU_PORT); in mv88e61xx_set_cpu_port()
736 val = mv88e61xx_read_port_config(phydev, CONFIG_MV88E61XX_CPU_PORT); in mv88e61xx_set_cpu_port()
741 if (mv88e61xx_6352_family(phydev)) { in mv88e61xx_set_cpu_port()
742 val = mv88e61xx_get_cmode(phydev, CONFIG_MV88E61XX_CPU_PORT); in mv88e61xx_set_cpu_port()
748 val = mv88e61xx_serdes_init(phydev); in mv88e61xx_set_cpu_port()
757 static int mv88e61xx_switch_init(struct phy_device *phydev) in mv88e61xx_switch_init() argument
765 res = mv88e61xx_switch_reset(phydev); in mv88e61xx_switch_init()
769 res = mv88e61xx_set_cpu_port(phydev); in mv88e61xx_switch_init()
778 static int mv88e61xx_phy_enable(struct phy_device *phydev, u8 phy) in mv88e61xx_phy_enable() argument
782 val = mv88e61xx_phy_read(phydev, phy, MII_BMCR); in mv88e61xx_phy_enable()
786 val = mv88e61xx_phy_write(phydev, phy, MII_BMCR, val); in mv88e61xx_phy_enable()
793 static int mv88e61xx_phy_setup(struct phy_device *phydev, u8 phy) in mv88e61xx_phy_setup() argument
801 val = mv88e61xx_phy_read(phydev, phy, PHY_REG_CTRL1); in mv88e61xx_phy_setup()
807 val = mv88e61xx_phy_write(phydev, phy, PHY_REG_CTRL1, val); in mv88e61xx_phy_setup()
814 static int mv88e61xx_fixed_port_setup(struct phy_device *phydev, u8 port) in mv88e61xx_fixed_port_setup() argument
818 val = mv88e61xx_port_read(phydev, port, PORT_REG_PHYS_CTRL); in mv88e61xx_fixed_port_setup()
831 return mv88e61xx_port_write(phydev, port, PORT_REG_PHYS_CTRL, in mv88e61xx_fixed_port_setup()
835 static int mv88e61xx_phy_config_port(struct phy_device *phydev, u8 phy) in mv88e61xx_phy_config_port() argument
839 val = mv88e61xx_port_enable(phydev, phy); in mv88e61xx_phy_config_port()
843 val = mv88e61xx_port_set_vlan(phydev, phy, in mv88e61xx_phy_config_port()
851 static int mv88e61xx_probe(struct phy_device *phydev) in mv88e61xx_probe() argument
857 res = mv88e61xx_hw_reset(phydev); in mv88e61xx_probe()
882 priv->mdio_bus = phydev->bus; in mv88e61xx_probe()
889 priv->smi_addr = phydev->addr; in mv88e61xx_probe()
895 smi_wrapper->priv = phydev; 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()
910 static int mv88e61xx_phy_config(struct phy_device *phydev) in mv88e61xx_phy_config() argument
916 res = mv88e61xx_switch_init(phydev); in mv88e61xx_phy_config()
922 phydev->addr = i; in mv88e61xx_phy_config()
924 res = mv88e61xx_phy_enable(phydev, i); in mv88e61xx_phy_config()
929 res = mv88e61xx_phy_setup(phydev, i); in mv88e61xx_phy_config()
934 res = mv88e61xx_phy_config_port(phydev, i); in mv88e61xx_phy_config()
940 res = genphy_config_aneg(phydev); in mv88e61xx_phy_config()
945 res = phy_reset(phydev); in mv88e61xx_phy_config()
954 res = mv88e61xx_fixed_port_setup(phydev, i); in mv88e61xx_phy_config()
965 static int mv88e61xx_phy_is_connected(struct phy_device *phydev) in mv88e61xx_phy_is_connected() argument
969 val = mv88e61xx_phy_read(phydev, phydev->addr, PHY_REG_STATUS1); in mv88e61xx_phy_is_connected()
981 static int mv88e61xx_phy_startup(struct phy_device *phydev) in mv88e61xx_phy_startup() argument
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()
992 if (!mv88e61xx_phy_is_connected(phydev)) in mv88e61xx_phy_startup()
994 res = genphy_update_link(phydev); in mv88e61xx_phy_startup()
997 res = mv88e61xx_parse_status(phydev); 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()