From nobody Sun Feb 8 13:10:37 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 1E5C8C43219 for ; Thu, 24 Nov 2022 10:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbiKXKVf (ORCPT ); Thu, 24 Nov 2022 05:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbiKXKVX (ORCPT ); Thu, 24 Nov 2022 05:21:23 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 087F214F52C for ; Thu, 24 Nov 2022 02:21:15 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id w79so1275072pfc.2 for ; Thu, 24 Nov 2022 02:21:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bhjmEX7h7UKuTd3pV2F0JRbYwLj/obCLhiM6HTgRw0A=; b=hyEW92Qgxc5TQnLZWHdyOLmDAEq5T8M7V0iOgxHI7fmQKv4wqB5EmzbNffcjGDXl1y vmD6r+xRz62PtEZwYK8WpFdk3i1WCAg8MvTKFFyhdAR3U03Upmodz/Sk2+R459pZt5ue KoM27RRJTxSG0VqLVljHKplaFJmL3x9ILSBTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bhjmEX7h7UKuTd3pV2F0JRbYwLj/obCLhiM6HTgRw0A=; b=uph0xCzKEipcTLNwBr/GnZ1Vvmne5XCKz4uLHqHbGdKpioJucLuKDurDTnIJX2AAdl XfG34WN00BnZFkUn4uoWlwseX03eO8ziSjjqCcnFuNz+HThZ18kqJofmMPBRwwUl71+w 1QRzlW4s1AvQoHa4CAiSIDQigaoxcLXNadKc5+TQIxFJqco/8c94MscUaLzAQbfhvK7u RkQrVEoOsfvJglblbi3LL/y3+3IoARo6GM/1elsMcxvzSVlUDxEsjYP78FnM959LAExP DUVejx6233Zp4h323hqx9/c5ad+G6Zn256jXU7qkSxoWOIONJGMqHnQMfYc5w6iohO2Z F4HQ== X-Gm-Message-State: ANoB5pkjk0htpHWtvQh5ld4w9amlFm29CpLi1zTAXhijEfVgO/wHZo6O Ddm2xPEvTQDTKahwKVoVqHOTow== X-Google-Smtp-Source: AA0mqf5Dpv3pBFrlepUdrqazsU1AaoAF/JpY4AkUKXgwym+PfS6uoAGgqvHrWP1Xgn/dQtFUItYqyg== X-Received: by 2002:a63:4043:0:b0:470:2ecd:333e with SMTP id n64-20020a634043000000b004702ecd333emr30066989pga.596.1669285274569; Thu, 24 Nov 2022 02:21:14 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:14 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 1/7] device property: Add remote endpoint to devcon matcher Date: Thu, 24 Nov 2022 18:20:50 +0800 Message-Id: <20221124102056.393220-2-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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: Prashant Malani When searching the device graph for device matches, check the remote-endpoint itself for a match. Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin --- Changes in v6: - New in v6 drivers/base/property.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4d6278a84868..2ab8be8ca45e 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1223,6 +1223,21 @@ static unsigned int fwnode_graph_devcon_matches(stru= ct fwnode_handle *fwnode, break; } =20 + /* + * Some drivers may register devices for endpoints. Check + * the remote-endpoints for matches in addition to the remote + * port parent. + */ + node =3D fwnode_graph_get_remote_endpoint(ep); + if (fwnode_device_is_available(node)) { + ret =3D match(node, con_id, data); + if (ret) { + if (matches) + matches[count] =3D ret; + count++; + } + } + node =3D fwnode_graph_get_remote_port_parent(ep); if (!fwnode_device_is_available(node)) { fwnode_handle_put(node); --=20 2.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 9E189C43219 for ; Thu, 24 Nov 2022 10:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbiKXKVl (ORCPT ); Thu, 24 Nov 2022 05:21:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbiKXKVZ (ORCPT ); Thu, 24 Nov 2022 05:21:25 -0500 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 1D39614FEDB for ; Thu, 24 Nov 2022 02:21:21 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id p12so1108028plq.4 for ; Thu, 24 Nov 2022 02:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3Zp7oNSpvCJzlmrAgiA+eyc89NALrCy35DmIPjsn8o=; b=Lk6A3X3u7rHOEkHOKdmz7Rf/XoRmo/K4/VfJsj8Om775/vkojm7XMlKACeEPdtGuaY GWc3uQh8uXQFtaJdIUpElGlC0FwjCX/fGyfhcBNnkoABKE+H+lRGtSCr6xHwihfNhdnD YH1yIBafS0Aw0dZHXl5eRfe/hATI+Ef9EbYm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3Zp7oNSpvCJzlmrAgiA+eyc89NALrCy35DmIPjsn8o=; b=h6UofC6psPd6iLNIrcyeZOuB2IldpAanPxB27jBTpuBgTBsFzWowvJwYHTzFftGz0b xmeadWzMTR2Jk3hdQQUhVqFj0AUX/KfeuMitR5dmUMcbQ6wQQS6ruHb/CtVpENnRw/0i ciNDKDenkZ6pUMyXfvu/osjBlZsWu3cfZ7U2xihZZvuQhgNI0OQtgX/wrLQokLSfmyPp 4kiEGB4I7ifNsO4yUObQ6LQ+hQg8T0CuU/a9OS6MY8I3uH6EOeW6HaHXpRnkWVpHc/cq yYt5VvzhCiaz/fPDxM4EV0TcfK+L0UDJfNg5zG+9faKeLQC3tYSmcXADnssMo1PlT+Bw SJ8g== X-Gm-Message-State: ANoB5plNTdeVOFSg7IabzLv8FRswQsz5VZY1fG+1cfzdmo5CWy3WLn1I bx2VzqTPSp97keDia7HaUYwPaA== X-Google-Smtp-Source: AA0mqf4e/Cym/Pz7zBKvhY1xLXZhdwP/ObGG9vCVjg1dRXcUSRdgzQFvHu0Ftn7dlBCUsdOuexDJjw== X-Received: by 2002:a17:90a:448a:b0:218:48f3:2e48 with SMTP id t10-20020a17090a448a00b0021848f32e48mr34222110pjg.36.1669285280659; Thu, 24 Nov 2022 02:21:20 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:20 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 2/7] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Date: Thu, 24 Nov 2022 18:20:51 +0800 Message-Id: <20221124102056.393220-3-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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: Prashant Malani When using OF graph, the fw_devlink code will create links between the individual port driver (cros-ec-typec here) and the parent device for a Type-C switch (like mode-switch). Since the mode-switch will in turn have the usb-c-connector (i.e the child of the port driver) as a supplier, fw_devlink will not be able to resolve the cyclic dependency correctly. As a result, the mode-switch driver probe() never runs, so mode-switches are never registered. Because of that, the port driver probe constantly fails with -EPROBE_DEFER, because the Type-C connector class requires all switch devices to be registered prior to port registration. To break this deadlock and allow the mode-switch registration to occur, purge all the usb-c-connector nodes' absent suppliers. This eliminates the connector as a supplier for a switch and allows it to be probed. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin --- Changes in v6: - New in v6 drivers/platform/chrome/cros_ec_typec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/cros_ec_typec.c index 2a7ff14dc37e..f74e01d18ef3 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -382,6 +382,15 @@ static int cros_typec_init_ports(struct cros_typec_dat= a *typec) return -EINVAL; } =20 + /* + * OF graph may have set up some device links with switches, since connec= tors have their + * own compatible. Purge these to avoid a deadlock in switch probe (the s= witch mistakenly + * assumes the connector is a supplier). + */ + if (dev->of_node) + device_for_each_child_node(dev, fwnode) + fw_devlink_purge_absent_suppliers(fwnode); + /* DT uses "reg" to specify port number. */ port_prop =3D dev->of_node ? "reg" : "port-number"; device_for_each_child_node(dev, fwnode) { --=20 2.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 1CAB6C433FE for ; Thu, 24 Nov 2022 10:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbiKXKV7 (ORCPT ); Thu, 24 Nov 2022 05:21:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbiKXKVc (ORCPT ); Thu, 24 Nov 2022 05:21:32 -0500 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 7525F150CB2 for ; Thu, 24 Nov 2022 02:21:27 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id t17so1033747pjo.3 for ; Thu, 24 Nov 2022 02:21:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b9KcK1J3it0ftVBy4iMTAiutJ0HoDn4vV6l4PCThFvs=; b=EcrwUdGALRkhCF6+jeFlkUBLXIIWyUjpF4rTujN1HxPt2yoZ7bvcgpfN4ZwRsrq2M0 ySDGRxTUTbLvGC/Sp+B/GHjpyxsqQj/pVTPgwu4fMEuINxqsrxM2OrlP7AbgmQqvP4SW MDTgPw1Wfh+96fRcWBl7io3b6fkJXmpeHm+/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b9KcK1J3it0ftVBy4iMTAiutJ0HoDn4vV6l4PCThFvs=; b=npmH+eRdPKBt/EysY/MNWcrckAg7ib7WQBs1GxpvYpjg446P9ZJNM/8gNmztmBXjhc /SM4zcWl/qj9muKf32047BdMUhvZk5s3UKtEwVroclsj+sA0iMQXX66g6G560LPXPLp/ J9SKRX/2k9vx8h4xTy17Re87v0V1QDN3qhot3eetYTTtwTHwdAFkkSKcuZX531VpNa1U L3+dVIr1FIGFQaFgZ1nqP8dekKM0sCyWqAteIKldB4kPROx09WVXnVSfnW5sXPvEnsRU /Hm4lcw+gBf65frlnnMHJy7uAYSq6eyqhiNnz5f30pPCaRpio+NZ1T6RCYVzH0JyLuG4 /xWg== X-Gm-Message-State: ANoB5pn1ZFxmLEQWouklIvt1XngYACsI5+S6umywBj1KcYlIDzASHXDM TyVT5gsptFgGsIr0QLTY4ofhIQ== X-Google-Smtp-Source: AA0mqf46GQ5ufhbsGjVkzHAuwHzwpntLipYUVoKE+qWJzofRfTXK5R5FNxhQAwt7WLq+0sY+rWaWLg== X-Received: by 2002:a17:902:e492:b0:186:5f71:7939 with SMTP id i18-20020a170902e49200b001865f717939mr15675016ple.162.1669285286917; Thu, 24 Nov 2022 02:21:26 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:26 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 3/7] dt-bindings: drm/bridge: anx7625: Add mode-switch support Date: Thu, 24 Nov 2022 18:20:52 +0800 Message-Id: <20221124102056.393220-4-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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" Analogix 7625 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports. Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints. Also include the link to the product brief in the bindings. Signed-off-by: Pin-yen Lin --- Changes in v6: - Remove switches node and use endpoints and data-lanes property to describe the connections. .../display/bridge/analogix,anx7625.yaml | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/analogix,anx7= 625.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,anx762= 5.yaml index 4590186c4a0b..5fdbf1f3bab8 100644 --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml @@ -12,7 +12,8 @@ maintainers: =20 description: | The ANX7625 is an ultra-low power 4K Mobile HD Transmitter - designed for portable devices. + designed for portable devices. Product brief is available at + https://www.analogix.com/en/system/files/AA-002291-PB-6-ANX7625_ProductB= rief.pdf =20 properties: compatible: @@ -112,10 +113,36 @@ properties: data-lanes: true =20 port@1: - $ref: /schemas/graph.yaml#/properties/port + $ref: /schemas/graph.yaml#/properties/port-base description: Video port for panel or connector. =20 + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/media/video-interfaces.yaml# + type: object + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + remote-endpoint: true + + data-lanes: + minItems: 1 + uniqueItems: true + items: + - enum: [ 0, 1, 2, 3] + + mode-switch: + type: boolean + description: Register this node as a Type-C mode switch or= not. + + required: + - reg + - remote-endpoint + required: - port@0 - port@1 @@ -186,3 +213,45 @@ examples: }; }; }; + - | + &i2c3 { + anx_bridge_dp: anx7625-dp@58 { + compatible =3D "analogix,anx7625"; + reg =3D <0x58>; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&anx7625_dp_pins>; + enable-gpios =3D <&pio 176 GPIO_ACTIVE_HIGH>; + reset-gpios =3D <&pio 177 GPIO_ACTIVE_HIGH>; + vdd10-supply =3D <&pp1100_dpbrdg>; + vdd18-supply =3D <&pp1800_dpbrdg_dx>; + vdd33-supply =3D <&pp3300_dpbrdg_dx>; + analogix,audio-enable; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + anx7625_dp_in: endpoint { + bus-type =3D <7>; + remote-endpoint =3D <&dpi_out>; + }; + }; + + port@1 { + reg =3D <1>; + anx_typec0: endpoint@0 { + mode-switch; + data-lanes =3D <0 1>; + remote-endpoint =3D <&typec_port0>; + }; + anx_typec1: endpoint@1 { + mode-switch; + data-lanes =3D <2 3>; + remote-endpoint =3D <&typec_port1>; + }; + }; + }; + }; + }; --=20 2.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 363F2C433FE for ; Thu, 24 Nov 2022 10:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbiKXKWN (ORCPT ); Thu, 24 Nov 2022 05:22:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbiKXKVe (ORCPT ); Thu, 24 Nov 2022 05:21:34 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD0614E6D9 for ; Thu, 24 Nov 2022 02:21:33 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id a16so854122pfg.4 for ; Thu, 24 Nov 2022 02:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xSARwn2UnE9YTFUF2W3+HZEu0BpMDJn1tvX56Vn2aEc=; b=Ug9Id50cct6zOXOQoNNjH9g7+k3Y+GPROT/0at83jSeiIUZNvMxLUnWXIfKhQWwCqD BvLcx+EY9+QMbGcQ5JRGAFFNl5qvTOXxO0htrR5T7HhUAP4Z9WIyIPI3a2F/bEF3byyF wVpCmNKlejLHByIQdI99O8XbYNYoezW4RvB7U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xSARwn2UnE9YTFUF2W3+HZEu0BpMDJn1tvX56Vn2aEc=; b=uAbGqOCDK9GWvG5LDy7elZWy2K2XNUSI0/PxxBdzxE53yPkQImo4omK9buTX9MED3M MgEwf0dcSCx85VMI/0WaaisZYBldfTazni+S5+itc7n7+8HJ9is+gnPUfrM+OLRpgS+f 6tPaNQA61D2c45la3E9A7fuB6smX6+5eAVTF++LLI6rQJooA/efT605ncFR15Mikp2kU KEl1Klbwx5QCr9ozd9WiVzUMgb7PLnLrDCitDDRCTWIh7C0s7Z/ECU/wcj6iisFLZFf9 sR0pcZOsw/MmFQDB+BuSFL01aG0huLbmCvnHh8yjpN+V4Oq0SMTW+sj8eT8IWpGHvxqE tvjA== X-Gm-Message-State: ANoB5pkW3YdvP2kmtgwKg2OsF2zN9MJMXtjVWaKORa76wvuJSovJ3mpE Qh67mbSXLVEB9CgXbcFhjJ6X9g== X-Google-Smtp-Source: AA0mqf7L3iC4gnmNoqCiVBZ9XwHWFS6fSLEjPGOepaa1BcV25Acbf6ifE5OqPVrzqGDBw0HCuMDfIQ== X-Received: by 2002:a05:6a00:80f:b0:571:8794:e845 with SMTP id m15-20020a056a00080f00b005718794e845mr15217721pfk.18.1669285292953; Thu, 24 Nov 2022 02:21:32 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:32 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 4/7] drm/bridge: anx7625: Check for Type-C during panel registration Date: Thu, 24 Nov 2022 18:20:53 +0800 Message-Id: <20221124102056.393220-5-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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" The output port endpoints can be connected to USB-C connectors. Running drm_of_find_panel_or_bridge() with such endpoints leads to a continuous return value of -EPROBE_DEFER, even though there is no panel present. To avoid this, check for the existence of a "mode-switch" property in the port endpoint, and skip panel registration completely if so. Signed-off-by: Pin-yen Lin --- Changes in v6: - New in v6 drivers/gpu/drm/bridge/analogix/anx7625.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/br= idge/analogix/anx7625.c index b0ff1ecb80a5..b9e3d6ad8846 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1650,7 +1650,7 @@ static int anx7625_get_swing_setting(struct device *d= ev, static int anx7625_parse_dt(struct device *dev, struct anx7625_platform_data *pdata) { - struct device_node *np =3D dev->of_node, *ep0; + struct device_node *np =3D dev->of_node, *ep0, *sw; int bus_type, mipi_lanes; =20 anx7625_get_swing_setting(dev, pdata); @@ -1689,6 +1689,17 @@ static int anx7625_parse_dt(struct device *dev, if (of_property_read_bool(np, "analogix,audio-enable")) pdata->audio_en =3D 1; =20 + /* + * Don't bother finding a panel if a Type-C `mode-switch` property is + * present in one of the endpoints. + */ + for_each_endpoint_of_node(np, sw) { + if (of_property_read_bool(sw, "mode-switch")) { + of_node_put(sw); + return 0; + } + } + pdata->panel_bridge =3D devm_drm_of_get_bridge(dev, np, 1, 0); if (IS_ERR(pdata->panel_bridge)) { if (PTR_ERR(pdata->panel_bridge) =3D=3D -ENODEV) { --=20 2.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 1570DC433FE for ; Thu, 24 Nov 2022 10:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbiKXKWR (ORCPT ); Thu, 24 Nov 2022 05:22:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbiKXKVk (ORCPT ); Thu, 24 Nov 2022 05:21:40 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56A114F9DE for ; Thu, 24 Nov 2022 02:21:39 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id h193so1198234pgc.10 for ; Thu, 24 Nov 2022 02:21:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/AMzuZTvtULhDaNSb1CGR7wc9XfQGANRhchKL9iMWpc=; b=jYETd7vRF39IppIhmII7tbsyaUQpByJvGYddMez3t0wvAsKDcjqYisry/Hjr/8vxPD PyTMM/9y3cCcuPrjYSHLe6bs16y4EJQ9+eKf54Er6N5NNrlWQwPMIOsLaIC5iUzunsD5 23bQsA+xq3PaWRlVLGnKgTLHiWS+ns7D3LtY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/AMzuZTvtULhDaNSb1CGR7wc9XfQGANRhchKL9iMWpc=; b=m8fO8VjwnZg5tBbYEG1rQ6jm88HHioWscw+OEZZLmDLoWy6r5uvHG5FspwrKOYBb2h NB0JAEfoUaY1J6YOAccgxM/vvuGcn7VfF2PsBLwVK2+Dmw7YyIVrC4F9X5tU3KSwJ8/x zFTlwf+gMv3xvaIidM5FgQ02L7m+J4rCmj37iXchzwM7QDx6meCihv8KKNLXu49paKO1 Bl58AqFZ9ohKxNGYK2riDKG/FJDaIHJQFgnJCJRbq3S+NYch5Rj62Sk13x/bMkQHHyK5 /lE/26Ew9bWQmE1SGoQOIZVFJ6ynqI+5W+Yy/yFUUO7033KJvM1wPFBIKO66PvuXUq8p aACw== X-Gm-Message-State: ANoB5plVTKpzgS7rtOoF19S5+nM9R7DV9O0JQsFg61OCIr8ADEDiyWdM c7yCASJSozeWOln8R+9YRGkUUg== X-Google-Smtp-Source: AA0mqf7uiJNri7ShNc7g3uvn+n6tfamN3Ey97TemVTN3B6xuR1e8ujBuJ5eX9U46TMi77SoxlYuYDg== X-Received: by 2002:a62:148f:0:b0:560:ee47:81e1 with SMTP id 137-20020a62148f000000b00560ee4781e1mr17482882pfu.63.1669285299158; Thu, 24 Nov 2022 02:21:39 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:38 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 5/7] drm/bridge: anx7625: Register Type C mode switches Date: Thu, 24 Nov 2022 18:20:54 +0800 Message-Id: <20221124102056.393220-6-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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" Register USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the crosspoint switch based on the entered alternate mode for a specific Type-C connector. Signed-off-by: Pin-yen Lin --- Changes in v6: - Squashed to a single patch drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 169 ++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 20 +++ 3 files changed, 190 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/brid= ge/analogix/Kconfig index 173dada218ec..992b43ed1dd7 100644 --- a/drivers/gpu/drm/bridge/analogix/Kconfig +++ b/drivers/gpu/drm/bridge/analogix/Kconfig @@ -34,6 +34,7 @@ config DRM_ANALOGIX_ANX7625 tristate "Analogix Anx7625 MIPI to DP interface support" depends on DRM depends on OF + depends on TYPEC || TYPEC=3Dn select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/br= idge/analogix/anx7625.c index b9e3d6ad8846..2485e61f5cab 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include =20 #include @@ -2573,6 +2575,167 @@ 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; + + 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); + + 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); + + 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; +} + +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 dp_lanes[2]; + int ret, num_lanes, i, port_num =3D -1; + + num_lanes =3D drm_of_get_data_lanes_count(node, 0, 2); + if (num_lanes < 0) { + dev_err(dev, "Error on getting data lanes count: %d\n", num_lanes); + return num_lanes; + } + + ret =3D of_property_read_u32_array(node, "data-lanes", dp_lanes, num_lane= s); + if (ret) { + dev_err(dev, "Failed to read the data-lanes variable: %d\n", + ret); + return ret; + } + + /* + * <0 1> refers to SSRX1/SSTX1, and <2 3> refers to SSRX2/SSTX2. + */ + for (i =3D 0; i < num_lanes; i++) { + if (port_num !=3D -1 && port_num !=3D dp_lanes[i] / 2) { + dev_err(dev, "Invalid data lane numbers\n"); + return -EINVAL; + } + port_num =3D dp_lanes[i] / 2; + } + + 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\n", + port_num, ret); + } + + 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 *dev, struct anx7= 625_data *ctx) +{ + struct device_node *port, *sw; + int ret =3D 0; + + port =3D of_graph_get_port_by_id(dev->of_node, 1); + + for_each_child_of_node(port, sw) { + if (of_property_read_bool(sw, "mode-switch")) + ctx->num_typec_switches++; + } + + if (!ctx->num_typec_switches) { + dev_warn(dev, "No Type-C switches node found\n"); + return ret; + } + + ctx->typec_ports =3D devm_kcalloc( + dev, ctx->num_typec_switches, sizeof(struct anx7625_port_data), + GFP_KERNEL); + if (!ctx->typec_ports) + return -ENOMEM; + + /* Register switches for each connector. */ + for_each_child_of_node(port, sw) { + if (!of_property_read_bool(sw, "mode-switch")) + continue; + ret =3D anx7625_register_mode_switch(dev, sw, ctx); + if (ret) { + dev_err(dev, "Failed to register mode switch: %d\n", ret); + of_node_put(sw); + break; + } + } + + if (ret) + anx7625_unregister_typec_switches(ctx); + + return ret; +} + static int anx7625_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -2681,6 +2844,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 && ret !=3D -ENODEV) + dev_warn(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)) @@ -2732,6 +2899,8 @@ static void anx7625_i2c_remove(struct i2c_client *cli= ent) =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 14f33d6be289..b8634766b04e 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 /***************************************************************/ @@ -449,6 +461,12 @@ struct anx7625_i2c_client { struct i2c_client *tcpc_client; }; =20 +struct anx7625_port_data { + bool dp_connected; + struct typec_mux_dev *typec_mux; + struct anx7625_data *ctx; +}; + struct anx7625_data { struct anx7625_platform_data pdata; struct platform_device *audio_pdev; @@ -479,6 +497,8 @@ struct anx7625_data { struct drm_connector *connector; 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.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 34790C433FE for ; Thu, 24 Nov 2022 10:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbiKXKWU (ORCPT ); Thu, 24 Nov 2022 05:22:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiKXKVu (ORCPT ); Thu, 24 Nov 2022 05:21:50 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D31B815B4E7 for ; Thu, 24 Nov 2022 02:21:45 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id ci10so1047469pjb.1 for ; Thu, 24 Nov 2022 02:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nI+gZT0pcePdydFoBeIT1UIcJJFwcuKGSk5zJ0RL4tU=; b=h0Y+v3WtWtEa8b3ysBdsgKHNq8g5LNo8YXyeBfLFNKlHmk2xzqlJdZf8/dacjprErY tqXVFAUTRiP5vbsey1w3Bn7mDO1Aj5qfei74MJMrTMNQGNjyKJFzy0/VEY2MFVV/zBrN g0H+3UT1NOjdvCDGiisvDtceQxOMvoHjs9rpo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nI+gZT0pcePdydFoBeIT1UIcJJFwcuKGSk5zJ0RL4tU=; b=f3BFN04f6+0YdWGaO6hgoPmj+i8s16Uca//ylaOmjdHu1K9jae239TQo22yvqzSpfh WIL7DgC0lTnp0pS7CuG56eo3w/Zxp3TZYzFGOrT2dpl5pcxx0mRdIU8Fr6f0RsK9DO6N kOaBkuT8anFkmiHLRH4HUrKQEGaYytdwAA+5X6mlW29DIzIniHbs3x06taFzxG/CWK4N taUlnKHEYlCqPmYAJ1eUc3dqhj8VeAau2jo8i5CM11Qsx9Tt1qeK7UpsNxPwhffTs6oQ bSr1IU0ABuAWVocf9tkNngWF3NTHLG3RXAlavxJ0HvFV+9PyQoEVIoZ32PCzOTXJ/T7w WS9w== X-Gm-Message-State: ANoB5pnLz6Ta2o59YWGcs8bAWyMOPGgHpHRE8EK2g5AIxdfFjiCIt0Xw X4C8UeUhZh6/8oFBfypag+h/bw== X-Google-Smtp-Source: AA0mqf7hh4W9Fkbv8iFQguyRhGwjrTAFkMKQsz1viXpfZVWTjFkqR6ffAp9vqXowTDad2gm63u4YVA== X-Received: by 2002:a17:902:b613:b0:181:9900:18df with SMTP id b19-20020a170902b61300b00181990018dfmr13219005pls.70.1669285305357; Thu, 24 Nov 2022 02:21:45 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:44 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 6/7] dt/bindings: drm/bridge: it6505: Add mode-switch support Date: Thu, 24 Nov 2022 18:20:55 +0800 Message-Id: <20221124102056.393220-7-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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" ITE IT6505 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports. Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints. Signed-off-by: Pin-yen Lin --- Changes in v6: - Remove switches node and use endpoints and data-lanes property to describe the connections. .../bindings/display/bridge/ite,it6505.yaml | 94 ++++++++++++++++++- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.ya= ml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml index 833d11b2303a..b4b9881c7759 100644 --- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml @@ -52,9 +52,53 @@ properties: maxItems: 1 description: extcon specifier for the Power Delivery =20 - port: - $ref: /schemas/graph.yaml#/properties/port - description: A port node pointing to DPI host port node + data-lanes: + maxItems: 1 + description: restrict the dp output data-lanes with value of 1-4 + + max-pixel-clock-khz: + maxItems: 1 + description: restrict max pixel clock + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: A port node pointing to DPI host port node + + port@1: + $ref: /schemas/graph.yaml#/properties/port-base + description: + Video port for panel or connector. + + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/media/video-interfaces.yaml# + type: object + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + remote-endpoint: true + + data-lanes: + minItems: 1 + uniqueItems: true + items: + - enum: [ 0, 1, 2, 3] + + mode-switch: + type: boolean + description: Register this node as a Type-C mode switch or= not. + + required: + - reg + - remote-endpoint =20 required: - compatible @@ -62,7 +106,7 @@ required: - pwr18-supply - interrupts - reset-gpios - - extcon + - ports =20 additionalProperties: false =20 @@ -92,3 +136,45 @@ examples: }; }; }; + - | + #include + + &i2c3 { + clock-frequency =3D <100000>; + + 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>; + hpd-gpios =3D <&pio 10 0>; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + port@0 { + reg =3D <0>; + it6505_in: endpoint { + remote-endpoint =3D <&dpi_out>; + }; + }; + port@1 { + reg =3D <1>; + ite_typec0: endpoint@0 { + mode-switch; + data-lanes =3D <0 1>; + remote-endpoint =3D <&typec_port0>; + }; + ite_typec1: endpoint@1 { + mode-switch; + data-lanes =3D <2 3>; + remote-endpoint =3D <&typec_port1>; + }; + }; + }; + }; + }; --=20 2.38.1.584.g0f3c55d4c2-goog From nobody Sun Feb 8 13:10:37 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 B1579C433FE for ; Thu, 24 Nov 2022 10:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbiKXKW6 (ORCPT ); Thu, 24 Nov 2022 05:22:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiKXKV6 (ORCPT ); Thu, 24 Nov 2022 05:21:58 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D05115BB03 for ; Thu, 24 Nov 2022 02:21:52 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d20so1087522plr.10 for ; Thu, 24 Nov 2022 02:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2lj9TOq4Mi1yjs5u7EUelEqMG61qPa6abk6tN/y0iWc=; b=dh73Yb5LdX3XzNMgeceewCLByB4kWa76LmjwGRhHetVfb+CTAGgtAq5OTOlGq1UIUU N5maCRzze0/a+LAv9FVd004ct9wIXxE5OfztI8aNUhcr+K8WLORlTU6U/+GI93MusNF9 tlo96VnZBJaBiQbAN7YVW60Xdb7XdmMurNEcc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2lj9TOq4Mi1yjs5u7EUelEqMG61qPa6abk6tN/y0iWc=; b=MfRr3jWE909anGmp1hnNjr+5a4g+Si+Iar3GpTzAHQ/PN4hS44TG1T1hgv/ChngJvo G/VzOR945JN6RdEIyt6D9ngWWY7q9mp6rDVZrn3jDcSJYP9ITYQMwbuZACEOWxoACczV PsVA4OU0Newotbi55JS5MPXo8fYZrlANrg5AgSMCqIqfIlpCQraFCKJ13WLkcZlW8mmX /qzi0ji+kxxnlkPC4/jRlel86/70aexpqJt1Iot9RofgG8Tlurla5PD0rwSif8cEP3rX wmGoKnf12AG0+KfceuAL21gKREBciMzjWZZUty1IuWXOcpQnIuqzWI5tFEGg1Pm86gmn ce7A== X-Gm-Message-State: ANoB5pkopuQHlDxSPZOfHXoblDJ4sKEJxrznbyE4R1kOGkfxwimavk9I 0t6/7zRuomwszP2aqXPxdrHU6g== X-Google-Smtp-Source: AA0mqf5vM89hcYo+bffA1QF85tTKpfgIDPFWo2QBf9erTyQa+wFSdxLwOaGJ+X+28Ax9kTHSiczlKA== X-Received: by 2002:a17:90a:71c8:b0:213:caaf:411 with SMTP id m8-20020a17090a71c800b00213caaf0411mr16426875pjs.74.1669285311724; Thu, 24 Nov 2022 02:21:51 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:d446:708:8556:dfee]) by smtp.gmail.com with ESMTPSA id t123-20020a625f81000000b005747b59fc54sm854584pfb.172.2022.11.24.02.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:21:51 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: Javier Martinez Canillas , Stephen Boyd , dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Thomas Zimmermann , devicetree@vger.kernel.org, Pin-yen Lin , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, Marek Vasut , Xin Ji , Lyude Paul , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Allen Chen Subject: [PATCH v6 7/7] drm/bridge: it6505: Register Type C mode switches Date: Thu, 24 Nov 2022 18:20:56 +0800 Message-Id: <20221124102056.393220-8-treapking@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124102056.393220-1-treapking@chromium.org> References: <20221124102056.393220-1-treapking@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" Register USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the "lane_swap" state based on the entered alternate mode for a specific Type-C connector, which ends up updating the lane swap registers of the it6505 chip. Signed-off-by: Pin-yen Lin --- Changes in v6: - Changed it6505_typec_mux_set callback function to accommodate with the latest drm-misc patches - Changed the driver implementation to accommodate with the new binding - Squashed to a single patch drivers/gpu/drm/bridge/Kconfig | 1 + drivers/gpu/drm/bridge/ite-it6505.c | 205 +++++++++++++++++++++++++++- 2 files changed, 202 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 57946d80b02d..9b1240ef3981 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -87,6 +87,7 @@ config DRM_FSL_LDB config DRM_ITE_IT6505 tristate "ITE IT6505 DisplayPort bridge" depends on OF + depends on TYPEC || TYPEC=3Dn select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 21a9b8422bda..37e2bd8d8d79 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include =20 #include @@ -30,6 +32,7 @@ #include #include #include +#include =20 #include =20 @@ -402,6 +405,12 @@ struct debugfs_entries { const struct file_operations *fops; }; =20 +struct it6505_port_data { + bool dp_connected; + struct typec_mux_dev *typec_mux; + struct it6505 *it6505; +}; + struct it6505 { struct drm_dp_aux aux; struct drm_bridge bridge; @@ -454,6 +463,8 @@ struct it6505 { struct delayed_work delayed_audio; 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; @@ -3265,13 +3276,185 @@ static void it6505_shutdown(struct i2c_client *cli= ent) 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; + + 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); + + 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= ); + + 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\n"); + goto unlock; + } + + it6505_typec_ports_update(it6505); + + if (!old_dp_connected && new_dp_connected) { + int ret =3D pm_runtime_get_sync(dev); + + /* + * On system resume, mux_set can be triggered before + * pm_runtime_force_resume re-enables runtime power management. + * Handling the error here to make sure the bridge is powered on. + */ + if (ret < 0) + it6505_poweron(it6505); + + complete_all(&it6505->extcon_completion); + } + + if (old_dp_connected && !new_dp_connected) { + reinit_completion(&it6505->extcon_completion); + 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; +} + +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 dp_lanes[2]; + int ret, num_lanes, i, port_num =3D -1; + + num_lanes =3D drm_of_get_data_lanes_count(node, 0, 2); + if (num_lanes <=3D 0) { + dev_err(dev, "Error on getting data lanes count: %d\n", + num_lanes); + return num_lanes; + } + + ret =3D of_property_read_u32_array(node, "data-lanes", dp_lanes, num_lane= s); + if (ret) { + dev_err(dev, "Failed to read the data-lanes variable: %d\n", + ret); + return ret; + } + + for (i =3D 0; i < num_lanes; i++) { + if (port_num !=3D -1 && port_num !=3D dp_lanes[i] / 2) { + dev_err(dev, "Invalid data lane numbers\n"); + return -EINVAL; + } + port_num =3D dp_lanes[i] / 2; + } + + 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\n", + port_num, ret); + } + + 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 *dev, struct it650= 5 *it6505) +{ + struct device_node *port, *sw; + int ret =3D 0; + + port =3D of_graph_get_port_by_id(dev->of_node, 1); + + for_each_child_of_node(port, sw) { + if (of_property_read_bool(sw, "mode-switch")) + it6505->num_typec_switches++; + } + + if (!it6505->num_typec_switches) { + dev_warn(dev, "No Type-C switches node found\n"); + return ret; + } + + it6505->typec_ports =3D devm_kzalloc( + dev, it6505->num_typec_switches * sizeof(struct it6505_port_data), + GFP_KERNEL); + if (!it6505->typec_ports) + return -ENOMEM; + + /* Register switches for each connector. */ + for_each_child_of_node(port, sw) { + if (!of_property_read_bool(sw, "mode-switch")) + continue; + ret =3D it6505_register_mode_switch(dev, sw, it6505); + if (ret) { + dev_err(dev, "Failed to register mode switch: %d\n", ret); + of_node_put(sw); + break; + } + } + + if (ret) + it6505_unregister_typec_switches(it6505); + + return ret; +} + 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) @@ -3292,11 +3475,24 @@ 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\n", + 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) { + if (ret !=3D -ENODEV) + dev_warn(dev, "Didn't register Type-C switches, err: %d\n", + ret); + if (!it6505->extcon) { + dev_err(dev, "Both extcon and typec-switch are not registered.\n"); + return -EINVAL; + } + } =20 it6505->regmap =3D devm_regmap_init_i2c(client, &it6505_regmap_config); if (IS_ERR(it6505->regmap)) { @@ -3367,6 +3563,7 @@ static void it6505_i2c_remove(struct i2c_client *clie= nt) drm_dp_aux_unregister(&it6505->aux); it6505_debugfs_remove(it6505); it6505_poweroff(it6505); + it6505_unregister_typec_switches(it6505); } =20 static const struct i2c_device_id it6505_id[] =3D { --=20 2.38.1.584.g0f3c55d4c2-goog