From nobody Wed Feb 11 07:50:12 2026 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 E548F1CDFAE for ; Sun, 5 Jan 2025 18:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736100946; cv=none; b=ldggDeH+zqHSuXv7e+ZFp6tDpnKKLBer2OEPMHJPno6uPg6pArMJ6+CE7IEy760pYrTdwTytfg0YKoO7NLmkalbwK0oCWf9apsIFpHiWkJoQf0MNveQ9vKFvxA5ZLRNLERbPnPCPhg06UKBMnge+Dpgl2qVyGxYxDUnqvvQ+Rhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736100946; c=relaxed/simple; bh=uyYm4AkMvyc5cNDTbp+U5fuCFOWH+DVbD8gtKAdlEIU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PJSywUnUF226WeFS1UFRLH/gOAeORrzmGDoeOzVwuSU6hbbWblBGD0L9G/LYyremnv6WYD3/bwdu1w+71Cw1z5tCjlSxmk/qF+nNzoEzG0JNGfH6jGXsUmGPoKjCBnAK+UxRdNYWI2r0t1xnGZAf79CmvHmp7uNR3Womg/Shgvw= 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=CQh2d8V6; arc=none smtp.client-ip=209.85.208.48 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="CQh2d8V6" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5d7e527becaso23155005a12.3 for ; Sun, 05 Jan 2025 10:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736100941; x=1736705741; 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=nCWum8u2aSE0H9NGugk1g+nl+FSObYpFAdsp0A4AhFk=; b=CQh2d8V6fMapEPmyoZng4SCtlKbEkpihSEOf2MgK3yVgahynmPLDNqoLvFgMD4Vr0a ZldnVRCGik6dnF9DQwsZRU+uRYOJcHq/KNGdxzeKQJgdRtih2M92nefDEvmhqhaX48Aj AvRW1TK5ASWYzT1rgzmFNN87KJewp4jZZ6l4k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736100941; x=1736705741; 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=nCWum8u2aSE0H9NGugk1g+nl+FSObYpFAdsp0A4AhFk=; b=qRnTXAqMi14WmU/QD0f0KwDW/+mwPrjuT8oTJZQmPVlDX5+Py0XeiWgiZOPgP8165B KN7amE/p62uTgnywFWaaYWP0WK/bwtpBbpo7qrATfyQ2YmfTgNiCEPAjEjET47nIdmP0 gFnTaZm5lyUA2jAPzE3wyPtYt7p53gPjSCoDzvYMBCyRmZmMw4roi1BcCG4f6Xc4PD7P wDSrLBF2dYQrvcFqSp4prp/t+ny0KSzrJxNlf4gu5Wp4D5yQB3/jHsCdtTmFPDTqMyz/ J9vb1KwbBv9vVzYZsv19QhadLd3SCrkmPLzqkDELSAMnxGurV+D8SuQ+xjpOPC8qjDeu oi3g== X-Gm-Message-State: AOJu0YyEHB7bwRjgGdSR3Qb1J4TqfP9KKacjZLJnYAX0aTuddZKlK6pA tPP6162GFHPu5wGhwQi1f4VmjKWZ6FKHjv+5jhsJ+rSJavXiEmFjq9afAOv9gYJaUKCWJSDk2Mx + X-Gm-Gg: ASbGnct+/0+BRdp/eCTdEaCC0zPcUxd0H7ID1hqJxRPOdSZwYW9oCkr+p8seyE9STrZ AcQ+zMfgKqibnQy6hi2d8a/hVPLCiW3ZKVNUYl9HuxsmLZ3AA4J/LDMWljnLXuOpzWgtBpWMRxC dSn+TPaSR/v167qU2bJ8IoneaD5jCOXUYjnJmvko9ojYg34Gh5JW5m/VcdqLEc+dlofkSDjhvo5 S1KvlKZcRAzhkp65WRau+PMQKIPhJau3sINmKyChE04zOzBPIKEb4v0NbWv9rNqMioMAxPbr1/a HTndNLX7HerMAA4HXxn1r/WytyAsH2mhXEjAm/VUac99C0nygJvuqsy7zCiyqUAGGQVxk3bP+65 1sf5Y/lrE2WmRHvPk2g== X-Google-Smtp-Source: AGHT+IFeu46e7LHQ6MyNCXFCxnHyuX7vCIGWrO/EtiZn47VacrN5DdmgWvSrKWY5flVSdhQ2UzUVwg== 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 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 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> 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 --- 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