* Re: patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next
[not found] ` <PH0PR11MB4888B9D24A5F90E8AA02B28B81019@PH0PR11MB4888.namprd11.prod.outlook.com>
@ 2021-06-30 10:05 ` Johan Hovold
2021-07-01 4:58 ` Tung Pham
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2021-06-30 10:05 UTC (permalink / raw)
To: Tung Pham; +Cc: gregkh@linuxfoundation.org, Pho Tran, Hung Nguyen, linux-usb
Hi Tung,
On Wed, Jun 30, 2021 at 08:58:29AM +0000, Tung Pham wrote:
First, thanks for testing the patch.
Please make sure to CC the usb list when reporting problems. I've added
it to CC now.
> When I test the apply patch with Linux kernel.
> https://github.com/torvalds/linux/blob/master/drivers/usb/serial/cp210x.c
>
> when I setting the CP2108 with GPIO 0 and GPIO 1 are alternative
> functions (not GPIO) using simplicity studio.
> And then test with the driver, it shows:
> root@ubuntu:/sys/class/gpio# ls
> export gpiochip496 unexport
> root@ubuntu:/sys/class/gpio# echo 496 > /sys/class/gpio/export
> bash: echo: write error: No such device
> root@ubuntu:/sys/class/gpio# echo 497 > /sys/class/gpio/export
> bash: echo: write error: No such device
> This is what we expected because the GPIO 0 and GPIO 1 are alternative
> functions (not GPIO).
Are you sure you're using the latest mainline kernel here, that is,
5.13 here?
With recent kernel's you would not see -ENODEV ("No such device") but
rather -EINVAL ("Invalid argument").
What does "uname -a" say?
And which version of the patch are you applying? Are you sure it's the
latest?
> But when I test the branch of Mr Gregkh.
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/tree/drivers/usb/serial/cp210x.c?h=usb-testing
> when I setting the CP2108 with GPIO 0 and GPIO 1 are alternative
> functions (not GPIO) using simplicity studio.
> And then test with the driver, it shows:
> root@ubuntu:/sys/class/gpio# ls
> export gpiochip496 unexport
> root@ubuntu:/sys/class/gpio# echo 496 > /sys/class/gpio/export
> root@ubuntu:/sys/class/gpio# echo 497 > /sys/class/gpio/export
> That mean it still use GPIO 0 and GPIO 1 as GPIO functions.
It does seem that way, but to be sure, do the
/sys/class/gpio/gpio496
/sys/class/gpio/gpio497
directories show up as well?
> I don't know why there is that different. We can discuss more if you
> know the information.
I just did a quick test using the code in the usb-next (testing) branch
and it seems to work as expected when hard-coding alternate functions
for some of the pins in the driver.
I did not actually reprogram the device so perhaps something is broken
with regards to reading the port configuration. But then you should see
the problem if you apply the patch to an earlier kernel as well.
Can you apply the below patch on top of Greg's usb-next (or usb-testing)
branch and send me the logs from when connecting the device?
Johan
From 4ac38b282cfa1e6a17ff9d11b886cbebce3b9654 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Wed, 30 Jun 2021 11:59:28 +0200
Subject: [PATCH] dbg: USB: serial: cp210x: dump CP2108 alternate function
config
---
drivers/usb/serial/cp210x.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 09b845d0da41..1628ea1e9948 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1797,6 +1797,9 @@ static int cp2108_gpio_init(struct usb_serial *serial)
if (result < 0)
return result;
+ dev_info(&serial->interface->dev, "%s - %*ph\n", __func__,
+ 4, config.enhancedfxn_ifc);
+
priv->gc.ngpio = 16;
priv->gpio_pushpull = le16_to_cpu(config.reset_state.gpio_mode_pb1);
gpio_latch = le16_to_cpu(config.reset_state.gpio_latch_pb1);
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next
2021-06-30 10:05 ` patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next Johan Hovold
@ 2021-07-01 4:58 ` Tung Pham
2021-07-01 7:02 ` Johan Hovold
0 siblings, 1 reply; 4+ messages in thread
From: Tung Pham @ 2021-07-01 4:58 UTC (permalink / raw)
To: Johan Hovold
Cc: gregkh@linuxfoundation.org, Pho Tran, Hung Nguyen,
linux-usb@vger.kernel.org
Dear Johan.
>Please make sure to CC the usb list when reporting problems. I've added it to CC now.
Yes, I will remember to do this next time.
>Are you sure you're using the latest mainline kernel here, that is,
>5.13 here?
>With recent kernel's you would not see -ENODEV ("No such device") but rather -EINVAL ("Invalid argument").
>What does "uname -a" say?
I use the kernel 5.8.0-59-generic, I think either result ("No such device") or ("Invalid argument") may be accepted in this case.
>And which version of the patch are you applying? Are you sure it's the latest?
I apply patch V13 from last mail that you send.
>> But when I test the branch of Mr Gregkh.
>> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/tree/dr
>> ivers/usb/serial/cp210x.c?h=usb-testing
>> root@ubuntu:/sys/class/gpio# echo 496 > /sys/class/gpio/export
>> root@ubuntu:/sys/class/gpio# echo 497 > /sys/class/gpio/export That
>> mean it still use GPIO 0 and GPIO 1 as GPIO functions.
>It does seem that way, but to be sure, do the
> /sys/class/gpio/gpio496
> /sys/class/gpio/gpio497
>directories show up as well?
Today I retest it and it seem everything is ok. May be previous test I have some loading driver problem. The result is as below:
echo 496 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument
echo 497 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument
tung@ubuntu:~$ /sys/class/gpio/gpio496
bash: /sys/class/gpio/gpio496: No such file or directory
>I just did a quick test using the code in the usb-next (testing) branch and it seems to work as expected when hard-coding alternate functions for some of >the pins in the driver.
>I did not actually reprogram the device so perhaps something is broken with regards to reading the port configuration. But then you should see the >problem if you apply the patch to an earlier kernel as well.
>Can you apply the below patch on top of Greg's usb-next (or usb-testing) branch and send me the logs from when connecting the device?
The log written is:
[ 3599.781531] cp210x 2-2.1:1.0: cp2108_gpio_init - 03 00 00 00
Anyway both drivers are now working ok.
Thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next
2021-07-01 4:58 ` Tung Pham
@ 2021-07-01 7:02 ` Johan Hovold
2021-07-01 7:46 ` Tung Pham
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2021-07-01 7:02 UTC (permalink / raw)
To: Tung Pham
Cc: gregkh@linuxfoundation.org, Pho Tran, Hung Nguyen,
linux-usb@vger.kernel.org
On Thu, Jul 01, 2021 at 04:58:09AM +0000, Tung Pham wrote:
> >Are you sure you're using the latest mainline kernel here, that is,
> >5.13 here? With recent kernel's you would not see -ENODEV ("No such
> >device") but rather -EINVAL ("Invalid argument"). What does "uname
> >-a" say?
>
> I use the kernel 5.8.0-59-generic, I think either result ("No such
> device") or ("Invalid argument") may be accepted in this case.
Yes, you should be able to apply this patch to older kernels without
many additional changes, but you should still mention which kernel
you're using since backporting may not always work as expected.
> >And which version of the patch are you applying? Are you sure it's
> >the latest?
>
> I apply patch V13 from last mail that you send.
Good.
> >> But when I test the branch of Mr Gregkh.
> >> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/tree/dr
> >> ivers/usb/serial/cp210x.c?h=usb-testing
> >> root@ubuntu:/sys/class/gpio# echo 496 > /sys/class/gpio/export
> >> root@ubuntu:/sys/class/gpio# echo 497 > /sys/class/gpio/export That
> >> mean it still use GPIO 0 and GPIO 1 as GPIO functions.
>
> >It does seem that way, but to be sure, do the
>
> > /sys/class/gpio/gpio496
> > /sys/class/gpio/gpio497
>
> >directories show up as well?
>
> Today I retest it and it seem everything is ok. May be previous test I
> have some loading driver problem. The result is as below:
>
> echo 496 > /sys/class/gpio/export
> -bash: echo: write error: Invalid argument
> echo 497 > /sys/class/gpio/export
> -bash: echo: write error: Invalid argument
> tung@ubuntu:~$ /sys/class/gpio/gpio496
> bash: /sys/class/gpio/gpio496: No such file or directory
Very odd.
Were you using the very same device in both tests? And did you try with
the older kernel before the new one? Perhaps the new settings had not
yet taken effect otherwise?
> >I just did a quick test using the code in the usb-next (testing)
> >branch and it seems to work as expected when hard-coding alternate
> >functions for some of >the pins in the driver.
> >
> >I did not actually reprogram the device so perhaps something is
> >broken with regards to reading the port configuration. But then you
> >should see the >problem if you apply the patch to an earlier kernel
> >as well.
> >
> >Can you apply the below patch on top of Greg's usb-next (or
> >usb-testing) branch and send me the logs from when connecting the
> >device?
>
> The log written is:
> [ 3599.781531] cp210x 2-2.1:1.0: cp2108_gpio_init - 03 00 00 00
Thanks for confirming. So everything appears to work as expected, and
you should have seen the expected -EINVAL unless the device actually did
return all-zero here for some reason.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next
2021-07-01 7:02 ` Johan Hovold
@ 2021-07-01 7:46 ` Tung Pham
0 siblings, 0 replies; 4+ messages in thread
From: Tung Pham @ 2021-07-01 7:46 UTC (permalink / raw)
To: Johan Hovold
Cc: gregkh@linuxfoundation.org, Pho Tran, Hung Nguyen,
linux-usb@vger.kernel.org
Dear Johan.
>Yes, you should be able to apply this patch to older kernels without many additional changes, but you should still mention which kernel you're using >since backporting may not always work as expected.
Yes. Thank you for remaining me.
>Good.
>Very odd.
>Were you using the very same device in both tests? And did you try with the older kernel before the new one? Perhaps the new settings had not yet >taken effect otherwise?
Both test I use same device and same kernel version 5.8.0-59-generic.
May be in the wrong test, the device that have been configuring and the driver may not load new setting from device, I think the wrong may come from device. Just some plug and unplug problem.
>> The log written is:
>> [ 3599.781531] cp210x 2-2.1:1.0: cp2108_gpio_init - 03 00 00 00
>Thanks for confirming. So everything appears to work as expected, and you should have seen the expected -EINVAL unless the device actually did return >all-zero here for some reason.
Yes, now it return -EINVAL ("Invalid argument"). As expected.
Thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-01 7:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1624532158188214@kroah.com>
[not found] ` <PH0PR11MB4888B9D24A5F90E8AA02B28B81019@PH0PR11MB4888.namprd11.prod.outlook.com>
2021-06-30 10:05 ` patch "USB: serial: cp210x: add support for GPIOs on CP2108" added to usb-next Johan Hovold
2021-07-01 4:58 ` Tung Pham
2021-07-01 7:02 ` Johan Hovold
2021-07-01 7:46 ` Tung Pham
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.