aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02-C3000-voltage_050221.patch
blob: 1663304aaec6e999d9dfb9fca2131bc238949d61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
diff -Nur c3000_pre/linux/arch/arm/config.in c3000_work/linux/arch/arm/config.in
--- c3000_pre/linux/arch/arm/config.in	2005-02-21 21:41:40.000000000 +0900
+++ c3000_work/linux/arch/arm/config.in	2005-02-21 22:25:37.000000000 +0900
@@ -478,6 +478,9 @@
    if [ "$CONFIG_ARCH_PXA_SPITZ" = "y" ]; then
       bool 'Use clock change(cccr_change) enable (EXPERIMENTAL)' CONFIG_SL_CCCR_CHANGE
    fi
+   if [ "$CONFIG_SL_CCCR_CHANGE" = "y" ]; then
+      bool 'Core voltage change enable (EXPERIMENTAL)' CONFIG_CHANGE_CORE_VOLT
+   fi
    if [ "$CONFIG_ARCH_SHARP_SL" = "y" ]; then
       define_bool CONFIG_BATT y
    fi
diff -Nur c3000_pre/linux/arch/arm/mach-pxa/pxa27x_power.c c3000_work/linux/arch/arm/mach-pxa/pxa27x_power.c
--- c3000_pre/linux/arch/arm/mach-pxa/pxa27x_power.c	2004-11-04 14:13:54.000000000 +0900
+++ c3000_work/linux/arch/arm/mach-pxa/pxa27x_power.c	2005-02-21 22:25:37.000000000 +0900
@@ -150,6 +150,10 @@
 extern int sharpsl_main_bk_flag;
 int sharpsl_request_off = 0;
 
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+static unsigned char current_core_voltage = 0x1a;
+#endif
+
 void PrintParamTable(void);
 
 int sharpsl_restart(void)
@@ -324,7 +328,7 @@
   return -1;
 }
 
-#ifdef DEBUG
+#if defined(DEBUG) || defined(CONFIG_CHANGE_CORE_VOLT)
 int pwr_i2c_read( unsigned char device, unsigned char *value )
 {
   unsigned long	r;
@@ -405,12 +409,33 @@
 static void cpu_xscale_voltage_high(void)
 {
   pwr_i2c_open();
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+  pwr_i2c_write( 0x0c, current_core_voltage );
+  pwr_i2c_close();
+  printk("current voltage %x\n", current_core_voltage );
+#else
   pwr_i2c_write( 0x0c, 0x1a );  // 1.35V - SlewRate 1
   pwr_i2c_close();
+#endif
+}
+
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+void cpu_xscale_voltage_write(unsigned char value)
+{
+  if (value > 0x10 )
+    return;
+  value += 0x10;
+  pwr_i2c_open();
+  pwr_i2c_write( 0x0c, value );
+  pwr_i2c_close();
+  current_core_voltage = value;
+  printk("current voltage %x\n", current_core_voltage );
+
 }
+#endif
 
-#ifdef DEBUG
-static unsigned char cpu_xscale_voltage_read(void)
+#if defined(DEBUG) || defined(CONFIG_CHANGE_CORE_VOLT)
+unsigned char cpu_xscale_voltage_read(void)
 {
   unsigned char value=0xff;
   pwr_i2c_open();
@@ -418,7 +443,9 @@
   pwr_i2c_close();
   return value;
 }
+#endif
 
+#if defined(DEBUG)
 #define CLKCFG(a)	asm("mrc p14, 0, %0, C6, C0, 0" : "=r"(a))
 static void __debug_printk(void)
 {
diff -Nur c3000_pre/linux/arch/arm/mach-pxa/sharpsl_apm.c c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c
--- c3000_pre/linux/arch/arm/mach-pxa/sharpsl_apm.c	2005-02-21 21:44:13.000000000 +0900
+++ c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c	2005-02-21 22:29:17.000000000 +0900
@@ -135,6 +135,11 @@
 struct proc_dir_entry *proc_zaurus;
 #endif
 
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+extern unsigned char cpu_xscale_voltage_read(void);
+extern void cpu_xscale_voltage_write(unsigned char);
+#endif
+
 #if defined(CONFIG_SABINAL_DISCOVERY)
 #define SHARPSL_AC_LINE_STATUS (( ASIC3_GPIO_PSTS_D & AC_IN )? APM_AC_OFFLINE : APM_AC_ONLINE)
 #define BACKPACK_IN_DETECT()	( ASIC3_GPIO_PSTS_D & BACKPACK_DETECT ) /* 0: exist , 1: not in */
@@ -1036,6 +1041,58 @@
 EXPORT_SYMBOL(write_cccr);
 #endif
 
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+
+void write_vcore(int vcore)
+{
+    printk("Change Core voltage = %x.\n", vcore);
+    cpu_xscale_voltage_write(vcore);
+    return;
+}
+
+int read_vcore(void)
+{
+    return cpu_xscale_voltage_read();
+}
+
+static ssize_t core_volt_read_params(struct file *file, char *buf,
+				       size_t nbytes, loff_t *ppos)
+{
+        char outputbuf[32];
+	int count;
+	
+	if (*ppos>0) /* Assume reading completed in previous read*/
+	        return 0;
+	count = sprintf(outputbuf, "0x%02X\n", (unsigned int) cpu_xscale_voltage_read() );
+	count++;
+	*ppos += count;
+	if (count>nbytes)/* Assume output can be read at one time */
+	        return -EINVAL;
+	if (copy_to_user(buf, outputbuf, count+1))
+	        return -EFAULT;
+	return count;
+}
+
+static ssize_t core_volt_write_params(struct file *file, const char *buf,
+					size_t nbytes, loff_t *ppos)
+{
+        unsigned int param=0;
+    
+	sscanf(buf,"%x",&param);
+	if (param) {
+	    write_vcore(param);
+	}
+	return nbytes;
+}
+
+static struct file_operations proc_core_volt_params_operations = {
+        read:core_volt_read_params,
+        write:core_volt_write_params,
+};
+EXPORT_SYMBOL(read_vcore);
+EXPORT_SYMBOL(write_vcore);
+#endif
+
 #ifdef CONFIG_APM_CPU_IDLE
 #ifdef SHARPSL_NEW_IDLE
 static int save_icmr;
@@ -2849,6 +2906,7 @@
 	struct proc_dir_entry *lock_fcs_proc;
 	struct proc_dir_entry *power_mode_proc;
 	struct proc_dir_entry *cccr_change_proc;
+	struct proc_dir_entry *core_volt_proc;
 
 	apm_info.bios = apm_bios_info;
 	if (apm_info.bios.version == 0) {
@@ -2981,6 +3039,14 @@
 	        cccr_change_proc->proc_fops = &proc_cccr_change_params_operations;
 	}
 #endif
+
+#if defined(CONFIG_CHANGE_CORE_VOLT)
+	core_volt_proc = create_proc_entry("zaurus/VCORE", 0, NULL);
+	if (core_volt_proc) {
+	        core_volt_proc->proc_fops = &proc_core_volt_params_operations;
+	}
+#endif
+
 	kernel_thread(apm_thread, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
   	
 #if defined(CONFIG_SABINAL_DISCOVERY) || defined(CONFIG_ARCH_PXA_TOSA)