From nobody Tue Dec 16 14:42:02 2025 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E12A33DABF2 for ; Tue, 14 Jan 2025 09:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736845900; cv=none; b=UdgKN6VCqpSDtj1CHvFnqz1MFmvT1iBiylZ+9cgJf3pj/+yGy8HqWTpcKL2G033ydzvrNYtDL1DmPcrZOxnJQ7wL9vUKV4GWe4z2Ny/6/cQclLEEMe/+7aivUVol3Hmk60umNYvUenESb/9ucnqk1aSf4clgDiKMqUAUOZW6Fm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736845900; c=relaxed/simple; bh=54AnFoYFZcZqYgavjCEUI5tS3rZv1k1LrPOchNuHl/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NahNCUoX5JwERq7cik9HOw1dN/z5vAjce19OJbrHLw4G15Df1lCwDYOjRyhI26ZGptRBJeGtba1My8Ly6UMVzuUVBoHdJOEL/egxvHdm0Z/mYp9S2pWCofKxtTVjYhqaTdj+VSJ5pB8Ninb9p0iwD6jwOnVq8VtdgvrzF/ILWmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=ed4VDlvp; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="ed4VDlvp" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5d9f06f8cf2so2100781a12.3 for ; Tue, 14 Jan 2025 01:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736845897; x=1737450697; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4PuckIz6TtMrm6FhKB7AMqxRoyDL7dpmszhuAU6edRg=; b=ed4VDlvpfolrC5IqrtPkLtgAgFXBLjx1WMDerBlqzlobbEUSTMcfctmZWmyyzvQOyF MRYb0k15vTXQkD7oqn8xzapEe1vX2sAH+2bxtasYAV9Mhz4VFvphCfA0qB+LyT/PFmTm XPONzUkruaC6St6eo3d2gN0Yllvqoq3wJWBXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736845897; x=1737450697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4PuckIz6TtMrm6FhKB7AMqxRoyDL7dpmszhuAU6edRg=; b=Rim/dT9XTa8YmXsCXfrnrFXnyWE6Lfg2r5C0oaYCgrT7/n6u8DMOk2xOZ/AqvVYNHQ 5MCo4DRifGINj/9lrbsQY/mtiHWeXCa6ABkuFHvPxJ7tT2iwr9+cvOGM1cQyZNjD5jwr 0M50QXPP5+0eR9FIl8+sijOgQKcpzs2iSW6cnbs04E5WNwwX4E2Pw4jxDwclQxLh8QZg k+zVgtEGD0FcjRQM0WTuVsLPBUDzG9W2l+wyFJ7DLdN2u778mTPPn4ahsr4Ze0XgTqOi kbyneAQg7LWhTqmMA7Ze1tQEEDj8pS0jTs3FOC4sprdj9G9gNUXsloMu2oRQz/rSu2Lr 8gsg== X-Gm-Message-State: AOJu0YwNQE5JtB18NfPvZYXVgZrUD0xpvXuHeneQyUH2x1tzVeOffHzl xBzSeGJ/nTy/p1Z4ZBFPdgzXWGVw9ThmYK8at8y/r+tatIV9L88Q01DBx9TT/+9a9+BuLUB0+8W 6 X-Gm-Gg: ASbGnctbEtUlzU54682l3joxhLWdsH0iNOHW3pqSiOLUpBiInyNtEnRoExO1kFE9WD9 A/LS0GcnNbvQSHG2dP1Wo7J+/gpIpS4RXcecGMhDy7RuuY9Vu65qE6Xlq1C2LHzmHtrt8zCDvS3 T9IQlPmYQV774RAp+4gggpwK1Y1vswdWu20A9ZYiCo2EMW3X1h5dmjpniPoe6wR/L44QN+mc/2J Mo7xfcJ3CIRyHdwU4v9cUPn8Aso6HtWXpBdTc8V21Iie6N4JCHOznqCGZK/s/ga5YCtEYLiwGq3 vQ3jrOnorz5sI6SUp4qucw== X-Google-Smtp-Source: AGHT+IFg5688v9iu2Z6jN1GBfV5nDayopSS598535VN8IIxu6UQsTzwr6yLMykzma1EPL9vJgQo+tw== X-Received: by 2002:a17:907:7e95:b0:aaf:c19a:cc1c with SMTP id a640c23a62f3a-ab2ab6c6625mr1898191166b.22.1736845897042; Tue, 14 Jan 2025 01:11:37 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c95b7317sm599640766b.154.2025.01.14.01.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 01:11:36 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandre Torgue , Maxime Coquelin , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v3 3/4] clk: stm32f4: use FIELD helpers to access the PLLCFGR fields Date: Tue, 14 Jan 2025 10:11:15 +0100 Message-ID: <20250114091128.528757-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114091128.528757-1-dario.binacchi@amarulasolutions.com> References: <20250114091128.528757-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- (no changes since v1) 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 . */ =20 +#include #include #include #include @@ -39,6 +40,8 @@ #define STM32F4_RCC_DCKCFGR 0x8c #define STM32F7_RCC_DCKCFGR2 0x90 =20 +#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 =3D to_clk_gate(hw); struct stm32f4_pll *pll =3D to_stm32f4_pll(gate); + unsigned long val; unsigned long n; =20 - n =3D (readl(base + pll->offset) >> 6) & 0x1ff; + val =3D readl(base + pll->offset); + n =3D FIELD_GET(STM32F4_RCC_PLLCFGR_N_MASK, val); =20 return parent_rate * n; } @@ -673,9 +678,10 @@ static int stm32f4_pll_set_rate(struct clk_hw *hw, uns= igned long rate, =20 n =3D rate / parent_rate; =20 - val =3D readl(base + pll->offset) & ~(0x1ff << 6); + val =3D readl(base + pll->offset) & ~STM32F4_RCC_PLLCFGR_N_MASK; + val |=3D FIELD_PREP(STM32F4_RCC_PLLCFGR_N_MASK, n); =20 - writel(val | ((n & 0x1ff) << 6), base + pll->offset); + writel(val, base + pll->offset); =20 if (pll_state) stm32f4_pll_enable(hw); --=20 2.43.0