From patchwork Mon Feb 5 15:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Oltmanns X-Patchwork-Id: 196881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp963670dyb; Mon, 5 Feb 2024 07:53:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVmCXvplWCLtvpVfLHu2ovu58beUPwW2IS+jiQmJaQa8Nu3YpyUaWMha+QHaUlHHuPgQLD X-Received: by 2002:a05:6a00:92a9:b0:6e0:4e0f:62a8 with SMTP id jw41-20020a056a0092a900b006e04e0f62a8mr2432078pfb.2.1707148419515; Mon, 05 Feb 2024 07:53:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148419; cv=pass; d=google.com; s=arc-20160816; b=G8ok3i7Xdqbm5zJmjRlG9Hb3tEynC2BQjGa/V310ZyZ3/XL+l2MDpWfvxBFk9VbeSt eEQhQwi7VNByVSSWV9IhSk5U0HWw4TCClWlzYu64Y7TRhlC98t8EfGLGeizOPn8g8QGT onh1pOnQU1C0KcxmFfIiVC9W+f/kLbEHxY29Y32qEITDC8i/pjDDYgvP+tVcLo93T8BZ B3I5OpcQszJA6zgCmq0ylphUJV8sKj5wE6DxkYX0lwRciwUi/2DnGuf+SqOuxhswlFzO H12ESRXpXVE2eAVPlmcaDrult4bg0VWrj6a/hIljWKh/K8iegL65BwDACesZ6gfq1XB9 GlYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=jU9BjDKbdWvhuTRibGk4N23TVvjyO4DZIzgSg1oCo6o=; fh=XyzQNGTKkXmFRc7x6vMEaoDxBwwsx1peVGUXJHX7/eY=; b=uWf8wdCbPkLqm6MUje2j/b2JRxM/dK37CySDRNWByGS/jb7CXV8vIi5WwWPTj1jXCQ odLCStI6SOrw9ZRXrbNsJbiKmDLwiUmCPStlIHrLTYW2eXMQLgoxVZdZe2xC1+gx7o8+ KHJf9AWiO/yZ6BpAEb53NO6hpyl/ms+d7psi/IuPkIJerxIW5aX/8cUCnfjCES4nth4J WGcQQ81WAsJAXHS//wOEop79eyfY3NWnh6x0iHMUNaqULLq6ozSlFL6Pe+bFqOT5J3j/ U+trDD/IfOLHuNORH9ND/v66rlL6GnOHCT++yReIwNx3Lf1YLsgAyQlVZ0IGwXQOJgse PY1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=IDaUUJ5P; arc=pass (i=1 spf=pass spfdomain=oltmanns.dev dkim=pass dkdomain=oltmanns.dev dmarc=pass fromdomain=oltmanns.dev); spf=pass (google.com: domain of linux-kernel+bounces-52894-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52894-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev X-Forwarded-Encrypted: i=1; AJvYcCVIVOsuvyUDirbkV305oZP/kbKIqYMTTAQHfQYSG3/kWFdCgd3xpHNVvKyK3PHIvjlhOR5DTTJztHU2/gzycWCq2G1Rkw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z6-20020a634c06000000b005d512d7e4b9si57381pga.690.2024.02.05.07.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52894-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=IDaUUJ5P; arc=pass (i=1 spf=pass spfdomain=oltmanns.dev dkim=pass dkdomain=oltmanns.dev dmarc=pass fromdomain=oltmanns.dev); spf=pass (google.com: domain of linux-kernel+bounces-52894-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52894-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9BE10B26680 for ; Mon, 5 Feb 2024 15:24:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B1543E486; Mon, 5 Feb 2024 15:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oltmanns.dev header.i=@oltmanns.dev header.b="IDaUUJ5P" Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E0EF3A8F4; Mon, 5 Feb 2024 15:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146595; cv=none; b=H3LR4bAPhlxlMf27GSmmeVf8dmr67choPN1ptqP+Qvue2pzlPwurHtu7GaNwDcn33ZUD8Z3iclKiCNFTphSgdZ3XzqV1XbFetGo7OXZLVxSmpbHpLo8V34t7a1W3YJOVWNMLGYOmcwF2cCQnqVhfUBKnMvIQFY5gAposaJ8IwMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146595; c=relaxed/simple; bh=/3dNKggDHZ8IDpHedZkuDBEbq+kfTgK2pJtlaJ3P5io=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OE/SHb8v2XNolGpNVJYHxwHDcvxYt5jA0bzMh53ZJnPPhW87BEagE8o4Gl7wrGRcjAAlqBrcTYzuH9Y+qVvVoUqU0CEEdfTiip/ww41A5n8bp9ip0InBO3qUDrLI6FCQdPnMGtolGEt1pA6MIY1lv7iLc+v/ZHZrwrpTitqVYhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oltmanns.dev; spf=pass smtp.mailfrom=oltmanns.dev; dkim=pass (2048-bit key) header.d=oltmanns.dev header.i=@oltmanns.dev header.b=IDaUUJ5P; arc=none smtp.client-ip=80.241.56.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oltmanns.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oltmanns.dev Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4TT9B00qv3z9sqg; Mon, 5 Feb 2024 16:23:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1707146584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jU9BjDKbdWvhuTRibGk4N23TVvjyO4DZIzgSg1oCo6o=; b=IDaUUJ5PaOMkW+Dzmqmhvw1A2j2Lfq6AF6jkWqYyvuUV1mnPji1NK36FRhHisVpA1kq91J N9nQAbdp5x1uKIQ2nJMSsJBfeEHeU3Lg9wlnrwSTrGCBbbi4aekUehgkYMOuMyjdmRX9Cm /HR6dLUGcoGE9kf3JY6qhuiTgh3x5FGGw5WaK7OZ/NYc/XBo5xkaX5CJMwKyMDWdZBYdTc OXJ2OcDHedVgWThIGV1viXPs+xhuOKsRMHQoSZ2rQEguyscQBTVXgunD07NfRF2RbDin8P OhYcz/VzrOJo7cdUDvCVE+Y5ISgk6LdGAIg3AWTcgjra1KaYtxslApH5S7yN5g== From: Frank Oltmanns Date: Mon, 05 Feb 2024 16:22:26 +0100 Subject: [PATCH v2 3/6] clk: sunxi-ng: nkm: Support minimum and maximum rate Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240205-pinephone-pll-fixes-v2-3-96a46a2d8c9b@oltmanns.dev> References: <20240205-pinephone-pll-fixes-v2-0-96a46a2d8c9b@oltmanns.dev> In-Reply-To: <20240205-pinephone-pll-fixes-v2-0-96a46a2d8c9b@oltmanns.dev> To: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , =?utf-8?q?Guido_G=C3=BCnther?= , Purism Kernel Team , Ondrej Jirman , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Frank Oltmanns X-Developer-Signature: v=1; a=openpgp-sha256; l=1857; i=frank@oltmanns.dev; h=from:subject:message-id; bh=/3dNKggDHZ8IDpHedZkuDBEbq+kfTgK2pJtlaJ3P5io=; b=owEB7QES/pANAwAIAZppogiUStPHAcsmYgBlwP0/R/bYRLSWDoR8LFJNAtlZjd3AuDTv0TkSy h6Q/t85+q+JAbMEAAEIAB0WIQQC/SV7f5DmuaVET5aaaaIIlErTxwUCZcD9PwAKCRCaaaIIlErT x7cUC/90hwXY99Ja4sPw6whiQKjE2ZtXg2fE1iRFw0+6vh1HBrZuuzBYjAond8O2cZhSszDwTV6 fsKjWCndURyzjCM50NZOZidj8q2F2hNxNfwzYtd2DeYxhaT7IzHpzwWiS150YVdru/4YTgc+zmm 6fePa2l5nnrf+nr1LL2371HweSyQbxUHiAzrCR2iaZhkhDpkEmRQBmkzIQRIKlLHf6TkaG1j0IQ mzbCbsCDTfewQUPHe+sRDAndVbsxwi65ZoCI5BPtDlLoW9SgJLeawQ27nR22EsgA1VR1+FqSKgt JUka8btp+cH79A2OeLbeZoKapTa3T3BcU8gYviht8L24G99WcywrYzEOKfxJkZGwaXzfXJWTzjs NjaepFV6e+z/1Xy6E7oRgHP2Ns+4brhuPhnqfwBgjK9bmo7ogE0uC9OV4JtNygG/5CDGm8IIOaO UE5j/+5B8D47kn6fIaozCmuA1f3Ti/UgXv2t63jjvvM0LYNdWpiBJf8IZ/SmdsXkpFNNU= X-Developer-Key: i=frank@oltmanns.dev; a=openpgp; fpr=02FD257B7F90E6B9A5444F969A69A208944AD3C7 X-Rspamd-Queue-Id: 4TT9B00qv3z9sqg X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790074860701660649 X-GMAIL-MSGID: 1790074860701660649 According to the Allwinner User Manual, the Allwinner A64 requires PLL-MIPI to run at 500MHz-1.4GHz. Add support for that to ccu_nkm. Signed-off-by: Frank Oltmanns --- drivers/clk/sunxi-ng/ccu_nkm.c | 13 +++++++++++++ drivers/clk/sunxi-ng/ccu_nkm.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c index 1168d894d636..7d135908d6e0 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.c +++ b/drivers/clk/sunxi-ng/ccu_nkm.c @@ -181,6 +181,12 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate *= nkm->fixed_post_div; + if (nkm->min_rate && rate < nkm->min_rate) + rate = nkm->min_rate; + + if (nkm->max_rate && rate > nkm->max_rate) + rate = nkm->max_rate; + if (!clk_hw_can_set_rate_parent(&nkm->common.hw)) rate = ccu_nkm_find_best(*parent_rate, rate, &_nkm, &nkm->common); else @@ -220,6 +226,13 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate, _nkm.min_m = 1; _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; + + if (nkm->min_rate && rate < nkm->min_rate) + rate = nkm->min_rate; + + if (nkm->max_rate && rate > nkm->max_rate) + rate = nkm->max_rate; + ccu_nkm_find_best(parent_rate, rate, &_nkm, &nkm->common); spin_lock_irqsave(nkm->common.lock, flags); diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h index c409212ee40e..358a9df6b6a0 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.h +++ b/drivers/clk/sunxi-ng/ccu_nkm.h @@ -27,6 +27,8 @@ struct ccu_nkm { struct ccu_mux_internal mux; unsigned int fixed_post_div; + unsigned long min_rate; + unsigned long max_rate; unsigned long max_m_n_ratio; unsigned long min_parent_m_ratio;