summaryrefslogtreecommitdiff
path: root/target/linux/etrax-2.6/patches/cris/020-syscalls.patch
blob: f735ce7458d939256c05c4531f6097f4384f255d (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
diff -urN linux-2.6.19.2.orig/include/asm-cris/unistd.h linux-2.6.19.2/include/asm/unistd.h
--- linux-2.6.19.2.orig/include/asm-cris/unistd.h	2007-06-16 23:59:11.000000000 +0200
+++ linux-2.6.19.2/include/asm/unistd.h	2007-06-17 03:43:10.000000000 +0200
@@ -325,9 +325,52 @@
 #define __NR_getcpu		318
 #define __NR_epoll_pwait	319
 
+#ifdef CONFIG_ETRAX_GPIO 
+	#ifdef CONFIG_FOXBONE
+		#define __NR_gpiosetbits	320
+		#define __NR_gpioclearbits	321
+		#define __NR_gpiosetdir		322
+		#define __NR_gpiotogglebit	323
+		#define __NR_gpiogetbits	324
+		#define __NR_foxboneread	325
+		#define __NR_foxbonewrite	326 
+		#define __NR_foxbonebulkread	327 
+		#define __NR_foxbonebulkwrite	328 
+		#define __NR_foxbonereset	329
+		#define __NR_foxboneintreg	330
+		#define __NR_foxboneintcheck	331
+		#define __NR_foxboneintwait	332
+		#define NR_syscalls 333
+	
+	#else
+		#define __NR_gpiosetbits	320
+		#define __NR_gpioclearbits	321
+		#define __NR_gpiosetdir		322
+		#define __NR_gpiotogglebit	323
+		#define __NR_gpiogetbits	324
+		
+		#define NR_syscalls 325
+	#endif
+#else
+	#ifdef CONFIG_FOXBONE 
+		#define __NR_foxboneread	320
+		#define __NR_foxbonewrite	321 
+		#define __NR_foxbonebulkread	322
+		#define __NR_foxbonebulkwrite	323
+		#define __NR_foxboneintreg	324
+		#define __NR_foxboneintcheck	325
+		#define __NR_foxboneintwait	326
+	
+		#define NR_syscalls 327
+	
+	#else 
+	
+		#define NR_syscalls 320
+	#endif
+#endif
+	
 #ifdef __KERNEL__
 
-#define NR_syscalls 320
 
 #include <asm/arch/unistd.h>
 
--- linux-2.6.19.2.orig/include/linux/gpio_syscalls.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.19.2/include/linux/gpio_syscalls.h	2007-06-17 03:44:49.000000000 +0200
@@ -0,0 +1,75 @@
+#ifndef __LINUX_SYSCALL_GPIO
+#define __LINUX_SYSCALL_GPIO
+#include <linux/autoconf.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <asm/unistd.h>
+
+// port defines
+#define PORTA 	'A'
+#define PORTB 	'B'
+#define PORTG 	'G'
+
+//direction defines
+#define DIRIN 	'I'
+#define DIROUT 	'O'
+
+// pin defines for PORTG
+#define PG0	(1<<0)
+#define PG1     (1<<1)
+#define PG2     (1<<2)
+#define PG3     (1<<3)
+#define PG4     (1<<4)
+#define PG5     (1<<5)
+#define PG6     (1<<6)
+#define PG7     (1<<7)
+#define PG8     (1<<8)
+#define PG9     (1<<9)
+#define PG10	(1<<10)
+#define PG11    (1<<11)
+#define PG12    (1<<12)
+#define PG13    (1<<13)
+#define PG14    (1<<14)
+#define PG15    (1<<15)
+#define PG16    (1<<16)
+#define PG17    (1<<17)
+#define PG18    (1<<18)
+#define PG19    (1<<19)
+#define PG20    (1<<20)
+#define PG21    (1<<21)
+#define PG22    (1<<22)
+#define PG23    (1<<23)
+#define PG24    (1<<24)
+
+#define PG8_15	0x00ff00
+#define PG16_23	0xff0000
+
+
+// pin defines for PORTA
+#define PA0	(1<<0)
+#define PA1	(1<<1)
+#define PA2	(1<<2)
+#define PA3	(1<<3)
+#define PA4	(1<<4)
+#define PA5	(1<<5)
+#define PA6	(1<<6)
+#define PA7	(1<<7)
+
+// pin defines for PORTB
+#define PB0	(1<<0)
+#define PB1	(1<<1)
+#define PB2	(1<<2)
+#define PB3	(1<<3)
+#define PB4	(1<<4)
+#define PB5	(1<<5)
+#define PB6	(1<<6)
+#define PB7	(1<<7)
+
+int errno;
+_syscall2(void, gpiosetbits, unsigned char, port, unsigned int, bits);
+_syscall2(void, gpioclearbits, unsigned char, port, unsigned int, bits);
+_syscall3(void, gpiosetdir, unsigned char, port, unsigned char, dir, unsigned int, bits);
+_syscall2(void, gpiotogglebit, unsigned char, port, unsigned int, bits);
+_syscall2(unsigned int, gpiogetbits, unsigned char, port, unsigned int, bits);
+
+#endif
--- linux-2.6.19.2.orig/arch/cris/arch-v10/kernel/entry.S	2007-06-16 23:58:14.000000000 +0200
+++ linux-2.6.19.2/arch/cris/arch-v10/kernel/entry.S	2007-06-17 03:48:21.000000000 +0200
@@ -1200,6 +1200,23 @@
 	.long sys_move_pages
 	.long sys_getcpu
 	.long sys_epoll_pwait
+#ifdef CONFIG_ETRAX_GPIO
+	.long sys_gpiosetbits
+	.long sys_gpioclearbits
+	.long sys_gpiosetdir
+	.long sys_gpiotogglebit
+	.long sys_gpiogetbits
+#endif
+#ifdef CONFIG_FOXBONE
+	.long sys_foxboneread
+	.long sys_foxbonewrite
+	.long sys_foxbonebulkread
+	.long sys_foxbonebulkwrite
+	.long sys_foxbonereset
+	.long sys_foxboneintreg
+	.long sys_foxboneintcheck
+	.long sys_foxboneintwait	
+#endif
 		
         /*
          * NOTE!! This doesn't have to be exact - we just have
diff -urN linux-2.6.19.2.orig/arch/cris/arch-v10/drivers/gpio_syscalls.c linux-2.6.19.2/arch/cris/arch-v10/drivers/gpio_syscalls.c
--- linux-2.6.19.2.orig/arch/cris/arch-v10/drivers/gpio_syscalls.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.19.2/arch/cris/arch-v10/drivers/gpio_syscalls.c	2007-06-17 04:09:15.000000000 +0200
@@ -0,0 +1,192 @@
+
+#include <linux/autoconf.h>
+
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/poll.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+
+#include <asm/uaccess.h>
+#include <linux/gpio_syscalls.h>
+
+#include <asm/etraxgpio.h>
+#include <asm/arch/svinto.h>
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/irq.h>
+#include <asm/arch/io_interface_mux.h>
+
+#include <asm/unistd.h>
+
+
+extern int errno;
+
+
+asmlinkage void sys_gpiosetbits(unsigned char port, unsigned int bits){
+	switch(port){
+	case 'G':
+	case 'g':
+		*R_PORT_G_DATA = port_g_data_shadow |= bits;
+		break;
+		
+	case 'A':
+	case 'a':
+		*R_PORT_PA_DATA = port_pa_data_shadow |= bits;
+		break;
+
+	case 'B':
+	case 'b':
+		*R_PORT_PB_DATA = port_pb_data_shadow |= bits;
+		break;
+		
+	};
+};
+
+
+asmlinkage void sys_gpioclearbits(unsigned char port, unsigned int bits){
+	switch(port){
+	case 'G':
+	case 'g':
+		*R_PORT_G_DATA = port_g_data_shadow &= ~bits;
+		break;
+		
+	case 'A':
+	case 'a':
+		*R_PORT_PA_DATA = port_pa_data_shadow &= ~bits;
+		break;
+
+	case 'B':
+	case 'b':
+		*R_PORT_PB_DATA = port_pb_data_shadow &= ~bits;
+		break;
+		
+	};
+};
+
+asmlinkage void sys_gpiosetdir(unsigned char port, unsigned char dir, unsigned int bits){
+	if((dir=='I' )||(dir=='i')){
+		switch(port){
+		case 'G':
+		case 'g':
+			if(bits & (1<<0)){
+				genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g0dir);
+			};
+			if((bits & 0x0000FF00)==0x0000FF00){
+				genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g8_15dir);
+			};			
+			if((bits & 0x00FF0000)==0x00FF0000){
+				genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g16_23dir);
+			};			
+			if(bits & (1<<24)){
+				genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g24dir);
+			};			
+			*R_GEN_CONFIG = genconfig_shadow;
+			break;
+		
+		case 'A':
+		case 'a':
+			*R_PORT_PA_DIR = port_pa_dir_shadow &= ~(bits & 0xff);
+			break;
+
+		case 'B':
+		case 'b':
+			*R_PORT_PB_DIR = port_pb_dir_shadow &= ~(bits & 0xff);
+			break;
+		};
+	} else if((dir=='O' )||(dir=='o')){
+		switch(port){
+		case 'G':
+		case 'g':
+			if(bits & (1<<0)){
+				genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g0dir);
+			};
+			if((bits & 0x0000FF00)==0x0000FF00){
+				genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g8_15dir);
+			};			
+			if((bits & 0x00FF0000)==0x00FF0000){
+				genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g8_15dir);
+			};			
+			if(bits & (1<<24)){
+				genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g24dir);
+			};			
+			*R_GEN_CONFIG = genconfig_shadow;
+			break;
+		
+		case 'A':
+		case 'a':
+			*R_PORT_PA_DIR = port_pa_dir_shadow |= (bits & 0xff);
+			break;
+
+		case 'B':
+		case 'b':
+			*R_PORT_PB_DIR = port_pb_dir_shadow |= (bits & 0xff);
+			break;
+		};
+	};
+};
+
+
+asmlinkage void sys_gpiotogglebit(unsigned char port, unsigned int bits){
+	switch(port){
+	case 'G':
+	case 'g':
+		if(port_g_data_shadow & bits){
+			*R_PORT_G_DATA = port_g_data_shadow &= ~bits;
+		} else {
+			*R_PORT_G_DATA = port_g_data_shadow |= bits;
+		};
+		break;
+		
+	case 'A':
+	case 'a':
+		if(*R_PORT_PA_DATA & bits){
+			*R_PORT_PA_DATA = port_pa_data_shadow &= ~(bits & 0xff);
+		} else {
+			*R_PORT_PA_DATA = port_pa_data_shadow |= (bits & 0xff);	
+		};
+		break;
+
+	case 'B':
+	case 'b':
+		if(*R_PORT_PB_DATA & bits){
+			*R_PORT_PB_DATA = port_pb_data_shadow &= ~(bits & 0xff);
+		} else {
+			*R_PORT_PB_DATA = port_pb_data_shadow |= (bits & 0xff);	
+		};
+		break;
+		
+	};
+};
+
+
+asmlinkage unsigned int sys_gpiogetbits(unsigned char port, unsigned int bits){
+	unsigned int data = 0;
+	switch(port){
+	case 'G':
+	case 'g':
+		data = *R_PORT_G_DATA;
+		break;
+		
+	case 'A':
+	case 'a':
+		data = *R_PORT_PA_DATA;
+		break;
+
+	case 'B':
+	case 'b':
+		data = *R_PORT_PB_DATA;
+		break;
+		
+	};
+	data &= bits;
+	return data;
+};
+
+
Only in linux-2.6.19.2/arch/cris/arch-v10/drivers/: gpio_syscalls.c
diff linux-2.6.19.2.orig/arch/cris/arch-v10/drivers/Makefile linux-2.6.19.2/arch/cris/arch-v10/drivers/Makefile
8a9
> obj-$(CONFIG_ETRAX_GPIO)            += gpio_syscalls.o