From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60902C43334 for ; Wed, 22 Jun 2022 17:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358452AbiFVRhp (ORCPT ); Wed, 22 Jun 2022 13:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236617AbiFVRhe (ORCPT ); Wed, 22 Jun 2022 13:37:34 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4030D3465E for ; Wed, 22 Jun 2022 10:37:32 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id y6so15999882plg.0 for ; Wed, 22 Jun 2022 10:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ip37DPD07EETfXOxsfp2/EM6PqDmL5lG+cbJGq8qMS0=; b=ZPHnCjyjvUbujGkd26KmywiDqMZnRn48AeNxI9NqxorRJckmyQ2rnpsqvG9X4vPxNh u1wNPA+vvIAxgPsOKZUUdMFB8CrSxzONRQmtkdNpmliEFOwYNtDAh8RUvR/b3uHqaZt2 h1n/g5chy8zFgcrmI2Y6OwlWY7m9sjIvjyM0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ip37DPD07EETfXOxsfp2/EM6PqDmL5lG+cbJGq8qMS0=; b=KvGIFGTJBWgM7EgE2K3TrS70fxAXjtc7VqUvRAHeOY6+2pthULJl9hr6zvDLnM4jSt /I3weYRXh3cXx4sFUtazmwW7t2g+6flcLhmpuruZUq1D945x08JHN1E5v7uS1U+g45IP E+WL9FybT/CUMFPXu8i6AIti+/W/x/w1duJhsekRM7HuSW+k6D4VmdP/MA0GlphXHIP/ tyW9yNGseOG3tVUTwR80WZr3nZEWGmHJu6t3mgp1YQtqB/xpZvClylsxnYJ5r8r7+lBd lbBVenMRtSgyMpgbCDhKV/n1MzTyi7hqOr3qdiKfizEU35v9c1v7zRhBg+EdM/gEAMVm g+Ag== X-Gm-Message-State: AJIora/oGdKnij8qMkGwaZgF7T+fB7+wjYipucwBUE8OmM5mFBc6mE7s oC1d/sqVju956LEiE/KKGiSF4DsbB8fdgA== X-Google-Smtp-Source: AGRyM1vsXsxyT7P5XEC2KEN3AdZUJCoJzWRcoryprlb4+a2186xYoUq1U1dIzCQjIjHiHaFAJrvmhg== X-Received: by 2002:a17:90a:b703:b0:1dd:1e2f:97d7 with SMTP id l3-20020a17090ab70300b001dd1e2f97d7mr50693283pjr.62.1655919451266; Wed, 22 Jun 2022 10:37:31 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:37:30 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , Krzysztof Kozlowski , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 1/9] dt-bindings: usb: Add Type-C switch binding Date: Wed, 22 Jun 2022 17:34:30 +0000 Message-Id: <20220622173605.1168416-2-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a binding which represents a component that can control the routing of USB Type-C data lines as well as address data line orientation (based on CC lines' orientation). Reviewed-by: Krzysztof Kozlowski Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado Signed-off-by: Prashant Malani --- Changes since v4: - Added Reviewed-by tags. - Patch moved to 1/9 position (since Patch v4 1/7 and 2/7 were applied to usb-next) Changes since v3: - No changes. Changes since v2: - Added Reviewed-by and Tested-by tags. Changes since v1: - Removed "items" from compatible. - Fixed indentation in example. .../devicetree/bindings/usb/typec-switch.yaml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/typec-switch.yaml diff --git a/Documentation/devicetree/bindings/usb/typec-switch.yaml b/Docu= mentation/devicetree/bindings/usb/typec-switch.yaml new file mode 100644 index 000000000000..78b0190c8543 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/typec-switch.yaml @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/typec-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: USB Type-C Switch + +maintainers: + - Prashant Malani + +description: + A USB Type-C switch represents a component which routes USB Type-C data + lines to various protocol host controllers (e.g USB, VESA DisplayPort, + Thunderbolt etc.) depending on which mode the Type-C port, port partner + and cable are operating in. It can also modify lane routing based on + the orientation of a connected Type-C peripheral. + +properties: + compatible: + const: typec-switch + + mode-switch: + type: boolean + description: Specify that this switch can handle alternate mode switch= ing. + + orientation-switch: + type: boolean + description: Specify that this switch can handle orientation switching. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + description: OF graph binding modelling data lines to the Type-C switc= h. + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Link between the switch and a Type-C connector. + + required: + - port@0 + +required: + - compatible + - ports + +anyOf: + - required: + - mode-switch + - required: + - orientation-switch + +additionalProperties: true + +examples: + - | + drm-bridge { + usb-switch { + compatible =3D "typec-switch"; + mode-switch; + orientation-switch; + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + anx_ep: endpoint { + remote-endpoint =3D <&typec_controller>; + }; + }; + }; + }; + }; --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E0DAC43334 for ; Wed, 22 Jun 2022 17:39:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376467AbiFVRjO (ORCPT ); Wed, 22 Jun 2022 13:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359087AbiFVRjK (ORCPT ); Wed, 22 Jun 2022 13:39:10 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85BE02CE1A for ; Wed, 22 Jun 2022 10:39:02 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id b12-20020a17090a6acc00b001ec2b181c98so111554pjm.4 for ; Wed, 22 Jun 2022 10:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qgh99EBxGgLNrQTAUT0hETOyP/8Bs0IDb9y71koPqbA=; b=SxSb10pEPpA/mENH9tzX6Cx4oRXwsEntigCH1GfQqMz3fKctzHYOnNjRXELwerRmJX o+ygM/XRwkGLxGi42dre8nMzn1ieuUINu8zUE7JNm+loDfEPcCz9Gdti2V1e9qLpv0Qh Od7ZyY1Yse22gI3/vFlHziZy/hOu+5Mt2iyz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qgh99EBxGgLNrQTAUT0hETOyP/8Bs0IDb9y71koPqbA=; b=YtM5k2vjSKwB4Ne7dYzRLiN7fQuwCdb3c3sy6XwPjUpGJZdNJ6gKw4tGF+5vgYbCGE rQ3wJLOVoS9KCOTCICAiaS3C/CT0e/bHi0IxeKAcyCYABlpqicTppM5nujXyRGCD/4Sp slnzld1ZwITfV4hxtBwcN5VZtic/3yUKm/Iq/R9nDKCPiaQmordXX9phYoaL7qg897iH U6t0sEjWNpJ5hL25ksSfGAGGBaDdfjMytG9whYopCCpuiGVCulrPnfzGqirTKvEDVtBD vzPLiHB09Lnb8nfZJXTwWBp1jgMvHCduya60e04NG4g/Y4XlmV9igiDnQyssqL+YLiX6 8KaA== X-Gm-Message-State: AJIora/oapSycPgT30xA0HXodxchQxNbdO5jzTEaRuYqA0hdS4TE8JXb +s7XROLhvFMws4gPRHq+8qzfpDFKp3muJw== X-Google-Smtp-Source: AGRyM1so94Fp7yZbSDNTBz4EDR3Fp6stUXIwlclYmUkkdIYNS8v22rCU52FSM10UI+XCNclyA+LvZA== X-Received: by 2002:a17:90a:5911:b0:1ec:9e24:c671 with SMTP id k17-20020a17090a591100b001ec9e24c671mr4854060pji.173.1655919541762; Wed, 22 Jun 2022 10:39:01 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:39:01 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , Krzysztof Kozlowski , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 2/9] dt-bindings: drm/bridge: anx7625: Add mode-switch support Date: Wed, 22 Jun 2022 17:34:31 +0000 Message-Id: <20220622173605.1168416-3-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Analogix 7625 can be used in systems to switch USB Type-C DisplayPort alternate mode lane traffic between 2 Type-C ports. Update the binding to accommodate this usage by introducing a switch property. Reviewed-by: Krzysztof Kozlowski Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado Signed-off-by: Prashant Malani --- Changes since v4: - Added Reviewed-by tags. - Patch moved to 2/9 position (since Patch v4 1/7 and 2/7 were applied to usb-next). Changes since v3: - Fix unevaluatedProperties usage. - Add additionalProperties to top level "switches" nodes. - Make quotes consistent. - Add '^..$' to regex. (All suggested by Krzysztof Kozlowski) Changes since v2: - Added Reviewed-by and Tested-by tags. Changes since v1: - Introduced patternProperties for "switch" children (suggested by Krzysztof Kozlowski). - Added unevaluatedProperties descriptor (suggested by Krzysztof Kozlowski). - Added "address-cells" and "size-cells" properties to "switches". .../display/bridge/analogix,anx7625.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Documentation/devicetree/bindings/display/bridge/analogix,anx7= 625.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,anx762= 5.yaml index 35a48515836e..bc6f7644db31 100644 --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml @@ -105,6 +105,34 @@ properties: - port@0 - port@1 =20 + switches: + type: object + description: Set of switches controlling DisplayPort traffic on + outgoing RX/TX lanes to Type C ports. + additionalProperties: false + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^switch@[01]$': + $ref: /schemas/usb/typec-switch.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + required: + - switch@0 + required: - compatible - reg @@ -167,5 +195,41 @@ examples: }; }; }; + switches { + #address-cells =3D <1>; + #size-cells =3D <0>; + switch@0 { + compatible =3D "typec-switch"; + reg =3D <0>; + mode-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + anx_typec0: endpoint { + remote-endpoint =3D <&typec_port0>; + }; + }; + }; + }; + switch@1 { + compatible =3D "typec-switch"; + reg =3D <1>; + mode-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + anx_typec1: endpoint { + remote-endpoint =3D <&typec_port1>; + }; + }; + }; + }; + }; }; }; --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C637CCA481 for ; Wed, 22 Jun 2022 17:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358064AbiFVRk3 (ORCPT ); Wed, 22 Jun 2022 13:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344588AbiFVRk2 (ORCPT ); Wed, 22 Jun 2022 13:40:28 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2D22CE09 for ; Wed, 22 Jun 2022 10:40:27 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id k7so15991953plg.7 for ; Wed, 22 Jun 2022 10:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+phphPSX2QRUw0tjQuAYChy3WBtYC3d4W2KVy+eHtGw=; b=oD8jiOaOWh5aqMxI3+gxdJly1kokltURo4J1pPYbZk4EQWQSqhUbX8BiVTxv/Eq74y ldo3TY+Sc/j8kQWCNanxJhYAwnNIFG/RfJlT6XBI11a5JjkLFCTkahcKakMZshxzO/o/ DtXpoJVT34o9NFA2J/MfAvlhQdQje0V42K2rc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+phphPSX2QRUw0tjQuAYChy3WBtYC3d4W2KVy+eHtGw=; b=RcD5B5sWe6Rl8Lu725zXachl4nwLJw+My5i2zciXPXMDV5Kqc1fzPYQDt9KPAigva0 mYon4kv3KK0rwLJXaBqM4rV1o9kW/6Sh2ABGL8Y9NfBQPPOJ8tV3RdOG09FZvI5qZ0QO Ycsy7NCodN3Utw53p3qjyU3YHeaJbfufg+6SKE1PF3ShyNO3V/uhtGLFyBFYyGBf5jsq 4K0OhWOosrTLt/tTECeknrELAo56xSONqm6k7/D9ern8P+lYloihyDnGlPsgs7cwrWu8 dRnWnyyKkh1OD5NQI1sF0yWkFHARbxc5Gdms7FgKSXCaU94GARjEKwzWcX+txfIcFss/ 0zIQ== X-Gm-Message-State: AJIora+STe5wSbov4H6tTlEBlCo340parRa9x1EgOB1LJXSzaWWxPnPe BgRjN3ZSo0VLu0qw1Fssv728bXRuFSjFaQ== X-Google-Smtp-Source: AGRyM1ssKkK+844r5lhZX3MDfkPyWSoqQhMfsDXY150pJ//UPfwP33OcS6jm3l8TWfGyzoyNVJQXEQ== X-Received: by 2002:a17:90a:d148:b0:1ea:4e16:545b with SMTP id t8-20020a17090ad14800b001ea4e16545bmr51326528pjw.132.1655919627126; Wed, 22 Jun 2022 10:40:27 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:40:26 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 3/9] drm/bridge: anx7625: Register number of Type C switches Date: Wed, 22 Jun 2022 17:34:32 +0000 Message-Id: <20220622173605.1168416-4-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Parse the "switches" node, if available, and count and store the number of Type-C switches within it. Since we currently don't do anything with this info, no functional changes are expected from this change. This patch sets a foundation for the actual registering of Type-C switches with the Type-C connector class framework. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado Signed-off-by: Prashant Malani --- Changes since v4: - Added Reviewed-by tags. - Patch moved to 3/9 position (since Patch v4 1/7 and 2/7 were applied to usb-next). Changes since v3: - No changes. Changes since v2: - Move ret variable to Patch v3 6/7. - Make error print a dev_dbg, since it is noisy. - Added Reviewed-by and Tested-by tags. Changes since v1: - No changes. drivers/gpu/drm/bridge/analogix/anx7625.c | 18 ++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/br= idge/analogix/anx7625.c index 53a5da6c49dd..e3d4c2738b8c 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -2581,6 +2581,20 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } =20 +static int anx7625_register_typec_switches(struct device *device, struct a= nx7625_data *ctx) +{ + struct device_node *of =3D of_get_child_by_name(device->of_node, "switche= s"); + + if (!of) + return -ENODEV; + + ctx->num_typec_switches =3D of_get_child_count(of); + if (ctx->num_typec_switches <=3D 0) + return -ENODEV; + + return 0; +} + static int anx7625_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -2686,6 +2700,10 @@ static int anx7625_i2c_probe(struct i2c_client *clie= nt, if (platform->pdata.intp_irq) queue_work(platform->workqueue, &platform->work); =20 + ret =3D anx7625_register_typec_switches(dev, platform); + if (ret) + dev_dbg(dev, "Didn't register Type C switches, err: %d\n", ret); + platform->bridge.funcs =3D &anx7625_bridge_funcs; platform->bridge.of_node =3D client->dev.of_node; if (!anx7625_of_panel_on_aux_bus(&client->dev)) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/br= idge/analogix/anx7625.h index e257a84db962..d5cbca708842 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -473,6 +473,7 @@ struct anx7625_data { struct drm_connector *connector; struct mipi_dsi_device *dsi; struct drm_dp_aux aux; + int num_typec_switches; }; =20 #endif /* __ANX7625_H__ */ --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 039A6C433EF for ; Wed, 22 Jun 2022 17:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376975AbiFVRls (ORCPT ); Wed, 22 Jun 2022 13:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376453AbiFVRlp (ORCPT ); Wed, 22 Jun 2022 13:41:45 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF08326F3 for ; Wed, 22 Jun 2022 10:41:44 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id f16so15206393pjj.1 for ; Wed, 22 Jun 2022 10:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iqFu6eq0doQNxGl3THHsCdmxIIdaHhCl+qW0VkKfqs4=; b=lklvD5Db8dOOqxAjh1aR8cX1jRZ8T41RvAygZLNrG0KTVlwop9NNTcSIf/MaI0vKvU w6Th0eMGj7HQFD8RAMer8JrfBn0L3YJ8ztVZjk/lFAdR8AJWtkbJarK6JYGZOfkqGebS Pj1FD1BIYlaC3mXul3Im6S2OXokgxY5uYqd9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iqFu6eq0doQNxGl3THHsCdmxIIdaHhCl+qW0VkKfqs4=; b=Fa44OLHgjqcLmA/ThZw/kmj4FDt82PWLN7MHuyaYY7BtQhC0FBGMSgN+wy051PXX5O 9G+KKYamERRZ6Zsyhq7GlMnzKFga0fGhhrVSTfb4knynMCbsYdmZHoTvFhOrtjmqBALi TPLYrkQt+3S2aLNNznEmZ47Q06uEealU8og2/gYyf3HzLxHK5tlVcBnDXRkkkdN+ZWLe U7MgNJ3Y2rVOUy8zWOPlXAxY69sSuh6CCE4wGv/+ecVKbImQo2+BO1gVq3NpHQKElWcT VxbDW2SGW/11t1zGQ9ycJrNrjCJLLHyljbYpgTk9lNOdKDIxjU8ajxMuhBLtPo5o0JT1 4GrQ== X-Gm-Message-State: AJIora8zcFrgEqeGNe6tpl/uYX5CxiKXtscpdKQ7LVTdhcjx2FaCW3rW ksh/AZTmJPqQhKVxGWS+W7zgvtgEqShHNg== X-Google-Smtp-Source: AGRyM1vLUQTIiuOXP4qi/rnqbT6Oss85carGi8Gjh88k4W1Cqn+3cKW05jftBBKBLFddxt+Zfe569w== X-Received: by 2002:a17:902:d712:b0:167:757c:a6f4 with SMTP id w18-20020a170902d71200b00167757ca6f4mr36364274ply.5.1655919703356; Wed, 22 Jun 2022 10:41:43 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:41:42 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 4/9] drm/bridge: anx7625: Register Type-C mode switches Date: Wed, 22 Jun 2022 17:34:33 +0000 Message-Id: <20220622173605.1168416-5-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the DT node has "switches" available, register a Type-C mode-switch for each listed "switch". This allows the driver to receive state information about what operating mode a Type-C port and its connected peripherals are in, as well as status information (like VDOs) related to that state. The callback function is currently a stub, but subsequent patches will implement the required functionality. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado Signed-off-by: Prashant Malani --- Changes since v4: - Added Reviewed-by tags. - Patch moved to 4/9 position (since Patch v4 1/7 and 2/7 were applied to usb-next). Changes since v3: - No changes. Changes since v2: - Updated dev_info() to dev_warn() print, but added a check to ensure it only triggers on non -ENODEV errors. - Made conflict resolutions resulting from changes introduced in Patch v3 5/7 (add ret variable here instead of in Patch v3 5/7). - Added Reviewed-by and Tested-by tags. Changes since v1: - No changes. drivers/gpu/drm/bridge/analogix/anx7625.c | 82 +++++++++++++++++++++-- drivers/gpu/drm/bridge/analogix/anx7625.h | 6 ++ 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/br= idge/analogix/anx7625.c index e3d4c2738b8c..bd21f159b973 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -15,6 +15,7 @@ #include #include #include +#include #include =20 #include @@ -2581,10 +2582,61 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } =20 +static int anx7625_typec_mux_set(struct typec_mux_dev *mux, + struct typec_mux_state *state) +{ + return 0; +} + +static int anx7625_register_mode_switch(struct device *dev, struct device_= node *node, + struct anx7625_data *ctx) +{ + struct anx7625_port_data *port_data; + struct typec_mux_desc mux_desc =3D {}; + char name[32]; + u32 port_num; + int ret; + + ret =3D of_property_read_u32(node, "reg", &port_num); + if (ret) + return ret; + + if (port_num >=3D ctx->num_typec_switches) { + dev_err(dev, "Invalid port number specified: %d\n", port_num); + return -EINVAL; + } + + port_data =3D &ctx->typec_ports[port_num]; + port_data->ctx =3D ctx; + mux_desc.fwnode =3D &node->fwnode; + mux_desc.drvdata =3D port_data; + snprintf(name, sizeof(name), "%s-%u", node->name, port_num); + mux_desc.name =3D name; + mux_desc.set =3D anx7625_typec_mux_set; + + port_data->typec_mux =3D typec_mux_register(dev, &mux_desc); + if (IS_ERR(port_data->typec_mux)) { + ret =3D PTR_ERR(port_data->typec_mux); + dev_err(dev, "Mode switch register for port %d failed: %d", port_num, re= t); + } + + return ret; +} + +static void anx7625_unregister_typec_switches(struct anx7625_data *ctx) +{ + int i; + + for (i =3D 0; i < ctx->num_typec_switches; i++) + typec_mux_unregister(ctx->typec_ports[i].typec_mux); +} + static int anx7625_register_typec_switches(struct device *device, struct a= nx7625_data *ctx) { - struct device_node *of =3D of_get_child_by_name(device->of_node, "switche= s"); + struct device_node *of, *sw; + int ret =3D 0; =20 + of =3D of_get_child_by_name(device->of_node, "switches"); if (!of) return -ENODEV; =20 @@ -2592,7 +2644,27 @@ static int anx7625_register_typec_switches(struct de= vice *device, struct anx7625 if (ctx->num_typec_switches <=3D 0) return -ENODEV; =20 - return 0; + ctx->typec_ports =3D devm_kzalloc(device, + ctx->num_typec_switches * sizeof(struct anx7625_port_data), + GFP_KERNEL); + if (!ctx->typec_ports) + return -ENOMEM; + + /* Register switches for each connector. */ + for_each_available_child_of_node(of, sw) { + if (!of_property_read_bool(sw, "mode-switch")) + continue; + ret =3D anx7625_register_mode_switch(device, sw, ctx); + if (ret) { + dev_err(device, "Failed to register mode switch: %d\n", ret); + break; + } + } + + if (ret) + anx7625_unregister_typec_switches(ctx); + + return ret; } =20 static int anx7625_i2c_probe(struct i2c_client *client, @@ -2701,8 +2773,8 @@ static int anx7625_i2c_probe(struct i2c_client *clien= t, queue_work(platform->workqueue, &platform->work); =20 ret =3D anx7625_register_typec_switches(dev, platform); - if (ret) - dev_dbg(dev, "Didn't register Type C switches, err: %d\n", ret); + if (ret && ret !=3D -ENODEV) + dev_warn(dev, "Didn't register Type C switches, err: %d\n", ret); =20 platform->bridge.funcs =3D &anx7625_bridge_funcs; platform->bridge.of_node =3D client->dev.of_node; @@ -2757,6 +2829,8 @@ static int anx7625_i2c_remove(struct i2c_client *clie= nt) =20 drm_bridge_remove(&platform->bridge); =20 + anx7625_unregister_typec_switches(platform); + if (platform->pdata.intp_irq) destroy_workqueue(platform->workqueue); =20 diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/br= idge/analogix/anx7625.h index d5cbca708842..76cfc64f7574 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -443,6 +443,11 @@ struct anx7625_i2c_client { struct i2c_client *tcpc_client; }; =20 +struct anx7625_port_data { + struct typec_mux_dev *typec_mux; + struct anx7625_data *ctx; +}; + struct anx7625_data { struct anx7625_platform_data pdata; struct platform_device *audio_pdev; @@ -474,6 +479,7 @@ struct anx7625_data { struct mipi_dsi_device *dsi; struct drm_dp_aux aux; int num_typec_switches; + struct anx7625_port_data *typec_ports; }; =20 #endif /* __ANX7625_H__ */ --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C91C3C433EF for ; Wed, 22 Jun 2022 17:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377373AbiFVRnA (ORCPT ); Wed, 22 Jun 2022 13:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377369AbiFVRm6 (ORCPT ); Wed, 22 Jun 2022 13:42:58 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D57DF11 for ; Wed, 22 Jun 2022 10:42:55 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id f65so16721973pgc.7 for ; Wed, 22 Jun 2022 10:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ptqr6Gt87GBK7ogASDiLHOYZ5B9Dk9q5REfKiGiBgc0=; b=Jfqg6JJQ7G9ltX2drICxGwUWHhxKuHKFf0kGAkjHl5ZR83RxlZZKlkVyQk7lHOUkJR rIkr9D5BVoYSsT+kdOmkw0b39O7tOqw5bSq64v9u3wiRrrBpi9CAK7IE+rSkL/Hj1irC 2JDLTpQG/8Saf/Ut1zRwrROffMF8vajmdPNaA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ptqr6Gt87GBK7ogASDiLHOYZ5B9Dk9q5REfKiGiBgc0=; b=XX8bqH6ylm62KGRqE6n/szGdMkmkJ4Zf1LqGiag4NKhQTeXCKxzRj/MbyiqFY9L98v cNPJnYVXHs8OOOSfunPt9o5xm/5dsSCDezA3PiyWARhWbj7e5HtQ/lo0RKreVpJsgCXU GpZcfR+U8iwqDocVSbgUSpIKqGHOJLITVwB1nKxrOTZqShiZQjPO9RRGz7uddcBh4VUT 57Vj7SGxof9ZYmV3clhBZJiPal64OKyLYgiwoT25UCRTpI4OFvg+7hlyaUPmHsXdGZax mY+nwi8FyWTBIy9FYq7O6diO9Gnhvb07o+rwKivjU58MHddIY9lFqPojJ1juAE/ltNlX npew== X-Gm-Message-State: AJIora+kW+0A/FAB3eggSTrcjoeN1FtKqyy0achGRLBgZHmaXBXcEGu5 2v+TECQxivmWpiCwQ3cDMPXQlNHB/bAMhg== X-Google-Smtp-Source: AGRyM1tKf6IK4rTXOn4QslrbCdg6CX/PumJ0UUDKbKt9Vz/2UQqZ89g2VS9gjz2ZhpbdipD5/qLGqw== X-Received: by 2002:a63:5703:0:b0:408:b2c3:8df9 with SMTP id l3-20020a635703000000b00408b2c38df9mr3767997pgb.247.1655919774471; Wed, 22 Jun 2022 10:42:54 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:42:53 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Pin-Yen Lin , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Prashant Malani , Allen Chen , Andrzej Hajda , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 5/9] drm/bridge: anx7625: Add typec_mux_set callback function Date: Wed, 22 Jun 2022 17:34:34 +0000 Message-Id: <20220622173605.1168416-6-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pin-Yen Lin Add the callback function when the driver receives state changes of the Type-C port. The callback function configures the crosspoint switch of the anx7625 bridge chip, which can change the output pins of the signals according to the port state. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado Signed-off-by: Pin-Yen Lin Signed-off-by: Prashant Malani --- Changes since v4: - Patch moved to 5/9 position (since Patch v4 1/7 and 2/7 were applied to usb-next). Changes since v3: - Added Reviewed-by tag from Angelo. Changes since v2: - Moved num_typec_switches check to beginning of function - Made dp_connected assignments fit on one line (and removed unnecessary parentheses) - Added Reviewed-by and Tested-by tags. Changes since v1: - No changes. drivers/gpu/drm/bridge/analogix/anx7625.c | 56 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++++ 2 files changed, 69 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/br= idge/analogix/anx7625.c index bd21f159b973..5992fc8beeeb 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include =20 @@ -2582,9 +2583,64 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } =20 +static void anx7625_set_crosspoint_switch(struct anx7625_data *ctx, + enum typec_orientation orientation) +{ + if (orientation =3D=3D TYPEC_ORIENTATION_NORMAL) { + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, + SW_SEL1_SSRX_RX1 | SW_SEL1_DPTX0_RX2); + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, + SW_SEL2_SSTX_TX1 | SW_SEL2_DPTX1_TX2); + } else if (orientation =3D=3D TYPEC_ORIENTATION_REVERSE) { + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, + SW_SEL1_SSRX_RX2 | SW_SEL1_DPTX0_RX1); + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, + SW_SEL2_SSTX_TX2 | SW_SEL2_DPTX1_TX1); + } +} + +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx) +{ + if (ctx->typec_ports[0].dp_connected && ctx->typec_ports[1].dp_connected) + /* Both ports available, do nothing to retain the current one. */ + return; + else if (ctx->typec_ports[0].dp_connected) + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_NORMAL); + else if (ctx->typec_ports[1].dp_connected) + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_REVERSE); +} + static int anx7625_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) { + struct anx7625_port_data *data =3D typec_mux_get_drvdata(mux); + struct anx7625_data *ctx =3D data->ctx; + struct device *dev =3D &ctx->client->dev; + bool new_dp_connected, old_dp_connected; + + if (ctx->num_typec_switches =3D=3D 1) + return 0; + + old_dp_connected =3D ctx->typec_ports[0].dp_connected || ctx->typec_ports= [1].dp_connected; + + dev_dbg(dev, "mux_set dp_connected: c0=3D%d, c1=3D%d\n", + ctx->typec_ports[0].dp_connected, ctx->typec_ports[1].dp_connected); + + data->dp_connected =3D (state->alt && state->alt->svid =3D=3D USB_TYPEC_D= P_SID && + state->alt->mode =3D=3D USB_TYPEC_DP_MODE); + + new_dp_connected =3D ctx->typec_ports[0].dp_connected || ctx->typec_ports= [1].dp_connected; + + /* dp on, power on first */ + if (!old_dp_connected && new_dp_connected) + pm_runtime_get_sync(dev); + + anx7625_typec_two_ports_update(ctx); + + /* dp off, power off last */ + if (old_dp_connected && !new_dp_connected) + pm_runtime_put_sync(dev); + return 0; } =20 diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/br= idge/analogix/anx7625.h index 76cfc64f7574..7d6c6fdf9a3a 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -55,6 +55,18 @@ #define HPD_STATUS_CHANGE 0x80 #define HPD_STATUS 0x80 =20 +#define TCPC_SWITCH_0 0xB4 +#define SW_SEL1_DPTX0_RX2 BIT(0) +#define SW_SEL1_DPTX0_RX1 BIT(1) +#define SW_SEL1_SSRX_RX2 BIT(4) +#define SW_SEL1_SSRX_RX1 BIT(5) + +#define TCPC_SWITCH_1 0xB5 +#define SW_SEL2_DPTX1_TX2 BIT(0) +#define SW_SEL2_DPTX1_TX1 BIT(1) +#define SW_SEL2_SSTX_TX2 BIT(4) +#define SW_SEL2_SSTX_TX1 BIT(5) + /******** END of I2C Address 0x58 ********/ =20 /***************************************************************/ @@ -444,6 +456,7 @@ struct anx7625_i2c_client { }; =20 struct anx7625_port_data { + bool dp_connected; struct typec_mux_dev *typec_mux; struct anx7625_data *ctx; }; --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51357C43334 for ; Wed, 22 Jun 2022 17:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377410AbiFVRoe (ORCPT ); Wed, 22 Jun 2022 13:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377384AbiFVRob (ORCPT ); Wed, 22 Jun 2022 13:44:31 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDA7A3465E for ; Wed, 22 Jun 2022 10:44:23 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id w24so8257639pjg.5 for ; Wed, 22 Jun 2022 10:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OYDYAsce/lvf/QfGm3jCkG+AP6MQ1L8nhfe2kq87L58=; b=RaJ3sON5zAZxk49VCqlnWjZ6D/CiNIfYanugUfOUgXy47wCRqi8FawzM30EIoAuqQr Trnk685D9hf5f1zQVJSkepSnxFReFzXW7Rhj72iUpjjAwpYWLeuKvohYlKrK9PfXj8pP f/22wwHIgwY2IfA9Iw6qFGZMoj3u7M+NaI6/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OYDYAsce/lvf/QfGm3jCkG+AP6MQ1L8nhfe2kq87L58=; b=yS/o2qnH4dBQY4/Hd6fjr/X3CSgoIn0U7oos2WQj5deppDvDhq5zXJtmTgDU8p9OEe CQFFof4FvX2RYzUH7YA+/pOfQT/NkGJ+4mUemQ8h2l+n4AXQluEKPXpSFKWlUHQta+Jh 05yDou6ubSLE6HRXy1LYRuVSvLQwXxDNFkWRVMQOHrdB28I12h4WhFK+IrSuvjiXZx5J yEKig7KOLp80epy/KRL5HXhNgnM7E9nBzUfpqvBp7bEg5n1d1HP3MFM09PMvX/himXTL P5/zzGq/c72bOpu07ZG/6NuB/uiPK3iTeHKcUGWAoc0v7Ga6BPvVhDW9MOja/J7phdZF TfjQ== X-Gm-Message-State: AJIora9e/6Ium332yvrP4i16BtKHFYrBn8G8rxyNWUGwiHMLgJzi0dv1 w/MZfgkHF9EmX1AockW/608Z29Wz69dWIQ== X-Google-Smtp-Source: AGRyM1ty31aam1ZaSwmYgBtv3dtTfaMuAS4USae3mq7FEmOSNketiQDrk6OZDlI6edoaR+3QgyKZww== X-Received: by 2002:a17:90b:314b:b0:1e3:1033:f555 with SMTP id ip11-20020a17090b314b00b001e31033f555mr50517081pjb.245.1655919863147; Wed, 22 Jun 2022 10:44:23 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:44:22 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Pin-Yen Lin , Prashant Malani , Allen Chen , Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 6/9] dt/bindings: drm/bridge: it6505: Add mode-switch support Date: Wed, 22 Jun 2022 17:34:35 +0000 Message-Id: <20220622173605.1168416-7-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pin-Yen Lin ITE IT6505 can be used in systems to switch USB Type-C DisplayPort alternate mode lane traffic between 2 Type-C ports. Update the binding to accommodate this usage by introducing a switch property. Signed-off-by: Pin-Yen Lin Signed-off-by: Prashant Malani --- v5 is the first version for this patch. .../bindings/display/bridge/ite,it6505.yaml | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.ya= ml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml index 833d11b2303a..86bb6dc5ae6f 100644 --- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml @@ -56,13 +56,46 @@ properties: $ref: /schemas/graph.yaml#/properties/port description: A port node pointing to DPI host port node =20 + switches: + type: object + description: Set of switches controlling DisplayPort traffic on + outgoing RX/TX lanes to Type C ports. + additionalProperties: false + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^switch@[01]$': + $ref: /schemas/usb/typec-switch.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + required: + - switch@0 + required: - compatible - ovdd-supply - pwr18-supply - interrupts - reset-gpios - - extcon + +oneOf: + - required: + - extcon + - required: + - switches =20 additionalProperties: false =20 @@ -92,3 +125,65 @@ examples: }; }; }; + - | + #include + + i2c3 { + #address-cells =3D <1>; + #size-cells =3D <0>; + + it6505dptx: it6505dptx@5c { + compatible =3D "ite,it6505"; + interrupts =3D <8 IRQ_TYPE_LEVEL_LOW 8 0>; + reg =3D <0x5c>; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&it6505_pins>; + ovdd-supply =3D <&mt6366_vsim2_reg>; + pwr18-supply =3D <&pp1800_dpbrdg_dx>; + reset-gpios =3D <&pio 177 0>; + + port { + it6505_dp_in: endpoint { + remote-endpoint =3D <&dpi_out>; + }; + }; + + switches { + #address-cells =3D <1>; + #size-cells =3D <0>; + switch@0 { + compatible =3D "typec-switch"; + reg =3D <0>; + mode-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + ite_typec0: endpoint { + remote-endpoint =3D <&typec_port0>; + }; + }; + }; + }; + + switch@1 { + compatible =3D "typec-switch"; + reg =3D <1>; + mode-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + ite_typec1: endpoint { + remote-endpoint =3D <&typec_port1>; + }; + }; + }; + }; + }; + }; + }; --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B998C43334 for ; Wed, 22 Jun 2022 17:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377399AbiFVRp6 (ORCPT ); Wed, 22 Jun 2022 13:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377384AbiFVRpz (ORCPT ); Wed, 22 Jun 2022 13:45:55 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E26D3467E for ; Wed, 22 Jun 2022 10:45:54 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id t3-20020a17090a510300b001ea87ef9a3dso147712pjh.4 for ; Wed, 22 Jun 2022 10:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HUYHW95AtLLmO7V4imqn0bSxETrjySQOkszCKZgpB8c=; b=lbchqIqZHE9CwsidR5WeollNQ6dBNgdTnBG0KNFSuSMHXIevxj6D7aC9O2Teg3vixK WJ1Jr3arfzfufi6xxT/db/9/UlXuAuGrZ5BnHzfyMgsT3ULuzk/danAHku6hBy6TgC2+ 7TZUUjQWMf/S6gPNFwmWDdi8AbH1Y1mJRKcXo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HUYHW95AtLLmO7V4imqn0bSxETrjySQOkszCKZgpB8c=; b=zkXsxfUuq76YTd+YmJJjQazhOlnrnJ8Cg8cFcd5SNX2L5jHKkU6yPW68juKLYj94zj PWrh+AWZ9SERRELuwAfgjL4w1AvzsSqvkeVxE7iDwmp8RFELxSOyMpiNKYVvezdJj0BF Oq+c/JOBR3t7lHnj7Iv8r+ZMpV9cWQ3FCms93pqpRCl+adeO7C2asfbEimJmi62lx5E+ I11Nhlknom00rSlzjgyWgPbsVxD6vxUB2uiB2eI/AjOptLoIK6LvnXQhcZfYMx8QH69/ ZTpl7N8bXq14Xg8Ve8u/RfFHomfApBiVXnMRveVtoY3nt3g+CSVEA5hDppsjCFkS1JQy +osQ== X-Gm-Message-State: AJIora9/4+6FJbXjFAGt/+Y8uCHc20ZMco8o/PR+k9FGgxRbv51/F5Pu L02sgYB5mTSc+qiiiheIFpwpoFljYvfH2w== X-Google-Smtp-Source: AGRyM1sFxe9GH21t/auStPnBEkJHItewIiphX9U6txtmcstedWPu/2gRKDpmd2xjVTxW4cdMr9LGMw== X-Received: by 2002:a17:903:2285:b0:16a:2ee7:4779 with SMTP id b5-20020a170903228500b0016a2ee74779mr13121137plh.43.1655919953548; Wed, 22 Jun 2022 10:45:53 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:45:53 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Pin-Yen Lin , Prashant Malani , Allen Chen , Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 7/9] drm/bridge: it6505: Register number of Type C switches Date: Wed, 22 Jun 2022 17:34:36 +0000 Message-Id: <20220622173605.1168416-8-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pin-Yen Lin Parse the "switches" node, if available, and count and store the number of Type-C switches within it. The extcon registration is still supported, but we don't expect both extcon and typec-switch be registered at the same time. This patch sets a foundation for the actual registering of Type-C switches with the Type-C connector class framework. Signed-off-by: Pin-Yen Lin Signed-off-by: Prashant Malani --- v5 is the first version for this patch. drivers/gpu/drm/bridge/ite-it6505.c | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 4b673c4792d7..b259f9f367f6 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -452,6 +452,7 @@ struct it6505 { struct delayed_work delayed_audio; struct it6505_audio_data audio; struct dentry *debugfs; + int num_typec_switches; =20 /* it6505 driver hold option */ bool enable_drv_hold; @@ -3229,13 +3230,28 @@ static void it6505_shutdown(struct i2c_client *clie= nt) it6505_lane_off(it6505); } =20 +static int it6505_register_typec_switches(struct device *device, struct it= 6505 *it6505) +{ + struct device_node *of; + + of =3D of_get_child_by_name(device->of_node, "switches"); + if (!of) + return -ENODEV; + + it6505->num_typec_switches =3D of_get_child_count(of); + if (it6505->num_typec_switches <=3D 0) + return -ENODEV; + + return 0; +} + static int it6505_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct it6505 *it6505; struct device *dev =3D &client->dev; struct extcon_dev *extcon; - int err, intp_irq; + int err, intp_irq, ret; =20 it6505 =3D devm_kzalloc(&client->dev, sizeof(*it6505), GFP_KERNEL); if (!it6505) @@ -3255,11 +3271,21 @@ static int it6505_i2c_probe(struct i2c_client *clie= nt, if (PTR_ERR(extcon) =3D=3D -EPROBE_DEFER) return -EPROBE_DEFER; if (IS_ERR(extcon)) { - dev_err(dev, "can not get extcon device!"); - return PTR_ERR(extcon); + if (PTR_ERR(extcon) !=3D -ENODEV) + dev_warn(dev, "Cannot get extcon device: %ld", PTR_ERR(extcon)); + it6505->extcon =3D NULL; + } else { + it6505->extcon =3D extcon; } =20 - it6505->extcon =3D extcon; + ret =3D it6505_register_typec_switches(dev, it6505); + if (ret) { + dev_dbg(dev, "Didn't register Type C switches, err: %d", ret); + if (!it6505->extcon) { + dev_err(dev, "Both extcon and typec-switch are not registered."); + return -EINVAL; + } + } =20 it6505->regmap =3D devm_regmap_init_i2c(client, &it6505_regmap_config); if (IS_ERR(it6505->regmap)) { --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B55B3C43334 for ; Wed, 22 Jun 2022 17:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377266AbiFVRrZ (ORCPT ); Wed, 22 Jun 2022 13:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377425AbiFVRrV (ORCPT ); Wed, 22 Jun 2022 13:47:21 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CECD635AAB for ; Wed, 22 Jun 2022 10:47:19 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id l4so16713636pgh.13 for ; Wed, 22 Jun 2022 10:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ozFhzYmR4E95kB5IvCCZ7Zhda6htukA9ft1DlgyNV/o=; b=CawAhneHC/p+xXOIC1j1y4DXWjBHk+xdf6T6b/IRcKfJO4W8BAHwZpeasTZ1klNF3/ xT1GD6SgQ4uPMuEjxQ0Lo+dOzXTfddCoudLE/Ty7XjhN2tAQkL6oX2e1sDtRfIbGMTrI 0iuXYklU8zG8BWpFmjtnIFTnAVshfx6NdPHB4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ozFhzYmR4E95kB5IvCCZ7Zhda6htukA9ft1DlgyNV/o=; b=JPkx5JzUjokf4w+XC5b3DMxwRd6NAkTZYV6A338jT2vc1K2XRclVB+nZIxddEPCc2q TRmMjiL7ZuYUlFLWMXNF7QC24HB0s5sGhetW7DcDbgeEww45/sGsaGOpGBcp7b2Fouhi b5Z97BVWS4O7x6dIEV5IeQj7th0FrhJgSIOvZgynfmjiCXPsUGMMX4xxHqZqgVh71o8G 0w571SPcua53bLs2cW7ZIskv3xA1C8Y5dUqV9zOgHMNFhhaN2m/2maE2vAKUke1h6IZ0 CFH0sxYD7z9PR2ATHE8GQDUA4pC/kLLQrhOsVeE0glgkUyKZ2pLApqmqWQy4JdZlZA71 UeDQ== X-Gm-Message-State: AJIora8pLnM1OK3bASwP6BT4Kp+NTtLzh5tlbUP3RbKLM0E5hTW0cBDm enbpyO2VtSEmgeesPvnfk/pxyVWilNus5A== X-Google-Smtp-Source: AGRyM1tBbILrL9IcBn2sx8C63vhIXgPha/EGUevChjROlBAs1HDcrrQphyTY41RUJ1/FuutnDCyUnA== X-Received: by 2002:a63:8842:0:b0:40d:4365:907f with SMTP id l63-20020a638842000000b0040d4365907fmr1254341pgd.568.1655920039161; Wed, 22 Jun 2022 10:47:19 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:47:18 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Pin-Yen Lin , Prashant Malani , Allen Chen , Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 8/9] drm/bridge: it6505: Register Type-C mode switches Date: Wed, 22 Jun 2022 17:34:37 +0000 Message-Id: <20220622173605.1168416-9-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pin-Yen Lin When the DT node has "switches" available, register a Type-C mode-switch for each listed "switch". This allows the driver to receive state information about what operating mode a Type-C port and its connected peripherals are in, as well as status information (like VDOs) related to that state. The callback function is currently a stub, but subsequent patches will implement the required functionality. Signed-off-by: Pin-Yen Lin Signed-off-by: Prashant Malani --- v5 is the first version for this patch. drivers/gpu/drm/bridge/ite-it6505.c | 85 ++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index b259f9f367f6..cb1dd4cbd33b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -17,6 +17,7 @@ #include #include #include +#include #include =20 #include @@ -402,6 +403,11 @@ struct debugfs_entries { const struct file_operations *fops; }; =20 +struct it6505_port_data { + struct typec_mux_dev *typec_mux; + struct it6505 *it6505; +}; + struct it6505 { struct drm_dp_aux aux; struct drm_bridge bridge; @@ -453,6 +459,7 @@ struct it6505 { struct it6505_audio_data audio; struct dentry *debugfs; int num_typec_switches; + struct it6505_port_data *typec_ports; =20 /* it6505 driver hold option */ bool enable_drv_hold; @@ -3230,9 +3237,59 @@ static void it6505_shutdown(struct i2c_client *clien= t) it6505_lane_off(it6505); } =20 +static int it6505_typec_mux_set(struct typec_mux_dev *mux, + struct typec_mux_state *state) +{ + return 0; +} + +static int it6505_register_mode_switch(struct device *dev, struct device_n= ode *node, + struct it6505 *it6505) +{ + struct it6505_port_data *port_data; + struct typec_mux_desc mux_desc =3D {}; + char name[32]; + u32 port_num; + int ret; + + ret =3D of_property_read_u32(node, "reg", &port_num); + if (ret) + return ret; + + if (port_num >=3D it6505->num_typec_switches) { + dev_err(dev, "Invalid port number specified: %d\n", port_num); + return -EINVAL; + } + + port_data =3D &it6505->typec_ports[port_num]; + port_data->it6505 =3D it6505; + mux_desc.fwnode =3D &node->fwnode; + mux_desc.drvdata =3D port_data; + snprintf(name, sizeof(name), "%s-%u", node->name, port_num); + mux_desc.name =3D name; + mux_desc.set =3D it6505_typec_mux_set; + + port_data->typec_mux =3D typec_mux_register(dev, &mux_desc); + if (IS_ERR(port_data->typec_mux)) { + ret =3D PTR_ERR(port_data->typec_mux); + dev_err(dev, "Mode switch register for port %d failed: %d", port_num, re= t); + } + + return ret; +} + +static void it6505_unregister_typec_switches(struct it6505 *it6505) +{ + int i; + + for (i =3D 0; i < it6505->num_typec_switches; i++) + typec_mux_unregister(it6505->typec_ports[i].typec_mux); +} + static int it6505_register_typec_switches(struct device *device, struct it= 6505 *it6505) { - struct device_node *of; + struct device_node *of, *sw; + int ret =3D 0; =20 of =3D of_get_child_by_name(device->of_node, "switches"); if (!of) @@ -3241,8 +3298,28 @@ static int it6505_register_typec_switches(struct dev= ice *device, struct it6505 * it6505->num_typec_switches =3D of_get_child_count(of); if (it6505->num_typec_switches <=3D 0) return -ENODEV; + it6505->typec_ports =3D devm_kzalloc(device, + it6505->num_typec_switches * + sizeof(struct it6505_port_data), + GFP_KERNEL); + if (!it6505->typec_ports) + return -ENOMEM; =20 - return 0; + /* Register switches for each connector. */ + for_each_available_child_of_node(of, sw) { + if (!of_property_read_bool(sw, "mode-switch")) + continue; + ret =3D it6505_register_mode_switch(device, sw, it6505); + if (ret) { + dev_err(device, "Failed to register mode switch: %d\n", ret); + break; + } + } + + if (ret) + it6505_unregister_typec_switches(it6505); + + return ret; } =20 static int it6505_i2c_probe(struct i2c_client *client, @@ -3280,7 +3357,8 @@ static int it6505_i2c_probe(struct i2c_client *client, =20 ret =3D it6505_register_typec_switches(dev, it6505); if (ret) { - dev_dbg(dev, "Didn't register Type C switches, err: %d", ret); + if (ret !=3D -ENODEV) + dev_warn(dev, "Didn't register Type C switches, err: %d", ret); if (!it6505->extcon) { dev_err(dev, "Both extcon and typec-switch are not registered."); return -EINVAL; @@ -3350,6 +3428,7 @@ static int it6505_i2c_remove(struct i2c_client *clien= t) drm_dp_aux_unregister(&it6505->aux); it6505_debugfs_remove(it6505); it6505_poweroff(it6505); + it6505_unregister_typec_switches(it6505); =20 return 0; } --=20 2.37.0.rc0.104.g0611611a94-goog From nobody Mon Apr 20 02:46:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66343C433EF for ; Wed, 22 Jun 2022 17:48:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377442AbiFVRsh (ORCPT ); Wed, 22 Jun 2022 13:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376841AbiFVRsc (ORCPT ); Wed, 22 Jun 2022 13:48:32 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FE531DF9 for ; Wed, 22 Jun 2022 10:48:30 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id cv13so13901845pjb.4 for ; Wed, 22 Jun 2022 10:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=INtMn1T8YiMhzQt2Th4wtcU0KbijPUKMnT6GFbUU1es=; b=iMepv6cEm1kKrueKz6F8JmBrKe29Bg85av9Djx9b2MBTrbDc+JfTwOd23NQ0BJeQQq 37fpA2gDzLO8DXBdJ7A/uB8Xuvc4+KcZ7fS8DOsSgvAElBeVOGA5tMu6YLkOQDWz3BpQ kizqT+2a2uqLFbJqLLOcqRR8PeNirsLEMS434= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=INtMn1T8YiMhzQt2Th4wtcU0KbijPUKMnT6GFbUU1es=; b=NpY4WKJ5I92uAHh5WvGb98n3sz9dmRDbxXNrnu4f68HSYDuyQMv45Vaa2pY9FdKNeF Y2xjaxmSzsGbKwlrvy/K63j1TtrXHOe2uqreGN7wlGTmgIvYV5g7n2K3qlDawa/K8mUu kkn7YWK9JkLmBh6kHtps5HpyjeEuled8m8gUnbOMW0t3o+SarY315zHqxr9F5kf2TLC5 ofaKoxiGEGpdmJoxPlem+uiTeV3BwpooSOTEJLHI3nsl9W85VpBz4Eb8ecI3E7fvy3bO ViOzK4nhcyRmr4H74S5WKTCgmtC52GTdGOqFK1j+B1uMWOPg3HqliWvwTT/ziMJgjtgV hUOw== X-Gm-Message-State: AJIora9KqKjLzbPXV0EA2NLq9jrMOFgG94F1WCjBqIoF1iHHlPN6hFOG HGZpaOM7hxim7IaWaUTjHx0AhArXE7Mujg== X-Google-Smtp-Source: AGRyM1uOMxnpSmvwdwqtw/1opcMtIJbxFZWf2fsabN2cbcr6zK0lX2+IO4vplGkVs7xRBGrXcbNLOA== X-Received: by 2002:a17:903:41c7:b0:16a:2dcf:c4a0 with SMTP id u7-20020a17090341c700b0016a2dcfc4a0mr13200643ple.83.1655920110049; Wed, 22 Jun 2022 10:48:30 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l17-20020a17090b079100b001ece55aec38sm35470pjz.30.2022.06.22.10.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 10:48:29 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Pin-Yen Lin , Prashant Malani , Allen Chen , Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: [PATCH v5 9/9] drm/bridge: it6505: Add typec_mux_set callback function Date: Wed, 22 Jun 2022 17:34:38 +0000 Message-Id: <20220622173605.1168416-10-pmalani@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.104.g0611611a94-goog In-Reply-To: <20220622173605.1168416-1-pmalani@chromium.org> References: <20220622173605.1168416-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pin-Yen Lin Add the callback function when the driver receives state changes of the Type-C ports. The callback function configures the lane_swap state and ends up updating the lane swap registers of it6505 bridge chip. Signed-off-by: Pin-Yen Lin Signed-off-by: Prashant Malani --- v5 is the first version for this patch. drivers/gpu/drm/bridge/ite-it6505.c | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index cb1dd4cbd33b..87b9bd742b52 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include =20 @@ -404,6 +405,7 @@ struct debugfs_entries { }; =20 struct it6505_port_data { + bool dp_connected; struct typec_mux_dev *typec_mux; struct it6505 *it6505; }; @@ -3237,9 +3239,65 @@ static void it6505_shutdown(struct i2c_client *clien= t) it6505_lane_off(it6505); } =20 +static void it6505_typec_ports_update(struct it6505 *it6505) +{ + usleep_range(3000, 4000); + + if (it6505->typec_ports[0].dp_connected && it6505->typec_ports[1].dp_conn= ected) + /* Both ports available, do nothing to retain the current one. */ + return; + else if (it6505->typec_ports[0].dp_connected) + it6505->lane_swap =3D false; + else if (it6505->typec_ports[1].dp_connected) + it6505->lane_swap =3D true; + + usleep_range(3000, 4000); +} + static int it6505_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) { + struct it6505_port_data *data =3D typec_mux_get_drvdata(mux); + struct it6505 *it6505 =3D data->it6505; + struct device *dev =3D &it6505->client->dev; + bool old_dp_connected, new_dp_connected; + + if (it6505->num_typec_switches =3D=3D 1) + return 0; + + mutex_lock(&it6505->extcon_lock); + + old_dp_connected =3D it6505->typec_ports[0].dp_connected || + it6505->typec_ports[1].dp_connected; + + dev_dbg(dev, "mux_set dp_connected: c0=3D%d, c1=3D%d\n", + it6505->typec_ports[0].dp_connected, it6505->typec_ports[1].dp_connected= ); + + data->dp_connected =3D (state->alt && state->alt->svid =3D=3D USB_TYPEC_D= P_SID && + state->alt->mode =3D=3D USB_TYPEC_DP_MODE); + + new_dp_connected =3D it6505->typec_ports[0].dp_connected || + it6505->typec_ports[1].dp_connected; + + if (it6505->enable_drv_hold) { + dev_dbg(dev, "enable driver hold"); + goto unlock; + } + + it6505_typec_ports_update(it6505); + + if (!old_dp_connected && new_dp_connected) + pm_runtime_get_sync(dev); + + if (old_dp_connected && !new_dp_connected) { + pm_runtime_put_sync(dev); + if (it6505->bridge.dev) + drm_helper_hpd_irq_event(it6505->bridge.dev); + memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); + } + +unlock: + mutex_unlock(&it6505->extcon_lock); return 0; } =20 --=20 2.37.0.rc0.104.g0611611a94-goog