[PATCH] arm64: dts: imx8mp-evk: add dual-role usb port1 support

Marco Felsch m.felsch at pengutronix.de
Wed May 3 11:48:34 PDT 2023


Hi Li, Andreas,

On 23-03-27, Jun Li wrote:
> 
> > -----Original Message-----
> > From: Andreas Henriksson <andreas at fatal.se>
> > Sent: Monday, March 27, 2023 4:50 PM
> > To: Jun Li <jun.li at nxp.com>; Marco Felsch <m.felsch at pengutronix.de>
> > Cc: robh+dt at kernel.org; krzysztof.kozlowski+dt at linaro.org;
> > shawnguo at kernel.org; dl-linux-imx <linux-imx at nxp.com>; festevam at gmail.com;
> > linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org;
> > kernel at pengutronix.de; Xu Yang <xu.yang_2 at nxp.com>
> > Subject: Re: [PATCH] arm64: dts: imx8mp-evk: add dual-role usb port1 support
> > 
> > On Fri, Mar 24, 2023 at 10:18:17AM +0000, Jun Li wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Marco Felsch <m.felsch at pengutronix.de>
> > > > Sent: Thursday, March 23, 2023 6:58 PM
> > > > To: robh+dt at kernel.org; krzysztof.kozlowski+dt at linaro.org;
> > > > shawnguo at kernel.org; dl-linux-imx <linux-imx at nxp.com>;
> > > > festevam at gmail.com
> > > > Cc: linux-arm-kernel at lists.infradead.org;
> > > > linux-kernel at vger.kernel.org; kernel at pengutronix.de
> > > > Subject: [PATCH] arm64: dts: imx8mp-evk: add dual-role usb port1
> > > > support
> > > >
> > > > The i.MX8MP-EVK has a dual-role usb-type-c port marked as PORT1. By
> > > > this commit the dual-role support is added which allows the
> > > > user-space to assign usb-gadget functions to it via the configFS.
> > >
> > > So just ignore the orientation switch will make this port cannot work
> > > at super speed, this is actually why this port is not enabled at upstream.
> > > I see the orientation switch via GPIO for SBU is already merged:
> > > drivers/usb/typec/mux/gpio-sbu-mux.c
> > > Do you have interest to expand this driver to support super speed
> > > switch for this case?
> > [...]
> > 
> > FWIW This is what I ended up with (after backporting the gpio-sbu-mux patches)
> > a little while ago trying to get the usb-c ports going on imx8mp-evk. I've
> > not yet had the time to fully test this (only done host/device, not tested:
> > SS, orientation, etc), so beware that it might be completely wrong.
> 
> Thanks for the advice.
> 
> *reuse* compatible = "gpio-sbu-mux"; can make the basic *function* work,
> but that's not the right direction, SBU has its own signal in typec connector,
> here what we need is the Super Speed signal switch, you can see iMX8MP EVK
> use 2 GPIOs control the SS for 3 states(normal orientation, reserve orientation,
> places all channels in high impedance state), but SBU will disable both channels
> at TYPEC_STATE_USB, this is not correct for USB data, so logically we cannot
> reuse SBU either. But I think this gpio-sbu-mux.c driver can be extended to
> add support super speed signal orientation.

Thanks for the useful input :) I was dug into the usb-c hole and now I'm
back. The "gpio-sbu-mux" should fit perfectly for our use-case, we only
have to tell the driver to act as 'orientation-switch' only. All pieces
are in place so just dts work to do. I will test my new patch and send a
new version which should support super-speed to (fingers crossed).

Regards,
  Marco


> 
> Li Jun 
> 
> > 
> > #include "dt-bindings/usb/pd.h"
> > 
> > &usb3_phy0 {
> >     vbus-power-supply = <&ptn5110>;
> >     status = "okay";
> > };
> > 
> > &usb3_0 {
> >     status = "okay";
> > };
> > 
> > &usb_dwc3_0 {
> >     dr_mode = "otg";
> >     hnp-disable;
> >     srp-disable;
> >     adp-disable;
> >     usb-role-switch;
> >     role-switch-default-mode = "peripheral";
> >     snps,dis-u1-entry-quirk;
> >     snps,dis-u2-entry-quirk;
> >     status = "okay";
> > 
> >     port {
> >         usb3_drd_sw: endpoint {
> >             remote-endpoint = <&typec_dr_sw>;
> >         };
> >     };
> > };
> > 
> > &i2c2 {
> >     clock-frequency = <100000>;
> >     pinctrl-names = "default";
> >     pinctrl-0 = <&pinctrl_i2c2>;
> >     status = "okay";
> > 
> >     ptn5110: tcpc at 50 {
> >         compatible = "nxp,ptn5110";
> >         pinctrl-names = "default";
> >         pinctrl-0 = <&pinctrl_typec>;
> >         reg = <0x50>;
> > 
> >         interrupt-parent = <&gpio4>;
> >         interrupts = <19 IRQ_TYPE_LEVEL_LOW>;
> >         status = "okay";
> > 
> >         port {
> >             typec_dr_sw: endpoint {
> >                 remote-endpoint = <&usb3_drd_sw>;
> >             };
> >         };
> > 
> >         usb_con: connector {
> >             compatible = "usb-c-connector";
> >             label = "USB-C";
> >             power-role = "dual";
> >             data-role = "dual";
> >             try-power-role = "sink";
> >             source-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>;
> >             sink-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)
> >                      PDO_VAR(5000, 20000, 3000)>;
> >             op-sink-microwatt = <15000000>;
> >             self-powered;
> > 
> >             ports {
> >                 #address-cells = <1>;
> >                 #size-cells = <0>;
> > 
> >                 port at 1 {
> >                     reg = <1>;
> >                     typec_con_ss: endpoint {
> >                         remote-endpoint = <&usb3_data_ss>;
> >                     };
> >                 };
> >             };
> >         };
> >     };
> > 
> > };
> > 
> > &iomuxc {
> >     pinctrl_typec: typec1grp {
> >         fsl,pins = <
> >             MX8MP_IOMUXC_SAI1_TXD7__GPIO4_IO19    0x1c4
> >         >;
> >     };
> > 
> >     pinctrl_typec_mux: typec1muxgrp {
> >         fsl,pins = <
> >             MX8MP_IOMUXC_SAI1_MCLK__GPIO4_IO20    0x16
> >             MX8MP_IOMUXC_SD2_WP__GPIO2_IO20        0x16
> >         >;
> >     };
> > 
> > 
> >     pinctrl_i2c2: i2c2grp {
> >         fsl,pins = <
> >             MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL        0x400001c2
> >             MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA        0x400001c2
> >         >;
> >     };
> > };
> > 
> > / {
> >     gpio-sbu-mux {
> >         compatible = "gpio-sbu-mux";
> > 
> >         pinctrl-names = "default";
> >         pinctrl-0 = <&pinctrl_typec_mux>;
> >         select-gpios = <&gpio4 20 GPIO_ACTIVE_LOW>; // (PAD_)SAI1_MCLK ->
> > USB1_SS_SEL
> >         enable-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>; // (PAD_)SD2_WP ->
> > USB1_TYPEC_EN_B -> TYPEC_EN_B
> > 
> >         //mode-switch;
> >         orientation-switch;
> > 
> >         port {
> >             usb3_data_ss: endpoint {
> >                 remote-endpoint = <&typec_con_ss>;
> >             };
> >         };
> >     };
> > };
> > 
> > Hope it might help.
> > 
> > Regards,
> > Andreas Henriksson
> 



More information about the linux-arm-kernel mailing list