Add s3ctl Hibernation code for porter board.
[AGL/meta-agl.git] / meta-agl-bsp / meta-renesas / recipes-kernel / s3ctl-module / files / 0001-Add-s3ctl-hibernation-code.patch
1 From 03253eae0da9a84e343a8f21c65ac07196369420 Mon Sep 17 00:00:00 2001
2 From: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
3 Date: Sun, 21 May 2017 23:08:52 +0900
4 Subject: [PATCH] Add s3ctl hibernation code
5
6 Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
7 ---
8  drv/s3ctl_drv.c | 50 ++++++++++++++++++++++++++++++++++++++------------
9  1 file changed, 38 insertions(+), 12 deletions(-)
10
11 diff --git a/drv/s3ctl_drv.c b/drv/s3ctl_drv.c
12 index a7b4bee..6640a49 100755
13 --- a/drv/s3ctl_drv.c
14 +++ b/drv/s3ctl_drv.c
15 @@ -66,6 +66,7 @@
16  #include <linux/ioctl.h>
17  #include <linux/slab.h>
18  #include <linux/dma-mapping.h>
19 +#include <linux/suspend.h>
20  
21  #include "s3ctl_private.h"
22  
23 @@ -332,19 +333,10 @@ static struct miscdevice misc = {
24         .fops           = &fops,
25  };
26  
27 -
28 -static int s3ctrl_init(void)
29 +static int s3ctl_initialize(void)
30  {
31 -       int ret;
32 -       unsigned int product;
33 -       unsigned int es;
34 -
35 -       ret = map_register();
36 -       if (ret != 0) {
37 -               printk(KERN_ERR "S3D map_register() NG\n");
38 -               return -1;
39 -       }
40 -
41 +       int product;
42 +       int es;
43         product = S3_PRR_PRODUCTMASK & ioread32((void *)top_prr);
44         es = S3_PRR_ESMASK & ioread32((void *)top_prr);
45         if (product == S3_PRR_H2) {
46 @@ -366,11 +358,44 @@ static int s3ctrl_init(void)
47                         set_xymodeconf(S3_XYMODE_VAL_NEW);
48         } else
49                 set_xymodeconf(S3_XYMODE_VAL_NEW);
50 +       return 0;
51 +}
52 +
53 +static int s3ctl_cpu_pm_notify(struct notifier_block *self,
54 +                               unsigned long action, void *hcpu)
55 +{
56 +       if (action == PM_HIBERNATION_PREPARE)
57 +               ;
58 +       else if (action == PM_POST_HIBERNATION) {
59 +               pr_info("%s: hibernation finished: %ld\n", __func__, action);
60 +               s3ctl_initialize();
61 +       }
62 +       return NOTIFY_DONE;
63 +}
64 +
65 +static struct notifier_block s3ctl_pm_notifier_block  = {
66 +       .notifier_call = s3ctl_cpu_pm_notify,
67 +};
68 +
69 +static int s3ctrl_init(void)
70 +{
71 +       int ret;
72 +       unsigned int product;
73 +       unsigned int es;
74 +
75 +       ret = map_register();
76 +       if (ret != 0) {
77 +               printk(KERN_ERR "S3D map_register() NG\n");
78 +               return -1;
79 +       }
80 +       s3ctl_initialize();
81  
82         misc_register(&misc);
83  
84         spin_lock_init(&lock);
85  
86 +       register_pm_notifier(&s3ctl_pm_notifier_block);
87 +
88         return 0;
89  }
90  
91 @@ -379,6 +404,7 @@ static void s3ctrl_exit(void)
92         misc_deregister(&misc);
93  
94         unmap_register();
95 +       unregister_pm_notifier(&s3ctl_pm_notifier_block);
96  }
97  
98  module_init(s3ctrl_init);
99 -- 
100 1.8.3.1
101