From patchwork Tue Jan 14 09:11:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3799 Return-Path: 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 D8E693F174 for ; Tue, 14 Jan 2025 10:11:39 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5d3d9d6293fsf4580318a12.0 for ; Tue, 14 Jan 2025 01:11:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736845899; cv=pass; d=google.com; s=arc-20240605; b=HQ+bLqviAxXN+Doop7dg1i0r7A/BjTyKjrVojCZWvj+B6LLbDpd5x0ZvLEa+aZW+7Q 3ys5deJBRwQan1OXVlFSXk3D0s2v8UL12lj0J6PAfgOn3YigqZdVKfAYwsxz+9qleI8n dFAbekGO1Dr/TdTxZzIXrM0ZWzhSGFHZwsUFE4ff2/yj+5wWarKGwe+OLPeegtUx9BWo 7lSr+HjLY27WGwPZfneBJNMgC1NAIoRoxwnGaBMpU18Em0mwtaVoJOKJYzDFk2yUunqq qzy91p38qmo6gaKmLLKEEB/GKDfC9jhCIlBrwsT/X82MOBT8qrkTJoHY69VcCxy17bQW ZWfQ== 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=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; fh=zK9fWrrsFFOto7JJZkReofxEC2dpjbeVrB2x2ArWUKU=; b=Ar5eRfdYSEJgAy02ClchE7Pfm0RkYsN3T0iSJZfSMRrEfUUSdGy7ash+XOts5O0FUw zojAB3HKon1hTXEYpmxHdxg7oIcAx1p/MAGEEyhrqyiWVN8fFEOeIfY/4aoNhvSTy1yx 9SDwWCpDoHUlyY1OLVayjCDXDPrfFS6HYAP3r5SLE7eaDx+x7q8F86Wr16If/3w65wAY ef3+exJEEFMJp572t1fexD2GTKCVlBoyd3jM5CJ5OR1tK69EVEz8PvQTTyXW9mIQ1b7C eKAzHtdVAg0d0RCRBobGJGqx1js5gI3NI9geKj9Baj0VXfKFZ7/IxCgjgjzlDnix6No6 ka3A==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HMsljGCg; 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=1736845899; x=1737450699; 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=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; b=dJ6wWEiLZ+ZJUMy+NPfx8pYcdZiejjIIeu3QjuSGEnLzzE1PpJmG8e6APb5MCdYn1S qsXYsisQiRlqNVs71lCQ3RipC7Jd4HAJDpe2TWWAxjqGrfyIWMha1TxTFJClACK32DIR YjB0ywnCd/s2gB/zWL4xxpgYBIxBXLd5GDkxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736845899; x=1737450699; 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=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; b=wJE8pG8Cf0CIRGxNeDGXRC06rpgZ7hiPOlwekI5GHHXKpTj4yovwABnZ/rK36Pg7Ki 6n44hBxYdUdwQ+9Y/3dFEHynAgsUGW1F6rXBIbhQRF6WPzcDSj1uJ5y4RkuhvOyCeEfX yWCbD/3EUb3EvbaBpOoDhOaOPFOcq6dJUAX+qKYOXvW0u1DoGh9VvTc4BOodqix+ZeDT xmTB/HNIP0brc2p76RMhaKkuln6IQLCCpgxygC9F7mGqToobjN4z27qoBEZxXygxgYXq DRkwIedkl6/WAkVg0l/Lb5OJubE17n+2RtH5SZv6DIrmw+FNj2+nFskHfYYD+b40psYM P3jw== X-Forwarded-Encrypted: i=2; AJvYcCUyJUEpMLEemxpwDKuF958tYw4WWCLhyptHNhIWLINitgcXzY7qKj3SA1fcDMkYunSdzv7Sj5Uxc5il1j0p@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzgiN4ebUHSrf+divMEbHm6R2EyD8f9v0otp3+sqF7D22Z48FaJ Cg0YeEoS1vkZB7THnrjz5067sSbzqgXooAKaQ7IsEUdGl8xaCpZuQG4tytFjUOiy2WlmcLXLKw= = X-Google-Smtp-Source: AGHT+IFAQP4ouRS4ycEzD7VpqBOenrLU2LpfC4uXotai0A+vBRCiQ6WQygeMfvHKYV2YYPOIVPBfrg== X-Received: by 2002:a05:6402:3217:b0:5cf:bcaf:98ec with SMTP id 4fb4d7f45d1cf-5d972e48686mr21394562a12.26.1736845899390; Tue, 14 Jan 2025 01:11:39 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:8d15:0:b0:5d3:bf89:291f with SMTP id 4fb4d7f45d1cf-5d9851d963fls1855602a12.0.-pod-prod-07-eu; Tue, 14 Jan 2025 01:11:37 -0800 (PST) X-Received: by 2002:a17:906:6a1e:b0:aae:bac6:6659 with SMTP id a640c23a62f3a-ab2ab675c7bmr2234752566b.7.1736845897493; Tue, 14 Jan 2025 01:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736845897; cv=none; d=google.com; s=arc-20240605; b=FC9+TZhEEmXguVZBp2qsj4Z3USWjYL0jR5B2yDTzaiv4ZY5D/+OVh2ZfuFSGN06l1Q iurSwPu6ftODp9h+v4fH+OEVIqP7C/JHUXYqWwGfa9ZbqC8EC+n7qEsCtyxBM//UTzRq aE+mXcVl+YPvbqpJlbMtKxoacw4ojw/d7svefR4P8CkFUdRNamJnC0dorEhN3qLy0gyD lK3874dJ6AwMaf8Gn/04KbPLBm1zSvbkqEojZ5yErl3TOGyhrBi/lRsywq3CX0xTzZSX iYpgKqi90RvdqTr0QoGzjRSTK6SU3UTi0+zLYbcurqKgqS8/jzaFvRBezNio8NfdTjdL mdPg== 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=4PuckIz6TtMrm6FhKB7AMqxRoyDL7dpmszhuAU6edRg=; fh=LKhgYKqW/DH7bOgdnVELRgL+gR1eISg3bEXUN1rI9pA=; b=EBcyyiCr9Y+6B+J0WIM6f9BvdkDGeBTN+GHhCKfgjrx5Y4ujiioMWzQ/rIXUVnEh2i pHSww1oo2MS6sp0tNJQoDm7seA9jx+Rv/jLEXLxXSfBbcqZII4BIq1oSJWAqdlobhjQT SBPSrgrL5PHnO6XaaQprYe3qnf/SxEeXTSufjMIJBxg2qsDtmfuCwvb0GTNq4Oy7J9iJ XNZ0MqiKpNzQhVNzvvCMlFXhNENjPEcpCB6JEjxZJwTmnlp913CSemm+FX6cWZTMFU09 bUKZFufgKeCttJs4hpdbKUlMYn18+W3bEhrUTo4eRV8juiIAcmC4jolkAPRBN8TpPz4v kySQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HMsljGCg; 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-ab2c93f24b8sor420186966b.14.2025.01.14.01.11.37 for (Google Transport Security); Tue, 14 Jan 2025 01:11:37 -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: ASbGncslG86luW9iJoaIv22SttqBSUC3hr/mnQf36LI/otB5sS1IzKA6UzXsYpWwSAv 7cPauVOwqO+gDPIcOgQ/Obob+UNP9HX1PoiJp81E7y72PvaugL3q60dSAOMzg9gtNVmw7/XfZg7 V2zyfxqsibbJ/CScsC7267kKob66sUvBtQkCPqsFoVOwcIhjPAq3Fk8Lnxx1B4ddA84Booq/A6v FRachLH7J5bdHpl7r18x+lMmbM67yu6NPikYEtU/97LFZvAILUkvjjc/sOn0U1j010QMyR7t2CV dGaINppDcdqoLFOtwOY1ZQ== 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> 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=HMsljGCg; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 . */ +#include #include #include #include @@ -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);