xref: /openbmc/linux/drivers/net/usb/aqc111.c (revision 7cea2d40afd05375d521a0f8e17dec1c1b5806b2)
117364b80SDmitry Bezrukov // SPDX-License-Identifier: GPL-2.0-or-later
217364b80SDmitry Bezrukov /* Aquantia Corp. Aquantia AQtion USB to 5GbE Controller
317364b80SDmitry Bezrukov  * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
417364b80SDmitry Bezrukov  * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
517364b80SDmitry Bezrukov  * Copyright (C) 2002-2003 TiVo Inc.
617364b80SDmitry Bezrukov  * Copyright (C) 2017-2018 ASIX
717364b80SDmitry Bezrukov  * Copyright (C) 2018 Aquantia Corp.
817364b80SDmitry Bezrukov  */
917364b80SDmitry Bezrukov 
1017364b80SDmitry Bezrukov #include <linux/module.h>
1117364b80SDmitry Bezrukov #include <linux/netdevice.h>
1217364b80SDmitry Bezrukov #include <linux/mii.h>
1317364b80SDmitry Bezrukov #include <linux/usb.h>
1417364b80SDmitry Bezrukov #include <linux/usb/cdc.h>
1517364b80SDmitry Bezrukov #include <linux/usb/usbnet.h>
1617364b80SDmitry Bezrukov 
17*7cea2d40SDmitry Bezrukov static const struct net_device_ops aqc111_netdev_ops = {
18*7cea2d40SDmitry Bezrukov 	.ndo_open		= usbnet_open,
19*7cea2d40SDmitry Bezrukov 	.ndo_stop		= usbnet_stop,
20*7cea2d40SDmitry Bezrukov };
21*7cea2d40SDmitry Bezrukov 
22*7cea2d40SDmitry Bezrukov static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
23*7cea2d40SDmitry Bezrukov {
24*7cea2d40SDmitry Bezrukov 	struct usb_device *udev = interface_to_usbdev(intf);
25*7cea2d40SDmitry Bezrukov 	int ret;
26*7cea2d40SDmitry Bezrukov 
27*7cea2d40SDmitry Bezrukov 	/* Check if vendor configuration */
28*7cea2d40SDmitry Bezrukov 	if (udev->actconfig->desc.bConfigurationValue != 1) {
29*7cea2d40SDmitry Bezrukov 		usb_driver_set_configuration(udev, 1);
30*7cea2d40SDmitry Bezrukov 		return -ENODEV;
31*7cea2d40SDmitry Bezrukov 	}
32*7cea2d40SDmitry Bezrukov 
33*7cea2d40SDmitry Bezrukov 	usb_reset_configuration(dev->udev);
34*7cea2d40SDmitry Bezrukov 
35*7cea2d40SDmitry Bezrukov 	ret = usbnet_get_endpoints(dev, intf);
36*7cea2d40SDmitry Bezrukov 	if (ret < 0) {
37*7cea2d40SDmitry Bezrukov 		netdev_dbg(dev->net, "usbnet_get_endpoints failed");
38*7cea2d40SDmitry Bezrukov 		return ret;
39*7cea2d40SDmitry Bezrukov 	}
40*7cea2d40SDmitry Bezrukov 
41*7cea2d40SDmitry Bezrukov 	dev->net->netdev_ops = &aqc111_netdev_ops;
42*7cea2d40SDmitry Bezrukov 
43*7cea2d40SDmitry Bezrukov 	return 0;
44*7cea2d40SDmitry Bezrukov }
45*7cea2d40SDmitry Bezrukov 
46*7cea2d40SDmitry Bezrukov static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
47*7cea2d40SDmitry Bezrukov {
48*7cea2d40SDmitry Bezrukov }
49*7cea2d40SDmitry Bezrukov 
5017364b80SDmitry Bezrukov static const struct driver_info aqc111_info = {
5117364b80SDmitry Bezrukov 	.description	= "Aquantia AQtion USB to 5GbE Controller",
52*7cea2d40SDmitry Bezrukov 	.bind		= aqc111_bind,
53*7cea2d40SDmitry Bezrukov 	.unbind		= aqc111_unbind,
5417364b80SDmitry Bezrukov };
5517364b80SDmitry Bezrukov 
5617364b80SDmitry Bezrukov #define AQC111_USB_ETH_DEV(vid, pid, table) \
5717364b80SDmitry Bezrukov 	USB_DEVICE_INTERFACE_CLASS((vid), (pid), USB_CLASS_VENDOR_SPEC), \
5817364b80SDmitry Bezrukov 	.driver_info = (unsigned long)&(table) \
5917364b80SDmitry Bezrukov }, \
6017364b80SDmitry Bezrukov { \
6117364b80SDmitry Bezrukov 	USB_DEVICE_AND_INTERFACE_INFO((vid), (pid), \
6217364b80SDmitry Bezrukov 				      USB_CLASS_COMM, \
6317364b80SDmitry Bezrukov 				      USB_CDC_SUBCLASS_ETHERNET, \
6417364b80SDmitry Bezrukov 				      USB_CDC_PROTO_NONE), \
6517364b80SDmitry Bezrukov 	.driver_info = (unsigned long)&(table),
6617364b80SDmitry Bezrukov 
6717364b80SDmitry Bezrukov static const struct usb_device_id products[] = {
6817364b80SDmitry Bezrukov 	{AQC111_USB_ETH_DEV(0x2eca, 0xc101, aqc111_info)},
6917364b80SDmitry Bezrukov 	{ },/* END */
7017364b80SDmitry Bezrukov };
7117364b80SDmitry Bezrukov MODULE_DEVICE_TABLE(usb, products);
7217364b80SDmitry Bezrukov 
7317364b80SDmitry Bezrukov static struct usb_driver aq_driver = {
7417364b80SDmitry Bezrukov 	.name		= "aqc111",
7517364b80SDmitry Bezrukov 	.id_table	= products,
7617364b80SDmitry Bezrukov 	.probe		= usbnet_probe,
7717364b80SDmitry Bezrukov 	.disconnect	= usbnet_disconnect,
7817364b80SDmitry Bezrukov };
7917364b80SDmitry Bezrukov 
8017364b80SDmitry Bezrukov module_usb_driver(aq_driver);
8117364b80SDmitry Bezrukov 
8217364b80SDmitry Bezrukov MODULE_DESCRIPTION("Aquantia AQtion USB to 5/2.5GbE Controllers");
8317364b80SDmitry Bezrukov MODULE_LICENSE("GPL");
84