diff mbox series

USB: qcaux: Add Motorola modem UARTs

Message ID 20181203013424.7433-1-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series USB: qcaux: Add Motorola modem UARTs | expand

Commit Message

Tony Lindgren Dec. 3, 2018, 1:34 a.m. UTC
On Motorola Mapphone devices such as Droid 4 there are five USB ports
that do not use the same layout as Gobi 1K/2K/etc devices listed in
qcserial.c. So we should use qcaux.c or option.c as noted by
Dan Williams <dcbw@redhat.com>.

The ff/ff/ff interfaces seem to always be UARTs on Motorola devices.
And we should not add interfaces with 0x0a class (CDC Data) as they
are part of a multi-interface function like for example interface
0x22b8:0x4281 as noted by Bjørn Mork <bjorn@mork.no>.

The ttyUSB ports on Droid 4 seem to be:

ttyUSB0 DIAG, CQDM-capable
ttyUSB1 MUX or NMEA, no response
ttyUSB2 MUX or NMEA, no response
ttyUSB3 TCMD
ttyUSB4 AT-capable

To enable the MUX or NMEA ports, it seems that something needs
to be done additionally to enable them, maybe via the DIAG or
TCMD port. Who knows, maybe it's just some NVRAM setting.

Cc: Bjørn Mork <bjorn@mork.no>
Cc: Johan Hovold <johan@kernel.org>
Cc: Dan Williams <dcbw@redhat.com>
Cc: Marcel Partap <mpartap@gmx.net>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lingren <tony@atomide.com>
---
 drivers/usb/serial/qcaux.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Johan Hovold Dec. 5, 2018, 6:17 a.m. UTC | #1
On Sun, Dec 02, 2018 at 05:34:24PM -0800, Tony Lindgren wrote:
> On Motorola Mapphone devices such as Droid 4 there are five USB ports
> that do not use the same layout as Gobi 1K/2K/etc devices listed in
> qcserial.c. So we should use qcaux.c or option.c as noted by
> Dan Williams <dcbw@redhat.com>.
> 
> The ff/ff/ff interfaces seem to always be UARTs on Motorola devices.
> And we should not add interfaces with 0x0a class (CDC Data) as they
> are part of a multi-interface function like for example interface
> 0x22b8:0x4281 as noted by Bjørn Mork <bjorn@mork.no>.

Can you post the output of usb-devices (or lsusb -v) for these three
devices (PIDs)?

Thanks,
Johan
Tony Lindgren Dec. 6, 2018, 1:54 a.m. UTC | #2
Hi,

* Johan Hovold <johan@kernel.org> [181205 06:17]:
> On Sun, Dec 02, 2018 at 05:34:24PM -0800, Tony Lindgren wrote:
> > On Motorola Mapphone devices such as Droid 4 there are five USB ports
> > that do not use the same layout as Gobi 1K/2K/etc devices listed in
> > qcserial.c. So we should use qcaux.c or option.c as noted by
> > Dan Williams <dcbw@redhat.com>.
> > 
> > The ff/ff/ff interfaces seem to always be UARTs on Motorola devices.
> > And we should not add interfaces with 0x0a class (CDC Data) as they
> > are part of a multi-interface function like for example interface
> > 0x22b8:0x4281 as noted by Bjørn Mork <bjorn@mork.no>.
> 
> Can you post the output of usb-devices (or lsusb -v) for these three
> devices (PIDs)?

Here's two out of three for you to look at. They're all listed in
drivers/usb/serial/mdm6600.c in at least the Motorola Mapphone
Android kernels, see for example the LineageOS kernel at [0] if
you want to look at the USB serial driver.

I don't have a device with 9600 with 0x2e0a id.

Regards,

Tony

[0] https://github.com/LineageOS/android_kernel_motorola_omap4-common/blob/cm-14.1/drivers/usb/serial/mdm6600.c

8< ---------------------
Bus 001 Device 002: ID 22b8:4281  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x22b8 
  idProduct          0x4281 
  bcdDevice            0.00
  iManufacturer           1 Motorola, Incorporated
  iProduct                2 Flash MZ600
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3 Motorola Configuration
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 
      bInterfaceSubClass      0 
      bInterfaceProtocol    252 
      iInterface              5 Motorola Flash
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

