diff options
author | Zhangfei Gao <zhangfei.gao@linaro.org> | 2015-02-04 14:59:21 +0800 |
---|---|---|
committer | Fei Wang <w.f@huawei.com> | 2015-02-06 12:57:47 +0800 |
commit | ab1c6fb74a9cd111df246aeaeefd03731c0f9b44 (patch) | |
tree | 91fe5a3623b3f162b3e681e95265605ebb7d8eaa | |
parent | 797cb4b0af5aa3e75edc4c9f4258a13f56233160 (diff) |
usb: dwc2: method of switching usb speed
1, hardware feature
high speed:
host A only support high speed, does not support keyboard/mouse
otg host support all speed, including keyboard/mouse
full speed:
Both host A and otg host only support full/low speed.
2. If user want to support full speed.
mount -t debugfs none /mnt
cd /mnt/f72c0000.usb/
cat config
echo 1 > config /* switch to full speed */
echo 0 > config /* switch to high speed */
Then unplug usb, host mode will switch to full speed, all ports don't support high speed in host mode.
Every time switch speed, just need plug usb -> unplug usb.
For example:
mount -t debugfs none /mnt
cd /mnt/f72c0000.usb/
cat config
input para should be:
0, HIGH speed;
1, FULL speed
Current speed=0: HIGH speed
If unplug usb and insert mouse now, it will fail.
usb 1-1-port1: unable to enumerate USB device
echo 1 > config
Current speed=1: FULL speed
cat config
input para should be:
0, HIGH speed;
1, FULL speed
Current speed=1: FULL speed
If unplug usb and insert mouse now
usb 1-1.1: new low-speed USB device number 8 using dwc2
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
-rw-r--r-- | drivers/usb/dwc2/core.h | 1 | ||||
-rw-r--r-- | drivers/usb/dwc2/gadget.c | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index f74304b12652..0664631fed5b 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -616,6 +616,7 @@ struct dwc2_hsotg { struct dentry *debug_file; struct dentry *debug_testmode; struct dentry *debug_fifo; + struct dentry *debug_config; /* DWC OTG HW Release versions */ #define DWC2_CORE_REV_2_71a 0x4f54271a diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 364cd9614fe7..7818b32f0bbc 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3689,6 +3689,41 @@ static const struct file_operations ep_fops = { .release = single_release, }; +static int config_fops_get(void *data, u64 *speed) +{ + struct dwc2_hsotg *hsotg = data; + + pr_info("input para should be:\n 0, HIGH speed;\n 1, FULL speed\n"); + if (hsotg->core_params->speed) + pr_info("Current speed=%d: FULL speed\n", + hsotg->core_params->speed); + else + pr_info("Current speed=%d: HIGH speed\n", + hsotg->core_params->speed); + *speed = hsotg->core_params->speed; + + return 0; +}; + +static int config_fops_set(void *data, u64 speed) +{ + struct dwc2_hsotg *hsotg = data; + + if (hsotg->core_params->speed != speed) + hsotg->core_params->speed = speed; + + if (hsotg->core_params->speed) + pr_info("Current speed=%d: FULL speed\n", + hsotg->core_params->speed); + else + pr_info("Current speed=%d: HIGH speed\n", + hsotg->core_params->speed); + return 0; +}; + +DEFINE_SIMPLE_ATTRIBUTE(config_fops, config_fops_get, + config_fops_set, "%llu\n"); + /** * s3c_hsotg_create_debug - create debugfs directory and files * @hsotg: The driver state @@ -3712,6 +3747,12 @@ static void s3c_hsotg_create_debug(struct dwc2_hsotg *hsotg) /* create general state file */ + hsotg->debug_config = debugfs_create_file("config", S_IWUSR | S_IRUGO, + root, hsotg, &config_fops); + + if (IS_ERR(hsotg->debug_config)) + dev_err(hsotg->dev, "%s: failed to create config\n", __func__); + hsotg->debug_file = debugfs_create_file("state", S_IRUGO, root, hsotg, &state_fops); @@ -3781,6 +3822,7 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg *hsotg) debugfs_remove(hsotg->debug_file); debugfs_remove(hsotg->debug_testmode); + debugfs_remove(hsotg->debug_config); debugfs_remove(hsotg->debug_fifo); debugfs_remove(hsotg->debug_root); } |