mbox series

[v4,00/18] Add Qualcomm PMIC TPCM support

Message ID 20230318121828.739424-1-bryan.odonoghue@linaro.org
Headers show
Series Add Qualcomm PMIC TPCM support | expand

Message

Bryan O'Donoghue March 18, 2023, 12:18 p.m. UTC
v4:
- Per Rob's input the pdphy and type-c appear as stadalone blocks
  inside of the PMIC declaration which is a 1:1 mapping of PMIC hardware.
  The TCPM virtual device is declared at the top-level.
  https://lore.kernel.org/all/YY7p7jviA3ZG05gL@robh.at.kernel.org/

- Squashes the removal of the old driver with the addition of the new. - Heikki, Gunter
  https://lore.kernel.org/all/YYVHcHC1Gm92VxEM@kuha.fi.intel.com/

- Reworked Dmitry's old patch for the QMP to account for file renames and
  very minimal code-drift in the interregnum.

- New yaml checks drive update of PMIC VBUS yaml

- Some housekeeping on the sc7180 yaml side. sc7180 is not supported yet.

- Expands and fixes the examples being added in the PMIC tcpm examples.

Previous set:
https://lore.kernel.org/all/20211105033558.1573552-1-bryan.odonoghue@linaro.org/

Bootable:
https://git.codelinaro.org/bryan.odonoghue/kernel/-/commits/linux-next-23-03-18-pm8150b-tcpm-qcom-wrapper-typec-mux

V3:
Rob Herrings review

- Drops use of remote-endpoint and ports to bind
  tcpm to pdphy and typec replacing with phandle

- Drops pmic-pdphy-* and pmic-typec-* from interrupt names
  as suggested

- Passes make dt_binding_check DT_CHECKER_FLAGS=-m

BOD
- Noticed qcom_pmic_tcpm_pdphy_enable() was missing a
  regulator_disable in case of an error, added.

- qcom_pmic_tcpm_pdphy_probe()
  devm_regulator_get() should come before regmap_get()
  as is the case in qcom_pmic_tcpm_typec_probe()

- Fixes compatible name in qcom,pmic-typec.yaml should
  have read qcom,pm8150b-typec not qcom,pm8150b-usb-typec

- Makes sure compat for core is "qcom,pm8150b-tcpm" in
  docs and driver

- Drops redundant return in void qcom_pmic_tcpm_pdphy_reset_off()

Kernel Robot
- Drops unused variable debounced in qcom_pmic_tcpm_typec_get_cc()

- Drops unsused variable orientation in qcom_pmic_tcpm_typec_set_cc()

Latest bootable series can be found here:
Link: https://git.linaro.org/people/bryan.odonoghue/kernel.git/log/?h=usb-next-04-11-21-pm8150b-tcpm-v3

git diff usb-next-27-10-21-pm8150b-tcpm-v2 -- drivers/usb/typec/tcpm/qcom/
git diff usb-next-27-10-21-pm8150b-tcpm-v2 -- Documentation/devicetree/bindings/usb/qcom,pmic*

Previous set:
Link: https://lore.kernel.org/linux-usb/20211028164941.831918-1-bryan.odonoghue@linaro.org/T/#t

V2 resend:
- Adding omitted devicetree mailing list

V2:

Guenter Roeck's review
- Converts suggested qcom_pmic_tcpm_core.c into one-liners

- Adds comment on how polarity is set in set_polarity()

- Removes optional set_current_limit()

- regmap_read/regmap_write
  Reviwing other pm8150b/spmi drivers I then added in checks for all
  reamap_read()/regmap_write() calls.

- Fixes (type == TCPC_TX_CABLE_RESET || TCPC_TX_HARD_RESET)
  thanks I definitely had the blinkers on there and didn't see that at all

- qcom_pmic_tcpm_pdphy_pd_transmit_payload()
  Treats regmap_read and read value as separate error paths

- qcom_pmic_tcpm_pdphy_set_pd_rx()
  Replaces boolean if/else with !on as suggested

- Returns -ENODEV not -EINVAL on dev_get_regmap() error

- qcom_pmic_tcpm_pdphy_pd_receive()
  Guenter asks: "No error return ?"
  bod: No we are inside an ISR here if we read data we pass that off to TCPM
       if somehow we don't read the data - it is "junk" there's no value IMO
       in pushing an error upwards back to the handler.

Heikki Krogerus' review
- Includes Makefile I missed adding to my git index

- Removes old Kconfig entry for remove driver

Randy Dunlap's review 
- Rewords drivers/usb/typec/tcpm/Kconfig

- Drops tautology "aggregates togther"

- Corrects spelling typos

BOD's own review
- Drops redundant include of regmap.h in qcom_pmic_tcpm_core.c

- Propogates qcom_pmic_tcpm_pdphy_disable() error upwards

- Propogates pmic_pdphy_reset() error upwards

- Drops error prints in qcom_pmic_tcpm_pdphy_pd_transmit_payload()
  I had these in-place during development and don't recall them being
  triggered even once, they are redundant, remove.
 
Differences between the two can be seen by
git diff usb-next-27-10-21-pm8150b-tcpm-v2..usb-next-25-10-21-pm8150b-tcpm -- drivers/usb/typec/tcpm

Latest bootable series can be found here:
Link: https://git.linaro.org/people/bryan.odonoghue/kernel.git/log/?h=usb-next-27-10-21-pm8150b-tcpm-v2

