mbox series

[v2,00/15] usb: typec: qcom-pmic-typec: enable support for PMI632 PMIC

Message ID 20240113-pmi632-typec-v2-0-182d9aa0a5b3@linaro.org (mailing list archive)
Headers show
Series usb: typec: qcom-pmic-typec: enable support for PMI632 PMIC | expand

Message

Dmitry Baryshkov Jan. 13, 2024, 8:55 p.m. UTC
The Qualcomm PMI632 PMIC (found on Qualcomm Robotics RB2 platform)
doesn't support USB Power Delivery. However this PMIC still supports
handling of the Type-C port (orientation detection, etc). Reuse exiting
qcom-pmic-typec driver to support Type-C related functionality of this
PMIC. Use this to enable USB-C connector support on the RB2 platform.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Changes in v2:
- Split qcom_pmic_typec_pdphy_set_roles() changes to separate patch
  (Konrad)
- Simplified devm_kzalloc / sizeof() argument (Konrad)
- Made start / stop callbacks mandatory (Bryan)
- Reworked Type-C port handling into a backend similar to PD PHY (Bryan)
- Made more qcom-pmic-typec data static const (Bryan)
- Squashed usbc PHY single-lane removal patch (Konrad)
- Further usbc PHY cleanup (Konrad)
- Fixed order of DT properties in pmi632.dtsi (Konrad)
- Instead of specifying bogus PDOs for the port, specify pd-disable and
  typec-power-opmode properties for the connector
- Moved orientation-switch / usb-dual-role properties to sm6115.dtsi
  (Konrad)
- Linked usb_dwc3_ss and usb_qmpphy_usb_ss_in
- Link to v1: https://lore.kernel.org/r/20240113-pmi632-typec-v1-0-de7dfd459353@linaro.org

---
Dmitry Baryshkov (14):
      dt-bindings: regulator: qcom,usb-vbus-regulator: add support for PMI632
      dt-bindings: usb: qcom,pmic-typec: add support for the PMI632 block
      dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: split from sc8280xp PHY schema
      dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: support USB-C data
      usb: typec: tcpm: fix the PD disabled case
      usb: typec: qcom-pmic-typec: fix arguments of qcom_pmic_typec_pdphy_set_roles
      usb: typec: qcom-pmic-typec: allow different implementations for the PD PHY
      usb: typec: qcom-pmic-typec: allow different implementations for the port backend
      usb: typec: qcom-pmic-typec: add support for PMI632 PMIC
      phy: qcom: qmp-usb: split USB-C PHY driver
      phy: qcom: qmp-usb: drop dual-lane handling
      phy: qcom: qmp-usbc: add support for the Type-C handling
      arm64: dts: qcom: pmi632: define USB-C related blocks
      arm64: dts: qcom: qrb4210-rb2: enable USB-C port handling

Vladimir Zapolskiy (1):
      arm64: dts: qcom: sm6115: drop pipe clock selection

 .../bindings/phy/qcom,msm8998-qmp-usb3-phy.yaml    |  171 +++
 .../phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml        |   22 -
 .../regulator/qcom,usb-vbus-regulator.yaml         |    9 +-
 .../devicetree/bindings/usb/qcom,pmic-typec.yaml   |   28 +-
 arch/arm64/boot/dts/qcom/pmi632.dtsi               |   30 +
 arch/arm64/boot/dts/qcom/qrb4210-rb2.dts           |   50 +-
 arch/arm64/boot/dts/qcom/sm6115.dtsi               |   44 +-
 drivers/phy/qualcomm/Makefile                      |    2 +-
 drivers/phy/qualcomm/phy-qcom-qmp-usb.c            |  323 +-----
 drivers/phy/qualcomm/phy-qcom-qmp-usbc.c           | 1169 ++++++++++++++++++++
 drivers/usb/typec/tcpm/qcom/Makefile               |    3 +-
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c      |  254 +----
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h      |   27 +
 .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c    |  157 ++-
 .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h    |   94 +-
 .../typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c   |   80 ++
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c |  290 ++++-
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h |  172 +--
 drivers/usb/typec/tcpm/tcpm.c                      |    3 +-
 19 files changed, 2058 insertions(+), 870 deletions(-)
