WIP FPC-III support
[linux/fpc-iii.git] / drivers / clk / ingenic / pm.c
blob341752b640d2b8a4bb806b4e8404e72ef6cb3a03
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2019 Paul Cercueil <paul@crapouillou.net>
4 */
6 #include "cgu.h"
7 #include "pm.h"
9 #include <linux/io.h>
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);
24 return 0;
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);