From patchwork Thu Oct 27 03:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: allen X-Patchwork-Id: 11524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a40e:b0:83:7221:86ba with SMTP id ck14csp194549dyb; Wed, 26 Oct 2022 20:03:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58JC+//zaBQlwyHjlXkR9/XI6SKIhykPNJnH3LqUaW/OaXHGnAxrZeTaGda6WbzPb8XyO/ X-Received: by 2002:a17:90a:dc83:b0:212:59ea:84b2 with SMTP id j3-20020a17090adc8300b0021259ea84b2mr7448169pjv.61.1666839829770; Wed, 26 Oct 2022 20:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666839829; cv=none; d=google.com; s=arc-20160816; b=vQlmHLu7w9/k3RLfplv3JlfnHl76onClaq9esrcy0ERd9MQcHkNqG2dv4fL+11cHVA oszG3AoLBP7wutpCI1PQqsoczouXOwzXtV/7MHF2cBjldHJFMjb6/j3K2Vfz8nORw1rZ uwPgulo6rQHOfoyQ9QQh3tW7L8u1/5Du9m5M8jf2Fa4i82W5PG2d/zJBtNPClk9FIJXR lyT7yD3ZkMoW3g0MX7TF0E7nTH9Kjv20Wwkhev12hlJjIh6nyUWKG+HO1EHUUvCueCJF 9RRM2sgQKiUwI21Q9008qhqLofyoCX6u22fGlRwFM6lFBgJqR/v8k7rEpAZUYdJh9iVu d+1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=K8pJQy2ALE9QVF+in7mcihEQBQMiOvmf7Og9sAdL99I=; b=XpuDSYVG33Wmwz5eqnq52XqJew8yCRP39Nu5iMuzxEpcf7985M0SNrpDhlnRzrzNO4 SXUn9F7kGgK/DCtbrcuJ6RR6OpmVwDS+efwlVnrIY9Fq2uu1vJVbbD/GqavRj+ZiZ07h 3bX5qxp75IiHTmg2+JtnGAWbmD+TE61ZI9AdBfPyuxngOjwIocp1XEYUG0qraeXSxAHa /jTvXGs/7EEpFDvM4ZTnrRld2WsLabXaqiw/bWxLVasfBhvhtXVbswiXd4lDsZbSAFVc MCfEciEmzLzbSoOKAuD18CBAFlUSyhgbsh4GNfWcRIk+o+K+FE30rRfhU2HU3ufyaJS8 dM8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb5-20020a17090b35c500b0021366690f1esi263277pjb.113.2022.10.26.20.03.14; Wed, 26 Oct 2022 20:03:49 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234272AbiJ0DCh (ORCPT + 99 others); Wed, 26 Oct 2022 23:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234150AbiJ0DCQ (ORCPT ); Wed, 26 Oct 2022 23:02:16 -0400 Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422A614408E; Wed, 26 Oct 2022 20:02:15 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 27 Oct 2022 11:02:14 +0800 Received: from CSBMAIL1.internal.ite.com.tw (CSBMAIL1.internal.ite.com.tw [192.168.65.58]) by mse.ite.com.tw with ESMTP id 29R329aQ066880; Thu, 27 Oct 2022 11:02:09 +0800 (GMT-8) (envelope-from allen.chen@ite.com.tw) Received: from VirtualBox.internal.ite.com.tw (192.168.70.46) by CSBMAIL1.internal.ite.com.tw (192.168.65.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Thu, 27 Oct 2022 11:02:08 +0800 From: allen CC: Allen Chen , Pin-Yen Lin , Jau-Chih Tseng , Hermes Wu , Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , "open list:DRM DRIVERS" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list Subject: [PATCH v6 1/2] dt-bindings: it6505: add properties to restrict output bandwidth Date: Thu, 27 Oct 2022 11:01:53 +0800 Message-ID: <20221027030155.59238-2-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221027030155.59238-1-allen.chen@ite.com.tw> References: <20221027030155.59238-1-allen.chen@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.70.46] X-ClientProxiedBy: CSBMAIL1.internal.ite.com.tw (192.168.65.58) To CSBMAIL1.internal.ite.com.tw (192.168.65.58) X-TM-SNTS-SMTP: 70E5B4906432A1B9367F90D8984C2AC6C8C504F4A986AA129654A344C592C4B62002:8 X-MAIL: mse.ite.com.tw 29R329aQ066880 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1747808241107071009?= X-GMAIL-MSGID: =?utf-8?q?1747808241107071009?= From: allen chen Add properties to restrict dp output data-lanes and clock. Signed-off-by: Pin-Yen Lin Signed-off-by: Allen Chen --- .../bindings/display/bridge/ite,it6505.yaml | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml index 833d11b2303a7..b16a9d9127ddb 100644 --- a/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml +++ b/Documentation/devicetree/bindings/display/bridge/ite,it6505.yaml @@ -52,9 +52,49 @@ properties: maxItems: 1 description: extcon specifier for the Power Delivery - port: - $ref: /schemas/graph.yaml#/properties/port - description: A port node pointing to DPI host port node + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: A port node pointing to DPI host port node + + properties: + endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + properties: + link-frequencies: + minItems: 1 + maxItems: 1 + description: Allowed max link frequencies in Hz + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: Video port for DP output + + properties: + endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + properties: + data-lanes: + minItems: 1 + uniqueItems: true + items: + - enum: [ 0, 1 ] + - const: 1 + - const: 2 + - const: 3 + + required: + - port@0 + - port@1 required: - compatible @@ -63,6 +103,7 @@ required: - interrupts - reset-gpios - extcon + - ports additionalProperties: false @@ -85,9 +126,24 @@ examples: reset-gpios = <&pio 179 1>; extcon = <&usbc_extcon>; - port { - it6505_in: endpoint { - remote-endpoint = <&dpi_out>; + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + it6505_in: endpoint { + remote-endpoint = <&dpi_out>; + link-frequencies = /bits/ 64 <150000000>; + }; + }; + + port@1 { + reg = <1>; + it6505_out: endpoint { + remote-endpoint = <&dp_in>; + data-lanes = <0 1>; + }; }; }; }; From patchwork Thu Oct 27 03:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: allen X-Patchwork-Id: 11525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a40e:b0:83:7221:86ba with SMTP id ck14csp199723dyb; Wed, 26 Oct 2022 20:15:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DeSyY36moqw9CivuJYDNCX/o/gxMJjq4KRXzg/KI3cMTNCpy1gc75fBEc9hXA6RFewWB5 X-Received: by 2002:a17:906:cc0f:b0:7ad:2da5:4711 with SMTP id ml15-20020a170906cc0f00b007ad2da54711mr7674005ejb.628.1666840529713; Wed, 26 Oct 2022 20:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666840529; cv=none; d=google.com; s=arc-20160816; b=A7/FY5wPjakeHSwLoyn2PGaok+WE4K1XJU9d8McbHYGrZ+TJh158N4nS6FF79M+Vfu RR51Jka3UsOe0a33AJiRlyb2wxH5SUPg+9W13M4VYFeEThJi0dooQaG7P0oDuI32Np7f Qe/3hGCiT4UYM5efqqAzEFcvR8/58lL2DCPoMTd5f0sk1UeKzgJ9eRXNxQMvFVfvo7Ih caJRY/VuUc2E3xDRoceTUAsuYgbp4r/Bionlm8mlLQ671foMzu/5/3pT7IPzQB9oNFh5 3R0yIaD4qCV1J5PaAs3pUgTIp6BEiq/RcnzVFlivUlc1Lo+TObFLFWVtvXHGzyexFiqg 1I9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=Ewmr9E28IrsYhJT+ITfNeWjb7YaIlvn3KJP5fk+bn+o=; b=uYf4zDJTe/2Lgjve+BdfOY7GcsZYo7zll4gG0subOr1fVg3bTJHQpfbDRnCurFOXhj ZIf/9WEM7TmSXeNIb/iOMii3qsFZxpuUXvLDGR+kvLQJca2Zocwp2lHI8qrxa3qh2duK r1T9ZhJtrQ9CExTwf5hoOU9MSuT+towHe8/Lu2VC2gDS2qlnlCUIJYSpHsjrtobUOtDn BnDulwYSIzaaNHLO2PBXKXebiUyYUramGdd/YZaGyC7u7C7RqPvKhvr4LD+jwLLqRBBf 5Y/uT2ySWVLxk4j1KDlJXomKqZ9a1NZWGjSxBQ59yR2rh245mhELulcoDPrrSldwia2S cHEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wg5-20020a17090705c500b0073cd848ae8asi303076ejb.321.2022.10.26.20.14.54; Wed, 26 Oct 2022 20:15:29 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234291AbiJ0DCo (ORCPT + 99 others); Wed, 26 Oct 2022 23:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234196AbiJ0DCR (ORCPT ); Wed, 26 Oct 2022 23:02:17 -0400 Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE56148FDF for ; Wed, 26 Oct 2022 20:02:15 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 27 Oct 2022 11:02:14 +0800 Received: from CSBMAIL1.internal.ite.com.tw (CSBMAIL1.internal.ite.com.tw [192.168.65.58]) by mse.ite.com.tw with ESMTP id 29R329I1066884; Thu, 27 Oct 2022 11:02:09 +0800 (GMT-8) (envelope-from allen.chen@ite.com.tw) Received: from VirtualBox.internal.ite.com.tw (192.168.70.46) by CSBMAIL1.internal.ite.com.tw (192.168.65.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Thu, 27 Oct 2022 11:02:09 +0800 From: allen CC: Allen Chen , Pin-Yen Lin , Jau-Chih Tseng , Hermes Wu , Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH v6 2/2] drm/bridge: add it6505 driver to read data-lanes and link-frequencies from dt Date: Thu, 27 Oct 2022 11:01:54 +0800 Message-ID: <20221027030155.59238-3-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221027030155.59238-1-allen.chen@ite.com.tw> References: <20221027030155.59238-1-allen.chen@ite.com.tw> MIME-Version: 1.0 X-Originating-IP: [192.168.70.46] X-ClientProxiedBy: CSBMAIL1.internal.ite.com.tw (192.168.65.58) To CSBMAIL1.internal.ite.com.tw (192.168.65.58) X-TM-SNTS-SMTP: D2FAF83ABC70EADEED34BCE8DDA5CC3317F3AABE3E0EC9380F4DCCB60E1D035E2002:8 X-MAIL: mse.ite.com.tw 29R329I1066884 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1747808975245105672?= X-GMAIL-MSGID: =?utf-8?q?1747808975245105672?= From: allen chen Add driver to read data-lanes and link-frequencies from dt property to restrict output bandwidth. Signed-off-by: Allen chen Signed-off-by: Pin-yen Lin --- drivers/gpu/drm/bridge/ite-it6505.c | 80 +++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index a4302492cf8df..ed4536cde3140 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -437,6 +437,8 @@ struct it6505 { bool powered; bool hpd_state; u32 afe_setting; + u32 max_dpi_pixel_clock; + u32 max_lane_count; enum hdcp_state hdcp_status; struct delayed_work hdcp_work; struct work_struct hdcp_wait_ksv_list; @@ -1476,7 +1478,8 @@ static void it6505_parse_link_capabilities(struct it6505 *it6505) it6505->lane_count = link->num_lanes; DRM_DEV_DEBUG_DRIVER(dev, "Sink support %d lanes training", it6505->lane_count); - it6505->lane_count = min_t(int, it6505->lane_count, MAX_LANE_COUNT); + it6505->lane_count = min_t(int, it6505->lane_count, + it6505->max_lane_count); it6505->branch_device = drm_dp_is_branch(it6505->dpcd); DRM_DEV_DEBUG_DRIVER(dev, "Sink %sbranch device", @@ -2912,7 +2915,7 @@ it6505_bridge_mode_valid(struct drm_bridge *bridge, if (mode->flags & DRM_MODE_FLAG_INTERLACE) return MODE_NO_INTERLACE; - if (mode->clock > DPI_PIXEL_CLK_MAX) + if (mode->clock > it6505->max_dpi_pixel_clock) return MODE_CLOCK_HIGH; it6505->video_info.clock = mode->clock; @@ -3099,10 +3102,32 @@ static int it6505_init_pdata(struct it6505 *it6505) return 0; } +static int it6505_get_data_lanes_count(const struct device_node *endpoint, + const unsigned int min, + const unsigned int max) +{ + int ret; + + ret = of_property_count_u32_elems(endpoint, "data-lanes"); + if (ret < 0) + return ret; + + if (ret < min || ret > max) + return -EINVAL; + + return ret; +} + static void it6505_parse_dt(struct it6505 *it6505) { struct device *dev = &it6505->client->dev; + struct device_node *np = dev->of_node, *ep = NULL; + int len; + u64 link_frequencies; + u32 data_lanes[4]; u32 *afe_setting = &it6505->afe_setting; + u32 *max_lane_count = &it6505->max_lane_count; + u32 *max_dpi_pixel_clock = &it6505->max_dpi_pixel_clock; it6505->lane_swap_disabled = device_property_read_bool(dev, "no-laneswap"); @@ -3118,7 +3143,56 @@ static void it6505_parse_dt(struct it6505 *it6505) } else { *afe_setting = 0; } - DRM_DEV_DEBUG_DRIVER(dev, "using afe_setting: %d", *afe_setting); + + ep = of_graph_get_endpoint_by_regs(np, 1, 0); + of_node_put(ep); + + if (ep) { + len = it6505_get_data_lanes_count(ep, 1, 4); + + if (len > 0 && len != 3) { + of_property_read_u32_array(ep, "data-lanes", + data_lanes, len); + *max_lane_count = len; + } else { + *max_lane_count = MAX_LANE_COUNT; + dev_err(dev, "error data-lanes, use default"); + } + } else { + *max_lane_count = MAX_LANE_COUNT; + dev_err(dev, "error endpoint, use default"); + } + + ep = of_graph_get_endpoint_by_regs(np, 0, 0); + of_node_put(ep); + + if (ep) { + len = of_property_read_variable_u64_array(ep, + "link-frequencies", + &link_frequencies, 0, + 1); + if (len >= 0) { + do_div(link_frequencies, 1000); + if (link_frequencies > 297000) { + dev_err(dev, + "max pixel clock error, use default"); + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; + } else { + *max_dpi_pixel_clock = link_frequencies; + } + } else { + dev_err(dev, "error link frequencies, use default"); + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; + } + } else { + dev_err(dev, "error endpoint, use default"); + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; + } + + DRM_DEV_DEBUG_DRIVER(dev, "using afe_setting: %u, max_lane_count: %u", + it6505->afe_setting, it6505->max_lane_count); + DRM_DEV_DEBUG_DRIVER(dev, "using max_dpi_pixel_clock: %u kHz", + it6505->max_dpi_pixel_clock); } static ssize_t receive_timing_debugfs_show(struct file *file, char __user *buf,