Lines Matching +full:bus +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0+
32 /* Pseudo-PHY address (non configurable) to access internal registers */
114 struct mii_dev *bus; member
118 static int b53_mdio_op(struct mii_dev *bus, u8 page, u8 reg, u16 op) in b53_mdio_op() argument
126 ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_op()
133 ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_op()
140 v = bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_op()
149 return -EIO; in b53_mdio_op()
154 static int b53_mdio_read8(struct mii_dev *bus, u8 page, u8 reg, u8 *val) in b53_mdio_read8() argument
158 ret = b53_mdio_op(bus, page, reg, REG_MII_ADDR_READ); in b53_mdio_read8()
162 *val = bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read8()
168 static int b53_mdio_read16(struct mii_dev *bus, u8 page, u8 reg, u16 *val) in b53_mdio_read16() argument
172 ret = b53_mdio_op(bus, page, reg, REG_MII_ADDR_READ); in b53_mdio_read16()
176 *val = bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read16()
182 static int b53_mdio_read32(struct mii_dev *bus, u8 page, u8 reg, u32 *val) in b53_mdio_read32() argument
186 ret = b53_mdio_op(bus, page, reg, REG_MII_ADDR_READ); in b53_mdio_read32()
190 *val = bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read32()
192 *val |= bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read32()
198 static int b53_mdio_read48(struct mii_dev *bus, u8 page, u8 reg, u64 *val) in b53_mdio_read48() argument
204 ret = b53_mdio_op(bus, page, reg, REG_MII_ADDR_READ); in b53_mdio_read48()
208 for (i = 2; i >= 0; i--) { in b53_mdio_read48()
210 temp |= bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read48()
219 static int b53_mdio_read64(struct mii_dev *bus, u8 page, u8 reg, u64 *val) in b53_mdio_read64() argument
225 ret = b53_mdio_op(bus, page, reg, REG_MII_ADDR_READ); in b53_mdio_read64()
229 for (i = 3; i >= 0; i--) { in b53_mdio_read64()
231 temp |= bus->read(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_read64()
240 static int b53_mdio_write8(struct mii_dev *bus, u8 page, u8 reg, u8 value) in b53_mdio_write8() argument
244 ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_write8()
249 return b53_mdio_op(bus, page, reg, REG_MII_ADDR_WRITE); in b53_mdio_write8()
252 static int b53_mdio_write16(struct mii_dev *bus, u8 page, u8 reg, in b53_mdio_write16() argument
257 ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, MDIO_DEVAD_NONE, in b53_mdio_write16()
262 return b53_mdio_op(bus, page, reg, REG_MII_ADDR_WRITE); in b53_mdio_write16()
265 static int b53_mdio_write32(struct mii_dev *bus, u8 page, u8 reg, in b53_mdio_write32() argument
272 int ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, in b53_mdio_write32()
280 return b53_mdio_op(bus, page, reg, REG_MII_ADDR_WRITE); in b53_mdio_write32()
283 static int b53_mdio_write48(struct mii_dev *bus, u8 page, u8 reg, in b53_mdio_write48() argument
290 int ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, in b53_mdio_write48()
298 return b53_mdio_op(bus, page, reg, REG_MII_ADDR_WRITE); in b53_mdio_write48()
301 static int b53_mdio_write64(struct mii_dev *bus, u8 page, u8 reg, in b53_mdio_write64() argument
308 int ret = bus->write(bus, BRCM_PSEUDO_PHY_ADDR, in b53_mdio_write64()
316 return b53_mdio_op(bus, page, reg, REG_MII_ADDR_WRITE); in b53_mdio_write64()
322 return b53_mdio_read8(dev->bus, page, reg, value); in b53_read8()
328 return b53_mdio_read16(dev->bus, page, reg, value); in b53_read16()
334 return b53_mdio_read32(dev->bus, page, reg, value); in b53_read32()
340 return b53_mdio_read48(dev->bus, page, reg, value); in b53_read48()
346 return b53_mdio_read64(dev->bus, page, reg, value); in b53_read64()
352 return b53_mdio_write8(dev->bus, page, reg, value); in b53_write8()
358 return b53_mdio_write16(dev->bus, page, reg, value); in b53_write16()
364 return b53_mdio_write32(dev->bus, page, reg, value); in b53_write32()
370 return b53_mdio_write48(dev->bus, page, reg, value); in b53_write48()
376 return b53_mdio_write64(dev->bus, page, reg, value); in b53_write64()
398 return -ETIMEDOUT; in b53_flush_arl()
407 struct b53_device *dev = phydev->priv; in b53_switch_reset()
422 } while (timeout-- > 0); in b53_switch_reset()
425 return -ETIMEDOUT; in b53_switch_reset()
438 return -EINVAL; in b53_switch_reset()
454 struct b53_device *dev = phydev->priv; in b53_enable_cpu_port()
460 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(dev->cpu_port), port_ctrl); in b53_enable_cpu_port()
475 * on a per-port basis such that we only have Port i and IMP in in b53_imp_vlan_setup()
492 struct b53_device *dev = phydev->priv; in b53_port_enable()
493 unsigned int cpu_port = dev->cpu_port; in b53_port_enable()
536 return -ENOMEM; in b53_probe()
540 phydev->priv = dev; in b53_probe()
541 dev->bus = phydev->bus; in b53_probe()
542 dev->cpu_port = CONFIG_B53_CPU_PORT; in b53_probe()
591 phydev->addr = port; in b53_phy_startup()
602 * b53_enable_cpu_port, we cannot be dependent on the user-facing port in b53_phy_startup()
605 phydev->speed = 1000; in b53_phy_startup()
606 phydev->duplex = 1; in b53_phy_startup()
607 phydev->link = 1; in b53_phy_startup()
632 u8 page, offset, width; in do_b53_reg_read() local
633 struct mii_dev *bus; in do_b53_reg_read() local
634 int ret = -EINVAL; in do_b53_reg_read()
640 bus = miiphy_get_dev_by_name(name); in do_b53_reg_read()
641 if (!bus) { in do_b53_reg_read()
642 printf("unable to find MDIO bus: %s\n", name); in do_b53_reg_read()
648 width = simple_strtoul(argv[3], NULL, 10); in do_b53_reg_read()
650 switch (width) { in do_b53_reg_read()
652 ret = b53_mdio_read8(bus, page, offset, &value8); in do_b53_reg_read()
657 ret = b53_mdio_read16(bus, page, offset, &value16); in do_b53_reg_read()
662 ret = b53_mdio_read32(bus, page, offset, &value32); in do_b53_reg_read()
667 ret = b53_mdio_read48(bus, page, offset, &value64); in do_b53_reg_read()
672 ret = b53_mdio_read48(bus, page, offset, &value64); in do_b53_reg_read()
677 printf("Unsupported width: %d\n", width); in do_b53_reg_read()
686 u8 page, offset, width; in do_b53_reg_write() local
687 struct mii_dev *bus; in do_b53_reg_write() local
688 int ret = -EINVAL; in do_b53_reg_write()
692 bus = miiphy_get_dev_by_name(name); in do_b53_reg_write()
693 if (!bus) { in do_b53_reg_write()
694 printf("unable to find MDIO bus: %s\n", name); in do_b53_reg_write()
700 width = simple_strtoul(argv[3], NULL, 10); in do_b53_reg_write()
701 if (width == 48 || width == 64) in do_b53_reg_write()
706 switch (width) { in do_b53_reg_write()
708 ret = b53_mdio_write8(bus, page, offset, value & 0xff); in do_b53_reg_write()
711 ret = b53_mdio_write16(bus, page, offset, value); in do_b53_reg_write()
714 ret = b53_mdio_write32(bus, page, offset, value); in do_b53_reg_write()
717 ret = b53_mdio_write48(bus, page, offset, value64); in do_b53_reg_write()
720 ret = b53_mdio_write64(bus, page, offset, value64); in do_b53_reg_write()
723 printf("Unsupported width: %d\n", width); in do_b53_reg_write()
739 --argc; in do_b53_reg()
746 --argc; in do_b53_reg()
753 --argc; in do_b53_reg()
765 "write mdioname page (hex) offset (hex) width (dec) value (hex)\n"
766 "read mdioname page (hex) offset (hex) width (dec)\n"