| Message ID | 20250105181525.1370822-6-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRBT4Y5O5QMGQEG3HO3RA@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com
[209.85.208.70])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 105E83F1CD
for <linux-amarula@patchwork.amarulasolutions.com>;
Sun, 5 Jan 2025 19:15:44 +0100 (CET)
Received: by mail-ed1-f70.google.com with SMTP id
4fb4d7f45d1cf-5d3eea3b9aasf11546361a12.1
for <linux-amarula@patchwork.amarulasolutions.com>;
Sun, 05 Jan 2025 10:15:44 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1736100944; cv=pass;
d=google.com; s=arc-20240605;
b=QdmXUXLSxSgoJMDSNF0B/e8kFZ5u+oO2pJa1GDM0QsNzjVjdfUWO5FZTYO9XmBkB0R
LHuy/RID/xdcX9SsNQDZEzg9wXkIR+jx5HMiSw5Wv24zm3pXkhvUduIGqZ8XxcSLbIGn
o/dXynSTNNRELHP3qTZVhv0rFHhABK241IVz8wRWmtiT/dsQO9Er8pNNRHJFkzxpQEYC
835OzR2Ls3sW4GrD+VayElu6NbGWvAFBc+f6S7vVC4Yzm+nKuZDI7KLYNYhQFBL67D5C
BJ6n9J/DX5F0gTs8fkYj1z9crt9HsQaupY+B+21BHMajqX/zT5c0LNcuPpBO5m64WU1+
DL4A==
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:cc:to:from:dkim-signature;
bh=1tPipegvnQ3ONRzBAGiPBme4jPOU8WTgAYHIigquWlQ=;
fh=RiBwRHuNpgHtOtbZz9+pw5TgkgtPhUBA0rr8wf9JNdc=;
b=bkxiac3eQg8uvPcouZ3CqQ/K9bZO+1HSAPYYWjNyQRrI7FNYTN8hTyg+W8ofoNTdP3
nxxV0+zuSPd0OKte7MH+a7xYSHVX+IHe7Hisrgq/gegmYDfepCtZqPNFRlMcP/O+EC3d
wkCdfl7OLMl0u+MpxpvB7cb70vWWIiuQMoyQTLb9HMGB56GeZsjye1lgt7eH5zeVwijO
NQeDUn5SCz3ciq00tIIpu+xpBGvtjkv8ZuSJc8wATo7UIV3lDm+yFMgbXprvoOxN+Vvg
vAPJouG5roHu5WEU8hkMTtC2+UFisC/iYYKiUr17MFVQQtRiVrXfC4/LHIDq+eIDdnnR
Cryg==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=p9n0Z29h;
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=1736100944; x=1736705744;
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=1tPipegvnQ3ONRzBAGiPBme4jPOU8WTgAYHIigquWlQ=;
b=CZN2TeBQRy5OFtw6bnVh2ZPieLLbAtLieeFOrY83jD19AhhGWqrZrW56cWYuxpGOwF
pe93fWYynuZtlZDqnOC640frA5tJM1Zpv7dWMsbl63KQLyRftBN+OZsXseQpF8D1N+oT
k2JPL7ddPW5rrFencJ0VY+NYEUt4ygUlPRC5I=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1736100944; x=1736705744;
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=1tPipegvnQ3ONRzBAGiPBme4jPOU8WTgAYHIigquWlQ=;
b=CEKtga7x7qch0sBRTwdUphPkuQmMk1H/vc4ItA4tntf0ZCr5ADU1zcmMgwQUTW3JWn
xl3tMzO5+KTN+nC2IGOg6Q1fk6C01jc4UfPjOrlYi1ryQgV2+6Pk+J4IxaVdIhYoRF4k
FAobC4vVQ/Mk4ufFxe26QFEu4oTVV3ktjYc2nfsj28QuXn/VrbMhRRpFM5CMSuIOL3pc
RJWqkfMx1LcWVvj6QEFuZWNarfF9k4qrG+UuvfcpzTCwFswjZ5x86tNOsjuii3LWkVXM
6+qY1DioN4smuWhJpoDoiI6wdOrh03PCNZNwZ1At7C5q2M5PmteTpUHxVzVpWElsMlv+
O1yw==
X-Forwarded-Encrypted: i=2;
AJvYcCVlpIVtLJN93QDlOF0rQ0JmPLymmawABNIYo9jQ9o/W/jjo7/D9TJdmVi75lESc8uOJGIugJZJcQnSPPmKP@patchwork.amarulasolutions.com
X-Gm-Message-State: AOJu0Yzr3etq0UqDvy7QITk5n2mPjDroMsTRz44LWpZXF6Sr57CU0+ua
hAVRf4gDw0C5Z1Y3LyJ4jgYunE4+cYHoVPhEau/KWSpqxxN8OR+Qaq9t3dWym/QH4g==
X-Google-Smtp-Source:
AGHT+IEt3nXnJIXuSkWBTE3NM+Dbjku2bAX2lT1+tbgZ5LUl0eB1j2StfkhQ3SVKR1IyZj8TQApKZA==
X-Received: by 2002:a05:6402:5245:b0:5d3:ba42:e9fa with SMTP id
4fb4d7f45d1cf-5d81ddc01a0mr136930141a12.16.1736100943731;
Sun, 05 Jan 2025 10:15:43 -0800 (PST)
X-BeenThere: linux-amarula@amarulasolutions.com
Received: by 2002:a50:935a:0:b0:5d0:e410:4698 with SMTP id
4fb4d7f45d1cf-5d8f7e29c4fls1090005a12.1.-pod-prod-05-eu;
Sun, 05 Jan 2025 10:15:42 -0800 (PST)
X-Received: by 2002:a05:6402:3604:b0:5d9:d58:bcfa with SMTP id
4fb4d7f45d1cf-5d90d58c161mr28180136a12.27.1736100941907;
Sun, 05 Jan 2025 10:15:41 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1736100941; cv=none;
d=google.com; s=arc-20240605;
b=JAyGtZ92Zlksy8DIppkNcsi7yo7jyU8xT0ogFfx+rz4qTXL06U1hJ2ISoAhSX2qRbD
R9cZK5E9pfyfljevEgRgHRkHsv0SE4XMwv+vS0R37jHFF2qJFj6KobHRMz1x8FGD+2tk
GU/cY3Bnrh1J3d0NnnPh20dyiG4l/UISkxOgqJGX/jCFbRFqjijj+SYo7GDGZWMPWJhk
YDBNlOBA1TbjURqQi297OI8c08qeAXEBfOXYO/+/MgLawIKLCzgQ4CQG2nWATn6sTdIG
/moM03sdju7gybRLO5HvIZIVOqNEIWucE6Qfp+MeOqfTsVffnGkXqNBE3rmTGFAaGbjq
l3HQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=nCWum8u2aSE0H9NGugk1g+nl+FSObYpFAdsp0A4AhFk=;
fh=LKhgYKqW/DH7bOgdnVELRgL+gR1eISg3bEXUN1rI9pA=;
b=ZlzQu8lYkBsXnrh4VZk6bnsKfyxq/tCsUkKd4kkmDkD9YTc8Fh0DhiVOgU8k6LONZF
B0VLH5E/cMJsPBLhy9G30eMbTs4U1Kfcdc3as1sKvJBjChfEOOn4VIB58T2B40OfQGwp
VFVqIvawxtMnMfXAZkpZM80boSHiYHDI0sggv7dEIl5ubyOHMTiNAtywMvqbRwmeBqGU
n9jXHeex7JiXPuke3zZpPgWJJemxe7ExNknddazkdG7xCTDUPEmskffmCiJt6TW8fi8u
CsKoT/3XMda9cTdWH7a0wz4sDXvu2vAmohvHyLrz4BSVfFcBv1U+VIfBTinCfdyDcsBi
DqAQ==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=p9n0Z29h;
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
a640c23a62f3a-aac0ef44df1sor879322166b.13.2025.01.05.10.15.41
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Sun, 05 Jan 2025 10:15:41 -0800 (PST)
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-Gm-Gg: ASbGncv17jVdwlc+OtAijpRJpv1Fzfs5F2RjszjNZ2Kk92hVVc5bY8H1SeepC9uoCrR
Mc9FwyTAMKz7ZKJW+9pM+FYLr7bhr1/4xUvnbSFww11PKMeZTaNRQby7LMnD4Q/VjadSbC/Oad9
EUwTbw7jRfu8WUm3YZBuYffCRsZn3JW/EMuHu1dBtUAW18LhSts7HcKNbBRqIWPbUjHXBKnW6S2
ZQR7VO7bmZZX62UkUVFfrhYjuHqt5T565r9mUksVYZG3OK0t95x68OLSrIF1Ayst3qqsS0RTSrb
Lp6QBp2ANfOk5Olrksy4v+s/qg510XfiEoXAETCFMIpe333o9ci1HOIORagn9imq6ME97xlLGnE
mozrE6LXcj8vAgBFeHA==
X-Received: by 2002:a05:6402:540b:b0:5d6:48ef:c19f with SMTP id
4fb4d7f45d1cf-5d81de1c28fmr134000185a12.29.1736100941394;
Sun, 05 Jan 2025 10:15:41 -0800 (PST)
Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it
(host-79-41-6-15.retail.telecomitalia.it. [79.41.6.15])
by smtp.gmail.com with ESMTPSA id
a640c23a62f3a-aac0e82f178sm2138185066b.38.2025.01.05.10.15.39
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 05 Jan 2025 10:15:40 -0800 (PST)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: linux-amarula@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-clk@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: [PATCH 5/6] clk: stm32f4: use FIELD helpers to access the PLLCFGR
fields
Date: Sun, 5 Jan 2025 19:14:17 +0100
Message-ID: <20250105181525.1370822-6-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20250105181525.1370822-1-dario.binacchi@amarulasolutions.com>
References: <20250105181525.1370822-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=p9n0Z29h;
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: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Support spread spectrum clocking for stm32f{4,7} platforms
|
|
Commit Message
Dario Binacchi
Jan. 5, 2025, 6:14 p.m. UTC
Use GENMASK() along with FIELD_GET() and FIELD_PREP() helpers to access
the PLLCFGR fields instead of manually masking and shifting.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
drivers/clk/clk-stm32f4.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index 07c13ebe327d..db1c56c8d54f 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -5,6 +5,7 @@ * Inspired by clk-asm9260.c . */ +#include <linux/bitfield.h> #include <linux/clk-provider.h> #include <linux/err.h> #include <linux/io.h> @@ -39,6 +40,8 @@ #define STM32F4_RCC_DCKCFGR 0x8c #define STM32F7_RCC_DCKCFGR2 0x90 +#define STM32F4_RCC_PLLCFGR_N_MASK GENMASK(14, 6) + #define NONE -1 #define NO_IDX NONE #define NO_MUX NONE @@ -632,9 +635,11 @@ static unsigned long stm32f4_pll_recalc(struct clk_hw *hw, { struct clk_gate *gate = to_clk_gate(hw); struct stm32f4_pll *pll = to_stm32f4_pll(gate); + unsigned long val; unsigned long n; - n = (readl(base + pll->offset) >> 6) & 0x1ff; + val = readl(base + pll->offset); + n = FIELD_GET(STM32F4_RCC_PLLCFGR_N_MASK, val); return parent_rate * n; } @@ -673,9 +678,10 @@ static int stm32f4_pll_set_rate(struct clk_hw *hw, unsigned long rate, n = rate / parent_rate; - val = readl(base + pll->offset) & ~(0x1ff << 6); + val = readl(base + pll->offset) & ~STM32F4_RCC_PLLCFGR_N_MASK; + val |= FIELD_PREP(STM32F4_RCC_PLLCFGR_N_MASK, n); - writel(val | ((n & 0x1ff) << 6), base + pll->offset); + writel(val, base + pll->offset); if (pll_state) stm32f4_pll_enable(hw);