Fix the AR7 led driver compilation (#2160)
[openwrt.git] / target / linux / rdc-2.6 / patches / 000-rdc_fixes.patch
1 diff -urN linux-2.6.19/arch/i386/Kconfig linux-2.6.19.new/arch/i386/Kconfig
2 --- linux-2.6.19/arch/i386/Kconfig 2006-11-29 22:57:37.000000000 +0100
3 +++ linux-2.6.19.new/arch/i386/Kconfig 2006-12-17 17:13:33.000000000 +0100
4 @@ -180,6 +180,14 @@
5 Only choose this option if you have such a system, otherwise you
6 should say N here.
7
8 +config X86_RDC
9 + bool "Support for RDC 3211 boards"
10 + help
11 + Support for RDC 3211 systems. Say 'Y' here if the kernel is
12 + supposed to run on an IA-32 RDC R3211 system.
13 + Only choose this option if you have such as system, otherwise you
14 + should say N here.
15 +
16 endchoice
17
18 config ACPI_SRAT
19 diff -urN linux-2.6.19/arch/i386/Makefile linux-2.6.19.new/arch/i386/Makefile
20 --- linux-2.6.19/arch/i386/Makefile 2006-11-29 22:57:37.000000000 +0100
21 +++ linux-2.6.19.new/arch/i386/Makefile 2006-12-17 17:13:33.000000000 +0100
22 @@ -92,6 +92,10 @@
23 mflags-$(CONFIG_X86_ES7000) := -Iinclude/asm-i386/mach-es7000
24 mcore-$(CONFIG_X86_ES7000) := mach-default
25 core-$(CONFIG_X86_ES7000) := arch/i386/mach-es7000/
26 +# RDC subarch support
27 +mflags-$(CONFIG_X86_RDC) := -Iinclude/asm-i386/mach-generic
28 +mcore-$(CONFIG_X86_RDC) := mach-default
29 +core-$(CONFIG_X86_RDC) += arch/i386/mach-rdc/
30
31 # default subarch .h files
32 mflags-y += -Iinclude/asm-i386/mach-default
33 diff -urN linux-2.6.19/arch/i386/mach-rdc/Makefile linux-2.6.19.new/arch/i386/mach-rdc/Makefile
34 --- linux-2.6.19/arch/i386/mach-rdc/Makefile 1970-01-01 01:00:00.000000000 +0100
35 +++ linux-2.6.19.new/arch/i386/mach-rdc/Makefile 2006-12-17 17:13:33.000000000 +0100
36 @@ -0,0 +1,5 @@
37 +#
38 +# Makefile for the linux kernel.
39 +#
40 +
41 +obj-$(CONFIG_X86_RDC) := led.o
42 diff -urN linux-2.6.19/arch/i386/mach-rdc/led.c linux-2.6.19.new/arch/i386/mach-rdc/led.c
43 --- linux-2.6.19/arch/i386/mach-rdc/led.c 1970-01-01 01:00:00.000000000 +0100
44 +++ linux-2.6.19.new/arch/i386/mach-rdc/led.c 2006-12-17 17:13:33.000000000 +0100
45 @@ -0,0 +1,743 @@
46 +/*
47 + * LED interface for WP3200
48 + *
49 + * Copyright (C) 2002, by Allen Hung
50 + *
51 + */
52 +
53 +#include <linux/types.h>
54 +#include <linux/errno.h>
55 +#include <linux/ioport.h>
56 +#include <linux/fcntl.h>
57 +#include <linux/sched.h>
58 +#include <linux/module.h>
59 +#include <linux/proc_fs.h>
60 +#include <linux/init.h>
61 +#include <linux/timer.h>
62 +#include <asm/io.h>
63 +#include <asm/uaccess.h>
64 +#include <asm/system.h>
65 +#include <linux/reboot.h>
66 +
67 +#include "led.h"
68 +
69 +#define BUF_LEN 30
70 +
71 +struct LED_DATA {
72 + char sts_buf[BUF_LEN+1];
73 + unsigned long sts;
74 +};
75 +
76 +struct LED_DATA led_data[LED_DEV_NUM];
77 +// sam
78 +unsigned long ul_ledstat = 0xffffffff;
79 +
80 +
81 +static struct timer_list blink_timer[LED_DEV_NUM];
82 +// sam 01-30-2004 for watchdog
83 +static struct timer_list watchdog;
84 +// end sam
85 +static char cmd_buf[BUF_LEN+1];
86 +
87 +//------------------------------------------------------------
88 +static long atoh(char *p)
89 +{
90 + long v = 0, c;
91 + while ( (c = *p++) ) {
92 + if ( c >= '0' && c <= '9' ) v = (v << 4) + c - '0';
93 + else if ( c >= 'a' && c <= 'f' ) v = (v << 4) + c - 'a' + 0xA;
94 + else if ( c >= 'A' && c <= 'F' ) v = (v << 4) + c - 'A' + 0xA;
95 + else break;
96 + }
97 + return v;
98 +}
99 +
100 +static int reset_flash_default(void *data)
101 +{
102 + char *argv[3], *envp[1] = {NULL};
103 + int i = 0;
104 +
105 + int reset_default=(int) data;
106 +
107 + argv[i++] = "/bin/flash";
108 + argv[i++] = "default";
109 + argv[i] = NULL;
110 + if(reset_default)
111 + if (call_usermodehelper(argv[0], argv, envp, 1))
112 + printk("failed to Reset to default\n");
113 + machine_restart(0);
114 + return 0;
115 +}
116 +
117 +// sam for ps 3205U -- using CSx1 (0xb0e00000)
118 +// bit map as following
119 +// BIT 1 2 3 4 5
120 +// POWER WLEN PORT1 PORT2 PORT3
121 +//
122 +// value 0 --> led on
123 +// value 1 --> led off
124 +
125 +#define _ROUTER_
126 +
127 +#ifdef _ROUTER_
128 + #define LED_VAL 0x8000384C // the data ofset of gpio 0~30
129 +#else
130 + #define LED_VAL 0x80003888 // the ofset of gpio 31~58
131 +#endif
132 +#define GPIO_VAL 0x8000384C // the offset of gpio 0-30
133 +
134 +
135 +
136 +// sam 1-30-2004 LED status
137 +// bit map as following
138 +// BIT 4:0 Link status -->PHY Link ->1 = up, 0 = down
139 +#define LINK_STATUS (*(unsigned long *)0xb2000014)
140 +#define WATCHDOG_VAL (*(unsigned long *)0xb20000c0)
141 +#define WATCHDOG_PERIOD 500 // unit ms
142 +#define EXPIRE_TIME 300 // unit 10 ms
143 +#define CLEAR_TIMEER 0xffffa000l // bit 14:0 -> count up timer, write 0 to clear
144 +#define ENABLE_WATCHDOG 0x80000000l // bit 31 -> 1 enable , 0 disable watchdog
145 +#define WATCHDOG_SET_TMR_SHIFT 16 // bit 16:30 -> watchdog timer set
146 +// end sam
147 +
148 +
149 +//------------------------------------------------------------
150 +static void turn_led(int id, int on)
151 +{
152 + unsigned long led_bit = 1 << (id);
153 + unsigned long led_bit_val;
154 +
155 + // since we define we have 8 led devices and use gpio 53, 55, 57, 58
156 + // which locate at bit21~26, so we rotate left 20bit
157 +
158 +#ifdef _ROUTER_
159 + led_bit_val = led_bit;
160 +#else
161 + led_bit_val = led_bit << 20;
162 +#endif
163 +
164 + switch ( on ) {
165 + case 0:
166 + ul_ledstat|= led_bit_val;
167 + outl(LED_VAL, 0xcf8);
168 + outl(ul_ledstat, 0xcfc);
169 + break; // LED OFF
170 + case 1:
171 + ul_ledstat &= ~led_bit_val;
172 + outl(LED_VAL, 0xcf8);
173 + outl(ul_ledstat, 0xcfc);
174 + break; // LED ON
175 + case 2:
176 + ul_ledstat ^= led_bit_val;
177 + outl(LED_VAL, 0xcf8);
178 + outl(ul_ledstat, 0xcfc);
179 + break; // LED inverse
180 + }
181 +}
182 +
183 +
184 +static int led_flash[30]={20,10,100,5,5,150,100,5,5,50,20,50,50,20,60,5,20,10,30,10,5,10,50,2,5,5,5,70,10,50};//Erwin
185 +static unsigned int wlan_counter; //Erwin
186 +static void blink_wrapper(u_long id)
187 +{
188 + u_long sts = led_data[id].sts;
189 +
190 + if ( (sts & LED_BLINK_CMD) == LED_BLINK_CMD ) {
191 + unsigned long period = sts & LED_BLINK_PERIOD;
192 + if(period == 0xffff) // BLINK random
193 + {
194 + blink_timer[id].expires = jiffies + 3*led_flash[wlan_counter%30]*HZ/1000;
195 + wlan_counter++;
196 + }
197 + else
198 + blink_timer[id].expires = jiffies + (period * HZ / 1000);
199 + turn_led(id, 2);
200 + add_timer(&blink_timer[id]);
201 + }
202 + else if ( sts == LED_ON || sts == LED_OFF )
203 + turn_led(id, sts==LED_ON ? 1 : 0);
204 +}
205 +//------------------------------------------------------------
206 +static void get_token_str(char *str, char token[][21], int token_num)
207 +{
208 + int t, i;
209 +
210 + for ( t = 0 ; t < token_num ; t++ ) {
211 + memset(token[t], 0, 21);
212 + while ( *str == ' ' ) str++;
213 + for ( i = 0 ; str[i] ; i++ ) {
214 + if ( str[i] == '\t' || str[i] == ' ' || str[i] == '\n' ) break;
215 + if ( i < 20 ) token[t][i] = str[i];
216 + }
217 + str += i;
218 + }
219 +}
220 +
221 +//------------------------------------------------------------
222 +static void set_led_status_by_str(int id)
223 +{
224 + char token[3][21], *p;
225 +
226 +
227 + get_token_str(led_data[id].sts_buf, token, 3);
228 +
229 + if ( strcmp(token[0], "LED") )
230 + {
231 + goto set_led_off;
232 + }
233 + if ( !strcmp(token[1], "ON") )
234 + {
235 +
236 + turn_led(id, 1);
237 + led_data[id].sts = LED_ON;
238 + }
239 + else if ( !strcmp(token[1], "OFF") )
240 + {
241 +
242 + goto set_led_off;
243 + }
244 + else if ( !strcmp(token[1], "BLINK") )
245 + {
246 + unsigned int period = 0;
247 + p = token[2];
248 + if ( !strcmp(p, "FAST") )
249 + period = LED_BLINK_FAST & LED_BLINK_PERIOD;
250 + else if ( !strcmp(p, "SLOW") )
251 + period = LED_BLINK_SLOW & LED_BLINK_PERIOD;
252 + else if ( !strcmp(p, "EXTRA_SLOW") )
253 + period = LED_BLINK_EXTRA_SLOW & LED_BLINK_PERIOD;
254 + else if ( !strcmp(p, "RANDOM") )
255 + period = LED_BLINK_RANDOM & LED_BLINK_PERIOD;
256 + else if ( !strcmp(p, "OFF") )
257 + goto set_led_off;
258 + else if ( *p >= '0' && *p <= '9' )
259 + {
260 + while ( *p >= '0' && *p <= '9' )
261 + period = period * 10 + (*p++) - '0';
262 +// if ( period > 10000 )
263 +// period = 10000;
264 + }
265 + else
266 + period = LED_BLINK & LED_BLINK_PERIOD;
267 +
268 + if ( period == 0 )
269 + goto set_led_off;
270 +
271 + sprintf(led_data[id].sts_buf, "LED BLINK %d\n", period);
272 + led_data[id].sts = LED_BLINK_CMD + period;
273 + turn_led(id, 2);
274 + // Set timer for next blink
275 + del_timer(&blink_timer[id]);
276 + blink_timer[id].function = blink_wrapper;
277 + blink_timer[id].data = id;
278 + init_timer(&blink_timer[id]);
279 +
280 + blink_timer[id].expires = jiffies + (1000 * HZ / 1000);
281 +
282 + add_timer(&blink_timer[id]);
283 + }
284 + else
285 + {
286 + goto set_led_off;
287 + }
288 + return;
289 + set_led_off:
290 + strcpy(led_data[id].sts_buf, "LED OFF\n");
291 + led_data[id].sts = LED_OFF;
292 + turn_led(id, 0);
293 +}
294 +
295 +//----------------------------------------------------------------------
296 +static int led_read_proc(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
297 +{
298 + int len, dev;
299 +
300 + for ( len = dev = 0 ; dev < LED_DEV_NUM ; dev++ ) {
301 + len += sprintf(buf+len, "%d: %s", dev, led_data[dev].sts_buf);
302 + }
303 + len = strlen(buf) - fpos;
304 + if ( len <= 0 ) {
305 + *start = buf;
306 + *eof = 1;
307 + return 0;
308 + }
309 + *start = buf + fpos;
310 + if ( len <= length ) *eof = 1;
311 + return len < length ? len : length;
312 +}
313 +
314 +//----------------------------------------------------------------------
315 +static int led_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
316 +{
317 + int id = (int)file->private_data;
318 +
319 + switch ( cmd ) {
320 + case LED_ON:
321 + strcpy(led_data[id].sts_buf, "LED ON\n");
322 + set_led_status_by_str(id);
323 + break;
324 + case LED_OFF:
325 + strcpy(led_data[id].sts_buf, "LED OFF\n");
326 + set_led_status_by_str(id);
327 + break;
328 + default:
329 + if ( (cmd & LED_BLINK_CMD) != LED_BLINK_CMD )
330 + {
331 + break;
332 + }
333 + case LED_BLINK:
334 + case LED_BLINK_FAST:
335 + case LED_BLINK_SLOW:
336 + case LED_BLINK_EXTRA_SLOW:
337 + case LED_BLINK_RANDOM:
338 + sprintf(led_data[id].sts_buf, "LED BLINK %d\n", (int)(cmd & LED_BLINK_PERIOD));
339 + set_led_status_by_str(id);
340 + break;
341 + }
342 + return 0;
343 +}
344 +
345 +static int led_open(struct inode *inode, struct file *file)
346 +{
347 + int led_id = MINOR(inode->i_rdev);
348 +// unsigned long led_bit = 1 << (led_id);
349 +
350 + if ( led_id >= LED_DEV_NUM )
351 + return -ENODEV;
352 +/* sam 12/02/2003
353 + GPIO_SEL_I_O &= ~led_bit; // 0 to GPIO
354 + GPIO_O_EN |= (led_bit << 16); // 0 to Output
355 +*/
356 +
357 + file->private_data = (void*)led_id;
358 + return 0;
359 +}
360 +
361 +static long led_read(struct file *file, char *buf, size_t count, loff_t *fpos)
362 +{
363 + int rem, len;
364 + int id = (int)file->private_data;
365 + char *p = led_data[id].sts_buf;
366 +
367 + len = strlen(p);
368 + rem = len - *fpos;
369 + if ( rem <= 0 ) {
370 + *fpos = len;
371 + return 0;
372 + }
373 + if ( rem > count ) rem = count;
374 + memcpy(buf, p+(*fpos), rem);
375 + *fpos += rem;
376 + return rem;
377 +}
378 +
379 +static long led_write(struct file *file, char *buf, size_t count, loff_t *fpos)
380 +{
381 + int len;
382 + int id = (int)file->private_data;
383 + char *p = id == REG_MINOR ? cmd_buf : led_data[id].sts_buf;
384 + memset(p, 0, BUF_LEN);
385 +
386 + p += *fpos;
387 + len = 0;
388 +
389 +
390 + while ( count > 0 )
391 + {
392 +
393 + if ( *fpos < BUF_LEN )
394 + {
395 + int c = *buf++;
396 + p[len] = c>='a' && c<='z' ? c-'a'+'A' : c;
397 + }
398 + (*fpos)++;
399 + len++;
400 + count--;
401 + }
402 + // sam
403 + set_led_status_by_str(id);
404 + (*fpos) = 0;
405 + //
406 +
407 + return len;
408 +}
409 +
410 +static int led_flush(struct file *file)
411 +{
412 + int id = (int)file->private_data;
413 +
414 + if ( file->f_mode & FMODE_WRITE )
415 + {
416 + set_led_status_by_str(id);
417 + }
418 + return 0;
419 +}
420 +
421 +static struct file_operations led_fops = {
422 + read: led_read,
423 + write: led_write,
424 + flush: led_flush,
425 + ioctl: led_ioctl,
426 + open: led_open,
427 +};
428 +
429 +//----------------------------------------------
430 +static unsigned long *reg_addr;
431 +static int dump_len;
432 +
433 +static int dump_content(char *buf)
434 +{
435 + return 0;
436 +}
437 +
438 +static long gpio_read(struct file *file, char *buf, size_t count, loff_t *fpos)
439 +{
440 + int rem, len;
441 + int id = (int)file->private_data;
442 + char temp[80*10];
443 + unsigned long gpio_regval =0;
444 +
445 + outl(GPIO_VAL, 0xcf8);
446 + gpio_regval = inl(0xcfc);
447 + gpio_regval |= 0x40;
448 + outl(gpio_regval, 0xcfc); // each in, need out 1 first
449 + gpio_regval = inl(0xcfc);
450 +
451 +
452 + // sam debug
453 + //printk(KERN_ERR "gpio_id:%d, gpio_regval:%08X\n", id, gpio_regval);
454 + //end sam
455 +
456 + if ( id < GPIO_DEV_NUM ) {
457 + int gpio_bit = 1 << id;
458 +
459 + len = sprintf(temp, "%d\n", (gpio_regval & gpio_bit) ? 1 : 0);
460 + }
461 + else // REG device
462 + len = dump_content(temp);
463 + rem = len - *fpos;
464 + if ( rem <= 0 ) {
465 + *fpos = len;
466 + return 0;
467 + }
468 + if ( rem > count ) rem = count;
469 + memcpy(buf, temp+(*fpos), rem);
470 + *fpos += rem;
471 + return rem;
472 +}
473 +
474 +static int gpio_flush(struct file *file)
475 +{
476 + return 0;
477 +}
478 +
479 +static int gpio_open(struct inode *inode, struct file *file)
480 +{
481 + int id = MINOR(inode->i_rdev);
482 + if ( id >= GPIO_DEV_NUM && id != REG_MINOR )
483 + return -ENODEV;
484 + file->private_data = (void*)id;
485 + return 0;
486 +}
487 +
488 +static struct file_operations gpio_fops = {
489 + read: gpio_read,
490 + open: gpio_open,
491 + flush: gpio_flush,
492 + write: led_write,
493 +};
494 +
495 +// ---------------------------------------------
496 +// sam 1-30-2004 LAN_STATUS Device
497 +
498 +//static unsigned long *reg_addr;
499 +//static int dump_len;
500 +
501 +//static int lanSt_content(char *buf)
502 +//{
503 +// int i, j, len;
504 +// unsigned long *p = (unsigned long *)0xb2000014; // PHY_ST
505 +// // j = dump_len/4 + ((dump_len&3) ? 1 : 0);
506 +// len = sprintf(buf, "Reg Addr = %08lX, Value = \n", (unsigned long)p);
507 +// // for ( i = 0 ; i < j ; i++, p++ )
508 +// len += sprintf(buf+len,"%08lX\n", *p);
509 +
510 +// return len;
511 +//}
512 +
513 +#define MAC_IOBASE 0xe800 // Eth0
514 +#define PHY_ADDR 1 // For Eth0
515 +#define MII_STATUS_ADDR 1
516 +// where "id" value means which bit of PHY reg 1 we want to check
517 +static long lanSt_read(struct file *file, char *buf, size_t count, loff_t *fpos)
518 +{
519 + int rem, len;
520 +// unsigned long *p = (unsigned long *)0xb2000014; // PHY_ST
521 + unsigned short status;
522 + unsigned int i = 0;
523 + int id = (int)file->private_data;
524 + char temp[80*10];
525 +
526 + outw(0x2000 + MII_STATUS_ADDR + (PHY_ADDR << 8), MAC_IOBASE + 0x20);
527 + do{}while( (i++ < 2048) && (inw(MAC_IOBASE+0x20) & 0x2000) );
528 +
529 + status = inw(MAC_IOBASE + 0x24);
530 +
531 + // sam debug
532 + //printk(KERN_ERR "PHY REG1 Status:%04x\n", status );
533 + // end sam
534 +
535 + if ( id < LAN_DEV_NUM ) {
536 + unsigned long lanSt_bit = 1 << id;
537 +// len = lanSt_content(temp);
538 + len = sprintf(temp, "%d\n",(status & lanSt_bit) ? 1 : 0);
539 + }
540 + else // REG device
541 + {
542 + len = sprintf(temp, "-1\n");
543 + }
544 + rem = len - *fpos;
545 + if ( rem <= 0 ) {
546 + *fpos = len;
547 + return 0;
548 + }
549 + if ( rem > count ) rem = count;
550 + memcpy(buf, temp+(*fpos), rem);
551 + *fpos += rem;
552 + return rem;
553 +}
554 +
555 +static int lanSt_flush(struct file *file)
556 +{
557 + return 0;
558 +}
559 +
560 +static int lanSt_open(struct inode *inode, struct file *file)
561 +{
562 + int id = MINOR(inode->i_rdev);
563 + if ( id >= LAN_DEV_NUM && id != REG_MINOR )
564 + return -ENODEV;
565 + file->private_data = (void*)id;
566 + return 0;
567 +}
568 +
569 +static struct file_operations lanSt_fops = {
570 + read: lanSt_read,
571 + open: lanSt_open,
572 + flush: lanSt_flush,
573 + write: led_write,
574 +};
575 +
576 +//----------------------------------------------
577 +static int SwResetPress = 0;
578 +static int SwResetCounter = 0;
579 +static int RebootFlag = 0;
580 +static void watchdog_wrapper(unsigned int period)
581 +{
582 + // { RexHua add for restore default, by press SwReset 5 second, 2 sec to restart
583 +#if 0 //
584 + u_long reg;
585 +
586 + outl(GPIO_VAL, 0xcf8);
587 + reg = inl(0xcfc);
588 + reg |= 0x40;
589 + outl(reg, 0xcfc); // each in, need out 1 first
590 + reg = inl(0xcfc);
591 +
592 + if( (reg & 0x40) == 0)
593 + {
594 + if(SwResetPress == 0)
595 + {
596 + SwResetCounter=0;
597 + strcpy(led_data[15].sts_buf, "LED BLINK 500\n" );
598 + set_led_status_by_str(15);
599 + }
600 + SwResetPress=1;
601 + printk("SwReset press!\n");
602 +
603 + }
604 + else
605 + {
606 + if(SwResetPress=1)
607 + {
608 + strcpy(led_data[15].sts_buf, "LED ON\n" );
609 + set_led_status_by_str(15);
610 + }
611 +
612 + SwResetPress=0;
613 + if(RebootFlag == 1)
614 + machine_restart(0);
615 + }
616 +
617 + if(SwResetPress == 1)
618 + {
619 + if(SwResetCounter > 10)
620 + {
621 + turn_led(15, 0);
622 +// kernel_thread(reset_flash_default, 1, SIGCHLD);
623 + reset_flash_default(1);
624 + turn_led(15, 1);
625 + }
626 + else if(SwResetCounter == 3)
627 + {
628 + RebootFlag=1;
629 + strcpy(led_data[15].sts_buf, "LED BLINK 100\n" );
630 + set_led_status_by_str(15);
631 + }
632 + }
633 +
634 + SwResetCounter++;
635 +#endif
636 +
637 + // clear timer count
638 + outl(0x80003844, 0xcf8);
639 + outl(0x00800080, 0xcfc); // enable watchdog and set the timeout = 1.34s
640 + //printk(KERN_ERR "wdt\n" );
641 + watchdog.expires = jiffies + (period * HZ / 1000);
642 + add_timer(&watchdog);
643 +}
644 +
645 +//----------------------------------------------
646 +static int init_status;
647 +
648 +#define INIT_REGION 0x01
649 +#define INIT_LED_REGISTER 0x02
650 +#define INIT_LED_PROC_READ 0x04
651 +#define INIT_GPIO_REGISTER 0x08
652 +// sam 1-30-2004 LAN_STATUS
653 +#define INIT_LAN_STATUS_REGISTER 0x10
654 +#define INIT_WATCHDOG_REGISTER 0x20
655 +
656 +static void led_exit(void)
657 +{
658 + int id;
659 + for ( id = 0 ; id < LED_DEV_NUM ; id++ ) {
660 + del_timer(&blink_timer[id]);
661 + turn_led(id, 0);
662 + }
663 + if ( init_status & INIT_LED_PROC_READ )
664 + remove_proc_entry("driver/led", NULL);
665 +
666 + if ( init_status & INIT_LED_REGISTER )
667 + unregister_chrdev(LED_MAJOR, "led");
668 +
669 + if ( init_status & INIT_GPIO_REGISTER )
670 + unregister_chrdev(GPIO_MAJOR, "gpio");
671 + // sam 1-30-2004
672 +
673 + if( init_status & INIT_LAN_STATUS_REGISTER )
674 + unregister_chrdev(LAN_STATUS_MAJOR, "lanSt");
675 +
676 + if( init_status & INIT_WATCHDOG_REGISTER)
677 + del_timer(&watchdog);
678 +
679 +
680 + // end sam
681 +
682 +}
683 +
684 +static int __init led_init(void)
685 +{
686 + int result, id, i, j;
687 + unsigned long reg;
688 + init_status = 0;
689 +
690 + //----- register device (LED)-------------------------
691 +
692 +
693 + result = register_chrdev(LED_MAJOR, "led", &led_fops);
694 + if ( result < 0 ) {
695 + printk(KERN_ERR "led: can't register char device\n" );
696 + led_exit();
697 + return result;
698 + }
699 + init_status |= INIT_LED_REGISTER;
700 + //----- register device (GPIO)-------------------------
701 + result = register_chrdev(GPIO_MAJOR, "gpio", &gpio_fops);
702 + if ( result < 0 ) {
703 + printk(KERN_ERR "gpio: can't register char device\n" );
704 + led_exit();
705 + return result;
706 + }
707 + init_status |= INIT_GPIO_REGISTER;
708 +
709 + // sam 1-30-2004 LAN Status
710 + // ----- register device (LAN_STATUS)-------------------
711 +
712 + //--> sam 5-1802995
713 +
714 + result = register_chrdev(LAN_STATUS_MAJOR, "lanSt", &lanSt_fops);
715 + if ( result < 0 ) {
716 + printk(KERN_ERR "lanSt: can't register char device\n" );
717 + led_exit();
718 + return result;
719 + }
720 + init_status |= INIT_LAN_STATUS_REGISTER;
721 +
722 + // <-- end sam
723 +
724 + // -----------init watchdog timer-------------------------
725 + //del_timer(&blink_timer[id]);
726 +
727 + outl(0x80003840, 0xcf8);
728 + reg = inl(0xcfc);
729 + reg |= 0x1600; // ensable SRC bit
730 + outl(reg, 0xcfc);
731 +#ifdef _ROUTER_
732 + outl(0x80003848, 0xcf8);
733 + reg = inl(0xcfc);
734 + reg |= 0x18040; // enable GPIO, PowerLED:15, WLAN_LED0:16, SwReset:6
735 + outl(reg, 0xcfc);
736 +
737 + outl(0x8000384c, 0xcf8);
738 + reg = inl(0xcfc);
739 + reg |= 0x40; // output SwReset:6 1, Set SwReset as Input
740 + outl(reg, 0xcfc);
741 +#endif
742 + // sam debug
743 + //reg = inl(0xcfc);
744 + //printk(KERN_ERR "REG40:%08X\n", reg);
745 + // end sam
746 + outl(0x80003844, 0xcf8);
747 + outl(0x00800080, 0xcfc); // enable watchdog and set the timeout = 1.34s
748 +
749 + watchdog.function = watchdog_wrapper;
750 + watchdog.data = WATCHDOG_PERIOD;
751 + init_timer(&watchdog);
752 + watchdog.expires = jiffies + (WATCHDOG_PERIOD * HZ / 1000);
753 + add_timer(&watchdog);
754 + init_status |= INIT_WATCHDOG_REGISTER;
755 +
756 + // end sam
757 + //------ read proc -------------------
758 + if ( !create_proc_read_entry("driver/led", 0, 0, led_read_proc, NULL) ) {
759 + printk(KERN_ERR "led: can't create /proc/driver/led\n");
760 + led_exit();
761 + return -ENOMEM;
762 + }
763 + init_status |= INIT_LED_PROC_READ;
764 + //------------------------------
765 +// reg_addr = (unsigned long *)0xB4000000;
766 +// dump_len = 4;
767 +
768 + for ( id = 0 ; id < LED_DEV_NUM ; id++ ) {
769 + strcpy(led_data[id].sts_buf, "LED ON\n" );
770 + set_led_status_by_str(id);
771 + }
772 +
773 +// for (i = 0; i < 0xffff; i++)
774 +// for (j = 0; j < 0x6000; j++);
775 +
776 +/* sam 5-18-2005 remark
777 + for ( id = 0 ; id < LED_DEV_NUM ; id++ ) {
778 + strcpy(led_data[id].sts_buf, "LED ON\n" );
779 + set_led_status_by_str(id);
780 + }
781 +*/
782 + printk(KERN_INFO "LED & GPIO & LAN Status Driver LED_VERSION \n");
783 + return 0;
784 +}
785 +
786 +module_init(led_init);
787 +module_exit(led_exit);
788 +EXPORT_NO_SYMBOLS;
789 diff -urN linux-2.6.19/arch/i386/mach-rdc/led.h linux-2.6.19.new/arch/i386/mach-rdc/led.h
790 --- linux-2.6.19/arch/i386/mach-rdc/led.h 1970-01-01 01:00:00.000000000 +0100
791 +++ linux-2.6.19.new/arch/i386/mach-rdc/led.h 2006-12-17 17:13:33.000000000 +0100
792 @@ -0,0 +1,32 @@
793 +#ifndef _LED_H_INCLUDED
794 +#define _LED_H_INCLUDED
795 +
796 +#include <linux/autoconf.h>
797 +
798 +#define LED_VERSION "v1.0"
799 +#define LED_MAJOR 166
800 +#define LED_DEV_NUM 32
801 +#define LED_GPIO_START 1
802 +#define GPIO_MAJOR 167
803 +#define GPIO_DEV_NUM 32
804 +#define REG_MINOR 128
805 +// sam 1-30-2004 for LAN_STATUS
806 +#define LAN_STATUS_MAJOR 168
807 +#define LAN_DEV_NUM 5
808 +// end sam
809 +
810 +//#define GPIO_IO_BASE 0xB4002480
811 +//#define GPIO_IO_BASE ((unsigned long)0xb20000b8)
812 +//#define GPIO_IO_EXTENT 0x40
813 +
814 +#define LED_ON 0x010000
815 +#define LED_OFF 0x020000
816 +#define LED_BLINK_CMD 0x030000
817 +#define LED_BLINK_PERIOD 0x00FFFF
818 +#define LED_BLINK (LED_BLINK_CMD|1000)
819 +#define LED_BLINK_FAST (LED_BLINK_CMD|250)
820 +#define LED_BLINK_SLOW (LED_BLINK_CMD|500)
821 +#define LED_BLINK_EXTRA_SLOW (LED_BLINK_CMD|2000)
822 +#define LED_BLINK_RANDOM (LED_BLINK_CMD|0xffff)
823 +
824 +#endif
This page took 0.074844 seconds and 5 git commands to generate.