---
base-commit: 9e21984d62c56a0f6d1fc6f76b646212cfd7fe88
change-id: 20240112-pmi632-typec-4c7533092387

Best regards,

Comments

Vinod Koul Jan. 23, 2024, 2:20 p.m. UTC | #1
On Sat, 13 Jan 2024 22:55:43 +0200, Dmitry Baryshkov wrote:
> The Qualcomm PMI632 PMIC (found on Qualcomm Robotics RB2 platform)
> doesn't support USB Power Delivery. However this PMIC still supports
> handling of the Type-C port (orientation detection, etc). Reuse exiting
> qcom-pmic-typec driver to support Type-C related functionality of this
> PMIC. Use this to enable USB-C connector support on the RB2 platform.
> 
> 
> [...]

Applied, thanks!

[03/15] dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: split from sc8280xp PHY schema
        commit: 159919a184c5ef82fac3605b2390b17a549c06ac
[04/15] dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: support USB-C data
        commit: c1214b579733df7017c0e5f97f26eeb4b66df0c6
[10/15] phy: qcom: qmp-usb: split USB-C PHY driver
        commit: 19281571a4d5b6049dad9318db081af48818b1d2
[11/15] phy: qcom: qmp-usb: drop dual-lane handling
        commit: 52cfdc9c6c3306f0bda4f217396f508d3f5459fb
[12/15] phy: qcom: qmp-usbc: add support for the Type-C handling
        commit: dfdaba27b4660ec26de955cf4459499ddb005e2d

Best regards,
Luca Weiss Jan. 23, 2024, 8:43 p.m. UTC | #2
On Sat Jan 13, 2024 at 9:55 PM CET, Dmitry Baryshkov wrote:
> The Qualcomm PMI632 PMIC (found on Qualcomm Robotics RB2 platform)
> doesn't support USB Power Delivery. However this PMIC still supports
> handling of the Type-C port (orientation detection, etc). Reuse exiting
> qcom-pmic-typec driver to support Type-C related functionality of this
> PMIC. Use this to enable USB-C connector support on the RB2 platform.

Hi Dmitry,

I'm happy to report that testing this series on v6.8-rc1 kernel on
sdm632-fairphone-fp3 shows that USB role switching is working with this!

It's not extensive testing but plugging in a USB stick and USB headphone
jack dongle in both directions show up in dmesg as expected, and
afterwards also USB networking gadget still works to ssh into the
device.

My .dts part is a bit different to your RB2 dts since
sdm632-fairphone-fp3 doesn't support USB 3.0, only USB 2.0, but
otherwise looks pretty similar. I'll send a patch for that once your
series has landed.

Not sure on which patches it makes sense, but have my:

Tested-by: Luca Weiss <luca.weiss@fairphone.com> # sdm632-fairphone-fp3

And for reference:

Only thing I've noticed here is "Host supports USB 3.0 SuperSpeed" which
is half true, to my knowledge SDM632 does support USB 3.0 but it's not
hooked up (for some reason) on most MSM8953/SDM632-based devices.

[   22.986096] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[   22.986273] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[   22.990847] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230f665 hci version 0x100 quirks 0x0000000002000010
[   22.998260] xhci-hcd xhci-hcd.1.auto: irq 57, io mem 0x07000000
[   23.007684] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[   23.013435] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[   23.019029] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[   23.027696] hub 1-0:1.0: USB hub found
[   23.033167] hub 1-0:1.0: 1 port detected
[   23.037538] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[   23.041853] hub 2-0:1.0: USB hub found
[   23.049034] hub 2-0:1.0: 1 port detected
[   23.120301] qcom,pmic-typec 200f000.spmi:pmic@2:typec@1500: vbus vsafe5v fail
[   23.845537] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[   23.995466] usb-storage 1-1:1.0: USB Mass Storage device detected
[   23.996166] scsi host0: usb-storage 1-1:1.0
[   25.022547] scsi 0:0:0:0: Direct-Access     SanDisk  Ultra            1.00 PQ: 0 ANSI: 6
[   25.023926] sd 0:0:0:0: [sda] 60062500 512-byte logical blocks: (30.8 GB/28.6 GiB)
[   25.030873] sd 0:0:0:0: [sda] Write Protect is off
[   25.037204] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[   25.042395] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   25.070314]  sda: sda1 sda2 sda3
[   25.071050] sd 0:0:0:0: [sda] Attached SCSI removable disk