Previous set:
Link: https://lore.kernel.org/all/20211025150906.176686-1-bryan.odonoghue@linaro.org/T/#t

V1:
This series adds a set of yaml and a driver to bind together the type-c and
pdphy silicon in qcom's pm8150b block as a Linux type-c port manager.

As part of that we retire the existing qcom-pmic-typec driver and fully
replicate its functionality inside of the new block with the additional
pdphy stuff along with it.

An additional series will follow this one for the SoC and RB5 dtsi and dts
respectively.

A bootable series can be found here

Link: https://git.linaro.org/people/bryan.odonoghue/kernel.git/log/?h=usb-next-25-10-21-pm8150b-tcpm


Bryan O'Donoghue (17):
  dt-bindings: regulator: qcom,usb-vbus-regulator: Mark reg as required
  dt-bindings: regulator: qcom,usb-vbus-regulator: Mark
    regulator-*-microamp required
  dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add orientation-switch
    as optional
  dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add port as an optional
  dt-bindings: usb: Add qcom,pmic-typec dt-binding header
  dt-bindings: usb: Add Qualcomm PMIC Type-C controller YAML schema
  dt-bindings: usb: Add qcom,pmic-pdphy dt-binding header
  dt-bindings: usb: Add Qualcomm PMIC PDPHY controller YAML schema
  dt-bindings: usb: Add Qualcomm PMIC TCPM YAML schema
  dt-bindings: mfd: qcom,spmi-pmic: Add pdphy to SPMI device types
  dt-bindings: mfd: qcom,spmi-pmic: Add typec to SPMI device types
  usb: typec: qcom: Add Qualcomm PMIC TCPM support
  arm64: dts: qcom: pm8150b: Add a TCPM description
  arm64: dts: qcom: qrb5165-rb5: Switch on Type-C VBUS boost
  arm64: dts: qcom: qrb5165-rb5: Switch on basic TCPM
  arm64: dts: qcom: qrb5165-rb5: Switch on TCPM usb-role-switching for
    usb_1
  arm64: dts: qcom: qrb5165-rb5: Switch on TCPM orientation-switch for
    usb_1_qmpphy

Dmitry Baryshkov (1):
  phy: qcom-qmp: Register as a typec switch for orientation detection

 .../bindings/mfd/qcom,spmi-pmic.yaml          |   8 +
 .../phy/qcom,sc7180-qmp-usb3-dp-phy.yaml      |  10 +
 .../regulator/qcom,usb-vbus-regulator.yaml    |  10 +-
 .../bindings/usb/qcom,pmic-pdphy.yaml         |  89 +++
 .../bindings/usb/qcom,pmic-typec.yaml         |  88 +++
 .../bindings/usb/qcom,pmic-virt-tcpm.yaml     |  88 +++
 MAINTAINERS                                   |  10 +
 arch/arm64/boot/dts/qcom/pm8150b.dtsi         |  70 ++
 arch/arm64/boot/dts/qcom/qrb5165-rb5.dts      |  63 +-
 drivers/phy/qualcomm/Kconfig                  |   8 +
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c     |  80 ++-
 drivers/usb/typec/Kconfig                     |  13 -
 drivers/usb/typec/Makefile                    |   1 -
 drivers/usb/typec/qcom-pmic-typec.c           | 261 -------
 drivers/usb/typec/tcpm/Kconfig                |  11 +
 drivers/usb/typec/tcpm/Makefile               |   1 +
 drivers/usb/typec/tcpm/qcom/Makefile          |   6 +
 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.c | 605 +++++++++++++++++
 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.h |  85 +++
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 637 ++++++++++++++++++
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 163 +++++
 .../usb/typec/tcpm/qcom/qcom_pmic_virt_tcpm.c | 326 +++++++++
 .../dt-bindings/usb/typec/qcom,pmic-pdphy.h   |  18 +
 .../dt-bindings/usb/typec/qcom,pmic-typec.h   |  18 +
 24 files changed, 2388 insertions(+), 281 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-pdphy.yaml
 create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml
 create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml
 delete mode 100644 drivers/usb/typec/qcom-pmic-typec.c
 create mode 100644 drivers/usb/typec/tcpm/qcom/Makefile
 create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.c
 create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.h
 create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
 create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
 create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_virt_tcpm.c
 create mode 100644 include/dt-bindings/usb/typec/qcom,pmic-pdphy.h
 create mode 100644 include/dt-bindings/usb/typec/qcom,pmic-typec.h

Comments

Bryan O'Donoghue March 18, 2023, 5:46 p.m. UTC | #1
On 18/03/2023 13:10, Konrad Dybcio wrote:
>> +	usb-role-switch;
> This could maybe go to the SoC DTSI.. Bjorn, Krzysztof, WDYT?

Eh well I think this is a correct comment.

There's no good reason to have this as board-specific since it is a 
controller property. Moreover it only does something when there is a an 
agent to feed data into it.

arch/arm64/boot/dts/qcom/sc7280.dtsi:				usb-role-switch;

