From nobody Tue Dec 16 14:42:04 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 5D34F1FCF79 for ; Tue, 14 Jan 2025 18:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736878834; cv=none; b=EFby43VscChHctl0joQ2uWONHs7GEpUuGPD3WdL6DkHQW6UrwkIxRknruAVVNn5oXIbld3UiHDV/TrdMV/CH3OSOD8V3XLa/gSrvvFS2a57eE8dkZVPGBjiD7YzmDrcj2yvg6vvdajjTAE8UlJs3CDDp94a0fap16AawHSrH7J8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736878834; c=relaxed/simple; bh=54AnFoYFZcZqYgavjCEUI5tS3rZv1k1LrPOchNuHl/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MT8QO9jqmvV768MSnG8Atc73gNgimjSJ6GDJhWUTpiUxC9QPxxgbDB4qak49M/PgutwDUuctegDhA/S2fPEIPa9GTzOS9UYre2rlrQVI3Jnl7wHp0ntubkb9juEwCUabE+Tg3V+tOtlKWxtpvXsHWeQPBkKVm417YxTEWnDMzcg= 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=J/XG3Tmx; arc=none smtp.client-ip=209.85.128.45 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="J/XG3Tmx" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-436281c8a38so42006075e9.3 for ; Tue, 14 Jan 2025 10:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736878830; x=1737483630; 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=J/XG3TmxVxNxOaEVXd09pGGAEdlUlxkfu2aP/JKvNhmm3VWOAme82p/gz1EcCVlsmg Bu7xaR43zqzYdqvTHoeQQurLTXWJDGpU8iOpIq0MefXHdBCM7XAvkH6CFwQTP4DcGgjO 9kAGAfDD9JrG9tpNFc7sxC4PD/znl+3L4cxnM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878830; x=1737483630; 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=UleMb9bjgnz8xxBELZ8yzgeMvqL0vp/oNCru5o78gXEhRUzTswtVI+wauXk0nRLnm5 Er0+Nbk5S7qzZPQYTQXaOrsqIu53AgNJQoanCdYVPeZFowhh9U5twphzPJxyyo+Qs7zi eQ/t1mUZPGl7k3nzH9wT71w7TFPyr0KDRU80/AomHMj/10+R4/GNfA6sqSXJ5JGwuiYg zTGt7yhuPHQh5pafV0BfasL+ujVesL9cJUbZeT9for15FpJx2W6EzBVfIpPAUyvZHeUb gdFV+2QO8l6GbX/WMcJTM6kaIG8DgsojYDkgs4NSfnwOUm3QCKE6IcgphDpq4tjjMP05 M44g== X-Gm-Message-State: AOJu0YzoZMvflAmlU0H9ph/nABxlticLOu3wAbVFTBp8TnA/MZBaWEsf CiFLUUl7wVPxyLv67Ps1WYKOI/yG5xihlJ3IuuGh64Ql7/nESaez3bZiU1t99AAXfMmV3ExUFAn k X-Gm-Gg: ASbGncub49EDma7BrOTyFCMum+pvDU8z4rHAjtXHdoyp2coMSfQJdo3W1zumGFbF5tE O2hXZiAODDX8hrZ1K6tyJz1hcHMciPeyyp+svA3qVvI4yS2QKAX8Hoo31GEspYaXUWZmlvo79f2 BbMVDsqHiFCAh2koQyl7eAuTnqCvodL8F/pi0h6XrJukXXK8R48JtBJqEY2PvlrlJOqEwesMJ6M Dq7mgvKIFxsxx/3YtmSWYtcWA9VmDO/mdAFFNMJYuNN+s/3GpwnDggwPYQAaXuvC17QVHMncsOW mwjdKG6wbnMsWWuSOF7Nfg== X-Google-Smtp-Source: AGHT+IGg8Flgcd5l6IUz8p8YGCesmVvDp+YPLJXbTETLgCS7syXTYsMMOkRNhniDeCoESET8hKOsHw== X-Received: by 2002:a05:600c:4f0d:b0:434:ffe3:bc7d with SMTP id 5b1f17b1804b1-436e26ba521mr286846075e9.16.1736878830386; Tue, 14 Jan 2025 10:20:30 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38be66b01c7sm278970f8f.22.2025.01.14.10.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 10:20:30 -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 v4 3/4] clk: stm32f4: use FIELD helpers to access the PLLCFGR fields Date: Tue, 14 Jan 2025 19:19:48 +0100 Message-ID: <20250114182021.670435-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114182021.670435-1-dario.binacchi@amarulasolutions.com> References: <20250114182021.670435-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