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()
37 mvusb->buf[MVUSB_CMD_ADDR] = cpu_to_le16(0xa400 | (dev << 5) | reg); in mvusb_mdio_read()
39 err = usb_bulk_msg(mvusb->udev, usb_sndbulkpipe(mvusb->udev, 2), in mvusb_mdio_read()
40 mvusb->buf, 6, &alen, 100); in mvusb_mdio_read()
44 err = usb_bulk_msg(mvusb->udev, usb_rcvbulkpipe(mvusb->udev, 6), in mvusb_mdio_read()
45 &mvusb->buf[MVUSB_CMD_VAL], 2, &alen, 100); in mvusb_mdio_read()
49 return le16_to_cpu(mvusb->buf[MVUSB_CMD_VAL]); in mvusb_mdio_read()
52 static int mvusb_mdio_write(struct mii_bus *mdio, int dev, int reg, u16 val) in mvusb_mdio_write() argument
54 struct mvusb_mdio *mvusb = mdio->priv; in mvusb_mdio_write()
57 mvusb->buf[MVUSB_CMD_ADDR] = cpu_to_le16(0x8000 | (dev << 5) | reg); in mvusb_mdio_write()
58 mvusb->buf[MVUSB_CMD_VAL] = cpu_to_le16(val); in mvusb_mdio_write()
60 return usb_bulk_msg(mvusb->udev, usb_sndbulkpipe(mvusb->udev, 2), in mvusb_mdio_write()
61 mvusb->buf, 8, &alen, 100); in mvusb_mdio_write()
67 struct device *dev = &interface->dev; in mvusb_mdio_probe()
69 struct mii_bus *mdio; in mvusb_mdio_probe() local
72 mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb)); in mvusb_mdio_probe()
73 if (!mdio) in mvusb_mdio_probe()
74 return -ENOMEM; in mvusb_mdio_probe()
76 mvusb = mdio->priv; in mvusb_mdio_probe()
77 mvusb->mdio = mdio; in mvusb_mdio_probe()
78 mvusb->udev = usb_get_dev(interface_to_usbdev(interface)); in mvusb_mdio_probe()
81 mvusb->buf[MVUSB_CMD_PREAMBLE0] = cpu_to_le16(0xe800); in mvusb_mdio_probe()
82 mvusb->buf[MVUSB_CMD_PREAMBLE1] = cpu_to_le16(0x0001); in mvusb_mdio_probe()
84 snprintf(mdio->id, MII_BUS_ID_SIZE, "mvusb-%s", dev_name(dev)); in mvusb_mdio_probe()
85 mdio->name = mdio->id; in mvusb_mdio_probe()
86 mdio->parent = dev; in mvusb_mdio_probe()
87 mdio->read = mvusb_mdio_read; in mvusb_mdio_probe()
88 mdio->write = mvusb_mdio_write; in mvusb_mdio_probe()
91 ret = of_mdiobus_register(mdio, dev->of_node); in mvusb_mdio_probe()
95 return 0; in mvusb_mdio_probe()
98 usb_put_dev(mvusb->udev); in mvusb_mdio_probe()
105 struct usb_device *udev = mvusb->udev; in mvusb_mdio_disconnect()
107 mdiobus_unregister(mvusb->mdio); in mvusb_mdio_disconnect()
122 MODULE_DESCRIPTION("Marvell USB MDIO Adapter");