From patchwork Sun Jul 14 07:10:17 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: 3251 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 698B34135D for ; Sun, 14 Jul 2024 09:10:53 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-58d152f7f67sf2882873a12.1 for ; Sun, 14 Jul 2024 00:10:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720941053; cv=pass; d=google.com; s=arc-20160816; b=YnzodLTO6fFHR6Mhjt59vNd5NiszAHobghAgi3nzUi0N4U9D2BqPkHt2T6S222mrPW kCLDI6xwPaM5ciIsRalGrxoaLPz8AHN8CDlGcJMi8OsVPvbk4Ozrw1JnEgLv7OyPOMOY hb8K2bWD3v6qxOmq2PtNWzDuGJNvd3RiVs1yiftT4R4t1jtgnkaYnriNewI0zUsolYyP KqAU0gMuNK1W6eFUqKiM0/BE58uFDcYzehgeuJTecYXpdYKKcZmMoGWE9LleYevCTu3z DZBjX+GrKuqIonaFXqBTBn8Uea2m7oQ4kYbfddiPgMnm/w6KTrGpWIrJN8zG1mEaw/M0 GYbw== 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=CQaK2VLV8RuxbFuXjvDxUGiRvmFebTHFAlQx1lEl+qs=; b=Sx8favYp86b1VCh2q+KJjRzk+ztctutbuUrMXmpRxruOlO+B2sbPty1hbd2KhljGdG qjg4IddGK9FN+OH3yRIjRl+7loGqWYdG0hKAs5pFMAl33t5xZjJbYKe2oFT3V2OkY3z9 z52fCgj98C9VddEbvAoWaWnjTm0kQfMjW1FfZaKTDZ9wTdIGMwzKr+yc4lSA1e5GGHdD xfzK4JB1tbJ1GIZAk+pE2GI5WZMKcHDcqqEAmVcvZb4k0ZSxm4OgWud+zhT6kEdLPv4o F2TKrjQL1k3O7TXyuGOcziI1q9gab/fJy4YC8whn9Mm87AM7oanWFvjnP/iHhfhBm3tZ Uftw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=U1hXRj7J; 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=1720941053; x=1721545853; 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=D0b11StQxlFXyCCspkhmdSmi9QlAuay4E/EqtkSKKXG6fBpMpfZ/m4/pXEvkFpBVZ1 fGQyz2oxqP7fsQFvhzIrydmDKfhIbp2GP3hIW03mnJBxNWd4CXWeIPvPgp6aL/JGINTK GNOKKs44m+drUBqIAjS9WN8K0pW6H202Qavvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720941053; x=1721545853; 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=fzQO6UWm/5jjyskubOCCH2Vfw+/Zvn40cUKwb+EfDDR0iO/+MpWFLSlJW3yddNlOhb MacgmukLvGPKFQzm7r7MsmTonuaErzcOUNfj+apyw9BC0u/aYcQYpX3o/YqWrBFbj1Bb sgmF//5SwpH4tMCcGc0A5TlC+O9UrVBzsCPcdoAy3C6IFvce+8J6mQX+qTTVF5i4CvwI 2JW9h92Kpj956OjP3q3XOM3B4Rc0pPpGxkgs4vZI8X+/4oi0Mm8TkgXCInwg3adA8d0f 603zmuD92D1WJkmy8l9LgpigbpWQS+i+rDLUzTPA3Tq6Ls4HczPNRml3+hbq44oWHL/i oD6A== X-Forwarded-Encrypted: i=2; AJvYcCXKH6SGbtsBOLqh1rj/EBJsusG2lXUb/sXa9lwn+dOTVs0dyPRLwHQ0xqrTWDkP6CHT6ZvFdnhlCPiGNpnokBEwQBy11YMzoaDuQ5KMO7bVuPoup/DhC3BPJEYPTA== X-Gm-Message-State: AOJu0Yzyz+hAP1ccZKyzBcfb7HpZK+5BaY+ai7kGx7qOpmVMXr4CFzCb dszWPziOLvfhpUjqAOCBjjidl7Ck5MPbK9tNUannXoBp+4/d7bsWEnaVm54vtmFn9w== X-Google-Smtp-Source: AGHT+IHSRPxRid0L3FmQz7Nsp6mwk1rxKg5LGp7EjT9rXJCF/80kXTUrYSN9WXmXGS6j0TAD7U9iYQ== X-Received: by 2002:a05:6402:3588:b0:58b:db7c:93cd with SMTP id 4fb4d7f45d1cf-594bcba681bmr13998607a12.36.1720941053172; Sun, 14 Jul 2024 00:10:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:cc91:0:b0:585:2014:4d24 with SMTP id 4fb4d7f45d1cf-59821cb8976ls1555842a12.0.-pod-prod-08-eu; Sun, 14 Jul 2024 00:10:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLspYgENPkHJQHZERrVqRVwj5vYaSvWoMDD2CtWjroZpLaO63f/MiuRioOmtsA1eyU9yQ/xdtMhPRYNYho7bOASxiAAki5q15OiLTL/LUiI6Uy X-Received: by 2002:a17:906:1388:b0:a77:c4f6:9f9b with SMTP id a640c23a62f3a-a780b6b194cmr1149182466b.26.1720941051380; Sun, 14 Jul 2024 00:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720941051; cv=none; d=google.com; s=arc-20160816; b=tU45DyNJU2cM+i8SF/tHXLFhXqJy4R78r4TOxGfFdH/KjaY3E/3YTUJXIZD2/Plljm B0lv++Oe04A1F97iSEzmML04ppsufiouKkCYZdxNCtX9T7wgaVs5LKwA/r349eEGzPpK R+XPF8psPQ56llO1RdhdGK7hQYNCIiCglIbC2rr3QWx1ffwuQGokaKoOSByJPccNzcBx ZZ3N2Mmqk9uf6TM3+nnyXX++UdLIC0xRgLb+4C/hhppBqzD85+xRK+efQ20r2OKHCx2G uEqizZbAvvlzN/Lti2jp5i0kWMHb0WMR9ZlCwlRpsJFrSviW8qRZdForEiefeKyuDeaX vUKw== 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=mSoL1nz5iOuE9iIPr6zKDMBWYScKykJNyVnpLPqEZkY=; b=gDL4WOqJ5oXRgtz+ZllqRgkxbG58JplYkKXijWEDZgg3TP8oLykfi2u1E/CX/Kxghc /sOJXq6vcQYKmxk7KiwKlVSrxlm5pi9NTu1E+qqRxeGO3lnP/z6sJeVIsxHPJjn5En8h VA3hmhxxERTwpJ6JD8MTmM1t0qxTpHdZYdzmbdRU2WQCw1pUz0tyYJ3ecOkQ1NJ5Lz31 Qg67HCnThC3VndBvda1jnJBaMaOfwsGp2+DUky20+/laN+jlWpflwf921vQEU7lIbU0g mEQfLapEiEavFAGvMMby23UreXbsBSg1TigbrlU84EBgu7xG+YIOaKP7ZMZbYXUD0zeN jirA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=U1hXRj7J; 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 a640c23a62f3a-a79bc5dc347sor38049966b.11.2024.07.14.00.10.51 for (Google Transport Security); Sun, 14 Jul 2024 00:10:51 -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; AJvYcCWTY0GN3cfKVUwnRmvuAzARoE4KaIi8j+XbDTJb5Fity3LhBE5w+3C+aLiWGQBLdtNsW+Tjb8uJGwhMHsHMN7lZsQgo9MwRq4LWXwLtOcxBQF66 X-Received: by 2002:a17:907:94d4:b0:a72:44d8:3051 with SMTP id a640c23a62f3a-a780b688a5cmr1467617166b.16.1720941050977; Sun, 14 Jul 2024 00:10:50 -0700 (PDT) Received: from panicking.. (93-35-128-17.ip55.fastwebnet.it. [93.35.128.17]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc820d52sm104950266b.214.2024.07.14.00.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 00:10:50 -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 09:10:17 +0200 Message-ID: <20240714071023.10417-19-michael@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240714071023.10417-1-michael@amarulasolutions.com> References: <20240714071023.10417-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=U1hXRj7J; 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_ */