From patchwork Wed Jun 22 17:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891220 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 45D78C43334 for ; Wed, 22 Jun 2022 17:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231786AbiFVRhg (ORCPT ); Wed, 22 Jun 2022 13:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239201AbiFVRhe (ORCPT ); Wed, 22 Jun 2022 13:37:34 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4234344CF for ; Wed, 22 Jun 2022 10:37:31 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id m14so15978821plg.5 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=uZ4IKXgrTSQsAeqhFzB6UVZVduuNa+nOmLKAr9gOQETboWLk6uxZkBHXpPiyUrYych PIm/UrQXm39GuBWPPZI1E7J2Vz30VxVqqYDVZlUWcYzyjLsHFPu5TA4qw8UoC/flSa3F VgbAy6CVmHaVow4IIkwEtuBPxzz7ayYJfja4PIEJ5HeRFXvqN0ywpjvbicLuGbGRudoV TJgKc4vYQpuL0aJBAVCV7EHGy9pPf0vuHz+P1bKy0o0ABigB5sVgxtu5x4POQnGl0X7D 8aIk9IXnzXkafa+fuMksIDVITJsymtvqsDubsw8MdAUXTaA4dSOYszmW6OxLOD6KGprY dg6w== X-Gm-Message-State: AJIora9EUDR3y5d0Jft7RIqjbHh8lGXdZEJVSLC4LYgavID748paTFxx qAQMdmJkvLKFXyVbytm7B4c+tg== 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_F_=2E_R_=2E_A_=2E_Prado?= , 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?b?Sm9zw6kgRXhww7NzaXRv?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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ícolas F. R. A. Prado Tested-by: Nícolas 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/Documentation/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 switching. + + 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 switch. + + 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 = "typec-switch"; + mode-switch; + orientation-switch; + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + anx_ep: endpoint { + remote-endpoint = <&typec_controller>; + }; + }; + }; + }; + }; From patchwork Wed Jun 22 17:34:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891227 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 D70C2C43334 for ; Wed, 22 Jun 2022 17:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359263AbiFVRjL (ORCPT ); Wed, 22 Jun 2022 13:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346568AbiFVRjG (ORCPT ); Wed, 22 Jun 2022 13:39:06 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE1C1AD8A for ; Wed, 22 Jun 2022 10:39:02 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id k12-20020a17090a404c00b001eaabc1fe5dso135269pjg.1 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=UnBMkv71MGLhnwMaa3Aug9H7LxQxYVo0k3K/iodkZd+90TnYLQx5BqEvmI0y+3wSSa CxHUIktg84QU9cYFZoCGiWbyiP24SDkIfvC1oNgo6rDgpvGJY2lzshZgoAp/1TQrEMQs 2VxmsEHQMarpl6qnB2pZYanKJQqbBiRtec2Gp00PRmWQciyIQ4T2tWLGGakA8vms4Fmp fDHkKCmz7cMlrFF/fqB7CA/e28lzmtYwpEhRZ2TdQOlxLcxPGzNrW9NT5pKxpa77pQtH DeWKCSAGGTYCdj7Ph8eAdkoIL9362kJkHYNjaViHqKyNatJkCNdtA0NcF7NF/5gwxHEL mJPg== X-Gm-Message-State: AJIora96GsSlGEfwP9UrGrAhtHtHM2rvTgltpar1lHLzPbrO6htjtOjC 3sbetry9JaJ2mDT7qBHvmHy7iw== 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_F_=2E_R_=2E_A_=2E_Prado?= , 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?b?Sm9zw6kgRXhww7NzaXRv?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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ícolas F. R. A. Prado Tested-by: Nícolas 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,anx7625.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.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 + 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 = <1>; + #size-cells = <0>; + switch@0 { + compatible = "typec-switch"; + reg = <0>; + mode-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + anx_typec0: endpoint { + remote-endpoint = <&typec_port0>; + }; + }; + }; + }; + switch@1 { + compatible = "typec-switch"; + reg = <1>; + mode-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + anx_typec1: endpoint { + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + }; }; }; From patchwork Wed Jun 22 17:34:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891228 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 28595CCA47D for ; Wed, 22 Jun 2022 17:40:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232837AbiFVRk3 (ORCPT ); Wed, 22 Jun 2022 13:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbiFVRk2 (ORCPT ); Wed, 22 Jun 2022 13:40:28 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 990F72DA89 for ; Wed, 22 Jun 2022 10:40:27 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id a17so14018296pls.6 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=He1tbuMPfUNBmU6qdzGOFD8iCJsWWXuuPr83UYGUEHo9Eh+v0ugd79AEmFcfYliUdn jtAyn2fMaP8i6HWYvqTFXF0BIn4HwaeLWXX0qA2+sCdSZJUN32cS1/b9aXbZgjXUTDjV BPvTcXK4NL3C9nAew8JlQsaTEr1t4mIm4lNE/LXKJrmYvjq7b2zZIWGfyv1xT4PEPLvM BTvsILKl7aOH/kzH+4tCYacLle6+dRdQFsXUgjLZLCnfuLpNJbcWUYUE/mzo5v4BRDHI BP46u84ReHY3CgWnTChwTJsvhN7fft3X9AhPt2MiLJ3xnEKSfUi6X8Pn5Ga57LjfL3Lc kFYQ== X-Gm-Message-State: AJIora+gnU7MUkOihv5YbtFCeCyiEBrgyEJMdDYwJVv/rcmqjsa9U2an pcoSh/WrM5J3Y2UI1dXhuBcfpQ== 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_F_=2E_R_=2E_A_=2E_Prado?= , 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?b?Sm9zw6kgRXhww7NzaXRv?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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ícolas F. R. A. Prado Tested-by: Nícolas 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/bridge/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); } +static int anx7625_register_typec_switches(struct device *device, struct anx7625_data *ctx) +{ + struct device_node *of = of_get_child_by_name(device->of_node, "switches"); + + if (!of) + return -ENODEV; + + ctx->num_typec_switches = of_get_child_count(of); + if (ctx->num_typec_switches <= 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 *client, if (platform->pdata.intp_irq) queue_work(platform->workqueue, &platform->work); + ret = anx7625_register_typec_switches(dev, platform); + if (ret) + dev_dbg(dev, "Didn't register Type C switches, err: %d\n", ret); + platform->bridge.funcs = &anx7625_bridge_funcs; platform->bridge.of_node = 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/bridge/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; }; #endif /* __ANX7625_H__ */ From patchwork Wed Jun 22 17:34:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891229 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 E62B7CCA481 for ; Wed, 22 Jun 2022 17:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376490AbiFVRlq (ORCPT ); Wed, 22 Jun 2022 13:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376298AbiFVRlo (ORCPT ); Wed, 22 Jun 2022 13:41:44 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59FA30571 for ; Wed, 22 Jun 2022 10:41:43 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id d14so13095224pjs.3 for ; Wed, 22 Jun 2022 10:41:43 -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=NyYUbgkITEuxpn6vyIGdU1KrAMAVqgYBuRGVqEVwzxgxPq+XOtpdB2ptXJH4cwT2Yb VKWGTvb2fC8jC1kX/5c/KZXGo4cflVCUCEBQXPW18tAbcnjXdb8kP3WAFXO0IskPt1Z5 PzIC/vtsy0DbdpwOTrW8R4ob9HqT+VaFFsggNY5QSBer226oFS9tkAJDSUdOcO7pPD63 B3f6Bbr6T8FTEB2zOr/JNqZMiTvomyUE2pnYWthP9XHfWSPatyOkHz8+UyyZ9Qxx3Olc M0ypm7f9c+HxwhdtDbB0CzuqTTu5dDBj5WJ7AdJ3gUOUb/KhkANUFkLctSuMZti19TcK QAxQ== X-Gm-Message-State: AJIora+80CMUngwG6kGu6mzvFeyCoFb/3zgUbrNjT+jkbAUHvB0iVoni G3JDuWp0IHq79Q5eNcvTB5hCQQ== 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_F_=2E_R_=2E_A_=2E_Prado?= , 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?b?Sm9zw6kgRXhww7NzaXRv?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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ícolas F. R. A. Prado Tested-by: Nícolas 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/bridge/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 #include @@ -2581,10 +2582,61 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } +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 = {}; + char name[32]; + u32 port_num; + int ret; + + ret = of_property_read_u32(node, "reg", &port_num); + if (ret) + return ret; + + if (port_num >= ctx->num_typec_switches) { + dev_err(dev, "Invalid port number specified: %d\n", port_num); + return -EINVAL; + } + + port_data = &ctx->typec_ports[port_num]; + port_data->ctx = ctx; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; + snprintf(name, sizeof(name), "%s-%u", node->name, port_num); + mux_desc.name = name; + mux_desc.set = anx7625_typec_mux_set; + + port_data->typec_mux = typec_mux_register(dev, &mux_desc); + if (IS_ERR(port_data->typec_mux)) { + ret = PTR_ERR(port_data->typec_mux); + dev_err(dev, "Mode switch register for port %d failed: %d", port_num, ret); + } + + return ret; +} + +static void anx7625_unregister_typec_switches(struct anx7625_data *ctx) +{ + int i; + + for (i = 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 anx7625_data *ctx) { - struct device_node *of = of_get_child_by_name(device->of_node, "switches"); + struct device_node *of, *sw; + int ret = 0; + of = of_get_child_by_name(device->of_node, "switches"); if (!of) return -ENODEV; @@ -2592,7 +2644,27 @@ static int anx7625_register_typec_switches(struct device *device, struct anx7625 if (ctx->num_typec_switches <= 0) return -ENODEV; - return 0; + ctx->typec_ports = 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 = 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; } static int anx7625_i2c_probe(struct i2c_client *client, @@ -2701,8 +2773,8 @@ static int anx7625_i2c_probe(struct i2c_client *client, queue_work(platform->workqueue, &platform->work); ret = anx7625_register_typec_switches(dev, platform); - if (ret) - dev_dbg(dev, "Didn't register Type C switches, err: %d\n", ret); + if (ret && ret != -ENODEV) + dev_warn(dev, "Didn't register Type C switches, err: %d\n", ret); platform->bridge.funcs = &anx7625_bridge_funcs; platform->bridge.of_node = client->dev.of_node; @@ -2757,6 +2829,8 @@ static int anx7625_i2c_remove(struct i2c_client *client) drm_bridge_remove(&platform->bridge); + anx7625_unregister_typec_switches(platform); + if (platform->pdata.intp_irq) destroy_workqueue(platform->workqueue); diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/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; }; +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; }; #endif /* __ANX7625_H__ */ From patchwork Wed Jun 22 17:34:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891230 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 69BA5CCA47D for ; Wed, 22 Jun 2022 17:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377375AbiFVRm6 (ORCPT ); Wed, 22 Jun 2022 13:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376453AbiFVRm6 (ORCPT ); Wed, 22 Jun 2022 13:42:58 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D420F0A for ; Wed, 22 Jun 2022 10:42:54 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id e63so15225203pgc.5 for ; Wed, 22 Jun 2022 10:42: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=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=oZ3tWhGrjYNK69RE47WKsbo/0in33tjoqF2RHaNAGvPjR8btL5+nOUYP4F52TfiOEb cL2L/LNQ86IIgXAFKHQCecBoYgGQHLzJQIZxwT2kCmGEr9omGsl/hTUZgRwpeGNJeeTx J/jWSt+TerA+MxGCyhsAWxFXQFXr8QeX2HVK3cUqbX0arwyLj/xKFknqKo9vWGMpd/hU YvgltjPU3q3a7qh7rdgFaQuWe0xDq+Ei+NIRV+hBaGY63G8WyKKMDl6E4Pwxarf3H7P2 io7eMU8EQ/SHfkdTHUCU70XWza7iT5XUd5EoqaawQHKXJAdx4H224Utqud7rL3Amnm7h iwZg== X-Gm-Message-State: AJIora81oxyrT4WbASpAIbDWQE7nIN+5xiP1UF1Ze8bT6/PsyW3XKD5v 9FsV6WhzOd7TFH5UHyV1RHXwxQ== 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_F_=2E_R_=2E_A_=2E_Prado?= , 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?b?Sm9zw6kgRXhww7NzaXRv?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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ícolas F. R. A. Prado Tested-by: Nícolas 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/bridge/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 @@ -2582,9 +2583,64 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } +static void anx7625_set_crosspoint_switch(struct anx7625_data *ctx, + enum typec_orientation orientation) +{ + if (orientation == 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 == 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 = typec_mux_get_drvdata(mux); + struct anx7625_data *ctx = data->ctx; + struct device *dev = &ctx->client->dev; + bool new_dp_connected, old_dp_connected; + + if (ctx->num_typec_switches == 1) + return 0; + + old_dp_connected = ctx->typec_ports[0].dp_connected || ctx->typec_ports[1].dp_connected; + + dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", + ctx->typec_ports[0].dp_connected, ctx->typec_ports[1].dp_connected); + + data->dp_connected = (state->alt && state->alt->svid == USB_TYPEC_DP_SID && + state->alt->mode == USB_TYPEC_DP_MODE); + + new_dp_connected = 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; } diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/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 +#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 ********/ /***************************************************************/ @@ -444,6 +456,7 @@ struct anx7625_i2c_client { }; struct anx7625_port_data { + bool dp_connected; struct typec_mux_dev *typec_mux; struct anx7625_data *ctx; }; From patchwork Wed Jun 22 17:34:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891237 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 36BC6C43334 for ; Wed, 22 Jun 2022 17:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377414AbiFVRoc (ORCPT ); Wed, 22 Jun 2022 13:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359728AbiFVRo3 (ORCPT ); Wed, 22 Jun 2022 13:44:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A44CB34654 for ; Wed, 22 Jun 2022 10:44:23 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id go6so11778946pjb.0 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=qPkqMJQTSgFrbuw7Qrmg7oqOgmpqAQYCqunf6wVzasEl0M2UAtYgEkBQXa80YO7qxE aIE9xjPMDNSigBP2LkOspt+FnfAn1QYsvH52IdyQScuIKk3ejiz5EK8eaa82I0IETzJ/ FRe6nL88SOqtBxzC5PFknaibkFK0HQN5jVoKYBI04NDlxhYl1HuIPyW9iZbb1YbvYez2 ra3oFcwPl0mVZkVMjUtNTduUhiaSRJqvBvsN1qdeublItfW6R8r1iyssUuCv87xPgjMH /edJO0Oexg0aAXR0GDg/vY+l4COjlZw+n49PW9QLkm/5OIgP77nNNSGonOceZcW3OObv 6ZQg== X-Gm-Message-State: AJIora8nbYbFEmFLaSHK/2CzdNh2aYyl9jE7ecrrc95AW6OWKk0KUzSl hD3yaSJfFyiAr0j0U3Ct5CtYiQ== 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?b?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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.yaml 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 + 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 additionalProperties: false @@ -92,3 +125,65 @@ examples: }; }; }; + - | + #include + + i2c3 { + #address-cells = <1>; + #size-cells = <0>; + + it6505dptx: it6505dptx@5c { + compatible = "ite,it6505"; + interrupts = <8 IRQ_TYPE_LEVEL_LOW 8 0>; + reg = <0x5c>; + pinctrl-names = "default"; + pinctrl-0 = <&it6505_pins>; + ovdd-supply = <&mt6366_vsim2_reg>; + pwr18-supply = <&pp1800_dpbrdg_dx>; + reset-gpios = <&pio 177 0>; + + port { + it6505_dp_in: endpoint { + remote-endpoint = <&dpi_out>; + }; + }; + + switches { + #address-cells = <1>; + #size-cells = <0>; + switch@0 { + compatible = "typec-switch"; + reg = <0>; + mode-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + ite_typec0: endpoint { + remote-endpoint = <&typec_port0>; + }; + }; + }; + }; + + switch@1 { + compatible = "typec-switch"; + reg = <1>; + mode-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + ite_typec1: endpoint { + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + }; + }; + }; From patchwork Wed Jun 22 17:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891238 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 7CE73CCA47D for ; Wed, 22 Jun 2022 17:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359728AbiFVRp4 (ORCPT ); Wed, 22 Jun 2022 13:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbiFVRpy (ORCPT ); Wed, 22 Jun 2022 13:45:54 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A45834654 for ; Wed, 22 Jun 2022 10:45:54 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id b12-20020a17090a6acc00b001ec2b181c98so127708pjm.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=kElEwq538IwoPaL7lb39OSo7bArUJne+iPmiJxH+ySwNJGq+uefem9dpfW1CJauzK2 62vAHdoGTgGvmRFmoN/2aFsCQXgd2XbgydcJOYXhZ4ieNxSn/c6LX/396dSfF7uv05Wo iI9T6RaZgeZCPOwoxiRZSxat4PkRoXGlSunHb1NXH1HppHTARZL7ZhzQ3pD3ctsFNvLM WXoAHWcNXKTtwjTg8pssoBWkTAglnBrurq66zAo8XYkPwiqopJ1Y+5JgkT4cEWVKS1m2 X4eWyft3f79xXbkMjIgGXvPhmPT5eT8XlQTdvr2hVfgoqmnjZa9oRu/1NR8uR/jBoryt +nEQ== X-Gm-Message-State: AJIora/9i1bj7ddIaBkfZMXbdmyXSOozWBQ6Yuzfk91+TVVj5kWH1Ej2 qr12qkOpZ2xbfEOpZtXbqVrEsQ== 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?b?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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/ite-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; /* it6505 driver hold option */ bool enable_drv_hold; @@ -3229,13 +3230,28 @@ static void it6505_shutdown(struct i2c_client *client) it6505_lane_off(it6505); } +static int it6505_register_typec_switches(struct device *device, struct it6505 *it6505) +{ + struct device_node *of; + + of = of_get_child_by_name(device->of_node, "switches"); + if (!of) + return -ENODEV; + + it6505->num_typec_switches = of_get_child_count(of); + if (it6505->num_typec_switches <= 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 = &client->dev; struct extcon_dev *extcon; - int err, intp_irq; + int err, intp_irq, ret; it6505 = devm_kzalloc(&client->dev, sizeof(*it6505), GFP_KERNEL); if (!it6505) @@ -3255,11 +3271,21 @@ static int it6505_i2c_probe(struct i2c_client *client, if (PTR_ERR(extcon) == -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) != -ENODEV) + dev_warn(dev, "Cannot get extcon device: %ld", PTR_ERR(extcon)); + it6505->extcon = NULL; + } else { + it6505->extcon = extcon; } - it6505->extcon = extcon; + ret = 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; + } + } it6505->regmap = devm_regmap_init_i2c(client, &it6505_regmap_config); if (IS_ERR(it6505->regmap)) { From patchwork Wed Jun 22 17:34:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891239 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 22CFCC433EF for ; Wed, 22 Jun 2022 17:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377428AbiFVRrY (ORCPT ); Wed, 22 Jun 2022 13:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377423AbiFVRrU (ORCPT ); Wed, 22 Jun 2022 13:47:20 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A2F35A89 for ; Wed, 22 Jun 2022 10:47:19 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id n12so9815546pfq.0 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=plFsnu7cLlXYiEHYvsVnehPUeiIPqI8uS4hF8WHLnvCMlA1G/EFaNEOGC6qDGtUS8e VEk7GB84orSv24f1SaE/GNyv4CJ5NEw0SmAdtwMKPMQ3BmraF4TbdH/6NUxYKddxOXZ7 n8axyDES+3c9yAXNb71l7Sc1KAC/oMxaAYX9FMpKFi07x0oRKCFOiiPw2BEt4Cuvm4KH 2dodswZAPfC/iB5ZVS623GoCTLTkUDvZZ5sATfrnm2hV5SoCllrIzl4BkXd3IOlZ7XaJ 3WiNVudBhdaX5eyfn7MzkQi+LzRicC2Ef9JL7ZbkrUQkibgWo9anxHbf5LGrmvxTmy2q MXug== X-Gm-Message-State: AJIora9Wip/nhEYzDSL+WjlfdJWgqmju3wBoyvM/BF0L9G7uwMBhj4t4 39M3KBSPkyggFuMLVhS/hPfRIA== 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?b?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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/ite-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 #include @@ -402,6 +403,11 @@ struct debugfs_entries { const struct file_operations *fops; }; +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; /* it6505 driver hold option */ bool enable_drv_hold; @@ -3230,9 +3237,59 @@ static void it6505_shutdown(struct i2c_client *client) it6505_lane_off(it6505); } +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_node *node, + struct it6505 *it6505) +{ + struct it6505_port_data *port_data; + struct typec_mux_desc mux_desc = {}; + char name[32]; + u32 port_num; + int ret; + + ret = of_property_read_u32(node, "reg", &port_num); + if (ret) + return ret; + + if (port_num >= it6505->num_typec_switches) { + dev_err(dev, "Invalid port number specified: %d\n", port_num); + return -EINVAL; + } + + port_data = &it6505->typec_ports[port_num]; + port_data->it6505 = it6505; + mux_desc.fwnode = &node->fwnode; + mux_desc.drvdata = port_data; + snprintf(name, sizeof(name), "%s-%u", node->name, port_num); + mux_desc.name = name; + mux_desc.set = it6505_typec_mux_set; + + port_data->typec_mux = typec_mux_register(dev, &mux_desc); + if (IS_ERR(port_data->typec_mux)) { + ret = PTR_ERR(port_data->typec_mux); + dev_err(dev, "Mode switch register for port %d failed: %d", port_num, ret); + } + + return ret; +} + +static void it6505_unregister_typec_switches(struct it6505 *it6505) +{ + int i; + + for (i = 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 it6505 *it6505) { - struct device_node *of; + struct device_node *of, *sw; + int ret = 0; of = of_get_child_by_name(device->of_node, "switches"); if (!of) @@ -3241,8 +3298,28 @@ static int it6505_register_typec_switches(struct device *device, struct it6505 * it6505->num_typec_switches = of_get_child_count(of); if (it6505->num_typec_switches <= 0) return -ENODEV; + it6505->typec_ports = devm_kzalloc(device, + it6505->num_typec_switches * + sizeof(struct it6505_port_data), + GFP_KERNEL); + if (!it6505->typec_ports) + return -ENOMEM; - 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 = 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; } static int it6505_i2c_probe(struct i2c_client *client, @@ -3280,7 +3357,8 @@ static int it6505_i2c_probe(struct i2c_client *client, ret = it6505_register_typec_switches(dev, it6505); if (ret) { - dev_dbg(dev, "Didn't register Type C switches, err: %d", ret); + if (ret != -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 *client) drm_dp_aux_unregister(&it6505->aux); it6505_debugfs_remove(it6505); it6505_poweroff(it6505); + it6505_unregister_typec_switches(it6505); return 0; } From patchwork Wed Jun 22 17:34:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12891245 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 B61DECCA47D for ; Wed, 22 Jun 2022 17:48:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377439AbiFVRse (ORCPT ); Wed, 22 Jun 2022 13:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbiFVRsc (ORCPT ); Wed, 22 Jun 2022 13:48:32 -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 7E1A0FD04 for ; Wed, 22 Jun 2022 10:48:30 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id k12-20020a17090a404c00b001eaabc1fe5dso157685pjg.1 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=JiuKrKPrzd87K4+D3pGghn39vja486uLBJ5eqvIDyeP2GwdIpjK5qm4AM7/ipDJv4C hpbvMM6faCaBHQPoUj2meB7lVvpPzYoYr+zCagXKeswTZty8QVPuog8BoIoy8dCmjoSC nZ7Md5mGRmvI9qYC/zNHnCSeATkrWA0rh7s9tuIzGCamazf8QGbPuT9v0fJxaIZYbhNe J6C5QN2tMPUIvuaX6Dim/EqDp04NmK4EBA4f+/ZMqDfDHGD70I3OYJvKzq3qJgHLNoT+ 1cJxJtkvwdFJfyDCILEvCz8o9W/fw4aR4tRJkfpud0d6wc+r83sxTe2vD0liW0mVvllS 7WXw== X-Gm-Message-State: AJIora8FSvWv8HUPOiu9xo3iKQcORLrTZELCtyGbzmWMxHTZAUm5NNTB aqF/KOgjzsFnFz4Humdv4ZI+GA== 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?b?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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/ite-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 @@ -404,6 +405,7 @@ struct debugfs_entries { }; 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 *client) it6505_lane_off(it6505); } +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_connected) + /* Both ports available, do nothing to retain the current one. */ + return; + else if (it6505->typec_ports[0].dp_connected) + it6505->lane_swap = false; + else if (it6505->typec_ports[1].dp_connected) + it6505->lane_swap = 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 = typec_mux_get_drvdata(mux); + struct it6505 *it6505 = data->it6505; + struct device *dev = &it6505->client->dev; + bool old_dp_connected, new_dp_connected; + + if (it6505->num_typec_switches == 1) + return 0; + + mutex_lock(&it6505->extcon_lock); + + old_dp_connected = it6505->typec_ports[0].dp_connected || + it6505->typec_ports[1].dp_connected; + + dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", + it6505->typec_ports[0].dp_connected, it6505->typec_ports[1].dp_connected); + + data->dp_connected = (state->alt && state->alt->svid == USB_TYPEC_DP_SID && + state->alt->mode == USB_TYPEC_DP_MODE); + + new_dp_connected = 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; }