Bus 003 Device 109: ID 22b8:900e  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x22b8 
  idProduct          0x900e 
  bcdDevice            0.00
  iManufacturer           1 Motorola, Incorporated
  iProduct                2 Flash MZ600
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3 Motorola Configuration
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
Device Status:     0x0000
  (Bus Powered)
Johan Hovold Dec. 6, 2018, 6 a.m. UTC | #3
On Wed, Dec 05, 2018 at 05:54:07PM -0800, Tony Lindgren wrote:
> Hi,
> 
> * Johan Hovold <johan@kernel.org> [181205 06:17]:
> > On Sun, Dec 02, 2018 at 05:34:24PM -0800, Tony Lindgren wrote:
> > > On Motorola Mapphone devices such as Droid 4 there are five USB ports
> > > that do not use the same layout as Gobi 1K/2K/etc devices listed in
> > > qcserial.c. So we should use qcaux.c or option.c as noted by
> > > Dan Williams <dcbw@redhat.com>.
> > > 
> > > The ff/ff/ff interfaces seem to always be UARTs on Motorola devices.
> > > And we should not add interfaces with 0x0a class (CDC Data) as they
> > > are part of a multi-interface function like for example interface
> > > 0x22b8:0x4281 as noted by Bjørn Mork <bjorn@mork.no>.
> > 
> > Can you post the output of usb-devices (or lsusb -v) for these three
> > devices (PIDs)?
> 
> Here's two out of three for you to look at. They're all listed in
> drivers/usb/serial/mdm6600.c in at least the Motorola Mapphone
> Android kernels, see for example the LineageOS kernel at [0] if
> you want to look at the USB serial driver.
> 
> I don't have a device with 9600 with 0x2e0a id.
> 
> [0] https://github.com/LineageOS/android_kernel_motorola_omap4-common/blob/cm-14.1/drivers/usb/serial/mdm6600.c

Thanks for the pointer.

> 
> 8< ---------------------
> Bus 001 Device 002: ID 22b8:4281  
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               2.00
>   bDeviceClass            0 
>   bDeviceSubClass         0 
>   bDeviceProtocol         0 
>   bMaxPacketSize0        64
>   idVendor           0x22b8 
>   idProduct          0x4281 

This PID is not included in your patch however.

>   bcdDevice            0.00
>   iManufacturer           1 Motorola, Incorporated
>   iProduct                2 Flash MZ600
>   iSerial                 0 
>   bNumConfigurations      1
>   Configuration Descriptor:
>     bLength                 9
>     bDescriptorType         2
>     wTotalLength       0x0020
>     bNumInterfaces          1
>     bConfigurationValue     1
>     iConfiguration          3 Motorola Configuration
>     bmAttributes         0xe0
>       Self Powered
>       Remote Wakeup
>     MaxPower              500mA
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       0
>       bNumEndpoints           2
>       bInterfaceClass        10 
>       bInterfaceSubClass      0 
>       bInterfaceProtocol    252 

And wouldn't match on ff/ff/ff in any case.

>       iInterface              5 Motorola Flash
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x81  EP 1 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x01  EP 1 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
> Device Status:     0x0000
>   (Bus Powered)
> 
> Bus 003 Device 109: ID 22b8:900e  
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               2.00
>   bDeviceClass            0 
>   bDeviceSubClass         0 
>   bDeviceProtocol         0 
>   bMaxPacketSize0        64
>   idVendor           0x22b8 
>   idProduct          0x900e 
>   bcdDevice            0.00
>   iManufacturer           1 Motorola, Incorporated
>   iProduct                2 Flash MZ600
>   iSerial                 0 
>   bNumConfigurations      1
>   Configuration Descriptor:
>     bLength                 9
>     bDescriptorType         2
>     wTotalLength       0x0020
>     bNumInterfaces          1
>     bConfigurationValue     1
>     iConfiguration          3 Motorola Configuration
>     bmAttributes         0xe0
>       Self Powered
>       Remote Wakeup
>     MaxPower              500mA
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       0
>       bNumEndpoints           2
>       bInterfaceClass       255 
>       bInterfaceSubClass    255 
>       bInterfaceProtocol    255 
>       iInterface              0 
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x81  EP 1 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval              32
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x01  EP 1 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval              32
> Device Status:     0x0000
>   (Bus Powered)

