Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d77f77c authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Sylwester Nawrocki
Browse files

clk: samsung: exynos5420: Use generic helper for handling suspend/resume



Replace common suspend/resume handling code by generic helper.
Almost no functional change, the only difference is in handling
of hypothetical memory allocation failure on boot.

Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarSylwester Nawrocki <snawrocki@kernel.org>
parent 9a4d8a8c
Loading
Loading
Loading
Loading
+6 −66
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/syscore_ops.h>

#include "clk.h"
#include "clk-cpu.h"
@@ -156,10 +155,6 @@ enum exynos5x_plls {
static void __iomem *reg_base;
static enum exynos5x_soc exynos5x_soc;

#ifdef CONFIG_PM_SLEEP
static struct samsung_clk_reg_dump *exynos5x_save;
static struct samsung_clk_reg_dump *exynos5800_save;

/*
 * list of controller registers to be saved and restored during a
 * suspend/resume cycle.
@@ -283,66 +278,6 @@ static const struct samsung_clk_reg_dump exynos5420_set_clksrc[] = {
	{ .offset = GATE_IP_PERIC,		.value = 0xffffffff, },
};

static int exynos5420_clk_suspend(void)
{
	samsung_clk_save(reg_base, exynos5x_save,
				ARRAY_SIZE(exynos5x_clk_regs));

	if (exynos5x_soc == EXYNOS5800)
		samsung_clk_save(reg_base, exynos5800_save,
				ARRAY_SIZE(exynos5800_clk_regs));

	samsung_clk_restore(reg_base, exynos5420_set_clksrc,
				ARRAY_SIZE(exynos5420_set_clksrc));

	return 0;
}

static void exynos5420_clk_resume(void)
{
	samsung_clk_restore(reg_base, exynos5x_save,
				ARRAY_SIZE(exynos5x_clk_regs));

	if (exynos5x_soc == EXYNOS5800)
		samsung_clk_restore(reg_base, exynos5800_save,
				ARRAY_SIZE(exynos5800_clk_regs));
}

static struct syscore_ops exynos5420_clk_syscore_ops = {
	.suspend = exynos5420_clk_suspend,
	.resume = exynos5420_clk_resume,
};

static void __init exynos5420_clk_sleep_init(void)
{
	exynos5x_save = samsung_clk_alloc_reg_dump(exynos5x_clk_regs,
					ARRAY_SIZE(exynos5x_clk_regs));
	if (!exynos5x_save) {
		pr_warn("%s: failed to allocate sleep save data, no sleep support!\n",
			__func__);
		return;
	}

	if (exynos5x_soc == EXYNOS5800) {
		exynos5800_save =
			samsung_clk_alloc_reg_dump(exynos5800_clk_regs,
					ARRAY_SIZE(exynos5800_clk_regs));
		if (!exynos5800_save)
			goto err_soc;
	}

	register_syscore_ops(&exynos5420_clk_syscore_ops);
	return;
err_soc:
	kfree(exynos5x_save);
	pr_warn("%s: failed to allocate sleep save data, no sleep support!\n",
		__func__);
	return;
}
#else
static void __init exynos5420_clk_sleep_init(void) {}
#endif

/* list of all parent clocks */
PNAME(mout_mspll_cpu_p) = {"mout_sclk_cpll", "mout_sclk_dpll",
				"mout_sclk_mpll", "mout_sclk_spll"};
@@ -1540,7 +1475,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
		mout_kfc_p[0], mout_kfc_p[1], 0x28200,
		exynos5420_kfcclk_d, ARRAY_SIZE(exynos5420_kfcclk_d), 0);

	exynos5420_clk_sleep_init();
	samsung_clk_extended_sleep_init(reg_base,
		exynos5x_clk_regs, ARRAY_SIZE(exynos5x_clk_regs),
		exynos5420_set_clksrc, ARRAY_SIZE(exynos5420_set_clksrc));
	if (soc == EXYNOS5800)
		samsung_clk_sleep_init(reg_base, exynos5800_clk_regs,
				       ARRAY_SIZE(exynos5800_clk_regs));
	exynos5_subcmus_init(ctx, ARRAY_SIZE(exynos5x_subcmus),
			     exynos5x_subcmus);