Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6297287rwn; Tue, 13 Sep 2022 01:58:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6d4MnZa3Q3m0qOHOEhy3jLbye5fMrqOaTIxJ/FR5/Um7EXOAV3akFHJ6FvFcJz2keyG3v6 X-Received: by 2002:a63:6b04:0:b0:42a:910f:2cde with SMTP id g4-20020a636b04000000b0042a910f2cdemr27889562pgc.59.1663059520150; Tue, 13 Sep 2022 01:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663059520; cv=none; d=google.com; s=arc-20160816; b=VYpFM6/OjUDWEB/g3nZIo6coUSia7ivxtAYvY2MFZ3djCai0+UYPnJ5BD54PJ1KnW1 591Gqyn0fNe14cr1GYs92/DFdiHwX6DpHmV+QFWuwMU61UbAdTkbIg3nysjDUIM6l0oY W2rIzABKORsfEdmY86nvu+QxNUfN951mMjKwd9aFmchqYX1XQo/D6HZFW6giaMB3f0Tu E5MSDe8lt7k4qbGZC9ZiEAaWFD0OeuX/SbEhvUGLdIjPxXkjwOFJp/+usIrCxjWg4VAt pIG+L2+OHDpaAAQrBgWFwwYaB3HaHnzB6iBn35JXFA8jGZAmnl6m4NzX+BZgcly+FyTI BfXQ== 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=Qt5rUg2AoPfOVRbwKIG/xJO8zJW81k9EjpU/ZJU6PEE=; b=tvfF7PDGOZoEk5/JSwsmkzrH39iGaCjGj6okvjF00ifZc6CJEkzjeuLxHKP8ozWOo3 d5QY64j+VyYePWELDlDQPxtzOf4mB/ep3VGAfwj9XRV6WYlAXN8GW8uEj/U7FzKlw/sF OusR4VAh90m0goPDsZAdEBV3LwpZRVNDkzFubvJTTJMfbiD5ASSwnqPPH2fxZmjv8Oqk w4N1Cud53O699uQtZvboT1nuHjvpwz9YUGuHpEbrHB+jalRaWXwwX8RsEEhGV7RJh3t5 +ySR91L5PQ1Kwlxdb3ScffdP5WO6Z4THfyol8R+//alM4chkc+DZbcBgt3SRxjGxi//l Ed7w== 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 k10-20020a170902d58a00b0016af36d83d7si11495298plh.357.2022.09.13.01.58.27; Tue, 13 Sep 2022 01:58:40 -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 S231293AbiIMItD (ORCPT + 99 others); Tue, 13 Sep 2022 04:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbiIMIs4 (ORCPT ); Tue, 13 Sep 2022 04:48:56 -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 AFC73481C5 for ; Tue, 13 Sep 2022 01:48:55 -0700 (PDT) Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 13 Sep 2022 16:48:54 +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 28D8mnYw017681; Tue, 13 Sep 2022 16:48:49 +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; Tue, 13 Sep 2022 16:48:50 +0800 From: allen CC: Allen Chen , Pin-yen Lin , Jau-Chih Tseng , Kenneth Hung , Hermes Wu , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH 2/2] drm/bridge: add it6505 driver to read data-lanes and max-pixel-clock-khz from dt Date: Tue, 13 Sep 2022 16:48:35 +0800 Message-ID: <20220913084835.78490-3-allen.chen@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913084835.78490-1-allen.chen@ite.com.tw> References: <20220913084835.78490-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: 069AB609ACB3102B3EBC13ACA92CA85376184F7D7B3ADB0003D6A1F4488D40972002:8 X-MAIL: mse.ite.com.tw 28D8mnYw017681 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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