From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796115403; b=HkJfbWwysAnj/Y55qzutL8MSgyin+YG6umkU4R8Ywy6Vqq5+T2O9GFxCP/CH13KlD19d 6qXy0yC5OntmTcoJWWOqiOvJd7oucol7FP8CA8EAxyD5sSohl1gMnOzGC4eQ2CgYuCfUX pMoNiPR3aQJ4h8DSUzljQBTJfT3zD//m7m4VHNgnZhRC53iv7HqdioR4bI5giy37b2JO+ zJPvh6f0vWnNMDCoo1I468UYuMu+KjUyfSzeEgHRYk7Q//3XblfIgFHkRxMvNEhrmD6sF Hpo+PU4Be8J50nwH1YNSGu4lX80r1z4rKUKDGewI4x3oPqk2iF/LPsPHsp3rKXq23bg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115403; h=Received:DKIM-Signature:Received:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=VsqIlMAR1xltTk8Su29PbnAIQ0Q1JmOrCjXEs1DRm4U=; b=L3ql/wY2Yfm79Gu/aX8BCk9bWhM64sJjyd2Q6iFcsCn9Y4LiUnDJKLaBkr00zVTIozBa yo3nygmqpx58kwh57M6GKdqKDPkS/QQ0bJNEirR2QwzssgKTLrP+JE0gxJBEh3qo+XVkM fPHvpRj6A8A/dMgA9eofNRPHtRkjC0LHeY0wry8ERBoprem9L9/KBsPrdDZgLM3TvX392 uYAx7FoubhCqQakFjoexuaxfvHOHoKTyrabxmtyS+Z8OQ2dA3N2928QqKiymamO1JNSve 0wfBh0g5yJhr8iVXDbDT9ZBpXoQdv+/HmA/BCd5aHCb0LXMYearoAiJASKX545o1yiA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Eok3NMvP; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB5BD606A334; Tue, 1 Dec 2026 08:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Eok3NMvP Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796115403; b=uZX89lsABvQ9jl0Om1FhFpDLC3SB3hyekLlPC4Ww6DWY7+6KaV+TSmPXZBhZ5rRYbuQw RavxEwNKhh3xE6cDYd9z21mbQyyHHxarhTusyh2buwYz9orDSDfuibn1r66nOmnOGHx8+ aDrGVx6cBblYFP09TA7Sx1okEwY+tOr6I367PClcq4MBizgm3pQImTlMtsezbb9zHNeT9 uX0LpAna6hAsCRwU4Sm019eA6TKljbsDDjCJMsJ0S8Z2gKs1PL5cH7dd5DxpeNFqSH57T GuS8kjE1znQEfFynRZtHXWhzs7dJDCWJgnrdOIPGeTKeXN158CeleUCnN9ULOnDuNqw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796115403; h=DKIM-Signature:Received:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=VsqIlMAR1xltTk8Su29PbnAIQ0Q1JmOrCjXEs1DRm4U=; b=QQG3Qm74QAzVU+urV8RS5LK8fEXvIHfU4i2OT6sx0R4Bft3igzdGM0cSxZ6m/dq6R7bL lcNavMx0sIAE0E1UcLgdIwippj3/n5IaIjn2vcQXOH/CdOmZuvGg1fUY/dUwLddqmET8N 1fwPctcAIXEpoduLZhkMs0fiBhu0eJ8eINBUqgPyE7/nRW2A+evOoNe/MBSXImZgbT+OM A1cYKNNDMdDF7cd07Q2DSw73s1pjip42vOlPo2oVu/HjseFRqckp3EH2LbvO3vVg9KY7X gNrvWS8p2zFFFq+PO0i32wFJbQxw2vM54RVWmqrxHmCqtOLg2J6SvUjZlweeuTkSGVg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id B8D571F00898; Tue, 1 Dec 2026 08:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115403; bh=VsqIlMAR1xltTk8Su29PbnAIQ0Q1JmOrCjXEs1DRm4U=; h=From:Subject:Date:To:Cc:Reply-To; b=Eok3NMvPzrAw1doz9KwEjF4vpr+pXkdeq5og999kmNp1YOt+meCduHV5KCWoS+0iz Mz7M7gxzf28Vl+hgCDWIhNvTuSZZ/YtNFgRzgLONw85vPUzZZtqOCF2oyW+oOXWecQ uEriO8nvGYOdCp7qUWW9kmxfoIm1CWJ0Pz/0z7iydURvXD7h/8fj6drKf7FMg/7fGW c4eGX1/he+PuaUb/Pt1B5pDsfE0hE5MD8favcnYc1cBHr0lsUluV+x08yYgxM9gPXv ie3dQiMD8TPWHafEyduTnaEWyVU+14IWo9h8ksJutVU0gdvgGkYA7ZVfez1u7zfK3S ERUtHlUhth2aA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 170F14EC7D; Tue, 1 Dec 2026 08:56:41 +0000 (UTC) From: Jian Hu via B4 Relay Subject: [PATCH RFC RFT v3 00/13] clk: meson: Refactor PLL pre-divider as a divider clock Date: Tue, 01 Dec 2026 16:56:13 +0800 Message-Id: <20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAK2LDmsC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyjHUUlJIzE vPSU3UzU4B8JSMDIzNDQyMz3dzU4vy8+KLUtMTkkvyi+DzdNDMDc7PkVEPDRFNjJaC2AqBcZgX YyGilIDdnkFiQW4hSbG0tAH0LCApuAAAA X-Change-ID: 20261126-meson_refactor_n-f6076ce11a53 To: Stephen Boyd , Brian Masney , Jerome Brunet , Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Carlo Caione , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Jian Hu X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796115398; l=5637; i=jian.hu@amlogic.com; s=20260415; h=from:subject:message-id; bh=xxrf8ecrdTdnDfGPs+Nlvoq4hYn+AKMxQJkhMSrIdPg=; b=Ka1C1Mh+gJI0kL7Hwf6dERMH4F3FZNsYrW4dYOa9tzLC89rN0uOP2hDCokJJ9Z2GdD5N4U7af BjZyZGwwSOfC0SMFZqJEnFsZ8L3wSCv9Tby36zOHhi3+dhfILJ0PrAX X-Developer-Key: i=jian.hu@amlogic.com; a=ed25519; pk=zHUE+rNtH9z+Sb8au1/elWknjFQmy5QDVkBoxleuOIA= X-Endpoint-Received: by B4 Relay for jian.hu@amlogic.com/20260415 with auth_id=735 X-Original-From: Jian Hu Reply-To: jian.hu@amlogic.com This series refactors the Meson PLL driver to remove the dedicated PLL pre-divider (N) parameter from the PLL implementation and model it as a separate divider clock. Currently, the Meson PLL driver models the PLL pre-divider using a dedicated n field in struct meson_clk_pll_data. This makes the pre-divider part of the PLL-specific implementation, although the Common Clock Framework already provides a generic divider clock. The pre-divider is not intended to be dynamically adjusted. Each PLL has a fixed N value as part of its configuration. Most PLLs use N = 1, while a few special cases use N = 3 to satisfy their PLL input frequency constraints. Modeling the pre-divider as a separate divider clock removes PLL-specific handling and simplifies the PLL driver. The series updates the Amlogic SoC clock drivers to use standalone pre-divider clocks, with the PLL DCO taking the pre-divider clock as its parent instead of the input clock directly. It also adds the required clock IDs. Some Amlogic PLL pre-dividers read as zero after reset, which does not produce a usable clock. The existing divider implementation reports the parent rate for a zero divisor, potentially hiding this invalid state. In addition, when the requested pre-divider rate equals the parent rate, the divider must be configured with a divisor of 1. The zero value read from the register after reset must not prevent the divider from being configured correctly. To address these issues, the series introduces CLK_DIVIDER_INVALID_ZERO, allowing dividers with an invalid zero value to report a rate of zero instead of incorrectly reporting the parent rate. The common clock framework gained CLK_DIVIDER_INVALID_ZERO (BIT(9)), so the divider flags no longer fit in the u8 field of struct clk_regmap_div_data. Widen the divider flags to u16. Tested on: T7, C3, S4, AXG, GXL, SM1 and A1. Signed-off-by: Jian Hu --- Changes in v3: - Rebase to clk-amlogic. - return -EINVAL when divisor equals 0 in divider_ro_determine_rate(). - Separate patch for widen the divider flags. - Split the SoC changes for prediv clock. - Add CLK_DIVIDER_ONE_BASED for RO prediv. - Drop CLK_SET_RATE_PARENT for hdmi clock. - Update the comment for prediv table. - Add CLK_GET_RATE_NOCACHE for pcie prediv clock. - Rework meson_clk_pll_determine_rate(). - Described with a pll_mult_range for contiguous table. - Covert the table to const unsigned int * array. - Link to v2: https://lore.kernel.org/r/20261029-meson_refactor_n-v2-0-ff4ac74e527b@amlogic.com Changes in v2: - Add CLK_DIVIDER_INVALID_ZERO. - Add all SoCs prediv clock index. - Support table for pll m. - Fix the `determine` logic: when `best_parent_rate` equals 0, recalculate a new `parent_rate`. - Add all SoCs pll prediv clocks. - Link to v1: https://lore.kernel.org/r/20260923-meson_refactor_n-v1-0-3a8ce27121a2@amlogic.com --- Jian Hu (13): clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag clk: meson: clk-regmap: Widen the divider flags to 16 bits dt-bindings: clock: amlogic: Add PLL pre-divider clock IDs clk: meson: axg: Model the PLL pre-divider as a divider clock clk: meson: a1: Model the PLL pre-divider as a divider clock clk: meson: c3: Model the PLL pre-divider as a divider clock clk: meson: gxbb: Model the PLL pre-divider as a divider clock clk: meson: g12a: Model the PLL pre-divider as a divider clock clk: meson: meson8: Model the PLL pre-divider as a divider clock clk: meson: s4: Model the PLL pre-divider as a divider clock clk: meson: s7: Model the PLL pre-divider as a divider clock clk: meson: t7: Model the PLL pre-divider as a divider clock clk: meson: pll: Remove the dedicated n parameter drivers/clk/clk-divider.c | 5 + drivers/clk/meson/a1-pll.c | 69 ++++-- drivers/clk/meson/axg.c | 210 +++++++++++------- drivers/clk/meson/c3-pll.c | 97 ++++++-- drivers/clk/meson/clk-pll.c | 241 +++++++++++--------- drivers/clk/meson/clk-pll.h | 14 +- drivers/clk/meson/clk-regmap.h | 2 +- drivers/clk/meson/g12a.c | 282 ++++++++++++++++++------ drivers/clk/meson/gxbb.c | 260 +++++++++++++--------- drivers/clk/meson/meson8-ddr.c | 33 ++- drivers/clk/meson/meson8b.c | 209 +++++++++++------- drivers/clk/meson/s4-pll.c | 130 ++++++++--- drivers/clk/meson/s7-pll.c | 33 ++- drivers/clk/meson/t7-pll.c | 192 ++++++++++++---- include/dt-bindings/clock/amlogic,a1-pll-clkc.h | 3 + include/dt-bindings/clock/amlogic,c3-pll-clkc.h | 3 + include/dt-bindings/clock/amlogic,s4-pll-clkc.h | 4 + include/dt-bindings/clock/amlogic,s7-pll-clkc.h | 1 + include/dt-bindings/clock/amlogic,t7-pll-clkc.h | 6 + include/dt-bindings/clock/axg-clkc.h | 5 + include/dt-bindings/clock/g12a-clkc.h | 8 + include/dt-bindings/clock/gxbb-clkc.h | 4 + include/dt-bindings/clock/meson8-ddr-clkc.h | 1 + include/dt-bindings/clock/meson8b-clkc.h | 4 + include/linux/clk-provider.h | 3 + 25 files changed, 1259 insertions(+), 560 deletions(-) --- base-commit: 48275f2f75fd2a45a15f5fad2c8a2201ac465826 change-id: 20261126-meson_refactor_n-f6076ce11a53 Best regards, -- Jian Hu