[   31.347094] usb 1-1: USB disconnect, device number 2
[   31.364973] xhci-hcd xhci-hcd.1.auto: remove, state 4
[   31.365149] usb usb2: USB disconnect, device number 1
[   31.370427] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[   31.374236] xhci-hcd xhci-hcd.1.auto: remove, state 1
[   31.379906] usb usb1: USB disconnect, device number 1
[   31.475790] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered

Regards
Luca


>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> Changes in v2:
> - Split qcom_pmic_typec_pdphy_set_roles() changes to separate patch
>   (Konrad)
> - Simplified devm_kzalloc / sizeof() argument (Konrad)
> - Made start / stop callbacks mandatory (Bryan)
> - Reworked Type-C port handling into a backend similar to PD PHY (Bryan)
> - Made more qcom-pmic-typec data static const (Bryan)
> - Squashed usbc PHY single-lane removal patch (Konrad)
> - Further usbc PHY cleanup (Konrad)
> - Fixed order of DT properties in pmi632.dtsi (Konrad)
> - Instead of specifying bogus PDOs for the port, specify pd-disable and
>   typec-power-opmode properties for the connector
> - Moved orientation-switch / usb-dual-role properties to sm6115.dtsi
>   (Konrad)
> - Linked usb_dwc3_ss and usb_qmpphy_usb_ss_in
> - Link to v1: https://lore.kernel.org/r/20240113-pmi632-typec-v1-0-de7dfd459353@linaro.org
>
> ---
> Dmitry Baryshkov (14):
>       dt-bindings: regulator: qcom,usb-vbus-regulator: add support for PMI632
>       dt-bindings: usb: qcom,pmic-typec: add support for the PMI632 block
>       dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: split from sc8280xp PHY schema
>       dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: support USB-C data
>       usb: typec: tcpm: fix the PD disabled case
>       usb: typec: qcom-pmic-typec: fix arguments of qcom_pmic_typec_pdphy_set_roles
>       usb: typec: qcom-pmic-typec: allow different implementations for the PD PHY
>       usb: typec: qcom-pmic-typec: allow different implementations for the port backend
>       usb: typec: qcom-pmic-typec: add support for PMI632 PMIC
>       phy: qcom: qmp-usb: split USB-C PHY driver
>       phy: qcom: qmp-usb: drop dual-lane handling
>       phy: qcom: qmp-usbc: add support for the Type-C handling
>       arm64: dts: qcom: pmi632: define USB-C related blocks
>       arm64: dts: qcom: qrb4210-rb2: enable USB-C port handling
>
> Vladimir Zapolskiy (1):
>       arm64: dts: qcom: sm6115: drop pipe clock selection
>
>  .../bindings/phy/qcom,msm8998-qmp-usb3-phy.yaml    |  171 +++
>  .../phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml        |   22 -
>  .../regulator/qcom,usb-vbus-regulator.yaml         |    9 +-
>  .../devicetree/bindings/usb/qcom,pmic-typec.yaml   |   28 +-
>  arch/arm64/boot/dts/qcom/pmi632.dtsi               |   30 +
>  arch/arm64/boot/dts/qcom/qrb4210-rb2.dts           |   50 +-
>  arch/arm64/boot/dts/qcom/sm6115.dtsi               |   44 +-
>  drivers/phy/qualcomm/Makefile                      |    2 +-
>  drivers/phy/qualcomm/phy-qcom-qmp-usb.c            |  323 +-----
>  drivers/phy/qualcomm/phy-qcom-qmp-usbc.c           | 1169 ++++++++++++++++++++
>  drivers/usb/typec/tcpm/qcom/Makefile               |    3 +-
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c      |  254 +----
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h      |   27 +
>  .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c    |  157 ++-
>  .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h    |   94 +-
>  .../typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c   |   80 ++
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c |  290 ++++-
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h |  172 +--
>  drivers/usb/typec/tcpm/tcpm.c                      |    3 +-
>  19 files changed, 2058 insertions(+), 870 deletions(-)
> ---
> base-commit: 9e21984d62c56a0f6d1fc6f76b646212cfd7fe88
> change-id: 20240112-pmi632-typec-4c7533092387
>
> Best regards,
Dmitry Baryshkov Jan. 24, 2024, 1:43 a.m. UTC | #3
On Tue, 23 Jan 2024 at 22:43, Luca Weiss <luca.weiss@fairphone.com> wrote:
>
> On Sat Jan 13, 2024 at 9:55 PM CET, Dmitry Baryshkov wrote:
> > The Qualcomm PMI632 PMIC (found on Qualcomm Robotics RB2 platform)
> > doesn't support USB Power Delivery. However this PMIC still supports
> > handling of the Type-C port (orientation detection, etc). Reuse exiting
> > qcom-pmic-typec driver to support Type-C related functionality of this
> > PMIC. Use this to enable USB-C connector support on the RB2 platform.
>
> Hi Dmitry,
>
> I'm happy to report that testing this series on v6.8-rc1 kernel on
> sdm632-fairphone-fp3 shows that USB role switching is working with this!
>
> It's not extensive testing but plugging in a USB stick and USB headphone
> jack dongle in both directions show up in dmesg as expected, and
> afterwards also USB networking gadget still works to ssh into the
> device.
>
> My .dts part is a bit different to your RB2 dts since
> sdm632-fairphone-fp3 doesn't support USB 3.0, only USB 2.0, but
> otherwise looks pretty similar. I'll send a patch for that once your
> series has landed.
>
> Not sure on which patches it makes sense, but have my:
>
> Tested-by: Luca Weiss <luca.weiss@fairphone.com> # sdm632-fairphone-fp3

