Lines Matching +full:autosuspend +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
10 * See i2400m-usb.h for a general description of this driver.
13 * generic driver to implement the bus-specific functions (device
51 #include "i2400m-usb.h"
59 #include "usb-debug-levels.h"
65 "String of space-separated NAME:VALUE pairs, where NAMEs "
71 #define I2400MU_FW_FILE_NAME_v1_5 "i2400m-fw-usb-1.5.sbcf"
73 #define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
80 #define I6050U_FW_FILE_NAME_v1_5 "i6050-fw-usb-1.5.sbcf"
91 struct device *dev = &i2400mu->usb_iface->dev; in i2400mu_bus_dev_start()
120 struct device *dev = &i2400mu->usb_iface->dev; in i2400mu_bus_dev_stop()
138 * and will move the reset code to use a last-resort bus-based reset.
148 struct device *dev = &i2400mu->usb_iface->dev; in __i2400mu_send_barker()
152 ret = usb_autopm_get_interface(i2400mu->usb_iface); in __i2400mu_send_barker()
157 ret = -ENOMEM; in __i2400mu_send_barker()
161 epd = usb_get_epd(i2400mu->usb_iface, endpoint); in __i2400mu_send_barker()
162 pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress); in __i2400mu_send_barker()
165 ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size, in __i2400mu_send_barker()
173 ret = -EIO; in __i2400mu_send_barker()
176 case -EPIPE: in __i2400mu_send_barker()
178 * Stall -- maybe the device is choking with our in __i2400mu_send_barker()
187 if (edc_inc(&i2400mu->urb_edc, in __i2400mu_send_barker()
191 usb_queue_reset_device(i2400mu->usb_iface); in __i2400mu_send_barker()
194 usb_clear_halt(i2400mu->usb_dev, pipe); in __i2400mu_send_barker()
199 case -EINVAL: /* while removing driver */ in __i2400mu_send_barker()
200 case -ENODEV: /* dev disconnect ... */ in __i2400mu_send_barker()
201 case -ENOENT: /* just ignore it */ in __i2400mu_send_barker()
202 case -ESHUTDOWN: /* and exit */ in __i2400mu_send_barker()
203 case -ECONNRESET: in __i2400mu_send_barker()
204 ret = -ESHUTDOWN; in __i2400mu_send_barker()
207 if (edc_inc(&i2400mu->urb_edc, in __i2400mu_send_barker()
212 usb_queue_reset_device(i2400mu->usb_iface); in __i2400mu_send_barker()
222 usb_autopm_put_interface(i2400mu->usb_iface); in __i2400mu_send_barker()
254 * Note we need to return -ENODEV if a warm reset was requested and we
256 * and wimax_dev->op_reset.
285 i2400mu->endpoint_cfg.bulk_out); in i2400mu_bus_reset()
290 i2400mu->endpoint_cfg.reset_cold); in i2400mu_bus_reset()
292 result = usb_reset_device(i2400mu->usb_dev); in i2400mu_bus_reset()
295 case -EINVAL: /* device is gone */ in i2400mu_bus_reset()
296 case -ENODEV: in i2400mu_bus_reset()
297 case -ENOENT: in i2400mu_bus_reset()
298 case -ESHUTDOWN: in i2400mu_bus_reset()
306 result = -EINVAL; /* shut gcc up in certain arches */ in i2400mu_bus_reset()
310 && result != -EINVAL /* device is gone */ in i2400mu_bus_reset()
313 * Things failed -- resort to lower level reset, that in i2400mu_bus_reset()
316 * the i2400m->init_mutex; RT_WARM and RT_COLD can in i2400mu_bus_reset()
317 * come from areas where i2400m->init_mutex is taken. in i2400mu_bus_reset()
321 usb_queue_reset_device(i2400mu->usb_iface); in i2400mu_bus_reset()
322 result = -ENODEV; in i2400mu_bus_reset()
333 struct usb_device *udev = i2400mu->usb_dev; in i2400mu_get_drvinfo()
335 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); in i2400mu_get_drvinfo()
336 strlcpy(info->fw_version, i2400m->fw_name ? : "", in i2400mu_get_drvinfo()
337 sizeof(info->fw_version)); in i2400mu_get_drvinfo()
338 usb_make_path(udev, info->bus_info, sizeof(info->bus_info)); in i2400mu_get_drvinfo()
353 net_dev->ethtool_ops = &i2400mu_ethtool_ops; in i2400mu_netdev_setup()
372 struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry; in i2400mu_debugfs_add()
374 dentry = debugfs_create_dir("i2400m-usb", dentry); in i2400mu_debugfs_add()
375 i2400mu->debugfs_dentry = dentry; in i2400mu_debugfs_add()
385 &i2400mu->rx_size_auto_shrink); in i2400mu_debugfs_add()
387 debugfs_create_size_t("rx_size", 0600, dentry, &i2400mu->rx_size); in i2400mu_debugfs_add()
402 * Alloc a net device, initialize the bus-specific details and then
403 * calls the bus-generic initialization routine. That will register
415 struct device *dev = &iface->dev; in i2400mu_probe()
420 if (iface->cur_altsetting->desc.bNumEndpoints < 4) in i2400mu_probe()
421 return -ENODEV; in i2400mu_probe()
423 if (usb_dev->speed != USB_SPEED_HIGH) in i2400mu_probe()
427 result = -ENOMEM; in i2400mu_probe()
438 i2400m->wimax_dev.net_dev = net_dev; in i2400mu_probe()
439 i2400mu->usb_dev = usb_get_dev(usb_dev); in i2400mu_probe()
440 i2400mu->usb_iface = iface; in i2400mu_probe()
443 i2400m->bus_tx_block_size = I2400MU_BLK_SIZE; in i2400mu_probe()
450 i2400m->bus_tx_room_min = I2400MU_BLK_SIZE; in i2400mu_probe()
451 i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX; in i2400mu_probe()
452 i2400m->bus_setup = NULL; in i2400mu_probe()
453 i2400m->bus_dev_start = i2400mu_bus_dev_start; in i2400mu_probe()
454 i2400m->bus_dev_stop = i2400mu_bus_dev_stop; in i2400mu_probe()
455 i2400m->bus_release = NULL; in i2400mu_probe()
456 i2400m->bus_tx_kick = i2400mu_bus_tx_kick; in i2400mu_probe()
457 i2400m->bus_reset = i2400mu_bus_reset; in i2400mu_probe()
458 i2400m->bus_bm_retries = I2400M_USB_BOOT_RETRIES; in i2400mu_probe()
459 i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send; in i2400mu_probe()
460 i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack; in i2400mu_probe()
461 i2400m->bus_bm_mac_addr_impaired = 0; in i2400mu_probe()
463 switch (id->idProduct) { in i2400mu_probe()
470 i2400mu->i6050 = 1; in i2400mu_probe()
476 if (i2400mu->i6050) { in i2400mu_probe()
477 i2400m->bus_fw_names = i2400mu_bus_fw_names_6050; in i2400mu_probe()
478 i2400mu->endpoint_cfg.bulk_out = 0; in i2400mu_probe()
479 i2400mu->endpoint_cfg.notification = 3; in i2400mu_probe()
480 i2400mu->endpoint_cfg.reset_cold = 2; in i2400mu_probe()
481 i2400mu->endpoint_cfg.bulk_in = 1; in i2400mu_probe()
483 i2400m->bus_fw_names = i2400mu_bus_fw_names_5x50; in i2400mu_probe()
484 i2400mu->endpoint_cfg.bulk_out = 0; in i2400mu_probe()
485 i2400mu->endpoint_cfg.notification = 1; in i2400mu_probe()
486 i2400mu->endpoint_cfg.reset_cold = 2; in i2400mu_probe()
487 i2400mu->endpoint_cfg.bulk_in = 3; in i2400mu_probe()
490 iface->needs_remote_wakeup = 1; /* autosuspend (15s delay) */ in i2400mu_probe()
492 pm_runtime_set_autosuspend_delay(&usb_dev->dev, 15000); in i2400mu_probe()
506 usb_put_dev(i2400mu->usb_dev); in i2400mu_probe()
524 struct i2400m *i2400m = &i2400mu->i2400m; in i2400mu_disconnect()
525 struct net_device *net_dev = i2400m->wimax_dev.net_dev; in i2400mu_disconnect()
526 struct device *dev = &iface->dev; in i2400mu_disconnect()
530 debugfs_remove_recursive(i2400mu->debugfs_dentry); in i2400mu_disconnect()
533 usb_put_dev(i2400mu->usb_dev); in i2400mu_disconnect()
554 * i2400m->updown under i2400m->init_mutex. If it happens to change
560 * - tell the device to go into host interface power save mode, wait
564 * command, but this time, we don't want the code in usb-{tx,rx}.c
566 * deadlock, so we need to decrement i2400mu->do_autopm, that acts
575 * - stop the notification endpoint polling
581 struct device *dev = &iface->dev; in i2400mu_suspend()
584 struct i2400m *i2400m = &i2400mu->i2400m; in i2400mu_suspend()
592 rmb(); /* see i2400m->updown's documentation */ in i2400mu_suspend()
593 if (i2400m->updown == 0) in i2400mu_suspend()
595 if (i2400m->state == I2400M_SS_DATA_PATH_CONNECTED && is_autosuspend) { in i2400mu_suspend()
596 /* ugh -- the device is connected and this suspend in i2400mu_suspend()
597 * request is an autosuspend one (not a system standby in i2400mu_suspend()
607 * autosuspend thing, say no and it'll come back in i2400mu_suspend()
610 result = -EBADF; in i2400mu_suspend()
611 d_printf(1, dev, "fw up, link up, not-idle, autosuspend: " in i2400mu_suspend()
616 atomic_dec(&i2400mu->do_autopm); in i2400mu_suspend()
618 atomic_inc(&i2400mu->do_autopm); in i2400mu_suspend()
641 struct device *dev = &iface->dev; in i2400mu_resume()
643 struct i2400m *i2400m = &i2400mu->i2400m; in i2400mu_resume()
646 rmb(); /* see i2400m->updown's documentation */ in i2400mu_resume()
647 if (i2400m->updown == 0) { in i2400mu_resume()
654 * come back; otherwise, we'd use something like a get-state in i2400mu_resume()
666 struct device *dev = &iface->dev; in i2400mu_reset_resume()
668 struct i2400m *i2400m = &i2400mu->i2400m; in i2400mu_reset_resume()
689 return i2400m_pre_reset(&i2400mu->i2400m); in i2400mu_pre_reset()
704 return i2400m_post_reset(&i2400mu->i2400m); in i2400mu_post_reset()
759 MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");