From patchwork Wed Sep 11 15:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3445 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 704234354D for ; Wed, 11 Sep 2024 17:10:57 +0200 (CEST) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-374bb1e931csf550015f8f.0 for ; Wed, 11 Sep 2024 08:10:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1726067457; cv=pass; d=google.com; s=arc-20240605; b=TUa5+WKcsLaLeLiJ9o1e/SZFXstXryeT1/XjA2/1V6YgSc/yMs5BNa6UnUoX/LJAX8 PmrzclbqnqZnpFAJVeQvJBdzImJFNViY0/RP/CpW5JpqhVzksslejisAhWc7F6k/kkXG ndu7+8mLoFU/KxWKvrFCKhRPBi5BLHqDPzEubA0NaTj9/i2X81OLJAX3z8LjDc+DvRvo EDfYvvhCAA1ndOJVuAXqM17zgnjpNQBXFBYyeNhZv6Nz/Lz+vWhx7DBnFJSppk/cUB6n VldMoiHzKozIDBDnBVk1KHz2uMHgLmYcfHCrJkdiWXt/bD/IQazXpFL3L2UpjKz1Y+JX ufww== 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:to:from:dkim-signature; bh=k06/0Ab/FgDmzjsB1xNXwl8FQ2gso+evSdFzyXi39N8=; fh=mFJEKEGp7P0rJtdXaPikBf9TXSAZiee3Xr1Q+dL2tNE=; b=Vt7jtAtceFo447uOirA7ketJDPz0PgbTULbRB+PqXOHxs5XBdaVuPanQ/KOzMB9JyB yV1n0JjovlK1h1InXbw0t8mXCx9eBg8fSToDh97M73blGZxZezFw9OSqFcreAdXagT6I FV5JLvsQPXsiKK5gHpsZA2Minm/UzeVzKdOOnngZU4ggi0eOW1zNZ/iODekfIwCwM9jL 0IRRRk3PolSIz8eIMAjhsKyYE3cmQO16Y39XEELsI7qFzbYTutzS2f3Fa/ZLmGGj/aRh t7HFPXxkTzouNZCTPWKQdfq8lVgGkKgUItvTURvoqbrc4qmzkOWvuUaoP3diOb30OqIY E2MA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=A2iFH+hG; 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=1726067457; x=1726672257; 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:to:from:from:to:cc:subject:date:message-id:reply-to; bh=k06/0Ab/FgDmzjsB1xNXwl8FQ2gso+evSdFzyXi39N8=; b=EFV5vVs2Xbh5Zp7RS9pzxcMQ2obKzZt1FlsAhriCecQaMtlVdGRjJRRGbJYCu13CbC b1WHWKmAXOm5rmsQfK4xNw4oy3mi3z3SvOzAqVAVNY1eMc8exK0HWnJW8iTq+puyivFU z9L7pGjoaSIk12WaJdxiRjlMSOa1zyBh6rcCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726067457; x=1726672257; 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:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k06/0Ab/FgDmzjsB1xNXwl8FQ2gso+evSdFzyXi39N8=; b=HhcDlnIBpOAabp1aPW4+sLx11iRpWiGASWpgYrt6cJmmhHi2I5yU0c/K/7GBX6ohDg A5uARqlfabj9472Ej0JZ1bShXG3nlB9QMHpAl49Nzb8tjSTICz/4Y2c2/JuwABTsa6Ea fzOicXhj+F4i67tsn03i/JIEG3wkXiRsAb/ESy1Rj9Urek7o6awR26o1JHtXyM4ujbK7 YqNQg1V0DENA+ct+/aW/QRiitbhYhvy62rqkxZeFXE+OzviSfcLzoVVonWq7vX218Sc0 kP70FsskcZOBipcSoonZ4ClCl+5owEbrlJOZ7BRbIhi39/XBaVuHe+RecIlUqO88Byun AInQ== X-Forwarded-Encrypted: i=2; AJvYcCWjQkFWZGPo9MTxKsB0L/UwgZs/tzwFxSvmmN6Fb+UOKBgwki89Ju/MO9QdTA27N9pboc+kwGV1eEO6Xk1J@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YztIajqm7FfXA5MiKSc1wlgZv5MXm6ROXEsp1LUjapYwelBxi5I cbpZP/EmK4r5CArHKeynbEql59bOnLrfbYuJOG/JY5+nW5D6nYgbV7zijEKXMhRfKw== X-Google-Smtp-Source: AGHT+IH/kwzrOWc+IzTtdVac/MiGOkWIBMPUc+mDNs72kw1cxJMaMhvwWvOizd5LjXDoAkCBUCN2kw== X-Received: by 2002:a5d:4ec9:0:b0:374:c4c2:5ad5 with SMTP id ffacd0b85a97d-378a8a792fcmr4553614f8f.27.1726067457016; Wed, 11 Sep 2024 08:10:57 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:f001:0:b0:374:c124:db78 with SMTP id ffacd0b85a97d-378883bbd01ls1302175f8f.1.-pod-prod-00-eu; Wed, 11 Sep 2024 08:10:56 -0700 (PDT) X-Received: by 2002:adf:f842:0:b0:374:cb84:13d3 with SMTP id ffacd0b85a97d-378a8a1caf9mr4300591f8f.12.1726067455568; Wed, 11 Sep 2024 08:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726067455; cv=none; d=google.com; s=arc-20160816; b=wa1g2SGn2o3D7SXAycHaHMFx0yocYgb2jh8M7TUN9act/JZ+SgriojRtw9tF25iC83 6LX5lOoZEJoXIpbVfVWioDU+rIrq+QYQQyvd9GVTB6DWL1xCIIj+rzrBl9IOWhnfv8ZX AGTXVFETr6jmi4t178ivGQzsrwlFn2kUPfjCjcofO+XauJEnJ/kuG8e3g5S5POzKu3jj GpQ7ZErfsZLc5h1o4LzZz76Alo49g/2SBDzWR1Z389nr7zkOl6ZKZFZ3FYmm4aTxSRKG kNONLz+romVSgyS4rof8+2sJFgBpeedQwVfj7d08JGMkDWUbwofHmDKRevyIUH9OlZfY kt4g== 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:to:from:dkim-signature; bh=sva8w17y0XyKKEPL2HBX2MmC5Cmrpq7flOOHEHkSPG0=; fh=FtQepR0uNoeKT2PVdKfTKOkvEYfwbRmoVE9BmlYw3tk=; b=M+lzAiw0o2GbdxXwGyw+idk8doxiKWP36ZGWIiCZXFNQCmHoi2g/QWDA3n1b955trx z+WwW54WQnxvDXSimZs6WUSbfH6zxW96yFFKzHDD7obMG0899bqMdbZ7E0P+Ygw86NT1 KrH24ukjMAh2Ymx59lSQj7Fm7CMt0ppf3OYjAjL3fnz8v1ADAiAn0vu2BxM6E4NDkfOz q7WmcVzxoXVbHsWedk1T6pA90KyFRRISwAEOJYnXzvWqjlpjA6h1nDcZroBhWUp59pkp sNaA55bgzgxhrj3JlOM/TzKRvW+L2D9KjDaEyEofy4Cjy9tzUotR/2n4NuEGXsQgAESa zQbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=A2iFH+hG; 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 5b1f17b1804b1-42caeb3068dsor24896205e9.2.2024.09.11.08.10.55 for (Google Transport Security); Wed, 11 Sep 2024 08:10:55 -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-Received: by 2002:a05:600c:1da1:b0:42c:b8e5:34d5 with SMTP id 5b1f17b1804b1-42cbde02677mr42968645e9.15.1726067454829; Wed, 11 Sep 2024 08:10:54 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cb116f44esm137688375e9.45.2024.09.11.08.10.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 08:10:54 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Subject: [PATCH v2 15/27] phy: dphy: add support to calculate the timing based on hs_clk_rate Date: Wed, 11 Sep 2024 17:10:27 +0200 Message-ID: <20240911151039.2914886-15-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911151039.2914886-1-dario.binacchi@amarulasolutions.com> References: <20240911151039.2914886-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=A2iFH+hG; 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 --- drivers/phy/phy-core-mipi-dphy.c | 32 +++++++++++++++++++++++++++----- include/phy-mipi-dphy.h | 3 +++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/phy/phy-core-mipi-dphy.c b/drivers/phy/phy-core-mipi-dphy.c index 8fb985a1e682..de467c235266 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,26 @@ 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_ */