cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

pm-s3c2416.c (1865B)


      1// SPDX-License-Identifier: GPL-2.0
      2//
      3// Copyright (c) 2010 Samsung Electronics Co., Ltd.
      4//		http://www.samsung.com
      5//
      6// S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
      7
      8#include <linux/device.h>
      9#include <linux/syscore_ops.h>
     10#include <linux/io.h>
     11
     12#include <asm/cacheflush.h>
     13
     14#include "regs-s3c2443-clock.h"
     15
     16#include "cpu.h"
     17#include "pm.h"
     18
     19#include "s3c2412-power.h"
     20
     21#ifdef CONFIG_PM_SLEEP
     22extern void s3c2412_sleep_enter(void);
     23
     24static int s3c2416_cpu_suspend(unsigned long arg)
     25{
     26	/* enable wakeup sources regardless of battery state */
     27	__raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
     28
     29	/* set the mode as sleep, 2BED represents "Go to BED" */
     30	__raw_writel(0x2BED, S3C2443_PWRMODE);
     31
     32	s3c2412_sleep_enter();
     33
     34	pr_info("Failed to suspend the system\n");
     35	return 1; /* Aborting suspend */
     36}
     37
     38static void s3c2416_pm_prepare(void)
     39{
     40	/*
     41	 * write the magic value u-boot uses to check for resume into
     42	 * the INFORM0 register, and ensure INFORM1 is set to the
     43	 * correct address to resume from.
     44	 */
     45	__raw_writel(0x2BED, S3C2412_INFORM0);
     46	__raw_writel(__pa_symbol(s3c_cpu_resume), S3C2412_INFORM1);
     47}
     48
     49static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
     50{
     51	pm_cpu_prep = s3c2416_pm_prepare;
     52	pm_cpu_sleep = s3c2416_cpu_suspend;
     53
     54	return 0;
     55}
     56
     57static struct subsys_interface s3c2416_pm_interface = {
     58	.name		= "s3c2416_pm",
     59	.subsys		= &s3c2416_subsys,
     60	.add_dev	= s3c2416_pm_add,
     61};
     62
     63static __init int s3c2416_pm_init(void)
     64{
     65	return subsys_interface_register(&s3c2416_pm_interface);
     66}
     67
     68arch_initcall(s3c2416_pm_init);
     69#endif
     70
     71static void s3c2416_pm_resume(void)
     72{
     73	/* unset the return-from-sleep amd inform flags */
     74	__raw_writel(0x0, S3C2443_PWRMODE);
     75	__raw_writel(0x0, S3C2412_INFORM0);
     76	__raw_writel(0x0, S3C2412_INFORM1);
     77}
     78
     79struct syscore_ops s3c2416_pm_syscore_ops = {
     80	.resume		= s3c2416_pm_resume,
     81};