Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1419455rwb; Wed, 28 Sep 2022 18:49:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RT6s/WVuzhtNHvRdLp1Yt3Sn2fhcPirN8Gdfcu5dZv4BGDzrbspuIacqC56+3YrvhATni X-Received: by 2002:aa7:cc02:0:b0:453:b0f3:9927 with SMTP id q2-20020aa7cc02000000b00453b0f39927mr936687edt.66.1664416188790; Wed, 28 Sep 2022 18:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664416188; cv=none; d=google.com; s=arc-20160816; b=HwpR/pVkDhSgyNVy8VItpR9x3hh4aQq6Ii3ENnOEbtb2xGWjj/bTmPqhGomDx793JU 3siSMUtuGuM23ELLMdxBdA/zw1dK1PNcUqv71qCz+T+BzmFbiYzcOEZRewvc3lPOeHzm V5PRPhh0sHGcR7yX5qyq+YbzJ95S0UFCgaRhScaQxwM/rtaqCMqXweKZuNhykIdPXgHC vjOZdghqMKC/80uTuM/mA3S4pHj9tUtBPK01391S3suzFbIZH7x7ph1Zh752ZbmMLJld /E+S/+HhClHJMoaN+cZfMpJLzbHzQnT2TN0Ndz3FrS8W3va5d2IPxbWr6AZbMlSMvTE0 F9Pw== 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=KpTXI8E7N9B5W/zk/Sn4J2FVUug5dYTVTKEtxL149VI=; b=jgCALGNuH9JU8J8Dc5qEon1U4zEKKr6TS+hQBtDfDsfQQCZzt836m7vthjiRq8gC0m 2L0PJ28LbHUoAtkpK8aRz0B/5aLDN1tgIn1XSmg62KoQrln9gHgnAQzjSWxvrsgO9IoA LqISkuObz3DFPUuY900ByhlMPrLfoiwworRP9BSMwddIv+KSVJHYERB4LHhic2c+JaAT DMnfzo7S7NXGTaNjRtsBNTQr6lmbDzqKlb4732oMWdl3TuHWIK++fixXOaTzvwL3R8Vr J3EsWa+QrQR1OtKxm042kMeyV/ZwU2CA0ABT01Ay3iu33GTK+smfNYoMfUgA0iBjx2t8 9RUQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a0564020f1a00b00457e7b5d230si4201215eda.550.2022.09.28.18.49.23; Wed, 28 Sep 2022 18:49:48 -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 S233665AbiI2BqP (ORCPT + 99 others); Wed, 28 Sep 2022 21:46:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbiI2BqJ (ORCPT ); Wed, 28 Sep 2022 21:46:09 -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 7F235D2D65 for ; Wed, 28 Sep 2022 18:46:07 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 29 Sep 2022 09:46:06 +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 28T1k3xf041765; Thu, 29 Sep 2022 09:46:03 +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, 29 Sep 2022 09:45:14 +0800 From: allen CC: Allen Chen , Jau-Chih Tseng , Kenneth Hung , Hermes Wu , Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH v2 2/2] drm/bridge: add it6505 driver to read data-lanes and max-pixel-clock-khz from dt Date: Thu, 29 Sep 2022 09:44:52 +0800 Message-ID: <20220929014456.30077-3-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929014456.30077-1-allen.chen@ite.com.tw> References: <20220929014456.30077-1-allen.chen@ite.com.tw> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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: F89ADB4C5CCEB304D0D91482FF0A8ED263135192E8A47F867635897E00136C642002:8 X-MAIL: mse.ite.com.tw 28T1k3xf041765 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,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 From: allen chen Add driver to read data-lanes and max-pixel-clock-khz 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 | 35 ++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 2767b70fa2cb..cfa25a176a29 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -436,6 +436,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; @@ -1475,7 +1477,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", @@ -2901,7 +2904,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; @@ -3066,6 +3069,8 @@ static void it6505_parse_dt(struct it6505 *it6505) { struct device *dev = &it6505->client->dev; 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"); @@ -3081,7 +3086,31 @@ static void it6505_parse_dt(struct it6505 *it6505) } else { *afe_setting = 0; } - DRM_DEV_DEBUG_DRIVER(dev, "using afe_setting: %d", *afe_setting); + + if (device_property_read_u32(dev, "data-lanes", + max_lane_count) == 0) { + if (*max_lane_count > 4 || *max_lane_count == 3) { + dev_err(dev, "max lane count error, use default"); + *max_lane_count = MAX_LANE_COUNT; + } + } else { + *max_lane_count = MAX_LANE_COUNT; + } + + if (device_property_read_u32(dev, "max-pixel-clock-khz", + max_dpi_pixel_clock) == 0) { + if (*max_dpi_pixel_clock > 297000) { + dev_err(dev, "max pixel clock error, use default"); + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; + } + } else { + *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, -- 2.25.1