95478f82805e225a95ae3095182555681e46cab7
[10.03/openwrt.git] / target / linux / etrax-2.6 / patches / cris / 019-vhdl.patch
1 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone.c linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone.c
2 --- linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone.c      1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone.c   2007-06-17 02:46:15.000000000 +0200
4 @@ -0,0 +1,533 @@
5 +/*  
6 +  foxbone.c
7 +  Linux Kernel Driver for FoxBone on FOX VHDL Board 
8 +  (based on FoxBone protocol interface specifications rel 0.7)    
9 +  For more info see: http://www.acmesystems.it/?id=120
10 +  Author: John Crispin
11 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
12 +  
13 +  This is free software; you can redistribute it and/or modify
14 +  it under the terms of the GNU General Public License as published by
15 +  the Free Software Foundation; either version 2 of the License, or
16 +  (at your option) any later version.
17 +    
18 +  This example is distributed in the hope that it will be useful,
19 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 +  GNU General Public License for more details.
22 +    
23 +  To have a copy of the GNU General Public License write to the Free Software
24 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 +*/
26 +
27 +#include <linux/module.h>
28 +#include <linux/init.h>
29 +#include <linux/module.h>
30 +#include <linux/errno.h>
31 +#include <linux/ioport.h>
32 +#include <linux/version.h>
33 +#include <linux/init.h>
34 +#include <asm/uaccess.h>
35 +#include <asm/io.h>
36 +#include <linux/vmalloc.h>
37 +#include <linux/ioport.h>
38 +#include <linux/init.h>
39 +#include <linux/genhd.h>
40 +#include <linux/spinlock.h>
41 +#include <linux/autoconf.h>
42 +#include <linux/interrupt.h>
43 +#include <asm/etraxgpio.h>
44 +#include <asm/arch/svinto.h>
45 +#include <asm/io.h>
46 +#include <asm/system.h>
47 +#include <asm/irq.h>
48 +#include <asm/arch/io_interface_mux.h>
49 +
50 +
51 +#include "foxbone.h"
52 +#include "foxbone_userspace.h"
53 +
54 +
55 +#define Fox_line_Read                  (1<<1)
56 +#define Fox_line_WriteData             (1<<2)
57 +#define Fox_line_Reset                 (1<<3)
58 +#define Fox_line_WriteAddress          (1<<4)
59 +
60 +#define FOX_CLEAR_LINES                        (~(0x00FFFF00 | Fox_line_Read | Fox_line_WriteAddress | Fox_line_WriteData))
61 +
62 +#define DEV_NAME                       "foxbone"
63 +#define DEV_MAJOR                      14
64 +
65 +spinlock_t foxbone_lock_var = SPIN_LOCK_UNLOCKED;
66 +unsigned long foxbone_irq_flags;
67 +// is the userspce device enables ?
68 +unsigned char foxbone_userspace_is_open = 0;
69 +
70 +// are we processing interrupts ? (during fpga_flash the ints are not allowed to be handles
71 +unsigned char foxbone_allow_int;
72 +
73 +// the shadow of which ints are enabled
74 +unsigned int foxbone_shadow_int_high = 0;
75 +unsigned int foxbone_shadow_int_low = 0;
76 +
77 +// the following four variables get filled when the foxbone driver is started
78 +// they hold the release and the the application words
79 +unsigned int FOXBONE_release = 0;
80 +unsigned int FOXBONE_application1 = 0;
81 +unsigned int FOXBONE_application2 = 0;
82 +unsigned int FOXBONE_application3 = 0;
83 +
84 +
85 +
86 +FOXINT_CALLBACK foxint_callbacks[32];
87 +
88 +unsigned int foxbone_read(unsigned int add);
89 +void foxbone_write(unsigned int add, unsigned int data);
90 +
91 +static irqreturn_t foxbone_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs);
92 +
93 +unsigned int foxbone_interrupt_enabled = 0;
94 +
95 +
96 +       
97 +void FOX_delay(unsigned int d){
98 +       while(d--){
99 +               unsigned int i = 0;
100 +               for(i = 0; i < 32000; i++){
101 +                       i*=2;
102 +                       i/=2;
103 +               };
104 +       };
105 +};
106 +
107 +
108 +void foxbone_lock(void){
109 +       spin_lock_irqsave(&foxbone_lock_var, foxbone_irq_flags);
110 +
111 +};
112 +
113 +void foxbone_unlock(void){
114 +       spin_unlock_irqrestore(&foxbone_lock_var, foxbone_irq_flags);
115 +
116 +};
117 +
118 +int foxbone_register_interrupt(unsigned char irq, FOXINT_CALLBACK callback){
119 +       if(irq > 31){
120 +               printk("foxbone: trying to register invalid interrupt\n");
121 +               return 0;
122 +       };
123 +       if(!foxbone_interrupt_enabled){
124 +               foxbone_interrupt_enabled = 1;
125 +               printk("foxbone: starting interrupt system\n");                         
126 +               int err;
127 +               if ((err = request_irq(PA_IRQ_NBR, foxbone_pa_interrupt, SA_INTERRUPT | SA_SHIRQ, "foxbone", 123))){
128 +                       printk("foxbone: request_irq failed: Error %d\n",err);
129 +                       return ;
130 +               }
131 +               printk("foxbone: request_irq success -> irq: %ld\n",PA_IRQ_NBR);
132 +               *R_IRQ_MASK1_SET = IO_STATE(R_IRQ_MASK1_SET, pa0, set); 
133 +       };      
134 +       
135 +       printk("foxbone: new int %d registered\n", irq);
136 +       foxint_callbacks[irq] = callback;
137 +       if(irq < 15){
138 +               foxbone_shadow_int_high |= (1<<irq);
139 +               foxbone_write(0x08, foxbone_shadow_int_high);
140 +       } else {
141 +               foxbone_shadow_int_high |= (1<<15);
142 +               foxbone_write(0x08, foxbone_shadow_int_high);
143 +               foxbone_shadow_int_low |= (1<<(irq-16));
144 +               foxbone_write(0x09, foxbone_shadow_int_low);
145 +       };
146 +       return 1;       
147 +};
148 +
149 +
150 +void foxbone_unregister_interrupt(unsigned char irq){
151 +       if(irq > 31){
152 +               printk("foxbone: trying to unregister invalid interrupt\n");
153 +               return ;
154 +       };
155 +       printk("foxbone: interrupt %d unregistered\n", irq);
156 +       if(irq < 15){
157 +               foxbone_shadow_int_high &= ~(1<<irq);
158 +               foxbone_write(0x08, foxbone_shadow_int_high);
159 +       } else {
160 +               foxbone_shadow_int_low &= ~(1<<(irq-16));
161 +               foxbone_write(0x09, foxbone_shadow_int_low);
162 +
163 +               if(!foxbone_shadow_int_low){
164 +                       foxbone_shadow_int_high &= ~(1<<15);
165 +                       foxbone_write(0x08, foxbone_shadow_int_high);
166 +               };
167 +       };
168 +};
169 +
170 +#if 0
171 +#define DBG_INT(x) x
172 +#else
173 +#define DBG_INT(x)
174 +#endif
175 +
176 +// this is the bottom half of our interrupt handler
177 +static void foxbone_handle_interrupt(void){
178 +       if(foxbone_allow_int){
179 +               foxbone_lock();
180 +               unsigned int irq_high, irq_low, i;
181 +               DBG_INT(printk("Int handler");)
182 +               if(*R_PORT_PA_DATA & (1)){
183 +                       irq_high = foxbone_read(0x08);
184 +                       DBG_INT(printk("Got high_int %d\n", irq_high);)
185 +                       for(i = 0; i < 15; i++){
186 +                               if(irq_high & (1<<i)){
187 +                                       DBG_INT(printk("Go high_int %d\n",i);)
188 +                                       if(foxint_callbacks[i]){
189 +                                               foxint_callbacks[i](i);
190 +                                       };
191 +                               };
192 +                       };
193 +                       if(irq_high & (0x8000)){
194 +                               irq_low = foxbone_read(0x09);
195 +                               DBG_INT(printk("Got low_int %d\n", irq_low);)
196 +                               for(i = 0; i < 16; i++){
197 +                                       if(irq_low & (1<<i)){
198 +                                               DBG_INT(printk("Go low_int %d\n", i);)
199 +                                               if(foxint_callbacks[i+16]){
200 +                                                       foxint_callbacks[i+16](i+16);
201 +                                               };
202 +                                       };
203 +                               };
204 +
205 +                       };
206 +               };
207 +               foxbone_unlock();
208 +       };
209 +};
210 +
211 +// this is the top half of our interrupt handler
212 +static void tasklet_foxbone_int(unsigned long data);
213 +DECLARE_TASKLET(tl_foxint_descr, tasklet_foxbone_int, 0L);
214 +static void tasklet_foxbone_int(unsigned long data){
215 +       
216 +       DBG_INT(printk("got an int\n");)
217 +       foxbone_handle_interrupt();
218 +       
219 +}; 
220 +
221 +
222 +static irqreturn_t
223 +foxbone_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs)
224 +{      
225 +       unsigned long tmp;
226 +       
227 +       /* Find what PA interrupts are active */
228 +       tmp = (*R_IRQ_READ1);
229 +//     printk("_____%ud",*R_IRQ_READ1);
230 +       /* Find those that we have enabled */
231 +//     tmp &= (1 << R_IRQ_MASK1_SET__pa0__BITNR);
232 +
233 +       /* Clear them.. */
234 +       // *R_IRQ_MASK1_CLR = tmp;
235 +       //(1 << R_IRQ_MASK1_SET__pa0__BITNR);
236 +       
237 +       tasklet_schedule(&tl_foxint_descr);
238 +       // *R_IRQ_MASK1_SET = IO_STATE(R_IRQ_MASK1_SET, pa0, set);
239 +       
240 +        return IRQ_RETVAL(1);
241 +}
242 +
243 +
244 +static void foxbone_bus_in(void){
245 +       // turn all the iog8-15 pins into outputs
246 +       genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g8_15dir);
247 +       *R_GEN_CONFIG = genconfig_shadow;
248 +       
249 +       // turn all the iog16-23 pins into outputs
250 +       genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g16_23dir);
251 +       *R_GEN_CONFIG = genconfig_shadow;       
252 +};
253 +
254 +static void foxbone_bus_out(void){
255 +       // turn all the iog8-15 pins into outputs
256 +       genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g8_15dir);
257 +       *R_GEN_CONFIG = genconfig_shadow;
258 +       
259 +       // turn all the iog16-23 pins into outputs
260 +       genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g16_23dir);
261 +       *R_GEN_CONFIG = genconfig_shadow;       
262 +};
263 +
264 +void foxbone_reset(unsigned char reset){
265 +       if(reset){
266 +               *R_PORT_G_DATA = port_g_data_shadow |= Fox_line_Reset;
267 +       } else {
268 +               *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_Reset;
269 +       };
270 +};
271 +
272 +static void foxbone_setadd(unsigned long address){
273 +       *R_PORT_G_DATA = port_g_data_shadow &= FOX_CLEAR_LINES;
274 +
275 +       *R_PORT_G_DATA = port_g_data_shadow |= (address << 8)| Fox_line_WriteAddress;
276 +
277 +       *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteAddress; 
278 +};
279 +
280 +
281 +static unsigned int foxbone_read_data(unsigned char next){
282 +       unsigned int data;
283 +       *R_PORT_G_DATA = port_g_data_shadow &= FOX_CLEAR_LINES;
284 +
285 +       foxbone_bus_in();
286 +       
287 +       *R_PORT_G_DATA = port_g_data_shadow |= Fox_line_Read;
288 +       
289 +       // do the reading now
290 +       data =  *R_PORT_G_DATA;
291 +       data =  *R_PORT_G_DATA;
292 +       
293 +       // now return the Fox_line_ReadData to low state to idle the bus from the FPGA side
294 +       *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_Read;
295 +       foxbone_bus_out();
296 +       return ((unsigned int)((data&0x00FFFF00)>>8));
297 +}
298 +
299 +
300 +static unsigned int foxbone_write_data(unsigned int data, unsigned char next) {
301 +       // clear all address/data/control bits
302 +       *R_PORT_G_DATA = port_g_data_shadow &= FOX_CLEAR_LINES; 
303 +
304 +       *R_PORT_G_DATA = port_g_data_shadow |= (data << 8)| Fox_line_WriteData;
305 +       *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteData;
306 +       
307 +       return 0;
308 +}
309 +
310 +void foxbone_write(unsigned int add, unsigned int data){
311 +       foxbone_setadd(add);
312 +       foxbone_write_data(data, 0);
313 +};
314 +
315 +unsigned int foxbone_read(unsigned int add){
316 +       foxbone_setadd(add);
317 +       return foxbone_read_data(0);
318 +};
319 +
320 +void foxbone_write_next(unsigned data){
321 +       foxbone_write_data(data, 1);
322 +};
323 +
324 +unsigned int foxbone_read_next(void){
325 +       return foxbone_read_data(1);
326 +};
327 +
328 +void foxbone_bulk_write(unsigned int *data, unsigned int length, unsigned int add){
329 +       unsigned int i;
330 +       foxbone_write(add, *data);
331 +       unsigned long def_val = (port_g_data_shadow & 0xff0000ff) | Fox_line_WriteData;
332 +       for(i = 1; i < length; i++){    
333 +               *R_PORT_G_DATA = port_g_data_shadow = def_val | data[i]<<8;
334 +               *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteData;
335 +       };
336 +};
337 +
338 +void foxbone_bulk_read(unsigned int *data, unsigned int length, unsigned int add){
339 +       //printk("Get data from %d %d\n", add, length);
340 +       unsigned int i;
341 +       for(i = 0; i < length; i++){    
342 +               if(i == 0){
343 +                       data[i] = foxbone_read(add);
344 +               } else {
345 +                       data[i] = foxbone_read_next();
346 +               };
347 +       };
348 +       
349 +};
350 +
351 +void foxbone_initialise_bus(void){
352 +       memset(foxint_callbacks, 0, sizeof(FOXINT_CALLBACK)*32);
353 +
354 +       // clear all address/data/control bits
355 +       *R_PORT_G_DATA = port_g_data_shadow &= FOX_CLEAR_LINES; 
356 +       foxbone_reset(0);
357 +       int i;
358 +       for(i = 0; i < 32000; i++){
359 +               i++;
360 +               i--;
361 +       };
362 +       foxbone_reset(1);
363 +       
364 +       foxbone_bus_out();
365 +       
366 +       FOXBONE_release = foxbone_read(0x04);
367 +       FOXBONE_application1 = foxbone_read(0x05);
368 +       FOXBONE_application2 = foxbone_read(0x06);
369 +       FOXBONE_application3 = foxbone_read(0x07);
370 +       printk("foxbone : release = 0x%04x\n", FOXBONE_release);
371 +       printk("foxbone : application word 1 = 0x%04x\n", FOXBONE_application1);
372 +       printk("foxbone : application word 2 = 0x%04x\n", FOXBONE_application2);        
373 +       printk("foxbone : application word 3 = 0x%04x\n", FOXBONE_application3);
374 +
375 +       
376 +};
377 +
378 +
379 +static ssize_t foxbone_userspace_write(struct file * file, const char * buffer, size_t count, loff_t *offset){ 
380 +       if(count > (64 * 1024)){
381 +               printk("foxbone: trying to bulk write too much data\n");
382 +               return 1;
383 +       };
384 +       unsigned int *bulk_data = (unsigned int) kmalloc(count, GFP_KERNEL);
385 +       
386 +       copy_from_user((char*) bulk_data, buffer, count);
387 +       
388 +       foxbone_bulk_write(&bulk_data[2], bulk_data[1], bulk_data[0]);
389 +       
390 +       kfree(bulk_data);       
391 +       return 0;
392 +};
393 +
394 +
395 +static ssize_t foxbone_userspace_read(struct file *file, char *buffer, size_t count, loff_t *offset){
396 +       if(count > (64 * 1024)){
397 +               printk("foxbone: trying to bulk read too much data\n");
398 +               return 0;
399 +       };
400 +       
401 +       // find out which register we want to read
402 +       unsigned int bulk_data_info[2];
403 +       copy_from_user((char*) bulk_data_info, buffer, 8);
404 +               
405 +       // read the data
406 +       unsigned int *bulk_data = (unsigned int)kmalloc(count, GFP_KERNEL);
407 +               
408 +       foxbone_bulk_read(&bulk_data[0], bulk_data_info[1], bulk_data_info[0]);
409 +       
410 +       copy_to_user((char*)buffer, (char*)bulk_data, count);
411 +       
412 +       kfree(bulk_data);
413 +       
414 +       return count / 4;
415 +};
416 +
417 +// the app has send us some control data
418 +static int foxbone_userspace_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
419 +       int retval = 0;
420 +       FOXBONE_WRITE fb_write;
421 +       switch (cmd) {
422 +               case IOCTL_FOXBONE_INIT_BUS:
423 +                       foxbone_initialise_bus();
424 +                       break;
425 +                       
426 +               case IOCTL_FOXBONE_WRITE_REG:
427 +                       copy_from_user((FOXBONE_WRITE*)&fb_write, (FOXBONE_WRITE*)arg, sizeof(fb_write));
428 +                       foxbone_write(fb_write.reg, fb_write.data);
429 +                       break;
430 +               
431 +               case IOCTL_FOXBONE_READ_REG:
432 +                       retval = foxbone_read(arg);
433 +                       break;
434 +               
435 +               case IOCTL_FOXBONE_WRITE_NEXT:
436 +                       copy_from_user((FOXBONE_WRITE*)&fb_write, (FOXBONE_WRITE*)arg, sizeof(fb_write));
437 +                       foxbone_write_next(fb_write.data);
438 +                       break;
439 +               
440 +               case IOCTL_FOXBONE_READ_NEXT:
441 +                       retval = foxbone_read_next();
442 +                       break;
443 +
444 +               case IOCTL_FOXBONE_INTERRUPTS:
445 +                       foxbone_allow_int = arg;
446 +                       break;
447 +                               
448 +               default:
449 +                       printk("foxbone_userspace : unknown ioctl\n");
450 +                       break;          
451 +       }
452 +       return retval;
453 +};
454 +
455 +
456 +
457 +static int foxbone_userspace_open(struct inode *inode, struct file *file){
458 +       // Which minor device is the user trying to access ?
459 +       unsigned int dev_minor = MINOR(inode->i_rdev);
460 +       
461 +       // we only supprt minor 0 at the moment
462 +       if(dev_minor !=  0){
463 +               printk("foxbone_userspace : trying to access unknown minor device -> %d\n", dev_minor);
464 +               return -ENODEV;
465 +       }
466 +       
467 +       // check if another app is currently using the device
468 +       if(foxbone_userspace_is_open) {
469 +               printk("foxbone_userspace : Device with minor ID %d already in use\n", dev_minor);
470 +               return -EBUSY;
471 +       }
472 +       
473 +       return 0;
474 +};
475 +
476 +
477 +// gets called when an app closes the device
478 +static int foxbone_userspace_close(struct inode * inode, struct file * file){
479 +
480 +       foxbone_userspace_is_open = 0;
481 +       
482 +       return 0;
483 +};
484 +
485 +// so the kernel knows which functions to access for a given operation
486 +struct file_operations foxbone_userspace_fops = {
487 +        ioctl:          foxbone_userspace_ioctl,
488 +       write:          foxbone_userspace_write,
489 +       read:           foxbone_userspace_read,
490 +        open:           foxbone_userspace_open,
491 +        release:        foxbone_userspace_close
492 +};
493 +
494 +
495 +// module gets loaded into kernel / char dev is registered
496 +static int foxbone_userspace_init(void){
497 +       // flame the kprintk
498 +       printk("foxbone_userspace : FOX-VHDL userspace access module\n");
499 +       
500 +       // register the character device
501 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxbone_userspace_fops)) {
502 +               printk( "fpga_mod.ko : Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
503 +               return( -ENODEV );
504 +       };
505 +       
506 +       foxbone_userspace_is_open = 0;
507 +       printk("foxbone_userspace : Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
508 +       return 0;
509 +}
510 +
511 +
512 +// we are done so shut everything down
513 +static void foxbone_userspace_exit(void){
514 +       // tell the kernel that the device is not needed anymore
515 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
516 +       
517 +}
518 +
519 +
520 +static int __init foxbone_init(void){
521 +       printk("foxbone : FOX-VHDL FOXBONE access module started\n");
522 +       foxbone_initialise_bus();
523 +       foxbone_allow_int = 1;
524 +       foxbone_userspace_init();
525 +       return 0;
526 +}
527 +
528 +
529 +static void __exit foxbone_exit(void){
530 +       printk( "foxbone : Cleanup\n" );
531 +       foxbone_userspace_exit();
532 +}
533 +
534 +module_init (foxbone_init);
535 +module_exit (foxbone_exit);
536 +
537 +
538 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone.h
539 --- linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone.h      1970-01-01 01:00:00.000000000 +0100
540 +++ linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone.h   2007-06-17 02:46:15.000000000 +0200
541 @@ -0,0 +1,21 @@
542 +// prototypes for foxbone compliant modules
543 +
544 +typedef void (*FOXINT_CALLBACK) (unsigned int);
545 +
546 +extern unsigned int FOXBONE_release;
547 +extern unsigned int FOXBONE_application1;
548 +extern unsigned int FOXBONE_application2;
549 +extern unsigned int FOXBONE_application3;
550 +
551 +void foxbone_write(unsigned int add, unsigned int data);
552 +
553 +unsigned int foxbone_read(unsigned int add);
554 +
555 +void foxbone_write_next(unsigned data);
556 +
557 +unsigned int foxbone_read_next(void);
558 +
559 +void foxbone_initialise_bus(void);
560 +void foxbone_unregister_interrupt(unsigned char irq);
561 +int foxbone_register_interrupt(unsigned char irq, FOXINT_CALLBACK callback);
562 +void foxbone_reset(unsigned char reset);
563 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone_syscalls.c linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone_syscalls.c
564 --- linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone_syscalls.c     1970-01-01 01:00:00.000000000 +0100
565 +++ linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone_syscalls.c  2007-06-17 02:46:15.000000000 +0200
566 @@ -0,0 +1,155 @@
567 +/*  
568 +  foxbone_syscalls.c
569 +  Linux Kernel syscalls for FoxBone on FOX VHDL Board 
570 +  (based on FoxBone protocol interface specifications rel 0.7)    
571 +  For more info see: http://www.acmesystems.it/?id=120
572 +  Author: John Crispin
573 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
574 +  
575 +  This is free software; you can redistribute it and/or modify
576 +  it under the terms of the GNU General Public License as published by
577 +  the Free Software Foundation; either version 2 of the License, or
578 +  (at your option) any later version.
579 +    
580 +  This example is distributed in the hope that it will be useful,
581 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
582 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
583 +  GNU General Public License for more details.
584 +    
585 +  To have a copy of the GNU General Public License write to the Free Software
586 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
587 +*/
588 +
589 +
590 +#include <linux/kernel.h>
591 +#include <asm/uaccess.h>
592 +#include <linux/foxbone_syscalls.h>
593 +#include "foxbone.h"
594 +
595 +asmlinkage unsigned short int sys_foxboneread(unsigned short int reg){
596 +       return foxbone_read(reg);
597 +};
598 +
599 +asmlinkage void sys_foxbonewrite(unsigned short int reg, unsigned short int value){
600 +       foxbone_write(reg, value);
601 +};
602 +
603 +asmlinkage void sys_foxbonebulkread(unsigned short int reg, unsigned short int *value, unsigned int length){
604 +       unsigned int i;
605 +       unsigned int *buffer = kmalloc(length * 2, GFP_KERNEL);
606 +       *buffer = foxbone_read(reg);
607 +       for(i = 1; i < length; i++){
608 +               buffer[i] = foxbone_read_next();
609 +       };
610 +       copy_to_user(value, buffer, length * 2);
611 +       kfree(buffer);  
612 +       
613 +};
614 +
615 +asmlinkage void sys_foxbonebulkwrite(unsigned short int reg, unsigned short int *value, unsigned int length){
616 +       unsigned int i;
617 +       unsigned int *buffer = kmalloc(length * 2, GFP_KERNEL);
618 +       copy_from_user(buffer, value, length * 2);
619 +       foxbone_write(reg, *buffer);
620 +       for(i = 1; i < length; i++){
621 +               foxbone_write_next(buffer[i]);
622 +       };
623 +       kfree(buffer);  
624 +};
625 +
626 +
627 +/*
628 +       interrupt handling from userspace
629 +*/
630 +
631 +typedef struct _FOX_INT {
632 +       unsigned char enabled;
633 +       unsigned char count;
634 +       unsigned char wakeup;
635 +       wait_queue_head_t wait_queue;
636 +} FOX_INT;
637 +
638 +
639 +FOX_INT syscall_interrupts[32];
640 +
641 +
642 +void foxbone_interrupt_callback(unsigned int interrupt){
643 +       //printk("GOT INT %d\n", irq_no);
644 +       if(syscall_interrupts[interrupt].enabled){
645 +               syscall_interrupts[interrupt].count ++;
646 +               if(syscall_interrupts[interrupt].wakeup){
647 +                       wake_up_interruptible(&syscall_interrupts[interrupt].wait_queue);
648 +               };
649 +       };      
650 +};
651 +
652 +
653 +asmlinkage void sys_foxboneintreg(unsigned long int interrupt, unsigned char state){
654 +       if(interrupt > 31){
655 +               interrupt = 31;
656 +       };
657 +       if(state){
658 +               foxbone_register_interrupt(interrupt, foxbone_interrupt_callback);
659 +               syscall_interrupts[interrupt].enabled = 1;
660 +               syscall_interrupts[interrupt].count = 0;
661 +               init_waitqueue_head(&syscall_interrupts[interrupt].wait_queue);
662 +       } else {
663 +               foxbone_unregister_interrupt(interrupt);
664 +               syscall_interrupts[interrupt].enabled = 0;              
665 +       };
666 +};
667 +
668 +
669 +asmlinkage unsigned int sys_foxboneintcheck( unsigned long int interrupt){
670 +       unsigned int retval = 0xffff;
671 +       if(interrupt > 31){
672 +               interrupt = 31;
673 +       };      
674 +       if(syscall_interrupts[interrupt].enabled){
675 +               retval = syscall_interrupts[interrupt].count;
676 +               syscall_interrupts[interrupt].count = 0;
677 +       };
678 +       return retval;
679 +};
680 +
681 +
682 +asmlinkage unsigned int sys_foxboneintwait(unsigned long int interrupt, unsigned char timeout){
683 +       unsigned int retval = 0xffff;
684 +       if(interrupt > 31){
685 +               interrupt = 31;
686 +       };
687 +       if(syscall_interrupts[interrupt].enabled){
688 +               syscall_interrupts[interrupt].wakeup = 1;
689 +               syscall_interrupts[interrupt].count = 0;
690 +               interruptible_sleep_on_timeout(&syscall_interrupts[interrupt].wait_queue, timeout*HZ);
691 +               if(syscall_interrupts[interrupt].count != 0){
692 +                       retval = syscall_interrupts[interrupt].count;
693 +               };
694 +               syscall_interrupts[interrupt].count = 0;
695 +               syscall_interrupts[interrupt].wakeup = 0;
696 +       };
697 +       return retval;
698 +};
699 +
700 +
701 +asmlinkage void sys_foxbonereset(unsigned short int reg){
702 +       foxbone_reset(0);
703 +       int i;
704 +       for(i = 0; i < 32000; i++){
705 +               i++;
706 +               i--;
707 +       };
708 +       foxbone_reset(1);
709 +};
710 +
711 +static int __init foxbone_syscall_init(void){
712 +       memset(syscall_interrupts, 0, sizeof(FOX_INT) * 32);
713 +       return 0;
714 +}
715 +
716 +
717 +static void __exit foxbone_syscall_exit(void){
718 +}
719 +
720 +module_init (foxbone_syscall_init);
721 +module_exit (foxbone_syscall_exit);
722 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone_userspace.h linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone_userspace.h
723 --- linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/foxbone_userspace.h    1970-01-01 01:00:00.000000000 +0100
724 +++ linux-2.6.19.2/drivers/fox-vhdl/foxbone/foxbone_userspace.h 2007-06-17 02:46:15.000000000 +0200
725 @@ -0,0 +1,17 @@
726 +// These are the ioctls for accessing /dev/foxbone
727 +
728 +#define IOCTL_FOXBONE_INIT_BUS         0x3341
729 +#define IOCTL_FOXBONE_WRITE_REG        0x3342
730 +#define IOCTL_FOXBONE_READ_REG         0x3343
731 +#define IOCTL_FOXBONE_WRITE_NEXT       0x3344
732 +#define IOCTL_FOXBONE_READ_NEXT        0x3345
733 +#define IOCTL_FOXBONE_INTERRUPTS       0x3346
734 +
735 +// the data structure used to write a register
736 +typedef struct _FOXBONE_WRITE {
737 +       unsigned int reg;
738 +       unsigned int data;
739 +} FOXBONE_WRITE; 
740 +
741 +
742 +
743 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/Makefile linux-2.6.19.2/drivers/fox-vhdl/foxbone/Makefile
744 --- linux-2.6.19.2.orig/drivers/fox-vhdl/foxbone/Makefile       1970-01-01 01:00:00.000000000 +0100
745 +++ linux-2.6.19.2/drivers/fox-vhdl/foxbone/Makefile    2007-06-17 02:46:15.000000000 +0200
746 @@ -0,0 +1,2 @@
747 +obj-$(CONFIG_FOXBONE)          += foxbone.o
748 +obj-$(CONFIG_FOXBONE)          += foxbone_syscalls.o
749 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_event/foxbone.h
750 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/foxbone.h    1970-01-01 01:00:00.000000000 +0100
751 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_event/foxbone.h 2007-06-17 02:46:15.000000000 +0200
752 @@ -0,0 +1,16 @@
753 +// prototypes for foxbone compliant modules
754 +
755 +extern unsigned int FOXBONE_release;
756 +extern unsigned int FOXBONE_application1;
757 +extern unsigned int FOXBONE_application2;
758 +extern unsigned int FOXBONE_application3;
759 +
760 +void foxbone_write(unsigned int add, unsigned int data);
761 +
762 +unsigned int foxbone_read(unsigned int add);
763 +
764 +void foxbone_write_next(unsigned data);
765 +
766 +unsigned int foxbone_read_next(void);
767 +
768 +void foxbone_initialise_bus(void);
769 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/fox_event.c linux-2.6.19.2/drivers/fox-vhdl/fox_event/fox_event.c
770 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/fox_event.c  1970-01-01 01:00:00.000000000 +0100
771 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_event/fox_event.c       2007-06-17 02:46:15.000000000 +0200
772 @@ -0,0 +1,170 @@
773 +/*  
774 +  fox_event.c
775 +  Linux Kernel Driver for FoxBone EventCounter on FOX VHDL Board 
776 +  (based on FoxBone protocol interface specifications rel 0.7)    
777 +  For more info see: http://www.acmesystems.it/?id=120
778 +  Author: John Crispin
779 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
780 +  
781 +  This is free software; you can redistribute it and/or modify
782 +  it under the terms of the GNU General Public License as published by
783 +  the Free Software Foundation; either version 2 of the License, or
784 +  (at your option) any later version.
785 +    
786 +  This example is distributed in the hope that it will be useful,
787 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
788 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
789 +  GNU General Public License for more details.
790 +    
791 +  To have a copy of the GNU General Public License write to the Free Software
792 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
793 +*/
794 +
795 +#include <linux/module.h>
796 +#include <linux/init.h>
797 +#include <linux/module.h>
798 +#include <linux/errno.h>
799 +#include <linux/ioport.h>
800 +#include <linux/version.h>
801 +#include <linux/init.h>
802 +#include <asm/uaccess.h>
803 +#include <asm/io.h>
804 +#include <linux/vmalloc.h>
805 +#include <linux/ioport.h>  
806 +#include <linux/init.h>
807 +#include <linux/genhd.h>
808 +
809 +#define DEV_NAME                       "event"
810 +#define DEV_MAJOR                      193
811 +
812 +#include "foxbone.h"
813 +
814 +unsigned char foxevent_is_open = 0;
815 +
816 +
817 +#define IOCTL_FOXBONE_EVENT_SET_ALARM  0x4745
818 +#define IOCTL_FOXBONE_EVENT_GET_COUNT  0x4746
819 +#define IOCTL_FOXBONE_EVENT_GET_ALARM  0x4747
820 +#define IOCTL_FOXBONE_EVENT_RESET_ALARM        0x4748
821 +
822 +// the app has send us some control data
823 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
824 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
825 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
826 +       int retval = 0;
827 +       unsigned int current_io = 0;
828 +       switch (cmd) {
829 +               case IOCTL_FOXBONE_EVENT_SET_ALARM:
830 +                       foxbone_write(0x0040, 0);
831 +                       foxbone_write(0x0041, arg);
832 +                       foxbone_write(0x0040, 3);
833 +                       break;
834 +       
835 +               case IOCTL_FOXBONE_EVENT_GET_COUNT:
836 +                       retval = foxbone_read(0x0042);
837 +                       break;
838 +               
839 +               case IOCTL_FOXBONE_EVENT_GET_ALARM:
840 +                       retval = foxbone_read(0x0043);
841 +                       break;
842 +                       
843 +               case IOCTL_FOXBONE_EVENT_RESET_ALARM:
844 +                       current_io = foxbone_read(0x0040);
845 +                       current_io &= ~(1<<1);
846 +                       foxbone_write(0x0040, 0);
847 +                       current_io |= (1<<1);
848 +                       foxbone_write(0x0040, 0);
849 +                       break;
850 +                       
851 +               default:
852 +                       printk("fox_event: unknown ioctl\n");
853 +                       break;                  
854 +       }
855 +
856 +       return retval;
857 +};
858 +
859 +
860 +
861 +static int module_open(struct inode *inode, struct file *file){
862 +       // Which minor device is the user trying to access ?
863 +       unsigned int dev_minor = MINOR(inode->i_rdev);
864 +       
865 +       // we only supprt minor 0 at the moment
866 +       if(dev_minor !=  0){
867 +               printk("fox_event: trying to access unknown minor device -> %d\n", dev_minor);
868 +               return -ENODEV;
869 +       }
870 +       
871 +       // check if another app is currently using the device
872 +       if(foxevent_is_open) {
873 +               printk("fox_event: Device with minor ID %d already in use\n", dev_minor);
874 +               return -EBUSY;
875 +       }
876 +       
877 +       // more flaming
878 +       printk("fox_event: Minor %d has been opened\n", dev_minor);
879 +       return 0;
880 +};
881 +
882 +
883 +// gets called when an app closes the device
884 +static int module_close(struct inode * inode, struct file * file){
885 +       // Which minor device is the user trying to access ?
886 +       unsigned int dev_minor = MINOR(inode->i_rdev);
887 +       
888 +       // remember that the device has been closed
889 +       foxevent_is_open = 0;
890 +       
891 +       
892 +       // more flaming
893 +       printk("fox_event: Minor %d has been closed\n", dev_minor);
894 +       
895 +       return 0;
896 +};
897 +
898 +// so the kernel knows which functions to access for a given operation
899 +struct file_operations foxevent_module_fops = {
900 +        ioctl:         module_ioctl,
901 +        open:          module_open,
902 +        release:       module_close
903 +};
904 +
905 +
906 +// module gets loaded into kernel / char dev is registered
907 +static int __init mod_init(void){
908 +       // flame the kprintk
909 +       printk("fox_event: FOX-VHDL FPGA io module\n");
910 +       //printk("fox_event: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
911 +       //printk("fox_event: Starting ...\n");
912 +       
913 +       // register the character device
914 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxevent_module_fops)) {
915 +               printk( "fox_event: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
916 +               return( -ENODEV );
917 +       };
918 +       
919 +
920 +       // remember that the driver has been opened
921 +       foxevent_is_open = 0;
922 +       printk("fox_event: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
923 +       return 0;
924 +}
925 +
926 +
927 +// we are done so shut everything down
928 +static void __exit mod_exit(void){
929 +       printk( "fox_event: Cleanup\n" );
930 +       // tell the kernel that the device is not needed anymore
931 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
932 +       
933 +}
934 +
935 +module_init (mod_init);
936 +module_exit (mod_exit);
937 +
938 +
939 +
940 +
941 +
942 +
943 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_event/Makefile
944 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_event/Makefile     1970-01-01 01:00:00.000000000 +0100
945 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_event/Makefile  2007-06-17 02:46:15.000000000 +0200
946 @@ -0,0 +1 @@
947 +obj-$(CONFIG_FOXBONE_EVENT)          += fox_event.o
948 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_fpga_flash/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_fpga_flash/Makefile
949 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_fpga_flash/Makefile        1970-01-01 01:00:00.000000000 +0100
950 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_fpga_flash/Makefile     2007-06-17 02:46:15.000000000 +0200
951 @@ -0,0 +1,2 @@
952 +obj-$(CONFIG_FOX_FPGA)          += dpa3palg.oo dpalg.oo dpjtag2.oo dpjtag.oo dpuncomp.oo dpuser.oo fpga_module.oo
953 +
954 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_fpga_flash/MakefileORI linux-2.6.19.2/drivers/fox-vhdl/fox_fpga_flash/MakefileORI
955 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_fpga_flash/MakefileORI     1970-01-01 01:00:00.000000000 +0100
956 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_fpga_flash/MakefileORI  2007-06-17 02:46:15.000000000 +0200
957 @@ -0,0 +1 @@
958 +obj-$(CONFIG_FOX_FPGA)          += dpa3palg.o dpalg.o dpjtag2.o dpjtag.o dpuncomp.o dpuser.o fpga_module.o
959 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_io/foxbone.h
960 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/foxbone.h       1970-01-01 01:00:00.000000000 +0100
961 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_io/foxbone.h    2007-06-17 02:46:15.000000000 +0200
962 @@ -0,0 +1,16 @@
963 +// prototypes for foxbone compliant modules
964 +
965 +extern unsigned int FOXBONE_release;
966 +extern unsigned int FOXBONE_application1;
967 +extern unsigned int FOXBONE_application2;
968 +extern unsigned int FOXBONE_application3;
969 +
970 +void foxbone_write(unsigned int add, unsigned int data);
971 +
972 +unsigned int foxbone_read(unsigned int add);
973 +
974 +void foxbone_write_next(unsigned data);
975 +
976 +unsigned int foxbone_read_next(void);
977 +
978 +void foxbone_initialise_bus(void);
979 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/fox_io.c linux-2.6.19.2/drivers/fox-vhdl/fox_io/fox_io.c
980 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/fox_io.c        1970-01-01 01:00:00.000000000 +0100
981 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_io/fox_io.c     2007-06-17 02:46:15.000000000 +0200
982 @@ -0,0 +1,164 @@
983 +/*  
984 +  fox_io.c
985 +  Linux Kernel Driver for FoxBone I/O on FOX VHDL Board 
986 +  (based on FoxBone protocol interface specifications rel 0.7)    
987 +  For more info see: http://www.acmesystems.it/?id=120
988 +  Author: John Crispin
989 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
990 +  
991 +  This is free software; you can redistribute it and/or modify
992 +  it under the terms of the GNU General Public License as published by
993 +  the Free Software Foundation; either version 2 of the License, or
994 +  (at your option) any later version.
995 +    
996 +  This example is distributed in the hope that it will be useful,
997 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
998 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
999 +  GNU General Public License for more details.
1000 +    
1001 +  To have a copy of the GNU General Public License write to the Free Software
1002 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1003 +*/
1004 +
1005 +#include <linux/module.h>
1006 +#include <linux/init.h>
1007 +#include <linux/module.h>
1008 +#include <linux/errno.h>
1009 +#include <linux/ioport.h>
1010 +#include <linux/version.h>
1011 +#include <linux/init.h>
1012 +#include <asm/uaccess.h>
1013 +#include <asm/io.h>
1014 +#include <linux/vmalloc.h>
1015 +#include <linux/ioport.h>  
1016 +#include <linux/init.h>
1017 +#include <linux/genhd.h>
1018 +
1019 +#define DEV_NAME                       "foxio"
1020 +#define DEV_MAJOR                      190
1021 +
1022 +#include "foxbone.h"
1023 +
1024 +unsigned char foxio_is_open = 0;
1025 +
1026 +
1027 +#define IOCTL_FOXBONE_IO_SET           0x4545
1028 +#define IOCTL_FOXBONE_IO_CLR           0x4546
1029 +#define IOCTL_FOXBONE_IO_GET           0x4547
1030 +
1031 +// the app has send us some control data
1032 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
1033 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
1034 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
1035 +       int retval = 0;
1036 +       unsigned int current_io = 0;
1037 +       switch (cmd) {
1038 +               case IOCTL_FOXBONE_IO_SET:
1039 +                       current_io = foxbone_read(0x0014);
1040 +                       current_io |= (1<<arg);
1041 +                       foxbone_write(0x0014, current_io);
1042 +                       break;
1043 +       
1044 +               case IOCTL_FOXBONE_IO_CLR:
1045 +                       current_io = foxbone_read(0x0014);
1046 +                       current_io &= ~(1<<arg);
1047 +                       foxbone_write(0x0014, current_io);
1048 +                       break;
1049 +               
1050 +               case IOCTL_FOXBONE_IO_GET:
1051 +                       retval = foxbone_read(0x0015);
1052 +                       break;
1053 +               
1054 +                       
1055 +               default:
1056 +                       printk("fox_io: unknown ioctl\n");
1057 +                       break;                  
1058 +       }
1059 +
1060 +       return retval;
1061 +};
1062 +
1063 +
1064 +
1065 +static int module_open(struct inode *inode, struct file *file){
1066 +       // Which minor device is the user trying to access ?
1067 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1068 +       
1069 +       // we only supprt minor 0 at the moment
1070 +       if(dev_minor !=  0){
1071 +               printk("fox_io: trying to access unknown minor device -> %d\n", dev_minor);
1072 +               return -ENODEV;
1073 +       }
1074 +       
1075 +       // check if another app is currently using the device
1076 +       if(foxio_is_open) {
1077 +               printk("fox_io: Device with minor ID %d already in use\n", dev_minor);
1078 +               return -EBUSY;
1079 +       }
1080 +       
1081 +       // more flaming
1082 +       printk("fox_io: Minor %d has been opened\n", dev_minor);
1083 +       return 0;
1084 +};
1085 +
1086 +
1087 +// gets called when an app closes the device
1088 +static int module_close(struct inode * inode, struct file * file){
1089 +       // Which minor device is the user trying to access ?
1090 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1091 +       
1092 +       // remember that the device has been closed
1093 +       foxio_is_open = 0;
1094 +       
1095 +       
1096 +       // more flaming
1097 +       printk("fox_io: Minor %d has been closed\n", dev_minor);
1098 +       
1099 +       return 0;
1100 +};
1101 +
1102 +// so the kernel knows which functions to access for a given operation
1103 +struct file_operations foxio_module_fops = {
1104 +        ioctl:         module_ioctl,
1105 +        open:          module_open,
1106 +        release:       module_close
1107 +};
1108 +
1109 +
1110 +// module gets loaded into kernel / char dev is registered
1111 +static int __init mod_init(void){
1112 +       // flame the kprintk
1113 +       printk("fox_io: FOX-VHDL FPGA io module\n");
1114 +       //printk("fox_io: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
1115 +       //printk("fox_io: Starting ...\n");
1116 +       
1117 +       // register the character device
1118 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxio_module_fops)) {
1119 +               printk( "fox_io: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
1120 +               return( -ENODEV );
1121 +       };
1122 +       
1123 +
1124 +       // remember that the driver has been opened
1125 +       foxio_is_open = 0;
1126 +       printk("fox_io: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
1127 +       return 0;
1128 +}
1129 +
1130 +
1131 +// we are done so shut everything down
1132 +static void __exit mod_exit(void){
1133 +       printk( "fox_io: Cleanup\n" );
1134 +       // tell the kernel that the device is not needed anymore
1135 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
1136 +       
1137 +}
1138 +
1139 +module_init (mod_init);
1140 +module_exit (mod_exit);
1141 +
1142 +
1143 +
1144 +
1145 +
1146 +
1147 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_io/Makefile
1148 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_io/Makefile        1970-01-01 01:00:00.000000000 +0100
1149 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_io/Makefile     2007-06-17 02:46:15.000000000 +0200
1150 @@ -0,0 +1 @@
1151 +obj-$(CONFIG_FOXBONE_IO)          += fox_io.o
1152 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/foxbone.h
1153 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/foxbone.h 1970-01-01 01:00:00.000000000 +0100
1154 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/foxbone.h      2007-06-17 02:46:15.000000000 +0200
1155 @@ -0,0 +1,16 @@
1156 +// prototypes for foxbone compliant modules
1157 +
1158 +extern unsigned int FOXBONE_release;
1159 +extern unsigned int FOXBONE_application1;
1160 +extern unsigned int FOXBONE_application2;
1161 +extern unsigned int FOXBONE_application3;
1162 +
1163 +void foxbone_write(unsigned int add, unsigned int data);
1164 +
1165 +unsigned int foxbone_read(unsigned int add);
1166 +
1167 +void foxbone_write_next(unsigned data);
1168 +
1169 +unsigned int foxbone_read_next(void);
1170 +
1171 +void foxbone_initialise_bus(void);
1172 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/fox_loopback.c linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/fox_loopback.c
1173 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/fox_loopback.c    1970-01-01 01:00:00.000000000 +0100
1174 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/fox_loopback.c 2007-06-17 02:46:15.000000000 +0200
1175 @@ -0,0 +1,154 @@
1176 +/*  
1177 +  fox_loopback.c
1178 +  Linux Kernel Driver for FoxBone Loopback Register on FOX VHDL Board 
1179 +  (based on FoxBone protocol interface specifications rel 0.7)    
1180 +  For more info see: http://www.acmesystems.it/?id=120
1181 +  Author: John Crispin
1182 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
1183 +  
1184 +  This is free software; you can redistribute it and/or modify
1185 +  it under the terms of the GNU General Public License as published by
1186 +  the Free Software Foundation; either version 2 of the License, or
1187 +  (at your option) any later version.
1188 +    
1189 +  This example is distributed in the hope that it will be useful,
1190 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
1191 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1192 +  GNU General Public License for more details.
1193 +    
1194 +  To have a copy of the GNU General Public License write to the Free Software
1195 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1196 +*/
1197 +
1198 +#include <linux/module.h>
1199 +#include <linux/init.h>
1200 +#include <linux/module.h>
1201 +#include <linux/errno.h>
1202 +#include <linux/ioport.h>
1203 +#include <linux/version.h>
1204 +#include <linux/init.h>
1205 +#include <asm/uaccess.h>
1206 +#include <asm/io.h>
1207 +#include <linux/vmalloc.h>
1208 +#include <linux/ioport.h>  
1209 +#include <linux/init.h>
1210 +#include <linux/genhd.h>
1211 +
1212 +#define DEV_NAME                       "loopback"
1213 +#define DEV_MAJOR                      192
1214 +
1215 +#include "foxbone.h"
1216 +
1217 +unsigned char foxloopback_is_open = 0;
1218 +
1219 +
1220 +#define IOCTL_FOXBONE_LOOPBACK_SET             0x4045
1221 +#define IOCTL_FOXBONE_LOOPBACK_GET             0x4046
1222 +
1223 +// the app has send us some control data
1224 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
1225 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
1226 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
1227 +       int retval = 0;
1228 +       unsigned int current_io = 0;
1229 +       switch (cmd) {
1230 +               case IOCTL_FOXBONE_LOOPBACK_SET:
1231 +                       foxbone_write(0x0013, arg);
1232 +                       break;
1233 +               
1234 +               case IOCTL_FOXBONE_LOOPBACK_GET:
1235 +                       retval = foxbone_read(0x0013);
1236 +                       break;          
1237 +                       
1238 +               default:
1239 +                       printk("fox_loopback: unknown ioctl\n");
1240 +                       break;                  
1241 +       }
1242 +
1243 +       return retval;
1244 +};
1245 +
1246 +
1247 +
1248 +static int module_open(struct inode *inode, struct file *file){
1249 +       // Which minor device is the user trying to access ?
1250 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1251 +       
1252 +       // we only supprt minor 0 at the moment
1253 +       if(dev_minor !=  0){
1254 +               printk("fox_loopback: trying to access unknown minor device -> %d\n", dev_minor);
1255 +               return -ENODEV;
1256 +       }
1257 +       
1258 +       // check if another app is currently using the device
1259 +       if(foxloopback_is_open) {
1260 +               printk("fox_loopback: Device with minor ID %d already in use\n", dev_minor);
1261 +               return -EBUSY;
1262 +       }
1263 +       
1264 +       // more flaming
1265 +       printk("fox_loopback: Minor %d has been opened\n", dev_minor);
1266 +       return 0;
1267 +};
1268 +
1269 +
1270 +// gets called when an app closes the device
1271 +static int module_close(struct inode * inode, struct file * file){
1272 +       // Which minor device is the user trying to access ?
1273 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1274 +       
1275 +       // remember that the device has been closed
1276 +       foxloopback_is_open = 0;
1277 +       
1278 +       
1279 +       // more flaming
1280 +       printk("fox_loopback: Minor %d has been closed\n", dev_minor);
1281 +       
1282 +       return 0;
1283 +};
1284 +
1285 +// so the kernel knows which functions to access for a given operation
1286 +struct file_operations foxloopback_module_fops = {
1287 +        ioctl:         module_ioctl,
1288 +        open:          module_open,
1289 +        release:       module_close
1290 +};
1291 +
1292 +
1293 +// module gets loaded into kernel / char dev is registered
1294 +static int __init mod_init(void){
1295 +       // flame the kprintk
1296 +       printk("fox_loopback: FOX-VHDL FPGA io module\n");
1297 +       //printk("fox_loopback: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
1298 +       //printk("fox_loopback: Starting ...\n");
1299 +       
1300 +       // register the character device
1301 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxloopback_module_fops)) {
1302 +               printk( "fox_loopback: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
1303 +               return( -ENODEV );
1304 +       };
1305 +       
1306 +
1307 +       // remember that the driver has been opened
1308 +       foxloopback_is_open = 0;
1309 +       printk("fox_loopback: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
1310 +       return 0;
1311 +}
1312 +
1313 +
1314 +// we are done so shut everything down
1315 +static void __exit mod_exit(void){
1316 +       printk( "fox_loopback: Cleanup\n" );
1317 +       // tell the kernel that the device is not needed anymore
1318 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
1319 +       
1320 +}
1321 +
1322 +module_init (mod_init);
1323 +module_exit (mod_exit);
1324 +
1325 +
1326 +
1327 +
1328 +
1329 +
1330 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/Makefile
1331 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_loopback/Makefile  1970-01-01 01:00:00.000000000 +0100
1332 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_loopback/Makefile       2007-06-17 02:46:15.000000000 +0200
1333 @@ -0,0 +1 @@
1334 +obj-$(CONFIG_FOXBONE_LOOPBACK)          += fox_loopback.o
1335 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/foxbone.h
1336 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/foxbone.h 1970-01-01 01:00:00.000000000 +0100
1337 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/foxbone.h      2007-06-17 02:46:15.000000000 +0200
1338 @@ -0,0 +1,16 @@
1339 +// prototypes for foxbone compliant modules
1340 +
1341 +extern unsigned int FOXBONE_release;
1342 +extern unsigned int FOXBONE_application1;
1343 +extern unsigned int FOXBONE_application2;
1344 +extern unsigned int FOXBONE_application3;
1345 +
1346 +void foxbone_write(unsigned int add, unsigned int data);
1347 +
1348 +unsigned int foxbone_read(unsigned int add);
1349 +
1350 +void foxbone_write_next(unsigned data);
1351 +
1352 +unsigned int foxbone_read_next(void);
1353 +
1354 +void foxbone_initialise_bus(void);
1355 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/fox_multiply.c linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/fox_multiply.c
1356 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/fox_multiply.c    1970-01-01 01:00:00.000000000 +0100
1357 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/fox_multiply.c 2007-06-17 02:46:15.000000000 +0200
1358 @@ -0,0 +1,172 @@
1359 +/*  
1360 +  fox_multiply.c
1361 +  Linux Kernel Driver for FoxBone 32x32 fast multiplier on FOX VHDL Board 
1362 +  (based on FoxBone protocol interface specifications rel 0.7)    
1363 +  For more info see: http://www.acmesystems.it/?id=120
1364 +  Author: John Crispin
1365 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
1366 +  
1367 +  This is free software; you can redistribute it and/or modify
1368 +  it under the terms of the GNU General Public License as published by
1369 +  the Free Software Foundation; either version 2 of the License, or
1370 +  (at your option) any later version.
1371 +    
1372 +  This example is distributed in the hope that it will be useful,
1373 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
1374 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1375 +  GNU General Public License for more details.
1376 +    
1377 +  To have a copy of the GNU General Public License write to the Free Software
1378 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1379 +*/
1380 +
1381 +
1382 +#include <linux/module.h>
1383 +#include <linux/init.h>
1384 +#include <linux/module.h>
1385 +#include <linux/errno.h>
1386 +#include <linux/ioport.h>
1387 +#include <linux/version.h>
1388 +#include <linux/init.h>
1389 +#include <asm/uaccess.h>
1390 +#include <asm/io.h>
1391 +#include <linux/vmalloc.h>
1392 +#include <linux/ioport.h>  
1393 +#include <linux/init.h>
1394 +#include <linux/genhd.h>
1395 +
1396 +#define DEV_NAME                       "multiply"
1397 +#define DEV_MAJOR                      194
1398 +
1399 +#include "foxbone.h"
1400 +
1401 +unsigned char foxmultiply_is_open = 0;
1402 +
1403 +
1404 +#define IOCTL_FOXBONE_MUTIPLY          0x4945
1405 +
1406 +// the app has send us some control data
1407 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
1408 +       long data[3], i;
1409 +       int retval = 0;
1410 +       switch (cmd) {
1411 +               case IOCTL_FOXBONE_MUTIPLY:
1412 +                       copy_from_user((char*)&data[0], (char*)arg, sizeof(long)  * 3);
1413 +                       data[2] = jiffies;
1414 +                       printk("%ld, %ld\n", data[0], data[1]);
1415 +                       //for(i = 0; i < 1024*1024; i++){
1416 +                               foxbone_write(0x0021, (data[0]>>16)&0xffff);
1417 +                               foxbone_write(0x0020, data[0]&0xffff);
1418 +                               foxbone_write(0x0023, (data[1]>>16)&0xffff);
1419 +                               foxbone_write(0x0022, data[1]&0xffff);
1420 +                               data[0] = foxbone_read(0x0025);
1421 +                               data[0] = (data[0] << 16) + foxbone_read(0x0024);
1422 +                               data[1] = foxbone_read(0x0027);
1423 +                               data[1] = (data[1] << 16) + foxbone_read(0x0026);
1424 +                               /*printk("%4x\n", foxbone_read(0x0020));
1425 +                               printk("%4x\n", foxbone_read(0x0021));
1426 +                               printk("%4x\n", foxbone_read(0x0022));
1427 +                               printk("%4x\n", foxbone_read(0x0023));
1428 +                               
1429 +                               printk("%4x\n", foxbone_read(0x0024));
1430 +                               printk("%4x\n", foxbone_read(0x0025));
1431 +                               printk("%4x\n", foxbone_read(0x0026));
1432 +                               printk("%4x\n", foxbone_read(0x0027));
1433 +                               */              
1434 +                       //};
1435 +                       data[2] = jiffies - data[2];
1436 +                       copy_to_user((char*)arg, (char*)&data[0], sizeof(unsigned long) * 3);
1437 +                       break;
1438 +       
1439 +               default:
1440 +                       printk("fox_multiply: unknown ioctl\n");
1441 +                       break;                  
1442 +       }
1443 +
1444 +       return retval;
1445 +};
1446 +
1447 +
1448 +
1449 +static int module_open(struct inode *inode, struct file *file){
1450 +       // Which minor device is the user trying to access ?
1451 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1452 +       
1453 +       // we only supprt minor 0 at the moment
1454 +       if(dev_minor !=  0){
1455 +               printk("fox_multiply: trying to access unknown minor device -> %d\n", dev_minor);
1456 +               return -ENODEV;
1457 +       }
1458 +       
1459 +       // check if another app is currently using the device
1460 +       if(foxmultiply_is_open) {
1461 +               printk("fox_multiply: Device with minor ID %d already in use\n", dev_minor);
1462 +               return -EBUSY;
1463 +       }
1464 +       
1465 +       // more flaming
1466 +       //printk("fox_multiply: Minor %d has been opened\n", dev_minor);
1467 +       return 0;
1468 +};
1469 +
1470 +
1471 +// gets called when an app closes the device
1472 +static int module_close(struct inode * inode, struct file * file){
1473 +       // Which minor device is the user trying to access ?
1474 +       // unsigned int dev_minor = MINOR(inode->i_rdev);
1475 +       
1476 +       // remember that the device has been closed
1477 +       foxmultiply_is_open = 0;
1478 +       
1479 +       
1480 +       // more flaming
1481 +       //printk("fox_multiply: Minor %d has been closed\n", dev_minor);
1482 +       
1483 +       return 0;
1484 +};
1485 +
1486 +// so the kernel knows which functions to access for a given operation
1487 +struct file_operations foxmultiply_module_fops = {
1488 +        ioctl:         module_ioctl,
1489 +        open:          module_open,
1490 +        release:       module_close
1491 +};
1492 +
1493 +
1494 +// module gets loaded into kernel / char dev is registered
1495 +static int __init mod_init(void){
1496 +       // flame the kprintk
1497 +       printk("fox_multiply: FOX-VHDL FPGA multiplier module\n");
1498 +       //printk("fox_multiply: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
1499 +       //printk("fox_multiply: Starting ...\n");
1500 +       
1501 +       // register the character device
1502 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxmultiply_module_fops)) {
1503 +               printk( "fox_multiply: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
1504 +               return( -ENODEV );
1505 +       };
1506 +       
1507 +
1508 +       // remember that the driver has been opened
1509 +       foxmultiply_is_open = 0;
1510 +       printk("fox_multiply: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
1511 +       return 0;
1512 +}
1513 +
1514 +
1515 +// we are done so shut everything down
1516 +static void __exit mod_exit(void){
1517 +       printk( "fox_multiply: Cleanup\n" );
1518 +       // tell the kernel that the device is not needed anymore
1519 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
1520 +       
1521 +}
1522 +
1523 +module_init (mod_init);
1524 +module_exit (mod_exit);
1525 +
1526 +
1527 +
1528 +
1529 +
1530 +
1531 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/Makefile
1532 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_multiply/Makefile  1970-01-01 01:00:00.000000000 +0100
1533 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_multiply/Makefile       2007-06-17 02:46:15.000000000 +0200
1534 @@ -0,0 +1 @@
1535 +obj-$(CONFIG_FOXBONE_MULTIPLY)          += fox_multiply.o
1536 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/foxbone.h
1537 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/foxbone.h      1970-01-01 01:00:00.000000000 +0100
1538 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/foxbone.h   2007-06-17 02:46:15.000000000 +0200
1539 @@ -0,0 +1,16 @@
1540 +// prototypes for foxbone compliant modules
1541 +
1542 +extern unsigned int FOXBONE_release;
1543 +extern unsigned int FOXBONE_application1;
1544 +extern unsigned int FOXBONE_application2;
1545 +extern unsigned int FOXBONE_application3;
1546 +
1547 +void foxbone_write(unsigned int add, unsigned int data);
1548 +
1549 +unsigned int foxbone_read(unsigned int add);
1550 +
1551 +void foxbone_write_next(unsigned data);
1552 +
1553 +unsigned int foxbone_read_next(void);
1554 +
1555 +void foxbone_initialise_bus(void);
1556 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/fox_pwm.c linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/fox_pwm.c
1557 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/fox_pwm.c      1970-01-01 01:00:00.000000000 +0100
1558 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/fox_pwm.c   2007-06-17 02:46:15.000000000 +0200
1559 @@ -0,0 +1,180 @@
1560 +/*  
1561 +  fox_pwm.c
1562 +  Linux Kernel Driver for FoxBone 16 channel PWM generator on FOX VHDL Board 
1563 +  (based on FoxBone protocol interface specifications rel 0.7)    
1564 +  For more info see: http://www.acmesystems.it/?id=120
1565 +  Author: John Crispin
1566 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
1567 +  
1568 +  This is free software; you can redistribute it and/or modify
1569 +  it under the terms of the GNU General Public License as published by
1570 +  the Free Software Foundation; either version 2 of the License, or
1571 +  (at your option) any later version.
1572 +    
1573 +  This example is distributed in the hope that it will be useful,
1574 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
1575 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1576 +  GNU General Public License for more details.
1577 +    
1578 +  To have a copy of the GNU General Public License write to the Free Software
1579 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1580 +*/
1581 +
1582 +
1583 +#include <linux/module.h>
1584 +#include <linux/init.h>
1585 +#include <linux/module.h>
1586 +#include <linux/errno.h>
1587 +#include <linux/ioport.h>
1588 +#include <linux/version.h>
1589 +#include <linux/init.h>
1590 +#include <asm/uaccess.h>
1591 +#include <asm/io.h>
1592 +#include <linux/vmalloc.h>
1593 +#include <linux/ioport.h>  
1594 +#include <linux/init.h>
1595 +#include <linux/genhd.h>
1596 +
1597 +#define DEV_NAME                       "pwm"
1598 +#define DEV_MAJOR                      15
1599 +
1600 +#include "foxbone.h"
1601 +
1602 +unsigned char foxpwm_is_open = 0;
1603 +
1604 +
1605 +#define IOCTL_PWM_ENABLE       0x2310
1606 +#define IOCTL_PWM_DISABLE      0x2311
1607 +#define IOCTL_PWM_CHANNEL_BASE 0x2320
1608 +#define IOCTL_PWM_CHANNEL0     0x2320
1609 +#define IOCTL_PWM_CHANNEL1     0x2321
1610 +#define IOCTL_PWM_CHANNEL2     0x2322
1611 +#define IOCTL_PWM_CHANNEL3     0x2323
1612 +#define IOCTL_PWM_CHANNEL4     0x2324
1613 +#define IOCTL_PWM_CHANNEL5     0x2325
1614 +#define IOCTL_PWM_CHANNEL6     0x2326
1615 +#define IOCTL_PWM_CHANNEL7     0x2327
1616 +#define IOCTL_PWM_CHANNEL8     0x2328
1617 +#define IOCTL_PWM_CHANNEL9     0x2329
1618 +#define IOCTL_PWM_CHANNELA     0x232a
1619 +#define IOCTL_PWM_CHANNELB     0x232b
1620 +#define IOCTL_PWM_CHANNELC     0x232c
1621 +#define IOCTL_PWM_CHANNELD     0x232d
1622 +#define IOCTL_PWM_CHANNELE     0x232e
1623 +#define IOCTL_PWM_CHANNELF     0x232f
1624 +
1625 +
1626 +// the app has send us some control data
1627 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
1628 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
1629 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
1630 +       int retval = 0;
1631 +       unsigned int current_pwm;
1632 +       if((cmd >= IOCTL_PWM_CHANNEL0) && (cmd <= IOCTL_PWM_CHANNELF)){
1633 +               foxbone_write(0x0050 + (cmd - IOCTL_PWM_CHANNEL_BASE), arg);
1634 +       } else {
1635 +               switch (cmd) {
1636 +                       case IOCTL_PWM_ENABLE:
1637 +                               current_pwm = foxbone_read(0x0060);
1638 +                               current_pwm |= (1<<arg);
1639 +                               foxbone_write(0x0060, current_pwm);
1640 +                               break;
1641 +                       
1642 +                       case IOCTL_PWM_DISABLE:
1643 +                               current_pwm = foxbone_read(0x0060);
1644 +                               current_pwm &= ~(1<<arg);
1645 +                               foxbone_write(0x0060, current_pwm);
1646 +                               break;
1647 +                       
1648 +                       default:
1649 +                               printk("fox_pwm: unknown ioctl\n");
1650 +                               break;                  
1651 +               }
1652 +       };
1653 +       return retval;
1654 +};
1655 +
1656 +
1657 +
1658 +static int module_open(struct inode *inode, struct file *file){
1659 +       // Which minor device is the user trying to access ?
1660 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1661 +       
1662 +       // we only supprt minor 0 at the moment
1663 +       if(dev_minor !=  0){
1664 +               printk("fox_pwm: trying to access unknown minor device -> %d\n", dev_minor);
1665 +               return -ENODEV;
1666 +       }
1667 +       
1668 +       // check if another app is currently using the device
1669 +       if(foxpwm_is_open) {
1670 +               printk("fox_pwm: Device with minor ID %d already in use\n", dev_minor);
1671 +               return -EBUSY;
1672 +       }
1673 +       
1674 +       // more flaming
1675 +       printk("fox_pwm: Minor %d has been opened\n", dev_minor);
1676 +       return 0;
1677 +};
1678 +
1679 +
1680 +// gets called when an app closes the device
1681 +static int module_close(struct inode * inode, struct file * file){
1682 +       // Which minor device is the user trying to access ?
1683 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1684 +       
1685 +       // remember that the device has been closed
1686 +       foxpwm_is_open = 0;
1687 +       
1688 +       
1689 +       // more flaming
1690 +       printk("fox_pwm: Minor %d has been closed\n", dev_minor);
1691 +       
1692 +       return 0;
1693 +};
1694 +
1695 +// so the kernel knows which functions to access for a given operation
1696 +struct file_operations foxpwm_module_fops = {
1697 +        ioctl:         module_ioctl,
1698 +        open:          module_open,
1699 +        release:       module_close
1700 +};
1701 +
1702 +
1703 +// module gets loaded into kernel / char dev is registered
1704 +static int __init mod_init(void){
1705 +       // flame the kprintk
1706 +       printk("fox_pwm: FOX-VHDL FPGA PWM module\n");
1707 +       //printk("fox_pwm: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
1708 +       //printk("fox_pwm: Starting ...\n");
1709 +       
1710 +       // register the character device
1711 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxpwm_module_fops)) {
1712 +               printk( "fox_pwm: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
1713 +               return( -ENODEV );
1714 +       };
1715 +       
1716 +
1717 +       // remember that the driver has been opened
1718 +       foxpwm_is_open = 0;
1719 +       printk("fox_pwm: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
1720 +       return 0;
1721 +}
1722 +
1723 +
1724 +// we are done so shut everything down
1725 +static void __exit mod_exit(void){
1726 +       printk( "fox_pwm: Cleanup\n" );
1727 +       // tell the kernel that the device is not needed anymore
1728 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
1729 +       
1730 +}
1731 +
1732 +module_init (mod_init);
1733 +module_exit (mod_exit);
1734 +
1735 +
1736 +
1737 +
1738 +
1739 +
1740 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/Makefile
1741 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_pwm/Makefile       1970-01-01 01:00:00.000000000 +0100
1742 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_pwm/Makefile    2007-06-17 02:46:15.000000000 +0200
1743 @@ -0,0 +1 @@
1744 +obj-$(CONFIG_FOXBONE_PWM)          += fox_pwm.o
1745 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/foxbone.h
1746 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/foxbone.h 1970-01-01 01:00:00.000000000 +0100
1747 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/foxbone.h      2007-06-17 02:46:15.000000000 +0200
1748 @@ -0,0 +1,16 @@
1749 +// prototypes for foxbone compliant modules
1750 +
1751 +extern unsigned int FOXBONE_release;
1752 +extern unsigned int FOXBONE_application1;
1753 +extern unsigned int FOXBONE_application2;
1754 +extern unsigned int FOXBONE_application3;
1755 +
1756 +void foxbone_write(unsigned int add, unsigned int data);
1757 +
1758 +unsigned int foxbone_read(unsigned int add);
1759 +
1760 +void foxbone_write_next(unsigned data);
1761 +
1762 +unsigned int foxbone_read_next(void);
1763 +
1764 +void foxbone_initialise_bus(void);
1765 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/fox_timebase.c linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/fox_timebase.c
1766 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/fox_timebase.c    1970-01-01 01:00:00.000000000 +0100
1767 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/fox_timebase.c 2007-06-17 02:46:15.000000000 +0200
1768 @@ -0,0 +1,168 @@
1769 +/*  
1770 +  fox_timebase.c
1771 +  Linux Kernel Driver for FoxBone TimeBase on FOX VHDL Board 
1772 +  (based on FoxBone protocol interface specifications rel 0.7)    
1773 +  For more info see: http://www.acmesystems.it/?id=120
1774 +  Author: John Crispin
1775 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
1776 +  
1777 +  This is free software; you can redistribute it and/or modify
1778 +  it under the terms of the GNU General Public License as published by
1779 +  the Free Software Foundation; either version 2 of the License, or
1780 +  (at your option) any later version.
1781 +    
1782 +  This example is distributed in the hope that it will be useful,
1783 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
1784 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1785 +  GNU General Public License for more details.
1786 +    
1787 +  To have a copy of the GNU General Public License write to the Free Software
1788 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1789 +*/
1790 +
1791 +
1792 +#include <linux/module.h>
1793 +#include <linux/init.h>
1794 +#include <linux/module.h>
1795 +#include <linux/errno.h>
1796 +#include <linux/ioport.h>
1797 +#include <linux/version.h>
1798 +#include <linux/init.h>
1799 +#include <asm/uaccess.h>
1800 +#include <asm/io.h>
1801 +#include <linux/vmalloc.h>
1802 +#include <linux/ioport.h>  
1803 +#include <linux/init.h>
1804 +#include <linux/genhd.h>
1805 +
1806 +#define DEV_NAME                       "timebase"
1807 +#define DEV_MAJOR                      191
1808 +
1809 +#include "foxbone.h"
1810 +
1811 +unsigned char foxtimebase_is_open = 0;
1812 +
1813 +
1814 +#define IOCTL_FOXBONE_TIMEBASE_ENABLE          0x4645
1815 +#define IOCTL_FOXBONE_TIMEBASE_DISABLE         0x4646
1816 +#define IOCTL_FOXBONE_TIMEBASE_SETLO           0x4647
1817 +#define IOCTL_FOXBONE_TIMEBASE_SETHI           0x4648
1818 +
1819 +// the app has send us some control data
1820 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
1821 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
1822 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
1823 +       int retval = 0;
1824 +       switch (cmd) {
1825 +               case IOCTL_FOXBONE_TIMEBASE_ENABLE:
1826 +                       foxbone_write(0x0100, 0x01);
1827 +                       break;
1828 +                       
1829 +               case IOCTL_FOXBONE_TIMEBASE_DISABLE:
1830 +                       foxbone_write(0x0100, 0x00);
1831 +                       break;
1832 +       
1833 +               case IOCTL_FOXBONE_TIMEBASE_SETLO:
1834 +                       foxbone_write(0x0100, 0x00);
1835 +                       foxbone_write(0x0102, arg);
1836 +                       foxbone_write(0x0100, 0x01);
1837 +                       break;
1838 +                       
1839 +               case IOCTL_FOXBONE_TIMEBASE_SETHI:
1840 +                       foxbone_write(0x0100, 0x00);
1841 +                       foxbone_write(0x0103, arg);
1842 +                       foxbone_write(0x0100, 0x01);
1843 +                       break;
1844 +                       
1845 +               default:
1846 +                       printk("fox_timebase: unknown ioctl\n");
1847 +                       break;                  
1848 +       }
1849 +
1850 +       return retval;
1851 +};
1852 +
1853 +
1854 +
1855 +static int module_open(struct inode *inode, struct file *file){
1856 +       // Which minor device is the user trying to access ?
1857 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1858 +       
1859 +       // we only supprt minor 0 at the moment
1860 +       if(dev_minor !=  0){
1861 +               printk("fox_timebase: trying to access unknown minor device -> %d\n", dev_minor);
1862 +               return -ENODEV;
1863 +       }
1864 +       
1865 +       // check if another app is currently using the device
1866 +       if(foxtimebase_is_open) {
1867 +               printk("fox_timebase: Device with minor ID %d already in use\n", dev_minor);
1868 +               return -EBUSY;
1869 +       }
1870 +       
1871 +       // more flaming
1872 +       printk("fox_timebase: Minor %d has been opened\n", dev_minor);
1873 +       return 0;
1874 +};
1875 +
1876 +
1877 +// gets called when an app closes the device
1878 +static int module_close(struct inode * inode, struct file * file){
1879 +       // Which minor device is the user trying to access ?
1880 +       unsigned int dev_minor = MINOR(inode->i_rdev);
1881 +       
1882 +       // remember that the device has been closed
1883 +       foxtimebase_is_open = 0;
1884 +       
1885 +       
1886 +       // more flaming
1887 +       printk("fox_timebase: Minor %d has been closed\n", dev_minor);
1888 +       
1889 +       return 0;
1890 +};
1891 +
1892 +// so the kernel knows which functions to access for a given operation
1893 +struct file_operations foxtimebase_module_fops = {
1894 +        ioctl:         module_ioctl,
1895 +        open:          module_open,
1896 +        release:       module_close
1897 +};
1898 +
1899 +
1900 +// module gets loaded into kernel / char dev is registered
1901 +static int __init mod_init(void){
1902 +       // flame the kprintk
1903 +       printk("fox_timebase: FOX-VHDL FPGA timebase module\n");
1904 +       //printk("fox_timebase: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
1905 +       //printk("fox_timebase: Starting ...\n");
1906 +       
1907 +       // register the character device
1908 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &foxtimebase_module_fops)) {
1909 +               printk( "fox_timebase: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
1910 +               return( -ENODEV );
1911 +       };
1912 +       
1913 +
1914 +       // remember that the driver has been opened
1915 +       foxtimebase_is_open = 0;
1916 +       printk("fox_timebase: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
1917 +       return 0;
1918 +}
1919 +
1920 +
1921 +// we are done so shut everything down
1922 +static void __exit mod_exit(void){
1923 +       printk( "fox_timebase: Cleanup\n" );
1924 +       // tell the kernel that the device is not needed anymore
1925 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
1926 +       
1927 +}
1928 +
1929 +module_init (mod_init);
1930 +module_exit (mod_exit);
1931 +
1932 +
1933 +
1934 +
1935 +
1936 +
1937 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/Makefile
1938 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_timebase/Makefile  1970-01-01 01:00:00.000000000 +0100
1939 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_timebase/Makefile       2007-06-17 02:46:15.000000000 +0200
1940 @@ -0,0 +1 @@
1941 +obj-$(CONFIG_FOXBONE_TIMEBASE)          += fox_timebase.o
1942 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/fb.bak linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/fb.bak
1943 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/fb.bak     1970-01-01 01:00:00.000000000 +0100
1944 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/fb.bak  2007-06-17 02:46:15.000000000 +0200
1945 @@ -0,0 +1,661 @@
1946 +#include <linux/module.h>
1947 +#include <linux/kernel.h>
1948 +#include <linux/errno.h>
1949 +#include <linux/string.h>
1950 +#include <linux/mm.h>
1951 +#include <linux/tty.h>
1952 +#include <linux/slab.h>
1953 +#include <linux/vmalloc.h>
1954 +#include <linux/delay.h>
1955 +#include <linux/interrupt.h>
1956 +#include <linux/platform_device.h>
1957 +
1958 +#include <asm/uaccess.h>
1959 +#include <linux/fb.h>
1960 +#include <linux/init.h>
1961 +
1962 +#include "foxbone.h"
1963 +
1964 +
1965 +#if 0
1966 +#define DBG(x) x
1967 +#else
1968 +#define DBG(x) 
1969 +#endif
1970 +
1971 +
1972 +
1973 +// software delay
1974 +void FOXVHDL_delay(int ms) {
1975 +       int i,a;
1976 +       int delayvar=10;
1977 +       
1978 +       for (a=0;a<ms;a++) {
1979 +               for (i=0;i<35;i++) {
1980 +                       delayvar*=2;        
1981 +                       delayvar/=2;
1982 +               } 
1983 +       }
1984 +}  
1985 +
1986 +
1987 +
1988 +/*
1989 +||
1990 +||     FOXVHDL CTL functions
1991 +||
1992 +*/
1993 +
1994 +
1995 +static unsigned char FOXVHDL_current_bank = 0xff;
1996 +
1997 +static unsigned char blitting = 1;
1998 +
1999 +static unsigned char refreshrate = 6;
2000 +
2001 +
2002 +
2003 +unsigned int FOXVHDL_translate_BGR(unsigned char blue, unsigned char green, unsigned char red) {
2004 +       // translate the three color passed in a single 16 bit color word
2005 +       unsigned int result = ((blue>>3)<<11) | ((green>>2)<<5) | (red>>3);
2006 +       return result;
2007 +}
2008 +
2009 +
2010 +
2011 +
2012 +// wait until the videostate pin has the wanted value
2013 +void FOXVHDL_wait_videostate(unsigned char wait_state){
2014 +/*     unsigned char vid_state = 0;
2015 +       unsigned int max_error = 0xffff;
2016 +       //printk("Start wait\n");
2017 +       do {
2018 +               vid_state = FOXVHDL_get_bit_B(Fox_line_VideoState);
2019 +               max_error--;
2020 +       } while((vid_state != wait_state)&&(max_error > 10));
2021 +       */
2022 +       DBG(if(max_error < 11){printk("Stop wait\n");};)
2023 +};
2024 +       
2025 +
2026 +// choose the bank that we want to display
2027 +// OG5 == 0 --> Bank0
2028 +// OG5 == 1 --> Bank1
2029 +void FOXVHDL_set_bank(unsigned char bank){
2030 +       DBG(printk("%d, %d\n",FOXVHDL_current_bank, bank);)
2031 +       if(FOXVHDL_current_bank == bank){
2032 +               return;
2033 +       };
2034 +       
2035 +       DBG(printk("FOXVHDL_set_bank\n");)
2036 +       
2037 +       FOXVHDL_current_bank = bank;
2038 +       foxbone_write(0x7001, FOXVHDL_current_bank);    
2039 +       
2040 +       
2041 +};
2042 +
2043 +
2044 +// blit the bank
2045 +void FOXVHDL_swap_bank(void){
2046 +       FOXVHDL_set_bank((FOXVHDL_current_bank)?(0):(1));       
2047 +};
2048 +
2049 +
2050 +// initialise the I/O pins
2051 +void FOXVHDL_init(void){
2052 +       DBG(printk("FOXVHDL_init\n");)
2053 +       
2054 +       FOXVHDL_current_bank = 0;
2055 +       
2056 +       FOXVHDL_set_bank(1);
2057 +       
2058 +};
2059 +
2060 +/*
2061 +||
2062 +||     FOXVHDL IMAGE FUNCTIONS
2063 +||
2064 +*/
2065 +#define Fox_line_WriteData        (1<<2)
2066 +
2067 +void FOXVHDL_blit(unsigned short int *image){
2068 +       unsigned long i;
2069 +       unsigned int fb_ctl_reg;
2070 +       
2071 +       if(blitting){
2072 +               // reset the address pointer
2073 +               fb_ctl_reg = foxbone_read(0x7001);
2074 +               fb_ctl_reg |= (1<<4);
2075 +               foxbone_write(0x7001, fb_ctl_reg);
2076 +               fb_ctl_reg &= ~(1<<4);
2077 +               foxbone_write(0x7001, fb_ctl_reg);
2078 +                                
2079 +               foxbone_write(0x7000, image[0]);
2080 +               genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g8_15dir);
2081 +               *R_GEN_CONFIG = genconfig_shadow;
2082 +               genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g16_23dir);
2083 +               *R_GEN_CONFIG = genconfig_shadow;       
2084 +
2085 +               for(i = 1; i < 640 * 400; i++){
2086 +
2087 +                       *R_PORT_G_DATA = port_g_data_shadow = 
2088 +                                               (port_g_data_shadow & 0xff0000ff) | image[i]<<8;
2089 +                       *R_PORT_G_DATA = port_g_data_shadow |= Fox_line_WriteData;
2090 +                       *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteData;
2091 +               };
2092 +               for(i = 0; i <6144; i++){
2093 +                       foxbone_write_next(0);
2094 +               };
2095 +               FOXVHDL_swap_bank();
2096 +       };
2097 +};
2098 +
2099 +
2100 +
2101 +
2102 +
2103 +
2104 +/*
2105 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2106 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2107 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2108 +||
2109 +||                                                                             FRAMEBUFFER CODE
2110 +||
2111 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2112 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2113 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2114 +
2115 +*/
2116 +
2117 +
2118 +
2119 +
2120 +#define VIDEOMEMSIZE   (640 * 400 * 2) //512K
2121 +
2122 +static void *videomemory;
2123 +static u_long videomemorysize = VIDEOMEMSIZE;
2124 +
2125 +static unsigned char fb_started = 0;
2126 +
2127 +static struct fb_var_screeninfo foxfb_default __initdata = {
2128 +       .xres =         640,
2129 +       .yres =         400,
2130 +       .xres_virtual = 640,
2131 +       .yres_virtual = 400,
2132 +       .bits_per_pixel = 16,
2133 +       .red =          { 0, 5, 0 },
2134 +       .green =        { 5, 6, 0 },
2135 +       .blue =         { 11, 5, 0 },
2136 +       .activate =     FB_ACTIVATE_NOW,
2137 +       .height =       -1,
2138 +       .width =        -1,
2139 +       .vmode =        FB_VMODE_NONINTERLACED,
2140 +};
2141 +
2142 +static struct fb_fix_screeninfo foxfb_fix __initdata = {
2143 +       .id =           "FOX-VHDL FB",
2144 +       .type =         FB_TYPE_PACKED_PIXELS,
2145 +       .visual =       FB_VISUAL_TRUECOLOR,
2146 +       .xpanstep =     1,
2147 +       .ypanstep =     1,
2148 +       .ywrapstep =    1,
2149 +       .accel =        FB_ACCEL_NONE,
2150 +};
2151 +
2152 +static int foxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
2153 +static int foxfb_set_par(struct fb_info *info);
2154 +static int foxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info);
2155 +static int foxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
2156 +static int foxfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
2157 +static void foxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
2158 +static void foxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
2159 +static void foxfb_imageblit(struct fb_info *info, const struct fb_image *image);
2160 +
2161 +static int foxfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
2162 +
2163 +static struct fb_ops foxfb_ops = {
2164 +       .fb_check_var   = foxfb_check_var,
2165 +       .fb_set_par             = foxfb_set_par,
2166 +       .fb_setcolreg   = foxfb_setcolreg,
2167 +
2168 +       .fb_pan_display = foxfb_pan_display,
2169 +       .fb_fillrect    = foxfb_fillrect, //cfb_fillrect,
2170 +       .fb_copyarea    = foxfb_copyarea, //cfb_copyarea,
2171 +       .fb_imageblit   = foxfb_imageblit,//cfb_imageblit,
2172 +       .fb_mmap                = foxfb_mmap,
2173 +       .fb_ioctl               = foxfb_ioctl,
2174 +};
2175 +
2176 +// this function is defined in fbmem.c
2177 +extern int fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
2178 +
2179 +// this should be a free one
2180 +#define FOX_FBIOGET_SCREEN     0x4642
2181 +#define FOX_FBBLIT             0x4643
2182 +#define FOX_FB_RATE            0x4645
2183 +#define FOX_FB_TFT             0x4646
2184 +static int foxfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){
2185 +       void __user *argp = (void __user *)arg;
2186 +       unsigned int fb_ctl_reg;
2187 +       switch(cmd){
2188 +               // this assumes that arg points to a VIDEOMEMSIZE area of memory in user space
2189 +               case FOX_FBIOGET_SCREEN:
2190 +                       if(copy_to_user(argp, videomemory, VIDEOMEMSIZE)){
2191 +                               return 0;
2192 +                       } else {
2193 +                               return -1;
2194 +                       };
2195 +               case FOX_FBBLIT:
2196 +                       fb_ctl_reg = foxbone_read(0x7001);
2197 +                       if(arg){
2198 +                               printk("Enable FB\n");
2199 +                               fb_ctl_reg &= ~(1<<1);
2200 +                       } else {
2201 +                               printk("Disable FB\n");
2202 +                               fb_ctl_reg |= (1<<1);
2203 +                       };              
2204 +                       blitting = arg;
2205 +                       foxbone_write(0x7001, fb_ctl_reg);
2206 +                       break;
2207 +               case FOX_FB_RATE:
2208 +                       if((arg > 9) || (arg < 1)){
2209 +                               printk("fb0 : Illegal refreshrate\n");
2210 +                               break;
2211 +                       };
2212 +                       refreshrate = arg;
2213 +                       printk("fb0 : new refreshrate\n");
2214 +                       break;
2215 +               case FOX_FB_TFT:
2216 +                       fb_ctl_reg = foxbone_read(0x7001);
2217 +                       if(arg){
2218 +                               printk("Enable TFT\n");
2219 +                               fb_ctl_reg |= (1<<3);
2220 +                       } else {
2221 +                               printk("Disable TFT\n");
2222 +                               fb_ctl_reg &= ~(1<<3);
2223 +                       };
2224 +                       foxbone_write(0x7001, fb_ctl_reg);
2225 +                       break;
2226 +               default:
2227 +                       return fb_ioctl(inode, file, cmd, arg);         
2228 +       };
2229 +       return 0;
2230 +};
2231 +
2232 +// TODO add our own optimized code here
2233 +static void foxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect){
2234 +       cfb_fillrect(info, rect);
2235 +};
2236 +
2237 +
2238 +// TODO add our own optimized code here
2239 +static void foxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area){
2240 +       cfb_copyarea(info, area);
2241 +};
2242 +
2243 +// TODO add our own optimized code here
2244 +static void foxfb_imageblit(struct fb_info *info, const struct fb_image *image){
2245 +       cfb_imageblit(info, image);
2246 +};
2247 +
2248 +
2249 +/*
2250 + *  Internal routines
2251 + */
2252 +
2253 +static u_long get_line_length(int xres_virtual, int bpp)
2254 +{
2255 +       u_long length;
2256 +
2257 +       length = xres_virtual * bpp;
2258 +       length = (length + 31) & ~31;
2259 +       length >>= 3;
2260 +       return (length);
2261 +}
2262 +
2263 +    /*
2264 +     *  Setting the video mode has been split into two parts.
2265 +     *  First part, xxxfb_check_var, must not write anything
2266 +     *  to hardware, it should only verify and adjust var.
2267 +     *  This means it doesn't alter par but it does use hardware
2268 +     *  data from it to check this var. 
2269 +     */
2270 +
2271 +static int foxfb_check_var(struct fb_var_screeninfo *var,
2272 +                        struct fb_info *info)
2273 +{
2274 +       u_long line_length;
2275 +
2276 +       if (var->vmode & FB_VMODE_CONUPDATE) {
2277 +               var->vmode |= FB_VMODE_YWRAP;
2278 +               var->xoffset = info->var.xoffset;
2279 +               var->yoffset = info->var.yoffset;
2280 +       }
2281 +
2282 +       var->xres = 640;
2283 +       var->yres = 400;
2284 +       
2285 +       var->bits_per_pixel = 16;
2286 +       
2287 +       if (var->xres_virtual < var->xoffset + var->xres)
2288 +               var->xres_virtual = var->xoffset + var->xres;
2289 +       if (var->yres_virtual < var->yoffset + var->yres)
2290 +               var->yres_virtual = var->yoffset + var->yres;
2291 +
2292 +       line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
2293 +       if (line_length * var->yres_virtual > videomemorysize)
2294 +               return -ENOMEM;
2295 +
2296 +       var->red.offset = 0;
2297 +       var->red.length = 5;
2298 +       var->green.offset = 5;
2299 +       var->green.length = 6;
2300 +       var->blue.offset = 11;
2301 +       var->blue.length = 5;
2302 +       var->transp.offset = 0;
2303 +       var->transp.length = 0;
2304 +       var->red.msb_right = 0;
2305 +       var->green.msb_right = 0;
2306 +       var->blue.msb_right = 0;
2307 +       var->transp.msb_right = 0;
2308 +
2309 +       return 0;
2310 +}
2311 +
2312 +
2313 +
2314 +/* This routine actually sets the video mode. It's in here where we
2315 + * the hardware state info->par and fix which can be affected by the 
2316 + * change in par. For this driver it doesn't do much. 
2317 + */
2318 +static int foxfb_set_par(struct fb_info *info){
2319 +       info->fix.line_length = get_line_length(info->var.xres_virtual, info->var.bits_per_pixel);
2320 +       return 0;
2321 +}
2322 +
2323 +/*
2324 + *  Set a single color register. The values supplied are already
2325 + *  rounded down to the hardware's capabilities (according to the
2326 + *  entries in the var structure). Return != 0 for invalid regno.
2327 + */
2328 +
2329 +
2330 +static int foxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info){
2331 +       if (regno >= 256)       /* no. of hw registers */
2332 +               return 1;
2333 +
2334 +       /* grayscale works only partially under directcolor */
2335 +       if (info->var.grayscale) {
2336 +               /* grayscale = 0.30*R + 0.59*G + 0.11*B */
2337 +               red = green = blue =
2338 +                   (red * 77 + green * 151 + blue * 28) >> 8;
2339 +       }
2340 +
2341 +       /* Directcolor:
2342 +        *   var->{color}.offset contains start of bitfield
2343 +        *   var->{color}.length contains length of bitfield
2344 +        *   {hardwarespecific} contains width of RAMDAC
2345 +        *   cmap[X] is programmed to (X << red.offset) | (X << green.offset) | (X << blue.offset)
2346 +        *   RAMDAC[X] is programmed to (red, green, blue)
2347 +        * 
2348 +        * Pseudocolor:
2349 +        *    uses offset = 0 && length = RAMDAC register width.
2350 +        *    var->{color}.offset is 0
2351 +        *    var->{color}.length contains widht of DAC
2352 +        *    cmap is not used
2353 +        *    RAMDAC[X] is programmed to (red, green, blue)
2354 +        * Truecolor:
2355 +        *    does not use DAC. Usually 3 are present.
2356 +        *    var->{color}.offset contains start of bitfield
2357 +        *    var->{color}.length contains length of bitfield
2358 +        *    cmap is programmed to (red << red.offset) | (green << green.offset) |
2359 +        *                      (blue << blue.offset) | (transp << transp.offset)
2360 +        *    RAMDAC does not exist
2361 +        */
2362 +#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
2363 +       switch (info->fix.visual) {
2364 +       case FB_VISUAL_TRUECOLOR:
2365 +       case FB_VISUAL_PSEUDOCOLOR:
2366 +               red = CNVT_TOHW(red, info->var.red.length);
2367 +               green = CNVT_TOHW(green, info->var.green.length);
2368 +               blue = CNVT_TOHW(blue, info->var.blue.length);
2369 +               transp = CNVT_TOHW(transp, info->var.transp.length);
2370 +               break;
2371 +       case FB_VISUAL_DIRECTCOLOR:
2372 +               red = CNVT_TOHW(red, 8);        /* expect 8 bit DAC */
2373 +               green = CNVT_TOHW(green, 8);
2374 +               blue = CNVT_TOHW(blue, 8);
2375 +               /* hey, there is bug in transp handling... */
2376 +               transp = CNVT_TOHW(transp, 8);
2377 +               break;
2378 +       }
2379 +#undef CNVT_TOHW
2380 +       /* Truecolor has hardware independent palette */
2381 +       if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
2382 +               u32 v;
2383 +
2384 +               if (regno >= 16)
2385 +                       return 1;
2386 +
2387 +               v = (red << info->var.red.offset) |
2388 +                   (green << info->var.green.offset) |
2389 +                   (blue << info->var.blue.offset) |
2390 +                   (transp << info->var.transp.offset);
2391 +               switch (info->var.bits_per_pixel) {
2392 +               case 8:
2393 +                       break;
2394 +               case 16:
2395 +                       ((u32 *) (info->pseudo_palette))[regno] = v;
2396 +                       break;
2397 +               case 24:
2398 +               case 32:
2399 +                       ((u32 *) (info->pseudo_palette))[regno] = v;
2400 +                       break;
2401 +               }
2402 +               return 0;
2403 +       }
2404 +       return 0;
2405 +}
2406 +
2407 +    /*
2408 +     *  Pan or Wrap the Display
2409 +     *
2410 +     *  This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
2411 +     */
2412 +
2413 +static int foxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info){
2414 +       if (var->vmode & FB_VMODE_YWRAP) {
2415 +               if (var->yoffset < 0
2416 +                   || var->yoffset >= info->var.yres_virtual
2417 +                   || var->xoffset)
2418 +                       return -EINVAL;
2419 +       } else {
2420 +               if (var->xoffset + var->xres > info->var.xres_virtual ||
2421 +                   var->yoffset + var->yres > info->var.yres_virtual)
2422 +                       return -EINVAL;
2423 +       }
2424 +       info->var.xoffset = var->xoffset;
2425 +       info->var.yoffset = var->yoffset;
2426 +       if (var->vmode & FB_VMODE_YWRAP)
2427 +               info->var.vmode |= FB_VMODE_YWRAP;
2428 +       else
2429 +               info->var.vmode &= ~FB_VMODE_YWRAP;
2430 +       return 0;
2431 +}
2432 +
2433 +/*
2434 + *  Most drivers don't need their own mmap function 
2435 + */
2436 +
2437 +static int foxfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma){
2438 +        unsigned long page, pos;
2439 +        unsigned long start = vma->vm_start;
2440 +        unsigned long size  = vma->vm_end-vma->vm_start;
2441 +        printk("mmap : %ld %ld\n", size, info->fix.smem_len);
2442 +       //if (size > info->fix.smem_len){
2443 +        //       return -EINVAL;
2444 +       //}
2445 +        printk("MMAP2\n");
2446 +       pos = (unsigned long) info->screen_base;
2447 +        while (size > 0) {
2448 +                page = page_to_pfn(vmalloc_to_page((void *)pos));
2449 +               if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
2450 +                       return -EAGAIN;
2451 +               start += PAGE_SIZE;
2452 +               pos += PAGE_SIZE;
2453 +               if (size > PAGE_SIZE)
2454 +                       size -= PAGE_SIZE;
2455 +               else
2456 +                       size = 0;
2457 +        }
2458 +        return 0;
2459 +}
2460 +
2461 +
2462 +
2463 +
2464 +
2465 +// our timer
2466 +struct timer_list foxfb_timer;
2467 +
2468 +
2469 +// the prototype for the callback
2470 +static void foxfb_timer_callback(unsigned long ptr);
2471 +
2472 +
2473 +// setup the mmc timer
2474 +static void foxfb_timer_setup(void){
2475 +       init_timer(&foxfb_timer);
2476 +       foxfb_timer.function = foxfb_timer_callback;
2477 +       foxfb_timer.data = 0;
2478 +       foxfb_timer.expires = jiffies + ( HZ / refreshrate);
2479 +       add_timer(&foxfb_timer);        
2480 +};
2481 +
2482 +
2483 +// the timer callback function that detects if the card status has changed
2484 +static void foxfb_timer_callback(unsigned long ptr){
2485 +       del_timer(&foxfb_timer);
2486 +       FOXVHDL_blit(videomemory);
2487 +       foxfb_timer_setup();
2488 +};
2489 +
2490 +
2491 +static void foxfb_platform_release(struct device *device){
2492 +       // This is called when the reference count goes to zero.
2493 +}
2494 +
2495 +
2496 +static int __init foxfb_probe(struct platform_device *dev){
2497 +       struct fb_info *info;
2498 +       int retval = -ENOMEM;
2499 +
2500 +       if (!(videomemory = vmalloc(videomemorysize)))
2501 +               return retval;
2502 +               
2503 +       memset(videomemory, 0, videomemorysize);
2504 +
2505 +       info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
2506 +       if (!info)
2507 +               goto err;
2508 +
2509 +       info->screen_base = (char*)videomemory;
2510 +       info->fbops = &foxfb_ops;
2511 +       info->fix.smem_len = videomemorysize;
2512 +       retval = fb_find_mode(&info->var, info, NULL,
2513 +                             NULL, 0, NULL, 8);
2514 +
2515 +       if (!retval || (retval == 4))
2516 +               info->var = foxfb_default;
2517 +
2518 +       info->fix = foxfb_fix;
2519 +       info->pseudo_palette = info->par;
2520 +       info->par = NULL;
2521 +       info->flags = FBINFO_FLAG_DEFAULT;
2522 +
2523 +       retval = fb_alloc_cmap(&info->cmap, 256, 0);
2524 +       if (retval < 0)
2525 +               goto err1;
2526 +
2527 +       retval = register_framebuffer(info);
2528 +       if (retval < 0)
2529 +               goto err2;
2530 +       platform_set_drvdata(dev, info);
2531 +
2532 +       printk(KERN_INFO
2533 +              "fb%d: FOX-VHDL frame buffer device, using %ldK of video memory\n",
2534 +              info->node, videomemorysize >> 10);
2535 +       
2536 +       
2537 +       //FOXVHDL_blit(videomemory);  
2538 +       foxfb_timer_setup();
2539 +       return 0;
2540 +err2:
2541 +       fb_dealloc_cmap(&info->cmap);
2542 +err1:
2543 +       framebuffer_release(info);
2544 +err:
2545 +       vfree(videomemory);
2546 +       return retval;
2547 +}
2548 +
2549 +static int foxfb_remove(struct platform_device *dev)
2550 +{
2551 +       struct fb_info *info = platform_get_drvdata(dev);
2552 +
2553 +       if (info) {
2554 +               unregister_framebuffer(info);
2555 +               vfree(videomemory);
2556 +               framebuffer_release(info);
2557 +       }
2558 +       return 0;
2559 +}
2560 +
2561 +static struct platform_driver foxfb_driver = {
2562 +       .probe  = foxfb_probe,
2563 +       .remove = foxfb_remove,
2564 +       .driver = {
2565 +               .name   = "foxfb",
2566 +       },
2567 +};
2568 +
2569 +static struct platform_device foxfb_device = {
2570 +       .name   = "foxfb",
2571 +       .id     = 0,
2572 +       .dev    = {
2573 +               .release = foxfb_platform_release,
2574 +       }
2575 +};
2576 +
2577 +static int __init foxfb_init(void)
2578 +{
2579 +       int ret = 0;
2580 +       refreshrate = 8;
2581 +       printk(KERN_INFO "fb: Initialising framebuffer\n");
2582 +       
2583 +       FOXVHDL_init();
2584 +
2585 +       ret = platform_driver_register(&foxfb_driver);
2586 +
2587 +       if (!ret) {
2588 +               ret = platform_device_register(&foxfb_device);
2589 +               if (ret)
2590 +                       platform_driver_unregister(&foxfb_driver);
2591 +       }       
2592 +       fb_started = 1;
2593 +       return ret;
2594 +}
2595 +
2596 +static void __exit foxfb_exit(void)
2597 +{
2598 +       platform_device_unregister(&foxfb_device);
2599 +       platform_driver_unregister(&foxfb_driver);
2600 +}
2601 +
2602 +module_exit(foxfb_exit);
2603 +module_init(foxfb_init);
2604 +MODULE_LICENSE("GPL");
2605 +MODULE_AUTHOR("K. John '2B|!2B' Crispin");
2606 +MODULE_DESCRIPTION("FOX-VHDL Framebuffer Driver");
2607 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/foxbone.h linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/foxbone.h
2608 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/foxbone.h  1970-01-01 01:00:00.000000000 +0100
2609 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/foxbone.h       2007-06-17 02:46:15.000000000 +0200
2610 @@ -0,0 +1,20 @@
2611 +// prototypes for foxbone compliant modules
2612 +
2613 +extern unsigned int FOXBONE_release;
2614 +extern unsigned int FOXBONE_application1;
2615 +extern unsigned int FOXBONE_application2;
2616 +extern unsigned int FOXBONE_application3;
2617 +
2618 +void foxbone_write(unsigned int add, unsigned int data);
2619 +
2620 +unsigned int foxbone_read(unsigned int add);
2621 +
2622 +void foxbone_write_next(unsigned data);
2623 +
2624 +unsigned int foxbone_read_next(void);
2625 +
2626 +void foxbone_initialise_bus(void);
2627 +
2628 +void foxbone_lock(void);
2629 +
2630 +void foxbone_unlock(void);
2631 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/foxvhdlfb.c linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/foxvhdlfb.c
2632 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/foxvhdlfb.c        1970-01-01 01:00:00.000000000 +0100
2633 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/foxvhdlfb.c     2007-06-17 02:46:15.000000000 +0200
2634 @@ -0,0 +1,691 @@
2635 +/*  
2636 +  foxvhdlfb.c
2637 +  Linux Kernel Driver for FoxBone FrameBuffer on FOX VHDL Board 
2638 +  (based on FoxBone protocol interface specifications rel 0.7)    
2639 +  For more info see: http://www.acmesystems.it/?id=120
2640 +  Author: John Crispin
2641 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
2642 +  
2643 +  This is free software; you can redistribute it and/or modify
2644 +  it under the terms of the GNU General Public License as published by
2645 +  the Free Software Foundation; either version 2 of the License, or
2646 +  (at your option) any later version.
2647 +    
2648 +  This example is distributed in the hope that it will be useful,
2649 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
2650 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2651 +  GNU General Public License for more details.
2652 +    
2653 +  To have a copy of the GNU General Public License write to the Free Software
2654 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2655 +*/
2656 +
2657 +
2658 +#include <linux/module.h>
2659 +#include <linux/kernel.h>
2660 +#include <linux/errno.h>
2661 +#include <linux/string.h>
2662 +#include <linux/mm.h>
2663 +#include <linux/tty.h>
2664 +#include <linux/slab.h>
2665 +#include <linux/vmalloc.h>
2666 +#include <linux/delay.h>
2667 +#include <linux/interrupt.h>
2668 +#include <linux/platform_device.h>
2669 +
2670 +#include <asm/uaccess.h>
2671 +#include <linux/fb.h>
2672 +#include <linux/init.h>
2673 +
2674 +#include "foxbone.h"
2675 +
2676 +
2677 +#if 0
2678 +#define DBG(x) x
2679 +#else
2680 +#define DBG(x) 
2681 +#endif
2682 +
2683 +
2684 +/*
2685 +||
2686 +||     FOXVHDL CTL functions
2687 +||
2688 +*/
2689 +
2690 +
2691 +static unsigned char FOXVHDL_current_bank = 0xff;
2692 +
2693 +static unsigned char blitting = 1;
2694 +
2695 +static unsigned char refreshrate = 6;
2696 +
2697 +
2698 +
2699 +unsigned int FOXVHDL_translate_BGR(unsigned char blue, unsigned char green, unsigned char red) {
2700 +       // translate the three color passed in a single 16 bit color word
2701 +       unsigned int result = ((blue>>3)<<11) | ((green>>2)<<5) | (red>>3);
2702 +       return result;
2703 +}
2704 +
2705 +
2706 +
2707 +
2708 +// wait until the videostate pin has the wanted value
2709 +void FOXVHDL_wait_videostate(unsigned char wait_state){
2710 +/*     unsigned char vid_state = 0;
2711 +       unsigned int max_error = 0xffff;
2712 +       //printk("Start wait\n");
2713 +       do {
2714 +               vid_state = FOXVHDL_get_bit_B(Fox_line_VideoState);
2715 +               max_error--;
2716 +       } while((vid_state != wait_state)&&(max_error > 10));
2717 +       */
2718 +       DBG(if(max_error < 11){printk("Stop wait\n");};)
2719 +};
2720 +       
2721 +
2722 +// choose the bank that we want to display
2723 +// OG5 == 0 --> Bank0
2724 +// OG5 == 1 --> Bank1
2725 +void FOXVHDL_set_bank(unsigned char bank){
2726 +       DBG(printk("%d, %d\n",FOXVHDL_current_bank, bank);)
2727 +       if(FOXVHDL_current_bank == bank){
2728 +               return;
2729 +       };
2730 +       
2731 +       DBG(printk("FOXVHDL_set_bank\n");)
2732 +       
2733 +       FOXVHDL_current_bank = bank;
2734 +       foxbone_write(0x7001, FOXVHDL_current_bank);    
2735 +       
2736 +       
2737 +};
2738 +
2739 +
2740 +// blit the bank
2741 +void FOXVHDL_swap_bank(void){
2742 +       FOXVHDL_set_bank((FOXVHDL_current_bank)?(0):(1));       
2743 +};
2744 +
2745 +
2746 +// initialise the I/O pins
2747 +void FOXVHDL_init(void){
2748 +       DBG(printk("FOXVHDL_init\n");)
2749 +       
2750 +       FOXVHDL_current_bank = 0;
2751 +       
2752 +       FOXVHDL_set_bank(1);
2753 +       
2754 +};
2755 +
2756 +/*
2757 +||
2758 +||     FOXVHDL IMAGE FUNCTIONS
2759 +||
2760 +*/
2761 +#define Fox_line_WriteData        (1<<2)
2762 +
2763 +// for performance reasons, we do not use the foxbone access functions here
2764 +// we rather use an optimised algorithm. blitting now only takes about 6 ms. 
2765 +// meaning we can that effectivley achieve 17 frame. however the refresh rate by
2766 +// default is 4 fps
2767 +
2768 +#if 0
2769 +#define DBG_TIMER(x) x
2770 +#else
2771 +#define DBG_TIMER(x) 
2772 +#endif
2773 +
2774 +#if 0
2775 +#define DOUBLE_DATA_RATE
2776 +#endif
2777 +
2778 +void FOXVHDL_blit(unsigned short int *image){
2779 +       unsigned long i;
2780 +       unsigned int fb_ctl_reg;
2781 +       
2782 +       if(blitting){
2783 +               foxbone_lock();
2784 +               DBG_TIMER(unsigned long j = jiffies;)
2785 +               // reset the address pointer
2786 +               fb_ctl_reg = foxbone_read(0x7001);
2787 +               fb_ctl_reg |= (1<<4);
2788 +               foxbone_write(0x7001, fb_ctl_reg);
2789 +               fb_ctl_reg &= ~(1<<4);
2790 +               foxbone_write(0x7001, fb_ctl_reg);
2791 +                                
2792 +               foxbone_write(0x7000, image[0]);
2793 +               genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g8_15dir);
2794 +               *R_GEN_CONFIG = genconfig_shadow;
2795 +               genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g16_23dir);
2796 +               *R_GEN_CONFIG = genconfig_shadow;       
2797 +               
2798 +               *R_PORT_G_DATA = port_g_data_shadow = (port_g_data_shadow & 0xff0000ff);
2799 +               
2800 +
2801 +#ifdef DOUBLE_DATA_RATE
2802 +       
2803 +               unsigned long def_val = (port_g_data_shadow & 0xff0000ff);
2804 +               for(i = 1; i < 640 * 400; i+=2){
2805 +                       *R_PORT_G_DATA = port_g_data_shadow = def_val | image[i]<<8 | Fox_line_WriteData;
2806 +                       *R_PORT_G_DATA = port_g_data_shadow = def_val | image[i+1]<<8;
2807 +               };
2808 +               *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteData;
2809 +               
2810 +#else  
2811 +       
2812 +               unsigned long def_val = (port_g_data_shadow & 0xff0000ff) | Fox_line_WriteData;
2813 +               for(i = 1; i < 640 * 400; i++){ 
2814 +                       *R_PORT_G_DATA = port_g_data_shadow = def_val | image[i]<<8;
2815 +                       *R_PORT_G_DATA = port_g_data_shadow &= ~Fox_line_WriteData;
2816 +               };
2817 +#endif                 
2818 +               foxbone_unlock();
2819 +               FOXVHDL_swap_bank();
2820 +               DBG_TIMER(printk("%ld\n", jiffies - j);)
2821 +               
2822 +       };
2823 +};
2824 +
2825 +
2826 +
2827 +
2828 +
2829 +
2830 +/*
2831 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2832 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2833 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2834 +||
2835 +||                                                                             FRAMEBUFFER CODE
2836 +||
2837 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2838 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2839 +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2840 +
2841 +*/
2842 +
2843 +
2844 +
2845 +
2846 +#define VIDEOMEMSIZE   (640 * 400 * 2) //512K
2847 +
2848 +static void *videomemory;
2849 +static u_long videomemorysize = VIDEOMEMSIZE;
2850 +
2851 +static unsigned char fb_started = 0;
2852 +
2853 +static unsigned char fb_update = 0;
2854 +
2855 +static unsigned char fb_mmap_enable = 0;
2856 +
2857 +static struct fb_var_screeninfo foxfb_default __initdata = {
2858 +       .xres =         640,
2859 +       .yres =         400,
2860 +       .xres_virtual = 640,
2861 +       .yres_virtual = 400,
2862 +       .bits_per_pixel = 16,
2863 +       .red =          { 0, 5, 0 },
2864 +       .green =        { 5, 6, 0 },
2865 +       .blue =         { 11, 5, 0 },
2866 +       .activate =     FB_ACTIVATE_NOW,
2867 +       .height =       -1,
2868 +       .width =        -1,
2869 +       .vmode =        FB_VMODE_NONINTERLACED,
2870 +};
2871 +
2872 +static struct fb_fix_screeninfo foxfb_fix __initdata = {
2873 +       .id =           "FOX-VHDL FB",
2874 +       .type =         FB_TYPE_PACKED_PIXELS,
2875 +       .visual =       FB_VISUAL_TRUECOLOR,
2876 +       .xpanstep =     1,
2877 +       .ypanstep =     1,
2878 +       .ywrapstep =    1,
2879 +       .accel =        FB_ACCEL_NONE,
2880 +};
2881 +
2882 +static int foxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
2883 +static int foxfb_set_par(struct fb_info *info);
2884 +static int foxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info);
2885 +static int foxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
2886 +static int foxfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
2887 +static void foxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
2888 +static void foxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
2889 +static void foxfb_imageblit(struct fb_info *info, const struct fb_image *image);
2890 +
2891 +static int foxfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
2892 +
2893 +static struct fb_ops foxfb_ops = {
2894 +       .fb_check_var   = foxfb_check_var,
2895 +       .fb_set_par             = foxfb_set_par,
2896 +       .fb_setcolreg   = foxfb_setcolreg,
2897 +
2898 +       .fb_pan_display = foxfb_pan_display,
2899 +       .fb_fillrect    = foxfb_fillrect, //cfb_fillrect,
2900 +       .fb_copyarea    = foxfb_copyarea, //cfb_copyarea,
2901 +       .fb_imageblit   = foxfb_imageblit,//cfb_imageblit,
2902 +       .fb_mmap        = foxfb_mmap,
2903 +       .fb_ioctl       = foxfb_ioctl,
2904 +};
2905 +
2906 +// this function is defined in fbmem.c
2907 +extern int fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
2908 +
2909 +// this should be a free one
2910 +#define FOX_FBIOGET_SCREEN     0x4642
2911 +#define FOX_FBBLIT             0x4643
2912 +#define FOX_FB_RATE            0x4645
2913 +#define FOX_FB_TFT             0x4646
2914 +static int foxfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){
2915 +       void __user *argp = (void __user *)arg;
2916 +       unsigned int fb_ctl_reg;
2917 +       switch(cmd){
2918 +               // this assumes that arg points to a VIDEOMEMSIZE area of memory in user space
2919 +               case FOX_FBIOGET_SCREEN:
2920 +                       if(copy_to_user(argp, videomemory, VIDEOMEMSIZE)){
2921 +                               return 0;
2922 +                       } else {
2923 +                               return -1;
2924 +                       };
2925 +               case FOX_FBBLIT:
2926 +                       fb_ctl_reg = foxbone_read(0x7001);
2927 +                       if(arg){
2928 +                               printk("Enable FB\n");
2929 +                               fb_ctl_reg &= ~(1<<1);
2930 +                       } else {
2931 +                               printk("Disable FB\n");
2932 +                               fb_ctl_reg |= (1<<1);
2933 +                       };              
2934 +                       blitting = arg;
2935 +                       foxbone_write(0x7001, fb_ctl_reg);
2936 +                       break;
2937 +               case FOX_FB_RATE:
2938 +                       if((arg > 9) || (arg < 1)){
2939 +                               printk("fb0 : Illegal refreshrate\n");
2940 +                               break;
2941 +                       };
2942 +                       refreshrate = arg;
2943 +                       printk("fb0 : new refreshrate\n");
2944 +                       break;
2945 +               case FOX_FB_TFT:
2946 +                       fb_ctl_reg = foxbone_read(0x7001);
2947 +                       if(arg){
2948 +                               printk("Enable TFT\n");
2949 +                               fb_ctl_reg |= (1<<3);
2950 +                       } else {
2951 +                               printk("Disable TFT\n");
2952 +                               fb_ctl_reg &= ~(1<<3);
2953 +                       };
2954 +                       foxbone_write(0x7001, fb_ctl_reg);
2955 +                       break;
2956 +               default:
2957 +                       return fb_ioctl(inode, file, cmd, arg);         
2958 +       };
2959 +       return 0;
2960 +};
2961 +
2962 +// TODO add our own optimized code here
2963 +static void foxfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect){
2964 +       cfb_fillrect(info, rect);
2965 +       fb_update = 1;
2966 +};
2967 +
2968 +
2969 +// TODO add our own optimized code here
2970 +static void foxfb_copyarea(struct fb_info *info, const struct fb_copyarea *area){
2971 +       cfb_copyarea(info, area);
2972 +       fb_update = 1;
2973 +};
2974 +
2975 +// TODO add our own optimized code here
2976 +static void foxfb_imageblit(struct fb_info *info, const struct fb_image *image){
2977 +       cfb_imageblit(info, image);
2978 +       fb_update = 1;
2979 +};
2980 +
2981 +
2982 +/*
2983 + *  Internal routines
2984 + */
2985 +
2986 +static u_long get_line_length(int xres_virtual, int bpp)
2987 +{
2988 +       u_long length;
2989 +
2990 +       length = xres_virtual * bpp;
2991 +       length = (length + 31) & ~31;
2992 +       length >>= 3;
2993 +       return (length);
2994 +}
2995 +
2996 +    /*
2997 +     *  Setting the video mode has been split into two parts.
2998 +     *  First part, xxxfb_check_var, must not write anything
2999 +     *  to hardware, it should only verify and adjust var.
3000 +     *  This means it doesn't alter par but it does use hardware
3001 +     *  data from it to check this var. 
3002 +     */
3003 +
3004 +static int foxfb_check_var(struct fb_var_screeninfo *var,
3005 +                        struct fb_info *info)
3006 +{
3007 +       u_long line_length;
3008 +
3009 +       if (var->vmode & FB_VMODE_CONUPDATE) {
3010 +               var->vmode |= FB_VMODE_YWRAP;
3011 +               var->xoffset = info->var.xoffset;
3012 +               var->yoffset = info->var.yoffset;
3013 +       }
3014 +
3015 +       var->xres = 640;
3016 +       var->yres = 400;
3017 +       
3018 +       var->bits_per_pixel = 16;
3019 +       
3020 +       if (var->xres_virtual < var->xoffset + var->xres)
3021 +               var->xres_virtual = var->xoffset + var->xres;
3022 +       if (var->yres_virtual < var->yoffset + var->yres)
3023 +               var->yres_virtual = var->yoffset + var->yres;
3024 +
3025 +       line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
3026 +       if (line_length * var->yres_virtual > videomemorysize)
3027 +               return -ENOMEM;
3028 +
3029 +       var->red.offset = 0;
3030 +       var->red.length = 5;
3031 +       var->green.offset = 5;
3032 +       var->green.length = 6;
3033 +       var->blue.offset = 11;
3034 +       var->blue.length = 5;
3035 +       var->transp.offset = 0;
3036 +       var->transp.length = 0;
3037 +       var->red.msb_right = 0;
3038 +       var->green.msb_right = 0;
3039 +       var->blue.msb_right = 0;
3040 +       var->transp.msb_right = 0;
3041 +
3042 +       return 0;
3043 +}
3044 +
3045 +
3046 +
3047 +/* This routine actually sets the video mode. It's in here where we
3048 + * the hardware state info->par and fix which can be affected by the 
3049 + * change in par. For this driver it doesn't do much. 
3050 + */
3051 +static int foxfb_set_par(struct fb_info *info){
3052 +       info->fix.line_length = get_line_length(info->var.xres_virtual, info->var.bits_per_pixel);
3053 +       return 0;
3054 +}
3055 +
3056 +/*
3057 + *  Set a single color register. The values supplied are already
3058 + *  rounded down to the hardware's capabilities (according to the
3059 + *  entries in the var structure). Return != 0 for invalid regno.
3060 + */
3061 +
3062 +
3063 +static int foxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info){
3064 +       if (regno >= 256)       /* no. of hw registers */
3065 +               return 1;
3066 +
3067 +       /* grayscale works only partially under directcolor */
3068 +       if (info->var.grayscale) {
3069 +               /* grayscale = 0.30*R + 0.59*G + 0.11*B */
3070 +               red = green = blue =
3071 +                   (red * 77 + green * 151 + blue * 28) >> 8;
3072 +       }
3073 +
3074 +#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
3075 +       switch (info->fix.visual) {
3076 +       case FB_VISUAL_TRUECOLOR:
3077 +       case FB_VISUAL_PSEUDOCOLOR:
3078 +               red = CNVT_TOHW(red, info->var.red.length);
3079 +               green = CNVT_TOHW(green, info->var.green.length);
3080 +               blue = CNVT_TOHW(blue, info->var.blue.length);
3081 +               transp = CNVT_TOHW(transp, info->var.transp.length);
3082 +               break;
3083 +       case FB_VISUAL_DIRECTCOLOR:
3084 +               red = CNVT_TOHW(red, 8);        /* expect 8 bit DAC */
3085 +               green = CNVT_TOHW(green, 8);
3086 +               blue = CNVT_TOHW(blue, 8);
3087 +               /* hey, there is bug in transp handling... */
3088 +               transp = CNVT_TOHW(transp, 8);
3089 +               break;
3090 +       }
3091 +#undef CNVT_TOHW
3092 +       /* Truecolor has hardware independent palette */
3093 +       if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
3094 +               u32 v;
3095 +
3096 +               if (regno >= 16)
3097 +                       return 1;
3098 +
3099 +               v = (red << info->var.red.offset) |
3100 +                   (green << info->var.green.offset) |
3101 +                   (blue << info->var.blue.offset) |
3102 +                   (transp << info->var.transp.offset);
3103 +               switch (info->var.bits_per_pixel) {
3104 +               case 8:
3105 +                       break;
3106 +               case 16:
3107 +                       ((u32 *) (info->pseudo_palette))[regno] = v;
3108 +                       break;
3109 +               case 24:
3110 +               case 32:
3111 +                       ((u32 *) (info->pseudo_palette))[regno] = v;
3112 +                       break;
3113 +               }
3114 +               return 0;
3115 +       }
3116 +       return 0;
3117 +}
3118 +
3119 +
3120 +static int foxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info){
3121 +       if (var->vmode & FB_VMODE_YWRAP) {
3122 +               if (var->yoffset < 0
3123 +                   || var->yoffset >= info->var.yres_virtual
3124 +                   || var->xoffset)
3125 +                       return -EINVAL;
3126 +       } else {
3127 +               if (var->xoffset + var->xres > info->var.xres_virtual ||
3128 +                   var->yoffset + var->yres > info->var.yres_virtual)
3129 +                       return -EINVAL;
3130 +       }
3131 +       info->var.xoffset = var->xoffset;
3132 +       info->var.yoffset = var->yoffset;
3133 +       if (var->vmode & FB_VMODE_YWRAP)
3134 +               info->var.vmode |= FB_VMODE_YWRAP;
3135 +       else
3136 +               info->var.vmode &= ~FB_VMODE_YWRAP;
3137 +       return 0;
3138 +}
3139 +
3140 +
3141 +static int foxfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma){
3142 +        unsigned long page, pos;
3143 +        unsigned long start = vma->vm_start;
3144 +        unsigned long size  = vma->vm_end-vma->vm_start;
3145 +        fb_mmap_enable = 1;
3146 +       printk("mmap : %ld %ld\n", size, (long)info->fix.smem_len);
3147 +       //if (size > info->fix.smem_len){
3148 +        //       return -EINVAL;
3149 +       //}
3150 +       pos = (unsigned long) info->screen_base;
3151 +        while (size > 0) {
3152 +                page = page_to_pfn(vmalloc_to_page((void *)pos));
3153 +               if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
3154 +                       return -EAGAIN;
3155 +               start += PAGE_SIZE;
3156 +               pos += PAGE_SIZE;
3157 +               if (size > PAGE_SIZE)
3158 +                       size -= PAGE_SIZE;
3159 +               else
3160 +                       size = 0;
3161 +        }
3162 +        return 0;
3163 +}
3164 +
3165 +
3166 +// our timer
3167 +struct timer_list foxfb_timer;
3168 +
3169 +// are we currently blitting ?
3170 +static unsigned char we_are_blitting = 0;
3171 +
3172 +// the prototype for the callback
3173 +static void foxfb_timer_callback(unsigned long ptr);
3174 +
3175 +
3176 +static void tasklet_foxfb(unsigned long data);
3177 +DECLARE_TASKLET(tl_foxfb_descr, tasklet_foxfb, 0L);
3178 +static void tasklet_foxfb(unsigned long data){
3179 +       if(fb_update || fb_mmap_enable  ){
3180 +               FOXVHDL_blit(videomemory);
3181 +       } else {
3182 +               DBG(printk("FBWAIT");)
3183 +       };
3184 +       we_are_blitting = 0;
3185 +       fb_update = 0;
3186 +}
3187 +
3188 +
3189 +// setup the fb timer
3190 +static void foxfb_timer_setup(void){
3191 +       init_timer(&foxfb_timer);
3192 +       foxfb_timer.function = foxfb_timer_callback;
3193 +       foxfb_timer.data = 0;
3194 +       foxfb_timer.expires = jiffies + ( HZ / refreshrate);
3195 +       add_timer(&foxfb_timer);        
3196 +};
3197 +
3198 +
3199 +// the timer callback function that detects if the card status has changed
3200 +static void foxfb_timer_callback(unsigned long ptr){
3201 +       if((!we_are_blitting)){
3202 +               we_are_blitting = 1;
3203 +               del_timer(&foxfb_timer);
3204 +               tasklet_schedule(&tl_foxfb_descr);
3205 +               foxfb_timer_setup();
3206 +       };
3207 +};
3208 +
3209 +
3210 +static void foxfb_platform_release(struct device *device){
3211 +       // This is called when the reference count goes to zero.
3212 +}
3213 +
3214 +
3215 +static int __init foxfb_probe(struct platform_device *dev){
3216 +       struct fb_info *info;
3217 +       int retval = -ENOMEM;
3218 +
3219 +       if (!(videomemory = vmalloc(videomemorysize)))
3220 +               return retval;
3221 +               
3222 +       memset(videomemory, 0, videomemorysize);
3223 +
3224 +       info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
3225 +       if (!info)
3226 +               goto err;
3227 +
3228 +       info->screen_base = (char*)videomemory;
3229 +       info->fbops = &foxfb_ops;
3230 +       info->fix.smem_len = videomemorysize;
3231 +       retval = fb_find_mode(&info->var, info, NULL,
3232 +                             NULL, 0, NULL, 8);
3233 +
3234 +       if (!retval || (retval == 4))
3235 +               info->var = foxfb_default;
3236 +
3237 +       info->fix = foxfb_fix;
3238 +       info->pseudo_palette = info->par;
3239 +       info->par = NULL;
3240 +       info->flags = FBINFO_FLAG_DEFAULT;
3241 +       //info->cursor.mode &= ~CURSOR_BLINK;
3242 +       retval = fb_alloc_cmap(&info->cmap, 256, 0);
3243 +       if (retval < 0)
3244 +               goto err1;
3245 +
3246 +       retval = register_framebuffer(info);
3247 +       if (retval < 0)
3248 +               goto err2;
3249 +       platform_set_drvdata(dev, info);
3250 +
3251 +       printk(KERN_INFO
3252 +              "fb%d: FOX-VHDL frame buffer device, using %ldK of video memory\n",
3253 +              info->node, videomemorysize >> 10);
3254 +       
3255 +       
3256 +       //FOXVHDL_blit(videomemory);  
3257 +       foxfb_timer_setup();
3258 +       return 0;
3259 +err2:
3260 +       fb_dealloc_cmap(&info->cmap);
3261 +err1:
3262 +       framebuffer_release(info);
3263 +err:
3264 +       vfree(videomemory);
3265 +       return retval;
3266 +}
3267 +
3268 +static int foxfb_remove(struct platform_device *dev)
3269 +{
3270 +       struct fb_info *info = platform_get_drvdata(dev);
3271 +
3272 +       if (info) {
3273 +               unregister_framebuffer(info);
3274 +               vfree(videomemory);
3275 +               framebuffer_release(info);
3276 +       }
3277 +       return 0;
3278 +}
3279 +
3280 +static struct platform_driver foxfb_driver = {
3281 +       .probe  = foxfb_probe,
3282 +       .remove = foxfb_remove,
3283 +       .driver = {
3284 +               .name   = "foxfb",
3285 +       },
3286 +};
3287 +
3288 +static struct platform_device foxfb_device = {
3289 +       .name   = "foxfb",
3290 +       .id     = 0,
3291 +       .dev    = {
3292 +               .release = foxfb_platform_release,
3293 +       }
3294 +};
3295 +
3296 +static int __init foxfb_init(void)
3297 +{
3298 +       int ret = 0;
3299 +       refreshrate = 8;
3300 +       printk(KERN_INFO "fb: Initialising framebuffer\n");
3301 +       
3302 +       FOXVHDL_init();
3303 +
3304 +       ret = platform_driver_register(&foxfb_driver);
3305 +
3306 +       if (!ret) {
3307 +               ret = platform_device_register(&foxfb_device);
3308 +               if (ret)
3309 +                       platform_driver_unregister(&foxfb_driver);
3310 +       }       
3311 +       fb_started = 1;
3312 +       return ret;
3313 +}
3314 +
3315 +static void __exit foxfb_exit(void)
3316 +{
3317 +       platform_device_unregister(&foxfb_device);
3318 +       platform_driver_unregister(&foxfb_driver);
3319 +}
3320 +
3321 +module_exit(foxfb_exit);
3322 +module_init(foxfb_init);
3323 +MODULE_LICENSE("GPL");
3324 +MODULE_AUTHOR("K. John '2B|!2B' Crispin");
3325 +MODULE_DESCRIPTION("FOX-VHDL Framebuffer Driver");
3326 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/Makefile linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/Makefile
3327 --- linux-2.6.19.2.orig/drivers/fox-vhdl/fox_vhdl_fb/Makefile   1970-01-01 01:00:00.000000000 +0100
3328 +++ linux-2.6.19.2/drivers/fox-vhdl/fox_vhdl_fb/Makefile        2007-06-17 02:46:15.000000000 +0200
3329 @@ -0,0 +1,5 @@
3330 +# Makefile for fox_vhdl drivers
3331 +# 23.04.2006 <mailto:john@phrozen.org>
3332 +
3333 +# the fox_vhdl_framebuffer driver
3334 +obj-$(CONFIG_FOX_VHDL_FB)          += foxvhdlfb.o
3335 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/Kconfig linux-2.6.19.2/drivers/fox-vhdl/Kconfig
3336 --- linux-2.6.19.2.orig/drivers/fox-vhdl/Kconfig        1970-01-01 01:00:00.000000000 +0100
3337 +++ linux-2.6.19.2/drivers/fox-vhdl/Kconfig     2007-06-17 02:46:15.000000000 +0200
3338 @@ -0,0 +1,274 @@
3339 +menu "Acmesystems FPGA"
3340 +
3341 +config FOX_VHDL
3342 +       bool "Support for FOX-VHDL Board"
3343 +       default n
3344 +
3345 +config FOX_FPGA
3346 +       bool "FPGA flash module"
3347 +       depends on FOX_VHDL
3348 +       help
3349 +       Adds the module needed to flash the fpga from the FOX
3350 +
3351 +config FOXBONE
3352 +       bool "Basic FOXBONE support"
3353 +       depends on FOX_VHDL
3354 +       help
3355 +       Include this to get basic FOXBONE support
3356 +
3357 +config VT
3358 +       bool "Virtual terminal (needed for framebuffer)" if EMBEDDED
3359 +       select INPUT
3360 +       default y if !VIOCONS
3361 +       ---help---
3362 +         If you say Y here, you will get support for terminal devices with
3363 +         display and keyboard devices. These are called "virtual" because you
3364 +         can run several virtual terminals (also called virtual consoles) on
3365 +         one physical terminal. This is rather useful, for example one
3366 +         virtual terminal can collect system messages and warnings, another
3367 +         one can be used for a text-mode user session, and a third could run
3368 +         an X session, all in parallel. Switching between virtual terminals
3369 +         is done with certain key combinations, usually Alt-<function key>.
3370 +
3371 +         The setterm command ("man setterm") can be used to change the
3372 +         properties (such as colors or beeping) of a virtual terminal. The
3373 +         man page console_codes(4) ("man console_codes") contains the special
3374 +         character sequences that can be used to change those properties
3375 +         directly. The fonts used on virtual terminals can be changed with
3376 +         the setfont ("man setfont") command and the key bindings are defined
3377 +         with the loadkeys ("man loadkeys") command.
3378 +
3379 +         You need at least one virtual terminal device in order to make use
3380 +         of your keyboard and monitor. Therefore, only people configuring an
3381 +         embedded system would want to say N here in order to save some
3382 +         memory; the only way to log into such a system is then via a serial
3383 +         or network connection.
3384 +
3385 +         If unsure, say Y, or else you won't be able to do much with your new
3386 +         shiny Linux system :-)
3387 +
3388 +
3389 +menu "Framebuffer"     
3390 +depends on VT
3391 +
3392 +config FB
3393 +       bool "Support for frame buffer devices"
3394 +       depends on VT
3395 +       ---help---
3396 +         The frame buffer device provides an abstraction for the graphics
3397 +         hardware. It represents the frame buffer of some video hardware and
3398 +         allows application software to access the graphics hardware through
3399 +         a well-defined interface, so the software doesn't need to know
3400 +         anything about the low-level (hardware register) stuff.
3401 +
3402 +         Frame buffer devices work identically across the different
3403 +         architectures supported by Linux and make the implementation of
3404 +         application programs easier and more portable; at this point, an X
3405 +         server exists which uses the frame buffer device exclusively.
3406 +         On several non-X86 architectures, the frame buffer device is the
3407 +         only way to use the graphics hardware.
3408 +
3409 +         The device is accessed through special device nodes, usually located
3410 +         in the /dev directory, i.e. /dev/fb*.
3411 +
3412 +         You need an utility program called fbset to make full use of frame
3413 +         buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
3414 +         and the Framebuffer-HOWTO at
3415 +         <http://www.tahallah.demon.co.uk/programming/prog.html> for more
3416 +         information.
3417 +
3418 +         Say Y here and to the driver for your graphics board below if you
3419 +         are compiling a kernel for a non-x86 architecture.
3420 +
3421 +         If you are compiling for the x86 architecture, you can say Y if you
3422 +         want to play with it, but it is not essential. Please note that
3423 +         running graphical applications that directly touch the hardware
3424 +         (e.g. an accelerated X server) and that are not frame buffer
3425 +         device-aware may cause unexpected results. If unsure, say N.
3426 +
3427 +config FB_CFB_FILLRECT
3428 +       tristate
3429 +       depends on FB
3430 +       default n
3431 +       ---help---
3432 +         Include the cfb_fillrect function for generic software rectangle
3433 +         filling. This is used by drivers that don't provide their own
3434 +         (accelerated) version.
3435 +
3436 +config FB_CFB_COPYAREA
3437 +       tristate
3438 +       depends on FB
3439 +       default n
3440 +       ---help---
3441 +         Include the cfb_copyarea function for generic software area copying.
3442 +         This is used by drivers that don't provide their own (accelerated)
3443 +         version.
3444 +
3445 +config FB_CFB_IMAGEBLIT
3446 +       tristate
3447 +       depends on FB
3448 +       default n
3449 +       ---help---
3450 +         Include the cfb_imageblit function for generic software image
3451 +         blitting. This is used by drivers that don't provide their own
3452 +         (accelerated) version.
3453 +config DUMMY_CONSOLE
3454 +       bool "Dummy Console"
3455 +       depends on FB
3456 +       #PROM_CONSOLE!=y || VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y 
3457 +       default n
3458 +
3459 +config FRAMEBUFFER_CONSOLE
3460 +       bool "Framebuffer Console support"
3461 +       depends on FB
3462 +       select CRC32
3463 +       help
3464 +         Low-level framebuffer-based console driver.
3465 +config LOGO
3466 +       bool "Bootup logo"
3467 +       depends on FB || SGI_NEWPORT_CONSOLE
3468 +       help
3469 +         Enable and select frame buffer bootup logos.
3470 +
3471 +config LOGO_LINUX_CLUT224
3472 +       bool "Standard 224-color Linux logo"
3473 +       depends on LOGO
3474 +       default y
3475 +config FONTS
3476 +       bool "Select compiled-in fonts"
3477 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
3478 +       help
3479 +         Say Y here if you would like to use fonts other than the default
3480 +         your frame buffer console usually use.
3481 +
3482 +         Note that the answer to this question won't directly affect the
3483 +         kernel: saying N will just cause the configurator to skip all
3484 +         the questions about foreign fonts.
3485 +
3486 +         If unsure, say N (the default choices are safe).
3487 +
3488 +config FONT_8x8
3489 +       bool "VGA 8x8 font" if FONTS
3490 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
3491 +       default y if !SPARC && !FONTS
3492 +       help
3493 +         This is the "high resolution" font for the VGA frame buffer (the one
3494 +         provided by the text console 80x50 (and higher) modes).
3495 +
3496 +         Note that this is a poor quality font. The VGA 8x16 font is quite a
3497 +         lot more readable.
3498 +
3499 +         Given the resolution provided by the frame buffer device, answer N
3500 +         here is safe.
3501 +
3502 +config FONT_8x16
3503 +       bool "VGA 8x16 font" if FONTS
3504 +       depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON 
3505 +       default y if !SPARC && !FONTS
3506 +       help
3507 +         This is the "high resolution" font for the VGA frame buffer (the one
3508 +         provided by the VGA text console 80x25 mode.
3509 +
3510 +         If unsure, say Y.
3511 +
3512 +
3513 +config FOX_VHDL_FB
3514 +        bool "FOX_VHDL Framebuffer"
3515 +       depends on FOXBONE
3516 +       depends on FB
3517 +       select FB_CFB_FILLRECT
3518 +       select FB_CFB_COPYAREA
3519 +       select FB_CFB_IMAGEBLIT                         
3520 +       select VT_CONSOLE
3521 +       select DUMMY_CONSOLE
3522 +       select FRAMEBUFFER_CONSOLE
3523 +       select FONTS
3524 +       select LOGO
3525 +       select LOGO_LINUX_CLUT224
3526 +
3527 +config NANOXKBD
3528 +       bool "nano-X keyboard support"
3529 +       default n
3530 +       depends on FOX_VHDL_FB
3531 +       help 
3532 +       Enable the keyboard driver patches for nano-X
3533 +
3534 +
3535 +
3536 +#if FOX_VHDL_FB
3537 +       #source "drivers/video/console/Kconfig"
3538 +#endif
3539 +
3540 +#if FOX_VHDL_FB 
3541 +#      source "drivers/video/logo/Kconfig"
3542 +#endif
3543 +
3544 +endmenu
3545 +
3546 +
3547 +config FOXBONE_IO
3548 +       bool "FOXBONE I/O pins"
3549 +       depends on FOXBONE
3550 +       help
3551 +       Include this to get access to the I/O pins of the foxbone
3552 +
3553 +config FOXBONE_TIMEBASE
3554 +       bool "FOXBONE Timebase"
3555 +       depends on FOXBONE
3556 +       help
3557 +       Include this to get access to the timebase part of the fpga
3558 +
3559 +config FOXBONE_MMC
3560 +       bool "FOXBONE MMC/SD module"
3561 +       depends on FOXBONE
3562 +       help
3563 +       Include this to be able to access a mmc/sd card connected to J3 of the fox-vhdl board
3564 +
3565 +config FOXBONE_PWM
3566 +       bool "FOXBONE PWM module"
3567 +       depends on FOXBONE
3568 +       help
3569 +       Include this to enable PWM support into the kernel
3570 +
3571 +config FOXBONE_EVENT
3572 +       bool "FOXBONE EVENT counter module"
3573 +       depends on FOXBONE
3574 +       help
3575 +       Include this to enable foxbone event counter support
3576 +
3577 +config FOXBONE_LOOPBACK
3578 +       bool "FOXBONE Loopback module"
3579 +       depends on FOXBONE
3580 +       help
3581 +       Include this to be able to load the loopback module, that you can base your own driver on
3582 +
3583 +config FOXBONE_MULTIPLY
3584 +       bool "FOXBONE Multiplier example"
3585 +       depends on FOXBONE
3586 +       help
3587 +       Include this to use the 64 bit multiplier
3588 +
3589 +menu "FOXBONE interrupt handlers"
3590 +config FOXBONE_SAMPLE_ISR
3591 +       bool "FOXBONE example interrupt handlers"
3592 +       depends on FOXBONE
3593 +       
3594 +config FOXBONE_INT14
3595 +       bool "Int 14 - bit 0 of reg 0x13 set"
3596 +       depends on FOXBONE_SAMPLE_ISR
3597 +
3598 +config FOXBONE_INT31
3599 +       bool "Int 31 - bit 1 of reg 0x13 set"
3600 +       depends on FOXBONE_SAMPLE_ISR
3601 +
3602 +endmenu        
3603 +
3604 +
3605 +config ETRAX_CMDLINE
3606 +       string "Kernel command line" 
3607 +       default "root=/dev/mtdblock3 init=/linuxrc console=ttyS0"
3608 +       help
3609 +       use if no framebuffer is enabled console=ttyS0
3610 +       use if framebuffer is enabled console=tty0
3611 +                                       
3612 +endmenu
3613 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/keyboard/Makefile linux-2.6.19.2/drivers/fox-vhdl/keyboard/Makefile
3614 --- linux-2.6.19.2.orig/drivers/fox-vhdl/keyboard/Makefile      1970-01-01 01:00:00.000000000 +0100
3615 +++ linux-2.6.19.2/drivers/fox-vhdl/keyboard/Makefile   2007-06-17 02:46:15.000000000 +0200
3616 @@ -0,0 +1 @@
3617 +obj-$(CONFIG_NANOXKBD)          += nanoxkbd.o
3618 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/keyboard/nanoxkbd.c linux-2.6.19.2/drivers/fox-vhdl/keyboard/nanoxkbd.c
3619 --- linux-2.6.19.2.orig/drivers/fox-vhdl/keyboard/nanoxkbd.c    1970-01-01 01:00:00.000000000 +0100
3620 +++ linux-2.6.19.2/drivers/fox-vhdl/keyboard/nanoxkbd.c 2007-06-17 02:46:15.000000000 +0200
3621 @@ -0,0 +1,173 @@
3622 +/*  
3623 +  nanoxkbd.c
3624 +  Linux Kernel Driver for Nanox Keyboard driver for FOX VHDL Board framebuffer
3625 +  (based on FoxBone protocol interface specifications rel 0.7)    
3626 +  For more info see: http://www.acmesystems.it/?id=120
3627 +  Author: John Crispin
3628 +  Copyright (C) 2006 Phrozen (http://www.phrozen.biz)
3629 +  
3630 +  This is free software; you can redistribute it and/or modify
3631 +  it under the terms of the GNU General Public License as published by
3632 +  the Free Software Foundation; either version 2 of the License, or
3633 +  (at your option) any later version.
3634 +    
3635 +  This example is distributed in the hope that it will be useful,
3636 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
3637 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3638 +  GNU General Public License for more details.
3639 +    
3640 +  To have a copy of the GNU General Public License write to the Free Software
3641 +  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
3642 +*/
3643 +
3644 +
3645 +#include <linux/module.h>
3646 +#include <linux/init.h>
3647 +#include <linux/module.h>
3648 +#include <linux/errno.h>
3649 +#include <linux/ioport.h>
3650 +#include <linux/version.h>
3651 +#include <linux/init.h>
3652 +#include <asm/uaccess.h>
3653 +#include <asm/io.h>
3654 +#include <linux/vmalloc.h>
3655 +#include <linux/ioport.h>  
3656 +#include <linux/init.h>
3657 +#include <linux/genhd.h>
3658 +
3659 +#define DEV_NAME                       "keyboard"
3660 +#define DEV_MAJOR                      195
3661 +
3662 +
3663 +unsigned char nanoxkbd_is_open = 0;
3664 +
3665 +#define MAX_KEYS 128
3666 +unsigned int keys[MAX_KEYS];
3667 +unsigned char keys_count = 0;
3668 +unsigned char keys_pos = 0;
3669 +
3670 +#define IOCTL_NANOXKBD_GET             0x7878
3671 +
3672 +unsigned char nanoxkbd_add(unsigned int keycode){
3673 +       if(nanoxkbd_is_open){
3674 +               if(keys_count < MAX_KEYS){                      
3675 +                       keys[(keys_pos + keys_count) % MAX_KEYS] = keycode;
3676 +                       keys_count++;
3677 +                       printk("got key %d, %d, %d\n", keycode, keys_pos, keys_count);
3678 +               };
3679 +               return 1;
3680 +       };
3681 +       return 0;
3682 +};
3683 +
3684 +// the app has send us some control data
3685 +static int module_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg){
3686 +       //copy_to_user((char*)arg, (char*)&audio_data, sizeof(AUDIO_DATA));
3687 +       //copy_from_user((char*)&mp3_beep, (char*)arg, sizeof(MP3_BEEP));
3688 +       int retval = 0;
3689 +       switch (cmd) {
3690 +               case IOCTL_NANOXKBD_GET:
3691 +                       if(keys_count > 0){
3692 +                               keys_count--;
3693 +                               copy_to_user((char*)arg, (char*)&keys[keys_pos], sizeof(unsigned int));
3694 +                               keys_pos++;
3695 +                               if(keys_pos >= MAX_KEYS){
3696 +                                       keys_pos = 0;
3697 +                               };
3698 +                               retval = 1;
3699 +                       };
3700 +                       break;
3701 +                               
3702 +               default:
3703 +                       printk("nanoxkbd: unknown ioctl\n");
3704 +                       break;                  
3705 +       }
3706 +
3707 +       return retval;
3708 +};
3709 +
3710 +
3711 +
3712 +static int module_open(struct inode *inode, struct file *file){
3713 +       // Which minor device is the user trying to access ?
3714 +       unsigned int dev_minor = MINOR(inode->i_rdev);
3715 +       
3716 +       // we only supprt minor 0 at the moment
3717 +       if(dev_minor !=  0){
3718 +               printk("nanoxkbd: trying to access unknown minor device -> %d\n", dev_minor);
3719 +               return -ENODEV;
3720 +       }
3721 +       
3722 +       // check if another app is currently using the device
3723 +       if(nanoxkbd_is_open) {
3724 +               printk("nanoxkbd: Device with minor ID %d already in use\n", dev_minor);
3725 +               return -EBUSY;
3726 +       }
3727 +       nanoxkbd_is_open = 1;
3728 +       
3729 +       // more flaming
3730 +       printk("nanoxkbd: Minor %d has been opened\n", dev_minor);
3731 +       return 0;
3732 +};
3733 +
3734 +
3735 +// gets called when an app closes the device
3736 +static int module_close(struct inode * inode, struct file * file){
3737 +       // Which minor device is the user trying to access ?
3738 +       unsigned int dev_minor = MINOR(inode->i_rdev);
3739 +       
3740 +       // remember that the device has been closed
3741 +       nanoxkbd_is_open = 0;
3742 +       
3743 +       
3744 +       // more flaming
3745 +       printk("nanoxkbd: Minor %d has been closed\n", dev_minor);
3746 +       
3747 +       return 0;
3748 +};
3749 +
3750 +// so the kernel knows which functions to access for a given operation
3751 +struct file_operations nanoxkbd_module_fops = {
3752 +        ioctl:         module_ioctl,
3753 +        open:          module_open,
3754 +        release:       module_close
3755 +};
3756 +
3757 +
3758 +// module gets loaded into kernel / char dev is registered
3759 +static int __init mod_init(void){
3760 +       // flame the kprintk
3761 +       printk("nanoxkbd: FOX-VHDL FPGA io module\n");
3762 +       //printk("nanoxkbd: Made by K. John '2B|!2B' Crispin (john@phrozen.org)\n");
3763 +       //printk("nanoxkbd: Starting ...\n");
3764 +       
3765 +       // register the character device
3766 +       if(register_chrdev(DEV_MAJOR, DEV_NAME, &nanoxkbd_module_fops)) {
3767 +               printk( "nanoxkbd: Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
3768 +               return( -ENODEV );
3769 +       };
3770 +       
3771 +
3772 +       // remember that the driver has been opened
3773 +       nanoxkbd_is_open = 0;
3774 +       printk("nanoxkbd: Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
3775 +       return 0;
3776 +}
3777 +
3778 +
3779 +// we are done so shut everything down
3780 +static void __exit mod_exit(void){
3781 +       printk( "nanoxkbd: Cleanup\n" );
3782 +       // tell the kernel that the device is not needed anymore
3783 +       unregister_chrdev(DEV_MAJOR, DEV_NAME);
3784 +       
3785 +}
3786 +
3787 +module_init (mod_init);
3788 +module_exit (mod_exit);
3789 +
3790 +
3791 +
3792 +
3793 +
3794 +
3795 diff -urN linux-2.6.19.2.orig/drivers/fox-vhdl/Makefile linux-2.6.19.2/drivers/fox-vhdl/Makefile
3796 --- linux-2.6.19.2.orig/drivers/fox-vhdl/Makefile       1970-01-01 01:00:00.000000000 +0100
3797 +++ linux-2.6.19.2/drivers/fox-vhdl/Makefile    2007-06-17 02:46:15.000000000 +0200
3798 @@ -0,0 +1,13 @@
3799 +#
3800 +# Makefile for the i2c core.
3801 +#
3802 +obj-$(CONFIG_FOXBONE)          += foxbone/
3803 +obj-$(CONFIG_FOX_VHDL_FB)      += fox_vhdl_fb/
3804 +obj-$(CONFIG_FOX_FPGA)         += fox_fpga_flash/
3805 +obj-$(CONFIG_FOXBONE_PWM)      += fox_pwm/             
3806 +obj-$(CONFIG_FOXBONE_IO)       += fox_io/
3807 +obj-$(CONFIG_FOXBONE_TIMEBASE)         += fox_timebase/
3808 +obj-$(CONFIG_FOXBONE_LOOPBACK)  += fox_loopback/
3809 +obj-$(CONFIG_FOXBONE_EVENT)    += fox_event/
3810 +obj-$(CONFIG_FOXBONE_MULTIPLY) += fox_multiply/        
3811 +obj-$(CONFIG_NANOXKBD)                 += keyboard/
3812 --- linux-2.6.19.2.orig/arch/cris/Kconfig       2007-06-16 23:58:14.000000000 +0200
3813 +++ linux-2.6.19.2/drivers/fox-vhdl/Kconfig     2007-06-17 02:46:15.000000000 +0200
3814 @@ -1,244 +1,274 @@
3815 -#
3816 -# For a description of the syntax of this configuration file,
3817 -# see the Configure script.
3818 -#
3819 +menu "Acmesystems FPGA"
3820  
3821 -mainmenu "Linux/CRIS Kernel Configuration"
3822 -
3823 -config MMU
3824 -       bool
3825 -       default y
3826 -
3827 -config RWSEM_GENERIC_SPINLOCK
3828 -       bool
3829 -       default y
3830 -
3831 -config RWSEM_XCHGADD_ALGORITHM
3832 -       bool
3833 -
3834 -config GENERIC_IOMAP
3835 -       bool
3836 -       default y
3837 -
3838 -config GENERIC_FIND_NEXT_BIT
3839 -       bool
3840 -       default y
3841 -
3842 -config GENERIC_HWEIGHT
3843 -       bool
3844 +config FOX_VHDL
3845 +       bool "Support for FOX-VHDL Board"
3846 +       default n
3847 +
3848 +config FOX_FPGA
3849 +       bool "FPGA flash module"
3850 +       depends on FOX_VHDL
3851 +       help
3852 +       Adds the module needed to flash the fpga from the FOX
3853 +
3854 +config FOXBONE
3855 +       bool "Basic FOXBONE support"
3856 +       depends on FOX_VHDL
3857 +       help
3858 +       Include this to get basic FOXBONE support
3859 +
3860 +config VT
3861 +       bool "Virtual terminal (needed for framebuffer)" if EMBEDDED
3862 +       select INPUT
3863 +       default y if !VIOCONS
3864 +       ---help---
3865 +         If you say Y here, you will get support for terminal devices with
3866 +         display and keyboard devices. These are called "virtual" because you
3867 +         can run several virtual terminals (also called virtual consoles) on
3868 +         one physical terminal. This is rather useful, for example one
3869 +         virtual terminal can collect system messages and warnings, another
3870 +         one can be used for a text-mode user session, and a third could run
3871 +         an X session, all in parallel. Switching between virtual terminals
3872 +         is done with certain key combinations, usually Alt-<function key>.
3873 +
3874 +         The setterm command ("man setterm") can be used to change the
3875 +         properties (such as colors or beeping) of a virtual terminal. The
3876 +         man page console_codes(4) ("man console_codes") contains the special
3877 +         character sequences that can be used to change those properties
3878 +         directly. The fonts used on virtual terminals can be changed with
3879 +         the setfont ("man setfont") command and the key bindings are defined
3880 +         with the loadkeys ("man loadkeys") command.
3881 +
3882 +         You need at least one virtual terminal device in order to make use
3883 +         of your keyboard and monitor. Therefore, only people configuring an
3884 +         embedded system would want to say N here in order to save some
3885 +         memory; the only way to log into such a system is then via a serial
3886 +         or network connection.
3887 +
3888 +         If unsure, say Y, or else you won't be able to do much with your new
3889 +         shiny Linux system :-)
3890 +
3891 +
3892 +menu "Framebuffer"     
3893 +depends on VT
3894 +
3895 +config FB
3896 +       bool "Support for frame buffer devices"
3897 +       depends on VT
3898 +       ---help---
3899 +         The frame buffer device provides an abstraction for the graphics
3900 +         hardware. It represents the frame buffer of some video hardware and
3901 +         allows application software to access the graphics hardware through
3902 +         a well-defined interface, so the software doesn't need to know
3903 +         anything about the low-level (hardware register) stuff.
3904 +
3905 +         Frame buffer devices work identically across the different
3906 +         architectures supported by Linux and make the implementation of
3907 +         application programs easier and more portable; at this point, an X
3908 +         server exists which uses the frame buffer device exclusively.
3909 +         On several non-X86 architectures, the frame buffer device is the
3910 +         only way to use the graphics hardware.
3911 +
3912 +         The device is accessed through special device nodes, usually located
3913 +         in the /dev directory, i.e. /dev/fb*.
3914 +
3915 +         You need an utility program called fbset to make full use of frame
3916 +         buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
3917 +         and the Framebuffer-HOWTO at
3918 +         <http://www.tahallah.demon.co.uk/programming/prog.html> for more
3919 +         information.
3920 +
3921 +         Say Y here and to the driver for your graphics board below if you
3922 +         are compiling a kernel for a non-x86 architecture.
3923 +
3924 +         If you are compiling for the x86 architecture, you can say Y if you
3925 +         want to play with it, but it is not essential. Please note that
3926 +         running graphical applications that directly touch the hardware
3927 +         (e.g. an accelerated X server) and that are not frame buffer
3928 +         device-aware may cause unexpected results. If unsure, say N.
3929 +
3930 +config FB_CFB_FILLRECT
3931 +       tristate
3932 +       depends on FB
3933 +       default n
3934 +       ---help---
3935 +         Include the cfb_fillrect function for generic software rectangle
3936 +         filling. This is used by drivers that don't provide their own
3937 +         (accelerated) version.
3938 +
3939 +config FB_CFB_COPYAREA
3940 +       tristate
3941 +       depends on FB
3942 +       default n
3943 +       ---help---
3944 +         Include the cfb_copyarea function for generic software area copying.
3945 +         This is used by drivers that don't provide their own (accelerated)
3946 +         version.
3947 +
3948 +config FB_CFB_IMAGEBLIT
3949 +       tristate
3950 +       depends on FB
3951 +       default n
3952 +       ---help---
3953 +         Include the cfb_imageblit function for generic software image
3954 +         blitting. This is used by drivers that don't provide their own
3955 +         (accelerated) version.
3956 +config DUMMY_CONSOLE
3957 +       bool "Dummy Console"
3958 +       depends on FB
3959 +       #PROM_CONSOLE!=y || VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y 
3960 +       default n
3961 +
3962 +config FRAMEBUFFER_CONSOLE
3963 +       bool "Framebuffer Console support"
3964 +       depends on FB
3965 +       select CRC32
3966 +       help
3967 +         Low-level framebuffer-based console driver.
3968 +config LOGO
3969 +       bool "Bootup logo"
3970 +       depends on FB || SGI_NEWPORT_CONSOLE
3971 +       help
3972 +         Enable and select frame buffer bootup logos.
3973 +
3974 +config LOGO_LINUX_CLUT224
3975 +       bool "Standard 224-color Linux logo"
3976 +       depends on LOGO
3977         default y
3978 -
3979 -config GENERIC_CALIBRATE_DELAY
3980 -       bool
3981 -       default y
3982 -
3983 -config IRQ_PER_CPU
3984 -       bool
3985 -       default y
3986 -
3987 -config CRIS
3988 -       bool
3989 -       default y
3990 -
3991 -source "init/Kconfig"
3992 -
3993 -menu "General setup"
3994 -
3995 -source "fs/Kconfig.binfmt"
3996 -
3997 -config GENERIC_HARDIRQS
3998 -       bool
3999 -       default y
4000 -
4001 -config SMP
4002 -       bool "SMP"
4003 -       help
4004 -         SMP support. Always Say N.
4005 -
4006 -config NR_CPUS
4007 -       int
4008 -       depends on SMP
4009 -       default 2
4010 -
4011 -config SCHED_MC
4012 -       bool "Multi-core scheduler support"
4013 -       depends on SMP
4014 -       default y
4015 -       help
4016 -         Multi-core scheduler support improves the CPU scheduler's decision
4017 -         making when dealing with multi-core CPU chips at a cost of slightly
4018 -         increased overhead in some places. If unsure say N here.
4019 -
4020 -config ETRAX_CMDLINE
4021 -       string "Kernel command line"
4022 -       default "root=/dev/mtdblock3"
4023 -       help
4024 -         Pass additional commands to the kernel.
4025 -
4026 -config ETRAX_WATCHDOG
4027 -       bool "Enable ETRAX watchdog"
4028 -       help
4029 -         Enable the built-in watchdog timer support on ETRAX based embedded
4030 -         network computers.
4031 -
4032 -config ETRAX_WATCHDOG_NICE_DOGGY
4033 -       bool "Disable watchdog during Oops printouts"
4034 -       depends on ETRAX_WATCHDOG
4035 -       help
4036 -         By enabling this you make sure that the watchdog does not bite while
4037 -         printing oopses. Recommended for development systems but not for
4038 -         production releases.
4039 -
4040 -config ETRAX_FAST_TIMER
4041 -       bool "Enable ETRAX fast timer API"
4042 -       help
4043 -         This options enables the API to a fast timer implementation using
4044 -        timer1 to get sub jiffie resolution timers (primarily one-shot
4045 -        timers).
4046 -        This is needed if CONFIG_ETRAX_SERIAL_FAST_TIMER is enabled.
4047 -
4048 -config OOM_REBOOT
4049 -       bool "Enable reboot at out of memory"
4050 -
4051 -source "kernel/Kconfig.preempt"
4052 -source "kernel/Kconfig.sched"
4053 -
4054 -source mm/Kconfig
4055 +config FONTS
4056 +       bool "Select compiled-in fonts"
4057 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
4058 +       help
4059 +         Say Y here if you would like to use fonts other than the default
4060 +         your frame buffer console usually use.
4061 +
4062 +         Note that the answer to this question won't directly affect the
4063 +         kernel: saying N will just cause the configurator to skip all
4064 +         the questions about foreign fonts.
4065 +
4066 +         If unsure, say N (the default choices are safe).
4067 +
4068 +config FONT_8x8
4069 +       bool "VGA 8x8 font" if FONTS
4070 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
4071 +       default y if !SPARC && !FONTS
4072 +       help
4073 +         This is the "high resolution" font for the VGA frame buffer (the one
4074 +         provided by the text console 80x50 (and higher) modes).
4075 +
4076 +         Note that this is a poor quality font. The VGA 8x16 font is quite a
4077 +         lot more readable.
4078 +
4079 +         Given the resolution provided by the frame buffer device, answer N
4080 +         here is safe.
4081 +
4082 +config FONT_8x16
4083 +       bool "VGA 8x16 font" if FONTS
4084 +       depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON 
4085 +       default y if !SPARC && !FONTS
4086 +       help
4087 +         This is the "high resolution" font for the VGA frame buffer (the one
4088 +         provided by the VGA text console 80x25 mode.
4089 +
4090 +         If unsure, say Y.
4091 +
4092 +
4093 +config FOX_VHDL_FB
4094 +        bool "FOX_VHDL Framebuffer"
4095 +       depends on FOXBONE
4096 +       depends on FB
4097 +       select FB_CFB_FILLRECT
4098 +       select FB_CFB_COPYAREA
4099 +       select FB_CFB_IMAGEBLIT                         
4100 +       select VT_CONSOLE
4101 +       select DUMMY_CONSOLE
4102 +       select FRAMEBUFFER_CONSOLE
4103 +       select FONTS
4104 +       select LOGO
4105 +       select LOGO_LINUX_CLUT224
4106 +
4107 +config NANOXKBD
4108 +       bool "nano-X keyboard support"
4109 +       default n
4110 +       depends on FOX_VHDL_FB
4111 +       help 
4112 +       Enable the keyboard driver patches for nano-X
4113 +
4114 +
4115 +
4116 +#if FOX_VHDL_FB
4117 +       #source "drivers/video/console/Kconfig"
4118 +#endif
4119 +
4120 +#if FOX_VHDL_FB 
4121 +#      source "drivers/video/logo/Kconfig"
4122 +#endif
4123  
4124  endmenu
4125  
4126 -menu "Hardware setup"
4127 -
4128 -choice
4129 -       prompt "Processor type"
4130 -       default ETRAX100LX
4131  
4132 -config ETRAX100LX
4133 -       bool "ETRAX-100LX-v1"
4134 +config FOXBONE_IO
4135 +       bool "FOXBONE I/O pins"
4136 +       depends on FOXBONE
4137         help
4138 -         Support version 1 of the ETRAX 100LX.
4139 +       Include this to get access to the I/O pins of the foxbone
4140  
4141 -config ETRAX100LX_V2
4142 -       bool "ETRAX-100LX-v2"
4143 +config FOXBONE_TIMEBASE
4144 +       bool "FOXBONE Timebase"
4145 +       depends on FOXBONE
4146         help
4147 -         Support version 2 of the ETRAX 100LX.
4148 +       Include this to get access to the timebase part of the fpga
4149  
4150 -config SVINTO_SIM
4151 -       bool "ETRAX-100LX-for-xsim-simulator"
4152 +config FOXBONE_MMC
4153 +       bool "FOXBONE MMC/SD module"
4154 +       depends on FOXBONE
4155         help
4156 -         Support the xsim ETRAX Simulator.
4157 +       Include this to be able to access a mmc/sd card connected to J3 of the fox-vhdl board
4158  
4159 -config ETRAXFS
4160 -       bool "ETRAX-FS-V32"
4161 +config FOXBONE_PWM
4162 +       bool "FOXBONE PWM module"
4163 +       depends on FOXBONE
4164         help
4165 -         Support CRIS V32.
4166 +       Include this to enable PWM support into the kernel
4167  
4168 -config ETRAXFS_SIM
4169 -       bool "ETRAX-FS-V32-Simulator"
4170 +config FOXBONE_EVENT
4171 +       bool "FOXBONE EVENT counter module"
4172 +       depends on FOXBONE
4173         help
4174 -         Support CRIS V32 VCS simualtor.
4175 +       Include this to enable foxbone event counter support
4176  
4177 -endchoice
4178 -
4179 -config ETRAX_ARCH_V10
4180 -       bool
4181 -       default y if ETRAX100LX || ETRAX100LX_V2
4182 -       default n if !(ETRAX100LX || ETRAX100LX_V2)
4183 -
4184 -config ETRAX_ARCH_V32
4185 -       bool
4186 -       default y if ETRAXFS || ETRAXFS_SIM
4187 -       default n if !(ETRAXFS || ETRAXFS_SIM) 
4188 -
4189 -config ETRAX_DRAM_SIZE
4190 -       int "DRAM size (dec, in MB)"
4191 -       default "8"
4192 +config FOXBONE_LOOPBACK
4193 +       bool "FOXBONE Loopback module"
4194 +       depends on FOXBONE
4195         help
4196 -         Size of DRAM (decimal in MB) typically 2, 8 or 16.
4197 +       Include this to be able to load the loopback module, that you can base your own driver on
4198  
4199 -config ETRAX_FLASH_BUSWIDTH
4200 -       int "Buswidth of NOR flash in bytes"
4201 -       default "2"
4202 +config FOXBONE_MULTIPLY
4203 +       bool "FOXBONE Multiplier example"
4204 +       depends on FOXBONE
4205         help
4206 -         Width in bytes of the NOR Flash bus (1, 2 or 4). Is usually 2.
4207 +       Include this to use the 64 bit multiplier
4208  
4209 -config ETRAX_NANDFLASH_BUSWIDTH
4210 -       int "Buswidth of NAND flash in bytes"
4211 -       default "1"
4212 -       help
4213 -         Width in bytes of the NAND flash (1 or 2).
4214 +menu "FOXBONE interrupt handlers"
4215 +config FOXBONE_SAMPLE_ISR
4216 +       bool "FOXBONE example interrupt handlers"
4217 +       depends on FOXBONE
4218 +       
4219 +config FOXBONE_INT14
4220 +       bool "Int 14 - bit 0 of reg 0x13 set"
4221 +       depends on FOXBONE_SAMPLE_ISR
4222  
4223 -config ETRAX_FLASH1_SIZE
4224 -       int "FLASH1 size (dec, in MB. 0 = Unknown)"
4225 -       default "0"
4226 +config FOXBONE_INT31
4227 +       bool "Int 31 - bit 1 of reg 0x13 set"
4228 +       depends on FOXBONE_SAMPLE_ISR
4229  
4230 -# arch/cris/arch is a symlink to correct arch (arch-v10 or arch-v32)
4231 -source arch/cris/arch/Kconfig
4232 +endmenu        
4233  
4234 -endmenu
4235 -
4236 -source "net/Kconfig"
4237 -
4238 -# bring in ETRAX built-in drivers
4239 -menu "Drivers for built-in interfaces"
4240 -# arch/cris/arch is a symlink to correct arch (arch-v10 or arch-v32)
4241 -source arch/cris/arch/drivers/Kconfig
4242  
4243 +config ETRAX_CMDLINE
4244 +       string "Kernel command line" 
4245 +       default "root=/dev/mtdblock3 init=/linuxrc console=ttyS0"
4246 +       help
4247 +       use if no framebuffer is enabled console=ttyS0
4248 +       use if framebuffer is enabled console=tty0
4249 +                                       
4250  endmenu
4251 -
4252 -source "drivers/base/Kconfig"
4253 -
4254 -# standard linux drivers
4255 -source "drivers/mtd/Kconfig"
4256 -
4257 -source "drivers/parport/Kconfig"
4258 -
4259 -source "drivers/pnp/Kconfig"
4260 -
4261 -source "drivers/block/Kconfig"
4262 -
4263 -source "drivers/md/Kconfig"
4264 -
4265 -source "drivers/ide/Kconfig"
4266 -
4267 -source "drivers/scsi/Kconfig"
4268 -
4269 -source "drivers/ieee1394/Kconfig"
4270 -
4271 -source "drivers/message/i2o/Kconfig"
4272 -
4273 -source "drivers/net/Kconfig"
4274 -
4275 -source "drivers/isdn/Kconfig"
4276 -
4277 -source "drivers/telephony/Kconfig"
4278 -
4279 -source "drivers/cdrom/Kconfig"
4280 -
4281 -#
4282 -# input before char - char/joystick depends on it. As does USB.
4283 -#
4284 -source "drivers/input/Kconfig"
4285 -
4286 -source "drivers/char/Kconfig"
4287 -
4288 -#source drivers/misc/Config.in
4289 -source "drivers/media/Kconfig"
4290 -
4291 -source "fs/Kconfig"
4292 -
4293 -source "sound/Kconfig"
4294 -
4295 -source "drivers/pcmcia/Kconfig"
4296 -
4297 -source "drivers/pci/Kconfig"
4298 -
4299 -source "drivers/usb/Kconfig"
4300 -
4301 -source "arch/cris/Kconfig.debug"
4302 -
4303 -source "security/Kconfig"
4304 -
4305 -source "crypto/Kconfig"
4306 -
4307 -source "lib/Kconfig"
4308 --- linux-2.6.19.2.orig/arch/cris/Kconfig       2007-06-16 23:58:14.000000000 +0200
4309 +++ linux-2.6.19.2/drivers/fox-vhdl/Kconfig     2007-06-17 02:46:15.000000000 +0200
4310 @@ -1,244 +1,274 @@
4311 -#
4312 -# For a description of the syntax of this configuration file,
4313 -# see the Configure script.
4314 -#
4315 +menu "Acmesystems FPGA"
4316  
4317 -mainmenu "Linux/CRIS Kernel Configuration"
4318 -
4319 -config MMU
4320 -       bool
4321 -       default y
4322 -
4323 -config RWSEM_GENERIC_SPINLOCK
4324 -       bool
4325 -       default y
4326 -
4327 -config RWSEM_XCHGADD_ALGORITHM
4328 -       bool
4329 -
4330 -config GENERIC_IOMAP
4331 -       bool
4332 -       default y
4333 -
4334 -config GENERIC_FIND_NEXT_BIT
4335 -       bool
4336 -       default y
4337 -
4338 -config GENERIC_HWEIGHT
4339 -       bool
4340 +config FOX_VHDL
4341 +       bool "Support for FOX-VHDL Board"
4342 +       default n
4343 +
4344 +config FOX_FPGA
4345 +       bool "FPGA flash module"
4346 +       depends on FOX_VHDL
4347 +       help
4348 +       Adds the module needed to flash the fpga from the FOX
4349 +
4350 +config FOXBONE
4351 +       bool "Basic FOXBONE support"
4352 +       depends on FOX_VHDL
4353 +       help
4354 +       Include this to get basic FOXBONE support
4355 +
4356 +config VT
4357 +       bool "Virtual terminal (needed for framebuffer)" if EMBEDDED
4358 +       select INPUT
4359 +       default y if !VIOCONS
4360 +       ---help---
4361 +         If you say Y here, you will get support for terminal devices with
4362 +         display and keyboard devices. These are called "virtual" because you
4363 +         can run several virtual terminals (also called virtual consoles) on
4364 +         one physical terminal. This is rather useful, for example one
4365 +         virtual terminal can collect system messages and warnings, another
4366 +         one can be used for a text-mode user session, and a third could run
4367 +         an X session, all in parallel. Switching between virtual terminals
4368 +         is done with certain key combinations, usually Alt-<function key>.
4369 +
4370 +         The setterm command ("man setterm") can be used to change the
4371 +         properties (such as colors or beeping) of a virtual terminal. The
4372 +         man page console_codes(4) ("man console_codes") contains the special
4373 +         character sequences that can be used to change those properties
4374 +         directly. The fonts used on virtual terminals can be changed with
4375 +         the setfont ("man setfont") command and the key bindings are defined
4376 +         with the loadkeys ("man loadkeys") command.
4377 +
4378 +         You need at least one virtual terminal device in order to make use
4379 +         of your keyboard and monitor. Therefore, only people configuring an
4380 +         embedded system would want to say N here in order to save some
4381 +         memory; the only way to log into such a system is then via a serial
4382 +         or network connection.
4383 +
4384 +         If unsure, say Y, or else you won't be able to do much with your new
4385 +         shiny Linux system :-)
4386 +
4387 +
4388 +menu "Framebuffer"     
4389 +depends on VT
4390 +
4391 +config FB
4392 +       bool "Support for frame buffer devices"
4393 +       depends on VT
4394 +       ---help---
4395 +         The frame buffer device provides an abstraction for the graphics
4396 +         hardware. It represents the frame buffer of some video hardware and
4397 +         allows application software to access the graphics hardware through
4398 +         a well-defined interface, so the software doesn't need to know
4399 +         anything about the low-level (hardware register) stuff.
4400 +
4401 +         Frame buffer devices work identically across the different
4402 +         architectures supported by Linux and make the implementation of
4403 +         application programs easier and more portable; at this point, an X
4404 +         server exists which uses the frame buffer device exclusively.
4405 +         On several non-X86 architectures, the frame buffer device is the
4406 +         only way to use the graphics hardware.
4407 +
4408 +         The device is accessed through special device nodes, usually located
4409 +         in the /dev directory, i.e. /dev/fb*.
4410 +
4411 +         You need an utility program called fbset to make full use of frame
4412 +         buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
4413 +         and the Framebuffer-HOWTO at
4414 +         <http://www.tahallah.demon.co.uk/programming/prog.html> for more
4415 +         information.
4416 +
4417 +         Say Y here and to the driver for your graphics board below if you
4418 +         are compiling a kernel for a non-x86 architecture.
4419 +
4420 +         If you are compiling for the x86 architecture, you can say Y if you
4421 +         want to play with it, but it is not essential. Please note that
4422 +         running graphical applications that directly touch the hardware
4423 +         (e.g. an accelerated X server) and that are not frame buffer
4424 +         device-aware may cause unexpected results. If unsure, say N.
4425 +
4426 +config FB_CFB_FILLRECT
4427 +       tristate
4428 +       depends on FB
4429 +       default n
4430 +       ---help---
4431 +         Include the cfb_fillrect function for generic software rectangle
4432 +         filling. This is used by drivers that don't provide their own
4433 +         (accelerated) version.
4434 +
4435 +config FB_CFB_COPYAREA
4436 +       tristate
4437 +       depends on FB
4438 +       default n
4439 +       ---help---
4440 +         Include the cfb_copyarea function for generic software area copying.
4441 +         This is used by drivers that don't provide their own (accelerated)
4442 +         version.
4443 +
4444 +config FB_CFB_IMAGEBLIT
4445 +       tristate
4446 +       depends on FB
4447 +       default n
4448 +       ---help---
4449 +         Include the cfb_imageblit function for generic software image
4450 +         blitting. This is used by drivers that don't provide their own
4451 +         (accelerated) version.
4452 +config DUMMY_CONSOLE
4453 +       bool "Dummy Console"
4454 +       depends on FB
4455 +       #PROM_CONSOLE!=y || VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y 
4456 +       default n
4457 +
4458 +config FRAMEBUFFER_CONSOLE
4459 +       bool "Framebuffer Console support"
4460 +       depends on FB
4461 +       select CRC32
4462 +       help
4463 +         Low-level framebuffer-based console driver.
4464 +config LOGO
4465 +       bool "Bootup logo"
4466 +       depends on FB || SGI_NEWPORT_CONSOLE
4467 +       help
4468 +         Enable and select frame buffer bootup logos.
4469 +
4470 +config LOGO_LINUX_CLUT224
4471 +       bool "Standard 224-color Linux logo"
4472 +       depends on LOGO
4473         default y
4474 -
4475 -config GENERIC_CALIBRATE_DELAY
4476 -       bool
4477 -       default y
4478 -
4479 -config IRQ_PER_CPU
4480 -       bool
4481 -       default y
4482 -
4483 -config CRIS
4484 -       bool
4485 -       default y
4486 -
4487 -source "init/Kconfig"
4488 -
4489 -menu "General setup"
4490 -
4491 -source "fs/Kconfig.binfmt"
4492 -
4493 -config GENERIC_HARDIRQS
4494 -       bool
4495 -       default y
4496 -
4497 -config SMP
4498 -       bool "SMP"
4499 -       help
4500 -         SMP support. Always Say N.
4501 -
4502 -config NR_CPUS
4503 -       int
4504 -       depends on SMP
4505 -       default 2
4506 -
4507 -config SCHED_MC
4508 -       bool "Multi-core scheduler support"
4509 -       depends on SMP
4510 -       default y
4511 -       help
4512 -         Multi-core scheduler support improves the CPU scheduler's decision
4513 -         making when dealing with multi-core CPU chips at a cost of slightly
4514 -         increased overhead in some places. If unsure say N here.
4515 -
4516 -config ETRAX_CMDLINE
4517 -       string "Kernel command line"
4518 -       default "root=/dev/mtdblock3"
4519 -       help
4520 -         Pass additional commands to the kernel.
4521 -
4522 -config ETRAX_WATCHDOG
4523 -       bool "Enable ETRAX watchdog"
4524 -       help
4525 -         Enable the built-in watchdog timer support on ETRAX based embedded
4526 -         network computers.
4527 -
4528 -config ETRAX_WATCHDOG_NICE_DOGGY
4529 -       bool "Disable watchdog during Oops printouts"
4530 -       depends on ETRAX_WATCHDOG
4531 -       help
4532 -         By enabling this you make sure that the watchdog does not bite while
4533 -         printing oopses. Recommended for development systems but not for
4534 -         production releases.
4535 -
4536 -config ETRAX_FAST_TIMER
4537 -       bool "Enable ETRAX fast timer API"
4538 -       help
4539 -         This options enables the API to a fast timer implementation using
4540 -        timer1 to get sub jiffie resolution timers (primarily one-shot
4541 -        timers).
4542 -        This is needed if CONFIG_ETRAX_SERIAL_FAST_TIMER is enabled.
4543 -
4544 -config OOM_REBOOT
4545 -       bool "Enable reboot at out of memory"
4546 -
4547 -source "kernel/Kconfig.preempt"
4548 -source "kernel/Kconfig.sched"
4549 -
4550 -source mm/Kconfig
4551 +config FONTS
4552 +       bool "Select compiled-in fonts"
4553 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
4554 +       help
4555 +         Say Y here if you would like to use fonts other than the default
4556 +         your frame buffer console usually use.
4557 +
4558 +         Note that the answer to this question won't directly affect the
4559 +         kernel: saying N will just cause the configurator to skip all
4560 +         the questions about foreign fonts.
4561 +
4562 +         If unsure, say N (the default choices are safe).
4563 +
4564 +config FONT_8x8
4565 +       bool "VGA 8x8 font" if FONTS
4566 +       depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
4567 +       default y if !SPARC && !FONTS
4568 +       help
4569 +         This is the "high resolution" font for the VGA frame buffer (the one
4570 +         provided by the text console 80x50 (and higher) modes).
4571 +
4572 +         Note that this is a poor quality font. The VGA 8x16 font is quite a
4573 +         lot more readable.
4574 +
4575 +         Given the resolution provided by the frame buffer device, answer N
4576 +         here is safe.
4577 +
4578 +config FONT_8x16
4579 +       bool "VGA 8x16 font" if FONTS
4580 +       depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON 
4581 +       default y if !SPARC && !FONTS
4582 +       help
4583 +         This is the "high resolution" font for the VGA frame buffer (the one
4584 +         provided by the VGA text console 80x25 mode.
4585 +
4586 +         If unsure, say Y.
4587 +
4588 +
4589 +config FOX_VHDL_FB
4590 +        bool "FOX_VHDL Framebuffer"
4591 +       depends on FOXBONE
4592 +       depends on FB
4593 +       select FB_CFB_FILLRECT
4594 +       select FB_CFB_COPYAREA
4595 +       select FB_CFB_IMAGEBLIT                         
4596 +       select VT_CONSOLE
4597 +       select DUMMY_CONSOLE
4598 +       select FRAMEBUFFER_CONSOLE
4599 +       select FONTS
4600 +       select LOGO
4601 +       select LOGO_LINUX_CLUT224
4602 +
4603 +config NANOXKBD
4604 +       bool "nano-X keyboard support"
4605 +       default n
4606 +       depends on FOX_VHDL_FB
4607 +       help 
4608 +       Enable the keyboard driver patches for nano-X
4609 +
4610 +
4611 +
4612 +#if FOX_VHDL_FB
4613 +       #source "drivers/video/console/Kconfig"
4614 +#endif
4615 +
4616 +#if FOX_VHDL_FB 
4617 +#      source "drivers/video/logo/Kconfig"
4618 +#endif
4619  
4620  endmenu
4621  
4622 -menu "Hardware setup"
4623 -
4624 -choice
4625 -       prompt "Processor type"
4626 -       default ETRAX100LX
4627  
4628 -config ETRAX100LX
4629 -       bool "ETRAX-100LX-v1"
4630 +config FOXBONE_IO
4631 +       bool "FOXBONE I/O pins"
4632 +       depends on FOXBONE
4633         help
4634 -         Support version 1 of the ETRAX 100LX.
4635 +       Include this to get access to the I/O pins of the foxbone
4636  
4637 -config ETRAX100LX_V2
4638 -       bool "ETRAX-100LX-v2"
4639 +config FOXBONE_TIMEBASE
4640 +       bool "FOXBONE Timebase"
4641 +       depends on FOXBONE
4642         help
4643 -         Support version 2 of the ETRAX 100LX.
4644 +       Include this to get access to the timebase part of the fpga
4645  
4646 -config SVINTO_SIM
4647 -       bool "ETRAX-100LX-for-xsim-simulator"
4648 +config FOXBONE_MMC
4649 +       bool "FOXBONE MMC/SD module"
4650 +       depends on FOXBONE
4651         help
4652 -         Support the xsim ETRAX Simulator.
4653 +       Include this to be able to access a mmc/sd card connected to J3 of the fox-vhdl board
4654  
4655 -config ETRAXFS
4656 -       bool "ETRAX-FS-V32"
4657 +config FOXBONE_PWM
4658 +       bool "FOXBONE PWM module"
4659 +       depends on FOXBONE
4660         help
4661 -         Support CRIS V32.
4662 +       Include this to enable PWM support into the kernel
4663  
4664 -config ETRAXFS_SIM
4665 -       bool "ETRAX-FS-V32-Simulator"
4666 +config FOXBONE_EVENT
4667 +       bool "FOXBONE EVENT counter module"
4668 +       depends on FOXBONE
4669         help
4670 -         Support CRIS V32 VCS simualtor.
4671 +       Include this to enable foxbone event counter support
4672  
4673 -endchoice
4674 -
4675 -config ETRAX_ARCH_V10
4676 -       bool
4677 -       default y if ETRAX100LX || ETRAX100LX_V2
4678 -       default n if !(ETRAX100LX || ETRAX100LX_V2)
4679 -
4680 -config ETRAX_ARCH_V32
4681 -       bool
4682 -       default y if ETRAXFS || ETRAXFS_SIM
4683 -       default n if !(ETRAXFS || ETRAXFS_SIM) 
4684 -
4685 -config ETRAX_DRAM_SIZE
4686 -       int "DRAM size (dec, in MB)"
4687 -       default "8"
4688 +config FOXBONE_LOOPBACK
4689 +       bool "FOXBONE Loopback module"
4690 +       depends on FOXBONE
4691         help
4692 -         Size of DRAM (decimal in MB) typically 2, 8 or 16.
4693 +       Include this to be able to load the loopback module, that you can base your own driver on
4694  
4695 -config ETRAX_FLASH_BUSWIDTH
4696 -       int "Buswidth of NOR flash in bytes"
4697 -       default "2"
4698 +config FOXBONE_MULTIPLY
4699 +       bool "FOXBONE Multiplier example"
4700 +       depends on FOXBONE
4701         help
4702 -         Width in bytes of the NOR Flash bus (1, 2 or 4). Is usually 2.
4703 +       Include this to use the 64 bit multiplier
4704  
4705 -config ETRAX_NANDFLASH_BUSWIDTH
4706 -       int "Buswidth of NAND flash in bytes"
4707 -       default "1"
4708 -       help
4709 -         Width in bytes of the NAND flash (1 or 2).
4710 +menu "FOXBONE interrupt handlers"
4711 +config FOXBONE_SAMPLE_ISR
4712 +       bool "FOXBONE example interrupt handlers"
4713 +       depends on FOXBONE
4714 +       
4715 +config FOXBONE_INT14
4716 +       bool "Int 14 - bit 0 of reg 0x13 set"
4717 +       depends on FOXBONE_SAMPLE_ISR
4718  
4719 -config ETRAX_FLASH1_SIZE
4720 -       int "FLASH1 size (dec, in MB. 0 = Unknown)"
4721 -       default "0"
4722 +config FOXBONE_INT31
4723 +       bool "Int 31 - bit 1 of reg 0x13 set"
4724 +       depends on FOXBONE_SAMPLE_ISR
4725  
4726 -# arch/cris/arch is a symlink to correct arch (arch-v10 or arch-v32)
4727 -source arch/cris/arch/Kconfig
4728 +endmenu        
4729  
4730 -endmenu
4731 -
4732 -source "net/Kconfig"
4733 -
4734 -# bring in ETRAX built-in drivers
4735 -menu "Drivers for built-in interfaces"
4736 -# arch/cris/arch is a symlink to correct arch (arch-v10 or arch-v32)
4737 -source arch/cris/arch/drivers/Kconfig
4738  
4739 +config ETRAX_CMDLINE
4740 +       string "Kernel command line" 
4741 +       default "root=/dev/mtdblock3 init=/linuxrc console=ttyS0"
4742 +       help
4743 +       use if no framebuffer is enabled console=ttyS0
4744 +       use if framebuffer is enabled console=tty0
4745 +                                       
4746  endmenu
4747 -
4748 -source "drivers/base/Kconfig"
4749 -
4750 -# standard linux drivers
4751 -source "drivers/mtd/Kconfig"
4752 -
4753 -source "drivers/parport/Kconfig"
4754 -
4755 -source "drivers/pnp/Kconfig"
4756 -
4757 -source "drivers/block/Kconfig"
4758 -
4759 -source "drivers/md/Kconfig"
4760 -
4761 -source "drivers/ide/Kconfig"
4762 -
4763 -source "drivers/scsi/Kconfig"
4764 -
4765 -source "drivers/ieee1394/Kconfig"
4766 -
4767 -source "drivers/message/i2o/Kconfig"
4768 -
4769 -source "drivers/net/Kconfig"
4770 -
4771 -source "drivers/isdn/Kconfig"
4772 -
4773 -source "drivers/telephony/Kconfig"
4774 -
4775 -source "drivers/cdrom/Kconfig"
4776 -
4777 -#
4778 -# input before char - char/joystick depends on it. As does USB.
4779 -#
4780 -source "drivers/input/Kconfig"
4781 -
4782 -source "drivers/char/Kconfig"
4783 -
4784 -#source drivers/misc/Config.in
4785 -source "drivers/media/Kconfig"
4786 -
4787 -source "fs/Kconfig"
4788 -
4789 -source "sound/Kconfig"
4790 -
4791 -source "drivers/pcmcia/Kconfig"
4792 -
4793 -source "drivers/pci/Kconfig"
4794 -
4795 -source "drivers/usb/Kconfig"
4796 -
4797 -source "arch/cris/Kconfig.debug"
4798 -
4799 -source "security/Kconfig"
4800 -
4801 -source "crypto/Kconfig"
4802 -
4803 -source "lib/Kconfig"
4804 --- linux-2.6.19.2.orig/arch/cris/Kconfig       2007-06-16 23:58:14.000000000 +0200
4805 +++ linux-2.6.19.2/arch/cris/Kconfig    2007-06-17 02:52:11.000000000 +0200
4806 @@ -242,3 +242,6 @@
4807  source "crypto/Kconfig"
4808  
4809  source "lib/Kconfig"
4810 +menu "Acmesystems"
4811 +source "drivers/fox-vhdl/Kconfig"
4812 +endmenu
4813 79a80
4814 > obj-$(CONFIG_FOX_VHDL) += fox-vhdl/
4815 diff -urN linux-2.6.19.2.orig/include/linux/foxbone_syscalls.h linux-2.6.19.2/include/linux/foxbone_syscalls.h
4816 --- linux-2.6.19.2.orig/include/linux/foxbone_syscalls.h        1970-01-01 01:00:00.000000000 +0100
4817 +++ linux-2.6.19.2/include/linux/foxbone_syscalls.h     2007-06-17 03:31:39.000000000 +0200
4818 @@ -0,0 +1,18 @@
4819 +#ifndef __LINUX_SYSCALL_FOXBONE
4820 +#define __LINUX_SYSCALL_FOXBONE
4821 +#include <linux/autoconf.h>
4822 +#include <linux/kernel.h>
4823 +#include <linux/errno.h>
4824 +#include <asm/unistd.h>
4825 +
4826 +extern int errno;
4827 +_syscall1(void, foxbonereset, unsigned short int, reg);
4828 +_syscall1(unsigned short int, foxboneread, unsigned short int, reg);
4829 +_syscall2(void, foxbonewrite, unsigned short int, reg, unsigned short int, value);
4830 +_syscall3(void, foxbonebulkread, unsigned short int, reg, unsigned short int *, value, unsigned int, length);
4831 +_syscall3(void, foxbonebulkwrite, unsigned short int, reg, unsigned short int *, value, unsigned int, length);  
4832 +_syscall2(void, foxboneintreg, unsigned long int, interrupt, unsigned char, state);
4833 +_syscall1(unsigned int, foxboneintcheck, unsigned long int, interrupt);
4834 +_syscall2(unsigned int, foxboneintwait, unsigned long int, interrupt, unsigned char, timeout);
4835 +
4836 +#endif