---
bod
Krzysztof Kozlowski March 19, 2023, 11:45 a.m. UTC | #2
On 18/03/2023 13:18, Bryan O'Donoghue wrote:
> port is required to instantiate a remote-endpoint which can receive
> orientation-switch messages from a Type-C mux.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  .../bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml           | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml b/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
> index 52886cdb0e506..1c887e34b1223 100644
> --- a/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
> @@ -65,6 +65,12 @@ properties:
>      description: Flag the port as possible handler of orientation switching
>      type: boolean
>  
> +  port:
> +    $ref: /schemas/graph.yaml#/properties/port
> +    description:
> +      A port node to link the PHY to a TypeC controller for the purpose of
> +      handling altmode muxing and orientation switching.

Please extend the example as well.

Don't you have there two ports? USB and DP?

Best regards,
Krzysztof
Krzysztof Kozlowski March 19, 2023, 11:58 a.m. UTC | #3
On 18/03/2023 13:18, Bryan O'Donoghue wrote:
> Add a YAML description for the pm8150b-tcpm driver. The pm8150b-tcpm

No, do not add YAML description for driver.

Please add bindings for some hardware and describe the hardware.

> encapsulates a type-c block and a pdphy block into one block presented to
> the TCPM Linux API.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  .../bindings/usb/qcom,pmic-virt-tcpm.yaml     | 88 +++++++++++++++++++
>  1 file changed, 88 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml
> 
> diff --git a/Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml b/Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml
> new file mode 100644
> index 0000000000000..576842c8b65b4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml
> @@ -0,0 +1,88 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/usb/qcom,pmic-virt-tcpm.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm PMIC Virtual TCPM Driver

All previous comments apply.

> +
> +maintainers:
> +  - Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> +
> +description: |
> +  Qualcomm PMIC Virtual Type-C Port Manager Driver
> +  A virtual device which manages Qualcomm PMIC provided Type-C port and
> +  Power Delivery in one place.

OK, so it looks like bindings for driver, so a no-go. Unless there is
such device as "manager", this does not look like hardware description.

> +
> +properties:
> +  compatible:
> +    const: qcom,pmic-virt-tcpm
> +
> +  connector:
> +    type: object
> +    $ref: /schemas/connector/usb-connector.yaml#
> +    unevaluatedProperties: false
> +
> +  port:
> +    $ref: /schemas/graph.yaml#/properties/port
> +    description:
> +      Contains a port which consumes data-role switching messages.
> +
> +  qcom,pmic-typec:
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description:
> +      A phandle to the typec port hardware driver.
> +
> +  qcom,pmic-pdphy:
> +    $ref: /schemas/types.yaml#/definitions/phandle

Having typec and phy as phandles - not children - also suggests this is
some software construct, not hardware description.



Best regards,
Krzysztof
Krzysztof Kozlowski March 19, 2023, 11:59 a.m. UTC | #4
On 18/03/2023 13:18, Bryan O'Donoghue wrote:> Add the PMIC Type-C port
driver to the list of devices.

Either drop driver everywhere or drop the patches. We do not add drivers
to the bindings.


Best regards,
Krzysztof
Bryan O'Donoghue March 19, 2023, 2:59 p.m. UTC | #5
On 19/03/2023 11:58, Krzysztof Kozlowski wrote:
>> +
>> +maintainers:
>> +  - Bryan O'Donoghue<bryan.odonoghue@linaro.org>
>> +
>> +description: |
>> +  Qualcomm PMIC Virtual Type-C Port Manager Driver
>> +  A virtual device which manages Qualcomm PMIC provided Type-C port and
>> +  Power Delivery in one place.
> OK, so it looks like bindings for driver, so a no-go. Unless there is
> such device as "manager", this does not look like hardware description.
> 
>> +
>> +properties:
>> +  compatible:
>> +    const: qcom,pmic-virt-tcpm
>> +
>> +  connector:
>> +    type: object
>> +    $ref: /schemas/connector/usb-connector.yaml#
>> +    unevaluatedProperties: false
>> +
>> +  port:
>> +    $ref: /schemas/graph.yaml#/properties/port
>> +    description:
>> +      Contains a port which consumes data-role switching messages.
>> +
>> +  qcom,pmic-typec:
>> +    $ref: /schemas/types.yaml#/definitions/phandle
>> +    description:
>> +      A phandle to the typec port hardware driver.
>> +
>> +  qcom,pmic-pdphy:
>> +    $ref: /schemas/types.yaml#/definitions/phandle
> Having typec and phy as phandles - not children - also suggests this is
> some software construct, not hardware description.

So probably I didn't interpret Rob's comment correctly here.

For a pure software device - a virtual device - there should be no dts 
representation at all - not even at the firmware{}, chosen{}, rpm{} 
level, it wouldn't be possible/acceptable to have a tcpm {} with a 
compat pointing to the two phandles I have here ?

---
bod
Krzysztof Kozlowski March 19, 2023, 3:10 p.m. UTC | #6
On 19/03/2023 15:59, Bryan O'Donoghue wrote:
> On 19/03/2023 11:58, Krzysztof Kozlowski wrote:
>>> +
>>> +maintainers:
>>> +  - Bryan O'Donoghue<bryan.odonoghue@linaro.org>
>>> +
>>> +description: |
>>> +  Qualcomm PMIC Virtual Type-C Port Manager Driver
>>> +  A virtual device which manages Qualcomm PMIC provided Type-C port and
>>> +  Power Delivery in one place.
>> OK, so it looks like bindings for driver, so a no-go. Unless there is
>> such device as "manager", this does not look like hardware description.
>>
>>> +
>>> +properties:
>>> +  compatible:
>>> +    const: qcom,pmic-virt-tcpm
>>> +
>>> +  connector:
>>> +    type: object
>>> +    $ref: /schemas/connector/usb-connector.yaml#
>>> +    unevaluatedProperties: false
>>> +
>>> +  port:
>>> +    $ref: /schemas/graph.yaml#/properties/port
>>> +    description:
>>> +      Contains a port which consumes data-role switching messages.
>>> +
>>> +  qcom,pmic-typec:
>>> +    $ref: /schemas/types.yaml#/definitions/phandle
>>> +    description:
>>> +      A phandle to the typec port hardware driver.
>>> +
>>> +  qcom,pmic-pdphy:
>>> +    $ref: /schemas/types.yaml#/definitions/phandle
>> Having typec and phy as phandles - not children - also suggests this is
>> some software construct, not hardware description.
> 
> So probably I didn't interpret Rob's comment correctly here.

