From patchwork Wed Dec 2 10:26:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 5115 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3A2DF3F336 for ; Wed, 2 Dec 2026 11:27:51 +0100 (CET) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-499db0932f7sf14205035e9.0 for ; Wed, 02 Dec 2026 02:27:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1796207271; cv=pass; d=google.com; s=arc-20260327; b=hsig2/IPBsDcJLVwCbV+NWcVh/1ZnfjJSzJwLXlXGgg4QSP82LpqvTjstvcD+HveAk QFApSfjyDxCwg5kPsUxoV89sybNpz/VZ/azwYnhddhURX8m4dWlql7K09Ab4ubnmnzYR +uQ6BGm5Vb8Ap500irioRJjj39vodyBoRcutrIw0M05R+ukqc9MbqUhQZ4S1OZ2+UrUy QEWfkxWuY14Gr24tSZjkS9E0m15yKW7jBTbG5W8bYszyJIqjoiW+KaLhc1aUc+6qRkPh JjUg4lGsqO3sOLsYokF89xThghu3bCYDh1baNuENlM9636Wy0c+4Z5JHq82Sp5mCSUF8 +WFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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=pvky5UfxUmehGm/FujQeAZWrNWypVGQYXp3VXCbgal8=; fh=m5joHCl1uHYc6t/R1iQcdw2Fmo+9bOsklQXulUPL4M4=; b=fa4ckp5TB1q12JAMcNeDLUrA9zFOjvvAquUe63Zr7M/9reZ1aWKh+uFzyAywYPAo9V jsx407LcefabLXRkiQGhJ9Gcwf5F5Zooxll249whFqgyiTB9W5M13Oqs0kOtOD72kkZp FyUNv1pJP/JZmY4dBO/aquDAyPuTmkKK1pc4VEZl7yIPq0q35HZol6yFXwvOLpF6hGb2 IC9GoefxhxjCm0XPUNgmJ5isuooQFyZJsyN8UAwiYp+o0zvcHZy4oSJUmiQK+43ZRfrU 1H88J1u9fDymJ79Nc86zP3LwTAJGUitWnKY8+RW0t9GmkAHYdG/d8v8yfuXzI776+sFV iedA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LfFE+G4Z; 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=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1796207271; x=1796812071; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-type :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:content-type; bh=pvky5UfxUmehGm/FujQeAZWrNWypVGQYXp3VXCbgal8=; b=PR1IkW52+aKdW8aiGmSwy7rW4dWqsiso2RwudDEHX6C3TN1Ki5qA5GZOrg/4JO/spM WqYVK6F2W29jfPuSPZjFkg54UvfA+Tn5TWB4x1MOaK1bboRBJoYX1Yi//UoSbUf9t3iN iJhSFmzopa9tVbQ3q75rvzatohDXuVbM/cYeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796207271; x=1796812071; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :content-type:x-original-authentication-results:x-original-sender :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-gg:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pvky5UfxUmehGm/FujQeAZWrNWypVGQYXp3VXCbgal8=; b=BZl3zLSNf53T/N1L2AQqP6aZ3oibUZuQATP1pilIW267YsvIxtw9cADksjumwQRqAs M5QvNRZxk7rGsCWa+KLdghQPZoKMv9D4WO3z4ru5hg+Td5goP3feCxyScohqMpnCIXuT hxz+qzTQ8A0+ehmf7Oijx7lHqKz3Ig0SLyC6tAQZ03L2oB8tyKrs9yUS0WN4Gjb5nRtA 9UAI6Yk9fLxsMl2u3lp/I+wQ1xLLS1Q9OlImEMnPAgxJaH1wt9NPaO3aHvk4LWJAlTb7 eHqvSmHbGsj9upLTpddyvcEzESF4Ywhb+qrpxJBLAKvUnWLPl5p8yOWI8o9yGNSlxWCR smSw== X-Forwarded-Encrypted: i=2; AL+hErHNiAl26tqNamDYy8jerb65ZBNxIdypMi3UUM8zb7+bqEbN9XITabqSptAbiCzlLg+pFE9A2VnLVP+tWhUn@patchwork.amarulasolutions.com X-Gm-Message-State: APuU4Z+nWOmlkbshANX/IdYwlEHGs6aIZPel3aBEYia5Ujyqv2cvpHg+ 7sy3LuHv57Jsmypkkeo5tIkjMKPUL3q389/lPvaR/iI9ZnMt7av5UxRuuV0rVd33f5Ks1w== X-Received: by 2002:a05:600c:2909:b0:4bb:b39d:d447 with SMTP id 5b1f17b1804b1-4bbb39dd4famr269550995e9.1.1796207270812; Wed, 02 Dec 2026 02:27:50 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLddHooI/oeGZbMWPGsAFXaEUTVWz9k4bJalslo8A/DipyQ==" Received: by 2002:a05:600c:5253:b0:4bb:6c7b:62aa with SMTP id 5b1f17b1804b1-4bb8926e243ls100782845e9.1.-pod-prod-08-eu; Wed, 02 Dec 2026 02:27:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGODiI0rI1Ld1GWGOJ2oyvaLcGRqNq0mFVNuY/yzzdvbarWU1kMpDckt6wH/ntODD4+ShXmUwqUI2Rpcd+z@amarulasolutions.com X-Received: by 2002:a05:600c:a085:b0:4a2:526b:d410 with SMTP id 5b1f17b1804b1-4bb8881092bmr798682825e9.13.1796207269378; Wed, 02 Dec 2026 02:27:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796207269; cv=none; d=google.com; s=arc-20260327; b=cLLY+3//mAMkgbd029C5PMYavpmFt0EJ6ksAy1155v8zWnV7isTHoiFFotkSnf9Map /+2jWobj/zAUTEzo04NyUoQDwyHkWA8eyRhQNiCFPuBYhNX4tlX0EUcgErVH/CpUZb0e 423t/apn9LdVjQu9P/dx6B7N3wN+kcRsr7dXxj/rJnP3u5OBEBHivtk2c4VjSat/CCqx K867UjitFiM4Q3f+nTEeC43LLMD5DzRkLw9Kg+KmJsylrggm/pDgUqhTo1nBkBw1Cmvs WRskI/HWddZg4hyeCOKl42U9nHpbs4pI1jfMNIZbNjQ33ZmP2BDVl34osN3T81tqIhsY sB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=j1HCAYoYh+vqUm2c3fTDbTb0oiKPVG2Nfb1gIHjtQYY=; fh=8tJeQpmJA2XsqfevO2RL69Mk2P3wTKB2hlTo9Bst1l8=; b=OIo2mQSALS7dNHQzf2v8RtAFyu7aFWPmLmBrNC7Ih84CQEeNJdQWw+ODvuNbSVfi/e 9Azrwji6JLRrYDTW8hqMWQztRFlqGPi/HzhnU0oSZ2WcG6sy24l4s8yrxHrEMEtclNf3 ZRyOkggNbO97taR6xyqR+9WAagL8cbjfLJXDTwtVJWjQt0nRe+MIpUBRr5UufvZzgTzQ zMne73Jp0HJtaBbkEoRr+R7PEvqaewc+JoZOHiGf6JD6dIjR2YyZHlodKmhoR1ImNitT sD9oJmlSodl2bGU5gx75hHIrLzsAItVGOZBzlCR3jIyED2MwgNIDBEtYeaQv6XKkTuHY dA9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LfFE+G4Z; 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=neutral 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 ffacd0b85a97d-4ab70b054f8sor6012530f8f.6.2026.12.02.02.27.49 for (Google Transport Security); Wed, 02 Dec 2026 02:27:49 -0800 (PST) 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; AL+hErE73GEgHic01Ad0j9N9qUZZLSJJ31+HKJuNDiNsNh3TnnlOP/BYcFchmEBc7Ph0mxL6bLGKGZH0V5rV1rx+@amarulasolutions.com X-Gm-Gg: AZFdTZe8fqSE9qYUSByopy0t7g0QvED+pWqehi70U8lc2HXHNBk9fBOoNDVY3Z61DQl bigmTM0PIbPU07Fd8wMf8fDCktNrM2UdGA3WaSh7dxDXQFGDckX8Uo465q6S1qkW6jwv1V/QD9B R1onXTOjyMEWbjPhkesTycMnaoThQBjwoJ+wun+kQz4B/uf7LsmwGgTI4VQpwHe5ZjIQimfvyqX tLVU9ZzOqd4yeJJi+TiKOzkEv5Mh9SOQSqswmqF6YizqolCweo6cEQMAa8JpJ4bBQGdB+iFZKrL f59sad8OA++lyxT35Vcgmr7VUMmFsU8H2VbPKwXOpBJ5VM6VPWEORvCvtWloGo8zDihKI9ih8f0 nlMvz4xX00m3iryER+DNpYqFVotzbKrFoFS/+zyeM9w7+FJhvnDkNUtx+bJgtM2rBnhb0mQRcwu Zi8iuvtyQ3wNVwtuBXRBQsju14gnTBekDXINMZ4v23kD/GgT7q8Rry9v1LhejExZVY04WNPr3rW IqwyivuJHVsZSQ2WoESM5sPSMhpAgdrI5xR2Ye2MF5MLg+Or6z//PR0CKFabhnWKK8+lYA86Yes y83po1BwbvEciw/noCHYnVWmx1Q0L5nV9COMG5winhtEHL8+vmjuIE1YWBdN69cQ09m0cTXFvUO cxQ3r1CHL8vZHjKgQWCcf X-Received: by 2002:a05:600c:154e:b0:4a3:59ee:86b with SMTP id 5b1f17b1804b1-4bb887c3b63mr820376455e9.4.1796207268901; Wed, 02 Dec 2026 02:27:48 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6474:ebbf:6962:3ebc:7df:e6bf]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbbaeb1e4csm366823865e9.13.2026.12.02.02.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 02:27:48 -0800 (PST) From: Dario Binacchi To: u-boot@lists.u-boot-project.org Cc: Heiko Schocher , linux-amarula@amarulasolutions.com, Peng Fan , simon.holesch@bshg.com, Marek Vasut , Valeriy.Yatsenko@bshg.com, Leonhard Hesse , michael@amarulasolutions.com, Miquel Raynal , Marco Felsch , Vinod Koul , Sakari Ailus , Dario Binacchi , Joe Hershberger , Tom Rini Subject: [PATCH v3 15/26] phy: dphy: add support to calculate the timing based on hs_clk_rate Date: Wed, 2 Dec 2026 11:26:26 +0100 Message-ID: <20261202102716.572884-16-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202102716.572884-1-dario.binacchi@amarulasolutions.com> References: <20261202102716.572884-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=LfFE+G4Z; 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=neutral header.i=@amarulasolutions.com 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 --- (no changes since v1) 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_ */