From patchwork Thu May 18 23:06:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247499 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB6F9C77B73 for ; Thu, 18 May 2023 23:06:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE8B910E573; Thu, 18 May 2023 23:06:44 +0000 (UTC) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 800F410E571 for ; Thu, 18 May 2023 23:06:41 +0000 (UTC) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-334d7bb7155so6803155ab.0 for ; Thu, 18 May 2023 16:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451200; x=1687043200; 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=Eat7ZZkvIgNO0d+Nb1ho7Qs2hgM0XyaATLA4vhm7AEo=; b=DE944Ib1ld+120uL+TpRFUQEUj6080i0PgE0CJljKz9AT6i5kL6jbS5vo+Ah3G3Y6Q 5A1JNFqdHCind3nF0DuR3oKRPNTu1RxUEuYUDTkX1+xBVMZPnXBQ1G+7GPrdhsX+GoqS T3zCHFtXehuLBWscviMN4qwDbIgVkASo9Gke+noVwt/+OjXpd+qf1KVxAKH48lWwLbMQ lJHm2t3SHeoxm92FdGafsqeapPFYMsR5GAirsGd5fUHZysjBnjw17yGhij2oa/63kybo SqJPRjIP31NhhlmQLOTEsiycV0yBuMZZmW17Eayv17N0vhYIuxXAb6DHYG6WQ1O4p8lE 6T+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451200; x=1687043200; 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=Eat7ZZkvIgNO0d+Nb1ho7Qs2hgM0XyaATLA4vhm7AEo=; b=cCSBPELXK8akUTcGv0cMZRYT6eZyvktoPY5q3Fsqil2YQqUVirseaAOJxPGwHigrmU SE4Bi64HYt2xsiIDkue8A40cbWjCLjVRsYuO8A646K41GSpZux0N6q+v0dM5JDv8AQGT 1X3/2NY7BjaLEvijwmBSCpF+kw/VI8zw5J2zWh14eAhVsyWh8HEd15ESg/UeCeriwvni V4fyrRd3k7iu5DDjugPX2v8TqMkmH9ani3Ymxr49H+g3f7UmNNcpWS+OQIb9YcJhGtfM O/Vhr8VzXmcPzs5mgz//Vhm/7lCnJfIiUMLWnK1XPQh7k7dKkGFVV957Rwb2cldU9WfF ZGQQ== X-Gm-Message-State: AC+VfDzxOrgZaSnWATHaJnA16mFKUZSiHlpr4RPTFkIjN7ojHOZXN9M4 2pV0EEvMtHMfoZmW+r51uyU/dLJouMU= X-Google-Smtp-Source: ACHHUZ7k+Omw1YOkZhO0tjeAZNgxijvwDBeh4ZVTvPZ9gntUZInKMpBhWZ0XSLvpAnWgmUezU83HtA== X-Received: by 2002:a92:c6cf:0:b0:332:b18a:7ba7 with SMTP id v15-20020a92c6cf000000b00332b18a7ba7mr5201843ilm.27.1684451199670; Thu, 18 May 2023 16:06:39 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:39 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 1/6] drm: bridge: samsung-dsim: fix blanking packet size calculation Date: Thu, 18 May 2023 18:06:21 -0500 Message-Id: <20230518230626.404068-2-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Jagan Teki , Andrzej Hajda , Chen-Yu Tsai , Adam Ford , Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lucas Stach Scale the blanking packet sizes to match the ratio between HS clock and DPI interface clock. The controller seems to do internal scaling to the number of active lanes, so we don't take those into account. Signed-off-by: Lucas Stach Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index e0a402a85787..2be3b58624c3 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -874,17 +874,29 @@ static void samsung_dsim_set_display_mode(struct samsung_dsim *dsi) u32 reg; if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { + int byte_clk_khz = dsi->burst_clk_rate / 1000 / 8; + int hfp = (m->hsync_start - m->hdisplay) * byte_clk_khz / m->clock; + int hbp = (m->htotal - m->hsync_end) * byte_clk_khz / m->clock; + int hsa = (m->hsync_end - m->hsync_start) * byte_clk_khz / m->clock; + + /* remove packet overhead when possible */ + hfp = max(hfp - 6, 0); + hbp = max(hbp - 6, 0); + hsa = max(hsa - 6, 0); + + dev_dbg(dsi->dev, "calculated hfp: %u, hbp: %u, hsa: %u", + hfp, hbp, hsa); + reg = DSIM_CMD_ALLOW(0xf) | DSIM_STABLE_VFP(m->vsync_start - m->vdisplay) | DSIM_MAIN_VBP(m->vtotal - m->vsync_end); samsung_dsim_write(dsi, DSIM_MVPORCH_REG, reg); - reg = DSIM_MAIN_HFP(m->hsync_start - m->hdisplay) - | DSIM_MAIN_HBP(m->htotal - m->hsync_end); + reg = DSIM_MAIN_HFP(hfp) | DSIM_MAIN_HBP(hbp); samsung_dsim_write(dsi, DSIM_MHPORCH_REG, reg); reg = DSIM_MAIN_VSA(m->vsync_end - m->vsync_start) - | DSIM_MAIN_HSA(m->hsync_end - m->hsync_start); + | DSIM_MAIN_HSA(hsa); samsung_dsim_write(dsi, DSIM_MSYNC_REG, reg); } reg = DSIM_MAIN_HRESOL(m->hdisplay, num_bits_resol) | From patchwork Thu May 18 23:06:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247498 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE2BBC77B73 for ; Thu, 18 May 2023 23:06:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29DD410E56F; Thu, 18 May 2023 23:06:44 +0000 (UTC) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8668410E56F for ; Thu, 18 May 2023 23:06:42 +0000 (UTC) Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3311691ebd0so6503515ab.1 for ; Thu, 18 May 2023 16:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451201; x=1687043201; 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=TkgUBoTxrN0CEnRT74Chghq2miOefeDr1PRbCfEvqtc=; b=gHVZ/8ULZ6U5cF2PnE8kNQVwQpZh15ZUzFYh8Z5miIW1egbnujmJOhVkNr/mUP3P3R bHPCdWsqb0iSjdLY98Wjh/W6gRbhsXnwz8nEGIuslQk9xDpAzIn+Wdwyr4ZjIg2Ov07E QoBcaD7xNjq7cy6ViyhGVus1gnNN2cAf2wed8I0cTMCDeMskCe3eEYyARp7bm5u1Hq7w QPwe5l6wMT77i9O08vUeEYaBlQqwmgVNA9cJzAUOJa2GtHMcXfRm/8s5j6v2Z9hA//in 7DDxP0vMSspN2GWQfAfhf+VomirgRTf3tyf56L3LbvYWu7bcODAInT0X6WH3fys7zedE exRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451201; x=1687043201; 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=TkgUBoTxrN0CEnRT74Chghq2miOefeDr1PRbCfEvqtc=; b=R0U5P/lT0u1nl5wfwM8f+RX5DKxymOe+LP44CpusCPw+KSbq9pyFcfWXdjVsXprDV7 4S2qB5oA1PGGr6RFs+a/1HAQ9PsQZdX9Os2PDbKCZuDPo5+JmGMlbxZeFuxjAAU27o/w 2RFFJohPaxac8wxjfiGVhRN1YwWWQbejxMEYYvyD3J0UDpYO0jJvrIm39aBAFjYw3h+Q GjfKPIUfzWcrzziKMM+RDTnszZ8Dgqq23IK3bc8tdpiPcF3aa5LgjjmMzzMhJqrmGsez wrS1Ncx+CZjqmglrsMWbtBOiG2lS1/Uwp8Mxze8iFj5Kdz778WjVHsrsp2lY4Oj4GSSm A2Gw== X-Gm-Message-State: AC+VfDxOSHSiMx5b1STYU0bu51MWqnHnMcihIhULfIVY+wjzvZG/+IH7 oUjmR+JZS/6q1hEzZIxq/1bXW9BR/S8= X-Google-Smtp-Source: ACHHUZ7HzqXRSUkC3GUxq8ieAh8dmS5TsaMJpjwhpVKh1q+fP0bbQMSwJYioJHDXdw6gYz/2x90tlg== X-Received: by 2002:a92:c811:0:b0:32c:dc61:8e84 with SMTP id v17-20020a92c811000000b0032cdc618e84mr5665825iln.4.1684451201277; Thu, 18 May 2023 16:06:41 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:40 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Thu, 18 May 2023 18:06:22 -0500 Message-Id: <20230518230626.404068-3-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Jagan Teki , Andrzej Hajda , Chen-Yu Tsai , Adam Ford , Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" According to Table 13-45 of the i.MX8M Mini Reference Manual, the min and max values for M and the frequency range for the VCO_out calculator were incorrect. This information was contradicted in other parts of the mini, nano and plus manuals. After reaching out to my NXP Rep, when confronting him about discrepencies in the Nano manual, he responded with: "Yes it is definitely wrong, the one that is part of the NOTE in MIPI_DPHY_M_PLLPMS register table against PMS_P, PMS_M and PMS_S is not correct. I will report this to Doc team, the one customer should be take into account is the Table 13-40 DPHY PLL Parameters and the Note above." These updated values also match what is used in the NXP downstream kernel. To fix this, make new variables to hold the min and max values of m and the minimum value of VCO_out, and update the PMS calculator to use these new variables instead of using hard-coded values to keep the backwards compatibility with other parts using this driver. Fixes: 4d562c70c4dc ("drm: bridge: samsung-dsim: Add i.MX8M Mini/Nano support") Signed-off-by: Adam Ford Reviewed-by: Lucas Stach Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 22 ++++++++++++++++++++-- include/drm/bridge/samsung-dsim.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 2be3b58624c3..bf4b33d2de76 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -405,6 +405,9 @@ static const struct samsung_dsim_driver_data exynos3_dsi_driver_data = { .num_bits_resol = 11, .pll_p_offset = 13, .reg_values = reg_values, + .m_min = 41, + .m_max = 125, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { @@ -418,6 +421,9 @@ static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { .num_bits_resol = 11, .pll_p_offset = 13, .reg_values = reg_values, + .m_min = 41, + .m_max = 125, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { @@ -429,6 +435,9 @@ static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { .num_bits_resol = 11, .pll_p_offset = 13, .reg_values = reg_values, + .m_min = 41, + .m_max = 125, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { @@ -441,6 +450,9 @@ static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { .num_bits_resol = 12, .pll_p_offset = 13, .reg_values = exynos5433_reg_values, + .m_min = 41, + .m_max = 125, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { @@ -453,6 +465,9 @@ static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { .num_bits_resol = 12, .pll_p_offset = 13, .reg_values = exynos5422_reg_values, + .m_min = 41, + .m_max = 125, + .min_freq = 500, }; static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { @@ -469,6 +484,9 @@ static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { */ .pll_p_offset = 14, .reg_values = imx8mm_dsim_reg_values, + .m_min = 64, + .m_max = 1023, + .min_freq = 1050, }; static const struct samsung_dsim_driver_data * @@ -547,12 +565,12 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi, tmp = (u64)fout * (_p << _s); do_div(tmp, fin); _m = tmp; - if (_m < 41 || _m > 125) + if (_m < driver_data->m_min || _m > driver_data->m_max) continue; tmp = (u64)_m * fin; do_div(tmp, _p); - if (tmp < 500 * MHZ || + if (tmp < driver_data->min_freq * MHZ || tmp > driver_data->max_freq * MHZ) continue; diff --git a/include/drm/bridge/samsung-dsim.h b/include/drm/bridge/samsung-dsim.h index ba5484de2b30..a1a5b2b89a7a 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -54,11 +54,14 @@ struct samsung_dsim_driver_data { unsigned int has_freqband:1; unsigned int has_clklane_stop:1; unsigned int num_clks; + unsigned int min_freq; unsigned int max_freq; unsigned int wait_for_reset; unsigned int num_bits_resol; unsigned int pll_p_offset; const unsigned int *reg_values; + u16 m_min; + u16 m_max; }; struct samsung_dsim_host_ops { From patchwork Thu May 18 23:06:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247502 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1729DC7EE2D for ; Thu, 18 May 2023 23:06:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2146C10E574; Thu, 18 May 2023 23:06:49 +0000 (UTC) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 513D110E571 for ; Thu, 18 May 2023 23:06:44 +0000 (UTC) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3381e9ec12bso20452355ab.3 for ; Thu, 18 May 2023 16:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451203; x=1687043203; 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=OWvWiGJr56z9q9APTKrg8aD2bb2PPBSrUeKO9a/g3Js=; b=lA2Hqp+kdUMi3SHJQhTJWIgUTYRSIEEdfqnkzxCCwotAVtB/AxpD5T4O4WlqQfLSSc TNKqGHcYPppZs3tON5lhOhtGj/wqSExd/PoIrXZ6Bym/9wi+zX6lOH4uzTzzCd6851E5 HaAHxOeBEDshdCjEWDYVVsMKwVuwYn/j7CDgHImKhsMH8QOMJ96BEVK+FhMgJop7gwpe zIhddlTDCY9YCP2Zymz1ScYcErRfvgyu9GKH8wCBtWsRhTVY9BMiE+1+kJUwEddCjTJg /SJMs1PB0B6d3vMfeUqyUvQa1m1BH82zfVJzmx869Qpv70W8Zqiv0Nq6Gz77x2EpsMVA qf/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451203; x=1687043203; 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=OWvWiGJr56z9q9APTKrg8aD2bb2PPBSrUeKO9a/g3Js=; b=AdyAn36iDMous0jpIWzINCISMurPXCS7NAreaL7SdXTt9w94pCnud84pLYmB7Kx9v6 OX3mNfvF6ntcYaW5h56OBdPoRS7Yu8JXIPRWa7I0VhyV3WFt5MgdxxJFdP83sstlrLCm NWSdzFmefyjrydjXSAYs9H64bIHZz7gLYhfHRWJ3nKHziLRvcqx1y2ab5Rj/mGbZa0u2 YHbsnSaAaJaZ7GG7Cf+Ul3loZQ7yLu4T739F53tuZM9cojLh454GY7x9wkOub/naGH2J 3azmSzr6BZMjKyWoSMo5WXRNLV4zJ0n5Y5ksb630/d8N+/BhxAisV7JvkxX2V1U1dGw2 kw4g== X-Gm-Message-State: AC+VfDx3Ay3MPpKoScj3XefO4PCSXi1wa9tQZOeM5EKfV5WIr4RDeL2X P9Sb6fgMtynmBhvXN7dIHZJC3LiifQ4= X-Google-Smtp-Source: ACHHUZ6UOA1UEJhODzAvIyiNHCg4anOQmr91WME3HC/ntTLIZIcCmlm6eZTphfApwiECNFz0oopiGA== X-Received: by 2002:a92:d142:0:b0:334:9ab1:b3c3 with SMTP id t2-20020a92d142000000b003349ab1b3c3mr5243548ilg.19.1684451202844; Thu, 18 May 2023 16:06:42 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:42 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 3/6] drm: bridge: samsung-dsim: Fetch pll-clock-frequency automatically Date: Thu, 18 May 2023 18:06:23 -0500 Message-Id: <20230518230626.404068-4-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Jagan Teki , Andrzej Hajda , Chen-Yu Tsai , Adam Ford , Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make the pll-clock-frequency optional. If it's present, use it to maintain backwards compatibility with existing hardware. If it is absent, read clock rate of "sclk_mipi" to determine the rate. Since it can be optional, change the message from an error to dev_info. Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index bf4b33d2de76..6f012016068a 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1712,11 +1712,11 @@ static const struct mipi_dsi_host_ops samsung_dsim_ops = { }; static int samsung_dsim_of_read_u32(const struct device_node *np, - const char *propname, u32 *out_value) + const char *propname, u32 *out_value, bool optional) { int ret = of_property_read_u32(np, propname, out_value); - if (ret < 0) + if (ret < 0 && !optional) pr_err("%pOF: failed to get '%s' property\n", np, propname); return ret; @@ -1726,20 +1726,29 @@ static int samsung_dsim_parse_dt(struct samsung_dsim *dsi) { struct device *dev = dsi->dev; struct device_node *node = dev->of_node; + struct clk *pll_clk; int ret; ret = samsung_dsim_of_read_u32(node, "samsung,pll-clock-frequency", - &dsi->pll_clk_rate); - if (ret < 0) - return ret; + &dsi->pll_clk_rate, 1); + + /* If it doesn't exist, read it from the clock instead of failing */ + if (ret < 0) { + dev_dbg(dev, "Using sclk_mipi for pll clock frequency\n"); + pll_clk = devm_clk_get(dev, "sclk_mipi"); + if (!IS_ERR(pll_clk)) + dsi->pll_clk_rate = clk_get_rate(pll_clk); + else + return PTR_ERR(pll_clk); + } ret = samsung_dsim_of_read_u32(node, "samsung,burst-clock-frequency", - &dsi->burst_clk_rate); + &dsi->burst_clk_rate, 0); if (ret < 0) return ret; ret = samsung_dsim_of_read_u32(node, "samsung,esc-clock-frequency", - &dsi->esc_clk_rate); + &dsi->esc_clk_rate, 0); if (ret < 0) return ret; From patchwork Thu May 18 23:06:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247500 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D9C6C77B73 for ; Thu, 18 May 2023 23:06:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB60110E571; Thu, 18 May 2023 23:06:47 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 305D510E571 for ; Thu, 18 May 2023 23:06:46 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-3381a0cae92so20611915ab.0 for ; Thu, 18 May 2023 16:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451204; x=1687043204; 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=4o9sUAx3iK/A4vzjmFl/tQ6LFFXKGPJqcsBJSVqCXEY=; b=neaX1AsZMi4JgHzRyfIozgwJkv0FHSm6o2KaeG8oqw6uC6x7lCfn4Ki/4zzqGlEnya M0BuBiOj1lP7uaTnPY5que/47wI7qw7Ve/rH9kZMXmnc5cbq951KZ2i47NpVR3KPfO+P WnpunmjsKVfR+txcol9AxWoV1vEFS8n1T1X03Dyyjb7iLjzik9w5eeV1/prjhqy2nDpk EcgmWnwfGhByiNjV6yjOcR0CIkEfMYCzFAiKcxfQmGMUdKb3vyHwvpiw4RULlmGbIoIE uOQBFKvyXm//KalxwaUBmOoYpXwWj8NEVaiuEkp/S1BVHSXwQ2W2NQZkAtcsllmVRfTV rMoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451204; x=1687043204; 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=4o9sUAx3iK/A4vzjmFl/tQ6LFFXKGPJqcsBJSVqCXEY=; b=AnzdQTBKYI88sahs7D7tMEMB47jNePEAdauzKsZs9SLWNU1PZA5d07DZ4reResn1U9 fWopfWWgjKiLWwC/gTVhvUDcocLIP1NiXYkGjt1+CI3JxCzvHdT9oSXr6bWjlW6DbTvY WgCvjmjANOz5QfEPllmlMDfX5KdSA07BM45guY90b77OCjiciEfF+PE6dEiC7fjCHAdd Bth7OMjIwrwkV43DtWWS2Re6/zGnPNwMsZ5whRVP+qiOpOjt9pVI90zC3IVy2CS/k2YS jTCuJvk//cmLTIm0lzyKtQbiReHst1yQKDxSfHZSDBXn9GP6t93Yo9IZPA+sp29AzCFD eXLA== X-Gm-Message-State: AC+VfDzMrOh3lYc7aWTZ4yMXEaLJw664OA5v6aLzDv4AbV9Vc6vXNOlm 9V5qD+DRrf+SlWGOQxmMiFhwZlErFFk= X-Google-Smtp-Source: ACHHUZ49jytJKEuT745t6jx63iNJD9VDzHUyMD5fg/bxd46QCh04b8HvC+o6yRsw5Kn3S5qQd5r04Q== X-Received: by 2002:a92:c952:0:b0:337:83fc:43c8 with SMTP id i18-20020a92c952000000b0033783fc43c8mr5814594ilq.10.1684451204474; Thu, 18 May 2023 16:06:44 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:44 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 4/6] drm: bridge: samsung-dsim: Select GENERIC_PHY_MIPI_DPHY Date: Thu, 18 May 2023 18:06:24 -0500 Message-Id: <20230518230626.404068-5-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Laurent Pinchart , Andrzej Hajda , Chen-Yu Tsai , Marek Szyprowski , Adam Ford , Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to support variable DPHY timings, it's necessary to enable GENERIC_PHY_MIPI_DPHY so phy_mipi_dphy_get_default_config can be used to determine the nominal values for a given resolution and refresh rate. Signed-off-by: Adam Ford Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Chen-Yu Tsai --- drivers/gpu/drm/bridge/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index f076a09afac0..82c68b042444 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -227,6 +227,7 @@ config DRM_SAMSUNG_DSIM select DRM_KMS_HELPER select DRM_MIPI_DSI select DRM_PANEL_BRIDGE + select GENERIC_PHY_MIPI_DPHY help The Samsung MIPI DSIM bridge controller driver. This MIPI DSIM bridge can be found it on Exynos SoCs and From patchwork Thu May 18 23:06:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247501 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 668ADC77B7D for ; Thu, 18 May 2023 23:06:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C9B810E57A; Thu, 18 May 2023 23:06:48 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EC9910E571 for ; Thu, 18 May 2023 23:06:47 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-333eb36e453so6051745ab.3 for ; Thu, 18 May 2023 16:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451206; x=1687043206; 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=yt5KFw+xtdIb6VItu3DPNGmoCpleoJEIyPuwXXhva2M=; b=ZcATbFkprZeFTNuSJqhxSUZTj8gzDbNC/xotilvBhiqsd7QSqMSDRlsOucCBzqXZyI XYouvbGfy4ahQndKyeE3b4McfpFsCkVne6kX591hEGmbntrkFhdAVjCmhbokhuWzV6Qb anxwWcjMkXR4e51VGHvVXIHkOzVOyAtFr3pGDTBEmEQR/MtlznidBh0F+I34vf4J1Qm6 Nncs08OSkIf5QPK2hFekbTNfMI+9kaRRcjiztdhB7bKKdRB2YhxblcBs7dq+9Z/N13f2 Caxw69r1Z4ec5gN6TN+eFIxmzt01LxDa4B25itUC9/dOkGKbIpAkmpscavvVIq29yNiO ksuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451206; x=1687043206; 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=yt5KFw+xtdIb6VItu3DPNGmoCpleoJEIyPuwXXhva2M=; b=knmiXpypFfICc3gD8C9Sxhq6owmxN/5jmUS9V1cQEBrG7GqwogEamJ266/nkJXe4x7 KjwaS07z7+2YAPsttAuf8DhW4KocyQ/BZjKTewrSlzD5vcZCAYOL6a5lInY3Ad+9oscd Pvl4yWkyN+KjFgpiRaxf7HdjYG1ofEyHctmbeWXR92GeRpw2OQF3vXoxmKZ5VUmlaXp8 ESOQvRZmuSJFUuJk6gy2BlxpWxIzmjj61L08tJ5X8DT9T7Lwja24/PMlHGrv9IEYKW8c YZlLSjld2Qa6TSL0ltvitP6y06hDQiA1xE22BwE60wUz6MuTi4tGU7W/hp+i8p9CwVkA PIRg== X-Gm-Message-State: AC+VfDynJuEEyVkqVZ0au7MA/T37PGEIoUy7S23e5gYCL5Hu+WCYB6o0 Y5gTTaINKqZOS9hfijtZPzlxCeaMlmM= X-Google-Smtp-Source: ACHHUZ5NbInxQjiFLvVmnfh4z2rBRQlHrQv7f27IaNSKoLF9oRFxNaXcgXpzysKjyTOVjwElBGURAw== X-Received: by 2002:a92:d90c:0:b0:338:98a9:3898 with SMTP id s12-20020a92d90c000000b0033898a93898mr91909iln.21.1684451206258; Thu, 18 May 2023 16:06:46 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:45 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 5/6] drm: bridge: samsung-dsim: Dynamically configure DPHY timing Date: Thu, 18 May 2023 18:06:25 -0500 Message-Id: <20230518230626.404068-6-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Michael Walle , Jagan Teki , Andrzej Hajda , Chen-Yu Tsai , Marek Szyprowski , Adam Ford Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DPHY timings are currently hard coded. Since the input clock can be variable, the phy timings need to be variable too. To facilitate this, we need to cache the hs_clock based on what is generated from the PLL. The phy_mipi_dphy_get_default_config_for_hsclk function configures the DPHY timings in pico-seconds, and a small macro converts those timings into clock cycles based on the hs_clk. Signed-off-by: Adam Ford Signed-off-by: Lucas Stach Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Michael Walle Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 58 +++++++++++++++++++++++---- include/drm/bridge/samsung-dsim.h | 1 + 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 6f012016068a..e67e501c9d49 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -218,6 +218,8 @@ #define OLD_SCLK_MIPI_CLK_NAME "pll_clk" +#define PS_TO_CYCLE(ps, hz) DIV64_U64_ROUND_CLOSEST(((ps) * (hz)), 1000000000000ULL) + static const char *const clk_names[5] = { "bus_clk", "sclk_mipi", @@ -651,6 +653,8 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi, reg = samsung_dsim_read(dsi, DSIM_STATUS_REG); } while ((reg & DSIM_PLL_STABLE) == 0); + dsi->hs_clock = fout; + return fout; } @@ -698,13 +702,47 @@ static void samsung_dsim_set_phy_ctrl(struct samsung_dsim *dsi) const struct samsung_dsim_driver_data *driver_data = dsi->driver_data; const unsigned int *reg_values = driver_data->reg_values; u32 reg; + struct phy_configure_opts_mipi_dphy cfg; + int clk_prepare, lpx, clk_zero, clk_post, clk_trail; + int hs_exit, hs_prepare, hs_zero, hs_trail; + unsigned long long byte_clock = dsi->hs_clock / 8; if (driver_data->has_freqband) return; + phy_mipi_dphy_get_default_config_for_hsclk(dsi->hs_clock, + dsi->lanes, &cfg); + + /* + * TODO: + * The tech Applications Processor manuals for i.MX8M Mini, Nano, + * and Plus don't state what the definition of the PHYTIMING + * bits are beyond their address and bit position. + * After reviewing NXP's downstream code, it appears + * that the various PHYTIMING registers take the number + * of cycles and use various dividers on them. This + * calculation does not result in an exact match to the + * downstream code, but it is very close to the values + * generated by their lookup table, and it appears + * to sync at a variety of resolutions. If someone + * can get a more accurate mathematical equation needed + * for these registers, this should be updated. + */ + + lpx = PS_TO_CYCLE(cfg.lpx, byte_clock); + hs_exit = PS_TO_CYCLE(cfg.hs_exit, byte_clock); + clk_prepare = PS_TO_CYCLE(cfg.clk_prepare, byte_clock); + clk_zero = PS_TO_CYCLE(cfg.clk_zero, byte_clock); + clk_post = PS_TO_CYCLE(cfg.clk_post, byte_clock); + clk_trail = PS_TO_CYCLE(cfg.clk_trail, byte_clock); + hs_prepare = PS_TO_CYCLE(cfg.hs_prepare, byte_clock); + hs_zero = PS_TO_CYCLE(cfg.hs_zero, byte_clock); + hs_trail = PS_TO_CYCLE(cfg.hs_trail, byte_clock); + /* B D-PHY: D-PHY Master & Slave Analog Block control */ reg = reg_values[PHYCTRL_ULPS_EXIT] | reg_values[PHYCTRL_VREG_LP] | reg_values[PHYCTRL_SLEW_UP]; + samsung_dsim_write(dsi, DSIM_PHYCTRL_REG, reg); /* @@ -712,7 +750,9 @@ static void samsung_dsim_set_phy_ctrl(struct samsung_dsim *dsi) * T HS-EXIT: Time that the transmitter drives LP-11 following a HS * burst */ - reg = reg_values[PHYTIMING_LPX] | reg_values[PHYTIMING_HS_EXIT]; + + reg = DSIM_PHYTIMING_LPX(lpx) | DSIM_PHYTIMING_HS_EXIT(hs_exit); + samsung_dsim_write(dsi, DSIM_PHYTIMING_REG, reg); /* @@ -728,10 +768,11 @@ static void samsung_dsim_set_phy_ctrl(struct samsung_dsim *dsi) * T CLK-TRAIL: Time that the transmitter drives the HS-0 state after * the last payload clock bit of a HS transmission burst */ - reg = reg_values[PHYTIMING_CLK_PREPARE] | - reg_values[PHYTIMING_CLK_ZERO] | - reg_values[PHYTIMING_CLK_POST] | - reg_values[PHYTIMING_CLK_TRAIL]; + + reg = DSIM_PHYTIMING1_CLK_PREPARE(clk_prepare) | + DSIM_PHYTIMING1_CLK_ZERO(clk_zero) | + DSIM_PHYTIMING1_CLK_POST(clk_post) | + DSIM_PHYTIMING1_CLK_TRAIL(clk_trail); samsung_dsim_write(dsi, DSIM_PHYTIMING1_REG, reg); @@ -744,8 +785,11 @@ static void samsung_dsim_set_phy_ctrl(struct samsung_dsim *dsi) * T HS-TRAIL: Time that the transmitter drives the flipped differential * state after last payload data bit of a HS transmission burst */ - reg = reg_values[PHYTIMING_HS_PREPARE] | reg_values[PHYTIMING_HS_ZERO] | - reg_values[PHYTIMING_HS_TRAIL]; + + reg = DSIM_PHYTIMING2_HS_PREPARE(hs_prepare) | + DSIM_PHYTIMING2_HS_ZERO(hs_zero) | + DSIM_PHYTIMING2_HS_TRAIL(hs_trail); + samsung_dsim_write(dsi, DSIM_PHYTIMING2_REG, reg); } diff --git a/include/drm/bridge/samsung-dsim.h b/include/drm/bridge/samsung-dsim.h index a1a5b2b89a7a..d9d431e3b65a 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -93,6 +93,7 @@ struct samsung_dsim { u32 pll_clk_rate; u32 burst_clk_rate; + u32 hs_clock; u32 esc_clk_rate; u32 lanes; u32 mode_flags; From patchwork Thu May 18 23:06:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13247503 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EE94C7EE29 for ; Thu, 18 May 2023 23:06:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 32BEE10E57D; Thu, 18 May 2023 23:06:58 +0000 (UTC) Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 92D4E10E57C for ; Thu, 18 May 2023 23:06:49 +0000 (UTC) Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3352b8b9b70so640335ab.0 for ; Thu, 18 May 2023 16:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451208; x=1687043208; 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=ecbFuD3QxPryZIrTro3PTU8NirrT9CMhiKMvVewbmus=; b=DRlxu1K3ekyZ0+ZqWmJVHzlHiDTU/lo4ajzaQcfzIQ9w1xTidojcidM1YQuCK2BO3F tqm+ZiwKQY+HABU4Gtw4HBJqm1lPIhMSRQVWSSfHI0TfIILXKQfiTma7bcZcKU4cpe1T b/THWyOPH0DhPnmIn4G7LUBvawe7uAdL0LPUXnLKqFZaCVLBIJSV2og0thMmAsYuxC2P 3Hyyq5OWSb23+2Sl5QlQpW9fo4ESjElOEK1y0WYt26MJIW1+/sdM+FwA6K7xozxPAY3D RqhIyb5DLxH8L94aYNtw9AiqseUpIkFPBmnUqaFcRAM9cna6safTrKkf3sUlV4SoOoj1 JdOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451208; x=1687043208; 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=ecbFuD3QxPryZIrTro3PTU8NirrT9CMhiKMvVewbmus=; b=XP0cId4SrpOXP6FpMuoV4ltZlXBm9Pd1uEoPKpgB54vItgn/cXIJ94dRPP5otXAhTr KrKv/1B8+Z5wMO7Z4ieUdmRK00DdRYkdNBC9eVoU77hi5MGzL+lnsTDrhijaWAnWSnwq sWcCGXVFsT8UwvewDcc0oWKhp29nLp144o7Yuo+du9YGDWgbqNOyZHlcjWnmP2qUHRKd M279ucedjZ0PWpqoZF91T+C1qqN+CUV4/oqq0i7vqr08tfo29jL1arFQQR4GlW8u8Mex O7uhMOQ1BbGitFLPnwYXKoZkaOWwoMjVWnJSZ3K0CJ42spRQ8lJkO+UeGFQYNUxJspa6 HrTg== X-Gm-Message-State: AC+VfDwJTcIFC9EgMpMZSSOtUewTG8kJSMYwSAwflD5XAlT4myV3D4a4 CKBcE5dZC2ueccSp+6QYZaASJXZidQM= X-Google-Smtp-Source: ACHHUZ7xxlTDd296VQu9FJNR9Sswd4fc/CWekUdUKsFWsPmNwCOk9oswNovfBbTnLqqMQbRGdIkIRg== X-Received: by 2002:a92:ac11:0:b0:334:fa57:e670 with SMTP id r17-20020a92ac11000000b00334fa57e670mr4397461ilh.0.1684451207938; Thu, 18 May 2023 16:06:47 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:47 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V7 6/6] drm: bridge: samsung-dsim: Support non-burst mode Date: Thu, 18 May 2023 18:06:26 -0500 Message-Id: <20230518230626.404068-7-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , Laurent Pinchart , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Jagan Teki , Andrzej Hajda , Chen-Yu Tsai , Adam Ford , Marek Szyprowski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The high-speed clock is hard-coded to the burst-clock frequency specified in the device tree. However, when using devices like certain bridge chips without burst mode and varying resolutions and refresh rates, it may be necessary to set the high-speed clock dynamically based on the desired pixel clock for the connected device. This also removes the need to set a clock speed from the device tree for non-burst mode operation, since the pixel clock rate is the rate requested from the attached device like a bridge chip. This should have no impact for people using burst-mode and setting the burst clock rate is still required for those users. If the burst clock is not present, change the error message to dev_info indicating the clock use the pixel clock. Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index e67e501c9d49..9eda8ecc4151 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -660,11 +660,21 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi, static int samsung_dsim_enable_clock(struct samsung_dsim *dsi) { - unsigned long hs_clk, byte_clk, esc_clk; + unsigned long hs_clk, byte_clk, esc_clk, pix_clk; unsigned long esc_div; u32 reg; + struct drm_display_mode *m = &dsi->mode; + int bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); + + /* m->clock is in KHz */ + pix_clk = m->clock * 1000; + + /* Use burst_clk_rate if available, otherwise use the pix_clk */ + if (dsi->burst_clk_rate) + hs_clk = samsung_dsim_set_pll(dsi, dsi->burst_clk_rate); + else + hs_clk = samsung_dsim_set_pll(dsi, DIV_ROUND_UP(pix_clk * bpp, dsi->lanes)); - hs_clk = samsung_dsim_set_pll(dsi, dsi->burst_clk_rate); if (!hs_clk) { dev_err(dsi->dev, "failed to configure DSI PLL\n"); return -EFAULT; @@ -936,7 +946,7 @@ static void samsung_dsim_set_display_mode(struct samsung_dsim *dsi) u32 reg; if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { - int byte_clk_khz = dsi->burst_clk_rate / 1000 / 8; + int byte_clk_khz = dsi->hs_clock / 1000 / 8; int hfp = (m->hsync_start - m->hdisplay) * byte_clk_khz / m->clock; int hbp = (m->htotal - m->hsync_end) * byte_clk_khz / m->clock; int hsa = (m->hsync_end - m->hsync_start) * byte_clk_khz / m->clock; @@ -1786,10 +1796,13 @@ static int samsung_dsim_parse_dt(struct samsung_dsim *dsi) return PTR_ERR(pll_clk); } + /* If it doesn't exist, use pixel clock instead of failing */ ret = samsung_dsim_of_read_u32(node, "samsung,burst-clock-frequency", - &dsi->burst_clk_rate, 0); - if (ret < 0) - return ret; + &dsi->burst_clk_rate, 1); + if (ret < 0) { + dev_dbg(dev, "Using pixel clock for HS clock frequency\n"); + dsi->burst_clk_rate = 0; + } ret = samsung_dsim_of_read_u32(node, "samsung,esc-clock-frequency", &dsi->esc_clk_rate, 0);