1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2019 Paul Cercueil <paul@crapouillou.net>
10 #include <linux/syscore_ops.h>
12 #define CGU_REG_LCR 0x04
14 #define LCR_LOW_POWER_MODE BIT(0)
16 static void __iomem
* __maybe_unused ingenic_cgu_base
;
18 static int __maybe_unused
ingenic_cgu_pm_suspend(void)
20 u32 val
= readl(ingenic_cgu_base
+ CGU_REG_LCR
);
22 writel(val
| LCR_LOW_POWER_MODE
, ingenic_cgu_base
+ CGU_REG_LCR
);
27 static void __maybe_unused
ingenic_cgu_pm_resume(void)
29 u32 val
= readl(ingenic_cgu_base
+ CGU_REG_LCR
);
31 writel(val
& ~LCR_LOW_POWER_MODE
, ingenic_cgu_base
+ CGU_REG_LCR
);
34 static struct syscore_ops __maybe_unused ingenic_cgu_pm_ops
= {
35 .suspend
= ingenic_cgu_pm_suspend
,
36 .resume
= ingenic_cgu_pm_resume
,
39 void ingenic_cgu_register_syscore_ops(struct ingenic_cgu
*cgu
)
41 if (IS_ENABLED(CONFIG_PM_SLEEP
)) {
42 ingenic_cgu_base
= cgu
->base
;
43 register_syscore_ops(&ingenic_cgu_pm_ops
);