forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/clk/samsung/clk.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
34 * Copyright (c) 2013 Linaro Ltd.
45 * Author: Thomas Abraham <thomas.ab@samsung.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 *
107 * This file includes utility functions to register clocks to common
118 * clock framework for Samsung platforms.
....@@ -15,6 +12,7 @@
1512 #include <linux/clkdev.h>
1613 #include <linux/clk.h>
1714 #include <linux/clk-provider.h>
15
+#include <linux/io.h>
1816 #include <linux/of_address.h>
1917 #include <linux/syscore_ops.h>
2018
....@@ -62,8 +60,7 @@
6260 struct samsung_clk_provider *ctx;
6361 int i;
6462
65
- ctx = kzalloc(sizeof(struct samsung_clk_provider) +
66
- sizeof(*ctx->clk_data.hws) * nr_clks, GFP_KERNEL);
63
+ ctx = kzalloc(struct_size(ctx, clk_data.hws, nr_clks), GFP_KERNEL);
6764 if (!ctx)
6865 panic("could not allocate clock provider context.\n");
6966
....@@ -290,9 +287,12 @@
290287 {
291288 struct samsung_clock_reg_cache *reg_cache;
292289
293
- list_for_each_entry(reg_cache, &clock_reg_cache_list, node)
290
+ list_for_each_entry(reg_cache, &clock_reg_cache_list, node) {
294291 samsung_clk_save(reg_cache->reg_base, reg_cache->rdump,
295292 reg_cache->rd_num);
293
+ samsung_clk_restore(reg_cache->reg_base, reg_cache->rsuspend,
294
+ reg_cache->rsuspend_num);
295
+ }
296296 return 0;
297297 }
298298
....@@ -310,9 +310,11 @@
310310 .resume = samsung_clk_resume,
311311 };
312312
313
-void samsung_clk_sleep_init(void __iomem *reg_base,
313
+void samsung_clk_extended_sleep_init(void __iomem *reg_base,
314314 const unsigned long *rdump,
315
- unsigned long nr_rdump)
315
+ unsigned long nr_rdump,
316
+ const struct samsung_clk_reg_dump *rsuspend,
317
+ unsigned long nr_rsuspend)
316318 {
317319 struct samsung_clock_reg_cache *reg_cache;
318320
....@@ -330,13 +332,10 @@
330332
331333 reg_cache->reg_base = reg_base;
332334 reg_cache->rd_num = nr_rdump;
335
+ reg_cache->rsuspend = rsuspend;
336
+ reg_cache->rsuspend_num = nr_rsuspend;
333337 list_add_tail(&reg_cache->node, &clock_reg_cache_list);
334338 }
335
-
336
-#else
337
-void samsung_clk_sleep_init(void __iomem *reg_base,
338
- const unsigned long *rdump,
339
- unsigned long nr_rdump) {}
340339 #endif
341340
342341 /*
....@@ -357,10 +356,6 @@
357356 }
358357
359358 ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids);
360
- if (!ctx) {
361
- panic("%s: unable to allocate ctx\n", __func__);
362
- return ctx;
363
- }
364359
365360 if (cmu->pll_clks)
366361 samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks,
....@@ -380,8 +375,9 @@
380375 samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks,
381376 cmu->nr_fixed_factor_clks);
382377 if (cmu->clk_regs)
383
- samsung_clk_sleep_init(reg_base, cmu->clk_regs,
384
- cmu->nr_clk_regs);
378
+ samsung_clk_extended_sleep_init(reg_base,
379
+ cmu->clk_regs, cmu->nr_clk_regs,
380
+ cmu->suspend_regs, cmu->nr_suspend_regs);
385381
386382 samsung_clk_of_add_provider(np, ctx);
387383