Skip to content

Commit

Permalink
ARM: EXYNOS: Encapsulate register access inside a function for pm
Browse files Browse the repository at this point in the history
That makes the code cleaner and encapsulted. The function will be
reused in the next patch.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
  • Loading branch information
Daniel Lezcano authored and Kukjin Kim committed May 25, 2014
1 parent 7880e45 commit 309e08c
Showing 1 changed file with 41 additions and 24 deletions.
65 changes: 41 additions & 24 deletions arch/arm/mach-exynos/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,42 @@ int exynos_cluster_power_state(int cluster)
/* For Cortex-A9 Diagnostic and Power control register */
static unsigned int save_arm_register[2];

static void exynos_cpu_save_register(void)
{
unsigned long tmp;

/* Save Power control register */
asm ("mrc p15, 0, %0, c15, c0, 0"
: "=r" (tmp) : : "cc");

save_arm_register[0] = tmp;

/* Save Diagnostic register */
asm ("mrc p15, 0, %0, c15, c0, 1"
: "=r" (tmp) : : "cc");

save_arm_register[1] = tmp;
}

static void exynos_cpu_restore_register(void)
{
unsigned long tmp;

/* Restore Power control register */
tmp = save_arm_register[0];

asm volatile ("mcr p15, 0, %0, c15, c0, 0"
: : "r" (tmp)
: "cc");

/* Restore Diagnostic register */
tmp = save_arm_register[1];

asm volatile ("mcr p15, 0, %0, c15, c0, 1"
: : "r" (tmp)
: "cc");
}

static int exynos_cpu_suspend(unsigned long arg)
{
#ifdef CONFIG_CACHE_L2X0
Expand Down Expand Up @@ -228,17 +264,8 @@ static int exynos_pm_suspend(void)
tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
__raw_writel(tmp, S5P_CENTRAL_SEQ_OPTION);

if (!soc_is_exynos5250()) {
/* Save Power control register */
asm ("mrc p15, 0, %0, c15, c0, 0"
: "=r" (tmp) : : "cc");
save_arm_register[0] = tmp;

/* Save Diagnostic register */
asm ("mrc p15, 0, %0, c15, c0, 1"
: "=r" (tmp) : : "cc");
save_arm_register[1] = tmp;
}
if (!soc_is_exynos5250())
exynos_cpu_save_register();

return 0;
}
Expand All @@ -262,19 +289,9 @@ static void exynos_pm_resume(void)
/* No need to perform below restore code */
goto early_wakeup;
}
if (!soc_is_exynos5250()) {
/* Restore Power control register */
tmp = save_arm_register[0];
asm volatile ("mcr p15, 0, %0, c15, c0, 0"
: : "r" (tmp)
: "cc");

/* Restore Diagnostic register */
tmp = save_arm_register[1];
asm volatile ("mcr p15, 0, %0, c15, c0, 1"
: : "r" (tmp)
: "cc");
}

if (!soc_is_exynos5250())
exynos_cpu_restore_register();

/* For release retention */

Expand Down

0 comments on commit 309e08c

Please sign in to comment.