He proposed to merge it with other node:
"probably merged with
one of the nodes these phandles point to."

"Why can't most of this binding be part of"

I don't see how you implemented his comments. Actually, nothing improved
here in this regard - you still have these phandles.

> 
> For a pure software device - a virtual device - there should be no dts 
> representation at all - not even at the firmware{}, chosen{}, rpm{} 

By software we interpret here HLOS, so Linux. Firmware is FW, thus not
software in that context. rpm{} is some firmware on some processor.

You wrote here bindings/nodes for a Linux driver.

> level, it wouldn't be possible/acceptable to have a tcpm {} with a 
> compat pointing to the two phandles I have here ?

What is tcpm? Linux driver? Then not. You cannot have device nodes for a
Linux driver.

Best regards,
Krzysztof
Bryan O'Donoghue March 19, 2023, 3:50 p.m. UTC | #7
On 19/03/2023 15:10, Krzysztof Kozlowski wrote:
> What is tcpm? Linux driver? Then not. You cannot have device nodes for a
> Linux driver.

Hmm. Well, actually I'll just - concatonate these into one node but, it 
will have to be called something like "typec" and encompass both 
hardware blocks.

I'll try to make the name of that make sense.

---
bod
Krzysztof Kozlowski March 19, 2023, 5:50 p.m. UTC | #8
On 19/03/2023 16:44, Bryan O'Donoghue wrote:
> On 19/03/2023 15:10, Krzysztof Kozlowski wrote:
>> On 19/03/2023 15:59, Bryan O'Donoghue wrote:
>>> On 19/03/2023 11:58, Krzysztof Kozlowski wrote:
>>>>> +
>>>>> +maintainers:
>>>>> +  - Bryan O'Donoghue<bryan.odonoghue@linaro.org>
>>>>> +
>>>>> +description: |
>>>>> +  Qualcomm PMIC Virtual Type-C Port Manager Driver
>>>>> +  A virtual device which manages Qualcomm PMIC provided Type-C port and
>>>>> +  Power Delivery in one place.
>>>> OK, so it looks like bindings for driver, so a no-go. Unless there is
>>>> such device as "manager", this does not look like hardware description.
>>>>
>>>>> +
>>>>> +properties:
>>>>> +  compatible:
>>>>> +    const: qcom,pmic-virt-tcpm
>>>>> +
>>>>> +  connector:
>>>>> +    type: object
>>>>> +    $ref: /schemas/connector/usb-connector.yaml#
>>>>> +    unevaluatedProperties: false
>>>>> +
>>>>> +  port:
>>>>> +    $ref: /schemas/graph.yaml#/properties/port
>>>>> +    description:
>>>>> +      Contains a port which consumes data-role switching messages.
>>>>> +
>>>>> +  qcom,pmic-typec:
>>>>> +    $ref: /schemas/types.yaml#/definitions/phandle
>>>>> +    description:
>>>>> +      A phandle to the typec port hardware driver.
>>>>> +
>>>>> +  qcom,pmic-pdphy:
>>>>> +    $ref: /schemas/types.yaml#/definitions/phandle
>>>> Having typec and phy as phandles - not children - also suggests this is
>>>> some software construct, not hardware description.
>>>
>>> So probably I didn't interpret Rob's comment correctly here.
>>
>> He proposed to merge it with other node:
>> "probably merged with
>> one of the nodes these phandles point to."
>>
>> "Why can't most of this binding be part of"
>>
>> I don't see how you implemented his comments. Actually, nothing improved
>> here in this regard - you still have these phandles.
> 
> So this comment from Rob is what I was aiming for
> 
> "Your other option is instantiate your own device from the virtual
> driver's initcall based on presence of the 2 nodes above. "
> 
> rather than two mush the pdphy and typec into one device, which they are 
> not.

Sure, but you did not instantiate anything based on these two or one
nodes. You added virtual device node.


> I guess what I'm trying to understand is how you guys would suggest that 
> is actually done.

You have there already node for the PMIC USB Type-C, so this should be
part of it. I really do not understand why this is separate device lying
around in parallel like:

pmic {
	usb {
	};
};

virtual- pmic-tcpm {
};

What hardware piece does such description represent?

> 
> Could I trouble you for an example ?
> 
> ---
> bod

Best regards,
Krzysztof
Bryan O'Donoghue March 19, 2023, 10:32 p.m. UTC | #9
On 19/03/2023 17:50, Krzysztof Kozlowski wrote:
>> So this comment from Rob is what I was aiming for
>>
>> "Your other option is instantiate your own device from the virtual
>> driver's initcall based on presence of the 2 nodes above. "
>>
>> rather than two mush the pdphy and typec into one device, which they are
>> not.
> Sure, but you did not instantiate anything based on these two or one
> nodes. You added virtual device node.

