Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2309943rwb; Sun, 2 Oct 2022 20:55:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VEO++CVrOmEIDJQtOFzWU8gUYShp5/Rw+HR+DOQbF7f4blKrmkM3W6Fj45QqVAVKBswwI X-Received: by 2002:a17:90b:1d01:b0:203:2bda:abb1 with SMTP id on1-20020a17090b1d0100b002032bdaabb1mr9803434pjb.204.1664769309517; Sun, 02 Oct 2022 20:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664769309; cv=none; d=google.com; s=arc-20160816; b=X+5ouTBZ8ongdVesu7uLeCsEk5kTU1Wapjuh9vOXywQMb6ooQiEPRw2pB1xPqoOHTe ShfAztFpm90zR4387/pSgbIMbnJGUgyX58L58iIgQ1hqvvhJcLQSNFVp5JtPzGbTdGcc FfC5bopeA5PCtOzfCwUYooUcNWT1LM+2rSVtnW28bbvX38sfQBCYjVfdPaG9lTgfmJzJ uWZ/0r0xjzIAqSDNV4QAEy6owWfWj0vZblYSuw8f3F2AA4jYF8lOha4rUnT5NKY8hI09 +KGupdin6qhHI/hA+kB7ya/rRVK0OiES5SlvRa5m4yVYkPuI6LT9G7hv31sAhLu8i23z zerg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vxmJHnJAq9IIYHaZPP9CQadUjeHnEryHD+ffwmrX5Og=; b=TNdjqwtQcbUSMNm/CxIDSPSn+DbJqmUO/UQJroaY8S3yuRtYt3TBsb64O7CevXc6NB rCV1eOyMPNNqllhzjLPk/LPKrZTAadh4Z0n1MFBjFa9lyr4zcHcRFl/JBYx1S92EOyT7 7ANMIznKt4jetRgNhdhEDb4hN6lbbnzXF8gUOBQ35URMJIRoSfJ8F3H1VmeHmPpfQ/0G b0f/ZNbEKECeFqFnspLlla2czYNcz5z0lMawI7ByMebGfXQaS8MAA7kn5prAx7Z0LL+n LL2JBu6SqR4Cza9yCfueKetZw2BjU6BFrzPIVlpRoy5EJ/0ymJoTnoYZZoXz+Ix+M1R7 8Dlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bHz5O+U4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a170902f61100b001783af487d1si7364669plg.533.2022.10.02.20.54.40; Sun, 02 Oct 2022 20:55:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bHz5O+U4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229528AbiJCDnN (ORCPT + 99 others); Sun, 2 Oct 2022 23:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiJCDnL (ORCPT ); Sun, 2 Oct 2022 23:43:11 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D2837408 for ; Sun, 2 Oct 2022 20:43:10 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id rk17so19547218ejb.1 for ; Sun, 02 Oct 2022 20:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=vxmJHnJAq9IIYHaZPP9CQadUjeHnEryHD+ffwmrX5Og=; b=bHz5O+U44QAPBRjfjwiRypP1lO1VB7fQ8oK7ussO6V/CA9R2HKH1wr8oZY7Ck3koPZ iNla3MRDfLJfSSzP46QQ7Q/r66T4GuQoAt89QiUAYDGrHQI87/F6LboYfnJbkzJdOcBJ 11rU0MUdgFxc6Gh8qw9BPfsorJtaGq+bLSW9k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=vxmJHnJAq9IIYHaZPP9CQadUjeHnEryHD+ffwmrX5Og=; b=NWkLyQzbqJwrrZ3Bwu5uDpL07yRqyRsUBT8Cc+YKY49uzL+8OywF9TMhyLMOj8aeUk vg8rmt/WoKQy+uu87xS4ShjyZ4oL2FDGJYKWYCOBT/Azf44mZ3aAO6dQTAptk5czWYD3 xaQOItFva+PsLI4/KCjGz02+lQsHBOFuQa2gQcKFQj107I7GEbrg+j4rmJdUmEmak6uX N/6KlLMuHewDj19y64tThEgiC7/GnmtfKkUjkX1I0skJHHfowaxqmYXAaxxXl5tfTG67 V1QB+iod4zbDzDuf82iQED7+dvZ83wivzTki9AIogfTbWKTJZBX94beFPgd/SVaYTJwA cEEg== X-Gm-Message-State: ACrzQf0XybapgEYXGCG9cPaqxaZb/zsfFSkdkcfs0h7GnhTHuZGJPQr1 cR+PqGgClgNA3bKSg4TkiyniSVOHH6m9a3J/Qa0G6Q== X-Received: by 2002:a17:907:1ddb:b0:777:51ba:e58f with SMTP id og27-20020a1709071ddb00b0077751bae58fmr13327358ejc.695.1664768588519; Sun, 02 Oct 2022 20:43:08 -0700 (PDT) MIME-Version: 1.0 References: <20220628182336.GA711518-robh@kernel.org> <20220712174551.GG1823936-robh@kernel.org> In-Reply-To: From: Pin-yen Lin Date: Mon, 3 Oct 2022 11:42:57 +0800 Message-ID: Subject: Re: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding To: Rob Herring Cc: Stephen Boyd , "linux-kernel@vger.kernel.org" , Linux USB List , Benson Leung , Heikki Krogerus , Krzysztof Kozlowski , AngeloGioacchino Del Regno , =?UTF-8?B?TsOtY29sYXMgRiAuIFIgLiBBIC4gUHJhZG8=?= , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?B?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Robert Foss , Sam Ravnborg , Thomas Zimmermann , Xin Ji , Bjorn Andersson , Prashant Malani Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, Are there any thoughts or comments about this proposal? On Sat, Sep 17, 2022 at 2:22 AM Prashant Malani wrote: > > Hi folks, > > On Fri, Sep 2, 2022 at 12:41 AM Prashant Malani wrote: > > > > Hi Rob, > > > > On Jul 12 11:45, Rob Herring wrote: > > > > > > That's not the right interpretation. There should not be some Type-C > > > specific child mux/switch node because the device has no such h/w within > > > it. Assuming all the possibilities Stephen outlined are valid, it's > > > clear this lane selection has nothing to do with Type-C. It does have an > > > output port for its DP output already and using that to describe the > > > connection to DP connector(s) and/or Type-C connector(s) should be > > > handled. > > > Rob > > > > Below I've listed the proposal binding (for the Type-C connector) along > > with 2 sample hardware diagrams and corresponding DT. > > Any thoughts about this proposal? > > > > > The updated binding in usb-c-connector would be as follows: > > > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml > > index ae515651fc6b..a043b09cb8ec 100644 > > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml > > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml > > @@ -183,6 +183,30 @@ properties: > > port@1: > > $ref: /schemas/graph.yaml#/properties/port > > description: Super Speed (SS), present in SS capable connectors. > > + properties: > > + '#address-cells': > > + const: 1 > > + > > + '#size-cells': > > + const: 0 > > + > > + patternProperties: > > + "^endpoint@[0-1]$": > > + $ref: /schemas/graph.yaml#/$defs/endpoint-base > > + description: > > + Endpoints for the two SS lanes. endpoint@0 refers to SSTRX1 (A2,A3,B10,B11) > > + and endpoint@1 refers to SSTRX2 (B2,B3,A10,A11). > > + additionalProperties: false > > + > > + properties: > > + reg: > > + maxItems: 1 > > + > > + remote-endpoint: true > > + > > + required: > > + - reg > > + - remote-endpoint > > > > port@2: > > $ref: /schemas/graph.yaml#/properties/port > > > > Here are 2 examples of how that would look on some existing hardware: > > > > Example 1. 2 usb-c-connectors connecting to 1 drm bridge / DP switch: > > > > Here is the diagram we are using on the MTK platform: > > > > SOC > > +---------------------+ C0 > > | | +----------+ 2 lane +--------+ > > | | | +---------/---------+ SSTRX1 | > > | | | | | | > > | MIPI DPI | | | 2 lane | | > > | +------------+ ANX 7625 +---/-----+ +----+ SSTRX2 | > > | | | | | | +--------+ > > | | +----------+ | | > > +---------------------+ | | > > | | +----------+ 2 lane | | C1 > > | | | +----/----C----+ +--------+ > > | USB3 HC | 2 lane | | | | SSTRX1 | > > | +-----/------+ USB3 HUB | +---------+ | > > | (host controller) | | | 2 lane | | > > | | | +---------/---------+ SSTRX2 | > > +---------------------+ | | | | > > +----------+ +--------+ > > > > Some platforms use it6505, so that can be swapped in for anx7625 > > without any change to the rest of the hardware diagram. > > > > From the above, we can see that it is helpful to describe the > > Type-C SS lines as 2 endpoints: > > - 1 for SSTX1+SSRX1 (A2,A3 + B10,B11) > > - 1 for SSTX2+SSRX2 (B2,B3 + A10, A11) > > > > A device tree for this would look as follows: > > > > // Type-C port driver > > ec { > > ... > > cros_ec_typec { > > ... > > usb-c0 { > > compatible = "usb-c-connector"; > > ports { > > hs : port@0 { > > ... > > }; > > ss: port@1 { > > reg = <1>; > > c0_sstrx1: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&anx7625_out0>; > > }; > > c0_sstrx2: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&usb3hub_out0>; > > }; > > }; > > sbu : port@2 { > > ... > > }; > > }; > > }; > > usb-c1 { > > compatible = "usb-c-connector"; > > ports { > > hs : port@0 { > > ... > > }; > > ss: port@1 { > > reg = <1>; > > c1_sstrx1: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&anx7625_out1>; > > }; > > c1_sstrx2: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&usb3hub_out1>; > > }; > > }; > > sbu : port@2 { > > ... > > }; > > }; > > }; > > }; > > }; > > > > // DRM bridge / Type-C mode switch > > anx_bridge: anx7625@58 { > > compatible = "analogix,anx7625"; > > reg = <0x58>; > > ... > > // Input from DP controller > > port@0 { > > reg = <0>; > > ... > > }; > > > > // Output to Type-C connector / DP panel > > port@1 { > > reg = <1>; > > > > anx7625_out0: endpoint@0 { > > reg = <0>; > > mode-switch; > > remote-endpoint = <&c0_sstrx1>; > > }; > > anx7625_out1: endpoint@1 { > > reg = <1>; > > mode-switch; > > remote-endpoint = <&c1_sstrx1>; > > }; > > }; > > }; > > > > // USB3 hub > > usb3hub: foo_hub { > > ... > > ports@0 { > > // End point connected to USB3 host controller on SOC. > > }; > > port@1 { > > reg = <1>; > > > > foo_hub_out0: endpoint@0 { > > reg = <0>; > > mode-switch; ---> See c.) later > > remote-endpoint = <&c0_sstrx2>; > > }; > > foo_hub_out1: endpoint@1 { > > reg = <1>; > > mode-switch; > > remote-endpoint = <&c1_sstrx2>; > > }; > > }; > > }; > > > > Notes: > > - On the Chrome OS platform, the USB3 Hub is controlled by > > the EC, so we don't really need to describe that connection, > > but I've added a minimal one here just to show how the graph > > connection would work if the HUB was controlled by the SoC. > > - The above assumes that other hardware is controlling orientation. > > We can add "orientation-switch" drivers along the graph path > > if there is other hardware which controls orientation. > > > > Example 2: 1 USB-C connector connected to 1 drm-bridge/ mode-switch > > > > I've tried to use Bjorn's example [1], but I might have made > > some mistakes since I don't have access to the schematic. > > > > > > SoC > > +------------------------------------------+ > > | | > > | +---------------+ | > > | | | | > > | | DP ctrllr | +---------+ | C0 > > | | +-------+ | | 2 lane +----------+ > > | +---------------+ | QMP +-----+-----/--------+ SSTRX1 | > > | | PHY | | | | > > | +-------------+ 2 lane | | | 2 lane | | > > | | +----/----+ +-----+-----/--------+ SSTRX2 | > > | | dwc3 | +---------+ | | | > > | | | | | | > > | | | +---------+ | | | > > | | +---------+ HS PHY | | HS lanes | | > > | +-------------+ | +-----+----/---------+ D +/- | > > | | | | +----------+ > > | +---------+ | > > | | > > +------------------------------------------+ > > > > The DT would look something like this (borrowing from Stephen's example [2]): > > > > qmp { > > mode-switch; ----> See b.) later. > > orientation-switch; > > ports { > > qmp_usb_in: port@0 { > > reg = <0>; > > remote-endpoint = <&usb3_phy_out>; > > }; > > qmp_dp_in: port@1 { > > reg = <1>; > > remote-endpoint = <&dp_phy_out>; > > }; > > port@2 { > > reg = <2>; > > qmp_usb_dp_out0: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&c0_sstrx1>; > > }; > > qmp_usb_dp_out1: endpoint@1 { > > reg = <1>; > > remote-endpoint = <&c0_sstrx2>; > > }; > > }; > > }; > > > > dp-phy { > > ports { > > dp_phy_out: port { > > remote-endpoint = <&qmp_dp_in>; > > }; > > }; > > }; > > > > dwc3: usb-phy { > > ports { > > usb3_phy_out: port@0 { > > reg = <0>; > > remote-endpoint = <&qmp_usb_in>; > > }; > > }; > > }; > > > > glink { > > c0: usb-c-connector { > > compatible = "usb-c-connector"; > > ports { > > hs: port@0 { > > reg = <0>; > > endpoint@0 { > > reg = <0>; > > remote-endpoint = <&hs_phy_out>; > > }; > > }; > > > > ss: port@1 { > > reg = <1>; > > c0_sstrx1: endpoint@0 { > > reg = <0>; > > remote-endpoint = <&qmp_usb_dp_out0>; > > }; > > c0_sstrx2: endpoint@1 { > > reg = <1>; > > remote-endpoint = <&qmp_usb_dp_out1>; > > }; > > }; > > }; > > }; > > }; > > > > Notes: > > a. This proposal doesn't deal with the DRM bridge HPD forwarding; I > > believe that is covered by Stephen's example/proposal in [2], and > > can be addressed separately. That said, this binding is compatible > > with the proposal in [2], that is, make the "mode-switch" driver a > > drm-bridge and forward the HPD info to the upstream DRM-bridge (DP controller). > > The driver implementing "mode-switch" will be able to do that, since > > it gets DP status/attention VDOS with HPD info from the Type-C port driver. > > b. If both SSTRX pairs from a connector are routed to the same > > hardware block (example 2) then the device would keep "mode-switch" > > as a top level property (and the fwnode associated with "mode-switch" > > is the drm-bridge device). > > c. If SSTRX pairs from 2 connectors are routed to the same > > hardware block (example 1), then each end-point which is connected to > > the USB-C connector will have a "mode-switch" property in its end-point. > > There will be 2 mode switches registered here, and the fwnode for each > > "mode-switch" is the end-point node. > > > > b.) and c.) can be handled by Type C mux registration and matching > > code. We already have 3 mux devs for each mux [3]. > > > > For the single mode-switch case, mux_dev[1] will just refer to the top-level > > mode-switch registered by the DRM bridge / switch driver (example 1). > > For the 2 mode-switch case, typec_mux_dev[1] will have 2 child > > typec_mux_dev's, each of which represents the mode-switches > > registered by the DRM bridge / switch driver. Introducing this > > indirection means the port driver / alternate mode driver don't > > need to care about how the connectors are routed; the framework > > will just call the mux_set() function on the mux_dev() or its > > children if it has any. > > > > The benefit of this approach is existing bindings (which just > > assume 1 endpoint from usb-c-connector/port@1) should continue to > > work without any changes. > > > > Why don't we use data lanes for the usb-c-connector > > endpoints? I guess we could, but I am not a fan of adding the > > extra data-lane parsing logic to the Type-C framework (I > > don't think drivers need that level of detail from the connector > > binding). And even then, we will still need an extra end-point > > if the lanes of the USB-C connector are routed to different hardware blocks. > > > > The Type-C connector spec doesn't specify any alternate modes > > with < 1 SSTRX pair, so the most we can ever have (short of a > > major change to the spec) is 2 SSTRX end points for a > > connector each being routed to different hardware blocks. > > Codifying these as endpoint@0 and endpoint@1 in the usb-c-connector > > binding seems to line up nicely with this detail of the spec. > > > > Thanks, > > > > -Prashant > > > > [1] https://lore.kernel.org/linux-usb/Yv1y9Wjp16CstJvK@baldur/ > > [2] https://lore.kernel.org/linux-usb/CAE-0n52-QVeUVCB1qZzPbYyrb1drrbJf6H2DEEW9bOE6mh7egw@mail.gmail.com/ > > [3] https://elixir.bootlin.com/linux/v6.0-rc3/source/drivers/usb/typec/mux.c#L259