69 #include <linux/slab.h>
70 #include <linux/module.h>
73 #define D_SUBMODULE usb
76 static char i2400mu_debug_params[128];
80 "String of space-separated NAME:VALUE pairs, where NAMEs "
81 "are the different debug submodules and VALUE are the "
82 "initial debug value to set.");
85 static const char *i2400mu_bus_fw_names_5x50[] = {
86 #define I2400MU_FW_FILE_NAME_v1_5 "i2400m-fw-usb-1.5.sbcf"
88 #define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
94 static const char *i2400mu_bus_fw_names_6050[] = {
95 #define I6050U_FW_FILE_NAME_v1_5 "i6050-fw-usb-1.5.sbcf"
108 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
111 goto error_usb_tx_setup;
114 goto error_usb_rx_setup;
117 goto error_notif_setup;
118 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
126 d_fnend(3, dev,
"(i2400m %p) = void\n", i2400m);
132 void i2400mu_bus_dev_stop(
struct i2400m *i2400m)
134 struct i2400mu *i2400mu =
container_of(i2400m,
struct i2400mu, i2400m);
137 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
141 d_fnend(3, dev,
"(i2400m %p) = void\n", i2400m);
156 int __i2400mu_send_barker(
struct i2400mu *i2400mu,
167 ret = usb_autopm_get_interface(i2400mu->
usb_iface);
169 dev_err(dev,
"RESET: can't get autopm: %d\n", ret);
176 epd = usb_get_epd(i2400mu->
usb_iface, endpoint);
178 memcpy(buffer, barker, barker_size);
184 if (actual_len != barker_size) {
185 dev_err(dev,
"E: %s: short write (%d B vs %zu "
187 __func__, actual_len, barker_size);
204 dev_err(dev,
"E: %s: too many stalls in "
205 "URB; resetting device\n", __func__);
223 dev_err(dev,
"E: %s: maximum errors in URB "
224 "exceeded; resetting device\n",
228 dev_warn(dev,
"W: %s: cannot send URB: %d\n",
236 usb_autopm_put_interface(i2400mu->
usb_iface);
278 struct i2400mu *i2400mu =
280 struct device *dev = i2400m_dev(i2400m);
281 static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
287 static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
294 d_fnstart(3, dev,
"(i2400m %p rt %u)\n", i2400m, rt);
296 result = __i2400mu_send_barker(
297 i2400mu, i2400m_WARM_BOOT_BARKER,
298 sizeof(i2400m_WARM_BOOT_BARKER),
301 result = __i2400mu_send_barker(
302 i2400mu, i2400m_COLD_BOOT_BARKER,
303 sizeof(i2400m_COLD_BOOT_BARKER),
316 dev_err(dev,
"USB reset failed (%d), giving up!\n",
333 dev_err(dev,
"%s reset failed (%d); trying USB reset\n",
338 d_fnend(3, dev,
"(i2400m %p rt %u) = %d\n", i2400m, rt, result);
342 static void i2400mu_get_drvinfo(
struct net_device *net_dev,
345 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
346 struct i2400mu *i2400mu =
container_of(i2400m,
struct i2400mu, i2400m);
355 static const struct ethtool_ops i2400mu_ethtool_ops = {
356 .get_drvinfo = i2400mu_get_drvinfo,
361 void i2400mu_netdev_setup(
struct net_device *net_dev)
363 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
364 struct i2400mu *i2400mu =
container_of(i2400m,
struct i2400mu, i2400m);
365 i2400mu_init(i2400mu);
384 #define __debugfs_register(prefix, name, parent) \
386 result = d_level_register_debugfs(prefix, name, parent); \
393 int i2400mu_debugfs_add(
struct i2400mu *i2400mu)
401 result = PTR_ERR(dentry);
402 if (IS_ERR(dentry)) {
417 result = PTR_ERR(fd);
418 if (IS_ERR(fd) && result != -
ENODEV) {
419 dev_err(dev,
"Can't create debugfs entry "
420 "rx_size_auto_shrink: %d\n", result);
426 result = PTR_ERR(fd);
427 if (IS_ERR(fd) && result != -
ENODEV) {
428 dev_err(dev,
"Can't create debugfs entry "
429 "rx_size: %d\n", result);
465 struct device *dev = &iface->dev;
466 struct i2400m *i2400m;
467 struct i2400mu *i2400mu;
468 struct usb_device *usb_dev = interface_to_usbdev(iface);
471 dev_err(dev,
"device not connected as high speed\n");
476 i2400mu_netdev_setup);
477 if (net_dev ==
NULL) {
478 dev_err(dev,
"no memory for network device instance\n");
479 goto error_alloc_netdev;
483 i2400m = net_dev_to_i2400m(net_dev);
488 usb_set_intfdata(iface, i2400mu);
520 if (i2400mu->
i6050) {
534 iface->needs_remote_wakeup = 1;
537 usb_enable_autosuspend(usb_dev);
542 dev_err(dev,
"cannot setup device: %d\n", result);
545 result = i2400mu_debugfs_add(i2400mu);
547 dev_err(dev,
"Can't register i2400mu's debugfs: %d\n", result);
548 goto error_debugfs_add;
555 usb_set_intfdata(iface,
NULL);
573 struct i2400mu *i2400mu = usb_get_intfdata(iface);
574 struct i2400m *i2400m = &i2400mu->
i2400m;
576 struct device *dev = &iface->dev;
578 d_fnstart(3, dev,
"(iface %p i2400m %p)\n", iface, i2400m);
582 usb_set_intfdata(iface,
NULL);
585 d_fnend(3, dev,
"(iface %p i2400m %p) = void\n", iface, i2400m);
631 struct device *dev = &iface->dev;
632 struct i2400mu *i2400mu = usb_get_intfdata(iface);
633 unsigned is_autosuspend = 0;
634 struct i2400m *i2400m = &i2400mu->
i2400m;
661 d_printf(1, dev,
"fw up, link up, not-idle, autosuspend: "
662 "not entering powersave\n");
665 d_printf(1, dev,
"fw up: entering powersave\n");
669 if (result < 0 && !is_autosuspend) {
671 dev_err(dev,
"failed to suspend, will reset on resume\n");
675 goto error_enter_powersave;
677 d_printf(1, dev,
"powersave requested\n");
678 error_enter_powersave:
681 d_fnend(3, dev,
"(iface %p pm_msg %u) = %d\n",
682 iface, pm_msg.
event, result);
691 struct device *dev = &iface->dev;
692 struct i2400mu *i2400mu = usb_get_intfdata(iface);
693 struct i2400m *i2400m = &i2400mu->
i2400m;
695 d_fnstart(3, dev,
"(iface %p)\n", iface);
697 if (i2400m->
updown == 0) {
698 d_printf(1, dev,
"fw was down, no resume needed\n");
701 d_printf(1, dev,
"fw was up, resuming\n");
707 d_fnend(3, dev,
"(iface %p) = %d\n", iface, ret);
716 struct device *dev = &iface->dev;
717 struct i2400mu *i2400mu = usb_get_intfdata(iface);
718 struct i2400m *i2400m = &i2400mu->
i2400m;
720 d_fnstart(3, dev,
"(iface %p)\n", iface);
722 d_fnend(3, dev,
"(iface %p) = %d\n", iface, result);
723 return result < 0 ? result : 0;
738 struct i2400mu *i2400mu = usb_get_intfdata(iface);
753 struct i2400mu *i2400mu = usb_get_intfdata(iface);
763 { USB_DEVICE(0x8086, 0x0181) },
764 { USB_DEVICE(0x8086, 0x1403) },
765 { USB_DEVICE(0x8086, 0x1405) },
766 { USB_DEVICE(0x8086, 0x0180) },
767 { USB_DEVICE(0x8086, 0x0182) },
768 { USB_DEVICE(0x8086, 0x1406) },
769 { USB_DEVICE(0x8086, 0x1403) },
776 struct usb_driver i2400mu_driver = {
777 .name = KBUILD_MODNAME,
778 .suspend = i2400mu_suspend,
779 .resume = i2400mu_resume,
780 .reset_resume = i2400mu_reset_resume,
781 .probe = i2400mu_probe,
782 .disconnect = i2400mu_disconnect,
783 .pre_reset = i2400mu_pre_reset,
784 .post_reset = i2400mu_post_reset,
785 .id_table = i2400mu_id_table,
786 .supports_autosuspend = 1,
790 int __init i2400mu_driver_init(
void)
792 d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400mu_debug_params,
794 return usb_register(&i2400mu_driver);
800 void __exit i2400mu_driver_exit(
void)