From patchwork Sat Feb 4 13:30:32 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: 650690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A1EFC636CC for ; Sat, 4 Feb 2023 13:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233625AbjBDNbC (ORCPT ); Sat, 4 Feb 2023 08:31:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbjBDNbA (ORCPT ); Sat, 4 Feb 2023 08:31:00 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3100367E3 for ; Sat, 4 Feb 2023 05:30:57 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id 203so5552049pfx.6 for ; Sat, 04 Feb 2023 05:30:57 -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=R9iPc9yhVkUofB90tWrcvmiWB1xZN7L6aBmsKjdgh6c=; b=MmH3x/xM62zRTISXSedEvzRlaMSI+F8Qma5UmquaxSwlvv6YsPZ+8h1xP3F7M3D1Df QCXfWhoJOdvLdzh0hNXPqpam40tk12C8NpO5zRmImK/NmNXbcxJ9dSbO/w8oKgfe20ZG QRCqSAG2eCerNb0ZmsoC546f3eCSx0931M3tA= 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=R9iPc9yhVkUofB90tWrcvmiWB1xZN7L6aBmsKjdgh6c=; b=UXx37AVIPncB3CooCYixh1Pp25dZZtpeAoe+fB0OmmcTaEWF8kIDvOYjkOKVucgGW7 5d6kfGbnpXDdYKtR0yp3iFElz/yJ1tNm36eChTUp7aEIupOsAc6K78OXxnS+ekXisn8Y aXYKN45rNfQFCTuHcITPHixlHhLLjF+AXJV5Bbnc3U6P6YS5ndSz429lxH2m0m+dg36u irH6y6JOseGbvPAK2VNxfjOBO+M0NYMOJm6QIbeK5+x2MFmJSe2UOUYqyBFNTsAm0Bw9 KyX7Q9z+sB1eBydErjs/48jBc2TpESak+FzGNSWNKMjf3Keaen75s74ZeWEnrzIJcwlt gJ3Q== X-Gm-Message-State: AO0yUKVoPBHN7x07cS5XmxFiUdWpHH8coIgwFgkTkVGWiuD/ceJmR+9O /ZW+SEwkw7Cq++fgEVm19qz7Rw== X-Google-Smtp-Source: AK7set+L0bc/md7jnlp6ucsfNCGE/z+ghrSK5N+MS4DGPqmGcMvtPY/U7zbRRON1T5JI3CoL3plPaA== X-Received: by 2002:a05:6a00:882:b0:593:96a2:d60a with SMTP id q2-20020a056a00088200b0059396a2d60amr18474657pfj.30.1675517456766; Sat, 04 Feb 2023 05:30:56 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:30:56 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Chen-Yu Tsai Subject: [PATCH v11 1/9] device property: Add remote endpoint to devcon matcher Date: Sat, 4 Feb 2023 21:30:32 +0800 Message-Id: <20230204133040.1236799-2-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- Changes in v11: - Added missing fwnode_handle_put in drivers/base/property.c Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v6: - New in v6 drivers/base/property.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 2a5a37fcd998..e6f915b72eb7 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1223,6 +1223,22 @@ 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++; + } + } + fwnode_handle_put(node); + node = fwnode_graph_get_remote_port_parent(ep); if (!fwnode_device_is_available(node)) { fwnode_handle_put(node); From patchwork Sat Feb 4 13:30:33 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: 651004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECEB0C636CC for ; Sat, 4 Feb 2023 13:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233642AbjBDNbM (ORCPT ); Sat, 4 Feb 2023 08:31:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjBDNbG (ORCPT ); Sat, 4 Feb 2023 08:31:06 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB473647D for ; Sat, 4 Feb 2023 05:31:03 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id 7so5438483pga.1 for ; Sat, 04 Feb 2023 05:31:03 -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=bzf2jVYplA8aE3AG7mF8tjqc7YfVHNzTvjn8QCL8QQE=; b=XOar4LHD9c/G8nWjPa8i0IQvwhxfLXWogWDL1nY00qKfe23sg9JlyEHPfwz+CEeo92 GLaqvjPSWVv4K2TTudUs5ZF5iSuQ0FJ7X/5Y4WWrX/XZH9PLpGL6A0gvh8MEtDhfwc+K TCRFMMiqfzJygsnq2ww+OpoMZmv0Skk8blvjc= 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=bzf2jVYplA8aE3AG7mF8tjqc7YfVHNzTvjn8QCL8QQE=; b=dkByCdn4DHf8oNYiRFuXU8eSimtM8qh/i64waH3CxDYFblMqgkYv/+RnIYM+a9bUQB 6tLyfOeytruIxPt9pQjfkXptEE5sJ40jEvPFN7K+gjF9HyYLdbtv2Vl7qTtFVpajPuy7 KtyQhKHGvvjJmuRprJb7N3uwkBCzuyourvuoacS9H+E37wtN/p/OPL8N8OP4Tdia4FRt vVyr/rxuY1Ik3imScigzmA/gFnZ0km+cqEVl0m+6Rz101Uo78QzeknBkkhew2ak3KImi kzzYCq0QxvPZ1ToPPZYMbHg862wROud5FWVUyh9v2Sbiuetj2k2VV0fxuKT5JhFTpH67 uieg== X-Gm-Message-State: AO0yUKWr51DnCOLodxP4F2UdYrZNd9L+KSZd0QxN1hyk8yFmJReAOZiy CwDLFqMtA5BJ1LhN1E+JKt/VGg== X-Google-Smtp-Source: AK7set+1X6kXak01XGkVjrrceHshEa07YHswioqgR/Q4wKgCqR/quO47+t9nfD5gFl2gV4MQIY5S/g== X-Received: by 2002:aa7:80c6:0:b0:592:de72:4750 with SMTP id a6-20020aa780c6000000b00592de724750mr11680416pfn.23.1675517462757; Sat, 04 Feb 2023 05:31:02 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31:02 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Chen-Yu Tsai Subject: [PATCH v11 2/9] platform/chrome: cros_ec_typec: Purge blocking switch devlinks Date: Sat, 4 Feb 2023 21:30:33 +0800 Message-Id: <20230204133040.1236799-3-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 v11: - Collected Acked-by tag 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 Sat Feb 4 13:30:34 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: 650689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52058C636CD for ; Sat, 4 Feb 2023 13:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233718AbjBDNbW (ORCPT ); Sat, 4 Feb 2023 08:31:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbjBDNbP (ORCPT ); Sat, 4 Feb 2023 08:31:15 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510EF367FB for ; Sat, 4 Feb 2023 05:31:10 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id g9so5538737pfo.5 for ; Sat, 04 Feb 2023 05:31:10 -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=FDdE5NdckiHy7s3iR+29eACsJFzbSzvAEe6P9LTse94=; b=Hz0kyWgw+U+yiGOtooHjui9iU0tOd7FbPKhO3OLwtdfR05IN2otq+XuXU1Gxv/03rX Qc2lJpfUfuUzZHCPorxB/cAMMSmW5XrenDlrdhF7VZp0pbNj2a408FfH50BC4pXCFEfi Ef8CASHmgb7KUHf1sVK2C7PwWfUDf79sFjVYk= 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=FDdE5NdckiHy7s3iR+29eACsJFzbSzvAEe6P9LTse94=; b=HkS2uSA72iNIp1y9UqSqvJNViMayiEAQ0ycTh74rLtyTPQJEww921dt/0r7emTvwC4 zehDJHveNQiGQguPUwL1KUOXMLvH7/R1pjviB0Acp8aStbwIg2yDxDzdW81OVxiRsilq rfGmBo4O+QZ522qLGN9j67h/DGnLoLFR5ZJaeFRJrdJ02ARKKJAxEaTtyeV8qx5DdNW5 Oohmtw3Zca4mcuQ97BPpsykYGOqDNN9BOod0evfaAEpSs/k3bIGMYqpd/11lRyiSCexo nYtIcT/NTpMRP5c9RcwRdA2qHTTHxePgXN2Z2hRTzKD9upCmwsVui5IDUVm1iGj9bxeZ nRmw== X-Gm-Message-State: AO0yUKUKz6CQu7wu1+SKAjKxqZnldt0Kx59hst1bdS4jucg4uEt9EcNk h37iilflkSHhKvjZBIpJ4tfXig== X-Google-Smtp-Source: AK7set/ST5MLArUDet2tLQK9J0+VohaIXzVsS4E6jCWdVpVRrJ7e/uh76fYN2/hcEpb0onEGLzDJcA== X-Received: by 2002:a62:388e:0:b0:590:6a57:9901 with SMTP id f136-20020a62388e000000b005906a579901mr11048988pfa.18.1675517469476; Sat, 04 Feb 2023 05:31:09 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31:09 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Alex Deucher , Andi Shyti , Douglas Anderson , "Gustavo A. R. Silva" , Imre Deak , Jani Nikula , Kees Cook , Thierry Reding Subject: [PATCH v11 3/9] drm/display: Add Type-C switch helpers Date: Sat, 4 Feb 2023 21:30:34 +0800 Message-Id: <20230204133040.1236799-4-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 "reg" properties are available in Device Tree. Signed-off-by: Pin-yen Lin --- Changes in v11: - Use fwnode helpers instead of DT - Moved the helpers to a new file - Use "reg" instead of "data-lanes" to determine the port number - Dropped collected tags due to new changes 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/Makefile | 1 + drivers/gpu/drm/display/drm_dp_typec_helper.c | 114 ++++++++++++++++++ include/drm/display/drm_dp_helper.h | 31 +++++ 3 files changed, 146 insertions(+) create mode 100644 drivers/gpu/drm/display/drm_dp_typec_helper.c diff --git a/drivers/gpu/drm/display/Makefile b/drivers/gpu/drm/display/Makefile index 17ac4a1006a8..ef80b9fde615 100644 --- a/drivers/gpu/drm/display/Makefile +++ b/drivers/gpu/drm/display/Makefile @@ -14,5 +14,6 @@ drm_display_helper-$(CONFIG_DRM_DISPLAY_HDMI_HELPER) += \ drm_scdc_helper.o drm_display_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o drm_display_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o +drm_display_helper-$(CONFIG_TYPEC) += drm_dp_typec_helper.o obj-$(CONFIG_DRM_DISPLAY_HELPER) += drm_display_helper.o diff --git a/drivers/gpu/drm/display/drm_dp_typec_helper.c b/drivers/gpu/drm/display/drm_dp_typec_helper.c new file mode 100644 index 000000000000..b11a268da57f --- /dev/null +++ b/drivers/gpu/drm/display/drm_dp_typec_helper.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +static int drm_dp_register_mode_switch(struct device *dev, + struct fwnode_handle *fwnode, + 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 port_num; + int ret; + + ret = fwnode_property_read_u32(fwnode, "reg", &port_num); + if (ret) { + dev_err(dev, "Failed to read reg property: %d\n", ret); + return ret; + } + + port_data = &switch_desc->typec_ports[port_num]; + port_data->data = data; + port_data->port_num = port_num; + port_data->fwnode = fwnode; + mux_desc.fwnode = fwnode; + mux_desc.drvdata = port_data; + snprintf(name, sizeof(name), "%pfwP-%u", fwnode, 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. + * The port number is determined by the "reg" property of the endpoint. + */ +int drm_dp_register_typec_switches(struct device *dev, struct fwnode_handle *port, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set) +{ + struct fwnode_handle *sw; + int ret; + + fwnode_for_each_child_node(port, sw) { + if (fwnode_property_present(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. */ + fwnode_for_each_child_node(port, sw) { + if (!fwnode_property_present(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: + fwnode_handle_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); diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h index ab55453f2d2c..d9213739de72 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,34 @@ 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; + int port_num; + struct fwnode_handle *fwnode; + void *data; +}; + +struct drm_dp_typec_switch_desc { + int num_typec_switches; + struct drm_dp_typec_port_data *typec_ports; +}; + +#ifdef CONFIG_TYPEC +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc); +int drm_dp_register_typec_switches(struct device *dev, struct fwnode_handle *port, + struct drm_dp_typec_switch_desc *switch_desc, + void *data, typec_mux_set_fn_t mux_set); +#else +static inline void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc) +{ +} +static inline int drm_dp_register_typec_switches( + struct device *dev, struct fwnode_handle *port, + struct drm_dp_typec_switch_desc *switch_desc, void *data, + typec_mux_set_fn_t mux_set) +{ + return -EOPNOTSUPP; +} +#endif + #endif /* _DRM_DP_HELPER_H_ */ From patchwork Sat Feb 4 13:30:35 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: 651003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B8DDC636CC for ; Sat, 4 Feb 2023 13:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbjBDNb2 (ORCPT ); Sat, 4 Feb 2023 08:31:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233710AbjBDNbX (ORCPT ); Sat, 4 Feb 2023 08:31:23 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00597367C1 for ; Sat, 4 Feb 2023 05:31:16 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id m13so7856028plx.13 for ; Sat, 04 Feb 2023 05:31:16 -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=VFozqAO7y27WSMX10PmbGe+zEkg2ZSj3A7g8bFlTPI8=; b=ExdVtGh0PEiFMJQdufiU2ArXz+vVi3h660myAJbH5fks21pEn6zhkHbndMIyQFmdmq t/+PHLvjgEtjKq5UGf/PVDxBu8UoufdrjcZqy75MGNxhz/D5ZX7VtSZPIHFSvmH8OeGW aX8Tpz769on+ITPQx70eVu/fJifPknu2Xevsc= 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=VFozqAO7y27WSMX10PmbGe+zEkg2ZSj3A7g8bFlTPI8=; b=WKQZShJzEwjLluk2BBOFxIR0/+qn7EBlecnHh9HiCMZCBTt+Sxgm3Aovw096nKZzWk BxZMizynFOPJggEU8otZ1LX8hrLxG2RCJe6aLf+UTamhhSmm1yT9Tat1Q/ukDUbneABN HxPunfNGP3FYQwuvFDG3Fl1ziBO7FoMv1pEpvSkRXwsVGCxajqeXOaBelomC4k0BCkrX ubaG8SzwtZK6mQfJGrkdZecyVXCy0wStO3jg4HEZFtbpbaeiA4O8Ay/if7qtXHinQT1P OJ1d3/pFbv8myc9KjqtcEOuORVfRiEalceN9psSvyrszSsUegFacXXjSyQHPldotgbAn aKAg== X-Gm-Message-State: AO0yUKXbdo/jl4rQpCvOjX+G219ilRQfY23ZJ/JZ6knIDI6jj2Tx/A1E WLHn7DLGK/7VwQfFXgKrCVIUmw== X-Google-Smtp-Source: AK7set/0n8hhvNLDqUKkrSrNnJW5rpDyeILGha8mXk7j+a74GBfLqGVKg5L1RhKLIwKyhZ/pxG4/ZA== X-Received: by 2002:a05:6a20:9589:b0:bf:7ae0:5f97 with SMTP id iu9-20020a056a20958900b000bf7ae05f97mr11329759pzb.21.1675517476426; Sat, 04 Feb 2023 05:31:16 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31:16 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Krzysztof Kozlowski , Chen-Yu Tsai Subject: [PATCH v11 4/9] dt-bindings: display: bridge: anx7625: Add mode-switch support Date: Sat, 4 Feb 2023 21:30:35 +0800 Message-Id: <20230204133040.1236799-5-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 v11: - Updated the description of the endpoints - Referenced video-interfaces.yaml instead for the endpoints 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 | 94 ++++++++++++++++++- 1 file changed, 91 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..f287e8e0602f 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,9 +113,46 @@ 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. + Video port for panel or connector. Each endpoint connects to a video + output downstream, and the "data-lanes" property is used to describe + the pin connections. 0, 1, 2, 3 in "data-lanes" maps to SSRX1, SSTX1, + SSRX2, SSTX2, respectively. + + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/media/video-interfaces.yaml# + properties: + reg: true + + 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: + - remote-endpoint required: - port@0 @@ -186,3 +224,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 Sat Feb 4 13:30:36 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: 650688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 531B9C61DA4 for ; Sat, 4 Feb 2023 13:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbjBDNcH (ORCPT ); Sat, 4 Feb 2023 08:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233761AbjBDNb5 (ORCPT ); Sat, 4 Feb 2023 08:31:57 -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 80C3D37F22 for ; Sat, 4 Feb 2023 05:31:23 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id t17so5570972pfj.0 for ; Sat, 04 Feb 2023 05:31:23 -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=F/UCw5L3OryAN31Ax/yQTRwKEsI+8ZNGFWTdAJWTPHk=; b=acq2I2gv0MOoVf8w+0Oe1TN4/8R+sumEPcQ6iYP0qcCf2/4jbAOPJlGybmhXsWIbVE IvEU8qRF9vPM0ob7Fg88nYCmq6KHNzgrEyEH1wuVtutC5AngwNb+ymGmjhIX2fap3KsZ 30s6vnrQCWEliiYbOXFcyKkAK2LJMWrd2XjZA= 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=F/UCw5L3OryAN31Ax/yQTRwKEsI+8ZNGFWTdAJWTPHk=; b=jR3BomfY+1YLaro5VXlcNUjyRBxYfMLHYPxZXm3zHa0Y4t+mSrHRmPA+43ePmdR0x8 GjA9bpS7e96//VIcV4b08aqaAgRQQm+vpenDHeldzvPhh0jnOvYMY2VLDJva2vp0b2HZ JgHyyfLWjlqmQLYwMSUXvzj5JhmyqS4WAv8hmcOuS0oiypHqE32TLu/7xeAj3wLnQ/zX FYhPWauil2zG3rdb6VDVk/2YTMddZh4AJyhYB+5zCRCe1hY+IeFrSlMdllJQuXYLC2fM Ao+7ZKglv1qRGWWvMXzxHDxfaklZ4GX4eHQSdj/TanHIeESMpaAyh6f4Kup/FF7N4czv Z2ug== X-Gm-Message-State: AO0yUKWF2848d6cDLKN3BHy0fCnjjIzz/UzvQdKTwBsP02S4nW41Vmxp SrmeM8N7ovbSPYHuLZ2ayJBNBQ== X-Google-Smtp-Source: AK7set/kZtf8evW6ntULSPU2ZzT8kpFpt4gOXTjkd4Huews3RL5fh5Duq9H7uxMx2P9UV0B67sTGQg== X-Received: by 2002:aa7:8b1a:0:b0:58d:e33b:d565 with SMTP id f26-20020aa78b1a000000b0058de33bd565mr11193220pfd.5.1675517482695; Sat, 04 Feb 2023 05:31:22 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31:22 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Chen-Yu Tsai , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Subject: [PATCH v11 5/9] drm/bridge: anx7625: Check for Type-C during panel registration Date: Sat, 4 Feb 2023 21:30:36 +0800 Message-Id: <20230204133040.1236799-6-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- (no changes since v10) 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 Sat Feb 4 13:30:37 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: 651002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50CCC636CC for ; Sat, 4 Feb 2023 13:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233832AbjBDNcU (ORCPT ); Sat, 4 Feb 2023 08:32:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233782AbjBDNcA (ORCPT ); Sat, 4 Feb 2023 08:32:00 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84AF38B74 for ; Sat, 4 Feb 2023 05:31:29 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id r18so5398414pgr.12 for ; Sat, 04 Feb 2023 05:31:29 -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=+t1a8TZ24B1bOox1g7CR3AHOSy2O5Tdl47HMvPXNMoc=; b=AX5VuMt2gKTsR/ZQYnH6ufYmBtmVXM4rMhsKS9GZqccMVuxu+vlOqL2ihz58hhHSL0 grt6Tv569m79aMBdhJ3lUvAXXYRXIAynhHw6KdDi2rrR37QciT6oLqEIK1kpO5uUAwcd HVaEJ7M65cpr1sBx256DQJduJTRs4PF4itm+A= 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=+t1a8TZ24B1bOox1g7CR3AHOSy2O5Tdl47HMvPXNMoc=; b=MF8PvmfCFx3BJ/Q1oORVDsGDXmv0f2I5+J95rWQZ96u7d5K/0L07+6srBP5iD7HOld tnQNvRFA0o0v7uY6qDeGu+3bprkm5faLtcSLW52xIdZPnbXdPpn8ddN1/F4JcR/z5NEK 8A6bc5Kp8tH2oCCeRAmHs3e3d015kUKB0qxwRu4bh9iwrBS2GBq/hrFF1cWztgRWNuyy VK8bEj5Gz2WXiEoj+pudQGBmI7CZ3ZUX40ipyo/GKvz8zcIn6sTGHoEQtnSvtNtcONs9 g1yyl20MhsK03zG+wnHBdhhoz3lS6bx+8f6Ohs0wulSCcfD9M9CLErS8YpgDY/NOp4Ur cAhA== X-Gm-Message-State: AO0yUKX57CQl4Zhgr5Pu1Wi2tsDrfLQK9/unJSUgz7nDyW+X7RK1oKKw f2xTrcygElcPKUO/O4FeQZBcgA== X-Google-Smtp-Source: AK7set/mOMTOPhVIvHsmqBZeZh2BdY/pt5gdmQn+8SeCf9TdTDm+VAxAEgu9qCLqETHMIZHJGQz25A== X-Received: by 2002:aa7:96f6:0:b0:592:4d85:ecb1 with SMTP id i22-20020aa796f6000000b005924d85ecb1mr12985974pfq.33.1675517489073; Sat, 04 Feb 2023 05:31:29 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31:28 -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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Subject: [PATCH v11 6/9] drm/bridge: anx7625: Register Type C mode switches Date: Sat, 4 Feb 2023 21:30:37 +0800 Message-Id: <20230204133040.1236799-7-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- Changes in v11: - Added back "data-lanes" parsing logics - Removed Kconfig dependency - Updated the usage of the private data - Dropped Tested-by tag because of the new changes 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/anx7625.c | 149 ++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 20 +++ 2 files changed, 169 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 1cf242130b91..7bcffc2987a7 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,146 @@ 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) +{ + int i; + /* Check if both ports available and do nothing to retain the current one */ + if (ctx->port_data[0].dp_connected && ctx->port_data[1].dp_connected) + return; + + for (i = 0; i < 2; i++) { + if (ctx->port_data[i].dp_connected) + anx7625_set_crosspoint_switch( + ctx, ctx->port_data[i].orientation); + } +} + +static int anx7625_typec_mux_set(struct typec_mux_dev *mux, + struct typec_mux_state *state) +{ + struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux); + struct anx7625_data *ctx = (struct anx7625_data *) port->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; + + wait_for_completion(&ctx->mux_register); + + old_dp_connected = ctx->port_data[0].dp_connected || + ctx->port_data[1].dp_connected; + + ctx->port_data[port->port_num].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", + ctx->port_data[0].dp_connected, ctx->port_data[1].dp_connected); + + new_dp_connected = ctx->port_data[0].dp_connected || + ctx->port_data[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_node = of_graph_get_port_by_id(dev->of_node, 1); + struct drm_dp_typec_switch_desc *switch_desc = &ctx->switch_desc; + int ret; + u32 dp_lanes[4]; + unsigned int i, num_lanes; + + /* + * Currently, only mode switch is implemented. + * TODO: Implement Type-C orientation switch for anx7625. + */ + ret = drm_dp_register_typec_switches(dev, &port_node->fwnode, + &ctx->switch_desc, ctx, + anx7625_typec_mux_set); + if (ret) + return ret; + + ctx->port_data = devm_kcalloc( + dev, switch_desc->num_typec_switches, + sizeof(struct anx7625_typec_port_data), GFP_KERNEL); + + if (!ctx->port_data) { + ret = -ENOMEM; + goto unregister_mux; + } + + for (i = 0; i < switch_desc->num_typec_switches; i++) { + struct drm_dp_typec_port_data *port = &switch_desc->typec_ports[i]; + struct fwnode_handle *fwnode = port->fwnode; + + num_lanes = fwnode_property_read_u32_array(fwnode, "data-lanes", + NULL, 0); + + if (num_lanes <= 0 || num_lanes > 2) { + dev_err(dev, + "Error on getting data lanes count from %pfwP: %d\n", + fwnode, num_lanes); + ret = num_lanes; + goto unregister_mux; + } + + ret = fwnode_property_read_u32_array(fwnode, "data-lanes", + dp_lanes, num_lanes); + if (ret) { + dev_err(dev, + "Failed to read the data-lanes variable: %d\n", + ret); + goto unregister_mux; + } + + ctx->port_data[i].orientation = (dp_lanes[0] / 2 == 0) ? + TYPEC_ORIENTATION_NORMAL : TYPEC_ORIENTATION_REVERSE; + ctx->port_data[i].dp_connected = false; + } + complete_all(&ctx->mux_register); + + return 0; + +unregister_mux: + complete_all(&ctx->mux_register); + anx7625_unregister_typec_switches(ctx); + return ret; +} + static int anx7625_i2c_probe(struct i2c_client *client) { struct anx7625_data *platform; @@ -2609,6 +2751,7 @@ static int anx7625_i2c_probe(struct i2c_client *client) mutex_init(&platform->lock); mutex_init(&platform->hdcp_wq_lock); + init_completion(&platform->mux_register); INIT_DELAYED_WORK(&platform->hdcp_work, hdcp_check_work_func); platform->hdcp_workqueue = create_workqueue("hdcp workqueue"); @@ -2679,6 +2822,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 +2877,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..0efbe06c693e 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 ********/ /***************************************************************/ @@ -449,6 +461,11 @@ struct anx7625_i2c_client { struct i2c_client *tcpc_client; }; +struct anx7625_typec_port_data { + bool dp_connected; + enum typec_orientation orientation; +}; + struct anx7625_data { struct anx7625_platform_data pdata; struct platform_device *audio_pdev; @@ -479,6 +496,9 @@ struct anx7625_data { struct drm_connector *connector; struct mipi_dsi_device *dsi; struct drm_dp_aux aux; + struct completion mux_register; + struct drm_dp_typec_switch_desc switch_desc; + struct anx7625_typec_port_data *port_data; }; #endif /* __ANX7625_H__ */ From patchwork Sat Feb 4 13:30:38 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: 650687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 699DBC61DA4 for ; Sat, 4 Feb 2023 13:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233846AbjBDNcj (ORCPT ); Sat, 4 Feb 2023 08:32:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233794AbjBDNcC (ORCPT ); Sat, 4 Feb 2023 08:32:02 -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 9530231E07 for ; Sat, 4 Feb 2023 05:31:35 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id e10so5408892pgc.9 for ; Sat, 04 Feb 2023 05:31: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=ScndThhwtHpV5F0P8Xxb0ofinCCGGRNciaNDDZjg+H0=; b=XMXwPJoH3Jms7/I7o0HdRZ4tUuiI4VmyzVUL9oedcnMVzKlm7ozMMe1HWsADEeRwbd oC+UHxdLK8yGWyjG6ha5JBruOBKtnWQuF/6JQWuoKG+nVieQxr08s56ut91LsVj2TE05 qU0HcnTGMmxp+onUUbbVvUqAXMRjZ4An/6UKQ= 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=ScndThhwtHpV5F0P8Xxb0ofinCCGGRNciaNDDZjg+H0=; b=l2tDVdMRFk+NDvOWk2wDVKDTe+hLggVghr5F16Lnk3nVFU7IAisEHeHl6DvlCz2yYh 8EngCQCr6ZDXmK5Ju2YfjLIIvr6vDSH7wouRqytEhGCKq4BwMIU8vruyn75Y2h8EqML6 uTj1JactKl+XbhRZUnl9TsdD9WFBWtydz6HfRxcbpryuCg7j1U7oz0ySdYiZtBHQ3eJD Ydoje3JPNMqfgaEaEHBDvpKreOw6cULDf+G0cBkJIMp8LzsaLDcUfj5qWh8Zsi56x8gP CsJ22L191A5BYaKJiS+re0V3RBftlsuzapVUA0XKsBiMuVIcp2qHdiNmMfVKmzrV7LRM SttA== X-Gm-Message-State: AO0yUKVb4ET7C3ag+yqQtdC4TwzWnB58rW4yzBRhTEWyF/PBlkMXpsD6 vViDmIcpAuyrYDCQu67pAJb7sQ== X-Google-Smtp-Source: AK7set/zF6HqbNPS6IKmws2CM6dRhPc7IBJbyhe+r7yBH+N3hD5Manh9iXqhdIuaKdhLNAEUJTOGUA== X-Received: by 2002:a62:388f:0:b0:590:74f1:8c8a with SMTP id f137-20020a62388f000000b0059074f18c8amr12515095pfa.15.1675517495112; Sat, 04 Feb 2023 05:31:35 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31: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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev Subject: [PATCH v11 7/9] dt-bindings: display: bridge: it6505: Add mode-switch support Date: Sat, 4 Feb 2023 21:30:38 +0800 Message-Id: <20230204133040.1236799-8-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ITE IT6505 can be used in systems to switch the DP traffic between two downstreams, which can be USB Type-C DisplayPort alternate mode lane or regular DisplayPort output ports. Update the binding to accommodate this usage by introducing a data-lanes and a mode-switch property on endpoints. Signed-off-by: Pin-yen Lin --- Changes in v11: - Updated the description of the endpoints in the bindings - Referenced video-interfaces.yaml instead for the endpoints binding - Removed duplicated definitions from inherited schema 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 | 101 +++++++++++++++--- 1 file changed, 88 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml index b16a9d9127dd..8ae9c5cba22c 100644 --- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml @@ -75,22 +75,49 @@ properties: port@1: $ref: /schemas/graph.yaml#/$defs/port-base unevaluatedProperties: false - description: Video port for DP output + description: + Video port for DP output. Each endpoint connects to a video output + downstream, and the "data-lanes" property is used to describe the pin + connections. 0, 1, 2, 3 in "data-lanes" maps to TX0, TX1, TX2, TX3, + respectively. - properties: - endpoint: - $ref: /schemas/graph.yaml#/$defs/endpoint-base + + patternProperties: + "^endpoint@[01]$": + $ref: /schemas/media/video-interfaces.yaml# unevaluatedProperties: false properties: + reg: true + + 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 +129,6 @@ required: - pwr18-supply - interrupts - reset-gpios - - extcon - ports additionalProperties: false @@ -139,8 +165,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 +177,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 Sat Feb 4 13:30:39 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: 651001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE380C61DA4 for ; Sat, 4 Feb 2023 13:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233769AbjBDNcz (ORCPT ); Sat, 4 Feb 2023 08:32:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233756AbjBDNcE (ORCPT ); Sat, 4 Feb 2023 08:32:04 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6671238E85 for ; Sat, 4 Feb 2023 05:31:41 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id ay1so5539401pfb.7 for ; Sat, 04 Feb 2023 05:31:41 -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=TJHNnZjhyF9xP9t2anATW0hxAaKdfiKK9SSVPi+BG58=; b=RllsiPfUAZgN/YqUZ0I2+ghL8fV8veiD/KenKwqa9wFIY+XBFrzUDV7HjGqouhkbpc EQpLJHQtc2E6qAlaaKgmXBES8WdWpLXsSv9SSWR08yTlzhmx1Jf/6dBLG9f6yJ5cf6e4 zibK6Rzk7xMcx+7epK/EzNXW3u2hJTOtnLc+E= 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=TJHNnZjhyF9xP9t2anATW0hxAaKdfiKK9SSVPi+BG58=; b=HRqUwfDoAQwpflX/GkzAnWXKrBT+BADck3AL9ok3HWkXP1YkndAeBsugclGqfhXYQO qDR5uAx3U5SVSNcgAI0xPDiEPI4EEy6QQrDrNGmjSkf3G+a7oECr9QjZ6Jx8QIhAAe9q bqAQUFSiF9XlBvFkEf1oR4GtfUYw4svrjXBDErzpyhBgqapZo3IyLOa3/q4LVWDm6j35 RCzzd4NcgDqNvSeXoGHW6/o3bbEtdRZ0+/LaeZ8fbTD1yR4xTlegWVs+oUh1YzMEUPI1 u2P3870SO4bBwWNv1dvNCbkk7YH+13KsuXsMiJoCfLclpKwzPdBk298z9VMoHy+8rC6R g8qg== X-Gm-Message-State: AO0yUKX1bQFiG9E/njBQP2awrmzy9OOwxBQpRf+OOI18PhM8PmVHJmBB qkVPISCb3bGrHzjYx10RK7sbbQ== X-Google-Smtp-Source: AK7set9qV3tVb6Wvb08ArkIYSv0QgI48jRd4FWDCy3A/7jgeGh3bAAtFFz45vVCuuiH+t10ceDEvvg== X-Received: by 2002:a62:1541:0:b0:590:70e0:c6a9 with SMTP id 62-20020a621541000000b0059070e0c6a9mr12602932pfv.32.1675517500923; Sat, 04 Feb 2023 05:31:40 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31: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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev Subject: [PATCH v11 8/9] drm/bridge: it6505: Fix Kconfig indentation Date: Sat, 4 Feb 2023 21:30:39 +0800 Message-Id: <20230204133040.1236799-9-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Replace the spaces with tab characters in the Kconfig file. Signed-off-by: Pin-yen Lin Reviewed-by: AngeloGioacchino Del Regno --- (no changes since v10) 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 8b2226f72b24..46c35d34bd4f 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -74,19 +74,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 Sat Feb 4 13:30:40 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: 650686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD8EDC61DA4 for ; Sat, 4 Feb 2023 13:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233814AbjBDNdD (ORCPT ); Sat, 4 Feb 2023 08:33:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233731AbjBDNcR (ORCPT ); Sat, 4 Feb 2023 08:32:17 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00043B664 for ; Sat, 4 Feb 2023 05:31:47 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id w20so5546382pfn.4 for ; Sat, 04 Feb 2023 05:31: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=daGp5PoG0OrPfl60A6az47mpAJxpghRoHNP94dlB8eU=; b=L7dAfUNBrb1nRVOe/tgmzBeRDWXGSr9dg4Jb4hBT2EXsfRGOEzDIJAz9ADGKorArqM jH9X7fM/3wzCbcwwKKc0JDT+YDN6VUULeCr4Ui9tJUhNgyPEpqdRJsiqbU8bg6emCw6g x4WWCNGmVncvIbkeCLlsBNBaVHzXCdnh5F6/k= 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=daGp5PoG0OrPfl60A6az47mpAJxpghRoHNP94dlB8eU=; b=WilcvOO158c4T5JGIh4GKNfk9U9yZuwQ3hrwToc1KSNrWTzzcRYOHRIFHfB/hFbptr jptuhC+LqnwkP+lkviY2S83LTFM9L0BvcOe6jvHpZWahosnCb2Kzw5yMoxiou6Cghpwc 0C5sLxk/z/v5rN+JHGkdCVbSFjLRnkah0lbm6vUAMJAiDKFUuvOnPBulhYFx8Pz4Av4E MKJw6b7lDZpV8IFut1h+kn7g4RTBW6pnWoh3KqPWrsOkyuxWSTM87ii/eBhV/n9eJziT 0PW1XTCLjs4Jv6mdIZQVUDYrZl1tCeM5ovrs3DCvoMFRAxLPNk19kn40tvOi4LY1W2KE cn0Q== X-Gm-Message-State: AO0yUKW+1gsTP3XyRASoR/3tFEo3hkU6gWmb0l5dA34PgNp750c+Cp2l JvBFdLMmUdUN/wCoQsxqFCz9xw== X-Google-Smtp-Source: AK7set/40ct+tyVMRwiWGG4iS8StGf6zvFVDZqXkxGxyiA7MdgelG9KQ4yQA25mKOo/brEg68xULxg== X-Received: by 2002:a62:5254:0:b0:594:1f1c:3d2f with SMTP id g81-20020a625254000000b005941f1c3d2fmr6530068pfb.4.1675517507366; Sat, 04 Feb 2023 05:31:47 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:31: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: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev Subject: [PATCH v11 9/9] drm/bridge: it6505: Register Type C mode switches Date: Sat, 4 Feb 2023 21:30:40 +0800 Message-Id: <20230204133040.1236799-10-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Register USB Type-C mode switches when the "mode-switch" property and relevant port are available in Device Tree. Configure the "lane_swap" state based on the entered alternate mode for a specific Type-C connector, which ends up updating the lane swap registers of the it6505 chip. Signed-off-by: Pin-yen Lin --- Changes in v11: - Added back "data-lanes" parsing logics - Removed Kconfig dependency - Updated the usage of the private data 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/ite-it6505.c | 179 +++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 9cda2df21b88..902f27875177 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 @@ -402,6 +405,11 @@ struct debugfs_entries { const struct file_operations *fops; }; +struct it6505_typec_port_data { + bool dp_connected; + bool lane_swap; +}; + struct it6505 { struct drm_dp_aux aux; struct drm_bridge bridge; @@ -455,6 +463,9 @@ struct it6505 { struct delayed_work delayed_audio; struct it6505_audio_data audio; struct dentry *debugfs; + struct completion mux_register; + struct drm_dp_typec_switch_desc switch_desc; + struct it6505_typec_port_data *port_data; /* it6505 driver hold option */ bool enable_drv_hold; @@ -3346,12 +3357,157 @@ static void it6505_shutdown(struct i2c_client *client) it6505_lane_off(it6505); } +static void it6505_typec_ports_update(struct it6505 *it6505) +{ + int i; + + /* Check if both ports available and do nothing to retain the current one */ + if (it6505->port_data[0].dp_connected && it6505->port_data[1].dp_connected) + return; + + for (i = 0; i < 2; i++) { + if (it6505->port_data[i].dp_connected) + it6505->lane_swap = it6505->port_data[i].lane_swap; + } +} + +static int it6505_typec_mux_set(struct typec_mux_dev *mux, + struct typec_mux_state *state) +{ + struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux); + struct it6505 *it6505 = (struct it6505 *) port->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); + wait_for_completion(&it6505->mux_register); + + old_dp_connected = it6505->port_data[0].dp_connected || + it6505->port_data[1].dp_connected; + + it6505->port_data[port->port_num].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", + it6505->port_data[0].dp_connected, it6505->port_data[1].dp_connected); + + new_dp_connected = it6505->port_data[0].dp_connected || + it6505->port_data[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_node = of_graph_get_port_by_id(dev->of_node, 1); + struct drm_dp_typec_switch_desc *switch_desc = &it6505->switch_desc; + int ret; + u32 dp_lanes[4]; + unsigned int i, num_lanes; + + ret = drm_dp_register_typec_switches(dev, &port_node->fwnode, + &it6505->switch_desc, it6505, + it6505_typec_mux_set); + if (ret) + return ret; + + it6505->port_data = devm_kcalloc( + dev, switch_desc->num_typec_switches, + sizeof(struct it6505_typec_port_data), GFP_KERNEL); + + if (!it6505->port_data) { + ret = -ENOMEM; + goto unregister_mux; + } + + for (i = 0; i < switch_desc->num_typec_switches; i++) { + struct drm_dp_typec_port_data *port = &switch_desc->typec_ports[i]; + struct fwnode_handle *fwnode = port->fwnode; + + num_lanes = fwnode_property_read_u32_array(fwnode, "data-lanes", + NULL, 0); + + if (num_lanes <= 0 || num_lanes > 2) { + dev_err(dev, + "Error on getting data lanes count from %pfwP: %d\n", + fwnode, num_lanes); + ret = num_lanes; + goto unregister_mux; + } + + ret = fwnode_property_read_u32_array(fwnode, "data-lanes", + dp_lanes, num_lanes); + if (ret) { + dev_err(dev, + "Failed to read the data-lanes variable: %d\n", + ret); + goto unregister_mux; + } + + it6505->port_data[i].lane_swap = (dp_lanes[0] / 2 == 1); + } + complete_all(&it6505->mux_register); + + return 0; + +unregister_mux: + complete_all(&it6505->mux_register); + it6505_unregister_typec_switches(it6505); + return ret; +} + 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 +3527,25 @@ 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; + init_completion(&it6505->mux_register); + 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 +3617,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[] = {