From patchwork Sun Jul 14 11:32:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 3301 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3A6044135D for ; Sun, 14 Jul 2024 13:33:29 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-58e66895fd5sf2711748a12.0 for ; Sun, 14 Jul 2024 04:33:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720956809; cv=pass; d=google.com; s=arc-20160816; b=YzwlzA2+YObVdxs8fMcYaKnKUqfaOZULqXfezghH0oQZPX8M6/SUOKQpJXGN3JqXKv OjL/1Zj8gyp206wCl5HuemsIwhSFq1MjPWT2HcW0qi7YSuczRceDJCMe03wR1pH6QmnS 8rf/b23QH6ShJHB/UsC+3MzmBwCmguwwHbKjcbUxzALEraqn2Vm1WqkMbrc7zZSeouYj aEwdjk9PT+1PVujkz0nbeTPanG0J/8SzmTtgksyPjhzgxT99L0O8/hlRBrx4d7t17E7k yWj3F/xlIm4iFBIsPLQD+6NLSKXGxFJuYvkLUg+3awqgZqksjhGn1F1S1SDK1zEFWkl8 Ct7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=OcP0SqfbANmiysRY1ct3ggnr+n+1KFxcXMJBqxzvCsw=; fh=re/H6IHA3P68e0AhxxRCD5JespHQSj61SDXnkeid4bU=; b=NUkYAXVfRgMqur0x45+EvmmiEu4UIo7AUNndkv6vQQIH9gguRKHukgeqdjWQA1FjO/ Tb/DUJ3hg+FkTWdGsTwlTVgCdp7af+cKjXNDHwk9x3nZRWTuWslS3gmVWP4c3fe1ZMMJ 3OOYzad02CQbmH0vHFd6TbRJmXoyH97xhIHNveXAzxUELplpUDrnXevpG0vJBNKS5bKW AsJLaTodNggWZ2HX8OQpphW7eV584Mk+21sbWG4h3wYchDoEZj9sla7hGfvvssYjOn4x 74kL6iYymsLCkvt3XmcMB6ilwihsult7wzUN2QiHA64UeO8iFn8ZRHlqu+aq0PlTBiK7 KoQQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XRrN0AOZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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=1720956809; x=1721561609; 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=OcP0SqfbANmiysRY1ct3ggnr+n+1KFxcXMJBqxzvCsw=; b=GbkENbSGjx0xgAUG32Z2RKpAYLhVI8nBJa0ZgPcagccv5lVNJGtbwHUTBAv5gDaZEN cXDAAnabpkQ46CvgF5Xm+Gcae7pOZ7/FUX+NH4nx5V72H91L147mwQ+nwAEjQ4Dt8z3z bveTUO4RxjMMLz5PSkX3QslW5k2aRxbnOpSkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720956809; x=1721561609; 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=OcP0SqfbANmiysRY1ct3ggnr+n+1KFxcXMJBqxzvCsw=; b=JBVkWfhMkQAkr63fsGJsEFdHCzqytXAufKJdjxyujYuMOoHzPJjpXunx4dn6bxbpKP 8n8shTxxZGZ2Pru4wbjtN4qh/LhJqtb02t1DA+AL18g38F2kJNqEyp6XmNbZsBaKxkSL R+UhOkQUUeN3cH1wJ0JzfG5Ew6SXqIS2QKzUFbF7wMTAAEPatJKTIFmposCHqnL0dQWf c7H/jbNQK2BgOyDeoIAsJJ89AjOQjMWvYKsDv+Y2HJaVKJ9wmTbegb8O6Bu0He5Tp78m U5/2LwhH75TbljfR085NiuLRDi9Ccu+A+c90FaCh3wpzSm6K/AjosC75rEZ/Ttdb1Z38 vcxg== X-Forwarded-Encrypted: i=2; AJvYcCXX36dh9Zn7bKKKnHismVnbkcC+zvBHL8Yr6y0hLeKV3U2y1cw+YDWDSFENbp7sNejbIO9CB/AyJAk9HOWEFjbD1ty2nRtWb1NiEMOn1k5aGzW9pE3XVCyq6iBuKQ== X-Gm-Message-State: AOJu0YzaXayrguMWzW0/Yxj+YxfcQdj8w1+scmiWtJoocuqXMwVJORyd cmLo88mFuZmS6W1c10zxvtAtCQWhBO90piNsb5FSZc2Ng1/aOMrDD1fNypUBv0ZBcg== X-Google-Smtp-Source: AGHT+IFA0IQIHMb/lNrfRwSIm7rSYUV46JozPecRaj8TDkEB3pyeRdKcQmD8mNNh/vli1Y+n989pqQ== X-Received: by 2002:a50:8749:0:b0:59c:31fd:266b with SMTP id 4fb4d7f45d1cf-59c31fd267emr807704a12.28.1720956809002; Sun, 14 Jul 2024 04:33:29 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5249:b0:599:9c73:c397 with SMTP id 4fb4d7f45d1cf-5999c73c4fdls1084942a12.2.-pod-prod-09-eu; Sun, 14 Jul 2024 04:33:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWi+QdhXAJrcrPnSFPwwp5YujpL2rwGXYKIkEqr7NkFaiV4cViA3vIeE8sn/ScScABZsJpw+ETxmK1+Uk6Z+PN+b3XuEFqmX5mta3np52rAF5HM X-Received: by 2002:a50:d513:0:b0:599:7a9c:37b0 with SMTP id 4fb4d7f45d1cf-5997a9c3c27mr4065936a12.35.1720956807402; Sun, 14 Jul 2024 04:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720956807; cv=none; d=google.com; s=arc-20160816; b=s2kKQ7TlX7g0p94lGJmHF2t7nY7pgB+CxbmNZ1ADSEJTsHlLy38YeFP1zMH4zBXq/u JoYENCKixi0bVSpGTOzPF4HikIPjLiFkNom0RdaMVnPLR31LjSClSQ2WJwGy40qOGpDV Bu8HWawvXUENr9TomENfY1mJ+bUYEusU2PpRRYIzRQcC0Jkr8XHfItNMoZ3A91CrfTzy oRBimT9ovmdGQXGYuirjRCMfUg75zV8UEnejis2bvdyKlEEkDZUQiXJqoeBHiDZmvUY/ COj9wmbLeHqjKRpZJZxO/l/Und5yAScNMtkPXZjy0av/QIsM9484qGzB+WxpxAbr2S96 nrJg== 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=rc514+uaHWKBiHPYvvxNCrrDcH7xbnYL0XxtEFHj6to=; fh=yQgCFbnorAF88/g/A2ZDoomXR5yzn9vYZPluPD15wJE=; b=GuLWlPaZTLxz24VipFQtNyrmfQkbhm1Mca2eJcklQgK6mK92kRfoqY/1U6FlqmEMJT UbAD8wQ4nKhrO/88s/bEEVt6yvGoFxFWbR1iI6/FcsHRaC8U28sCppXlrjFZHSmy2RzY Iumw6vU8Gvqu+1v2NsaW3oH9uJmCyXRicYGfTSyrLMchkncgj9Hiq4EtthwBGErmB7AD W5MmOpr7oyb43uD6qdwwgrM3Z7Tj8Csg9/px81s+PLEsonTNQFJevfaLAM5TTgjxnLV+ 3hPZfnfWSahPuwRcZNLvGxpSE2VxouAXnVnX815yQvUVsjl/CSHqHNOZ65Y4vEVjW2m+ mtTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XRrN0AOZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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 4fb4d7f45d1cf-59b24a77618sor439906a12.3.2024.07.14.04.33.27 for (Google Transport Security); Sun, 14 Jul 2024 04:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCXlb5n8Zx1FsN8h5UigdQRaTzA0h7SPwo3DLvog+4et0PasEudt2jBFlsNaJAy0/hG/A1eZt0eF4Zeb/PGrVbgMxoy+joU99nP3XT//4q+uRVLS X-Received: by 2002:a05:6402:510c:b0:58d:be82:6b1f with SMTP id 4fb4d7f45d1cf-594baf872fcmr12163336a12.10.1720956807008; Sun, 14 Jul 2024 04:33:27 -0700 (PDT) Received: from panicking.. (mob-5-91-58-211.net.vodafone.it. [5.91.58.211]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b25528dc1sm1929469a12.52.2024.07.14.04.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 04:33:26 -0700 (PDT) From: Michael Trimarchi To: Michael Trimarchi Cc: Dario Binacchi , Patrick Barsanti , linux-amarula@amarulasolutions.com Subject: [PATCH 19/25] phy: dphy: add support to calculate the timing based on hs_clk_rate Date: Sun, 14 Jul 2024 13:32:56 +0200 Message-ID: <20240714113302.133399-19-michael@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240714113302.133399-1-michael@amarulasolutions.com> References: <20240714113302.133399-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XRrN0AOZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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: , 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 8fb985a1e6..de467c2352 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 a877ffee84..1ac128d78d 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_ */