Re: [PATCH v5 00/14] Add Qualcomm PMIC TPCM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17/04/2023 08:35, Luca Weiss wrote:
Do you have an idea in which part of the code to start debugging this?
Since orientation detection is working is it maybe in the phy code and
not in the tcpm driver? Or does that also touch crucial stuff for USB
apart from telling phy which direction to use?

PHY - I'd almost just do the following

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index edb788a71edeb..bbac82bd093f8 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -3369,7 +3369,7 @@ static int qmp_combo_typec_switch_set(struct typec_switch_dev *sw,

        dev_dbg(qmp->dev, "Toggling orientation current %d requested %d\n",
                qmp->orientation, orientation);
-
+return 0;

In that case the PHY should "just work" for host or device in one orientation.

The other possibility is that the data role message is not hitting dwc3 drd on your platform.

If you take the last commit on this branch - plus the updated PHY commit

Commit: 171d7f507511 ("usb: dwc3: drd: Enable user-space triggered role-switching")

Commit: eb0daa19f3ad ("phy: qcom-qmp: Register as a typec switch for orientation detection")

https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/linux-next-23-04-17-pm8150b-tcpm-qcom-wrapper-typec-mux

cat /sys/class/usb_role/a600000.usb-role-switch/role

On SM8250 it looks like this

- Attach TypeC accessory with USB key plugged in [1]
  Mount USB key, read/write some data
  Unmount USB key

  cat /sys/class/usb_role/a600000.usb-role-switch/role
  host

- Attach TypeC accessory in opposite orientation
  Run same test

- Connect to PC via TypeC cable
  Run usb-ecm-up.sh [2]

  cat /sys/class/usb_role/a600000.usb-role-switch/role
  device

  PC     : ifconfig enp49s0f3u2u4 192.168.8.1
  SM8250 : ifconfig usb0 192.168.8.2
  Then
    PC     : iperf -s
    SM8250 : iperf -c 192.168.8.1 -t 10
    [  1] 0.0000-10.0706 sec   307 MBytes   256 Mbits/sec

- Unplug from PC - replug TypeC accessory
  Rerun test in both orientations

- Replug target to PC
  In this case we only have to reset the IP address

  PC     : ifconfig enp49s0f3u2u4 192.168.8.1
  SM8250 : ifconfig usb0 192.168.8.2

Yep its worth checking out that the data-role switch is working, we might be looking at the wrong thing for you on the PHY.

[1] https://www.amazon.com/CableCreation-Multiport-Adapter-Gigabit-Ethernet/dp/B08FWMWGTD

[2] usb-ecm-up.sh
root@linaro-gnome:~# cat usb-ecm-up.sh
#!/usr/bin/env bash

# load libcomposite module
modprobe libcomposite

# ensure function is loaded
modprobe usb_f_ecm
modprobe usb_f_ncm

mount -t configfs none /sys/kernel/config/

# create a gadget
mkdir /sys/kernel/config/usb_gadget/g0

# cd to its configfs node
cd /sys/kernel/config/usb_gadget/g0

# configure it (vid/pid can be anything if USB Class is used for driver compat)
echo 0x0525 > idVendor
echo 0xa4a4 > idProduct

# configure its serial/mfg/product
mkdir strings/0x409

echo 0xCAFEBABE > strings/0x409/serialnumber
echo Linaro > strings/0x409/manufacturer
echo qrb5165-rb5 > strings/0x409/product

# create configs
mkdir configs/c.1
mkdir configs/c.1/strings/0x409

# create the function (name must match a usb_f_<name> module such as 'acm')
mkdir functions/ncm.0

echo "CDC ECM" > configs/c.1/strings/0x409/configuration

# associate function with config
ln -s functions/ncm.0 configs/c.1

# Set USB version 3.1
echo 0x0310 > bcdUSB

echo "super-speed-plus" > max_speed

# enable gadget by binding it to a UDC from /sys/class/udc
#echo a600000.dwc3 > UDC
echo a600000.usb > UDC
# to unbind it: echo "" > UDC; sleep 1; rm -rf /sys/kernel/config/usb_gadget/g0

sleep 1

ifconfig usb0 192.168.8.2




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux