Lines Matching +full:0 +full:- +full:mdio
1 // SPDX-License-Identifier: GPL-2.0
9 #define USB_MARVELL_VID 0x1286
12 { USB_DEVICE(USB_MARVELL_VID, 0x1fa4) },
27 struct mii_bus *mdio; member
32 static int mvusb_mdio_read(struct mii_bus *mdio, int dev, int reg) in mvusb_mdio_read() argument
34 struct mvusb_mdio *mvusb = mdio->priv; in mvusb_mdio_read()
38 return -EOPNOTSUPP; in mvusb_mdio_read()
40 mvusb->buf[MVUSB_CMD_ADDR] = cpu_to_le16(0xa400 | (dev << 5) | reg); in mvusb_mdio_read()
42 err = usb_bulk_msg(mvusb->udev, usb_sndbulkpipe(mvusb->udev, 2), in mvusb_mdio_read()
43 mvusb->buf, 6, &alen, 100); in mvusb_mdio_read()
47 err = usb_bulk_msg(mvusb->udev, usb_rcvbulkpipe(mvusb->udev, 6), in mvusb_mdio_read()
48 &mvusb->buf[MVUSB_CMD_VAL], 2, &alen, 100); in mvusb_mdio_read()
52 return le16_to_cpu(mvusb->buf[MVUSB_CMD_VAL]); in mvusb_mdio_read()
55 static int mvusb_mdio_write(struct mii_bus *mdio, int dev, int reg, u16 val) in mvusb_mdio_write() argument
57 struct mvusb_mdio *mvusb = mdio->priv; in mvusb_mdio_write()
61 return -EOPNOTSUPP; in mvusb_mdio_write()
63 mvusb->buf[MVUSB_CMD_ADDR] = cpu_to_le16(0x8000 | (dev << 5) | reg); in mvusb_mdio_write()
64 mvusb->buf[MVUSB_CMD_VAL] = cpu_to_le16(val); in mvusb_mdio_write()
66 return usb_bulk_msg(mvusb->udev, usb_sndbulkpipe(mvusb->udev, 2), in mvusb_mdio_write()
67 mvusb->buf, 8, &alen, 100); in mvusb_mdio_write()
73 struct device *dev = &interface->dev; in mvusb_mdio_probe()
75 struct mii_bus *mdio; in mvusb_mdio_probe() local
78 mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb)); in mvusb_mdio_probe()
79 if (!mdio) in mvusb_mdio_probe()
80 return -ENOMEM; in mvusb_mdio_probe()
82 mvusb = mdio->priv; in mvusb_mdio_probe()
83 mvusb->mdio = mdio; in mvusb_mdio_probe()
84 mvusb->udev = usb_get_dev(interface_to_usbdev(interface)); in mvusb_mdio_probe()
87 mvusb->buf[MVUSB_CMD_PREAMBLE0] = cpu_to_le16(0xe800); in mvusb_mdio_probe()
88 mvusb->buf[MVUSB_CMD_PREAMBLE1] = cpu_to_le16(0x0001); in mvusb_mdio_probe()
90 snprintf(mdio->id, MII_BUS_ID_SIZE, "mvusb-%s", dev_name(dev)); in mvusb_mdio_probe()
91 mdio->name = mdio->id; in mvusb_mdio_probe()
92 mdio->parent = dev; in mvusb_mdio_probe()
93 mdio->read = mvusb_mdio_read; in mvusb_mdio_probe()
94 mdio->write = mvusb_mdio_write; in mvusb_mdio_probe()
97 ret = of_mdiobus_register(mdio, dev->of_node); in mvusb_mdio_probe()
101 return 0; in mvusb_mdio_probe()
104 usb_put_dev(mvusb->udev); in mvusb_mdio_probe()
111 struct usb_device *udev = mvusb->udev; in mvusb_mdio_disconnect()
113 mdiobus_unregister(mvusb->mdio); in mvusb_mdio_disconnect()
128 MODULE_DESCRIPTION("Marvell USB MDIO Adapter");