clk / clocksource: Add Ingenic X1600 SoC support
Subsystems (4)
cover clk / clocksource: Add Ingenic X1600 SoC support
PATCH V1 2026-10-25 20:18:26:
This patch series introduces hardware support for the Clock Generation Unit (CGU) and the Timer Clock Unit (TCU) found in the Ingenic X1600 SoC. To achieve this cleanly, the common Ingenic clock and timer infrastructure is modernized and parameterized.
As a side effect of making the core structures flexible enough to handle the architectural layout of the X1600, it became straightforward to fully integrate support for the legacy JZ4730 SoC later.
The series is structured as follows:
Patch 1: Adds the device tree bindings and clock definitions for the X1600,
incorporating the specific I2S handling, routing, and RX/TX gates.
Patch 2: Implements the Ingenic X1600 CGU clock driver. It updates the common
CGU core framework to support secondary post-VCO dividers (OD1), and bypasses the lack of compound divider support via explicit mdiv/nddiv handling for the I2S clocks.
Patch 3&4: Adapt the existing JZ4760 and X1000 CGU drivers to match the expanded
signature of the calc_m_n_od() callback from Patch 2, preventing compilation breakages.
The changes have been successfully tested on CI20 (JZ4780), LX16 (X1600). And on LX20 (X2000), LX26 (X2600) boards (with additional, specific patches).
H. Nikolaus Schaller (3):
dt-bindings: clock: Add Ingenic X1600 CGU bindings
clk: ingenic: jz4760-cgu: Adapt calc_m_n_od() to core framework
changes
clk: ingenic: x1000-cgu: Adapt calc_m_n_od() to core framework changes
Paul Boddie (1):
clk: ingenic: Add Ingenic X1600 CGU clock driver support
.../bindings/clock/ingenic,cgu.yaml | 2 + drivers/clk/ingenic/Kconfig | 10 + drivers/clk/ingenic/Makefile | 1 + drivers/clk/ingenic/cgu.c | 150 ++++-- drivers/clk/ingenic/cgu.h | 42 +- drivers/clk/ingenic/jz4760-cgu.c | 3 +- drivers/clk/ingenic/x1000-cgu.c | 3 +- drivers/clk/ingenic/x1600-cgu.c | 476 ++++++++++++++++++ include/dt-bindings/clock/ingenic,x1600-cgu.h | 64 +++ 9 files changed, 716 insertions(+), 35 deletions(-) create mode 100644 drivers/clk/ingenic/x1600-cgu.c create mode 100644 include/dt-bindings/clock/ingenic,x1600-cgu.h
Signature · 1 line
2.56.0
PATCH 1/4 dt-bindings: clock: Add Ingenic X1600 CGU bindings
Add the device tree bindings and the clock ID definitions for the Clock Generation Unit (CGU) of the Ingenic X1600 SoC.
The clock layout features specific I2S handling. To properly support the I2S controllers on the X1600 without relying on complex compound dividers that are not yet natively supported by the drivers, split the structures to explicitly describe the additional I2S divider fields. This design accounts for the current driver limitations regarding division encoding while matching the hardware's internal gating architecture.
Furthermore, introduce dedicated I2S0 RX and TX clock definitions to allow independent and precise routing for I2S stream usage.
--- .../bindings/clock/ingenic,cgu.yaml | 2 + include/dt-bindings/clock/ingenic,x1600-cgu.h | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 include/dt-bindings/clock/ingenic,x1600-cgu.h
Documentation/devicetree/bindings/clock/ingenic,cgu.yaml +2 -0
@@ -28,6 +28,7 @@ select: - ingenic,jz4770-cgu - ingenic,jz4780-cgu - ingenic,x1000-cgu + - ingenic,x1600-cgu - ingenic,x1830-cgu required: - compatible
@@ -58,6 +59,7 @@ properties: - ingenic,jz4770-cgu - ingenic,jz4780-cgu - ingenic,x1000-cgu + - ingenic,x1600-cgu - ingenic,x1830-cgu - const: simple-mfd minItems: 1
include/dt-bindings/clock/ingenic,x1600-cgu.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.56.0
Re: [PATCH 1/4] dt-bindings: clock: Add Ingenic X1600 CGU bindings
Quoted 58 lines · H. Nikolaus Schaller
Add the device tree bindings and the clock ID definitions for the Clock Generation Unit (CGU) of the Ingenic X1600 SoC.
The clock layout features specific I2S handling. To properly support the I2S controllers on the X1600 without relying on complex compound dividers that are not yet natively supported by the drivers, split the structures to explicitly describe the additional I2S divider fields. This design accounts for the current driver limitations regarding division encoding while matching the hardware's internal gating architecture.
Furthermore, introduce dedicated I2S0 RX and TX clock definitions to allow independent and precise routing for I2S stream usage.
Co-developed-by Paul Boddie <[email protected]>Signed-off-by Paul Boddie <[email protected]>Co-developed-by H. Nikolaus Schaller <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>--- .../bindings/clock/ingenic,cgu.yaml | 2 + include/dt-bindings/clock/ingenic,x1600-cgu.h | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 include/dt-bindings/clock/ingenic,x1600-cgu.hDocumentation/devicetree/bindings/clock/ingenic,cgu.yaml +2
-0@@ -28,6 +28,7 @@ select: - ingenic,jz4770-cgu - ingenic,jz4780-cgu - ingenic,x1000-cgu + - ingenic,x1600-cgu - ingenic,x1830-cgu required: - compatible@@ -58,6 +59,7 @@ properties: - ingenic,jz4770-cgu - ingenic,jz4780-cgu - ingenic,x1000-cgu + - ingenic,x1600-cgu - ingenic,x1830-cgu - const: simple-mfd minItems: 1include/dt-bindings/clock/ingenic,x1600-cgu.h new file +8
-0@@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ +/* +* This header provides clock numbers for the ingenic,x1600-cgu DT binding. +* +* They are roughly ordered as: +* - external clocks +* - PLLs +* - muxes/dividers in the order they appear in the x1600 programmers manual
include/dt-bindings/clock/ingenic,x1600-cgu.h line 18
Quoted 10 lines
include/dt-bindings/clock/ingenic,x1600-cgu.h new file +10
-0+* - gates in order of their bit in the CLKGR* registers +*/ + +#ifndef __DT_BINDINGS_CLOCK_X1600_CGU_H__ +#define __DT_BINDINGS_CLOCK_X1600_CGU_H__ + +/* +* beware of unwritten rules: +* - list must start with 0 +* - list must not have "holes"
Please drop this, no need for individual souces to document standard rules. If you think documentation misses them, then please update writing-bindings doc.
If this is driver requirement, then please fix your driver not to impose such rules, although these two particularly are fine rules.
include/dt-bindings/clock/ingenic,x1600-cgu.h line 21
Quoted 3 lines
include/dt-bindings/clock/ingenic,x1600-cgu.h new file +3
-0+* - all clock parents must have lower number than a clock itself so that +* parents are initialized before +*/
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: clock: Add Ingenic X1600 CGU bindings
In reply to H. Nikolaus SchallerQuoted 11 lines · H. Nikolaus Schaller
Add the device tree bindings and the clock ID definitions for the Clock Generation Unit (CGU) of the Ingenic X1600 SoC.
The clock layout features specific I2S handling. To properly support the I2S controllers on the X1600 without relying on complex compound dividers that are not yet natively supported by the drivers, split the structures to explicitly describe the additional I2S divider fields. This design accounts for the current driver limitations regarding division encoding while matching the hardware's internal gating architecture.
Quoted 8 lines
Furthermore, introduce dedicated I2S0 RX and TX clock definitions to allow independent and precise routing for I2S stream usage.
Co-developed-by Paul Boddie <[email protected]>Signed-off-by Paul Boddie <[email protected]>Co-developed-by H. Nikolaus Schaller <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>---
One more nit:
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v7.1-rc7/source/Documentation/devicetree/bindings/submitting-patches.rst#L23
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: clock: Add Ingenic X1600 CGU bindings
Hi Krzysztof,
Quoted 23 lines
Am 30.10.2026 um 12:24 schrieb Krzysztof Kozlowski <[email protected]>:
Quoted 11 lines · H. Nikolaus Schaller
Add the device tree bindings and the clock ID definitions for the Clock Generation Unit (CGU) of the Ingenic X1600 SoC.
The clock layout features specific I2S handling. To properly support the I2S controllers on the X1600 without relying on complex compound dividers that are not yet natively supported by the drivers, split the structures to explicitly describe the additional I2S divider fields. This design accounts for the current driver limitations regarding division encoding while matching the hardware's internal gating architecture.
Quoted 8 lines
Furthermore, introduce dedicated I2S0 RX and TX clock definitions to allow independent and precise routing for I2S stream usage.
Co-developed-by Paul Boddie <[email protected]>Signed-off-by Paul Boddie <[email protected]>Co-developed-by H. Nikolaus Schaller <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>---
Quoted 7 lines
One more nit:
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v7.1-rc7/source/Documentation/devicetree/bindings/submitting-patches.rst#L23
thanks for both suggestions!
A V2 is in preparation covering the previous and this comment and other aspects as well.
BR nd thanks,
Nikolaus
PATCH 2/4 clk: ingenic: Add Ingenic X1600 CGU clock driver support
In reply to H. Nikolaus SchallerFrom: Paul Boddie <[email protected]>
Introduce clock driver support for the Clock Generation Unit (CGU) found in the Ingenic X1600 SoC.
To support the X1600 platform, update the common Ingenic CGU core framework to accommodate a secondary post-VCO divider (OD1) within the PLL configuration registers. Additionally, prevent a NULL pointer dereference in the rate determination path by properly supplying the secondary divider tracking during PLL calculation calls.
Implement custom handling for the I2S clocks on the X1600. Since complex compound hardware dividers are not yet natively supported by the core framework, explicit M-divider (mdiv) and N/D-divider (nddiv) structures are introduced to describe these specialized fields. This avoids a compilation failure and enables a stable, though limited, division encoding suitable for current needs.
Furthermore, this patch:
- Fixes the gating of the I2S0 and I2S1 clocks, matching the control bit behavior which functions as a clock enable flag.
- Introduces the custom OTG PHY clock operations and initialisation routines utilizing the hardware's OPCR registers.
- Registers the independent I2S0 RX and TX gate clocks employed by the X1600 peripheral block.
Tested successfully on the LX16 (X1600) boards and CI20 (JZ4780) to not interefere.
Checkpatch complains about not 4 lines of help paragraph but the style is the same as for the other machines. It also recommends using 'unsigned int' for the new struct ingenic_cgu_mdiv_info and struct ingenic_cgu_nddiv_info but this follows the style 'unsigned' of all other structs in cgu.h. Finally it complains about the empty line between struct ingenic_cgu_clk_info x1600_cgu_clocks[] = { and the comment. But I think it is more readable this way.
--- drivers/clk/ingenic/Kconfig | 10 + drivers/clk/ingenic/Makefile | 1 + drivers/clk/ingenic/cgu.c | 150 +++++++--- drivers/clk/ingenic/cgu.h | 42 ++- drivers/clk/ingenic/x1600-cgu.c | 476 ++++++++++++++++++++++++++++++++ 5 files changed, 646 insertions(+), 33 deletions(-) create mode 100644 drivers/clk/ingenic/x1600-cgu.c
drivers/clk/ingenic/Kconfig +10 -0
@@ -75,6 +75,16 @@ config INGENIC_CGU_X1000 If building for a X1000 SoC, you want to say Y here. +config INGENIC_CGU_X1600 + bool "Ingenic X1600 CGU driver" + default MACH_X1600 + select INGENIC_CGU_COMMON + help + Support the clocks provided by the CGU hardware on Ingenic X1600 + and compatible SoCs. + + If building for a X1600 SoC, you want to say Y here. + config INGENIC_CGU_X1830 bool "Ingenic X1830 CGU driver" default MACH_X1830
drivers/clk/ingenic/Makefile +1 -0
@@ -7,5 +7,6 @@ obj-$(CONFIG_INGENIC_CGU_JZ4760) += jz4760-cgu.o obj-$(CONFIG_INGENIC_CGU_JZ4770) += jz4770-cgu.o obj-$(CONFIG_INGENIC_CGU_JZ4780) += jz4780-cgu.o obj-$(CONFIG_INGENIC_CGU_X1000) += x1000-cgu.o +obj-$(CONFIG_INGENIC_CGU_X1600) += x1600-cgu.o obj-$(CONFIG_INGENIC_CGU_X1830) += x1830-cgu.o obj-$(CONFIG_INGENIC_TCU_CLK) += tcu.o
drivers/clk/ingenic/cgu.c +118 -32
262 lines not on this page · raw message
drivers/clk/ingenic/cgu.h +41 -1
72 lines not on this page · raw message
drivers/clk/ingenic/x1600-cgu.c new file +476 -0
476 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 2/4] clk: ingenic: Add Ingenic X1600 CGU clock driver support
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [High] clk: ingenic: uninitialized m and n in x1600_pll_calc_m_n_od() - [High] clk: ingenic: x1600…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [High] clk: ingenic: uninitialized m and n in x1600_pll_calc_m_n_od()
- [High] clk: ingenic: x1600: overlapping mux and div bits for X1600_CLK_CIMMCLK
- [High] clk: ingenic: x1600: missing .gate initializer for X1600_CLK_RTC
- [High] clk: ingenic: x1600: duplicate CLKGR0 gate bit for SADC and UART0
- [High] clk: ingenic: broken mdiv handling in ingenic_clk_calc_div() and set_rate()
- [High] clk: ingenic: x1600-cgu requires undocumented clk12m external DT clock
- [Medium] clk: ingenic: off-by-one od_max check in ingenic_pll_recalc_rate_od()
- [Medium] clk: ingenic: uninitialized d_reg and signed shift in ingenic_clk_set_rate()
- [Medium] clk: ingenic: x1600: missing -1 parent sentinels for X1600_CLK_OTGPHY
- [Medium] clk: ingenic: x1600: missing cgu->lock in OTG PHY enable/disable callbacks --
commit 3e8079f374773cb8ca4b149b680046e60d28f341
Author: Paul Boddie <[email protected]>
clk: ingenic: Add Ingenic X1600 CGU clock driver support
This commit adds Clock Generation Unit (CGU) driver support for the Ingenic X1600 SoC, including custom OTG PHY and PLL rate calculation handlers. It also extends the common Ingenic CGU core to handle secondary post-VCO PLL dividers (OD1) and fractional I2S M/N/D divider fields.
Quoted 28 lines
drivers/clk/ingenic/cgu.c +20
-0@@ -76,6 +77,40 @@ ingenic_cgu_gate_set(struct ingenic_cgu *cgu,* PLL operations */ +static unsigned +ingenic_pll_recalc_rate_od (u32 ctl,u8 od_shift,u8 od_bits,u8 od_max, +const s8 *od_encoding) +{ +unsigned int od, od_enc =0 ; + +if (od_bits >0 ) { + od_enc = ctl >> od_shift; + od_enc &=GENMASK (od_bits -1 ,0 ); + } + +/* +* Use the encoding table if indicated. Otherwise, use the value +* directly, interpreting an encoded value of zero as a divider +* value of one. +*/ +if (od_encoding) { +for (od =0 ; od < od_max; od++) +if (od_encoding[od] == od_enc) +break ;
drivers/clk/ingenic/cgu.c ingenic_cgu_gate_set(struct ingenic_cgu *cgu, · line 109
Quoted 10 lines
drivers/clk/ingenic/cgu.c +10
-0+ od++; + }else { + od = od_enc ? od_enc :1 ; + } + +/* if od_max = 0, od_bits should be 0 and od is fixed to 1. */ +if (od_max ==0 ) +WARN_ON_ONCE (od_bits !=0 ); +else +WARN_ON_ONCE (od == od_max);
[Severity: Medium]
In ingenic_pll_recalc_rate_od(), does moving od++ before WARN_ON_ONCE(od == od_max) cause an off-by-one regression in the bounds check when od_encoding is used?
Previously in ingenic_pll_recalc_rate(), the check against pll_info->od_max was performed on the 0-based loop index before incrementing od:
for (od = 0; od < pll_info->od_max; od++) if (pll_info->od_encoding[od] == od_enc) break; if (pll_info->od_max == 0) BUG_ON(pll_info->od_bits != 0); else BUG_ON(od == pll_info->od_max); od++;
With od++ now happening inside the if (od_encoding) branch before the check, matching the highest valid entry at od_encoding[od_max - 1] increments od to od_max and triggers a false WARN_ON_ONCE(od == od_max). Conversely, if od_enc is not found in od_encoding, the loop finishes with od == od_max, od++ makes it od_max + 1, and the warning does not fire.
[ ... ]
Quoted 19 lines
drivers/clk/ingenic/cgu.c +7
-1@@ -531,7 +590,7 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate,struct ingenic_cgu *cgu = ingenic_clk->cgu;unsigned long rate, flags;unsigned int hw_div, div; -u32 reg, mask; +u32 reg, mask, d_reg;int ret =0 ;if (clk_info->type &CGU_CLK_DIV ) {@@ -554,6 +613,30 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate, reg &= ~(mask << clk_info->div.shift); reg |= hw_div << clk_info->div.shift; +/* +* NOTE: Special treatment for the I2S dividers in the X1600. +* Set the multiplier to 1, imposing an N >= M*2 constraint, +* also setting D to "automatic" calculation. This permits the +* treatment of these dividers as normal dividers, although +* they are configured more similarly to PLLs.
drivers/clk/ingenic/cgu.c ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate, · line 631
Quoted 10 lines
drivers/clk/ingenic/cgu.c +10
-0+*/ +if (clk_info->mdiv.reg) { +if (div <2 ) { +spin_unlock_irqrestore (&cgu->lock, flags); +return -EINVAL ; + } + + mask =GENMASK (clk_info->mdiv.bits -1 ,0 ); + reg &= ~(mask << clk_info->mdiv.shift); + reg |=1 << clk_info->mdiv.shift;
[Severity: High]
How does the div < 2 constraint here in ingenic_clk_set_rate() interact with ingenic_clk_calc_div() and the hardware N field encoding?
In ingenic_clk_calc_div(), div is clamped to a minimum of clk_info->div.div (which is 1 for X1600_CLK_I2S0 and X1600_CLK_I2S1) without checking clk_info->mdiv.reg:
div = clamp_t(unsigned int, div, clk_info->div.div, clk_info->div.div << clk_info->div.bits);
When a rate >= parent_rate is requested, ingenic_clk_determine_rate() -> ingenic_clk_calc_div() calculates div == 1 and reports parent_rate as a valid rounded rate, but the subsequent call to ingenic_clk_set_rate() fails with -EINVAL because div < 2.
Additionally, just before the if (clk_info->mdiv.reg) block, ingenic_clk_set_rate() calculates:
hw_div = ((div / clk_info->div.div) - 1);
and writes hw_div (which is div - 1) into the N field at clk_info->div.shift, while writing a raw 1 into the M field at clk_info->mdiv.shift. Because the I2S fractional divider uses unoffset M and N values (f_out = f_in * M / N with N >= 2 * M), doesn't subtracting 1 from div program N = div - 1 instead of N = div (and write N = 1, M = 1 when div == 2, violating N >= 2 * M), while ingenic_clk_recalc_rate() adds 1 back when reading N and ignores mdiv?
Quoted 12 lines
drivers/clk/ingenic/cgu.c +8
-0+ +if (clk_info->nddiv.reg) { + d_reg =readl (cgu->base + clk_info->nddiv.reg); + d_reg &= ~(1 << clk_info->nddiv.explicit_d_bit); + d_reg |=1 << clk_info->nddiv.explicit_n_bit; + } + } +/* clear the stop bit */ if (clk_info->div.stop_bit !=-1 ) reg &= ~BIT (clk_info->div.stop_bit);
drivers/clk/ingenic/cgu.c ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate, · line 652
Quoted 5 lines
drivers/clk/ingenic/cgu.c +2
-0@@ -565,6 +648,9 @@ ingenic_clk_set_rate(struct clk_hw *hw, unsigned long req_rate,/* update the hardware */ writel (reg, cgu->base + clk_info->div.reg); +if (clk_info->nddiv.reg) +writel (d_reg, cgu->base + clk_info->nddiv.reg);
[Severity: Medium]
Can d_reg be used uninitialized here in ingenic_clk_set_rate(), and does the explicit_n_bit shift overflow a signed 32-bit int?
d_reg is only initialized when both clk_info->mdiv.reg and clk_info->nddiv.reg are non-zero, whereas writel(d_reg, cgu->base + clk_info->nddiv.reg) only checks clk_info->nddiv.reg, which triggers a -Wmaybe-uninitialized compiler warning when compiling cgu.c.
Also, in x1600_cgu_clocks[], X1600_CLK_I2S0 and X1600_CLK_I2S1 set explicit_n_bit to 31:
.nddiv = { CGU_REG_I2S0CDR1, 31, 30 },Should the bit operations on explicit_d_bit and explicit_n_bit use BIT() instead of shifting a signed int 1 << 31?
Quoted 5 lines
drivers/clk/ingenic/x1600-cgu.c new file +0
-0
[ ... ]
Quoted 5 lines
drivers/clk/ingenic/x1600-cgu.c new file +5
-0+static int x1600_otg_phy_enable (struct clk_hw *hw) +{ +void __iomem *reg_opcr = cgu->base +CGU_REG_OPCR ; + +writel ((readl (reg_opcr) & ~OPCR_GATEUSBPHYCLK ) |OPCR_SPENDN0 , reg_opcr);
drivers/clk/ingenic/x1600-cgu.c line 84
Quoted 10 lines
drivers/clk/ingenic/x1600-cgu.c new file +10
-0+ +return 0 ; +} + +static void x1600_otg_phy_disable (struct clk_hw *hw) +{ +void __iomem *reg_opcr = cgu->base +CGU_REG_OPCR ; + +writel ((readl (reg_opcr) & ~OPCR_SPENDN0 ) |OPCR_GATEUSBPHYCLK , reg_opcr); +}
[Severity: Medium]
Should x1600_otg_phy_enable() and x1600_otg_phy_disable() acquire cgu->lock around the read-modify-write of CGU_REG_OPCR?
X1600_CLK_RTC also uses CGU_REG_OPCR (.mux = { CGU_REG_OPCR, 2, 1 }), and ingenic_clk_set_parent() modifies CGU_REG_OPCR under the clock framework prepare_lock and cgu->lock, while clk_enable() and clk_disable() invoke x1600_otg_phy_enable() and x1600_otg_phy_disable() under enable_lock without holding cgu->lock. Can concurrent OTG PHY enable/disable and RTC reparenting race on CGU_REG_OPCR?
[ ... ]
Quoted 31 lines
drivers/clk/ingenic/x1600-cgu.c new file +31
-0+static void +x1600_pll_calc_m_n_od (const struct ingenic_cgu_pll_info *pll_info, +unsigned long rate,unsigned long parent_rate, +unsigned int *pm,unsigned int *pn,unsigned int *pod, +unsigned int *pod1) +{ +const unsigned int od_max = pll_info->od_max -1 ; +const unsigned int od1_max = pll_info->od1_max -1 ; +const unsigned int m_max =GENMASK (pll_info->m_bits -1 ,0 ); +const unsigned int n_max =GENMASK (pll_info->n_bits -1 ,0 ); +unsigned long m, n; +unsigned int od =1 , od1 =1 ; +const unsigned long fvco_min =600000000 , fvco_max =2400000000 ; +unsigned long fvco; + +/* +* Combined output divider range: +* +* ceil(fvco_min / rate) - fvco_max / rate +*/ +unsigned int od_combined_min = (fvco_min + rate) / rate; +unsigned int od_combined_max = fvco_max / rate; +unsigned int od_combined; + +for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) { + od =int_sqrt (od_combined); + od1 = od_combined / od; + +/* od == floor(sqrt(od_combined)); od1 >= od */ +if ((od * od1 == od_combined) && od <= od_max && od1 <= od1_max) { + fvco = rate * od_combined;
drivers/clk/ingenic/x1600-cgu.c line 145
Quoted 10 lines
drivers/clk/ingenic/x1600-cgu.c new file +10
-0+rational_best_approximation (fvco, parent_rate, m_max, n_max, &m, &n); +break ; + } + } + + *pm = m; + *pn = n; + *pod = od; + *pod1 = od1; +}
[Severity: High]
What happens in x1600_pll_calc_m_n_od() if the loop finishes without finding a matching od_combined?
m and n are declared without initialization and are only assigned inside the if ((od * od1 == od_combined) && od <= od_max && od1 <= od1_max) block. Since od_max and od1_max are 7, the maximum valid od * od1 product is 49. If a consumer requests a rate > fvco_max (where od_combined_min > od_combined_max), a rate <= ~12.24 MHz (where od_combined_min >= 50), or a rate where [od_combined_min, od_combined_max] contains no integer divisible by int_sqrt(od_combined) with both factors <= 7 (such as 43..48), the loop exits without initializing m and n, and leaves od and od1 with the last tested values (which can exceed od_max / od1_max).
When x1600_pll_calc_m_n_od() returns to ingenic_pll_calc() and ingenic_pll_set_rate():
return div_u64((u64)parent_rate * m * pll_info->rate_multiplier, n * od * od1);
can uninitialized m and n cause a division-by-zero panic if n is 0, or cause ingenic_pll_set_rate() to write uninitialized m and n and out-of-range od and od1 values into the PLL control register?
Also, in the od_combined_min calculation:
unsigned int od_combined_min = (fvco_min + rate) / rate;
when fvco_min is an exact multiple of rate (for example, rate == 600 MHz), this computes (fvco_min / rate) + 1 instead of ceil(fvco_min / rate). Should this use DIV_ROUND_UP(fvco_min, rate) (after guarding against rate == 0)?
drivers/clk/ingenic/x1600-cgu.c line 153
Quoted 8 lines
drivers/clk/ingenic/x1600-cgu.c new file +8
-0+ +static const struct ingenic_cgu_clk_info x1600_cgu_clocks[] = { + +/* External clocks */ + + [X1600_CLK_EXCLK ] = {"ext" ,CGU_CLK_EXT }, + [X1600_CLK_RTCLK ] = {"rtc" ,CGU_CLK_EXT }, + [X1600_CLK_12M ] = {"clk12m" ,CGU_CLK_EXT },
[Severity: High]
Will registering X1600_CLK_12M as CGU_CLK_EXT cause x1600_cgu_init() -> ingenic_cgu_register_clocks() -> ingenic_register_clock() to fail with -ENODEV on Device Trees that follow the ingenic,cgu.yaml binding?
In ingenic_register_clock(), every CGU_CLK_EXT clock is required to be present in the CGU Device Tree node:
if (clk_info->type == CGU_CLK_EXT) {
clk = of_clk_get_by_name(cgu->np, clk_info->name);
if (IS_ERR(clk)) {
pr_err("%s: no external clock '%s' provided\n",
__func__, clk_info->name);
err = -ENODEV;
goto out;
}However, Documentation/devicetree/bindings/clock/ingenic,cgu.yaml only allows two input clocks in clock-names ("ext" and "rtc"/"osc32k") and does not define "clk12m".
[ ... ]
drivers/clk/ingenic/x1600-cgu.c line 346
Quoted 8 lines
drivers/clk/ingenic/x1600-cgu.c new file +8
-0+ [X1600_CLK_CIMMCLK] = { +"cim_mclk" ,CGU_CLK_MUX |CGU_CLK_DIV |CGU_CLK_GATE , + .parents = { X1600_CLK_SCLKA, X1600_CLK_MPLL, + X1600_CLK_EPLL, -1 }, + .mux = { CGU_REG_CIMCDR, 30, 2 }, + .div = { CGU_REG_CIMCDR, 0, 1, 8, 30, 29, 28 }, + .gate = { CGU_REG_CLKGR0, 22 }, + },
[Severity: High]
In x1600_cgu_clocks[X1600_CLK_CIMMCLK], do the .mux and .div definitions overlap at bit 30 of CGU_REG_CIMCDR?
.mux = { CGU_REG_CIMCDR, 30, 2 } occupies bits 31:30 of CGU_REG_CIMCDR, while .div = { CGU_REG_CIMCDR, 0, 1, 8, 30, 29, 28 } sets ce_bit = 30, busy_bit = 29, and stop_bit = 28. When ingenic_clk_set_rate() sets BIT(clk_info->div.ce_bit), won't it overwrite bit 30 of the parent mux field in CGU_REG_CIMCDR instead of setting CE_CIM (bit 29) and polling BUSY_CIM (bit 28)?
drivers/clk/ingenic/x1600-cgu.c line 358
Quoted 12 lines
drivers/clk/ingenic/x1600-cgu.c new file +12
-0+ + [X1600_CLK_EXCLK_DIV512] = { +"exclk_div512" ,CGU_CLK_FIXDIV , + .parents = { X1600_CLK_EXCLK }, + .fixdiv = { 512 }, + }, + + [X1600_CLK_RTC] = { +"rtc_ercs" ,CGU_CLK_MUX |CGU_CLK_GATE , + .parents = { X1600_CLK_EXCLK_DIV512, X1600_CLK_RTCLK }, + .mux = { CGU_REG_OPCR, 2, 1}, + },
[Severity: High]X1600_CLK_RTC specifies CGU_CLK_MUX | CGU_CLK_GATE, but .gate is not initialized here.
Because .gate is zero-initialized to { .reg = 0, .bit = 0 }, won't enabling or disabling rtc_ercs (including during clk_disable_unused() or ingenic_clk_set_parent()) call ingenic_cgu_gate_set() on register 0x00 (CGU_REG_CLOCKCONTROL) bit 0, modifying the LSB of the X1600_CLK_CPU divider?
drivers/clk/ingenic/x1600-cgu.c line 366
Quoted 8 lines
drivers/clk/ingenic/x1600-cgu.c new file +8
-0+ + /* Custom (SoC-specific) OTG PHY */ + + [X1600_CLK_OTGPHY] = { +"otg_phy" ,CGU_CLK_CUSTOM , + .parents = { X1600_CLK_12M }, + .custom = { &x1600_otg_phy_ops }, + },
[Severity: Medium]
Should .parents for X1600_CLK_OTGPHY initialize the remaining slots to -1, i.e. { X1600_CLK_12M, -1, -1, -1 }?
In ingenic_register_clock(), clocks with CGU_CLK_CUSTOM iterate over all ARRAY_SIZE(clk_info->parents) (4) entries and register every entry that is not -1:
if (caps & (CGU_CLK_MUX | CGU_CLK_CUSTOM)) {
clk_init.num_parents = 0;
if (caps & CGU_CLK_MUX)
num_possible = 1 << clk_info->mux.bits;
else
num_possible = ARRAY_SIZE(clk_info->parents);
for (i = 0; i < num_possible; i++) {
if (clk_info->parents[i] == -1)
continue;With .parents = { X1600_CLK_12M }, the remaining three entries are zero-initialized to 0 (X1600_CLK_EXCLK, "ext"), registering otg_phy with four parents ("clk12m", "ext", "ext", "ext") instead of one.
[ ... ]
drivers/clk/ingenic/x1600-cgu.c line 422
Quoted 11 lines
drivers/clk/ingenic/x1600-cgu.c new file +11
-0+ [X1600_CLK_SADC] = { +"sadc" ,CGU_CLK_GATE , + .parents = { X1600_CLK_EXCLK, -1, -1, -1 }, + .gate = { CGU_REG_CLKGR0, 14 }, + }, + + [X1600_CLK_UART0] = { +"uart0" ,CGU_CLK_GATE , + .parents = { X1600_CLK_EXCLK, -1, -1, -1 }, + .gate = { CGU_REG_CLKGR0, 14 }, + },
[Severity: High]
Both X1600_CLK_SADC and X1600_CLK_UART0 use .gate = { CGU_REG_CLKGR0, 14 }. Should X1600_CLK_SADC use bit 13 of CGU_REG_CLKGR0 instead, so that gating unused sadc (for instance in clk_disable_unused()) does not gate uart0?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
kernel test robot
build botRe: [PATCH 2/4] clk: ingenic: Add Ingenic X1600 CGU clock driver support
In reply to H. Nikolaus Schallerkernel test robot noticed the following build warnings:
Hi Nikolaus,
kernel test robot noticed the following build warnings:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on robh/for-next linus/master v7.3 next-20261023] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/H-Nikolaus-Schaller/dt-bindings-clock-Add-Ingenic-X1600-CGU-bindings/20261025-201824 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/50983be55e467076e83e3ffc37b30fc4e5648e15.1792955907.git.hns%40goldelico.com patch subject: [PATCH 2/4] clk: ingenic: Add Ingenic X1600 CGU clock driver support config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20261026/[email protected]/config) compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 186e70f4e6a1521991d2340d3d49b23b1beff11f) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261026/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/clk/ingenic/x1600-cgu.c:129:38: warning: variable 'm' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
129 | for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/ingenic/x1600-cgu.c:141:8: note: uninitialized use occurs here
141 | *pm = m;
| ^
drivers/clk/ingenic/x1600-cgu.c:129:38: note: remove the condition if it is always true
129 | for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/ingenic/x1600-cgu.c:115:17: note: initialize the variable 'm' to silence this warning
115 | unsigned long m, n;
| ^
| = 0
>> drivers/clk/ingenic/x1600-cgu.c:129:38: warning: variable 'n' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
129 | for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/ingenic/x1600-cgu.c:142:8: note: uninitialized use occurs here
142 | *pn = n;
| ^
drivers/clk/ingenic/x1600-cgu.c:129:38: note: remove the condition if it is always true
129 | for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/ingenic/x1600-cgu.c:115:20: note: initialize the variable 'n' to silence this warning
115 | unsigned long m, n;
| ^
| = 02 warnings generated.
vim +129 drivers/clk/ingenic/x1600-cgu.c
104
105 static void
106 x1600_pll_calc_m_n_od(const struct ingenic_cgu_pll_info *pll_info,
107 unsigned long rate, unsigned long parent_rate,
108 unsigned int *pm, unsigned int *pn, unsigned int *pod,
109 unsigned int *pod1)
110 {
111 const unsigned int od_max = pll_info->od_max - 1;
112 const unsigned int od1_max = pll_info->od1_max - 1;
113 const unsigned int m_max = GENMASK(pll_info->m_bits - 1, 0);
114 const unsigned int n_max = GENMASK(pll_info->n_bits - 1, 0);
115 unsigned long m, n;
116 unsigned int od = 1, od1 = 1;
117 const unsigned long fvco_min = 600000000, fvco_max = 2400000000;
118 unsigned long fvco;
119
120 /*
121 * Combined output divider range:
122 *
123 * ceil(fvco_min / rate) - fvco_max / rate
124 */
125 unsigned int od_combined_min = (fvco_min + rate) / rate;
126 unsigned int od_combined_max = fvco_max / rate;
127 unsigned int od_combined;
128
> 129 for (od_combined = od_combined_min; od_combined <= od_combined_max; od_combined++) { 130 od = int_sqrt(od_combined);
131 od1 = od_combined / od;
132
133 /* od == floor(sqrt(od_combined)); od1 >= od */
134 if ((od * od1 == od_combined) && od <= od_max && od1 <= od1_max) {
135 fvco = rate * od_combined;
136 rational_best_approximation(fvco, parent_rate, m_max, n_max, &m, &n);
137 break;
138 }
139 }
140
141 *pm = m;
142 *pn = n;
143 *pod = od;
144 *pod1 = od1;
145 }
146
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 2/4] clk: ingenic: Add Ingenic X1600 CGU clock driver support
In reply to H. Nikolaus SchallerQuoted 16 lines
Introduce clock driver support for the Clock Generation Unit (CGU) found in the Ingenic X1600 SoC.
To support the X1600 platform, update the common Ingenic CGU core framework to accommodate a secondary post-VCO divider (OD1) within the PLL configuration registers. Additionally, prevent a NULL pointer dereference in the rate determination path by properly supplying the secondary divider tracking during PLL calculation calls.
Implement custom handling for the I2S clocks on the X1600. Since complex compound hardware dividers are not yet natively supported by the core framework, explicit M-divider (mdiv) and N/D-divider (nddiv) structures are introduced to describe these specialized fields. This avoids a compilation failure and enables a stable, though limited, division encoding suitable for current needs.
Quoted 7 lines
Furthermore, this patch:
- Fixes the gating of the I2S0 and I2S1 clocks, matching the control bit behavior which functions as a clock enable flag.
- Introduces the custom OTG PHY clock operations and initialisation routines utilizing the hardware's OPCR registers.
- Registers the independent I2S0 RX and TX gate clocks employed by the X1600 peripheral block.
Just from reading the commit message this patch needs to be split up further into several smaller patches to make it easier to review. Ideally try to make the different bullet points separate patches.
Quoted 10 lines
Tested successfully on the LX16 (X1600) boards and CI20 (JZ4780) to not interefere.
Checkpatch complains about not 4 lines of help paragraph but the style is the same as for the other machines. It also recommends using 'unsigned int' for the new struct
ingenic_cgu_mdiv_infoand structingenic_cgu_nddiv_infobut this follows the style 'unsigned' of all other structs incgu.h. Finally it complains about the empty line between structingenic_cgu_clk_infox1600_cgu_clocks[] = { and the comment. But I think it is more readable this way.
The checkpatch note can go below the --- below.
Quoted 73 lines
Co-developed-by H. Nikolaus Schaller <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>Co-developed-by Paul Boddie <[email protected]>Signed-off-by Paul Boddie <[email protected]>--- drivers/clk/ingenic/Kconfig | 10 + drivers/clk/ingenic/Makefile | 1 + drivers/clk/ingenic/cgu.c | 150 +++++++--- drivers/clk/ingenic/cgu.h | 42 ++- drivers/clk/ingenic/x1600-cgu.c | 476 ++++++++++++++++++++++++++++++++ 5 files changed, 646 insertions(+), 33 deletions(-) create mode 100644 drivers/clk/ingenic/x1600-cgu.cdrivers/clk/ingenic/Kconfig +10
-0@@ -75,6 +75,16 @@ config INGENIC_CGU_X1000 If building for a X1000 SoC, you want to say Y here. +config INGENIC_CGU_X1600 + bool "Ingenic X1600 CGU driver" + default MACH_X1600 + select INGENIC_CGU_COMMON + help + Support the clocks provided by the CGU hardware on Ingenic X1600 + and compatible SoCs. + + If building for a X1600 SoC, you want to say Y here. + config INGENIC_CGU_X1830 bool "Ingenic X1830 CGU driver" default MACH_X1830drivers/clk/ingenic/Makefile +1
-0@@ -7,5 +7,6 @@ obj-$(CONFIG_INGENIC_CGU_JZ4760) += jz4760-cgu.o obj-$(CONFIG_INGENIC_CGU_JZ4770) += jz4770-cgu.o obj-$(CONFIG_INGENIC_CGU_JZ4780) += jz4780-cgu.o obj-$(CONFIG_INGENIC_CGU_X1000) += x1000-cgu.o +obj-$(CONFIG_INGENIC_CGU_X1600) += x1600-cgu.o obj-$(CONFIG_INGENIC_CGU_X1830) += x1830-cgu.o obj-$(CONFIG_INGENIC_TCU_CLK) += tcu.odrivers/clk/ingenic/cgu.c +12
-0@@ -4,6 +4,7 @@* * Copyright (c) 2013-2015 Imagination Technologies * Author: Paul Burton <[email protected]> +* Copyright (c) 2023, 2024 Paul Boddie <[email protected]> */ #include <linux/bitops.h> @@ -76,6 +77,40 @@ ingenic_cgu_gate_set(struct ingenic_cgu *cgu,* PLL operations */ +static unsigned +ingenic_pll_recalc_rate_od (u32 ctl,u8 od_shift,u8 od_bits,u8 od_max, +const s8 *od_encoding) +{ +unsigned int od, od_enc =0 ; + +if (od_bits >0 ) { + od_enc = ctl >> od_shift; + od_enc &=GENMASK (od_bits -1 ,0 ); + } +
drivers/clk/ingenic/cgu.c ingenic_cgu_gate_set(struct ingenic_cgu *cgu, · line 100
Quoted 10 lines
drivers/clk/ingenic/cgu.c +10
-0+/* +* Use the encoding table if indicated. Otherwise, use the value +* directly, interpreting an encoded value of zero as a divider +* value of one. +*/ +if (od_encoding) { +for (od =0 ; od < od_max; od++) +if (od_encoding[od] == od_enc) +break ; + od++;
So if the entry is not found, then od will be set to od_max + 1, and it will pass through the warning checks.
I started to look through the rest of the driver but I stopped because there's just too many unrelated changes here. This needs to be split up further into separate patches to make it easier to review. If your commit message has the word 'and' then that's a hint that you may want to consider splitting it up further.
Also be sure to go through all of the feedback from Sashiko.
Brian
Signature · 1 line
Brian Masney <[email protected]>
Re: [PATCH 2/4] clk: ingenic: Add Ingenic X1600 CGU clock driver support
Hi Brian,
Quoted 26 lines
Am 11.11.2026 um 22:43 schrieb Brian Masney <[email protected]>:
Quoted 16 lines
Introduce clock driver support for the Clock Generation Unit (CGU) found in the Ingenic X1600 SoC.
To support the X1600 platform, update the common Ingenic CGU core framework to accommodate a secondary post-VCO divider (OD1) within the PLL configuration registers. Additionally, prevent a NULL pointer dereference in the rate determination path by properly supplying the secondary divider tracking during PLL calculation calls.
Implement custom handling for the I2S clocks on the X1600. Since complex compound hardware dividers are not yet natively supported by the core framework, explicit M-divider (mdiv) and N/D-divider (nddiv) structures are introduced to describe these specialized fields. This avoids a compilation failure and enables a stable, though limited, division encoding suitable for current needs.
Quoted 7 lines
Furthermore, this patch:
- Fixes the gating of the I2S0 and I2S1 clocks, matching the control bit behavior which functions as a clock enable flag.
- Introduces the custom OTG PHY clock operations and initialisation routines utilizing the hardware's OPCR registers.
- Registers the independent I2S0 RX and TX gate clocks employed by the X1600 peripheral block.
Quoted 3 lines
Just from reading the commit message this patch needs to be split up further into several smaller patches to make it easier to review. Ideally try to make the different bullet points separate patches.
Yes, that is already in preparation for a V2.
We will also extend this to cover the X2000 and X2600 (and JZ4730).
This needs to extend the core first and then add bindings and CGU code tables one after the other.
Quoted 12 lines
Quoted 11 lines
Tested successfully on the LX16 (X1600) boards and CI20 (JZ4780) to not interefere.
Checkpatch complains about not 4 lines of help paragraph but the style is the same as for the other machines. It also recommends using 'unsigned int' for the new struct
ingenic_cgu_mdiv_infoand structingenic_cgu_nddiv_infobut this follows the style 'unsigned' of all other structs incgu.h. Finally it complains about the empty line between structingenic_cgu_clk_infox1600_cgu_clocks[] = { and the comment. But I think it is more readable this way.
Quoted 1 line
The checkpatch note can go below the --- below.
Fine.
Quoted 79 lines
Quoted 79 lines
Co-developed-by H. Nikolaus Schaller <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>Co-developed-by Paul Boddie <[email protected]>Signed-off-by Paul Boddie <[email protected]>---
drivers/clk/ingenic/Kconfig | 10 + drivers/clk/ingenic/Makefile | 1 + drivers/clk/ingenic/cgu.c | 150 +++++++--- drivers/clk/ingenic/cgu.h | 42 ++- drivers/clk/ingenic/x1600-cgu.c | 476 ++++++++++++++++++++++++++++++++ 5 files changed, 646 insertions(+), 33 deletions(-)create mode 100644
drivers/clk/ingenic/x1600-cgu.cdrivers/clk/ingenic/Kconfig +10
-0@@ -75,6 +75,16 @@ config INGENIC_CGU_X1000 If building for a X1000 SoC, you want to say Y here. +config INGENIC_CGU_X1600 + bool "Ingenic X1600 CGU driver" + default MACH_X1600 + select INGENIC_CGU_COMMON + help + Support the clocks provided by the CGU hardware on Ingenic X1600 + and compatible SoCs. + + If building for a X1600 SoC, you want to say Y here. +config
INGENIC_CGU_X1830
bool "Ingenic X1830 CGU driver"
defaultMACH_X1830drivers/clk/ingenic/Makefile +0
-0@@ -7,5 +7,6 @@ obj-$(CONFIG_INGENIC_CGU_JZ4760) += jz4760-cgu.oobj-$(CONFIG_INGENIC_CGU_JZ4770) += jz4770-cgu.o
obj-$(CONFIG_INGENIC_CGU_JZ4780) += jz4780-cgu.o
obj-$(CONFIG_INGENIC_CGU_X1000) += x1000-cgu.o
+obj-$(CONFIG_INGENIC_CGU_X1600) += x1600-cgu.o
obj-$(CONFIG_INGENIC_CGU_X1830) += x1830-cgu.o
obj-$(CONFIG_INGENIC_TCU_CLK) += tcu.odrivers/clk/ingenic/cgu.c +17
-0@@ -4,6 +4,7 @@* * Copyright (c) 2013-2015 Imagination Technologies * Author: Paul Burton <[email protected]> +* Copyright (c) 2023, 2024 Paul Boddie <[email protected]> */ #include <linux/bitops.h> @@ -76,6 +77,40 @@ ingenic_cgu_gate_set(struct ingenic_cgu *cgu,* PLL operations */ +static unsigned +ingenic_pll_recalc_rate_od (u32 ctl,u8 od_shift,u8 od_bits,u8 od_max, +const s8 *od_encoding) +{ +unsigned int od, od_enc =0 ; + +if (od_bits >0 ) { + od_enc = ctl >> od_shift; + od_enc &=GENMASK (od_bits -1 ,0 ); + } + +/* +* Use the encoding table if indicated. Otherwise, use the value +* directly, interpreting an encoded value of zero as a divider +* value of one. +*/
Quoted 8 lines
drivers/clk/ingenic/cgu.c ingenic_cgu_gate_set(struct ingenic_cgu *cgu, · line 100
Quoted 5 lines
drivers/clk/ingenic/cgu.c +5
-0+if (od_encoding) { +for (od =0 ; od < od_max; od++) +if (od_encoding[od] == od_enc) +break ; + od++;So if the entry is not found, then od will be set to
od_max+ 1, and it will pass through the warning checks.
Sashiko also commented on such issues.
Quoted 8 lines
I started to look through the rest of the driver but I stopped because there's just too many unrelated changes here. This needs to be split up further into separate patches to make it easier to review. If your commit message has the word 'and' then that's a hint that you may want to consider splitting it up further.
Also be sure to go through all of the feedback from Sashiko.
Yes, sure.
BR and thanks,
Nikolaus
PATCH 3/4 clk: ingenic: jz4760-cgu: Adapt calc_m_n_od() to core framework changes
In reply to H. Nikolaus SchallerThe common Ingenic CGU core framework was updated to support a secondary post-VCO divider (OD1), which extended the signature of the calc_m_n_od() callback.
Update the JZ4760 CGU driver implementation to accept the new pod1 argument, preventing compilation errors. The parameter remains unused on this specific SoC architecture.
--- drivers/clk/ingenic/jz4760-cgu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/ingenic/jz4760-cgu.c +2 -1
@@ -56,7 +56,8 @@ static const u8 jz4760_cgu_pll_half_div_table[] = {static void jz4760_cgu_calc_m_n_od (const struct ingenic_cgu_pll_info *pll_info,unsigned long rate,unsigned long parent_rate, -unsigned int *pm,unsigned int *pn,unsigned int *pod) +unsigned int *pm,unsigned int *pn,unsigned int *pod, +unsigned int *pod1) {unsigned int m, n, od, m_max = (1 << pll_info->m_bits) -1 ;
Signature · 1 line
2.56.0
Paul Cercueil
maintainerRe: [PATCH 3/4] clk: ingenic: jz4760-cgu: Adapt calc_m_n_od() to core framework changes
Hi Nikolaus,
Le dimanche 25 octobre 2026 à 20:18 +0100, H. Nikolaus Schaller a écrit :
Quoted 28 lines
The common Ingenic CGU core framework was updated to support a secondary post-VCO divider (OD1), which extended the signature of the
calc_m_n_od()callback.Update the JZ4760 CGU driver implementation to accept the new pod1 argument, preventing compilation errors. The parameter remains unused on this specific SoC architecture.
Signed-off-by H. Nikolaus Schaller <[email protected]>---
drivers/clk/ingenic/jz4760-cgu.c | 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/clk/ingenic/jz4760-cgu.c +0
-0@@ -56,7 +56,8 @@ static const u8 jz4760_cgu_pll_half_div_table[] = {static void
jz4760_cgu_calc_m_n_od(const structingenic_cgu_pll_info*pll_info, unsigned long rate, unsigned longparent_rate,drivers/clk/ingenic/jz4760-cgu.c +0
-1- unsigned int *pm, unsigned int *pn, unsignedint *pod)
drivers/clk/ingenic/jz4760-cgu.c +1
-0+ unsigned int *pm, unsigned int *pn, unsignedint *pod,
drivers/clk/ingenic/jz4760-cgu.c +1
-0+ unsigned int *pod1)
Quoted 3 lines
{
unsigned int m, n, od,m_max= (1 <<pll_info->m_bits) - 1;
Well you can't update a callback prototype in patch 2/4 then update the implementations in 3/4, the kernel has to be buildable after each patch.
Cheers,
-Paul
PATCH 4/4 clk: ingenic: x1000-cgu: Adapt calc_m_n_od() to core framework changes
In reply to H. Nikolaus SchallerThe common Ingenic CGU core framework was updated to support a secondary post-VCO divider (OD1), which extended the signature of the calc_m_n_od() callback.
Update the X1000 CGU driver implementation to accept the new pod1 argument, preventing compilation errors. The parameter remains unused on this specific SoC architecture.
--- drivers/clk/ingenic/x1000-cgu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/ingenic/x1000-cgu.c +2 -1
@@ -173,7 +173,8 @@ static const struct clk_ops x1000_otg_phy_ops = {static void x1000_i2spll_calc_m_n_od (const struct ingenic_cgu_pll_info *pll_info,unsigned long rate,unsigned long parent_rate, -unsigned int *pm,unsigned int *pn,unsigned int *pod) +unsigned int *pm,unsigned int *pn,unsigned int *pod, +unsigned int *pod1) {const unsigned long m_max =GENMASK (pll_info->m_bits -1 ,0 );const unsigned long n_max =GENMASK (pll_info->n_bits -1 ,0 );
Signature · 1 line
2.56.0