Blame view

arch/arm/mach-s3c2416/pm.c 1.93 KB
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
1
2
3
4
5
6
7
8
9
10
11
  /* linux/arch/arm/mach-s3c2416/pm.c
   *
   * Copyright (c) 2010 Samsung Electronics Co., Ltd.
   *		http://www.samsung.com
   *
   * S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
  */
4a858cfc9   Kay Sievers   arm: convert sysd...
12
  #include <linux/device.h>
bb072c3cf   Rafael J. Wysocki   ARM / Samsung: Us...
13
  #include <linux/syscore_ops.h>
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
14
15
16
17
18
19
20
21
22
23
24
  #include <linux/io.h>
  
  #include <asm/cacheflush.h>
  
  #include <mach/regs-power.h>
  #include <mach/regs-s3c2443-clock.h>
  
  #include <plat/cpu.h>
  #include <plat/pm.h>
  
  extern void s3c2412_sleep_enter(void);
29cb3cd20   Russell King   ARM: pm: allow su...
25
  static int s3c2416_cpu_suspend(unsigned long arg)
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
26
  {
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
27
28
29
30
31
32
33
  	/* enable wakeup sources regardless of battery state */
  	__raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
  
  	/* set the mode as sleep, 2BED represents "Go to BED" */
  	__raw_writel(0x2BED, S3C2443_PWRMODE);
  
  	s3c2412_sleep_enter();
29cb3cd20   Russell King   ARM: pm: allow su...
34
35
  
  	panic("sleep resumed to originator?");
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
36
37
38
39
40
41
42
43
44
45
46
47
  }
  
  static void s3c2416_pm_prepare(void)
  {
  	/*
  	 * write the magic value u-boot uses to check for resume into
  	 * the INFORM0 register, and ensure INFORM1 is set to the
  	 * correct address to resume from.
  	 */
  	__raw_writel(0x2BED, S3C2412_INFORM0);
  	__raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
  }
4a858cfc9   Kay Sievers   arm: convert sysd...
48
  static int s3c2416_pm_add(struct device *dev)
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
49
50
51
52
53
54
  {
  	pm_cpu_prep = s3c2416_pm_prepare;
  	pm_cpu_sleep = s3c2416_cpu_suspend;
  
  	return 0;
  }
4a858cfc9   Kay Sievers   arm: convert sysd...
55
56
57
58
  static struct subsys_interface s3c2416_pm_interface = {
  	.name		= "s3c2416_pm",
  	.subsys		= &s3c2416_subsys,
  	.add_dev	= s3c2416_pm_add,
bb072c3cf   Rafael J. Wysocki   ARM / Samsung: Us...
59
60
61
  };
  
  static __init int s3c2416_pm_init(void)
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
62
  {
4a858cfc9   Kay Sievers   arm: convert sysd...
63
  	return subsys_interface_register(&s3c2416_pm_interface);
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
64
  }
bb072c3cf   Rafael J. Wysocki   ARM / Samsung: Us...
65
66
67
68
  arch_initcall(s3c2416_pm_init);
  
  
  static void s3c2416_pm_resume(void)
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
69
70
71
72
73
  {
  	/* unset the return-from-sleep amd inform flags */
  	__raw_writel(0x0, S3C2443_PWRMODE);
  	__raw_writel(0x0, S3C2412_INFORM0);
  	__raw_writel(0x0, S3C2412_INFORM1);
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
74
  }
bb072c3cf   Rafael J. Wysocki   ARM / Samsung: Us...
75
  struct syscore_ops s3c2416_pm_syscore_ops = {
6436b6a7a   Abhilash Kesavan   ARM: S3C2416: Add...
76
77
  	.resume		= s3c2416_pm_resume,
  };