usb: dwc3: debugfs: Add suppot for Enabling L1 in HS through debugfs

Currently the kernel implementation disables L1 in HS since
there are target which does not support gadget L1.
However, implementing this leads to Ch9 compliance
failures.
Therefore implementing a debugfs parameter through which
this can be controlled, when testing for compliance it can
be set to true and carry out the tests.

Change-Id: I9cf9c49737b18ca889fcc1dbe8232a7bb999f35c
Signed-off-by: Udipto Goswami <ugoswami@codeaurora.org>
This commit is contained in:
Udipto Goswami 2021-08-03 20:55:05 +05:30 • committed by Gerrit - the friendly Code Review server
commit 759851525d

View file

@ -1227,6 +1227,51 @@ static const struct file_operations dwc3_gadget_int_events_fops = {
.release = single_release,
};
static ssize_t dwc3_gadget_l1_store(struct file *file,
const char __user *ubuf, size_t count, loff_t *ppos)
{
struct seq_file *s = file->private_data;
struct dwc3 *dwc = s->private;
bool enable_l1;
int ret;
ret = kstrtobool_from_user(ubuf, count, &enable_l1);
if (ret < 0) {
dev_err(dwc->dev, "%s: can't get entered value: %d\n",
__func__, ret);
return ret;
}
dwc->gadget.lpm_capable = enable_l1;
dwc->usb2_gadget_lpm_disable = !enable_l1;
pr_info("dwc3 gadget lpm : %s. Perform a plugout/plugin\n",
enable_l1 ? "enabled" : "disabled");
return count;
}
static int dwc3_gadget_l1_status_show(struct seq_file *s, void *unused)
{
struct dwc3 *dwc = s->private;
seq_printf(s, "%d\n", dwc->gadget.lpm_capable);
return 0;
}
static int dwc3_gadget_l1_open(struct inode *inode, struct file *f)
{
return single_open(f, dwc3_gadget_l1_status_show, inode->i_private);
}
static const struct file_operations dwc3_l1_enable_ops = {
.open = dwc3_gadget_l1_open,
.write = dwc3_gadget_l1_store,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
void dwc3_debugfs_init(struct dwc3 *dwc)
{
struct dentry *root;
@ -1255,6 +1300,8 @@ void dwc3_debugfs_init(struct dwc3 *dwc)
debugfs_create_file("lsp_dump", S_IRUGO | S_IWUSR, root, dwc,
&dwc3_lsp_fops);
debugfs_create_file("enable_l1_suspend", 0644, root, dwc,
&dwc3_l1_enable_ops);
if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) {
debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, dwc,