.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
---|
3 | 4 | * Copyright (c) 2013 Linaro Ltd. |
---|
4 | 5 | * 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. |
---|
9 | 6 | * |
---|
10 | 7 | * This file includes utility functions to register clocks to common |
---|
11 | 8 | * clock framework for Samsung platforms. |
---|
.. | .. |
---|
15 | 12 | #include <linux/clkdev.h> |
---|
16 | 13 | #include <linux/clk.h> |
---|
17 | 14 | #include <linux/clk-provider.h> |
---|
| 15 | +#include <linux/io.h> |
---|
18 | 16 | #include <linux/of_address.h> |
---|
19 | 17 | #include <linux/syscore_ops.h> |
---|
20 | 18 | |
---|
.. | .. |
---|
62 | 60 | struct samsung_clk_provider *ctx; |
---|
63 | 61 | int i; |
---|
64 | 62 | |
---|
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); |
---|
67 | 64 | if (!ctx) |
---|
68 | 65 | panic("could not allocate clock provider context.\n"); |
---|
69 | 66 | |
---|
.. | .. |
---|
290 | 287 | { |
---|
291 | 288 | struct samsung_clock_reg_cache *reg_cache; |
---|
292 | 289 | |
---|
293 | | - list_for_each_entry(reg_cache, &clock_reg_cache_list, node) |
---|
| 290 | + list_for_each_entry(reg_cache, &clock_reg_cache_list, node) { |
---|
294 | 291 | samsung_clk_save(reg_cache->reg_base, reg_cache->rdump, |
---|
295 | 292 | reg_cache->rd_num); |
---|
| 293 | + samsung_clk_restore(reg_cache->reg_base, reg_cache->rsuspend, |
---|
| 294 | + reg_cache->rsuspend_num); |
---|
| 295 | + } |
---|
296 | 296 | return 0; |
---|
297 | 297 | } |
---|
298 | 298 | |
---|
.. | .. |
---|
310 | 310 | .resume = samsung_clk_resume, |
---|
311 | 311 | }; |
---|
312 | 312 | |
---|
313 | | -void samsung_clk_sleep_init(void __iomem *reg_base, |
---|
| 313 | +void samsung_clk_extended_sleep_init(void __iomem *reg_base, |
---|
314 | 314 | 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) |
---|
316 | 318 | { |
---|
317 | 319 | struct samsung_clock_reg_cache *reg_cache; |
---|
318 | 320 | |
---|
.. | .. |
---|
330 | 332 | |
---|
331 | 333 | reg_cache->reg_base = reg_base; |
---|
332 | 334 | reg_cache->rd_num = nr_rdump; |
---|
| 335 | + reg_cache->rsuspend = rsuspend; |
---|
| 336 | + reg_cache->rsuspend_num = nr_rsuspend; |
---|
333 | 337 | list_add_tail(®_cache->node, &clock_reg_cache_list); |
---|
334 | 338 | } |
---|
335 | | - |
---|
336 | | -#else |
---|
337 | | -void samsung_clk_sleep_init(void __iomem *reg_base, |
---|
338 | | - const unsigned long *rdump, |
---|
339 | | - unsigned long nr_rdump) {} |
---|
340 | 339 | #endif |
---|
341 | 340 | |
---|
342 | 341 | /* |
---|
.. | .. |
---|
357 | 356 | } |
---|
358 | 357 | |
---|
359 | 358 | 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 | | - } |
---|
364 | 359 | |
---|
365 | 360 | if (cmu->pll_clks) |
---|
366 | 361 | samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks, |
---|
.. | .. |
---|
380 | 375 | samsung_clk_register_fixed_factor(ctx, cmu->fixed_factor_clks, |
---|
381 | 376 | cmu->nr_fixed_factor_clks); |
---|
382 | 377 | 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); |
---|
385 | 381 | |
---|
386 | 382 | samsung_clk_of_add_provider(np, ctx); |
---|
387 | 383 | |
---|