Yes true, but I see the distinction you are making.

> 
>> I guess what I'm trying to understand is how you guys would suggest that
>> is actually done.
> You have there already node for the PMIC USB Type-C, so this should be
> part of it. I really do not understand why this is separate device lying
> around in parallel like:
> 
> pmic {
> 	usb {
> 	};
> };
> 
> virtual- pmic-tcpm {
> };
> 
> What hardware piece does such description represent?
> 

None, yes its a "HLOS" convenience, I take your point.
Bryan O'Donoghue March 23, 2023, 1:39 p.m. UTC | #10
On 21/03/2023 20:49, Rob Herring wrote:
> On Sun, Mar 19, 2023 at 12:45:13PM +0100, Krzysztof Kozlowski wrote:
>> On 18/03/2023 13:18, Bryan O'Donoghue wrote:
>>> port is required to instantiate a remote-endpoint which can receive
>>> orientation-switch messages from a Type-C mux.
>>>
>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>>> ---
>>>   .../bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml           | 6 ++++++
>>>   1 file changed, 6 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml b/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
>>> index 52886cdb0e506..1c887e34b1223 100644
>>> --- a/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
>>> +++ b/Documentation/devicetree/bindings/phy/qcom,sc7180-qmp-usb3-dp-phy.yaml
>>> @@ -65,6 +65,12 @@ properties:
>>>       description: Flag the port as possible handler of orientation switching
>>>       type: boolean
>>>   
>>> +  port:
>>> +    $ref: /schemas/graph.yaml#/properties/port
>>> +    description:
>>> +      A port node to link the PHY to a TypeC controller for the purpose of
>>> +      handling altmode muxing and orientation switching.
>>
>> Please extend the example as well.
>>
>> Don't you have there two ports? USB and DP?
> 
> Or 3: USB, DP, and connector.
> 
> Please make sure this all aligns with what Bjorn and I discussed
> recently. It was for glink specifically.
> 
> Rob

This is a PHY though, the DP, USB endpoints will go into the connector 
or into the typec node itself.

---
bod
Luca Weiss March 24, 2023, 3:10 p.m. UTC | #11
Hi Bryan,

On Sat Mar 18, 2023 at 1:18 PM CET, Bryan O'Donoghue wrote:
> Bryan O'Donoghue (17):
>   dt-bindings: regulator: qcom,usb-vbus-regulator: Mark reg as required
>   dt-bindings: regulator: qcom,usb-vbus-regulator: Mark
>     regulator-*-microamp required
>   dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add orientation-switch
>     as optional
>   dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add port as an optional
>   dt-bindings: usb: Add qcom,pmic-typec dt-binding header
>   dt-bindings: usb: Add Qualcomm PMIC Type-C controller YAML schema
>   dt-bindings: usb: Add qcom,pmic-pdphy dt-binding header
>   dt-bindings: usb: Add Qualcomm PMIC PDPHY controller YAML schema
>   dt-bindings: usb: Add Qualcomm PMIC TCPM YAML schema
>   dt-bindings: mfd: qcom,spmi-pmic: Add pdphy to SPMI device types
>   dt-bindings: mfd: qcom,spmi-pmic: Add typec to SPMI device types
>   usb: typec: qcom: Add Qualcomm PMIC TCPM support
>   arm64: dts: qcom: pm8150b: Add a TCPM description
>   arm64: dts: qcom: qrb5165-rb5: Switch on Type-C VBUS boost
>   arm64: dts: qcom: qrb5165-rb5: Switch on basic TCPM
>   arm64: dts: qcom: qrb5165-rb5: Switch on TCPM usb-role-switching for
>     usb_1
>   arm64: dts: qcom: qrb5165-rb5: Switch on TCPM orientation-switch for
>     usb_1_qmpphy
>
> Dmitry Baryshkov (1):
>   phy: qcom-qmp: Register as a typec switch for orientation detection

I've just given this a spin on sm7225-fairphone-fp4 with pm7250b as the
PMIC (instead of pm8150b).

Overall it seems to work, which is awesome! I think I sent you emails in
the past where I had troubles getting earlier revisions to work.

Still there's some rough edges:

As Jianhua Lu has already reported, I'm also hitting the vbus vsafe5v
message quite often. Returning 0 in that function on error seems to work
around it and everything appears to be fine regardless.

  [  243.939593] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: vbus vsafe5v fail
  [  243.939600] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 1 result -110

If you want to take a peek at the schematics for this device, they're
available here:
https://www.fairphone.com/wp-content/uploads/2022/09/FP4_Information-for-repairers-and-recyclers.pdf
USB things you can find on page 57, the pm7250b is on page 49.

When plugging in the device with TCPM on into my PC (peripheral mode)
then the USB device registers and unregisters every couple of seconds,
never stays stable on. No messages in dmesg when this happens. This only
happens with the USB-C plug in one direction, in the other it
works reliable.

Also I've had it that at some point the usb connection seemed to be kind
of stuck on host mode, plugging the device into my PC didn't appear to
do anything.

For host mode I tried using both a USB stick and a USB-C to headphone
jack dongle, both work fine in both directions.

