From patchwork Tue Jan 14 18:19:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3805 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 335A13F332 for ; Tue, 14 Jan 2025 19:20:33 +0100 (CET) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4362f893bfasf31703695e9.1 for ; Tue, 14 Jan 2025 10:20:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736878833; cv=pass; d=google.com; s=arc-20240605; b=GJDeH/xz6pi6AeLbY4e5Xi9l27x2eRinX0/UzdrLOLKvKxHAqpkRzeilx9+XV8Il9c Haw0FfLiOZKXwsdI5qVYvRlZJLGbLoIW/OcTF5PK3HoZy6dDDhb3GXIDgTP1MB65+IBd w3Vy0ueHWusy0ar9mZD0udRl2xBWrioNpWbFQarOiu8KU5RLpOPfQMcWqMyjUjcOdpUx c5LpRG3+dkMLQ2tO/JmUfdcRFTsi/GVKa2mpugirQjkuhSAX16iUqpyC13QZQmP0bZ7Z HlNte5quLLjCFk/iLDITLaQv7FJpvmtK7CdbCoeLqbOJCv6d+dN5W0/sexWruRga/FD+ XLkw== 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=usAKvCm24jXo7bK2/FrHvgtk9ddavMwsGtAilWtbAEI=; b=Ii0VK+RxeX5ybC+01BqdKVGPi2Vj8XvRhhZqfBdtKtsXLgXmNqAHaFQAwQTBZS71AU Gp7H+NA14gmE4NnT2utMRrfDUv4P/98KP3XHuoXg956cRA4y9G51AiwNzWerQtDTUH49 io4MVvRLAs16Rtt9Fw0gM14yTeA7EBrtZns/HLvwhbpeITrFGf7CnOX+IWbqDiIZgmjC 1JXt4dIq1+MzxOsWQ3ujqf/fDJD9/mAGQBW+l3S87FSFOK0e4CMHmB1Mqa6bxQ/lMwtI bSUY1+FdoO+yVEVkH04/zKKU+X8U3ozHHbHywX4149ZkbloFJrBFmf7OPnqsKMChNsTu 3IYw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TLHgoYHl; 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=1736878833; x=1737483633; 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=C1+WbbuEkcl3OV0HK6Ej6Tbj5K/68WBpDheA6MRBlaCjppYYDHH+3GoJksmd0K4P7Q CB5R5bNA7JLm9x5N2SRTf+PicbajVmcOzkJd32kRY0IOgLvwCJKbrxA2SxtLol3NMa2M VmLfJcTmAn28Ze0g7PY7hKgeIbOHgcwx3X4fY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878833; x=1737483633; 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=jFqNnzj0nW5d/f8fygu9IQwftS+Xdn58Sy3oYd093ixLAylDKvm5yQnyzce35RSvc9 P8MnLzeGrsgS3JOOaArTgsRDcrlUllU7RsU4y6qSwshe42L1Tqctjf9g1db3fBoe6hvP FfWXmdGMIFrWj7SOxgbzuzXQALubKfKzxceBxYMSyM3JSlWckfGQgimJRSA2Qo1TYD9Y a6uBVQEeeeQfoMD/RdmAEgapD+UUoejyTKluFWEQ78tslhCj/j1w7fo4s5+kQT5RBLu6 E930I15DSmibOV3EtPsFEuNdDg/KCHotRN4j6PCN2OIfTO9RaeAqLtZGPRHO+tyCOi/c 0SVw== X-Forwarded-Encrypted: i=2; AJvYcCVIaOtW3Owqkv7XMGVsoRsg89OdISH8iuSa/YPy5JKtiLwK8S2QdfZihxktt7wrmerrwwiKw/zEzMNDtL0M@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwDMVo+6jHua3g6whoA2NjU1FG0cGBQnCIbVjz0blTbGdpqchHs 9af4trZAal0rKR70mpOfa7/YHwtM5fE/dc/jkImdwjzokikP3CdHVpqDROBo4ElT4g== X-Google-Smtp-Source: AGHT+IEupehV7X8PZYsXPT71GkEd4gQxs50W6YLAwr+1oBMcF6Q5YjZh9vs8WFLBVmr7e1Fjv914FQ== X-Received: by 2002:a05:600c:198c:b0:435:306:e5dd with SMTP id 5b1f17b1804b1-436e26f47e0mr210636225e9.22.1736878832770; Tue, 14 Jan 2025 10:20:32 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:4e08:b0:436:5d0c:e9a4 with SMTP id 5b1f17b1804b1-436e87e0c5cls2314495e9.0.-pod-prod-08-eu; Tue, 14 Jan 2025 10:20:31 -0800 (PST) X-Received: by 2002:a05:600c:3516:b0:436:5165:f206 with SMTP id 5b1f17b1804b1-436e27075eemr244363305e9.31.1736878830860; Tue, 14 Jan 2025 10:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736878830; cv=none; d=google.com; s=arc-20240605; b=X+4Y6t1pps4kIsyU3SLYOWXfuYiTc+e5AjdI+U8g1nUZut5HcGyg/zLX4mHKr5oMmL Ar4tnzvPXS1C5XxuQRwnB63XrqZL5bgrt8EFrUgpVddBY2w2dMP8FHYXpwQzx9yMSttN qDtgc3obF/p3cJYmAOsv7kHB01vkAIsBG5B6rT/QrjuR2/7MGTW7h/Ckgr492N+F/YVW uNlpK/9jMp0tIh7xPCdFKkyCnMvM/JRePytz9+QNipm/kXa35hY/LUIcJbznSbt5D6Jz Ohh1NMrRMRE8tKwf1czE0FiYvhb2bcZBSiU4NFmkAEwtlR9PDh1fOVYP2QxJ8wqLxT+A B5bw== 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=aD7Wxh+4P6bUEpohodxnQ6BqOoqYPI5eWTeXZXO0mb0fB0i0GX71xrRjM0szvoD6XI pmlnXSkwyVMhAmBFxYJ9YvCklBSs2x07wKgLV7A3Tctp1DLO43pJ19YtjVWtYFdbVeU8 BlwP3EVHSbHu5rQdSU5UUNe9YmUrIdY8hraE0GjytRcqETnj+RdpnOwFoLCdBmhbLSC/ Gw1Cg4M3pkAVWDwl5Ej1X2/AVxnfgiy+8rfxRxOUBvUwzphaevj2i40rLrEWLUKFmIjI 3v4R3dg7qTviyb4djQEy2hpmn5Gm9zdpL/r3fKEXDag5KS2JeKVK/xJQJC7RN9D76J2M hHWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TLHgoYHl; 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 5b1f17b1804b1-436e9997694sor37211055e9.6.2025.01.14.10.20.30 for (Google Transport Security); Tue, 14 Jan 2025 10:20:30 -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: ASbGncvDlXSbmgLq7DRD7j90vLTaLksE/Yf95lE9YHhVjOxXkjwP7oBIu6pEwzowdG8 vq5KAU89wXHZuhJKLD9GtocRVErnHJp34ZpLaRUmAX3ugdOW9Su8x8Lu6inDyaM3iZDuQ/LBxKb pMrzDfzmndk/kjZtAKYV71xnXkdO3lzZi7YAtkAgF6qRFDcNoSd5ZUhjReLNcgTXhi2LepiPcz2 5g3QVl+k4M2oOBiZmOvvo+Ra3N0q28t8POZKRXyKwE0ij3Sagaq1zmnrrayr/6FjHAYTyBfFt9D ui6YZlXruO5s82VblFwPSQ== 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> 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=TLHgoYHl; 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);