From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795021588; b=glOldYk1frg5XYtnt/wPiAuLmTM+Efiypu/wkahiSyLY9DP/uP5C40Mar1tahO8Z+qPA 5Byq462fUXQJeWrCYeTlERFecMFyeoghFAZRiUKX9oJSe7cpHsKJKfn63C6V8b8WkSICk RCbbwcuummYEBYxPZMlkdY0J18UEIocfZdyTEXHgWgRowjzkKV58BY95WlwHxzaRjAQDm t+ODW1EuIsSdtiKhCc1b9Kuyn/choEUTqjfhbMqcSXFryHJ85WL3hSYv5PxxqeySxFQ0o ADi3z1DwXmLX/wiUrJucqwWNQgLgMgxmkkxaCToKG9xCEbP8Ho357pZXDt5TB+b6HMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795021588; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Last-TLS-Session-Version; bh=n/KnFPEXkZk4mn/ZwqdLrpMQFF2e10V2K2RI4DEGki8=; b=Urkcv9Fns/6tw9gbkTg8mJ1eh3C1P8UI/mKSa064848s3qIjLRAf3SDvQDLCIVKHQ1CJ KMHpOIlIUV+zAHUvmMhjHs9fVmqU8Vin6VTxCV9cvofn9p3oSu9P3IYWEDk+gBLxCKzWb I1BJrsePQZtGQLbLavXP81zBgo99GCNRF7nyIHjkPB9dUMEEsOX24ZNSpjfbPfglfjjax JiCvoYZ6yThayH1OKhPVzJxDK+Eb5iZnBY3JHKulmsz9lSxZo1a/YkkSCdqpEXD8rJak2 CxVuGrHkzqqAGwMdj0DG3fYxuh9eJRAWU01cYP2GZ+sG1eEZpTFpaoExEGRZY+PMFTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=xXTIiLXL; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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.subspace.kernel.org (Postfix) with ESMTPS id 372A9606A32A for ; Wed, 18 Nov 2026 17:06:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 372A9606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=xXTIiLXL Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id E18644E415F3; Wed, 18 Nov 2026 17:06:26 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A95465FE9B; Wed, 18 Nov 2026 17:06:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B88DD11BC29F0; Wed, 18 Nov 2026 18:06:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795021584; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=n/KnFPEXkZk4mn/ZwqdLrpMQFF2e10V2K2RI4DEGki8=; b=xXTIiLXLapr6q0xRhwdqKZhf2E/byMMV5xrMkJnGVLXaMzq0H5YU9GjvBgTzX8nVbkMlFA wi/cMla2b1aORd/KyVJHcrNkfgX1T3JRZAG/Vgy0tKP+cPv4ZRtmK3yUc37w9BGP9E23eG R21S618eoCaJZ1LHcSdZuVsNGoOL35yCU6qPF1N81gmVnWGSOP2CdyHutapgivjs+VPJtV Us6GU1t+h0A2CDmwQAMQVDi55hQtiICHSgG2L9LSrtM0WcO2pH9aVVonTFE0rz2ltWa+Vm qPqFlczebmJ3pvmW+lYPGnZuDj+LEzu1+k5C4UY/yL0uPQtRWHp+uogeBPGO6g== From: Miquel Raynal Date: Wed, 18 Nov 2026 17:59:14 +0100 Subject: [PATCH v12 05/10] clk: nuvoton: ma35d1: Reparent the gates correctly 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 Message-Id: <20261118-perso-ma35d1-upstream-clk-v12-5-bee2c8dad4e1@bootlin.com> References: <20261118-perso-ma35d1-upstream-clk-v12-0-bee2c8dad4e1@bootlin.com> In-Reply-To: <20261118-perso-ma35d1-upstream-clk-v12-0-bee2c8dad4e1@bootlin.com> To: Jacky Huang , Shan-Chun Hung , Michael Turquette , Stephen Boyd , Richard Cochran , Arnd Bergmann , Brian Masney , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Jeffery , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair Cc: Thomas Petazzoni , Steam Lin , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski , devicetree@vger.kernel.org, openbmc@lists.ozlabs.org, Miquel Raynal , stable@vger.kernel.org X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The clock tree is still incorrect. There are four main clocks in this system: - HXT: external high-speed crystal oscillator - LXT: external low-speed crystal oscillator - HIRC: internal high-speed RC oscillator - LIRC: internal low-speed RC oscillator Each clock has a 'gate' control to disable it. While in the TRM the 'gate' appears aside, in the CCF topology, the gates should be below. This is because if we gate one of those clocks, none of the children clocks continue ticking. Reparent hxt_gate under hxt, and all hxt children under hxt_gate. Do the same for the three other clock sources listed above. After this change, the frequencies are identical, but the clock tree looks much closer to the reality. Fixes: 691521a367cf ("clk: nuvoton: Add clock driver for ma35d1 clock controller") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal --- drivers/clk/nuvoton/clk-ma35d1.c | 78 +++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c index 4019df22a74e..d69c9fc0f39e 100644 --- a/drivers/clk/nuvoton/clk-ma35d1.c +++ b/drivers/clk/nuvoton/clk-ma35d1.c @@ -74,34 +74,46 @@ static const struct clk_parent_data lxtg_parent_data[] = { }; /* Mux parent selection, by index into the controller's clock table */ -static const int ca35clk_parent_idx[] = { HXT, CAPLL, DDRPLL }; +static const int ca35clk_parent_idx[] = { HXT_GATE, CAPLL, DDRPLL }; static const int sysclk0_parent_idx[] = { EPLL_DIV2, SYSPLL }; -static const int sysclk1_parent_idx[] = { HXT, SYSPLL }; +static const int sysclk1_parent_idx[] = { HXT_GATE, SYSPLL }; static const int axiclk_parent_idx[] = { AXICLK_DIV2, AXICLK_DIV4 }; -static const int ccap_parent_idx[] = { HXT, VPLL, APLL, SYSPLL }; +static const int ccap_parent_idx[] = { HXT_GATE, VPLL, APLL, SYSPLL }; static const int sdh_parent_idx[] = { SYSPLL, APLL }; static const int dcu_parent_idx[] = { EPLL_DIV2, SYSPLL }; static const int gfx_parent_idx[] = { EPLL, SYSPLL }; -static const int dbg_parent_idx[] = { HIRC, SYSPLL }; -static const int timer0_parent_idx[] = { HXT, LXT, PCLK0, -1, -1, LIRC, -1, HIRC }; -static const int timer1_parent_idx[] = { HXT, LXT, PCLK0, -1, -1, LIRC, -1, HIRC }; -static const int timer2_parent_idx[] = { HXT, LXT, PCLK1, -1, -1, LIRC, -1, HIRC }; -static const int timer3_parent_idx[] = { HXT, LXT, PCLK1, -1, -1, LIRC, -1, HIRC }; -static const int timer4_parent_idx[] = { HXT, LXT, PCLK2, -1, -1, LIRC, -1, HIRC }; -static const int timer5_parent_idx[] = { HXT, LXT, PCLK2, -1, -1, LIRC, -1, HIRC }; -static const int timer6_parent_idx[] = { HXT, LXT, PCLK0, -1, -1, LIRC, -1, HIRC }; -static const int timer7_parent_idx[] = { HXT, LXT, PCLK0, -1, -1, LIRC, -1, HIRC }; -static const int timer8_parent_idx[] = { HXT, LXT, PCLK1, -1, -1, LIRC, -1, HIRC }; -static const int timer9_parent_idx[] = { HXT, LXT, PCLK1, -1, -1, LIRC, -1, HIRC }; -static const int timer10_parent_idx[] = { HXT, LXT, PCLK2, -1, -1, LIRC, -1, HIRC }; -static const int timer11_parent_idx[] = { HXT, LXT, PCLK2, -1, -1, LIRC, -1, HIRC }; -static const int uart_parent_idx[] = { HXT, SYSCLK1_DIV2 }; -static const int wdt0_parent_idx[] = { -1, LXT, PCLK3_DIV4096, LIRC }; -static const int wdt1_parent_idx[] = { -1, LXT, PCLK3_DIV4096, LIRC }; -static const int wdt2_parent_idx[] = { -1, LXT, PCLK4_DIV4096, LIRC }; -static const int wwdt0_parent_idx[] = { -1, -1, PCLK3_DIV4096, LIRC }; -static const int wwdt1_parent_idx[] = { -1, -1, PCLK3_DIV4096, LIRC }; -static const int wwdt2_parent_idx[] = { -1, -1, PCLK4_DIV4096, LIRC }; +static const int dbg_parent_idx[] = { HIRC_GATE, SYSPLL }; +static const int timer0_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK0, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer1_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK0, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer2_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK1, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer3_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK1, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer4_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK2, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer5_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK2, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer6_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK0, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer7_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK0, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer8_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK1, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer9_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK1, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer10_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK2, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int timer11_parent_idx[] = { HXT_GATE, LXT_GATE, PCLK2, -1, -1, + LIRC_GATE, -1, HIRC_GATE }; +static const int uart_parent_idx[] = { HXT_GATE, SYSCLK1_DIV2 }; +static const int wdt0_parent_idx[] = { -1, LXT_GATE, PCLK3_DIV4096, LIRC_GATE }; +static const int wdt1_parent_idx[] = { -1, LXT_GATE, PCLK3_DIV4096, LIRC_GATE }; +static const int wdt2_parent_idx[] = { -1, LXT_GATE, PCLK4_DIV4096, LIRC_GATE }; +static const int wwdt0_parent_idx[] = { -1, -1, PCLK3_DIV4096, LIRC_GATE }; +static const int wwdt1_parent_idx[] = { -1, -1, PCLK3_DIV4096, LIRC_GATE }; +static const int wwdt2_parent_idx[] = { -1, -1, PCLK4_DIV4096, LIRC_GATE }; static const int spi0_parent_idx[] = { PCLK1, APLL }; static const int spi1_parent_idx[] = { PCLK2, APLL }; static const int spi2_parent_idx[] = { PCLK1, APLL }; @@ -109,11 +121,11 @@ static const int spi3_parent_idx[] = { PCLK2, APLL }; static const int qspi_parent_idx[] = { PCLK0, APLL }; static const int i2s_parent_idx[] = { APLL, SYSCLK1_DIV2 }; static const int can_parent_idx[] = { APLL, VPLL }; -static const int cko_parent_idx[] = { HXT, LXT, HIRC, LIRC, +static const int cko_parent_idx[] = { HXT_GATE, LXT_GATE, HIRC_GATE, LIRC_GATE, AXICLK_DIV4, SYSPLL, DDRPLL, EPLL_DIV2, APLL, VPLL }; -static const int smc_parent_idx[] = { HXT, PCLK4 }; -static const int kpi_parent_idx[] = { HXT, LXT }; +static const int smc_parent_idx[] = { HXT_GATE, PCLK4 }; +static const int kpi_parent_idx[] = { HXT_GATE, LXT_GATE }; static const struct clk_div_table ip_div_table[] = { {0, 2}, {1, 4}, {2, 6}, {3, 8}, {4, 10}, @@ -283,16 +295,16 @@ static int ma35d1_clocks_probe(struct platform_device *pdev) clk_base + REG_CLK_PWRCTL, 3); hws[CAPLL] = ma35d1_reg_clk_pll(dev, CAPLL, pllmode[0], "capll", - hws[HXT], clk_base + REG_CLK_PLL0CTL0); + hws[HXT_GATE], clk_base + REG_CLK_PLL0CTL0); hws[SYSPLL] = ma35d1_clk_fixed("syspll", 180000000); hws[DDRPLL] = ma35d1_reg_clk_pll(dev, DDRPLL, pllmode[1], "ddrpll", - hws[HXT], clk_base + REG_CLK_PLL2CTL0); + hws[HXT_GATE], clk_base + REG_CLK_PLL2CTL0); hws[APLL] = ma35d1_reg_clk_pll(dev, APLL, pllmode[2], "apll", - hws[HXT], clk_base + REG_CLK_PLL3CTL0); + hws[HXT_GATE], clk_base + REG_CLK_PLL3CTL0); hws[EPLL] = ma35d1_reg_clk_pll(dev, EPLL, pllmode[3], "epll", - hws[HXT], clk_base + REG_CLK_PLL4CTL0); + hws[HXT_GATE], clk_base + REG_CLK_PLL4CTL0); hws[VPLL] = ma35d1_reg_clk_pll(dev, VPLL, pllmode[4], "vpll", - hws[HXT], clk_base + REG_CLK_PLL5CTL0); + hws[HXT_GATE], clk_base + REG_CLK_PLL5CTL0); hws[EPLL_DIV2] = ma35d1_clk_fixed_factor(dev, "epll_div2", "epll", 1, 2); hws[EPLL_DIV4] = ma35d1_clk_fixed_factor(dev, "epll_div4", "epll", 1, 4); @@ -460,7 +472,7 @@ static int ma35d1_clocks_probe(struct platform_device *pdev) hws[CKO_GATE] = ma35d1_clk_gate(dev, "cko_gate", "cko_div", clk_base + REG_CLK_SYSCLK1, 13); - hws[GTMR_GATE] = ma35d1_clk_gate(dev, "gtmr_gate", "hirc", + hws[GTMR_GATE] = ma35d1_clk_gate(dev, "gtmr_gate", "hirc_gate", clk_base + REG_CLK_SYSCLK1, 14); hws[GPA_GATE] = ma35d1_clk_gate(dev, "gpa_gate", "hclk0", @@ -661,7 +673,7 @@ static int ma35d1_clocks_probe(struct platform_device *pdev) hws[UART16_GATE] = ma35d1_clk_gate(dev, "uart16_gate", "uart16_div", clk_base + REG_CLK_APBCLK0, 28); - hws[RTC_GATE] = ma35d1_clk_gate(dev, "rtc_gate", "lxt", + hws[RTC_GATE] = ma35d1_clk_gate(dev, "rtc_gate", "lxt_gate", clk_base + REG_CLK_APBCLK0, 29); hws[DDR_GATE] = ma35d1_clk_gate(dev, "ddr_gate", "ddrpll", clk_base + REG_CLK_APBCLK0, 30); -- 2.56.0