From patchwork Thu Jan 12 04:20:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3686746wrt; Wed, 11 Jan 2023 20:23:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvVhhA0Eg5gqNkLk7Rn02evKHIKGO8c14jFwdcj5GzCjI+fyzOqyH4W+pSdbpC9q/zrgoMz X-Received: by 2002:a17:906:30d3:b0:7c0:a1f9:c778 with SMTP id b19-20020a17090630d300b007c0a1f9c778mr62637761ejb.13.1673497420013; Wed, 11 Jan 2023 20:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497419; cv=none; d=google.com; s=arc-20160816; b=0cmg9WphkSWMXuTVz6LpUw/Qdhqo+AAqXKy1/y3kxb/LZQmLKCG5PNF4DSFB43t4KT cB6ixlD4JDROWD5zkwXVPR1iC5jhqLs9gd6P/ljpZvhMQsnyY7BHBf9RBQIPvHTehT2c rWCF0/U0KMh8Mo2702xj8asXUNxCj7LAjZogBwvVdG35SG2QdHRaLVf8kuw6Fxgco1oN /WqkT+daqsRqlLoZMEvvGFUtOYlt/wM9a0EYxzgkLCPCTEeru3t45eCHQZdy7NR01ZHX aac/2NvDpRcqx3Zu4ypEWJaGUK3wuVEuxAM7LZWRW/UjjUsbfpkgxxBq2AR3HUCJKJ9I KC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q03I2SqtfUHT+b3Yv/iRQSSryxJAUHsZ8NrVScVRxMI=; b=aDbL33ikAiXVnTqrWkcRCXjk5hV7FSSyhB6olu1FKz2t6jxvuQi1sxomGZA7ZCLs6z XQO15gMUpLOWfELHKr31DAq3mjaWGnt1FZx0Q1VOpe8peQkI4sH2KGeqQFVLfMEVRDHf QeLSOTGsGYBS3jb2A/rFjQNfkN0sN1UMXV6LcOOJ/99onytamFhVRCyds0ef34ZEFqiK unfqxulsdd+NOIu3OVjjT75vRPmL/J07xFQqV5HlIgDyQlG0c1G3+tvMVAMY6nz9rJNJ GIczdoOTN+oEfPPOAqZC2rJeVyxQj3pPcAlborSBJkYDDvaRSFL/UlQeW1czVoOZidhv VZ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f2KQNOht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb7-20020a1709076d8700b007c89c44ec7csi16299148ejc.502.2023.01.11.20.23.16; Wed, 11 Jan 2023 20:23:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f2KQNOht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236660AbjALEWV (ORCPT + 99 others); Wed, 11 Jan 2023 23:22:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236584AbjALEVh (ORCPT ); Wed, 11 Jan 2023 23:21:37 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE7195BC for ; Wed, 11 Jan 2023 20:21:20 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id g68so10869885pgc.11 for ; Wed, 11 Jan 2023 20:21:20 -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=q03I2SqtfUHT+b3Yv/iRQSSryxJAUHsZ8NrVScVRxMI=; b=f2KQNOhtwineaLdPBaanYUTkfKpWAsRnLTpA0trox4XkuknVYCNctsxaTb9tGgNaKu BiPdVJaRaMWIfNSedsGVzbWEWFA4Oyfa54lxWC+pmDiQ7Wu/rMobAp8vivpq2qPeoyru JGwxDlf/wLaFD441dPBCsW1FecE5k3Uf5Jc5E= 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=q03I2SqtfUHT+b3Yv/iRQSSryxJAUHsZ8NrVScVRxMI=; b=pfGBmjz8sS8o6zMigJC4XTUsI++lO7jnhfgdRjEswbAWwUOH4mkcNtqcgFVliHnn2a 63hoGDTGyGI0P3GT1a0n6r4ujjMqMfAmB5EIBzR6SUZdvwBJgblseTWejyFogVUV5LOB sMVJu4Ciady3/NtNjB/1V9OXHGhiiHS1TX1XA25X7MtioUHxJYG2PnqSJScR2oKQ215O qdqRGzL7Sp9QTMs59T3zv1ZL9dKSjdin4p48zkfdGAisQqKMUm5JXYalRBF+7KpmZ5uo 2ovDNhaKkq/+pUsNk/sT2IuzOUechZIcuByj0vhJsbBgTedkdgnMpjrFe72tKfAVNXow eJBw== X-Gm-Message-State: AFqh2kp+drtSZy/Q4hXpLVl/cqQv3HWrL8zA7y/BYHa6loARhmpxjj98 nrUqWsWaoD/LdIA6JVXklw3aNA== X-Received: by 2002:a62:e708:0:b0:583:2a2e:3465 with SMTP id s8-20020a62e708000000b005832a2e3465mr4830150pfh.1.1673497279634; Wed, 11 Jan 2023 20:21:19 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:19 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Chen-Yu Tsai Subject: [PATCH v10 1/9] device property: Add remote endpoint to devcon matcher Date: Thu, 12 Jan 2023 12:20:56 +0800 Message-Id: <20230112042104.4107253-2-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789230779607430?= X-GMAIL-MSGID: =?utf-8?q?1754789230779607430?= 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 Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai Acked-by: Heikki Krogerus --- Changes in v10: - Collected Reviewed-by and Tested-by tags 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 2a5a37fcd998..48877af4e444 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1223,6 +1223,21 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, break; } + /* + * Some drivers may register devices for endpoints. Check + * the remote-endpoints for matches in addition to the remote + * port parent. + */ + node = fwnode_graph_get_remote_endpoint(ep); + if (fwnode_device_is_available(node)) { + ret = match(node, con_id, data); + if (ret) { + if (matches) + matches[count] = ret; + count++; + } + } + node = fwnode_graph_get_remote_port_parent(ep); if (!fwnode_device_is_available(node)) { fwnode_handle_put(node); From patchwork Thu Jan 12 04:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3686821wrt; Wed, 11 Jan 2023 20:23:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXv2y6ROsKhL99DET756W4UFQCLCPz3w+aeHpoeEgM8krThmumVyQqtnmDpvBKaRHm7MEFNW X-Received: by 2002:a05:6402:2d9:b0:499:d0e3:7745 with SMTP id b25-20020a05640202d900b00499d0e37745mr5852277edx.14.1673497433553; Wed, 11 Jan 2023 20:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497433; cv=none; d=google.com; s=arc-20160816; b=HOmhEXaeNq+cEPJbGjP+OLwclso2rewGQr3gto+S25RoeZVgdSlWmUmHt0iu70KiQL hqtKpSYAnxPqiGYAtZ/YrZavRasmOPvu5VOm+WVrBsa/0rKk7umYqU7UCGCl/W7FDHvn 7crUrU+6KWBbxs8Jezup2lggpqHK+RyW0+skpIMOu6RK15btxhNCtNVD/Pa1y9LY9VIy qqx2B05HprCup/NClI3ShUqDrIYyvHC7yqE2S7Hs8EclTjj7cSeEsGVsL04pD0MmEtga iVUx6ztDZncbWAbe//FFk6WdCLxs6pKS+Ze7PseRD8wGF/r3fJu8AU8ZoQRjPc7jByhg 7oDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H1TkdCYd6ACDb822V5ymCJqJsoUWZt84bjeNRJjxiCU=; b=jrXuvBgQeVbViMog2S5FV9xIx9bZQBQrX9jpUNRIYC3xDxJd4/6DbCFRADbU/GXe4K H2aaDGxOCpyq8m7gY1IZsSiR7MAXadrvxSos+LwfVtwKA0UIK2S7FXG3T1rAovPoYdaL KOC1bv8yAMROsaKJuVFb7sO86KjOjVvHkm8Y1XGe0RXUaXo1PuYnjxSDTTc8i+VJAoVF qnPqesc5f7cfCDGInw/oD3UVrJxWHOh9neUqIOl/qN3fc6ZKZKOfIGYG1VwasOU1qt5g ZJyAxostZkpuTpsT+2lxw0sf9THr5dQz0tQ7KVKMGh1BQTIgPWaBZwRULKQcM8EK2qBn 1eHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jdJO71CD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds7-20020a0564021cc700b00484f68b784csi16449780edb.329.2023.01.11.20.23.29; Wed, 11 Jan 2023 20:23:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jdJO71CD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239134AbjALEWh (ORCPT + 99 others); Wed, 11 Jan 2023 23:22:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236697AbjALEVw (ORCPT ); Wed, 11 Jan 2023 23:21:52 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A6CA1B1 for ; Wed, 11 Jan 2023 20:21:26 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id a30so12940836pfr.6 for ; Wed, 11 Jan 2023 20:21:26 -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=H1TkdCYd6ACDb822V5ymCJqJsoUWZt84bjeNRJjxiCU=; b=jdJO71CDHt8Fc8jxM5omcbFXpLk35O/tD3XpCg8d1m2smMqB62v74cke8eZw48ZwPG 22NL7DuFBjv0SkgEL2IMFOkU+iJ4QR+phjPOZKqJDGP8XkkfHFuZhL7jJgm8yFsgXAW5 animO4QOKlwWfmaPFXh/tkYURQg5TaxD8tqas= 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=H1TkdCYd6ACDb822V5ymCJqJsoUWZt84bjeNRJjxiCU=; b=yh/EiiGKX4A13gNkQ6sgLffmbEbP+dcdE83aZQ8S34liiKgXzrqCcG2cNHTURBfHRk S02GFISnhGe14vYFtlp4U9ahDHcCJIIVNtVWsg2TATT3KdBYXqAI3DAW6AbIIbJa3kyh 28G3HlgoBpN82qa0KB9QG62BFXFRnWBiN9haG03jUwmb02wvNREmtJ+1KWAGxdiwXHms cKrwWR+jWLxDZHrgccyTmSk7ohs5w5POF1CmIXzqEtBUXNsQKQ9EwrvvwZabecKtJitF 27rQQV40NNQQQGzsyLWfxroyiG3/f5r8IVqgaK7sQR6TL2uhz3O/KOIlzAx3KSocMeG7 Br7w== X-Gm-Message-State: AFqh2kq/GYOcierZzrf2c2cs+1enS1XoeDcdnpX/uRt4Ple0Kh6fQWZ4 QB1DtFevPmTPYTYZrYB3zscB8w== X-Received: by 2002:a05:6a00:2997:b0:582:1f25:5b8 with SMTP id cj23-20020a056a00299700b005821f2505b8mr44070232pfb.19.1673497286002; Wed, 11 Jan 2023 20:21:26 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:25 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Chen-Yu Tsai Subject: [PATCH v10 2/9] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Date: Thu, 12 Jan 2023 12:20:57 +0800 Message-Id: <20230112042104.4107253-3-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789244521072748?= X-GMAIL-MSGID: =?utf-8?q?1754789244521072748?= 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 Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai Acked-by: Heikki Krogerus --- Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v7: - Fix the long comment lines Changes in v6: - New in v6 drivers/platform/chrome/cros_ec_typec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2a7ff14dc37e..302474a647cc 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -382,6 +382,16 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return -EINVAL; } + /* + * OF graph may have set up some device links with switches, + * since connectors have their own compatible. Purge these + * to avoid a deadlock in switch probe (the switch mistakenly + * assumes the connector is a supplier). + */ + if (dev_of_node(dev)) + device_for_each_child_node(dev, fwnode) + fw_devlink_purge_absent_suppliers(fwnode); + /* DT uses "reg" to specify port number. */ port_prop = dev->of_node ? "reg" : "port-number"; device_for_each_child_node(dev, fwnode) { From patchwork Thu Jan 12 04:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3686965wrt; Wed, 11 Jan 2023 20:24:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1iGzaBfo/j6gOauAQ2O9ax2NZwGtnKabNr9jLoSaK90S3N7zfalwiRUfJPPD5/MQjYGYR X-Received: by 2002:a17:907:73c1:b0:7e7:4dd7:bc0c with SMTP id es1-20020a17090773c100b007e74dd7bc0cmr60890574ejc.66.1673497461797; Wed, 11 Jan 2023 20:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497461; cv=none; d=google.com; s=arc-20160816; b=IIMQ2PHTgnvsqhO95PIztZojijS0oU8xWQKm1h2kVSCYj8p+VXdpLHLwD+Qzxd18Dq oRz3jwMV4Vo4OPfAYU+H6+qCfVuQR0bZIDLsy8NFFjCAdA0xM8r5TsSRvgMgnGDmOU/c TuzhWKj/B4NGbAKhtSK04TBEKeZANIBhdFWg79O3hv7u0gpPl/S9MCulo3TZy8H/OibU LpukD3jASlO3AtEL/RY913UKqB8bdeC7kXS9NsPvnVXuNeK0wUzn5AC8QmkZe6lsHU+C tDuN3VlaRt4LltvUud+bHdlbEgPP47yo9tg55lVc8WWNKYIwyi803m5PWnVkPlPSSz3M Bhqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aDVRGgfyVTS1/RVP67Y9O6IBzdS62PU0w4QAZOD5vEM=; b=Pplh/QWxw7QLNULt3QvrTfWsnv7lEhsbjAb+NY3t2jsCq+s4kl7vg3nwvbnKg/wrR2 kbmhSDPDkBJGEqxTr84TeMvAcXzVNsDpLTNVC5qq+wbdVkgJ8GuQuOmKz3F/gtTeJVtc Mo/sMAJBxY20ersR4OSamTYhRmMTqm0SRCijLg/F3CzTzZoAzzsGvPV2xKkbpvLENDn7 JmviO2k6qBui+PNNkRyheuD4RSBVhAWZ2/pbnj0ohqGJlgDlISKVaNpu+ST/sLiQ4iCB CTgpbaR5ns64npvz4ZOUpMpxOYdQa1afKjtNbpELjs+SlpMziBWiuNltrCtwCK7jHsKx h3KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W8Cs6H4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn9-20020a17090794c900b00855da26bcd6si7107221ejc.939.2023.01.11.20.23.58; Wed, 11 Jan 2023 20:24:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W8Cs6H4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239359AbjALEWp (ORCPT + 99 others); Wed, 11 Jan 2023 23:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236767AbjALEWA (ORCPT ); Wed, 11 Jan 2023 23:22:00 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E7DAB1D0 for ; Wed, 11 Jan 2023 20:21:35 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id g20so12945446pfb.3 for ; Wed, 11 Jan 2023 20:21:35 -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=aDVRGgfyVTS1/RVP67Y9O6IBzdS62PU0w4QAZOD5vEM=; b=W8Cs6H4xp7xC3wZAQSHHgf/sXztbttIRaHFwd29PmxMB7nVJ0/fVXijVYxrr8ggtkz WGTIqEkNz2bKDujKpmkosYJlDSH+lpeQRns3kLSX0tpJ7AhAFoecip97mUCim4Wgj+CJ BjaEqQUH1lna6l0GfwXtdZkuSsCe0vzB1tThg= 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=aDVRGgfyVTS1/RVP67Y9O6IBzdS62PU0w4QAZOD5vEM=; b=71qpD5poIwbaRuaNAwTPN1i5UdIYo16RiXy35FuO+YDHWu/vhAbaIxWfXbW+8KFC3O xpcwdaMXPWPl0AoUGGxuvhjrOpCEdGrSgGkI7AnnlrhsJRhT4GekCkdZcGx6se/2ZSIR jhQOl2oI6HCG+irWdtNfShx67SZUYYHUGRcwTcfXnG3OjfjNfT09NllDTqGv1EjKLaYt ls9pjEkz7yyZvBzRUOgGpYy0XmV5UkWQHfsx09HT794MkqOlkS6CnkaozaHTz3rLg8wE 01/hrbCyM6ujo283pVxuw2MRe4t6FNX5U+9Uj0L2u61gfMo2o2sRD+rGvDqLWCRlgrMH QzwQ== X-Gm-Message-State: AFqh2kq/+3XeWdaPEgiAvY+s+Uf4XiqXknDRI7R+At9EDwi2JNvkdeRV P+P+GBn+dthQiwsmR1s+CCHHeA== X-Received: by 2002:a05:6a00:228d:b0:58b:9f4e:5a45 with SMTP id f13-20020a056a00228d00b0058b9f4e5a45mr2497352pfe.11.1673497294983; Wed, 11 Jan 2023 20:21:34 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:34 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Chen-Yu Tsai , Dmitry Baryshkov , Douglas Anderson , Imre Deak , Jani Nikula , Kees Cook , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , shaomin Deng Subject: [PATCH v10 3/9] drm/display: Add Type-C switch helpers Date: Thu, 12 Jan 2023 12:20:58 +0800 Message-Id: <20230112042104.4107253-4-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789274633002074?= X-GMAIL-MSGID: =?utf-8?q?1754789274633002074?= Add helpers to register and unregister Type-C "switches" for bridges capable of switching their output between two downstream devices. The helper registers USB Type-C mode switches when the "mode-switch" and the "data-lanes" properties are available in Device Tree. Signed-off-by: Pin-yen Lin Tested-by: Chen-Yu Tsai Reviewed-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- Changes in v10: - Collected Reviewed-by and Tested-by tags - Replaced "void *" with "typec_mux_set_fn_t" for mux_set callbacks - Print out the node name when errors on parsing DT - Use dev_dbg instead of dev_warn when no Type-C switch nodes available - Made the return path of drm_dp_register_mode_switch clearer Changes in v8: - Fixed the build issue when CONFIG_TYPEC=m - Fixed some style issues Changes in v7: - Extracted the common codes to a helper function - New in v7 drivers/gpu/drm/display/drm_dp_helper.c | 134 ++++++++++++++++++++++++ include/drm/display/drm_dp_helper.h | 17 +++ 2 files changed, 151 insertions(+) diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index 16565a0a5da6..a2ec40a621cb 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -30,11 +30,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -3891,3 +3893,135 @@ int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) EXPORT_SYMBOL(drm_panel_dp_aux_backlight); #endif + +#if IS_REACHABLE(CONFIG_TYPEC) +static int drm_dp_register_mode_switch(struct device *dev, struct device_node *node, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set) +{ + struct drm_dp_typec_port_data *port_data; + struct typec_mux_desc mux_desc = {}; + char name[32]; + u32 dp_lanes[2]; + int ret, num_lanes, port_num = -1; + + num_lanes = drm_of_get_data_lanes_count(node, 0, 2); + if (num_lanes <= 0) { + dev_err(dev, "Error on getting data lanes count from %s: %d\n", + node->name, num_lanes); + return num_lanes; + } + + ret = of_property_read_u32_array(node, "data-lanes", dp_lanes, num_lanes); + if (ret) { + dev_err(dev, "Failed to read the data-lanes variable from %s: %d\n", + node->name, ret); + return ret; + } + + port_num = dp_lanes[0] / 2; + + port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + 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 = 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\n", + port_num, ret); + + return ret; + } + + return 0; +} + +/** + * drm_dp_register_typec_switches() - register Type-C switches + * @dev: Device that registers Type-C switches + * @port: Device node for the switch + * @switch_desc: A Type-C switch descriptor + * @data: Private data for the switches + * @mux_set: Callback function for typec_mux_set + * + * This function registers USB Type-C switches for DP bridges that can switch + * the output signal between their output pins. + * + * Currently only mode switches are implemented, and the function assumes the + * given @port device node has endpoints with "mode-switch" property. + * Register the endpoint as port 0 if the "data-lanes" property falls in 0/1, + * and register it as port 1 if "data-lanes" falls in 2/3. + */ +int drm_dp_register_typec_switches(struct device *dev, struct device_node *port, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set) +{ + struct device_node *sw; + int ret; + + for_each_child_of_node(port, sw) { + if (of_property_read_bool(sw, "mode-switch")) + switch_desc->num_typec_switches++; + } + + if (!switch_desc->num_typec_switches) { + dev_dbg(dev, "No Type-C switches node found\n"); + return 0; + } + + switch_desc->typec_ports = devm_kcalloc( + dev, switch_desc->num_typec_switches, + sizeof(struct drm_dp_typec_port_data), GFP_KERNEL); + + if (!switch_desc->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 = drm_dp_register_mode_switch(dev, sw, switch_desc, data, mux_set); + if (ret) + goto err_unregister_typec_switches; + } + + return 0; + +err_unregister_typec_switches: + of_node_put(sw); + drm_dp_unregister_typec_switches(switch_desc); + dev_err(dev, "Failed to register mode switch: %d\n", ret); + return ret; +} +EXPORT_SYMBOL(drm_dp_register_typec_switches); + +/** + * drm_dp_unregister_typec_switches() - unregister Type-C switches + * @switch_desc: A Type-C switch descriptor + */ +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc) +{ + int i; + + for (i = 0; i < switch_desc->num_typec_switches; i++) + typec_mux_unregister(switch_desc->typec_ports[i].typec_mux); +} +EXPORT_SYMBOL(drm_dp_unregister_typec_switches); +#else +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc) +{ +} +EXPORT_SYMBOL(drm_dp_register_typec_switches); +int drm_dp_register_typec_switches(struct device *dev, struct device_node *port, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set) +{ + return 0; +} +EXPORT_SYMBOL(drm_dp_unregister_typec_switches); +#endif diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h index ab55453f2d2c..5a3824f13b4e 100644 --- a/include/drm/display/drm_dp_helper.h +++ b/include/drm/display/drm_dp_helper.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -763,4 +764,20 @@ bool drm_dp_downstream_rgb_to_ycbcr_conversion(const u8 dpcd[DP_RECEIVER_CAP_SIZ const u8 port_cap[4], u8 color_spc); int drm_dp_pcon_convert_rgb_to_ycbcr(struct drm_dp_aux *aux, u8 color_spc); +struct drm_dp_typec_port_data { + struct typec_mux_dev *typec_mux; + void *data; + bool dp_connected; +}; + +struct drm_dp_typec_switch_desc { + int num_typec_switches; + struct drm_dp_typec_port_data *typec_ports; +}; + +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc); +int drm_dp_register_typec_switches(struct device *dev, struct device_node *port, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set); + #endif /* _DRM_DP_HELPER_H_ */ From patchwork Thu Jan 12 04:20:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3687087wrt; Wed, 11 Jan 2023 20:24:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsOpYo7XBYDI/p2SpPYD1Pi/7Xk4swl7hIubS0UH5tIom5+1Wffn4nB9fuib0neDCGroHw X-Received: by 2002:a17:906:3a98:b0:84d:255e:21a4 with SMTP id y24-20020a1709063a9800b0084d255e21a4mr15933209ejd.2.1673497481046; Wed, 11 Jan 2023 20:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497481; cv=none; d=google.com; s=arc-20160816; b=fWIVUBFYOVW4TMLeCYUH50PRj7g0B1xKOAiiwaZmUVuw0rSJpWY1GNmlbxGso81Xc5 FJMsHaXEIagG0fPBTWSegUwT2MBpQDNZrsshiloJ2vTEw/k6qmA6RhECOOIfO02ZtJOS SWd42nAQN7lABNlQpKxRf742BPDbNBY34oPv23o4eCvnHBMFBm+9ElNFnT+NwYkz1iz/ EePNZhbTkOmA9uEbvw/qFTfTJadPPj/zvfLbMcbQfyWuSZGMXq81vA0+yLyGiFuP/e7A 91P8LxCzq4BNOkhEb3ICF/YiH7DXK18YNY5PT9xyP6FMR9dd8JR1ySX38BG6D6OgvUuJ BCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zW4fdNu5opMQG/leQM62JltFy2Hko9Kx8atjzuDpU/M=; b=IvGf/prXn1q94gRntK+j4R0f63g8TmamM6tczaD7X8IObnuVCxRKWycTCEN5fYAHNq Hqa/GqTyJo5hkY+kRSwb3umW/cN7EJA1fqb9edSwJ3sr1IY6T0ipb1xABEnWXOpE/rOh 9DFcrHWcg78DalXaw+iWpbBhe3RIqJXiPgoKJS6LK+iiBk6+Is9TQ22k1+QbRGEPRAIN Yq1mQFXruzmRCJ00W0HmE3akg1GGHphiSzxUWrH12/VXTscs7Z+9/ACOL/aV7sFzpC5G rMZVOl9MtyXAbiIzEt7CpASe9H+vDpF9IU5SMEKU2gdjP2mElzGAeIGqZExTiZzGNxEy QqDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nAoPdiN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb10-20020a1709077e8a00b0084c855eabfesi17266195ejc.175.2023.01.11.20.24.17; Wed, 11 Jan 2023 20:24:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nAoPdiN0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236794AbjALEWw (ORCPT + 99 others); Wed, 11 Jan 2023 23:22:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236786AbjALEWB (ORCPT ); Wed, 11 Jan 2023 23:22:01 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7F4BC27 for ; Wed, 11 Jan 2023 20:21:42 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id x4so8798462pfj.1 for ; Wed, 11 Jan 2023 20:21:42 -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=zW4fdNu5opMQG/leQM62JltFy2Hko9Kx8atjzuDpU/M=; b=nAoPdiN0Zh6Uo7VQgf0+Z1FS2m+U2rDsaqqNeN6eF65HYbOkAa9L9FRQl7yccvqpe+ QSAmO8ILdPvXiZQfoWlaxTRLVXpY4NQZTawtQqUM2C3BZPgwcXseSY4PcqEg4epT6L3v ur2G2EbwQzREhFlJgCKbbeDZm8JG0HKIMzWPw= 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=zW4fdNu5opMQG/leQM62JltFy2Hko9Kx8atjzuDpU/M=; b=PTsWv3oPNCxPkqQDXXRYmyKk9Qnp3RQohiY7mCfMdpIfnvsI3X/tUPzeFUaCgb+GKZ Czu5pzha5D6DJpIDJlE6rq20JGn7QgU4TRUmfr7PIOKV248rMrdEl5EISvEnnOjAzVra cOc+TzcBpGj+xPlQy65dQvIr+Gwp9MW1//trlyJbkbCGmdtTHjb9ghV/g/x92GZcbIKY AwGIIguQnx5yOI9LtC3lyeY9HfzUvaGCwqKaKL75N7iAO3rXfhtXcoq44BTn8v/MflfZ Dmy7eZmRNx9aOP8920UhEUvbqeFpDWdCFJs/60G6jtEtCq9058Gx5WWIgxhaUV0DVQYB lbpQ== X-Gm-Message-State: AFqh2kpBVlHmyw/ouMeY7H61QSq0fGesvNFcowmOBE5OyjP4z9f/p3kD jDwMfwrHhEZ0f6X4lpYsp7Kz6w== X-Received: by 2002:a05:6a00:1da5:b0:577:9807:2db8 with SMTP id z37-20020a056a001da500b0057798072db8mr78203712pfw.3.1673497301094; Wed, 11 Jan 2023 20:21:41 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:40 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Krzysztof Kozlowski , Chen-Yu Tsai Subject: [PATCH v10 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support Date: Thu, 12 Jan 2023 12:20:59 +0800 Message-Id: <20230112042104.4107253-5-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789294449869962?= X-GMAIL-MSGID: =?utf-8?q?1754789294449869962?= 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 Reviewed-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v9: - Collected Reviewed-by tag Changes in v8: - Updated anx7625 bindings for data-lane property - Fixed the subject prefix Changes in v7: - Fixed issues reported by dt_binding_check - Updated the schema and the example dts for data-lanes. - Changed to generic naming for the example dts node. Changes in v6: - Remove switches node and use endpoints and data-lanes property to describe the connections. .../display/bridge/analogix,anx7625.yaml | 99 ++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml index 4590186c4a0b..b49a350c40e3 100644 --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml @@ -12,7 +12,8 @@ maintainers: 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_ProductBrief.pdf properties: compatible: @@ -112,10 +113,48 @@ properties: data-lanes: true port@1: - $ref: /schemas/graph.yaml#/properties/port + $ref: /schemas/graph.yaml#/$defs/port-base description: Video port for panel or connector. + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + remote-endpoint: true + + data-lanes: + oneOf: + - items: + - enum: [0, 1, 2, 3] + + - items: + - const: 0 + - const: 1 + + - items: + - const: 2 + - const: 3 + + - items: + - const: 0 + - const: 1 + - const: 2 + - const: 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 @@ -164,8 +203,12 @@ examples: }; mipi2dp_bridge_out: port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; - anx7625_out: endpoint { + anx7625_out: endpoint@0 { + reg = <0>; remote-endpoint = <&panel_in>; }; }; @@ -186,3 +229,53 @@ examples: }; }; }; + - | + i2c3 { + #address-cells = <1>; + #size-cells = <0>; + + encoder@58 { + compatible = "analogix,anx7625"; + reg = <0x58>; + pinctrl-names = "default"; + pinctrl-0 = <&anx7625_dp_pins>; + enable-gpios = <&pio 176 GPIO_ACTIVE_HIGH>; + reset-gpios = <&pio 177 GPIO_ACTIVE_HIGH>; + vdd10-supply = <&pp1100_dpbrdg>; + vdd18-supply = <&pp1800_dpbrdg_dx>; + vdd33-supply = <&pp3300_dpbrdg_dx>; + analogix,audio-enable; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + anx7625_dp_in: endpoint { + bus-type = <7>; + remote-endpoint = <&dpi_out>; + }; + }; + + port@1 { + #address-cells = <1>; + #size-cells = <0>; + + reg = <1>; + anx_typec0: endpoint@0 { + reg = <0>; + mode-switch; + data-lanes = <0 1>; + remote-endpoint = <&typec_port0>; + }; + anx_typec1: endpoint@1 { + reg = <1>; + mode-switch; + data-lanes = <2 3>; + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + }; From patchwork Thu Jan 12 04:21:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3686940wrt; Wed, 11 Jan 2023 20:24:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXufWKiQ5f6jRTbItVyGfisbJHHt3AMAk0bcMh/MYGrf2PHuBnsaUXJEs2reAgYfJj8Kq37S X-Received: by 2002:a17:907:c30c:b0:7c1:337e:5755 with SMTP id tl12-20020a170907c30c00b007c1337e5755mr39369016ejc.26.1673497457217; Wed, 11 Jan 2023 20:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497457; cv=none; d=google.com; s=arc-20160816; b=sBcCLn+GP1dxl3an0Tofr/DDPYioeJlfdAKd0bO7hgw24KFFSMe43pUTtNlRSmrEQE igz79Y6fsCtlQr5VQQWVpJ4g/SoWNOscFzxPVC3cJVgsTf6RIr726hurp/Bd9oTNgqge YrU4mSpkpfx4721LTkeJyg+pgSBeKxY7XxzzsVmo2NNeHevx3cIhsfZ/7TDXKXfnR8fi 8Vsb1CvSVnAdcB79R6+rLldbHhWgXgopxiQ0l5ee/S+7GkdQGbrSF0dgsnDmDwiHgRT5 LcsnrEOPX13mcHLOmkJ2HHXlpzD58k6OJ+haT2cSHGa/hlAbdFoKvsaXJltoXRbX5tRQ IFkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X4fsKZ8vfmDfUc1Nfjl36ivIzejXzy6Kt8K+gcJWI24=; b=u+3ztrPVG/V+A8KkpHQgI+xc+NCsOpvDeemyhpY3vPYlHi7SS4UDWSAK0TmOxL+9Vc tDsurQrj/RlMCA0lgQXHqzK35X8FWf76daOUPyA/BvRDMDBZX0v7nXkmOqLznMFKels9 qyYBT+mnclw1JcHLdmA3RboWhi/snGJFYZdGHYMQi8TROByY2BCflTrbXa4susVzIq7D VsU1NGrHcXtseP0TNWqTYeXw3EL3o8RSf+sbpnKfQ8hMuXw7gMUCqCZZ5a6mxk2ChbRY obd6UXE24Xr09fXBQypP4xw6GFD6B+O/pV3AqugaffQul0ciFOEWjnYzLu8iyQvTSPHb yr6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mkPluvk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb12-20020a170907960c00b007c1633cea0csi18198379ejc.513.2023.01.11.20.23.54; Wed, 11 Jan 2023 20:24:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mkPluvk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239479AbjALEXE (ORCPT + 99 others); Wed, 11 Jan 2023 23:23:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236805AbjALEWB (ORCPT ); Wed, 11 Jan 2023 23:22:01 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE7ABE00 for ; Wed, 11 Jan 2023 20:21:47 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id s67so11970412pgs.3 for ; Wed, 11 Jan 2023 20:21:47 -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=X4fsKZ8vfmDfUc1Nfjl36ivIzejXzy6Kt8K+gcJWI24=; b=mkPluvk59KIiAcPlMDzERaNoAA9HeVVqvopt0+jh3JVWYVk5ewNwNrAH9p0jo5Iwws 2CQ86HkEsKNCSwoYJKBDsEcZe8eQR/vO6t/ZPbARJBLEagCttO1T7hJDbm9X73MbQz2h pC/tdKthbblySuECemzkzZQ0F+XgWqAGd7pkE= 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=X4fsKZ8vfmDfUc1Nfjl36ivIzejXzy6Kt8K+gcJWI24=; b=FLNWr/6kJgPR8ohVSzNYnkcFvs8wQudRgD9v1oXcHcynHy9pKZGG1BNiOecTvM8gL5 wTxsePkv1tTDKJxg9re8gIcPbHMDQOdTuVFet9K1jN/nXL0YNsjrLcCycDBRFRMMMS1k gUvVEVUYwrNt+0yT318EblXK20a0EQqFPxEaZhReGl1HhQHkh5rG9XGRALjOTNCVF/qI vrpavaC9xb2fqI9QCXx17lE2cQ7N1G9q92h1uLEGATWnywJQk7uPpijLoCL+85v3Jjee iLv3wqwNccBfSCdnLrB7RI0ooald05dIy/IJGjtbaptmCRrC1ARBLjkCkN1w0y9VOVTu BXmA== X-Gm-Message-State: AFqh2krXLLddO1shSaB2RgYCXxArrFz9bJN8EynyLiwoJ/Yh0XHzmWzk 10QWrqT2Nu8cnEey3YAG4eh7FQ== X-Received: by 2002:a62:4dc7:0:b0:586:210b:2b67 with SMTP id a190-20020a624dc7000000b00586210b2b67mr17041922pfb.6.1673497307326; Wed, 11 Jan 2023 20:21:47 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:47 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Chen-Yu Tsai , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , =?utf-8?q?Uwe?= =?utf-8?q?_Kleine-K=C3=B6nig?= Subject: [PATCH v10 5/9] drm/bridge: anx7625: Check for Type-C during panel registration Date: Thu, 12 Jan 2023 12:21:00 +0800 Message-Id: <20230112042104.4107253-6-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789269860543474?= X-GMAIL-MSGID: =?utf-8?q?1754789269860543474?= 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 Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai --- Changes in v10: - Collected Reviewed-by and Tested-by tags 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/bridge/analogix/anx7625.c index b375887e655d..1cf242130b91 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1649,7 +1649,7 @@ static int anx7625_get_swing_setting(struct device *dev, static int anx7625_parse_dt(struct device *dev, struct anx7625_platform_data *pdata) { - struct device_node *np = dev->of_node, *ep0; + struct device_node *np = dev->of_node, *ep0, *sw; int bus_type, mipi_lanes; anx7625_get_swing_setting(dev, pdata); @@ -1688,6 +1688,17 @@ static int anx7625_parse_dt(struct device *dev, if (of_property_read_bool(np, "analogix,audio-enable")) pdata->audio_en = 1; + /* + * 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 = devm_drm_of_get_bridge(dev, np, 1, 0); if (IS_ERR(pdata->panel_bridge)) { if (PTR_ERR(pdata->panel_bridge) == -ENODEV) { From patchwork Thu Jan 12 04:21:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3686980wrt; Wed, 11 Jan 2023 20:24:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFA48A8Gh8pVxVJBEeuGClMs3bv7fItRUURTLvOD35dLTMh5T6Ny8nzLsFzxPBF3M8r1Jz X-Received: by 2002:a05:6402:35b:b0:488:e7ae:5cc4 with SMTP id r27-20020a056402035b00b00488e7ae5cc4mr41448984edw.41.1673497463935; Wed, 11 Jan 2023 20:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497463; cv=none; d=google.com; s=arc-20160816; b=icnwJCk1//4hZz2nqlIJqWOK5unwKk2NvQP7XtGGQypFNq/HV5PFggtzJkpoLWPlE9 sst/GSEnJyCYj6bNdaj6KadiTGZdAxnexsuUKtUSsTw5M/wv8EIvhsWNpddoxLV7M+UZ lDLJtf6GB69aGUrINqYQg9bbRDQYljcdOrvHQhTGzLsMmyMuld1ShZMsXWHJQuUK5Dj/ 4y7ShCZpSEnwAFHfXeD5QfObZBA5eywahW1nOvCtFYz/c2JGOiTAsZQF1yfb+/vTym2Q EEMWSQBSPRd0Grn3njmI4ybRdWRlPHubxHp5htm1C+zmmq2LQPS6HY5rMWxJPZE+Od7I iQ5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dyrwfywewO+EJZ65JeId9yW4fjW1rcHlsmlCHRqKdY4=; b=ozXuo36sh4YA5iA2iPwKswO9t+jkmV3m5feYpC84oFag1TPAhpHYJDW3ODCiRPEg9o XV7anbxCfRtTHJ/thFk7R6VoFUAaANvlRdg8F9WrgPdCX99uEUJciVzPcNDTDIc5fmi2 a/cI0vPVJx8cDIPXEGPQd7MBbGasxaOzHbkEZdA4eR7HIPn2rG9JwSkYcfxn54bSC4fu N+tMXLpAxbRJ00vOe0ng7OP8n5sUU4g1/fiapcwTPiunfvkNhHF/qSB0en4xeRc5j8v9 bjTdozUzOfxLKHVMzDsopi9u1NmrEEIo1wpCP1rplX1GEYFT+9vw+6eqYDZGhr9ma3Ok OcoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hE5nhmq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a50e601000000b0048d524fe52dsi16600005edm.250.2023.01.11.20.24.00; Wed, 11 Jan 2023 20:24:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hE5nhmq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239515AbjALEXO (ORCPT + 99 others); Wed, 11 Jan 2023 23:23:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236843AbjALEWC (ORCPT ); Wed, 11 Jan 2023 23:22:02 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F02D101F0 for ; Wed, 11 Jan 2023 20:21:55 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id w3so19012979ply.3 for ; Wed, 11 Jan 2023 20:21:55 -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=dyrwfywewO+EJZ65JeId9yW4fjW1rcHlsmlCHRqKdY4=; b=hE5nhmq9CLi+4zJA0yhBuE/nMUYwgkGU80LWlKESH7+Mjx2ijh5p6/txchkNtMgU9j LTbqDatXGlWhir6WPOKj0DX7MIq3rrqYtLqNGRl42A4ezNaTkxP19rTSws3rCNjES+Ec Ixck24yEFfVGYK4NUlpWDAkNBTaUx+RJ7N7gE= 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=dyrwfywewO+EJZ65JeId9yW4fjW1rcHlsmlCHRqKdY4=; b=BVUO9jfFDjeia36P6oN6K/X7IhF+FsxjLM7xNRhk7/LiZOFLIUm6kBtO+xJ4LyaZuf LH3XqiZnrk62LnizJQSdlf01/yR8hKwC4i4arB2JRFGHTywXP26LQH8e/2gpP1nAfnYq 4XkR1x95jX/mlU+1iuEVRKOuiDUsBvfUGs0yykRyWS12r/2jSoKx1xEuQRY0lmytnP79 lFT1WK+4XUyarO+D7i9qQNWBLshfgvrE/P0bN4EViobzdwUHmXL3PtsN+nQUj5QCq7zA 0w0AFJgwJcP2eAR3F38XkislcEiXvbeDPhbb1jh6Rs1xXzkA/2tRhD15/lx76KpU7AUR +i0Q== X-Gm-Message-State: AFqh2kqL3L3oMYjLm6TWK/XcApHlB7kGFllHYnT//NxBhvj/5FRU88Hf ph9Zso5fBA8iqrfjw+E0HoMY4Q== X-Received: by 2002:a05:6a20:d389:b0:af:7a4c:fb7d with SMTP id iq9-20020a056a20d38900b000af7a4cfb7dmr91809108pzb.23.1673497314896; Wed, 11 Jan 2023 20:21:54 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:21:54 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang , Chen-Yu Tsai , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Subject: [PATCH v10 6/9] drm/bridge: anx7625: Register Type C mode switches Date: Thu, 12 Jan 2023 12:21:01 +0800 Message-Id: <20230112042104.4107253-7-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789276850573450?= X-GMAIL-MSGID: =?utf-8?q?1754789276850573450?= Register USB Type-C mode switches when the "mode-switch" property and relevant ports are available in Device Tree. Configure the crosspoint switch based on the entered alternate mode for a specific Type-C connector. Crosspoint switch can also be used for switching the output signal for different orientations of a single USB Type-C connector, but the orientation switch is not implemented yet. A TODO is added for this. Signed-off-by: Pin-yen Lin Tested-by: Chen-Yu Tsai --- Changes in v10: - Added a TODO for implementing orientation switch for anx7625 - Updated the commit message for the absence of orientation switch - Fixed typo in the commit message - Collected Tested-by tag Changes in v7: - Fixed style issues in anx7625 driver - Removed DT property validation in anx7625 driver. - Extracted common codes to another commit. Changes in v6: - Squashed to a single patch drivers/gpu/drm/bridge/analogix/Kconfig | 1 + drivers/gpu/drm/bridge/analogix/anx7625.c | 92 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++ 3 files changed, 106 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/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=n 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/bridge/analogix/anx7625.c index 1cf242130b91..808dbf79d209 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 #include @@ -2572,6 +2574,90 @@ 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) +{ + struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; + /* Check if both ports available and do nothing to retain the current one */ + if (switch_desc.typec_ports[0].dp_connected && switch_desc.typec_ports[1].dp_connected) + return; + + if (switch_desc.typec_ports[0].dp_connected) + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_NORMAL); + else if (switch_desc.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 drm_dp_typec_port_data *port_data = typec_mux_get_drvdata(mux); + struct anx7625_data *ctx = (struct anx7625_data *) port_data->data; + struct device *dev = &ctx->client->dev; + struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; + bool new_dp_connected, old_dp_connected; + + if (switch_desc.num_typec_switches == 1) + return 0; + + old_dp_connected = switch_desc.typec_ports[0].dp_connected || + switch_desc.typec_ports[1].dp_connected; + + port_data->dp_connected = state->alt && + state->alt->svid == USB_TYPEC_DP_SID && + state->alt->mode == USB_TYPEC_DP_MODE; + + dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", + switch_desc.typec_ports[0].dp_connected, switch_desc.typec_ports[1].dp_connected); + + new_dp_connected = switch_desc.typec_ports[0].dp_connected || + switch_desc.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 void anx7625_unregister_typec_switches(struct anx7625_data *ctx) +{ + drm_dp_unregister_typec_switches(&ctx->switch_desc); +} + +static int anx7625_register_typec_switches(struct device *dev, struct anx7625_data *ctx) +{ + struct device_node *port = of_graph_get_port_by_id(dev->of_node, 1); + + /* + * Currently, only mode switch is implemented. + * TODO: Implement Type-C orientation switch for anx7625. + */ + return drm_dp_register_typec_switches(dev, port, &ctx->switch_desc, + ctx, anx7625_typec_mux_set); +} + static int anx7625_i2c_probe(struct i2c_client *client) { struct anx7625_data *platform; @@ -2679,6 +2765,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 && 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; if (!anx7625_of_panel_on_aux_bus(&client->dev)) @@ -2730,6 +2820,8 @@ static void 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 14f33d6be289..38abbd3d6b36 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 ********/ /***************************************************************/ @@ -479,6 +491,7 @@ struct anx7625_data { struct drm_connector *connector; struct mipi_dsi_device *dsi; struct drm_dp_aux aux; + struct drm_dp_typec_switch_desc switch_desc; }; #endif /* __ANX7625_H__ */ From patchwork Thu Jan 12 04:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42250 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3687609wrt; Wed, 11 Jan 2023 20:26:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsvgA5zqxKwQPkFRw29Auj1dpnAIRwyPoEKGAJC6XvjQYBgYLT7XGu0HFmxFwapZIbW/37k X-Received: by 2002:a05:6402:2409:b0:493:597e:2192 with SMTP id t9-20020a056402240900b00493597e2192mr23607322eda.38.1673497595763; Wed, 11 Jan 2023 20:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497595; cv=none; d=google.com; s=arc-20160816; b=xuE1+cGNe2OyxVcVkS59ht4UrzL7ldHL1QlT/7A1Dpr3wGuiRwGo2QlpOrQP2Bn/i3 IvpjQbatQw3GRtKefJchtmxEIEa2yHiilIvSSvhNqaAeFfiKyGS9CnU1gTNG9OyvOFLz pw8LhhlWIXYkxFM1ecJTYv+3G+kBlowuYR/VbYX/SSo61LEnt4O110rL8eEMxc38j6rn t83qbmIiFEVQfSCyJ/R1oRjRoNXabOSMu2I2L7/0T8LmZwotwZ3Gmx7Q+w3p8t2s1KXd 12IaMwS/YRwRXEDv2fYORUG60q2IV2B828HOcjoOiy4hcO5CH/9pgRmN244SgM7RgjUA JNOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A+W1cXAXq5duK/oGrDudgV2aBiDrEOkk3FJcTdtrXNI=; b=BuG57w8ksMtAco+LwRScrz1nXEfmx+qqFT7rTRlSwB0iAJuaM73jO3MeC3HDTQ6GsQ rdBjEbB3YjSusl+MPjoDtiBgmitS2m7vmvRrYUTYHKV5AUIlGMi7Hbbqzk8bN7U0gIzd Wmj6YL4nmIBaDprlu244hcwmwDQ/an0i39B3XlTpvxxIKVF3yrVwtXIYagoklJLl4gHH fKXEq7PNxJls395qTj9xxKZIugD4tOHC9MBIlbw73215myE027wqkQISaNLEJ82CDDe/ ACkqVMWLmtoE+FhWcOPm7MFrB7oZRsgvDGmgizo8AesqxtJXyQLpqEVTiZmZuCqTXvxJ ZoLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lyCQW6pE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e20-20020a50fb94000000b00497431159d4si14363906edq.532.2023.01.11.20.26.12; Wed, 11 Jan 2023 20:26:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lyCQW6pE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239544AbjALEXV (ORCPT + 99 others); Wed, 11 Jan 2023 23:23:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235881AbjALEWH (ORCPT ); Wed, 11 Jan 2023 23:22:07 -0500 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 B558F1DF0E for ; Wed, 11 Jan 2023 20:22:05 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id n12so17938744pjp.1 for ; Wed, 11 Jan 2023 20:22:05 -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=A+W1cXAXq5duK/oGrDudgV2aBiDrEOkk3FJcTdtrXNI=; b=lyCQW6pEIVnYKQAwsAKRPrWLr6a0pbfDTbyn0/QZC3RjMznqFU6UexHGwA6k+2Ct5+ ehmFOIHkp7bu5MId/ijQjkoqMOjqc38zKlAN0WQbr8dJp57hi6cGHX55KmfchbU5CkWG 0jUtUp8TKzDU4Nq1y6qPI28wgKjbv1GtMI1IA= 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=A+W1cXAXq5duK/oGrDudgV2aBiDrEOkk3FJcTdtrXNI=; b=M1EE9HndCWWtUEX+FnBYHUU2kyfwz6o1fVEhKmyc+/NtoEqYm0SmgVVi5+8KYX1X5w uqPy9cfELZ4h+Z8DAHU1uBWkyj5EJdXy9Z/SUsVRLSTILHc/nyQWDVygEVdCeCC8RzQw ikb44e1rRHYOkKKoNClxjzTquAiUwhhu9CaUqadVNJm0Bj2CtgotTcPX/qB8N2baHQez AvztPVNfdnB0CFw0+l5+Rbr7uaICnKUDrE/3BanqQxS1kgMYbU4MSkBxNN/E17qvw5qO S4fied9AqZXc5YUpNbuBvOp37nLAzIfoEP+RRpEtRr0nNguV/snrM9BR1RU1n1FHp8I6 Q/kw== X-Gm-Message-State: AFqh2kpmaSFFKQWIJ2muO4lT0OrcLsH/WXPAZ+m9Xet9Dy3T5/KDSOh/ 0G3r2jtTN2dQKo7hljCWFurp0w== X-Received: by 2002:a05:6a20:6f87:b0:b5:46fa:24e8 with SMTP id gv7-20020a056a206f8700b000b546fa24e8mr29390212pzb.38.1673497325247; Wed, 11 Jan 2023 20:22:05 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:22:04 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v10 7/9] dt-bindings: display: bridge: it6505: Add mode-switch support Date: Thu, 12 Jan 2023 12:21:02 +0800 Message-Id: <20230112042104.4107253-8-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789415039879494?= X-GMAIL-MSGID: =?utf-8?q?1754789415039879494?= 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 --- (no changes since v9) Changes in v9: - Fixed subject prefix again - Changed the naming of the example node for it6505 Changes in v8: - Updated bindings for data-lanes property - Fixed subject prefix Changes in v7: - Fixed issues reported by dt_binding_check. - Updated the schema and the example dts for data-lanes. - Changed to generic naming for the example dts node. Changes in v6: - Remove switches node and use endpoints and data-lanes property to describe the connections. .../bindings/display/bridge/ite,it6505.yaml | 93 ++++++++++++++++--- 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml index b16a9d9127dd..94182f131f86 100644 --- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml @@ -77,20 +77,43 @@ properties: unevaluatedProperties: false description: Video port for DP output - properties: - endpoint: + patternProperties: + "^endpoint@[01]$": $ref: /schemas/graph.yaml#/$defs/endpoint-base unevaluatedProperties: false properties: + reg: + maxItems: 1 + + remote-endpoint: true + data-lanes: - minItems: 1 - uniqueItems: true - items: - - enum: [ 0, 1 ] - - const: 1 - - const: 2 - - const: 3 + oneOf: + - items: + - enum: [0, 1, 2, 3] + + - items: + - const: 0 + - const: 1 + + - items: + - const: 2 + - const: 3 + + - items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + mode-switch: + type: boolean + description: Register this node as a Type-C mode switch or not. + + required: + - reg + - remote-endpoint required: - port@0 @@ -102,7 +125,6 @@ required: - pwr18-supply - interrupts - reset-gpios - - extcon - ports additionalProperties: false @@ -139,8 +161,11 @@ examples: }; port@1 { + #address-cells = <1>; + #size-cells = <0>; reg = <1>; - it6505_out: endpoint { + it6505_out: endpoint@0 { + reg = <0>; remote-endpoint = <&dp_in>; data-lanes = <0 1>; }; @@ -148,3 +173,49 @@ examples: }; }; }; + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + dp-bridge@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>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + it6505_dpi_in: endpoint { + remote-endpoint = <&dpi_out>; + }; + }; + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + ite_typec0: endpoint@0 { + reg = <0>; + mode-switch; + data-lanes = <0 1>; + remote-endpoint = <&typec_port0>; + }; + ite_typec1: endpoint@1 { + reg = <1>; + mode-switch; + data-lanes = <2 3>; + remote-endpoint = <&typec_port1>; + }; + }; + }; + }; + }; From patchwork Thu Jan 12 04:21:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3687393wrt; Wed, 11 Jan 2023 20:25:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuUzX4ccvhifBOGCg/sowsvPpPO3lLGIO2J2uJxol5tTd22jIa0NiC1UV2vwPGRzWHkC2J4 X-Received: by 2002:a05:6402:1119:b0:472:46bf:fb3c with SMTP id u25-20020a056402111900b0047246bffb3cmr61920578edv.35.1673497551790; Wed, 11 Jan 2023 20:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497551; cv=none; d=google.com; s=arc-20160816; b=pFlky1R11oYmQce+cBzMVW4+4F/mdcsHQjhE+vNgrSq5B2P6xKMoOImJKfD3BZhvT/ aqEHGz4zP2j7fJwPgHRds8tc/c26FvDgzwe07NA3ObD6tGv5fkMcQuQORr4F8NmBQCuQ vAdHNuh8fnAVPGxGsmXO1bO4/ti1TvyKp4xz9J9eWp5Vl0pmMvCKIlu73pRCj3jT+Xt5 Th6lQPTrpTsn/RFvNDwGQn3RwLW3FgB7YVS30k5IVdDgIlCOKEAAQNjzsX9yOy7CPIBz /jXlLi4h9eYA+ya9pQX7AT3ZPy09mfHLPscwoUCR1SVOgOw+DMhpzWMHlq3ovRlrjXRD se2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=08tc41QAkvFbPfqG9xFaXxlEL+CygmRv6gbW1qKfyT0=; b=mSLqgMybVlcZCTI6wrqZNPOYGkZtN2cTvIwdryL8KZRbXLxv3ygmfvY0Yy21fQf3Nd NpCaxZCwsEt+kWkOTV3I/Vc54xCN5UnFiepZXzR7K/HV40Cqurt80186hOtH0vuzXKbV 0vtkomMLv0zJ06f+bB17H6O8f62THXT76uKiQ6h4VJxkl0bGrQn1PwbZhXVZAyuDLvvW FzGLlYPxoXakA2SlkYCf530J+IKyObLmVeF/UEEZMnwZdtPPTJ0eASu9KU/n36j8DB+R DPTSXYSgqlN8MCHxdGxLxjwv+xFFpHCkJi2+Hwgu/h1lLL7peCOXcurwsmEMldRSqW6C 0kig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B5rTvu21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a50fa85000000b0049243a3d258si15467945edr.389.2023.01.11.20.25.28; Wed, 11 Jan 2023 20:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B5rTvu21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239561AbjALEX3 (ORCPT + 99 others); Wed, 11 Jan 2023 23:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbjALEWO (ORCPT ); Wed, 11 Jan 2023 23:22:14 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2BFF49146 for ; Wed, 11 Jan 2023 20:22:12 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id v3so11971670pgh.4 for ; Wed, 11 Jan 2023 20:22:12 -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=08tc41QAkvFbPfqG9xFaXxlEL+CygmRv6gbW1qKfyT0=; b=B5rTvu21cB1Pvztm8jHvC80rb1+BLt39TQzgQuAiwLFONfkM0ra6deRHzxhaRehscV q8pfteWSIIfiqIsRaEUI/7FuMhjNZzIwC9hAyEuO0YNO0NKuDHn4sJZgF/nHP9Kgvlqv 9nHCV5KdxevdTllYWjnCYu8586wYWfMkDf8lE= 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=08tc41QAkvFbPfqG9xFaXxlEL+CygmRv6gbW1qKfyT0=; b=zf6TCkchhlRIWIlapZt3lN08YqnWDgV57aatNNAd40ov/5cNz9tssqgmWW+k12yACB ByQNi5cbHzvtAUpDVLFtCcwupxMSSg8zdeFzJZZBAIWeRnszeu//GGWtk6fWT3Y1BuJC 7QX2FZ8KK12Zti1+4VVc1QjE/PeprSqINfIkEbtbnpniXJPdf1Ove1RIkRu03eZj0tvN u6zaAfXzfCIsTL/bD5kyfcw574BRQvutifRo8S49+348OT0rNPLYkWsg+YkH0YaVwbNt p7eurAnhtSLCaY7PFVmn/TxBoucb+a0DA8NnoO2LgeVYS90ErYUnB+ImNLGYxTViPLTQ FfsA== X-Gm-Message-State: AFqh2kqhT/+59cKXO33IRgyQovjD3LXte3d0UM5Y2vPAb08MzC6P/B1D +qBR+VDY7aeEVar9t26gvmuwGg== X-Received: by 2002:a62:870f:0:b0:582:bb80:58d7 with SMTP id i15-20020a62870f000000b00582bb8058d7mr4747262pfe.26.1673497332331; Wed, 11 Jan 2023 20:22:12 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:22:12 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v10 8/9] drm/bridge: it6505: Fix Kconfig indentation Date: Thu, 12 Jan 2023 12:21:03 +0800 Message-Id: <20230112042104.4107253-9-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789368904634759?= X-GMAIL-MSGID: =?utf-8?q?1754789368904634759?= Replace the spaces with tab characters in the Kconfig file. Signed-off-by: Pin-yen Lin Reviewed-by: AngeloGioacchino Del Regno --- Changes in v10: - Collected Reviewed-by tag Changes in v7: - New in v7 drivers/gpu/drm/bridge/Kconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 57946d80b02d..737578dd57ed 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -85,19 +85,19 @@ config DRM_FSL_LDB Support for i.MX8MP DPI-to-LVDS on-SoC encoder. config DRM_ITE_IT6505 - tristate "ITE IT6505 DisplayPort bridge" - depends on OF + tristate "ITE IT6505 DisplayPort bridge" + depends on OF select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER select DRM_DISPLAY_HELPER - select DRM_DP_AUX_BUS - select DRM_KMS_HELPER - select DRM_DP_HELPER - select EXTCON - select CRYPTO - select CRYPTO_HASH - help - ITE IT6505 DisplayPort bridge chip driver. + select DRM_DP_AUX_BUS + select DRM_KMS_HELPER + select DRM_DP_HELPER + select EXTCON + select CRYPTO + select CRYPTO_HASH + help + ITE IT6505 DisplayPort bridge chip driver. config DRM_LONTIUM_LT8912B tristate "Lontium LT8912B DSI/HDMI bridge" From patchwork Thu Jan 12 04:21:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 42248 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3687201wrt; Wed, 11 Jan 2023 20:25:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUYT1IB2+0QUTJ1bKju2WZO15/50iJwGm4JshX26H55Cf8CSTmQjN01Qq0Av+iKpRlzPK8 X-Received: by 2002:a17:906:2857:b0:7c1:8f53:83a0 with SMTP id s23-20020a170906285700b007c18f5383a0mr58969353ejc.13.1673497509587; Wed, 11 Jan 2023 20:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673497509; cv=none; d=google.com; s=arc-20160816; b=yiOmn+IkMtsLaS2/rqI6IO/cQjf2SKdnTvkwiUuAaG4NDClpL2R6gkC3FkxCnVLRPx pJJXpEFKEi/kHvSptAElSFTy/0aDm7FpbCWFdtz5ZyrsnbVjKDGzJofmXkoX6x5PWONn MNcWNEET7Q+Yinye7PsUSkcPnpKVxsiZddQAdVZlYdqFAr3H94tmUW1mft0JhMtsz646 XNwYNiDXO1t/nJkfjroMlowUhoo2VSpd6a1NUsTPlK77LKYSw5gx1dslCiceV7rzdONL QpjzUsBqUDPBv2Lfy6qF9KznV+DynYU3Ba5h23TDn/e0bJZzZPqzn1dIe0Z9SzSzdIVz +WDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9iAqigrmRtbOwkIjEJ3yqHcs8IpEn5bVcl0Fnp8oBxA=; b=oV2axhcqmylszowmVLWD6dmBQH1XGZiLjQmZK4ZyeDdLrm7vfk65dNcPQ3ZjLuGtXT pnSCRQNmwYNYT6G5MM+A/d7gBCBehj7A0D45tEIAF1rK1kBOXHmY2T/O0+VkZ4Bi0Pwj XRYLjo8I5rmbckDN2Pb+uv3yLO9V4cJkPPGh+NgJWklNkJxAl86tEh/fwQA6GS37Niem qDhU2+EsJcUCeaQVYrTNom6gtzynJr3CSdc1I05+p4Nr8k5cMtxVAhWn68jXIew/uRUk 1ELik5jNkh2lE4jqcGaLA3sgV91w3avUt/yTrx5QB1OBdyiaVZcJDK9GuYQiXEJvwxLC 4OGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oCt2kLHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw9-20020a1709066a0900b007c0969e429bsi18156876ejc.30.2023.01.11.20.24.46; Wed, 11 Jan 2023 20:25:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oCt2kLHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236784AbjALEYR (ORCPT + 99 others); Wed, 11 Jan 2023 23:24:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbjALEWU (ORCPT ); Wed, 11 Jan 2023 23:22:20 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97232DE7 for ; Wed, 11 Jan 2023 20:22:19 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id c85so9663485pfc.8 for ; Wed, 11 Jan 2023 20:22:19 -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=9iAqigrmRtbOwkIjEJ3yqHcs8IpEn5bVcl0Fnp8oBxA=; b=oCt2kLHUrC3byb2ZSFIKQjzWF6Uv4lPlenracng9ajltBCxyr/RyL7J6tI5EwIh5ql 8HUYtle8KLAEKJukvxWtusEIWx005J1CXhooZnWPzwaZH0UZuV7jdqSCp2mE0nJAZB2A mni6DdKZXeLvmj32wxdbeDVx2/bgeBtzjI7aI= 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=9iAqigrmRtbOwkIjEJ3yqHcs8IpEn5bVcl0Fnp8oBxA=; b=A5tETjSJZ/HW8PEowILcbOeHbLgDWl6HkvLIOKOc5zm8MDDQxrxpwP0NItV0KIzaqq /LOzo24MVQxHbca1AxMnCu5+Ncz6tdDWgNeaAHJrGo884Flj7U2hWmZatlOij8RnxWZH MGaafqOJFNDIYpuoh3PlutpT5gVEkvk5vA1fOwSX9r8Ao/grPD2vfMvNvTiVKfNYQb8s iofs7WkIuBOHYCPXSL1gTPEiDNi0ZX+DLRIhwtHk1jL93lbcYUIc/FTXqmW/3fki7FZM Dz9tP0orDl6dm/Swu0+jej+9PMPULlAIJIcNRnP560X5njwMmFBj0MU+FdYbAPI/YZU3 I4wQ== X-Gm-Message-State: AFqh2krqpGULugEpFOSf7H9vc3j9ft5w6CUzIhQZlCmxoIEBJwHqm0gM XEuwclczkWE8tTNptea8u8zGBQ== X-Received: by 2002:a62:e90e:0:b0:577:1c59:a96c with SMTP id j14-20020a62e90e000000b005771c59a96cmr73516887pfh.2.1673497339229; Wed, 11 Jan 2023 20:22:19 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:594f:5484:7591:d074]) by smtp.gmail.com with ESMTPSA id s8-20020aa78bc8000000b00582579cb0e0sm5519478pfd.129.2023.01.11.20.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 20:22:19 -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: Stephen Boyd , Pin-yen Lin , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Marek Vasut , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Lyude Paul , chrome-platform@lists.linux.dev, Xin Ji , Thomas Zimmermann , linux-kernel@vger.kernel.org, Allen Chen , linux-acpi@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v10 9/9] drm/bridge: it6505: Register Type C mode switches Date: Thu, 12 Jan 2023 12:21:04 +0800 Message-Id: <20230112042104.4107253-10-treapking@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112042104.4107253-1-treapking@chromium.org> References: <20230112042104.4107253-1-treapking@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754789324613727878?= X-GMAIL-MSGID: =?utf-8?q?1754789324613727878?= 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 Tested-by: Chen-Yu Tsai --- (no changes since v7) Changes in v7: - Fixed style issues in it6505 driver - Removed the redundant sleep in it6505 driver - Removed DT property validation in it6505 driver - Rebased to drm-misc-next - Extracted common codes to another commit 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 | 119 +++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 737578dd57ed..33803f581562 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=n 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/ite-it6505.c index 9cda2df21b88..d9be09e889e2 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 #include @@ -28,6 +30,7 @@ #include #include #include +#include #include #include @@ -455,6 +458,7 @@ struct it6505 { struct delayed_work delayed_audio; struct it6505_audio_data audio; struct dentry *debugfs; + struct drm_dp_typec_switch_desc switch_desc; /* it6505 driver hold option */ bool enable_drv_hold; @@ -3346,12 +3350,105 @@ static void it6505_shutdown(struct i2c_client *client) it6505_lane_off(it6505); } +static void it6505_typec_ports_update(struct it6505 *it6505) +{ + struct drm_dp_typec_switch_desc switch_desc = it6505->switch_desc; + + /* Check if both ports available and do nothing to retain the current one */ + if (switch_desc.typec_ports[0].dp_connected && switch_desc.typec_ports[1].dp_connected) + return; + + if (switch_desc.typec_ports[0].dp_connected) + it6505->lane_swap = false; + else if (switch_desc.typec_ports[1].dp_connected) + it6505->lane_swap = true; +} + +static int it6505_typec_mux_set(struct typec_mux_dev *mux, + struct typec_mux_state *state) +{ + struct drm_dp_typec_port_data *port_data = typec_mux_get_drvdata(mux); + struct it6505 *it6505 = (struct it6505 *) port_data->data; + struct device *dev = &it6505->client->dev; + struct drm_dp_typec_switch_desc switch_desc = it6505->switch_desc; + bool old_dp_connected, new_dp_connected; + + if (switch_desc.num_typec_switches == 1) + return 0; + + mutex_lock(&it6505->extcon_lock); + + old_dp_connected = switch_desc.typec_ports[0].dp_connected || + switch_desc.typec_ports[1].dp_connected; + + port_data->dp_connected = state->alt && + state->alt->svid == USB_TYPEC_DP_SID && + state->alt->mode == USB_TYPEC_DP_MODE; + + dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", + switch_desc.typec_ports[0].dp_connected, switch_desc.typec_ports[1].dp_connected); + + new_dp_connected = switch_desc.typec_ports[0].dp_connected || + switch_desc.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 = pm_runtime_get_sync(dev); + + /* + * pm_runtime_force_suspend() disables runtime PM when the + * system enters suspend state. But on system resume, mux_set + * can be triggered before pm_runtime_force_resume() re-enables + * runtime PM. This makes the bridge stay powered off if the + * downstream display is connected when the system is suspended. + * Handling the error here to make sure the bridge is powered + * on, and leave the PM runtime usage count incremented so + * the future runtime PM calls is balanced. + */ + 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 void it6505_unregister_typec_switches(struct it6505 *it6505) +{ + drm_dp_unregister_typec_switches(&it6505->switch_desc); +} + +static int it6505_register_typec_switches(struct device *dev, struct it6505 *it6505) +{ + struct device_node *port = of_graph_get_port_by_id(dev->of_node, 1); + + return drm_dp_register_typec_switches(dev, port, &it6505->switch_desc, + it6505, it6505_typec_mux_set); +} + static int it6505_i2c_probe(struct i2c_client *client) { 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) @@ -3371,11 +3468,24 @@ 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\n", + PTR_ERR(extcon)); + it6505->extcon = NULL; + } else { + it6505->extcon = extcon; } - it6505->extcon = extcon; + ret = it6505_register_typec_switches(dev, it6505); + if (ret) { + if (ret != -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; + } + } it6505->regmap = devm_regmap_init_i2c(client, &it6505_regmap_config); if (IS_ERR(it6505->regmap)) { @@ -3447,6 +3557,7 @@ static void it6505_i2c_remove(struct i2c_client *client) it6505_debugfs_remove(it6505); it6505_poweroff(it6505); it6505_remove_edid(it6505); + it6505_unregister_typec_switches(it6505); } static const struct i2c_device_id it6505_id[] = {