// SPDX-License-Identifier: GPL-2.0+ /* * zero.c -- Gadget Zero, for USB development * * Copyright (C) 2003-2008 David Brownell * Copyright (C) 2008 by Nokia Corporation
*/
/* * Gadget Zero only needs two bulk endpoints, and is an example of how you * can write a hardware-agnostic gadget driver running inside a USB device. * Some hardware details are visible, but don't affect most of the driver. * * Use it with the Linux host side "usbtest" driver to get a basic functional * test of your device-side usb stack, or with "usb-skeleton". * * It supports two similar configurations. One sinks whatever the usb host * writes, and in return sources zeroes. The other loops whatever the host * writes back, so the host can read it. * * Many drivers will only have one configuration, letting them be much * simpler if they also don't support high speed operation (like this * driver does). * * Why is *this* driver using two configurations, rather than setting up * two interfaces with different functions? To help verify that multiple * configuration infrastructure is working correctly; also, so that it can * work with low capability USB controllers without four bulk endpoints.
*/
/* * driver assumes self-powered hardware, and * has no way for users to trigger remote wakeup.
*/
/* * Normally the "loopback" configuration is second (index 1) so * it's not the default. Here's where to change that order, to * work better with hosts where config changes are problematic or * controllers (like original superh) that only support one config.
*/ staticbool loopdefault = 0;
module_param(loopdefault, bool, S_IRUGO|S_IWUSR);
/* Thanks to NetChip Technologies for donating this product ID. * * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! * Instead: allocate your own, using normal USB-IF procedures.
*/ #ifndef CONFIG_USB_ZERO_HNPTEST #define DRIVER_VENDOR_NUM 0x0525 /* NetChip */ #define DRIVER_PRODUCT_NUM 0xa4a0 /* Linux-USB "Gadget Zero" */ #define DEFAULT_AUTORESUME 0 #else #define DRIVER_VENDOR_NUM 0x1a0a /* OTG test device IDs */ #define DRIVER_PRODUCT_NUM 0xbadd #define DEFAULT_AUTORESUME 5 #endif
/* If the optional "autoresume" mode is enabled, it provides good * functional coverage for the "USBCV" test harness from USB-IF. * It's always set if OTG mode is enabled.
*/ staticunsigned autoresume = DEFAULT_AUTORESUME;
module_param(autoresume, uint, S_IRUGO);
MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
/* Maximum Autoresume time */ staticunsigned max_autoresume;
module_param(max_autoresume, uint, S_IRUGO);
MODULE_PARM_DESC(max_autoresume, "maximum seconds before remote wakeup");
/* Interval between two remote wakeups */ staticunsigned autoresume_interval_ms;
module_param(autoresume_interval_ms, uint, S_IRUGO);
MODULE_PARM_DESC(autoresume_interval_ms, "milliseconds to increase successive wakeup delays");
/* string IDs are assigned dynamically */ /* default serial number takes at least two packets */ staticchar serial[] = "0123456789.0123456789.0123456789";
/* unconfigured devices can't issue wakeups */ if (!cdev->config) return;
/* Normally the host would be woken up for something * more significant than just a timer firing; likely * because of some direct user request.
*/ if (g->speed != USB_SPEED_UNKNOWN) { int status = usb_gadget_wakeup(g);
INFO(cdev, "%s --> %d\n", __func__, status);
}
}
staticvoid zero_suspend(struct usb_composite_dev *cdev)
{ if (cdev->gadget->speed == USB_SPEED_UNKNOWN) return;
if (autoresume) { if (max_autoresume &&
(autoresume_step_ms > max_autoresume * 1000))
autoresume_step_ms = autoresume * 1000;
module_param_named(qlen, gzero_options.qlen, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(qlen, "depth of loopback queue");
module_param_named(ss_bulk_qlen, gzero_options.ss_bulk_qlen, uint,
S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(bulk_qlen, "depth of sourcesink queue for bulk transfer");
module_param_named(ss_iso_qlen, gzero_options.ss_iso_qlen, uint,
S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(iso_qlen, "depth of sourcesink queue for iso transfer");
/* Allocate string descriptor numbers ... note that string * contents can be overridden by the composite_dev glue.
*/
status = usb_string_ids_tab(cdev, strings_dev); if (status < 0) return status;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.