Probably this makes sense on pmi632 patches, as you definitely tested
only those and not RB2 ones.

>
> And for reference:
>
> Only thing I've noticed here is "Host supports USB 3.0 SuperSpeed" which
> is half true, to my knowledge SDM632 does support USB 3.0 but it's not
> hooked up (for some reason) on most MSM8953/SDM632-based devices.

I suppose it is the same story as SDM660. The SoC supports USB 3.0,
but device manufacturers at that time didn't care for the sake of
making them cheaper. So development kits had USB 3.0 (e.g. IFC6560),
but the actual phones didn't.

>
> [   22.986096] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
> [   22.986273] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
> [   22.990847] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230f665 hci version 0x100 quirks 0x0000000002000010
> [   22.998260] xhci-hcd xhci-hcd.1.auto: irq 57, io mem 0x07000000
> [   23.007684] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
> [   23.013435] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
> [   23.019029] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
> [   23.027696] hub 1-0:1.0: USB hub found
> [   23.033167] hub 1-0:1.0: 1 port detected
> [   23.037538] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
> [   23.041853] hub 2-0:1.0: USB hub found
> [   23.049034] hub 2-0:1.0: 1 port detected
> [   23.120301] qcom,pmic-typec 200f000.spmi:pmic@2:typec@1500: vbus vsafe5v fail
> [   23.845537] usb 1-1: new high-speed USB device number 2 using xhci-hcd
> [   23.995466] usb-storage 1-1:1.0: USB Mass Storage device detected
> [   23.996166] scsi host0: usb-storage 1-1:1.0
> [   25.022547] scsi 0:0:0:0: Direct-Access     SanDisk  Ultra            1.00 PQ: 0 ANSI: 6
> [   25.023926] sd 0:0:0:0: [sda] 60062500 512-byte logical blocks: (30.8 GB/28.6 GiB)
> [   25.030873] sd 0:0:0:0: [sda] Write Protect is off
> [   25.037204] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
> [   25.042395] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
> [   25.070314]  sda: sda1 sda2 sda3
> [   25.071050] sd 0:0:0:0: [sda] Attached SCSI removable disk
>
>
> [   31.347094] usb 1-1: USB disconnect, device number 2
> [   31.364973] xhci-hcd xhci-hcd.1.auto: remove, state 4
> [   31.365149] usb usb2: USB disconnect, device number 1
> [   31.370427] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
> [   31.374236] xhci-hcd xhci-hcd.1.auto: remove, state 1
> [   31.379906] usb usb1: USB disconnect, device number 1
> [   31.475790] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
>
> Regards
> Luca
>
>
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> > Changes in v2:
> > - Split qcom_pmic_typec_pdphy_set_roles() changes to separate patch
> >   (Konrad)
> > - Simplified devm_kzalloc / sizeof() argument (Konrad)
> > - Made start / stop callbacks mandatory (Bryan)
> > - Reworked Type-C port handling into a backend similar to PD PHY (Bryan)
> > - Made more qcom-pmic-typec data static const (Bryan)
> > - Squashed usbc PHY single-lane removal patch (Konrad)
> > - Further usbc PHY cleanup (Konrad)
> > - Fixed order of DT properties in pmi632.dtsi (Konrad)
> > - Instead of specifying bogus PDOs for the port, specify pd-disable and
> >   typec-power-opmode properties for the connector
> > - Moved orientation-switch / usb-dual-role properties to sm6115.dtsi
> >   (Konrad)
> > - Linked usb_dwc3_ss and usb_qmpphy_usb_ss_in
> > - Link to v1: https://lore.kernel.org/r/20240113-pmi632-typec-v1-0-de7dfd459353@linaro.org
> >
> > ---
> > Dmitry Baryshkov (14):
> >       dt-bindings: regulator: qcom,usb-vbus-regulator: add support for PMI632
> >       dt-bindings: usb: qcom,pmic-typec: add support for the PMI632 block
> >       dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: split from sc8280xp PHY schema
> >       dt-bindings: phy: qcom,msm8998-qmp-usb3-phy: support USB-C data
> >       usb: typec: tcpm: fix the PD disabled case
> >       usb: typec: qcom-pmic-typec: fix arguments of qcom_pmic_typec_pdphy_set_roles
> >       usb: typec: qcom-pmic-typec: allow different implementations for the PD PHY
> >       usb: typec: qcom-pmic-typec: allow different implementations for the port backend
> >       usb: typec: qcom-pmic-typec: add support for PMI632 PMIC
> >       phy: qcom: qmp-usb: split USB-C PHY driver
> >       phy: qcom: qmp-usb: drop dual-lane handling
> >       phy: qcom: qmp-usbc: add support for the Type-C handling
> >       arm64: dts: qcom: pmi632: define USB-C related blocks
> >       arm64: dts: qcom: qrb4210-rb2: enable USB-C port handling
> >
> > Vladimir Zapolskiy (1):
> >       arm64: dts: qcom: sm6115: drop pipe clock selection
> >
> >  .../bindings/phy/qcom,msm8998-qmp-usb3-phy.yaml    |  171 +++
> >  .../phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml        |   22 -
> >  .../regulator/qcom,usb-vbus-regulator.yaml         |    9 +-
> >  .../devicetree/bindings/usb/qcom,pmic-typec.yaml   |   28 +-
> >  arch/arm64/boot/dts/qcom/pmi632.dtsi               |   30 +
> >  arch/arm64/boot/dts/qcom/qrb4210-rb2.dts           |   50 +-
> >  arch/arm64/boot/dts/qcom/sm6115.dtsi               |   44 +-
> >  drivers/phy/qualcomm/Makefile                      |    2 +-
> >  drivers/phy/qualcomm/phy-qcom-qmp-usb.c            |  323 +-----
> >  drivers/phy/qualcomm/phy-qcom-qmp-usbc.c           | 1169 ++++++++++++++++++++
> >  drivers/usb/typec/tcpm/qcom/Makefile               |    3 +-
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c      |  254 +----
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h      |   27 +
> >  .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c    |  157 ++-
> >  .../usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h    |   94 +-
> >  .../typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c   |   80 ++
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c |  290 ++++-
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h |  172 +--
> >  drivers/usb/typec/tcpm/tcpm.c                      |    3 +-
> >  19 files changed, 2058 insertions(+), 870 deletions(-)
> > ---
> > base-commit: 9e21984d62c56a0f6d1fc6f76b646212cfd7fe88
> > change-id: 20240112-pmi632-typec-4c7533092387
> >
> > Best regards,
>