From patchwork Fri Sep 13 09:55:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3482 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E8F1B411AB for ; Fri, 13 Sep 2024 11:57:19 +0200 (CEST) Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5365c0e2eafsf1522576e87.3 for ; Fri, 13 Sep 2024 02:57:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1726221439; cv=pass; d=google.com; s=arc-20240605; b=f+y7os7P1UgQwtAWI43pvZVcLyffu6WzRA89s8nMmf0c1/K/dUeogml6Twc7z5OtN8 cWMOilPI1d8qBqvhk+9sWn/0NwFmZ8gdpcZ04uSv/M7YsooDlnZwy39YO7arocw522xM 630dzBIeWhI+2S9tOmK06Nz6GNcchaUxB02yaJXkKtGGuOlNW38IWuQaX+A+m4yJjN7F OMn+8/SfTiFM+TaO6cvY201W4tP3fBUEcmNcSMFDQ4ZRP1+nb+cq30JWTw6teAIzAAsZ Ua9KXOQepFS6CbRjQLjSdJsrrYxx0YykIw8fyS344JLd1cF+7HOLR285NTGfQTc9RiV/ D4xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=uL1OoYs/gKTsf7H88WOjiuFVhJ01U/C6euw1ZPjpcDw=; fh=hobjEWrsUDIGN8ryMLMc2xDg//12+SUIX2969R27bYc=; b=YbN+m9aBy0PRR1ItsbAZ2KfMbhEtMdHN8/7XH1KyDVwUeWB/m3W6F05rSjX88xEfnr 2UFASlvCBq1W8JYTYF8gFl2/IUqq8IRMVYPcBGg2zWzTc6tOurgHXBEPWTGLkmq2Blbz U7QpnWvm619Bqpb8/vWdAf1lhGh4ZOm2HzFa1vyNH7SsmbuqfKRAdDTmVJLZTC6mVjdy TVZGwqb2w08RpFVnCqeIx6FZwtSe/VHkUwcQAHN89ft6jeEp537MGjZ+5zdgGvw63tvb i3b1Z+04SzJibu+ovIzC4DOmxAc2aywgTNA8zbMRCaGnoCp5YAJ6uygxQJYINCSrl8qi Wv1g==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WSjPthxs; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1726221439; x=1726826239; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=uL1OoYs/gKTsf7H88WOjiuFVhJ01U/C6euw1ZPjpcDw=; b=lt/gXSGdkIjVJddmy4FPL+FrhNiFxzQOIHdTW/ZPLJbeQTk3vZRDG7i/V5fVnv/LmW JUTKfB0Lg+nE+JDWCkuEfizGRwhY3UWAkHAMADDhD0rcWS/9e255M/nmNG6kIJY5+tq0 lHZWoTS54kpo8ZiIYBVqyRMVbParl8REPp8m8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726221439; x=1726826239; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uL1OoYs/gKTsf7H88WOjiuFVhJ01U/C6euw1ZPjpcDw=; b=mpPSHTj0VVfpnintO9oXfX9/Zl/R5YvFUnwSIso864MnyG6y+erPwXZM9ppNZVNdaa /7o3R1hWDycNKhjp79X7VZ+31Lz/iFlBHtG6m4lWq9UUiLKSzprFgS+V4swbTeZq0V3f zRohyF/OpmhrFRi/VHzosYFuCRjFEnecusuPiTvRe9HdP1jr2VFasxK3sJd8tGsQqJBA gx+UBq3SDVNuT1rPfN2HAyEAPFKYC3nNYrKMKqHO1ASdkh8jie4MgW1TLud9Q+xNZ/81 Lqt50SglltAOiIzTxbmTr6ksaThC2Hsmq0YgxsGiKZhSuUVBdcQoPI9i+UAyjrrXQ5Qd ivtg== X-Forwarded-Encrypted: i=2; AJvYcCVPQAxgMH8P32tb+Qhr5u2Cp/FHAytS5TFNoxmEL3K4977PvtZrbKMRZZ7Gp0/2hxVgIy7sn2fKeXScCfeI@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yx4LcvOgl9KKOOk9W3oAhcaL12D3YPgHf3aa31RrBzGEa47Wcuj WixcLZVt8OA0CVWrzTE3+XkUJOcak2srkJck1zoKWPHANvzvsa8oumn28XVIsOJiQQ== X-Google-Smtp-Source: AGHT+IGOCTIYDZawUnZB9NyicIb2P4oxSmH0/cCHgaXN1IQyZWPsrZHmYIusRb1/RfqEqRHeEwyqJg== X-Received: by 2002:a05:6512:3b0e:b0:536:55ae:7444 with SMTP id 2adb3069b0e04-53678fba506mr3863353e87.22.1726221439171; Fri, 13 Sep 2024 02:57:19 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:3d93:b0:533:482f:afba with SMTP id 2adb3069b0e04-53678e09580ls936445e87.0.-pod-prod-02-eu; Fri, 13 Sep 2024 02:57:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYdorrE3CVxGp2eIgDWLfblczneUOhj2G2Nn/hq35buTrzdvfq4f6y5SzruszQYthNsQiewmRNzaYX8qbq@amarulasolutions.com X-Received: by 2002:a05:6512:3989:b0:52c:8abe:51fb with SMTP id 2adb3069b0e04-53678fb1facmr3560282e87.10.1726221437447; Fri, 13 Sep 2024 02:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726221437; cv=none; d=google.com; s=arc-20160816; b=K2AfTHeVyHIpDgeXZ5/34OKiESQT6T4IvtQ4kQUW9SA1L6H+ZfbM2DHOKxLo57Dy4+ 47qTl9CdwezpBdWGgl8FMR8AZFUfW961AWwzty0XMvYUbCEi15c5ugClE6nRT9X0d0ze Y2DaFazeU+VMSfYt2GXe/augniVJpeFx5G6ZxxXh/sTWPMQzFsl35mjlveTl0w8jEnlQ 6o66FOykW5kWRjjTZwvvHDcd4bPzo8eAhx7WtQkMQtVZeMLTLOCZHRGKhSl+LJBuhKY4 aLlPP0/DguXZt3WY59pmAFaW4PAlRQO9sNP354tjm/o/0wnTDVM1AWpEg1PJy10Qcw/o 8gZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=gwi4cPqbH0Gum7XAARv0sguyMNQwlnsuLBp/em7mdL8=; fh=xJB+ANC/AGIXMJJX+c8UmTT5qBOgEVyMqM/3hAVsxxk=; b=asu10T+gT/R1AZIfKAYUIx3+Zze9Oumk6iuX6aYgLt4zf3RQiLiWX1al7FMH/OIiJj qSLlHBfaF12cOxQUOzyUC+p9SuG0FYqQokl6gebjOguC6TPRm0qy0kK9N9gyySr9YwDI w9nW6yuRVQ3fwUI3P5tof5aBycXd5FIUUvr9bkQqdnolI1qPYAHTGCnZh7UCZPgz6zys JpVpzRT/cIyoWsyObvouyuT7Pvu85TRpDCuwl1ttlzxUNpaeETi9APYcWVejkxEp3YC8 Pb+ogZgbGiATq6JwaQgD2ByISQqgkntXKNcsceao1tzqyfghjtX/yhGOVJ48VLlK6leF y6SQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WSjPthxs; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 2adb3069b0e04-5365f868f65sor4179190e87.6.2024.09.13.02.57.17 for (Google Transport Security); Fri, 13 Sep 2024 02:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCWPQBpxuARAxvqozbV5HFmm/6tb3gIw7xFqxpWeLvqkBXakpji+nODFnpD4Z97PFDvmyQM0oFQMVLAGkxzy@amarulasolutions.com X-Received: by 2002:a05:6512:3f03:b0:52c:cc38:592c with SMTP id 2adb3069b0e04-53678f616demr3681093e87.0.1726221436131; Fri, 13 Sep 2024 02:57:16 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-4-102-18.retail.telecomitalia.it. [87.4.102.18]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cee72bsm863224766b.173.2024.09.13.02.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 02:57:15 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Fabio Estevam , linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Miquel Raynal , Marco Felsch , Vinod Koul , Sakari Ailus , Dario Binacchi , Igor Prusov , Joe Hershberger , Liu Ying , Stefan Bosch , Tom Rini Subject: [PATCH 14/26] phy: dphy: add support to calculate the timing based on hs_clk_rate Date: Fri, 13 Sep 2024 11:55:56 +0200 Message-ID: <20240913095622.72377-15-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240913095622.72377-1-dario.binacchi@amarulasolutions.com> References: <20240913095622.72377-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WSjPthxs; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Michael Trimarchi Upstream Linux commit 22168675bae7. For MIPI-CSI sender use-case it is common to specify the allowed link-frequencies which should be used for the MIPI link and is half the hs-clock rate. This commit adds a helper to calculate the D-PHY timing based on the hs-clock rate so we don't need to calculate the timings within the driver. Signed-off-by: Marco Felsch Acked-by: Vinod Koul Signed-off-by: Sakari Ailus Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/phy/phy-core-mipi-dphy.c | 30 +++++++++++++++++++++++++----- include/phy-mipi-dphy.h | 3 +++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/phy/phy-core-mipi-dphy.c b/drivers/phy/phy-core-mipi-dphy.c index 8fb985a1e682..727c2b040520 100644 --- a/drivers/phy/phy-core-mipi-dphy.c +++ b/drivers/phy/phy-core-mipi-dphy.c @@ -13,21 +13,23 @@ /* * Minimum D-PHY timings based on MIPI D-PHY specification. Derived * from the valid ranges specified in Section 6.9, Table 14, Page 41 - * of the D-PHY specification (v2.1). + * of the D-PHY specification (v1.2). */ -int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, +static int phy_mipi_dphy_calc_config(unsigned long pixel_clock, unsigned int bpp, unsigned int lanes, + unsigned long long hs_clk_rate, struct phy_configure_opts_mipi_dphy *cfg) { - unsigned long long hs_clk_rate; unsigned long long ui; if (!cfg) return -EINVAL; - hs_clk_rate = pixel_clock * bpp; - do_div(hs_clk_rate, lanes); + if (!hs_clk_rate) { + hs_clk_rate = pixel_clock * bpp; + do_div(hs_clk_rate, lanes); + } ui = ALIGN(PSEC_PER_SEC, hs_clk_rate); do_div(ui, hs_clk_rate); @@ -74,6 +76,24 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, return 0; } +int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, + unsigned int bpp, + unsigned int lanes, + struct phy_configure_opts_mipi_dphy *cfg) +{ + return phy_mipi_dphy_calc_config(pixel_clock, bpp, lanes, 0, cfg); +} + +int phy_mipi_dphy_get_default_config_for_hsclk(unsigned long long hs_clk_rate, + unsigned int lanes, + struct phy_configure_opts_mipi_dphy *cfg) +{ + if (!hs_clk_rate) + return -EINVAL; + + return phy_mipi_dphy_calc_config(0, 0, lanes, hs_clk_rate, cfg); +} + /* * Validate D-PHY configuration according to MIPI D-PHY specification * (v1.2, Section Section 6.9 "Global Operation Timing Parameters"). diff --git a/include/phy-mipi-dphy.h b/include/phy-mipi-dphy.h index a877ffee845d..1ac128d78dfe 100644 --- a/include/phy-mipi-dphy.h +++ b/include/phy-mipi-dphy.h @@ -279,6 +279,9 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, unsigned int bpp, unsigned int lanes, struct phy_configure_opts_mipi_dphy *cfg); +int phy_mipi_dphy_get_default_config_for_hsclk(unsigned long long hs_clk_rate, + unsigned int lanes, + struct phy_configure_opts_mipi_dphy *cfg); int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg); #endif /* __PHY_MIPI_DPHY_H_ */