From patchwork Sun Jul 14 10:53:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 3276 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 880D64130C for ; Sun, 14 Jul 2024 12:53:58 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-584ef6c00c0sf6630647a12.1 for ; Sun, 14 Jul 2024 03:53:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720954438; cv=pass; d=google.com; s=arc-20160816; b=X2hVm9OHojyzHDnoDFzUTay1+vhxlcG7AZQfO/RBqzQk7MQVLibRr5Q+g+EZ/nRVrF KyNFMwfB1w74IHN8NnGMkm2gLL+fXTIGO9ln+jIqCudAuta3zaXA9dxxB27EJT/TLgmT zTrNCsXbMKLI/PtGLfKB04h7Cwk2hB/ZP6o/djDv39uNUo48sskr2gJLixz47ecHiH+L nfIac+XEKfiMOGytdDJUj8fAs3FzapxSs/3rqUCmTeGkcUFdAVan8NSaArUqvvo40TRt eh7sqx062ZasxpB9wc82ZvG+gH/3TtsNQvZxLij4SXSU65xxEjC+qBU1MTOqvfJtVDJn cp+g== 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=5dudN320hIlaAcht9hwlSotUmr/zXOZ9z7pxoDrKLZ0=; b=vLi/HlZs+BToLremFIvOQd8nhCh6O54pVyT2oSKs/2h4pZkU/xj+xPxAE1DUOAf395 e9xvyCYmUmiVOQUTc9jo74Ih4ex6TUmaF8qIFXyQpTJfRFFNXP39WApoxehOqv4Z52Nc Z1hIJL28IthKC+ree2hrpHJizlSnqxwnn8VK9VNH4kB50IoZNK2pjoCM1PwWr61pjLuV oIXZQ6+8xwF0z3AvKnX0eUCWQqYVp5Gnw93v5dYzdV3O4354PH++F2pXTX+008Rx5fvR YJP9C8jMpAzIC1eY1N88Oql9gvAWv0kjrqZ06KOLqS3T7VmS/hO3H5SR6pGg2LTA/a4n Fp0w==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=At89tyQm; 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=1720954438; x=1721559238; 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=hkVvcYzMUz5Ja4axhn0ZdWQo+5d2bNHSfAdQIPJEgQoqFXpQARQh5wFHY0AAecVgbr g+qHlVVYKozq+HuJE1d4YpyOMyods3iBX3DxkPyVhGEWl6JvKVlhVyTVOIX4OpKScHT5 7e515qnVY2N+6RL+iMftuVpHIGftrlM9qpPF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720954438; x=1721559238; 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=wyznpVJaawHmBTfug6ab96F7TQURHE/zmakzNtBHo1M0RLReU3oYOb0JhfKfV9jIrg rxjiZBTq4xP4Jr+iZEWmaQEwcCizCb96D7yZJhAkadJ23eXKtSaOzjVzKws/iZYJBCnC Efae2UiRcsEW1C0XS8fay3QyxAwRFzUoDQ0olC0Wx+HcIQ3ojv4vUeoZhinqr4vHEYlL Zo1pn2XhxQFFJ79z5Jc/vvGW/rDHMUWFgHlvE/gjQZURfY/VP4RSj9SF2YW29Yu2p6Pi FVeWhZjtK6G0dDR8f7rBvd+8smp2n8aEdOzEaQFTcKnc5Lv0LJgTUbhQTHWaIw0HlWwW fKnA== X-Forwarded-Encrypted: i=2; AJvYcCUo5i6OxEpS1RBT39RZALbPwsojHqUVGybyIia/PL/5cg1l2tEfY5pSCmvflb9Dsp5bSppQlIkvB2WkUE+iSUIeNlS8Aba+0sbwoBsxgD0sKrD0IoAZuf5EIJaWbg== X-Gm-Message-State: AOJu0YyYWkcOfAl8P1e55Ai4RRbpCKS3WrStFrDuLnHJpMfxjJs1I6kd iNlCvkqAEUYuqMjONW5RBQgeu3GCfl0dornr24+DJ4dgjX3Faf0VRwTbc5YDOjLGoNXZ+8VerQ= = X-Google-Smtp-Source: AGHT+IEr26f/oAZTXwnho1Eg6coUH9oCEL55LXJhqyZZ65cTj87hPcB0Cdt3SstigBFqi/+GFfVM4A== X-Received: by 2002:a50:9e66:0:b0:585:2924:1569 with SMTP id 4fb4d7f45d1cf-599609a3be5mr5042392a12.21.1720954438262; Sun, 14 Jul 2024 03:53:58 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:48f:b0:57d:1766:62e9 with SMTP id 4fb4d7f45d1cf-5982661bbbels63459a12.2.-pod-prod-00-eu; Sun, 14 Jul 2024 03:53:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXU8qdN9Ux48RlTb+1/wfhBBej/TUxIZQ1xfcRK9cL85RzqciP7QMCaAw1VHWr0QzkPlcwqd3h9880mOkIjPUL4avHvhxwdOWzf9qLtvVtxPu+j X-Received: by 2002:a17:907:846:b0:a77:f5fc:cb61 with SMTP id a640c23a62f3a-a799cd67784mr730991966b.0.1720954436453; Sun, 14 Jul 2024 03:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720954436; cv=none; d=google.com; s=arc-20160816; b=i8vXuzt65LkaS7v87mryh9u0P8SUa8ObARTVtBgVgrENgJJ2j8IhjUXab12IJxltCI FV8FZ7N0zXCqGt4TkTzQXz3ow7Rx56K44K8y31Ni/0wRUncuJbbsnT/xai+73boCSjbn qhvVeWvNwXg8joMiR/G6bZEZ2Tg2MQxDriT8h2KXZ02nKrMgewd8f5K5Jbn5PwT/+cfO WNyHfGbq8EZ/XV2iAhmKzyh50CpYuARooTiyw/bvLFKSUMoOG5vKLe0yqt44K3u+4YLn XBqK9nue2PVIQWm4sGVLz5s96kOhO7et5EqzGL/KIIB0JK7bnSiuhbowP0z+gpA82YZW 6gdA== 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=e0mpXzIqokVgMkHyOfzwz+24UIfYqSRfitHpieCfNc8=; b=K26Kt0zNa+yK6pqBfKwe+Rh+KY/Jd4xHVlATiD18qSzNf+KauC2IqT23bbGki5oQWE s8QJ3emzX783sL3umBFlF8wfBQiTFhrremQ/O6yuEa9Bs76xHKtw0TDzpvl6yCObAy0O A9D1jtfHbTDm5wpRCSRkUDt/KALwyUuUCSKcQ9oer0J6r3j085D/zWLTkPxE9v6/ZOo5 WFzLRmFz9SwyLkD1mH5egRfxcidMIlWsnxAw/YkP1CPhKzuyz0jUjxjlpFIS4TOxQckm JeVLVN2BqTu2Jlt5ramLn/kdyyoWRtAetn1b7+lX+KPFYhNNLThzOHKIHj0551m5nmsW BbFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=At89tyQm; 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-a79bb7428a3sor79419866b.6.2024.07.14.03.53.56 for (Google Transport Security); Sun, 14 Jul 2024 03:53:56 -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; AJvYcCWXOhtizGiAMcVZhgd/oZClJ154Xak4gXnrh3O/jgaR1GpqndO1HgEq3JMOD8dxCfPqaa5+pI1U4hqYzDplcyFaaVPJRxZ8uhDMkiVB3Q9SuD5D X-Received: by 2002:a17:907:daa:b0:a72:5f3f:27a2 with SMTP id a640c23a62f3a-a799d392e7amr647653366b.26.1720954436011; Sun, 14 Jul 2024 03:53:56 -0700 (PDT) Received: from panicking.. (mob-5-91-58-211.net.vodafone.it. [5.91.58.211]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5a36c7sm119966166b.7.2024.07.14.03.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 03:53:55 -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 12:53:22 +0200 Message-ID: <20240714105328.35825-19-michael@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240714105328.35825-1-michael@amarulasolutions.com> References: <20240714105328.35825-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=At89tyQm; 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_ */