And this doesn't look like a modem with five (?) interfaces, but I guess
it's in "flash" mode?

Could you post the output for the two devices you have in "modem" mode?

How do switch modes by the way?

Thanks,
Johan
Tony Lindgren Dec. 6, 2018, 3:48 p.m. UTC | #4
Hi,

* Johan Hovold <johan@kernel.org> [181206 06:00]:
> On Wed, Dec 05, 2018 at 05:54:07PM -0800, Tony Lindgren wrote:
...
> >   idVendor           0x22b8 
> >   idProduct          0x4281 
> 
> This PID is not included in your patch however.

Oops sorry did a cat on wrong two trimmed lsusb -v output
files..

> And this doesn't look like a modem with five (?) interfaces, but I guess
> it's in "flash" mode?

Yes, the wrong lsusb output is  for the flash mode that we're not
adding here and can be ignored for now.

> Could you post the output for the two devices you have in "modem" mode?

Yes correct lsusb -v output below with five UARTs with ff/ff/ff and
two QMI ports that are already handled with an earlier commit
4071898bf0f4 ("net: qmi_wwan: Add USB IDs for MDM6600 modem on
Motorola Droid 4").

> How do switch modes by the way?

The flash mode gets enabled with the control GPIOs. I just
did a quick test patch for phy-mapphone-mdm6600 using module
param for that. Then additionally the modem USB can be
multiplexed to the PC by configuring mode in phy-cpcap-usb
but I don't have a patch for that.

Regards,

Tony

8< -----------------------
Bus 001 Device 002: ID 22b8:2a70  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x22b8 
  idProduct          0x2a70 
  bcdDevice            0.00
  iManufacturer           1 Motorola, Incorporated
  iProduct                2 Flash MZ600
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00fb
    bNumInterfaces          9
    bConfigurationValue     1
    iConfiguration          3 Motorola Configuration
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        5
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    251 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x87  EP 7 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x88  EP 8 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        6
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    251 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x89  EP 9 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8a  EP 10 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x07  EP 7 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        7
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    251 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8b  EP 11 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8c  EP 12 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x08  EP 8 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        8
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    251 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8d  EP 13 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8e  EP 14 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x09  EP 9 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              32
Device Status:     0x0000
  (Bus Powered)
Tony Lindgren Dec. 6, 2018, 3:57 p.m. UTC | #5
* Tony Lindgren <tony@atomide.com> [181206 07:48]:
> * Johan Hovold <johan@kernel.org> [181206 06:00]:
> > How do switch modes by the way?
> 
> The flash mode gets enabled with the control GPIOs. I just
> did a quick test patch for phy-mapphone-mdm6600 using module
> param for that. Then additionally the modem USB can be
> multiplexed to the PC by configuring mode in phy-cpcap-usb
> but I don't have a patch for that.

FYI, below is the test patch against next I used for switching
between normal mode and flash mode with a module param flash_mode
if somebody wants to play with it. For flashing the modem,
Android update-binary does it to deal with the signed modem
firmware, I don't know of the details what happens there.

Kishon, is there maybe some phy framework sysfs property
we could use for switching phy modes?

Regards,

Tony

8< -----------------------
diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
--- a/drivers/phy/motorola/phy-mapphone-mdm6600.c
+++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
@@ -80,6 +80,10 @@ enum phy_mdm6600_status {
 	PHY_MDM6600_STATUS_UNDEFINED,
 };
 
+static bool flash_mode;
+module_param(flash_mode, bool, 0);
+MODULE_PARM_DESC(flash_mode, "Start mdm6600 in flash mode");
+
 static const char * const
 phy_mdm6600_status_name[] = {
 	"off", "busy", "qc_dl", "ram_dl", "awake",
@@ -249,6 +253,9 @@ static irqreturn_t phy_mdm6600_wakeirq_thread(int irq, void *data)
 	struct phy_mdm6600 *ddata = data;
 	struct gpio_desc *mode_gpio1;
 
+	if (flash_mode)
+		return IRQ_NONE;
+
 	mode_gpio1 = ddata->mode_gpios->desc[PHY_MDM6600_MODE1];
 	dev_dbg(ddata->dev, "OOB wake on mode_gpio1: %i\n",
 		gpiod_get_value(mode_gpio1));
@@ -377,8 +384,13 @@ static int phy_mdm6600_device_power_on(struct phy_mdm6600 *ddata)
 	 * to configure USB flashing mode later on based on a module
 	 * parameter.
 	 */
-	gpiod_set_value_cansleep(mode_gpio0, 0);
-	gpiod_set_value_cansleep(mode_gpio1, 0);
+	if (flash_mode) {
+		gpiod_set_value_cansleep(mode_gpio0, 1);
+		gpiod_set_value_cansleep(mode_gpio1, 1);
+	} else {
+		gpiod_set_value_cansleep(mode_gpio0, 0);
+		gpiod_set_value_cansleep(mode_gpio1, 0);
+	}
 
 	/* Request start-up mode */
 	phy_mdm6600_cmd(ddata, PHY_MDM6600_CMD_NO_BYPASS);
@@ -414,7 +426,12 @@ static int phy_mdm6600_device_power_on(struct phy_mdm6600 *ddata)
 		dev_err(ddata->dev, "Timed out powering up\n");
 	}
 
-	/* Reconfigure mode1 GPIO as input for OOB wake */
+	/* Maybe reconfigure mode1 GPIO as input for OOB wake? */
+	if (flash_mode) {
+		dev_info(ddata->dev, "Started in flash mode\n");
+		goto done;
+	}
+
 	gpiod_direction_input(mode_gpio1);
 
 	wakeirq = gpiod_to_irq(mode_gpio1);
@@ -431,7 +448,7 @@ static int phy_mdm6600_device_power_on(struct phy_mdm6600 *ddata)
 	if (error)
 		dev_warn(ddata->dev, "no modem wakeirq irq%i: %i\n",
 			 wakeirq, error);
-
+done:
 	ddata->running = true;
 
 	return error;
@@ -499,6 +516,9 @@ static void phy_mdm6600_modem_wake(struct work_struct *work)
 {
 	struct phy_mdm6600 *ddata;
 
+	if (flash_mode)
+		return;
+
 	ddata = container_of(work, struct phy_mdm6600, modem_wake_work.work);
 	phy_mdm6600_wake_modem(ddata);
 	schedule_delayed_work(&ddata->modem_wake_work,
@@ -509,6 +529,9 @@ static int __maybe_unused phy_mdm6600_runtime_suspend(struct device *dev)
 {
 	struct phy_mdm6600 *ddata = dev_get_drvdata(dev);
 
+	if (flash_mode)
+		return 0;
+
 	cancel_delayed_work_sync(&ddata->modem_wake_work);
 	ddata->awake = false;
 
@@ -519,6 +542,9 @@ static int __maybe_unused phy_mdm6600_runtime_resume(struct device *dev)
 {
 	struct phy_mdm6600 *ddata = dev_get_drvdata(dev);
 
+	if (flash_mode)
+		return 0;
+
 	phy_mdm6600_modem_wake(&ddata->modem_wake_work.work);
 	ddata->awake = true;
Johan Hovold Dec. 13, 2018, 12:46 p.m. UTC | #6
Hi Tony,

Sorry for the late reply.

On Thu, Dec 06, 2018 at 07:48:23AM -0800, Tony Lindgren wrote:
> Hi,
> 
> * Johan Hovold <johan@kernel.org> [181206 06:00]:
> > On Wed, Dec 05, 2018 at 05:54:07PM -0800, Tony Lindgren wrote:
 
> > Could you post the output for the two devices you have in "modem" mode?
> 
> Yes correct lsusb -v output below with five UARTs with ff/ff/ff and
> two QMI ports that are already handled with an earlier commit
> 4071898bf0f4 ("net: qmi_wwan: Add USB IDs for MDM6600 modem on
> Motorola Droid 4").

Isn't it four QMI ports even (interfaces 5 through 8)?

> > How do switch modes by the way?
> 
> The flash mode gets enabled with the control GPIOs. I just
> did a quick test patch for phy-mapphone-mdm6600 using module
> param for that. Then additionally the modem USB can be
> multiplexed to the PC by configuring mode in phy-cpcap-usb
> but I don't have a patch for that.

Ah, ok.

> 8< -----------------------
> Bus 001 Device 002: ID 22b8:2a70  
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               2.00
>   bDeviceClass            0 
>   bDeviceSubClass         0 
>   bDeviceProtocol         0 
>   bMaxPacketSize0        64
>   idVendor           0x22b8 
>   idProduct          0x2a70 
>   bcdDevice            0.00
>   iManufacturer           1 Motorola, Incorporated
>   iProduct                2 Flash MZ600
>   iSerial                 0 
>   bNumConfigurations      1

>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        4
>       bAlternateSetting       0
>       bNumEndpoints           3
>       bInterfaceClass       255 
>       bInterfaceSubClass    255 
>       bInterfaceProtocol    255 
>       iInterface              0 
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x85  EP 5 IN
>         bmAttributes            3
>           Transfer Type            Interrupt
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               5

Since the modem (AT) port here has an interrupt endpoint, you should add
these device ids to the option driver which can handle that.

As the comment in qcaux suggests, that driver is intended for the diag
port of some old devices where the modem port was handled by cdc-acm.

>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x86  EP 6 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval              32
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x05  EP 5 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval              32

Also, if possible please include the more compact output of usb-devices
(or /sys/kernel/debug/usb/devices) for the devices you have access to in
the commit message.

Thanks,
Johan
Tony Lindgren Dec. 13, 2018, 2:37 p.m. UTC | #7
* Johan Hovold <johan@kernel.org> [181213 12:46]:
> On Thu, Dec 06, 2018 at 07:48:23AM -0800, Tony Lindgren wrote:
> > Yes correct lsusb -v output below with five UARTs with ff/ff/ff and
> > two QMI ports that are already handled with an earlier commit
> > 4071898bf0f4 ("net: qmi_wwan: Add USB IDs for MDM6600 modem on
> > Motorola Droid 4").
> 
> Isn't it four QMI ports even (interfaces 5 through 8)?

Oh right yes it's four QMI ports.

> >       bDescriptorType         4
> >       bInterfaceNumber        4
> >       bAlternateSetting       0
> >       bNumEndpoints           3
> >       bInterfaceClass       255 
> >       bInterfaceSubClass    255 
> >       bInterfaceProtocol    255 
> >       iInterface              0 
> >       Endpoint Descriptor:
> >         bLength                 7
> >         bDescriptorType         5
> >         bEndpointAddress     0x85  EP 5 IN
> >         bmAttributes            3
> >           Transfer Type            Interrupt
> >           Synch Type               None
> >           Usage Type               Data
> >         wMaxPacketSize     0x0040  1x 64 bytes
> >         bInterval               5
> 
> Since the modem (AT) port here has an interrupt endpoint, you should add
> these device ids to the option driver which can handle that.

Oh OK will do.

> As the comment in qcaux suggests, that driver is intended for the diag
> port of some old devices where the modem port was handled by cdc-acm.

OK

> Also, if possible please include the more compact output of usb-devices
> (or /sys/kernel/debug/usb/devices) for the devices you have access to in
> the commit message.

Will do.

Thanks,

Tony
diff mbox series

Patch

diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -42,6 +42,12 @@ 
 #define LG_VENDOR_ID				0x1004
 #define LG_PRODUCT_VX4400_6000			0x6000 /* VX4400/VX6000/Rumor */
 
+/* Motorola devices */
+#define MOTOROLA_VENDOR_ID			0x22b8
+#define MOTOROLA_PRODUCT_MDM6600		0x2a70 /* MDM6600 on mapphone */
+#define MOTOROLA_PRODUCT_MDM9600		0x2e0a /* MDM9600 on mapphone */
+#define MOTOROLA_PRODUCT_MDM_FLASH		0x900e /* MDM UART flash mode */
+
 /* Sanyo devices */
 #define SANYO_VENDOR_ID				0x0474
 #define SANYO_PRODUCT_KATANA_LX			0x0754 /* SCP-3800 (Katana LX) */
@@ -60,6 +66,9 @@  static const struct usb_device_id id_table[] = {
 	{ USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(MOTOROLA_VENDOR_ID, MOTOROLA_PRODUCT_MDM6600, 0xff, 0xff, 0xff) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(MOTOROLA_VENDOR_ID, MOTOROLA_PRODUCT_MDM9600, 0xff, 0xff, 0xff) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(MOTOROLA_VENDOR_ID, MOTOROLA_PRODUCT_MDM_FLASH, 0xff, 0xff, 0xff) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
 	{ USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xfd, 0xff) },  /* NMEA */