* [PATCH RFC 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit
2026-11-23 20:31 [PATCH RFC 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Andreas Kemnade
@ 2026-11-23 20:31 ` Andreas Kemnade
2026-11-23 20:31 ` [PATCH 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source Andreas Kemnade
2026-11-23 20:31 ` [PATCH 3/3] ARM: dts: imx: kobo-clarahd: Use 32K clock for the timer Andreas Kemnade
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Kemnade @ 2026-11-23 20:31 UTC (permalink / raw)
To: Russell King, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Daniel Lezcano, Thomas Gleixner, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-arm-kernel, imx, linux-kernel, devicetree, linux, Andreas Kemnade
Since there are situations when only wakeup from some GPIO IRQs is
required (besides the timekeeping infrastructure which can be fed by
an always on 32K clock), add another idle state to allow power-hungry
PLLs to be turned off in that condition.
Since some clocks are not turned off by RPM and
implementing it seems not feasible, keep a list of clocks to be ignored.
This includes clocks marked as CLK_IS_CRITICAL (romclk, aips_tzX clocks).
This is RFC because that mask check feels hacky. collecting references to
every clock feels a bit too much, maybe set a flag somewhere by
the clock driver.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
arch/arm/mach-imx/common.h | 1 +
arch/arm/mach-imx/cpuidle-imx6sx.c | 42 +++++++++++++++++++++++++++++++++++++-
arch/arm/mach-imx/pm-imx6.c | 23 +++++++++++++++++++++
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index d7ecaa822adbd..7804cf5d83922 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -35,6 +35,7 @@ void imx_gpc_set_arm_power_down_timing(u32 sw2iso, u32 sw);
void imx25_pm_init(void);
void imx27_pm_init(void);
void imx5_pmu_init(void);
+bool imx6sll_check_pll_are_used(void);
enum mxc_cpu_pwr_mode {
WAIT_CLOCKED, /* wfi only */
diff --git a/arch/arm/mach-imx/cpuidle-imx6sx.c b/arch/arm/mach-imx/cpuidle-imx6sx.c
index 83c5cbd3748e1..4537cb7b3a637 100644
--- a/arch/arm/mach-imx/cpuidle-imx6sx.c
+++ b/arch/arm/mach-imx/cpuidle-imx6sx.c
@@ -65,6 +65,36 @@ static __cpuidle int imx6sx_enter_wait(struct cpuidle_device *dev,
return index;
}
+static __cpuidle int imx6sx_enter_pll_off(struct cpuidle_device *dev,
+ struct cpuidle_driver *drv, int index)
+{
+ if (!cpu_is_imx6sll() || imx6sll_check_pll_are_used())
+ return imx6sx_enter_wait(dev, drv, 2);
+
+ imx6_set_lpm(STOP_POWER_ON);
+ imx6_enable_rbc(true);
+ imx_gpc_set_arm_power_in_lpm(true);
+ imx_set_cpu_jump(0, v7_cpu_resume);
+ imx6_set_int_mem_clk_lpm(true);
+ /* Need to notify there is a cpu pm operation. */
+ cpu_pm_enter();
+ cpu_cluster_pm_enter();
+
+ ct_cpuidle_enter();
+
+ cpu_suspend(0, imx6sx_idle_finish);
+
+ ct_cpuidle_exit();
+
+ cpu_cluster_pm_exit();
+ cpu_pm_exit();
+ imx6_enable_rbc(false);
+ imx_gpc_set_arm_power_in_lpm(false);
+
+ imx6_set_lpm(WAIT_CLOCKED);
+ return index;
+}
+
static struct cpuidle_driver imx6sx_cpuidle_driver = {
.name = "imx6sx_cpuidle",
.owner = THIS_MODULE,
@@ -95,8 +125,18 @@ static struct cpuidle_driver imx6sx_cpuidle_driver = {
.name = "LOW-POWER-IDLE",
.desc = "ARM power off",
},
+ /* STOP ON */
+ {
+ .exit_latency = 500,
+ .target_residency = 800,
+ .flags = CPUIDLE_FLAG_TIMER_STOP |
+ CPUIDLE_FLAG_RCU_IDLE,
+ .enter = imx6sx_enter_pll_off,
+ .name = "STOP ON",
+ .desc = "ARM power off + PLL off",
+ },
},
- .state_count = 3,
+ .state_count = 4,
.safe_state_index = 0,
};
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
index 3c73e2cdb8ceb..65a5268d31614 100644
--- a/arch/arm/mach-imx/pm-imx6.c
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -64,6 +64,14 @@
#define MX6Q_SUSPEND_OCRAM_SIZE 0x1000
#define MX6_MAX_MMDC_IO_NUM 33
+#define CCGR0 0x68
+#define CCGR1 0x6c
+#define CCGR2 0x70
+#define CCGR3 0x74
+#define CCGR4 0x78
+#define CCGR5 0x7c
+#define CCGR6 0x80
+
static void __iomem *ccm_base __ro_after_init;
static void __iomem *suspend_ocram_base __ro_after_init;
static void (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase) __ro_after_init;
@@ -287,6 +295,21 @@ void imx6_enable_rbc(bool enable)
imx_gpc_restore_all();
}
+bool imx6sll_check_pll_are_used(void)
+{
+ /* check for any clock active which provides more than register access */
+ return readl_relaxed(ccm_base + CCGR0) & BIT(29) ||
+ readl_relaxed(ccm_base + CCGR1) & (BIT(25) | BIT(23) | BIT(15) | BIT(13) |
+ BIT(11) | BIT(7) | BIT(5) | BIT(3) | BIT(1)) ||
+ readl_relaxed(ccm_base + CCGR2) & (BIT(31) | BIT(29) | BIT(11) | BIT(9) |
+ BIT(7) | BIT(3)) ||
+ readl_relaxed(ccm_base + CCGR3) & (BIT(11) | BIT(5) | BIT(3)) ||
+ readl_relaxed(ccm_base + CCGR4) & (BIT(23) | BIT(21) | BIT(19) | BIT(17)) ||
+ readl_relaxed(ccm_base + CCGR5) & (BIT(25) | BIT(23) | BIT(21) | BIT(21) |
+ BIT(19) | BIT(15) | BIT(7)) ||
+ readl_relaxed(ccm_base + CCGR6) & (BIT(7) | BIT(5) | BIT(3) | BIT(1));
+}
+
static void imx6q_enable_wb(bool enable)
{
u32 val;
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source
2026-11-23 20:31 [PATCH RFC 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Andreas Kemnade
2026-11-23 20:31 ` [PATCH RFC 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit Andreas Kemnade
@ 2026-11-23 20:31 ` Andreas Kemnade
2026-11-23 20:31 ` [PATCH 3/3] ARM: dts: imx: kobo-clarahd: Use 32K clock for the timer Andreas Kemnade
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Kemnade @ 2026-11-23 20:31 UTC (permalink / raw)
To: Russell King, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Daniel Lezcano, Thomas Gleixner, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-arm-kernel, imx, linux-kernel, devicetree, linux, Andreas Kemnade
To avoid depending on PLL infrastructure for timekeeping, prepare for
using the 32K clock by configuring the clock source accordingly.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
drivers/clocksource/timer-imx-gpt.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index 8335bd7f8c6ce..3c023da565564 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -50,8 +50,10 @@ enum imx_gpt_type {
/* MX31, MX35, MX25, MX5, MX6 */
#define V2_TCTL_WAITEN (1 << 3) /* Wait enable mode */
+#define V2_TCTL_STOPEN (1 << 5) /* Stop enable mode */
#define V2_TCTL_CLK_IPG (1 << 6)
#define V2_TCTL_CLK_PER (2 << 6)
+#define V2_TCTL_CLK_32K (4 << 6)
#define V2_TCTL_CLK_OSC_DIV8 (5 << 6)
#define V2_TCTL_FRR (1 << 9)
#define V2_TCTL_24MEN (1 << 10)
@@ -314,14 +316,19 @@ static void imx6dl_gpt_setup_tctl(struct imx_timer *imxtm)
u32 tctl_val;
tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
- if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8) {
+ if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8) {
tctl_val |= V2_TCTL_CLK_OSC_DIV8;
/* 24 / 8 = 3 MHz */
writel_relaxed(7 << V2_TPRER_PRE24M, imxtm->base + MXC_TPRER);
tctl_val |= V2_TCTL_24MEN;
- } else {
+ } else if (clk_get_rate(imxtm->clk_per) == 32768)
+ /*
+ * if powered by that always on clock, it is feasible to let
+ * it run in stop mode, too, allowing lower idle states
+ */
+ tctl_val |= V2_TCTL_CLK_32K | V2_TCTL_STOPEN;
+ else
tctl_val |= V2_TCTL_CLK_PER;
- }
writel_relaxed(tctl_val, imxtm->base + MXC_TCTL);
}
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/3] ARM: dts: imx: kobo-clarahd: Use 32K clock for the timer
2026-11-23 20:31 [PATCH RFC 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Andreas Kemnade
2026-11-23 20:31 ` [PATCH RFC 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit Andreas Kemnade
2026-11-23 20:31 ` [PATCH 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source Andreas Kemnade
@ 2026-11-23 20:31 ` Andreas Kemnade
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Kemnade @ 2026-11-23 20:31 UTC (permalink / raw)
To: Russell King, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Daniel Lezcano, Thomas Gleixner, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-arm-kernel, imx, linux-kernel, devicetree, linux, Andreas Kemnade
To avoid depending on PLL infrastructure for timekeeping, use 32K timer
for the timer.
---
arch/arm/boot/dts/nxp/imx/imx6sll-kobo-clarahd.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/nxp/imx/imx6sll-kobo-clarahd.dts b/arch/arm/boot/dts/nxp/imx/imx6sll-kobo-clarahd.dts
index 1000ee8b807aa..2e907c4163629 100644
--- a/arch/arm/boot/dts/nxp/imx/imx6sll-kobo-clarahd.dts
+++ b/arch/arm/boot/dts/nxp/imx/imx6sll-kobo-clarahd.dts
@@ -46,6 +46,11 @@ &gpio_keys {
pinctrl-0 = <&pinctrl_gpio_keys>;
};
+&gpt1 {
+ clocks = <&clks IMX6SLL_CLK_GPT_BUS>,
+ <&clks IMX6SLL_CLK_CKIL>;
+};
+
&i2c1 {
pinctrl-names = "default","sleep";
pinctrl-0 = <&pinctrl_i2c1>;
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread