- do_settimeofday(&ts);
-diff -urN linux-2.6.19/arch/i386/mach-rdc/Makefile linux-2.6.19.new/arch/i386/mach-rdc/Makefile
---- linux-2.6.19/arch/i386/mach-rdc/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.19.new/arch/i386/mach-rdc/Makefile 2006-12-17 17:13:33.000000000 +0100
-@@ -0,0 +1,5 @@
-+#
-+# Makefile for the linux kernel.
-+#
-+
-+obj-$(CONFIG_X86_RDC) := led.o
-diff -urN linux-2.6.19/arch/i386/mach-rdc/led.c linux-2.6.19.new/arch/i386/mach-rdc/led.c
---- linux-2.6.19/arch/i386/mach-rdc/led.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.19.new/arch/i386/mach-rdc/led.c 2006-12-17 17:13:33.000000000 +0100
-@@ -0,0 +1,743 @@
-+/*
-+ * LED interface for WP3200
-+ *
-+ * Copyright (C) 2002, by Allen Hung
-+ *
-+ */
-+
-+#include <linux/types.h>
-+#include <linux/errno.h>
-+#include <linux/ioport.h>
-+#include <linux/fcntl.h>
-+#include <linux/sched.h>
-+#include <linux/module.h>
-+#include <linux/proc_fs.h>
-+#include <linux/init.h>
-+#include <linux/timer.h>
-+#include <asm/io.h>
-+#include <asm/uaccess.h>
-+#include <asm/system.h>
-+#include <linux/reboot.h>
-+
-+#include "led.h"
-+
-+#define BUF_LEN 30
-+
-+struct LED_DATA {
-+ char sts_buf[BUF_LEN+1];
-+ unsigned long sts;
-+};
-+
-+struct LED_DATA led_data[LED_DEV_NUM];
-+// sam
-+unsigned long ul_ledstat = 0xffffffff;
-+
-+
-+static struct timer_list blink_timer[LED_DEV_NUM];
-+// sam 01-30-2004 for watchdog
-+static struct timer_list watchdog;
-+// end sam
-+static char cmd_buf[BUF_LEN+1];
-+
-+//------------------------------------------------------------
-+static long atoh(char *p)
-+{
-+ long v = 0, c;
-+ while ( (c = *p++) ) {
-+ if ( c >= '0' && c <= '9' ) v = (v << 4) + c - '0';
-+ else if ( c >= 'a' && c <= 'f' ) v = (v << 4) + c - 'a' + 0xA;
-+ else if ( c >= 'A' && c <= 'F' ) v = (v << 4) + c - 'A' + 0xA;
-+ else break;
-+ }
-+ return v;
-+}
-+
-+static int reset_flash_default(void *data)
-+{
-+ char *argv[3], *envp[1] = {NULL};
-+ int i = 0;
-+
-+ int reset_default=(int) data;
-+
-+ argv[i++] = "/bin/flash";
-+ argv[i++] = "default";
-+ argv[i] = NULL;
-+ if(reset_default)
-+ if (call_usermodehelper(argv[0], argv, envp, 1))
-+ printk("failed to Reset to default\n");
-+ machine_restart(0);
-+ return 0;
-+}
-+
-+// sam for ps 3205U -- using CSx1 (0xb0e00000)
-+// bit map as following
-+// BIT 1 2 3 4 5
-+// POWER WLEN PORT1 PORT2 PORT3
-+//
-+// value 0 --> led on
-+// value 1 --> led off
-+
-+#define _ROUTER_
-+
-+#ifdef _ROUTER_
-+ #define LED_VAL 0x8000384C // the data ofset of gpio 0~30
-+#else
-+ #define LED_VAL 0x80003888 // the ofset of gpio 31~58
-+#endif
-+#define GPIO_VAL 0x8000384C // the offset of gpio 0-30
-+
-+
-+
-+// sam 1-30-2004 LED status
-+// bit map as following
-+// BIT 4:0 Link status -->PHY Link ->1 = up, 0 = down
-+#define LINK_STATUS (*(unsigned long *)0xb2000014)
-+#define WATCHDOG_VAL (*(unsigned long *)0xb20000c0)
-+#define WATCHDOG_PERIOD 500 // unit ms
-+#define EXPIRE_TIME 300 // unit 10 ms
-+#define CLEAR_TIMEER 0xffffa000l // bit 14:0 -> count up timer, write 0 to clear
-+#define ENABLE_WATCHDOG 0x80000000l // bit 31 -> 1 enable , 0 disable watchdog
-+#define WATCHDOG_SET_TMR_SHIFT 16 // bit 16:30 -> watchdog timer set
-+// end sam
-+
-+
-+//------------------------------------------------------------
-+static void turn_led(int id, int on)
-+{
-+ unsigned long led_bit = 1 << (id);
-+ unsigned long led_bit_val;
-+
-+ // since we define we have 8 led devices and use gpio 53, 55, 57, 58
-+ // which locate at bit21~26, so we rotate left 20bit
-+
-+#ifdef _ROUTER_
-+ led_bit_val = led_bit;
-+#else
-+ led_bit_val = led_bit << 20;
-+#endif
-+
-+ switch ( on ) {
-+ case 0:
-+ ul_ledstat|= led_bit_val;
-+ outl(LED_VAL, 0xcf8);
-+ outl(ul_ledstat, 0xcfc);
-+ break; // LED OFF
-+ case 1:
-+ ul_ledstat &= ~led_bit_val;
-+ outl(LED_VAL, 0xcf8);
-+ outl(ul_ledstat, 0xcfc);
-+ break; // LED ON
-+ case 2:
-+ ul_ledstat ^= led_bit_val;
-+ outl(LED_VAL, 0xcf8);
-+ outl(ul_ledstat, 0xcfc);
-+ break; // LED inverse
-+ }
-+}
-+
-+
-+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
-+static unsigned int wlan_counter; //Erwin
-+static void blink_wrapper(u_long id)
-+{
-+ u_long sts = led_data[id].sts;
-+
-+ if ( (sts & LED_BLINK_CMD) == LED_BLINK_CMD ) {
-+ unsigned long period = sts & LED_BLINK_PERIOD;
-+ if(period == 0xffff) // BLINK random
-+ {
-+ blink_timer[id].expires = jiffies + 3*led_flash[wlan_counter%30]*HZ/1000;
-+ wlan_counter++;
-+ }
-+ else
-+ blink_timer[id].expires = jiffies + (period * HZ / 1000);
-+ turn_led(id, 2);
-+ add_timer(&blink_timer[id]);
-+ }
-+ else if ( sts == LED_ON || sts == LED_OFF )
-+ turn_led(id, sts==LED_ON ? 1 : 0);
-+}
-+//------------------------------------------------------------
-+static void get_token_str(char *str, char token[][21], int token_num)
-+{
-+ int t, i;
-+
-+ for ( t = 0 ; t < token_num ; t++ ) {
-+ memset(token[t], 0, 21);
-+ while ( *str == ' ' ) str++;
-+ for ( i = 0 ; str[i] ; i++ ) {
-+ if ( str[i] == '\t' || str[i] == ' ' || str[i] == '\n' ) break;
-+ if ( i < 20 ) token[t][i] = str[i];
-+ }
-+ str += i;
-+ }
-+}
-+
-+//------------------------------------------------------------
-+static void set_led_status_by_str(int id)
-+{
-+ char token[3][21], *p;
-+
-+
-+ get_token_str(led_data[id].sts_buf, token, 3);
-+
-+ if ( strcmp(token[0], "LED") )
-+ {
-+ goto set_led_off;
-+ }
-+ if ( !strcmp(token[1], "ON") )
-+ {
-+
-+ turn_led(id, 1);
-+ led_data[id].sts = LED_ON;
-+ }
-+ else if ( !strcmp(token[1], "OFF") )
-+ {
-+
-+ goto set_led_off;
-+ }
-+ else if ( !strcmp(token[1], "BLINK") )
-+ {
-+ unsigned int period = 0;
-+ p = token[2];
-+ if ( !strcmp(p, "FAST") )
-+ period = LED_BLINK_FAST & LED_BLINK_PERIOD;
-+ else if ( !strcmp(p, "SLOW") )
-+ period = LED_BLINK_SLOW & LED_BLINK_PERIOD;
-+ else if ( !strcmp(p, "EXTRA_SLOW") )
-+ period = LED_BLINK_EXTRA_SLOW & LED_BLINK_PERIOD;
-+ else if ( !strcmp(p, "RANDOM") )
-+ period = LED_BLINK_RANDOM & LED_BLINK_PERIOD;
-+ else if ( !strcmp(p, "OFF") )
-+ goto set_led_off;
-+ else if ( *p >= '0' && *p <= '9' )
-+ {
-+ while ( *p >= '0' && *p <= '9' )
-+ period = period * 10 + (*p++) - '0';
-+// if ( period > 10000 )
-+// period = 10000;
-+ }
-+ else
-+ period = LED_BLINK & LED_BLINK_PERIOD;
-+
-+ if ( period == 0 )
-+ goto set_led_off;
-+
-+ sprintf(led_data[id].sts_buf, "LED BLINK %d\n", period);
-+ led_data[id].sts = LED_BLINK_CMD + period;
-+ turn_led(id, 2);
-+ // Set timer for next blink
-+ del_timer(&blink_timer[id]);
-+ blink_timer[id].function = blink_wrapper;
-+ blink_timer[id].data = id;
-+ init_timer(&blink_timer[id]);
-+
-+ blink_timer[id].expires = jiffies + (1000 * HZ / 1000);
-+
-+ add_timer(&blink_timer[id]);
-+ }
-+ else
-+ {
-+ goto set_led_off;
-+ }
-+ return;
-+ set_led_off:
-+ strcpy(led_data[id].sts_buf, "LED OFF\n");
-+ led_data[id].sts = LED_OFF;
-+ turn_led(id, 0);
-+}
-+
-+//----------------------------------------------------------------------
-+static int led_read_proc(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
-+{
-+ int len, dev;
-+
-+ for ( len = dev = 0 ; dev < LED_DEV_NUM ; dev++ ) {
-+ len += sprintf(buf+len, "%d: %s", dev, led_data[dev].sts_buf);
-+ }
-+ len = strlen(buf) - fpos;
-+ if ( len <= 0 ) {
-+ *start = buf;
-+ *eof = 1;
-+ return 0;
-+ }
-+ *start = buf + fpos;
-+ if ( len <= length ) *eof = 1;
-+ return len < length ? len : length;
-+}
-+
-+//----------------------------------------------------------------------
-+static int led_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
-+{
-+ int id = (int)file->private_data;
-+
-+ switch ( cmd ) {
-+ case LED_ON:
-+ strcpy(led_data[id].sts_buf, "LED ON\n");
-+ set_led_status_by_str(id);
-+ break;
-+ case LED_OFF:
-+ strcpy(led_data[id].sts_buf, "LED OFF\n");
-+ set_led_status_by_str(id);
-+ break;
-+ default:
-+ if ( (cmd & LED_BLINK_CMD) != LED_BLINK_CMD )
-+ {
-+ break;
-+ }
-+ case LED_BLINK:
-+ case LED_BLINK_FAST:
-+ case LED_BLINK_SLOW:
-+ case LED_BLINK_EXTRA_SLOW:
-+ case LED_BLINK_RANDOM:
-+ sprintf(led_data[id].sts_buf, "LED BLINK %d\n", (int)(cmd & LED_BLINK_PERIOD));
-+ set_led_status_by_str(id);
-+ break;
-+ }
-+ return 0;
-+}
-+
-+static int led_open(struct inode *inode, struct file *file)
-+{
-+ int led_id = MINOR(inode->i_rdev);
-+// unsigned long led_bit = 1 << (led_id);
-+
-+ if ( led_id >= LED_DEV_NUM )
-+ return -ENODEV;
-+/* sam 12/02/2003
-+ GPIO_SEL_I_O &= ~led_bit; // 0 to GPIO
-+ GPIO_O_EN |= (led_bit << 16); // 0 to Output
-+*/
-+
-+ file->private_data = (void*)led_id;
-+ return 0;
-+}
-+
-+static long led_read(struct file *file, char *buf, size_t count, loff_t *fpos)
-+{
-+ int rem, len;
-+ int id = (int)file->private_data;
-+ char *p = led_data[id].sts_buf;
-+
-+ len = strlen(p);
-+ rem = len - *fpos;
-+ if ( rem <= 0 ) {
-+ *fpos = len;
-+ return 0;
-+ }
-+ if ( rem > count ) rem = count;
-+ memcpy(buf, p+(*fpos), rem);
-+ *fpos += rem;
-+ return rem;
-+}
-+
-+static long led_write(struct file *file, char *buf, size_t count, loff_t *fpos)
-+{
-+ int len;
-+ int id = (int)file->private_data;
-+ char *p = id == REG_MINOR ? cmd_buf : led_data[id].sts_buf;
-+ memset(p, 0, BUF_LEN);
-+
-+ p += *fpos;
-+ len = 0;
-+
-+
-+ while ( count > 0 )
-+ {
-+
-+ if ( *fpos < BUF_LEN )
-+ {
-+ int c = *buf++;
-+ p[len] = c>='a' && c<='z' ? c-'a'+'A' : c;
-+ }
-+ (*fpos)++;
-+ len++;
-+ count--;
-+ }
-+ // sam
-+ set_led_status_by_str(id);
-+ (*fpos) = 0;
-+ //
-+
-+ return len;
-+}
-+
-+static int led_flush(struct file *file)
-+{
-+ int id = (int)file->private_data;
-+
-+ if ( file->f_mode & FMODE_WRITE )
-+ {
-+ set_led_status_by_str(id);
-+ }
-+ return 0;