• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (c) 2012 Allwinner.
4  * 2012-05-01 Written by sunny (sunny@allwinnertech.com).
5  * 2012-10-01 Written by superm (superm@allwinnertech.com).
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18 #include <linux/module.h>
19 #include <linux/device.h>
20 #include <sunxi-sip.h>
21 
22 static u32 time_to_wakeup_ms;
23 static u32 debug_dram_crc_en;
24 static u32 debug_dram_crc_srcaddr = 0x40000000;
25 static u32 debug_dram_crc_len = (1024 * 1024);
26 
time_to_wakeup_ms_show(struct class * class,struct class_attribute * attr,char * buf)27 static ssize_t time_to_wakeup_ms_show(struct class *class, struct class_attribute *attr,
28 		char *buf)
29 {
30 	ssize_t size = 0;
31 
32 	size = sprintf(buf, "%u\n", time_to_wakeup_ms);
33 
34 	return size;
35 }
36 
time_to_wakeup_ms_store(struct class * class,struct class_attribute * attr,const char * buf,size_t count)37 static ssize_t time_to_wakeup_ms_store(struct class *class, struct class_attribute *attr,
38 		const char *buf, size_t count)
39 {
40 	u32 value = 0;
41 	int ret;
42 
43 	ret = kstrtoint(buf, 10, &value);
44 	if (ret) {
45 		pr_err("%s,%d err, invalid para!\n", __func__, __LINE__);
46 		return -EINVAL;
47 	}
48 
49 	time_to_wakeup_ms = value;
50 
51 	invoke_scp_fn_smc(SET_WAKEUP_SRC,
52 			SET_WAKEUP_TIME_MS(time_to_wakeup_ms), 0, 0);
53 
54 	pr_info("time_to_wakeup_ms change to %d\n", time_to_wakeup_ms);
55 
56 	return count;
57 }
58 static CLASS_ATTR_RW(time_to_wakeup_ms);
59 
dram_crc_paras_show(struct class * class,struct class_attribute * attr,char * buf)60 static ssize_t dram_crc_paras_show(struct class *class, struct class_attribute *attr,
61 			 char *buf)
62 {
63 	ssize_t size = 0;
64 
65 	size = sprintf(buf, "enable:0x%x srcaddr:0x%x lenght:0x%x\n", debug_dram_crc_en,
66 			debug_dram_crc_srcaddr, debug_dram_crc_len);
67 
68 	return size;
69 }
70 
dram_crc_paras_store(struct class * class,struct class_attribute * attr,const char * buf,size_t count)71 static ssize_t dram_crc_paras_store(struct class *class, struct class_attribute *attr,
72 		const char *buf, size_t count)
73 {
74 	u32 dram_crc_en      = 0;
75 	u32 dram_crc_srcaddr = 0;
76 	u32 dram_crc_len     = 0;
77 
78 	sscanf(buf, "%x %x %x\n", &dram_crc_en, &dram_crc_srcaddr, &dram_crc_len);
79 
80 	if ((dram_crc_en != 0) && (dram_crc_en != 1)) {
81 		pr_err("invalid debug dram crc paras [%x] [%x] [%x] to set\n",
82 			dram_crc_en, dram_crc_srcaddr, dram_crc_len);
83 
84 		return count;
85 	}
86 
87 	debug_dram_crc_en = dram_crc_en;
88 	debug_dram_crc_srcaddr = dram_crc_srcaddr;
89 	debug_dram_crc_len = dram_crc_len;
90 	invoke_scp_fn_smc(SET_DEBUG_DRAM_CRC_PARAS,
91 			debug_dram_crc_en,
92 			debug_dram_crc_srcaddr,
93 			debug_dram_crc_len);
94 	pr_info("dram_crc_en=0x%x, dram_crc_srcaddr=0x%x, dram_crc_len=0x%x\n",
95 		debug_dram_crc_en, debug_dram_crc_srcaddr, debug_dram_crc_len);
96 
97 	return count;
98 }
99 static CLASS_ATTR_RW(dram_crc_paras);
100 
101 static struct attribute *sunxi_standby_class_attrs[] = {
102 	&class_attr_time_to_wakeup_ms.attr,
103 	&class_attr_dram_crc_paras.attr,
104 	NULL,
105 };
106 ATTRIBUTE_GROUPS(sunxi_standby_class);
107 
108 struct class sunxi_standby_class = {
109 	.name = "sunxi_standby",
110 	.class_groups = sunxi_standby_class_groups,
111 };
112 
sunxi_standby_debug_init(void)113 static int __init sunxi_standby_debug_init(void)
114 {
115 	int ret;
116 
117 	ret = class_register(&sunxi_standby_class);
118 	if (ret < 0)
119 		pr_err("%s,%d err, ret:%d\n", __func__, __LINE__, ret);
120 
121 	return ret;
122 }
123 
sunxi_standby_debug_exit(void)124 static void __exit sunxi_standby_debug_exit(void)
125 {
126 	class_unregister(&sunxi_standby_class);
127 }
128 
129 module_init(sunxi_standby_debug_init);
130 module_exit(sunxi_standby_debug_exit);
131 
132 MODULE_DESCRIPTION("SUNXI STANDBY DEBUG");
133 MODULE_LICENSE("GPL");
134