Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3776836rwb; Sun, 20 Nov 2022 22:09:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7AgHLnBZPt0l6UcR2C/kGdUsS0CsKiVnHAX0Xc9pJIED1MmDjl78fSP5U4YJMUH/7UkFc9 X-Received: by 2002:a17:906:d785:b0:7ad:a3c6:6797 with SMTP id pj5-20020a170906d78500b007ada3c66797mr542383ejb.665.1669010982499; Sun, 20 Nov 2022 22:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669010982; cv=none; d=google.com; s=arc-20160816; b=IPWtKx49fNtnhdPxcEafV/4NZKgnbsa+GYP1T9h4GgEasDHC6sp8DtHQaVllaj8qE1 7U1Fqok6ojHwzi8aZ7QkmCEhfiJpFEHWEoTL1dx+/onfoDB5CEPwGmWv9sGxtsxED/v8 X/H1d7n5yN2O4EuCDYbdjhpURtM3clEOxUShaJKD1Xq5gc2YBShZLySzMoLgDACch/tM +rP0rxnprg9rN/ZHFWbBvNyiH/gfsaiX2SREyCaLblyyZ/+LwJwmnPVYhnDiphlsl5AX GFNRCBgmBMSTd0L5GBY4pppu7usDwOv44xhE3H8plEvk7BccfsN6yQtNfe0KGjQ8ohcD 1y4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AdzQfZlp1+RoluiUkkU4r5IReZONbXSnbU4C7vab+r4=; b=Twwz+/zX3epETyDhYP1m21/0crbqE8OesEDs3QEg9IiWFUk1xh7klgOieEKVorgn72 VOg6Ox89e/b6+p9/9FSQVZzOCssChVX9ryQM5/vaX6Qgo+4vXN00pNu2xtvcFDKq41ov PYXC5FN4zjeibh02ShBQ+v5VrqRoV6mxJrpoRMeIoTwrD13Czjp2WEzYIQsl22feeQiG X5gZOZFsvIi8uZL1mwtpd+9iK78HBncldwZxf6RoQqVbXZfJ3PA+U7AHfQTbzZkfToGO caJGZ1BD7Y+YqMgZzRNAZ+8XFcBJWGtscA2uwe7mCJvQRnh1SVEjudKP2IsUUSw8695o pPqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ci31+LDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a0564021f8400b00461c8f80e34si8241222edc.53.2022.11.20.22.09.19; Sun, 20 Nov 2022 22:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ci31+LDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbiKUFjx (ORCPT + 91 others); Mon, 21 Nov 2022 00:39:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbiKUFjv (ORCPT ); Mon, 21 Nov 2022 00:39:51 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DAB1145E for ; Sun, 20 Nov 2022 21:39:49 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id n21so25960983ejb.9 for ; Sun, 20 Nov 2022 21:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AdzQfZlp1+RoluiUkkU4r5IReZONbXSnbU4C7vab+r4=; b=ci31+LDzfAjGgIy8ZDVokMN9P+ifFni1+VU5k3tYvAjTdN9mtK+IknG7HVUL6QFc6A S4W7bBkQxbZtVljgzVfJXtLTfHhvOZTIT8awNN28aIUo9PL/oE/W2U0Whi0JmSskGi0a fc5MwzU8MyvgfK2moBe4U4wDPihR0RQ7DRTeI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AdzQfZlp1+RoluiUkkU4r5IReZONbXSnbU4C7vab+r4=; b=HUU91Y5OoN50oU0S4XRlXj+l7lvm5GeP3HS5RpmQMvkXf9Zjp2V2sWbK4b1Zzo169q m9UAHiqjhfpaTwKZ/o3UfXOd67Mg+W3QRcO7ZzQfvWMtz/UuqfJWORuKJyF7bUFTmkHA nOjYizXtcLl9miNzL/7Z3boodOFsv67a7MEmZeCKoUN8EqryemLtHE8xLFesbxyOMvnj cIUo3Hn5uk0idUHVbNlytXDUF9s/cmUhvQqo1IJfzpOrK+tyAA6/tCtm97Idj0GeltPD WTCdgOzbJAIWwZN0bZCh5+qWq+fNsHtIGvyokLYEyrr8VHI8UK37q3hg4QazabC90h6Y nZVQ== X-Gm-Message-State: ANoB5plGg5DRRFFa441jVM8r2sYI05t5TV8NomjIeT0DC1qUUDiDWSGl pnTUvbnLNpstF/X1hUSklnyK20ALBeXy9jU6EMBTig== X-Received: by 2002:a17:906:55c5:b0:78d:3862:4488 with SMTP id z5-20020a17090655c500b0078d38624488mr13283858ejp.683.1669009188450; Sun, 20 Nov 2022 21:39:48 -0800 (PST) MIME-Version: 1.0 References: <20221103091243.96036-1-allen.chen@ite.com.tw> <20221103091243.96036-3-allen.chen@ite.com.tw> In-Reply-To: <20221103091243.96036-3-allen.chen@ite.com.tw> From: Pin-yen Lin Date: Mon, 21 Nov 2022 13:39:36 +0800 Message-ID: Subject: Re: [PATCH v7 2/2] drm/bridge: add it6505 driver to read data-lanes and link-frequencies from dt To: allen Cc: 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, Friendly ping on this patch. Regards, Pin-yen On Thu, Nov 3, 2022 at 5:13 PM allen wrote: > > 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, > -- > 2.25.1 >