In any case, I look very much forward to this landing, it will be
awesome to have this feature working OOTB! And let me know if you need
anything tested on this hardware.

Regards
Luca

>
>  .../bindings/mfd/qcom,spmi-pmic.yaml          |   8 +
>  .../phy/qcom,sc7180-qmp-usb3-dp-phy.yaml      |  10 +
>  .../regulator/qcom,usb-vbus-regulator.yaml    |  10 +-
>  .../bindings/usb/qcom,pmic-pdphy.yaml         |  89 +++
>  .../bindings/usb/qcom,pmic-typec.yaml         |  88 +++
>  .../bindings/usb/qcom,pmic-virt-tcpm.yaml     |  88 +++
>  MAINTAINERS                                   |  10 +
>  arch/arm64/boot/dts/qcom/pm8150b.dtsi         |  70 ++
>  arch/arm64/boot/dts/qcom/qrb5165-rb5.dts      |  63 +-
>  drivers/phy/qualcomm/Kconfig                  |   8 +
>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c     |  80 ++-
>  drivers/usb/typec/Kconfig                     |  13 -
>  drivers/usb/typec/Makefile                    |   1 -
>  drivers/usb/typec/qcom-pmic-typec.c           | 261 -------
>  drivers/usb/typec/tcpm/Kconfig                |  11 +
>  drivers/usb/typec/tcpm/Makefile               |   1 +
>  drivers/usb/typec/tcpm/qcom/Makefile          |   6 +
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.c | 605 +++++++++++++++++
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.h |  85 +++
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 637 ++++++++++++++++++
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h | 163 +++++
>  .../usb/typec/tcpm/qcom/qcom_pmic_virt_tcpm.c | 326 +++++++++
>  .../dt-bindings/usb/typec/qcom,pmic-pdphy.h   |  18 +
>  .../dt-bindings/usb/typec/qcom,pmic-typec.h   |  18 +
>  24 files changed, 2388 insertions(+), 281 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-pdphy.yaml
>  create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-typec.yaml
>  create mode 100644 Documentation/devicetree/bindings/usb/qcom,pmic-virt-tcpm.yaml
>  delete mode 100644 drivers/usb/typec/qcom-pmic-typec.c
>  create mode 100644 drivers/usb/typec/tcpm/qcom/Makefile
>  create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.c
>  create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_pdphy.h
>  create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
>  create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.h
>  create mode 100644 drivers/usb/typec/tcpm/qcom/qcom_pmic_virt_tcpm.c
>  create mode 100644 include/dt-bindings/usb/typec/qcom,pmic-pdphy.h
>  create mode 100644 include/dt-bindings/usb/typec/qcom,pmic-typec.h
>
> -- 
> 2.39.2
Luca Weiss March 31, 2023, 8:48 a.m. UTC | #12
Hi Bryan,

On Fri Mar 24, 2023 at 4:28 PM CET, Bryan O'Donoghue wrote:
> On 24/03/2023 15:10, Luca Weiss wrote:
> > When plugging in the device with TCPM on into my PC (peripheral mode)
> > then the USB device registers and unregisters every couple of seconds,
> > never stays stable on. No messages in dmesg when this happens. This only
> > happens with the USB-C plug in one direction, in the other it
> > works reliable.
>
> Sounds like we need to do some SoC specific debug on orientation 
> switching in the PHY.

I also know that the phone has a AW35743 chip in the USB path,
controlled by DP_AUX_EN and DP_AUX_SEL gpios but I think this is only
for displayport, right?

>
> I wonder how many lanes dp_opts->lanes says for your part ?

Not sure.. Where is this configured?
But I also don't have DisplayPort over USB-C (video out) configured yet.
Related question: does video out work on sm8250+pm8150b for you?

>
> Also potentially not having "orientation-switch" in &usb_1_qmpphy{} but, 
> I think we discussed that before.

Definitely have that in my device dts in that node.

When unplugged from my PC (USB-C->USB-A cable) I get

  [ 1236.114620] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000042 detect 0

When plugging in just

  [ 1261.890238] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000062 detect 1

The same exact message also when plugging the USB-C plug the other way
on the phone.

When testing with a USB-C->USB-C cable the behavior is similar. Only one
orientation on the phone is stable, the other one has the same unstable
behavior. The direction on the laptop doesn't matter, both directions
(when not changing the phone direction) is stable. Not sure if this
indicates where something is wrong, I don't know enough USB-C for this
;) 

>
> So either
>
> - PHY orientation turn-around isn't working or

Since plugging in a USB stick works both ways, I assume at least some
part of it is working?

> - DTS orientation-switch isn't happening for you

Not sure what this means / how to check.

I'm attaching the USB-C->USB-C logs both ways, maybe they also show
something interesting?

Regards
Luca

==================================================================================
USB stable (device plug orientation 1):
==================================================================================

