public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: Jun Li <jun.li@nxp.com>, Marco Felsch <m.felsch@pengutronix.de>
Cc: "robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	Xu Yang <xu.yang_2@nxp.com>
Subject: Re: [PATCH] arm64: dts: imx8mp-evk: add dual-role usb port1 support
Date: Mon, 27 Mar 2023 10:49:47 +0200	[thread overview]
Message-ID: <20230327084947.dcguxgyo2lfen2ms@fatal.se> (raw)
In-Reply-To: <PA4PR04MB964081F4DB2E16D8E300B08389849@PA4PR04MB9640.eurprd04.prod.outlook.com>

On Fri, Mar 24, 2023 at 10:18:17AM +0000, Jun Li wrote:
> 
> 
> > -----Original Message-----
> > From: Marco Felsch <m.felsch@pengutronix.de>
> > Sent: Thursday, March 23, 2023 6:58 PM
> > To: robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org;
> > shawnguo@kernel.org; dl-linux-imx <linux-imx@nxp.com>; festevam@gmail.com
> > Cc: linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> > kernel@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.

#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@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@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

  parent reply	other threads:[~2023-03-27  8:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 10:58 [PATCH] arm64: dts: imx8mp-evk: add dual-role usb port1 support Marco Felsch
2023-03-24 10:18 ` Jun Li
2023-03-27  8:22   ` Marco Felsch
2023-03-27  8:49   ` Andreas Henriksson [this message]
2023-03-27 11:48     ` Jun Li
2023-05-03 18:48       ` Marco Felsch
2023-05-03 19:08         ` Marco Felsch
2023-03-30 14:38     ` Marco Felsch
2023-04-03  9:38       ` Andreas Henriksson
2023-04-05 13:16         ` Shawn Guo
2023-05-03 15:38           ` Marco Felsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230327084947.dcguxgyo2lfen2ms@fatal.se \
    --to=andreas@fatal.se \
    --cc=festevam@gmail.com \
    --cc=jun.li@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox