.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2013 Tomasz Figa <tomasz.figa at gmail.com> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | 4 | * |
---|
8 | 5 | * Common Clock Framework support for all S3C64xx SoCs. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/slab.h> |
---|
12 | 9 | #include <linux/clk-provider.h> |
---|
| 10 | +#include <linux/clk/samsung.h> |
---|
13 | 11 | #include <linux/of.h> |
---|
14 | 12 | #include <linux/of_address.h> |
---|
15 | | -#include <linux/syscore_ops.h> |
---|
16 | 13 | |
---|
17 | 14 | #include <dt-bindings/clock/samsung,s3c64xx-clock.h> |
---|
18 | 15 | |
---|
.. | .. |
---|
59 | 56 | static void __iomem *reg_base; |
---|
60 | 57 | static bool is_s3c6400; |
---|
61 | 58 | |
---|
62 | | -#ifdef CONFIG_PM_SLEEP |
---|
63 | | -static struct samsung_clk_reg_dump *s3c64xx_save_common; |
---|
64 | | -static struct samsung_clk_reg_dump *s3c64xx_save_soc; |
---|
65 | | - |
---|
66 | 59 | /* |
---|
67 | 60 | * List of controller registers to be saved and restored during |
---|
68 | 61 | * a suspend/resume cycle. |
---|
.. | .. |
---|
88 | 81 | CLK_SRC2, |
---|
89 | 82 | MEM0_GATE, |
---|
90 | 83 | }; |
---|
91 | | - |
---|
92 | | -static int s3c64xx_clk_suspend(void) |
---|
93 | | -{ |
---|
94 | | - samsung_clk_save(reg_base, s3c64xx_save_common, |
---|
95 | | - ARRAY_SIZE(s3c64xx_clk_regs)); |
---|
96 | | - |
---|
97 | | - if (!is_s3c6400) |
---|
98 | | - samsung_clk_save(reg_base, s3c64xx_save_soc, |
---|
99 | | - ARRAY_SIZE(s3c6410_clk_regs)); |
---|
100 | | - |
---|
101 | | - return 0; |
---|
102 | | -} |
---|
103 | | - |
---|
104 | | -static void s3c64xx_clk_resume(void) |
---|
105 | | -{ |
---|
106 | | - samsung_clk_restore(reg_base, s3c64xx_save_common, |
---|
107 | | - ARRAY_SIZE(s3c64xx_clk_regs)); |
---|
108 | | - |
---|
109 | | - if (!is_s3c6400) |
---|
110 | | - samsung_clk_restore(reg_base, s3c64xx_save_soc, |
---|
111 | | - ARRAY_SIZE(s3c6410_clk_regs)); |
---|
112 | | -} |
---|
113 | | - |
---|
114 | | -static struct syscore_ops s3c64xx_clk_syscore_ops = { |
---|
115 | | - .suspend = s3c64xx_clk_suspend, |
---|
116 | | - .resume = s3c64xx_clk_resume, |
---|
117 | | -}; |
---|
118 | | - |
---|
119 | | -static void __init s3c64xx_clk_sleep_init(void) |
---|
120 | | -{ |
---|
121 | | - s3c64xx_save_common = samsung_clk_alloc_reg_dump(s3c64xx_clk_regs, |
---|
122 | | - ARRAY_SIZE(s3c64xx_clk_regs)); |
---|
123 | | - if (!s3c64xx_save_common) |
---|
124 | | - goto err_warn; |
---|
125 | | - |
---|
126 | | - if (!is_s3c6400) { |
---|
127 | | - s3c64xx_save_soc = samsung_clk_alloc_reg_dump(s3c6410_clk_regs, |
---|
128 | | - ARRAY_SIZE(s3c6410_clk_regs)); |
---|
129 | | - if (!s3c64xx_save_soc) |
---|
130 | | - goto err_soc; |
---|
131 | | - } |
---|
132 | | - |
---|
133 | | - register_syscore_ops(&s3c64xx_clk_syscore_ops); |
---|
134 | | - return; |
---|
135 | | - |
---|
136 | | -err_soc: |
---|
137 | | - kfree(s3c64xx_save_common); |
---|
138 | | -err_warn: |
---|
139 | | - pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", |
---|
140 | | - __func__); |
---|
141 | | -} |
---|
142 | | -#else |
---|
143 | | -static void __init s3c64xx_clk_sleep_init(void) {} |
---|
144 | | -#endif |
---|
145 | 84 | |
---|
146 | 85 | /* List of parent clocks common for all S3C64xx SoCs. */ |
---|
147 | 86 | PNAME(spi_mmc_p) = { "mout_epll", "dout_mpll", "fin_pll", "clk27m" }; |
---|
.. | .. |
---|
508 | 447 | |
---|
509 | 448 | samsung_clk_register_alias(ctx, s3c64xx_clock_aliases, |
---|
510 | 449 | ARRAY_SIZE(s3c64xx_clock_aliases)); |
---|
511 | | - s3c64xx_clk_sleep_init(); |
---|
| 450 | + |
---|
| 451 | + samsung_clk_sleep_init(reg_base, s3c64xx_clk_regs, |
---|
| 452 | + ARRAY_SIZE(s3c64xx_clk_regs)); |
---|
| 453 | + if (!is_s3c6400) |
---|
| 454 | + samsung_clk_sleep_init(reg_base, s3c6410_clk_regs, |
---|
| 455 | + ARRAY_SIZE(s3c6410_clk_regs)); |
---|
512 | 456 | |
---|
513 | 457 | samsung_clk_of_add_provider(np, ctx); |
---|
514 | 458 | |
---|