[ 1722.130836] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000cb cc1 0x00000001 Ra cc2 0x00000002 Rd attached 1 cc=cc1
[ 1722.331025] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 0 requested 2
[ 1722.331152] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1722.331182] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: on
[ 1722.331224] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 0 control 0x00000003 state on cc cc2 vconn cc1
[ 1722.333742] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 1 result 0
[ 1722.333824] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1722.340158] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1722.373839] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000042 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc1
[ 1722.373880] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000042 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc1
[ 1722.373905] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: off
[ 1722.379037] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 0 result 0
[ 1722.379080] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 0 control 0x00000000 state off cc cc2 vconn cc1
[ 1722.379098] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 2 requested 0
[ 1722.379171] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1722.379193] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: start_toggling: misc 0x00000042 attached 0 port_type 0 current cc 4 new 4
[ 1722.379234] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000042 detect 0
[ 1722.383528] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1722.448649] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1722.448717] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[ 1722.449835] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230fe65 hci version 0x110 quirks 0x0000000000010010
[ 1722.449871] xhci-hcd xhci-hcd.1.auto: irq 188, io mem 0x0a600000
[ 1722.449972] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1722.449982] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[ 1722.449992] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[ 1722.450112] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
[ 1722.450121] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1722.450127] usb usb1: Product: xHCI Host Controller
[ 1722.450132] usb usb1: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1722.450138] usb usb1: SerialNumber: xhci-hcd.1.auto
[ 1722.450468] hub 1-0:1.0: USB hub found
[ 1722.450494] hub 1-0:1.0: 1 port detected
[ 1722.451703] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 1722.451810] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
[ 1722.451822] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1722.451831] usb usb2: Product: xHCI Host Controller
[ 1722.451839] usb usb2: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1722.451846] usb usb2: SerialNumber: xhci-hcd.1.auto
[ 1722.452491] hub 2-0:1.0: USB hub found
[ 1722.452524] hub 2-0:1.0: 1 port detected
[ 1722.453143] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1722.453153] usb usb2: USB disconnect, device number 1
[ 1722.454619] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[ 1722.454640] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1722.454653] usb usb1: USB disconnect, device number 1
[ 1722.457569] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
[ 1723.255900] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000cb cc1 0x00000001 Ra cc2 0x00000002 Rd attached 1 cc=cc1
[ 1723.255956] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000cb cc1 0x00000001 Ra cc2 0x00000002 Rd attached 1 cc=cc1
[ 1723.456104] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 0 requested 2
[ 1723.456214] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1723.456238] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: on
[ 1723.456283] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 0 control 0x00000003 state on cc cc2 vconn cc1
[ 1723.458727] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 1 result 0
[ 1723.458784] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.466539] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.503200] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.503241] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.507535] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.523733] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.523808] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.535554] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.543851] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.543892] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.551553] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.565097] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.571515] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.575554] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.576416] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1723.576482] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[ 1723.577757] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230fe65 hci version 0x110 quirks 0x0000000000010010
[ 1723.577850] xhci-hcd xhci-hcd.1.auto: irq 188, io mem 0x0a600000
[ 1723.578172] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1723.578216] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[ 1723.578258] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[ 1723.578680] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
[ 1723.578723] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1723.578747] usb usb1: Product: xHCI Host Controller
[ 1723.578755] usb usb1: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1723.578760] usb usb1: SerialNumber: xhci-hcd.1.auto
[ 1723.579187] hub 1-0:1.0: USB hub found
[ 1723.579211] hub 1-0:1.0: 1 port detected
[ 1723.579480] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 1723.579548] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
[ 1723.579555] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1723.579560] usb usb2: Product: xHCI Host Controller
[ 1723.579564] usb usb2: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1723.579569] usb usb2: SerialNumber: xhci-hcd.1.auto
[ 1723.581083] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 2 requested 2
[ 1723.581144] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=0 power_role_src=1
[ 1723.581192] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.581234] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.581661] hub 2-0:1.0: USB hub found
[ 1723.581690] hub 2-0:1.0: 1 port detected
[ 1723.582636] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1723.582659] usb usb2: USB disconnect, device number 1
[ 1723.586362] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[ 1723.586421] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1723.586456] usb usb1: USB disconnect, device number 1
[ 1723.591097] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
[ 1723.591580] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.602619] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.602793] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.611512] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.623020] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.623062] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.631625] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.644262] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.650769] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc1
[ 1723.651546] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1723.662850] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 0 control 0x00000000 state off cc cc2 vconn cc1

- unplug -

[ 1867.223052] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000042 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc1
[ 1867.223277] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: off
[ 1867.226027] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 0 result 0
[ 1867.226064] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 0 control 0x00000000 state off cc cc2 vconn cc1
[ 1867.226084] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 2 requested 0
[ 1867.226145] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=0 power_role_src=1
[ 1867.226167] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: start_toggling: misc 0x00000042 attached 0 port_type 0 current cc 5 new 4
[ 1867.226212] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000042 detect 0
[ 1867.236933] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete

==================================================================================
USB unstable (device plug orientation 2):
==================================================================================

[ 1894.263324] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000c9 cc1 0x00000002 Rd cc2 0x00000001 Ra attached 1 cc=cc2
[ 1894.463482] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 0 requested 1
[ 1894.463616] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1894.463646] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: on
[ 1894.463690] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 4 control 0x00000007 state on cc cc1 vconn cc2
[ 1894.466173] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 1 result 0
[ 1894.466257] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1894.474797] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1894.505894] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000040 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc2
[ 1894.505935] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000040 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc2
[ 1894.505963] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: off
[ 1894.510880] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 0 result 0
[ 1894.510920] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 4 control 0x00000000 state off cc cc1 vconn cc2
[ 1894.510940] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 1 requested 0
[ 1894.511021] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1894.511043] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: start_toggling: misc 0x00000040 attached 0 port_type 0 current cc 4 new 4
[ 1894.511084] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000000 detect 0
[ 1894.516552] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1894.581138] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1894.581171] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[ 1894.582287] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230fe65 hci version 0x110 quirks 0x0000000000010010
[ 1894.582330] xhci-hcd xhci-hcd.1.auto: irq 188, io mem 0x0a600000
[ 1894.582464] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1894.582479] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[ 1894.582493] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[ 1894.582649] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
[ 1894.582661] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1894.582670] usb usb1: Product: xHCI Host Controller
[ 1894.582677] usb usb1: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1894.582685] usb usb1: SerialNumber: xhci-hcd.1.auto
[ 1894.583211] hub 1-0:1.0: USB hub found
[ 1894.583255] hub 1-0:1.0: 1 port detected
[ 1894.583830] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 1894.583960] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
[ 1894.583975] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1894.583987] usb usb2: Product: xHCI Host Controller
[ 1894.583996] usb usb2: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1894.584006] usb usb2: SerialNumber: xhci-hcd.1.auto
[ 1894.584742] hub 2-0:1.0: USB hub found
[ 1894.584782] hub 2-0:1.0: 1 port detected
[ 1894.585437] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1894.585452] usb usb2: USB disconnect, device number 1
[ 1894.588024] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[ 1894.588046] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1894.588060] usb usb1: USB disconnect, device number 1
[ 1894.591836] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
[ 1895.388351] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000c9 cc1 0x00000002 Rd cc2 0x00000001 Ra attached 1 cc=cc2
[ 1895.388407] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x000000c9 cc1 0x00000002 Rd cc2 0x00000001 Ra attached 1 cc=cc2
[ 1895.588568] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 0 requested 1
[ 1895.588643] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=1 power_role_src=1
[ 1895.588664] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: on
[ 1895.588705] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 4 control 0x00000007 state on cc cc1 vconn cc2
[ 1895.591193] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 1 result 0
[ 1895.591250] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.598187] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.635829] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.635940] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.640601] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.657692] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.657766] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.664570] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.677799] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.677836] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.684618] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.698467] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.704570] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.705452] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1895.705514] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[ 1895.706625] xhci-hcd xhci-hcd.1.auto: hcc params 0x0230fe65 hci version 0x110 quirks 0x0000000000010010
[ 1895.706658] xhci-hcd xhci-hcd.1.auto: irq 188, io mem 0x0a600000
[ 1895.706747] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1895.706755] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[ 1895.706764] xhci-hcd xhci-hcd.1.auto: Host supports USB 3.0 SuperSpeed
[ 1895.706824] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.707209] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.02
[ 1895.707250] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1895.707280] usb usb1: Product: xHCI Host Controller
[ 1895.707305] usb usb1: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1895.707331] usb usb1: SerialNumber: xhci-hcd.1.auto
[ 1895.708504] hub 1-0:1.0: USB hub found
[ 1895.708635] hub 1-0:1.0: 1 port detected
[ 1895.709607] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 1895.709928] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.02
[ 1895.709970] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1895.709999] usb usb2: Product: xHCI Host Controller
[ 1895.710023] usb usb2: Manufacturer: Linux 6.2.1-00102-gc2551b66fbe7-dirty xhci-hcd
[ 1895.710049] usb usb2: SerialNumber: xhci-hcd.1.auto
[ 1895.711360] hub 2-0:1.0: USB hub found
[ 1895.711392] hub 2-0:1.0: 1 port detected
[ 1895.712739] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.714685] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 1 requested 1
[ 1895.714749] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=0 power_role_src=1
[ 1895.714795] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.714837] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.715104] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1895.715114] usb usb2: USB disconnect, device number 1
[ 1895.718866] xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
[ 1895.718889] xhci-hcd xhci-hcd.1.auto: remove, state 1
[ 1895.718901] usb usb1: USB disconnect, device number 1
[ 1895.725858] xhci-hcd xhci-hcd.1.auto: USB bus 1 deregistered
[ 1895.726158] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.735069] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.735135] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.744571] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.756079] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.756119] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=1 Rp-1.5-180uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.764615] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.776343] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.782944] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_cc: currsrc=2 Rp-3.0-330uA mode EN_SRC_ONLY debounce 1 attached 1 cc=cc2
[ 1895.784556] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete
[ 1895.795184] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 4 control 0x00000000 state off cc cc1 vconn cc2

- unplug -

[ 1907.264840] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000040 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc2
[ 1907.264888] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_cc: misc 0x00000040 cc1 0x00000000 Open cc2 0x00000000 Open attached 0 cc=cc2
[ 1907.265075] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: set_pd_rx: off
[ 1907.267897] qcom,pmic-tcpm pm7250b-tcpm: set_vbus set: 0 result 0
[ 1907.267932] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: set_vconn: orientation 4 control 0x00000000 state off cc cc1 vconn cc2
[ 1907.267951] qcom-qmp-combo-phy 88e8000.phy: Toggling orientation current 1 requested 0
[ 1907.268011] qcom,pmic-usb-pdphy c440000.spmi:pmic@2:pdphy@1700: pdphy_set_roles: data_role_host=0 power_role_src=1
[ 1907.268034] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: start_toggling: misc 0x00000040 attached 0 port_type 0 current cc 5 new 4
[ 1907.268081] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: get_vbus: 0x00000040 detect 0
[ 1907.272422] qcom,pmic-typec c440000.spmi:pmic@2:typec@1500: Debounce cc complete