--- celinux-040503.jz/arch/mips/jz4730/common/pm.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/jz4730/common/pm.c 2008-09-10 10:45:18.000000000 +0200 @@ -112,8 +112,8 @@ static int jz_pm_do_suspend(void) REG_CPM_OCR |= CPM_OCR_SUSPEND_PHY0; /* suspend USB PHY 0 */ REG_CPM_OCR |= CPM_OCR_SUSPEND_PHY1; /* suspend USB PHY 1 */ - REG_CPM_OCR |= CPM_OCR_EXT_RTC_CLK; /* select the external RTC clock (32.768KHz) */ - +//wjx REG_CPM_OCR |= CPM_OCR_EXT_RTC_CLK; /* select the external RTC clock (32.768KHz) */ + REG_CPM_SCR |= 1<<4; //wjx /* Disable NAND ctroller */ REG_EMC_NFCSR &= ~(EMC_NFCSR_NFE | EMC_NFCSR_FCE); @@ -199,6 +199,7 @@ static int jz_pm_do_suspend(void) SAVE(CPM_MSCR, 32); /* Stop module clocks */ + __cpm_stop_uart0(); __cpm_stop_uart1(); __cpm_stop_uart2(); @@ -331,7 +332,7 @@ static int jz_pm_do_suspend(void) REG_CPM_OCR &= ~CPM_OCR_SUSPEND_PHY0; /* resume USB PHY 0 */ REG_CPM_OCR &= ~CPM_OCR_SUSPEND_PHY1; /* resume USB PHY 1 */ -#if 0 +#if 1 //wjx REG_CPM_OCR &= ~CPM_OCR_EXT_RTC_CLK; /* use internal RTC clock (JZ_EXTAL/128 Hz) */ #else REG_CPM_OCR |= CPM_OCR_EXT_RTC_CLK; /* use external RTC clock (32.768 KHz) */ @@ -344,7 +345,8 @@ static int jz_pm_do_suspend(void) xtime.tv_sec = REG_RTC_RSR; /* Enable interrupt */ - sti(); +//wjx sti(); + printk("resume\n"); //wjx return 0; } @@ -870,6 +872,12 @@ static void jz_board_pm_suspend(void) */ REG_CPM_WER = 0; /* Clear all first */ +// __gpio_as_input(16); /* GPIO 96 */ + __gpio_as_irq_rise_edge(16); + REG_CPM_WER |= 1 << 8; + REG_CPM_WRER |= 1 << 8; + REG_CPM_WFER |= 1 << 8; + /* RTC alarm */ REG_CPM_WER |= 1 << 0; REG_CPM_WRER |= 1 << 0; @@ -883,6 +891,9 @@ static void jz_board_pm_suspend(void) __gpio_as_irq_rise_edge(97); /* enable INTC irq */ + __intc_unmask_irq(IRQ_GPIO0); + __intc_unmask_irq(IRQ_GPIO1); + __intc_unmask_irq(IRQ_GPIO2); __intc_unmask_irq(IRQ_GPIO3); #if 0 @@ -909,6 +920,9 @@ static int jz_pm_do_sleep(void) /* Just allow next interrupts to wakeup the system. * Note: modify this according to your system. */ +// __gpio_as_input(16); /* GPIO 96 */ + __gpio_as_irq_rise_edge(16); /* wjx GPIO 97 */ + /* RTC alarm */ __gpio_as_irq_fall_edge(96); /* GPIO 96 */ @@ -916,8 +930,10 @@ static int jz_pm_do_sleep(void) __gpio_as_irq_rise_edge(97); /* GPIO 97 */ /* Enable INTC */ + __intc_unmask_irq(IRQ_GPIO0); + __intc_unmask_irq(IRQ_GPIO1); + __intc_unmask_irq(IRQ_GPIO2); __intc_unmask_irq(IRQ_GPIO3); - /* Disable modules e.g. LCD backlight */ /* Stop module clocks */ --- celinux-040503.jz/arch/mips/jz4730/common/proc.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/jz4730/common/proc.c 2008-09-10 10:45:18.000000000 +0200 @@ -18,6 +18,13 @@ #include #include #include +#include //wjx + +#define BATTERY_IO 17 //wjx check the battery capacity 2007.12.10 +#define NETWORK_IO 9 //wjx network eth0 led 2008.1.29 +#define CAPSLOCKLED_IO 27 //wjx 2008.3.31 +#define NUMLOCKLED_IO 86 +#define INTERNAL_WIFI_IO 95 //wey 2008.5.28 struct proc_dir_entry *proc_jz_root; @@ -205,6 +212,169 @@ static int proc_jz_pwm_write_word(struct return count; } +/* wjx 2007.12.10 battery status */ +static int battery_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + + __gpio_as_input(BATTERY_IO); + + if (__gpio_get_pin(BATTERY_IO) == 1) + { + len += sprintf (page+len, "1\n"); + } + else + { + len += sprintf (page+len, "0\n"); + } + return len; +} + + + +extern void keyboard_set_codec_volume(int lower); //wjx change the volume + +static int volume_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + #ifdef CONFIG_SOUND // wjx add 2008.5.19 + if (val) + keyboard_set_codec_volume(0); //wjx 2007.12.13 volume up + else + keyboard_set_codec_volume(1); //wjx 2007.12.13 volume down + #endif + return count; +} + + +static int eth0_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + printk("eth0_write_proc\n"); + unsigned long val = simple_strtoul(buffer, 0, 10); + + if (val) + { + __gpio_as_output(NETWORK_IO); + __gpio_clear_pin(NETWORK_IO); //wjx 2007.12.13 up eth0 led + } + else + { + __gpio_as_output(NETWORK_IO); + __gpio_set_pin(NETWORK_IO); //wjx 2007.12.13 down eth0 led + } + return count; +} + +//wjx 2008.3.31 +static int capslock_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + + if (val) + { + __gpio_as_output(CAPSLOCKLED_IO); + __gpio_clear_pin(CAPSLOCKLED_IO); //wjx 2007.12.13 up eth0 led + } + else + { + __gpio_as_output(CAPSLOCKLED_IO); + __gpio_set_pin(CAPSLOCKLED_IO); //wjx 2007.12.13 down eth0 led + } + return count; +} + +static int numlock_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + + if (val) + { + __gpio_as_output(NUMLOCKLED_IO); + __gpio_clear_pin(NUMLOCKLED_IO); //wjx 2007.12.13 up eth0 led + } + else + { + __gpio_as_output(NUMLOCKLED_IO); + __gpio_set_pin(NUMLOCKLED_IO); //wjx 2007.12.13 down eth0 led + } + return count; +} + +extern inline void __lcd_set_backlight_level(int n); +static int lcd_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + #ifdef CONFIG_FB //wjx add + if (val <= 300) + { + __lcd_set_backlight_level(val); //set the lcd backlight + } + #endif + return count; +} + + +/* wjx test read mcu i2c */ +static int mcu_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + int nr; + unsigned char battery_status = 0; + + i2c_open(); + nr = i2c_read(0x50>>1, &battery_status, 0xdb, 1); // battery adc + i2c_close(); + + len += sprintf (page+len, " nr:%d\n", nr); + len += sprintf(page+len, "%02x ", battery_status); + len += sprintf(page+len,"\n"); + + return len; +} + +/*control the internal wifi's power. wey 2008.5.28*/ +static int iwifi_write_proc (struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + + if (val) + { + __gpio_as_output(INTERNAL_WIFI_IO); + __gpio_set_pin(INTERNAL_WIFI_IO); + } + else + { + __gpio_as_output(INTERNAL_WIFI_IO); + __gpio_clear_pin(INTERNAL_WIFI_IO); + } + return count; +} + +/* wjx test read not input event happen time */ +extern unsigned int not_input_event_time; + +static int input_event_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + len += sprintf(page+len, "%d", not_input_event_time); + return len; +} + +static int input_event_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + unsigned long val = simple_strtoul(buffer, 0, 10); + + not_input_event_time = val; + + return count; +} + + +/***/ + #define PWM_NUM 2 static int jz_pwm_proc_init(void) @@ -299,6 +469,38 @@ static int mmc_read_proc (char *page, ch return len; } +/* zxl for USB */ +static int usb_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + + len += sprintf (page+len, "REG_HARB_HAPOR: 0x%08x\n", REG_HARB_HAPOR); + len += sprintf (page+len, "GPIO108: 0x%08x\n", (unsigned long)__gpio_get_pin(108)); + return len; +} + +/* zxl test RTC */ +static int rtc_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + int nr; + unsigned char data[7]; + int i; + + i2c_open(); + memset (data, 0, sizeof(data)); + nr = i2c_read(0xA2>>1, data, 0x02, 7); + + len += sprintf (page+len, " nr:\n", nr); + for (i = 6; i >= 0; i--) + len += sprintf(page+len, "%02x ", data[i]); + len += sprintf(page+len,"\n"); + i2c_close(); + return len; +} + /* * /proc/jz/xxx entry * @@ -308,6 +510,20 @@ static int __init jz_proc_init(void) struct proc_dir_entry *res; proc_jz_root = proc_mkdir("jz", 0); + /*CONFIG_XIPTECH_MINIPC_V2 edwin 2008-04-20*/ + res = create_proc_entry("usb", 0644, proc_jz_root); + if (res) { + res->read_proc = usb_read_proc; + res->write_proc = NULL; + res->data = NULL; + } + + res = create_proc_entry("rtc", 0644, proc_jz_root); + if (res) { + res->read_proc = rtc_read_proc; + res->write_proc = NULL; + res->data = NULL; + } /* External Memory Controller */ res = create_proc_entry("emc", 0644, proc_jz_root); @@ -341,6 +557,113 @@ static int __init jz_proc_init(void) res->data = NULL; } +#if 1 + /* wjx 2007.12.10 battery */ + res = create_proc_entry("battery", 0644, proc_jz_root); + if (res) { + __gpio_as_input(BATTERY_IO); + res->read_proc = battery_read_proc; + res->write_proc = NULL; + res->data = NULL; + } + +#endif + +#if 1 + /* wjx 2007.12.10 volume */ + res = create_proc_entry("volume", 0644, proc_jz_root); + if (res) { + + res->write_proc = volume_write_proc; + res->read_proc = NULL; + res->data = NULL; + } +#endif + +#if 1 + /* wjx 2007.12.10 eth0 network led */ + res = create_proc_entry("eth0_led", 0644, proc_jz_root); + if (res) { + __gpio_as_output(NETWORK_IO); + __gpio_set_pin(NETWORK_IO); + res->read_proc = NULL; + res->write_proc = eth0_write_proc; + res->data = NULL; + } +#endif + +#if 1 + /* wjx 2008.3.31 capslock led */ + res = create_proc_entry("capslock_led", 0644, proc_jz_root); + if (res) { + __gpio_as_output(CAPSLOCKLED_IO); + __gpio_set_pin(CAPSLOCKLED_IO); + /*edwin for test*/ + __gpio_as_output(95); + __gpio_set_pin(95); + /**/ + res->read_proc = NULL; + res->write_proc = capslock_write_proc; + res->data = NULL; + } +#endif + +#if 1 + /* wjx 2008.3.31 numlock led */ + res = create_proc_entry("numlock_led", 0644, proc_jz_root); + if (res) { + __gpio_as_output(NUMLOCKLED_IO); + __gpio_set_pin(NUMLOCKLED_IO); + res->read_proc = NULL; + res->write_proc = numlock_write_proc; + res->data = NULL; + } +#endif + +#if 1 + /* wjx 2007.12.14 lcd backlight */ + + res = create_proc_entry("lcd", 0644, proc_jz_root); + if (res) { + res->write_proc = lcd_write_proc; + res->read_proc = NULL; + res->data = NULL; + } + +#endif + +#if 1 + /* wjx 2008.1.29 mcu read battery status */ + + res = create_proc_entry("mcu", 0644, proc_jz_root); + if (res) { + res->write_proc = NULL; + res->read_proc = mcu_read_proc; + res->data = NULL; + } + +#endif + + /* wjx 2008.5.10 input event(mouse,keyboard) */ + + res = create_proc_entry("input_event", 0644, proc_jz_root); + if (res) { + res->write_proc = input_event_write_proc; + res->read_proc = input_event_read_proc; + res->data = NULL; + } +#if 1 + /*wey 2008.5.28 control the internal wifi*/ + res = create_proc_entry("iwifi", 0644, proc_jz_root); + if (res) { + __gpio_as_output(INTERNAL_WIFI_IO); + __gpio_clear_pin(INTERNAL_WIFI_IO);//by default turn off its power.wey 2008.5.28 + res->read_proc = NULL; + res->write_proc = iwifi_write_proc; + res->data = NULL; + } +#endif + /* PWM */ jz_pwm_proc_init(); --- celinux-040503.jz/arch/mips/jz4730/common/time.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/jz4730/common/time.c 2008-09-10 10:45:19.000000000 +0200 @@ -27,13 +27,29 @@ void (*timer_hw_ack)(void) = NULL; extern volatile unsigned long wall_jiffies; extern rwlock_t xtime_lock; +//wjx +#ifdef CONFIG_XIPTECH_MINIPC_V2 +void minipc_kbd_on_timer(void); +#endif + +//wjx take the times then where is not keyboard and mouse input event happen +unsigned int not_input_event_time = 0; + static void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { + if (timer_hw_ack) timer_hw_ack(); do_timer(regs); /* Increment jiffies by one */ + //wjx take time of no input event happen + + if (!(jiffies & 0x3ff)) // 10 second &3ff + { + not_input_event_time ++ ; + } + if (!user_mode(regs)) if (prof_buffer && current->pid) { extern int _stext; @@ -50,6 +66,12 @@ static void timer_interrupt(int irq, voi pc = prof_len-1; atomic_inc((atomic_t *)&prof_buffer[pc]); } + //wjx + #ifdef CONFIG_XIPTECH_MINIPC_V2 + #ifdef CONFIG_MINIPC_GPIOKB + minipc_kbd_on_timer(); + #endif + #endif } static struct irqaction timer_irqaction = { --- celinux-040503.jz/arch/mips/jz4730/pmpv1/setup.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/jz4730/pmpv1/setup.c 2008-09-10 10:45:20.000000000 +0200 @@ -23,15 +23,18 @@ static void __init board_gpio_setup(void __harb_usb0_uhc(); __gpio_as_emc(); __gpio_as_uart0(); +/* wjx __gpio_as_uart1(); __gpio_as_uart2(); __gpio_as_uart3(); +*/ __gpio_as_dma(); __gpio_as_eth(); __gpio_as_usb(); __gpio_as_lcd_master(); #if defined(CONFIG_I2S_AK4642EN) - __gpio_as_scc1(); +//wjx __gpio_as_scc1(); + __gpio_as_i2s_master(); //wjx #endif #if defined(CONFIG_I2S_TSC2301) || defined(CONFIG_I2S_TLC320AIC23) __gpio_as_ssi(); @@ -40,19 +43,21 @@ static void __init board_gpio_setup(void #if defined(CONFIG_I2S_TSC2301) || defined(CONFIG_I2S_TLC320AIC23) || defined(CONFIG_I2S_CS42L51) __gpio_as_i2s_slave(); #endif - __gpio_as_cim(); +//wjx __gpio_as_cim(); __gpio_as_msc(); +/* wjx __gpio_as_output(GPIO_LED_EN); __gpio_set_pin(GPIO_LED_EN); __gpio_as_output(GPIO_DISP_OFF_N); __gpio_set_pin(GPIO_DISP_OFF_N); +*/ __gpio_as_output(GPIO_PWM0); __gpio_set_pin(GPIO_PWM0); - __gpio_as_input(GPIO_RTC_IRQ); +//wjx __gpio_as_input(GPIO_RTC_IRQ); __gpio_as_output(GPIO_USB_CLK_EN); __gpio_set_pin(GPIO_USB_CLK_EN); } --- celinux-040503.jz/arch/mips/jz4740/common/dpm.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/jz4740/common/dpm.c 2008-09-10 10:45:21.000000000 +0200 @@ -290,7 +290,8 @@ static void jz_scale_pll(struct dpm_regs /* Update some DRAM parameters before changing frequency */ new_pll = JZ_EXTAL * ((cppcr>>23)+2) / ((((cppcr>>18)&0x1f)+2) * od[(cppcr>>16)&0x03]); cur_mclk = __cpm_get_mclk(); - new_mclk = new_pll / div[(REG_CPM_CPCCR>>CPM_CPCCR_MDIV_BIT) & 0xf]; + new_mclk = new_pll / div[(REG_CPM_CPCCR>>16) & 0xf]; + /* * Update some SDRAM parameters */ --- celinux-040503.jz/arch/mips/kernel/setup.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/arch/mips/kernel/setup.c 2008-09-10 10:45:24.000000000 +0200 @@ -789,3 +789,7 @@ static int __init fpu_disable(char *s) return 1; } __setup("nofpu", fpu_disable); + +//wjx +#include +EXPORT_SYMBOL(_machine_power_off); --- celinux-040503.jz/arch/mips/kernel/time.c 2004-05-03 13:23:33.000000000 +0200 +++ cel.new/arch/mips/kernel/time.c 2008-09-10 10:45:24.000000000 +0200 @@ -539,10 +539,16 @@ static inline void do_timer_interrupt(st local_timer_interrupt(0, NULL, regs); } +//wjx +/* +#ifdef CONFIG_XIPTECH_MINIPC_V2 +void minipc_kbd_on_timer(void); +#endif +*/ + void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { write_lock (&xtime_lock); - if (cpu_has_counter) { unsigned count; @@ -624,6 +630,12 @@ void timer_interrupt(int irq, void *dev_ if (!jiffies) { timerhi = timerlo = 0; } +/* +//wjx +#ifdef CONFIG_XIPTECH_MINIPC_V2 + minipc_kbd_on_timer(); +#endif +*/ } asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs) --- celinux-040503.jz/drivers/char/defkeymap.c 2004-05-03 13:23:33.000000000 +0200 +++ cel.new/drivers/char/defkeymap.c 2008-09-10 10:45:26.000000000 +0200 @@ -21,14 +21,23 @@ u_short plain_map[NR_KEYS] = { 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, -#if !defined(CONFIG_SA1100_H3XXX) 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, -#else - 0xF000|K_XFAUDIORECORD, 0xF000|K_XFPOWERDOWN, - 0xF000|K_XFCALENDAR, 0xF000|K_XTELEPHONE, - 0xF000|K_XFMAIL, 0xF000|K_XFSTART, - 0xF000|K_XFROCKERENTER, 0xf125, -#endif + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short shift_map[NR_KEYS] = { @@ -44,10 +53,26 @@ u_short shift_map[NR_KEYS] = { 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, - 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short altgr_map[NR_KEYS] = { @@ -63,10 +88,26 @@ u_short altgr_map[NR_KEYS] = { 0xf912, 0xf913, 0xf30b, 0xf90e, 0xf90f, 0xf910, 0xf30a, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, - 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short ctrl_map[NR_KEYS] = { @@ -86,6 +127,22 @@ u_short ctrl_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short shift_ctrl_map[NR_KEYS] = { @@ -101,10 +158,26 @@ u_short shift_ctrl_map[NR_KEYS] = { 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, - 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short alt_map[NR_KEYS] = { @@ -124,6 +197,22 @@ u_short alt_map[NR_KEYS] = { 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short ctrl_alt_map[NR_KEYS] = { @@ -139,10 +228,26 @@ u_short ctrl_alt_map[NR_KEYS] = { 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, - 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; ushort *key_maps[MAX_NR_KEYMAPS] = { --- celinux-040503.jz/drivers/char/jzchar/jz_udc_hotplug.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/drivers/char/jzchar/jz_udc_hotplug.c 2008-09-10 10:45:27.000000000 +0200 @@ -145,12 +145,6 @@ static int __init udc_hotplug_init(void) udc_timer.function = udc_timer_routine; udc_timer.data = 0; - retval = request_irq(UDC_HOTPLUG_IRQ, udc_hotplug_irq, - SA_INTERRUPT, "udc_hotplug", NULL); - if (retval) { - printk("Could not get udc hotplug irq %d\n", UDC_HOTPLUG_IRQ); - } - /* get current pin level */ __gpio_disable_pull(UDC_HOTPLUG_PIN); __gpio_as_input(UDC_HOTPLUG_PIN); @@ -165,6 +159,12 @@ static int __init udc_hotplug_init(void) __gpio_as_irq_rise_edge(UDC_HOTPLUG_PIN); } + retval = request_irq(UDC_HOTPLUG_IRQ, udc_hotplug_irq, + SA_INTERRUPT, "udc_hotplug", NULL); + if (retval) { + printk("Could not get udc hotplug irq %d\n", UDC_HOTPLUG_IRQ); + } + printk("UDC hotplug driver installed\n"); return 0; --- celinux-040503.jz/drivers/char/keyboard.c 2004-05-03 13:23:48.000000000 +0200 +++ cel.new/drivers/char/keyboard.c 2008-09-10 10:45:32.000000000 +0200 @@ -70,7 +70,8 @@ EXPORT_SYMBOL(handle_scancode); EXPORT_SYMBOL(kbd_ledfunc); extern void ctrl_alt_del(void); - +extern int flags_key_F2;//czj 2007.8.10 +extern int flags_key_F3;//edwin 08.03.31 struct console; /* @@ -243,6 +244,12 @@ void handle_scancode(unsigned char scanc * We keep track of the up/down status of the key, and * return the keycode if in MEDIUMRAW mode. */ + /* czj-2007-8-10 */ + if(keycode == 60) + flags_key_F2=1; + if(keycode == 61) + flags_key_F3=1; + if (up_flag) { rep = 0; --- celinux-040503.jz/drivers/char/minipc-kbd.c 1970-01-01 01:00:00.000000000 +0100 +++ cel.new/drivers/char/minipc-kbd.c 2008-10-01 17:17:15.000000000 +0200 @@ -0,0 +1,661 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +///#define SCAN_USE_TIMER 1 + +#if 0 //wjx +#define DBG(args...) printk(args) +#else +#define DBG(args...) +#endif + + +#define SCANHZ (HZ/20) + +#define CAPSLOCKLED 27 //wjx 2007.12.10 +#define NUMLOCKLED 86 + +static int capslock_flag = 0; // wjx +static int numlock_flag = 0; +static int fn_f5_flag = 0; + +/* KBD */ +static struct input_dev *kbd_dev; +//static int kbd_thread_pid = -1; +#ifdef SCAN_USE_TIMER +struct timer_list scan_timer; +#else +static int kbd_start = 0; +static int kbd_tick = 0; +#endif +static int kbd_refcount = 0; + +#if 1 +const static unsigned int key_c[] = { + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 125, +}; + +const static unsigned int key_r[] = { + 0, 1, 2, 3, 4, 5, 6, 7 +}; +#else +const static unsigned int key_c[] = { + /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ + 104, 97, 106, 6, 2, 5, 102, 1, 96, 111, 98, 7, 4, 110, 105, 125, 109, +}; + +const static unsigned int key_r[] = { + 3, 103, 100, 0, 108, 101, 99, 107, +}; +#endif + +#define KB_SCAN_LINE (sizeof(key_c)/sizeof(*key_c)) + +static unsigned char last_keys[KB_SCAN_LINE]; +static unsigned char cur_keys[KB_SCAN_LINE]; + +#define KEY_FN 0 + +const static int kmap[KB_SCAN_LINE][8] = { +/* 0*/ {KEY_PAUSE, 0, 0, 0, 0, 0, KEY_LEFTCTRL, KEY_F5,}, +/* 1*/ {KEY_Q, KEY_TAB, KEY_A, KEY_ESC, KEY_Z, 0, KEY_GRAVE, KEY_1,}, +/* 2*/ {KEY_W, KEY_CAPSLOCK, KEY_S, KEY_102ND, KEY_X, 0, 0, KEY_2,},//CZJ delet the KEY_BACKSLASH +/* 3*/ {KEY_E, KEY_F3, KEY_D, KEY_F4, KEY_C, 0, 0, KEY_3,}, +/* 4*/ {KEY_R, KEY_T, KEY_F, KEY_G, KEY_V, KEY_B, KEY_5, KEY_4,}, +/* 5*/ {KEY_U, KEY_Y, KEY_J, KEY_H, KEY_M, KEY_N, KEY_6, KEY_7,}, +/* 6*/ {KEY_I, KEY_RIGHTBRACE, KEY_K, KEY_F6, KEY_COMMA, 0, KEY_EQUAL, + KEY_8,}, +/* 7*/ {KEY_O, KEY_F7, KEY_L, 0, KEY_DOT, KEY_F19, KEY_F8, KEY_9,}, +/* 8*/ {0, 0, 0, KEY_SPACE, KEY_NUMLOCK, 0, KEY_DELETE, 0,}, +/* 9*/ {0, KEY_BACKSPACE, 0, 0, KEY_ENTER, 0, KEY_F9, 0,}, +/*10*/ {0, 0, 0, KEY_LEFTALT, 0, 0, 0, KEY_SYSRQ,}, +/*11*/ {KEY_P, KEY_LEFTBRACE, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_BACKSLASH, + KEY_SLASH, KEY_MINUS, KEY_0,}, +/*12*/ {KEY_KP0, KEY_F20, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_F10,}, //CZJ ADD NUM PACK +/*13*/ {KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KPPLUS, KEY_KPMINUS, KEY_F2, KEY_KPSLASH,}, //CZJ ADD NUM PACK +/*14*/ {KEY_KPDOT, KEY_KPASTERISK, 0, 0, 0, 0, KEY_INSERT, 0,}, //CZJ ADD NUM PACK +/*15*/ {0, 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, 0, 0,}, +/*16*/ {0, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, 0, 0, 0, KEY_F1, KEY_FN,}, +}; + +static int +xy2code (int col, int row) +{ + if ((col < KB_SCAN_LINE) && (row < 8)) + return kmap[col][row]; + else + return 0; +} + +#define KB_SCAN_LINE (sizeof(key_c)/sizeof(*key_c)) + +static void +setup_keybd (void) +{ + int i; + + for (i = 0; i < sizeof (key_r) / sizeof (*key_r); i++) + { + __gpio_as_input (key_r[i]); + __gpio_disable_pull (key_r[i]); + } + + __gpio_as_input (8); /* key_int */ + + for (i = 0; i < KB_SCAN_LINE; i++) + { + __gpio_as_output (key_c[i]); + __gpio_clear_pin (key_c[i]); + } + + __gpio_as_output (NUMLOCKLED); //wjx 2007.12.10 + __gpio_set_pin (NUMLOCKLED); + + __gpio_as_output (CAPSLOCKLED); + __gpio_set_pin (CAPSLOCKLED); + +} + +#define kb_scan_delay() udelay(3) + +static int +scan_keybd (unsigned char *kr) +{ + int i, k; + + for (i = 0; i < 8; i++) + { + + if (!__gpio_get_pin (key_r[i])) + { + for (k = 0; k < KB_SCAN_LINE; k++) + { + __gpio_set_pin (key_c[k]); + kb_scan_delay (); + if (__gpio_get_pin (key_r[i])) + { + if (kmap[k][i] == 0) + DBG ("input [%d] %d\n", k, i); + kr[k] |= (1U << i); + } + __gpio_clear_pin (key_c[k]); + } + } + } + + return (int) __gpio_get_pin (8); +} + +static void scan_kbd (unsigned long); + +static void +start_scan_timer (void) +{ +#ifdef SCAN_USE_TIMER + + scan_timer.expires = jiffies + SCANHZ; + scan_timer.data = 0; + scan_timer.function = scan_kbd; + add_timer (&scan_timer); +#else + kbd_start = 1; +#endif +} + + +static void +set_capslock_led () +{ + + capslock_flag = !capslock_flag; + + if (capslock_flag) + { + __gpio_clear_pin (CAPSLOCKLED); + } + else + { + __gpio_set_pin (CAPSLOCKLED); + } +} + +static void +set_numlock_led () +{ + numlock_flag = !numlock_flag; + + if (numlock_flag) + { + __gpio_clear_pin (NUMLOCKLED); + } + else + { + __gpio_set_pin (NUMLOCKLED); + } +} + + +/*for the "left-right" buttons beside touch pad.edwin*/ +/*define gpio pin*/ +#define TP_MOUSE_RIGHT 13 +#define TP_MOUSE_LEFT 16 + +int left_up = 1; +int right_up = 1; + +static struct input_dev *tp_mouse_dev; + + +static int +tp_mouse_event (struct input_dev *dev, unsigned int type, unsigned int code, + int value) +{ + return 1; +} + +static int +tp_mouse_open (struct input_dev *dev) +{ + return 1; +} + +static void +scan_mouse_left (void) +{ + int state; + + if (left_up != (state = __gpio_get_pin (TP_MOUSE_LEFT))) + { + left_up = state; + input_report_key (tp_mouse_dev, BTN_LEFT, state); + } +} + +static void +scan_mouse_right (void) +{ + int state; + if (right_up != (state = __gpio_get_pin (TP_MOUSE_RIGHT))) + { + right_up = state; + input_report_key (tp_mouse_dev, BTN_RIGHT, state); + } +} + + +static int +tp_mouse_setup (void) +{ + int retval; + + if (NULL == + (tp_mouse_dev = kmalloc (sizeof (struct input_dev), GFP_KERNEL))) + return -ENOMEM; + + /*init gpio */ + __gpio_as_input (TP_MOUSE_LEFT); + __gpio_disable_pull (TP_MOUSE_LEFT); + __gpio_as_input (TP_MOUSE_RIGHT); + __gpio_disable_pull (TP_MOUSE_RIGHT); + + memset (tp_mouse_dev, 0, sizeof (struct input_dev)); + + tp_mouse_dev->evbit[0] = BIT (EV_KEY) | BIT (EV_REL); + tp_mouse_dev->keybit[LONG (BTN_MOUSE)] = BIT (BTN_LEFT) | BIT (BTN_RIGHT); + tp_mouse_dev->relbit[0] = BIT (REL_X); + + input_register_device (tp_mouse_dev); + + return 0; +} + +static void +tp_mouse_exit (void) +{ + if (tp_mouse_dev) + { + input_unregister_device (tp_mouse_dev); + kfree (tp_mouse_dev); + } +} + +/* end */ +//wjx Fn + F5 change the lcd backlight +extern inline void __lcd_set_backlight_level (int n); + +static void +scan_kbd (unsigned long dummy) +{ + int col, scancode; + static int testcode = KEY_RESERVED; + int state; + int lcd_pwm_dut, key_down_flag = 0; + + dummy = dummy; + + memset (cur_keys, 0, sizeof (cur_keys)); + scan_keybd (cur_keys); + for (col = 0; col < KB_SCAN_LINE; col++) + { + unsigned char change = cur_keys[col] ^ last_keys[col]; + if (change) + { + int row; + for (row = 0; row < 8; row++) + { + if (((1U << row) & change) && (scancode = xy2code (col, row))) + { + DBG ("KB col=%d row=%d %d\n", col, row, scancode); + if (cur_keys[col] & (1U << row)) + { + key_down_flag = 1; + } + else + { + key_down_flag = 0; + } + if (last_keys[16] & (1 << 7)) + { // Fn key down + + extern void keyboard_set_codec_volume (int); + switch (scancode) + { + case KEY_F1: + scancode = KEY_F11; + break; + case KEY_F2: + scancode = KEY_F12; + break; + case KEY_F10: + scancode = KEY_SCROLLLOCK; + break; + case KEY_UP: + scancode = KEY_PAGEUP; + break; + case KEY_DOWN: + scancode = KEY_PAGEDOWN; + break; + case KEY_LEFT: + scancode = KEY_HOME; + break; + case KEY_RIGHT: + scancode = KEY_END; + break; + + case KEY_MINUS: + if (key_down_flag) + keyboard_set_codec_volume (0); + scancode = KEY_RESERVED; //wjx filter the - key + break; + case KEY_EQUAL: + if (key_down_flag) + keyboard_set_codec_volume (1); + scancode = KEY_RESERVED; //wjx filter the = key + break; + + case KEY_F4: + if (key_down_flag) { + lcd_pwm_dut = REG_PWM_DUT (0)*2/3 ; + if (lcd_pwm_dut <0) + lcd_pwm_dut = 0; + __lcd_set_backlight_level (lcd_pwm_dut); + } + scancode = KEY_RESERVED; //wjx filter the = key + break; + case KEY_F5: + if (key_down_flag) { + lcd_pwm_dut = (REG_PWM_DUT (0)+1)*3/2; + if (lcd_pwm_dut > 300) + lcd_pwm_dut = 300; + __lcd_set_backlight_level (lcd_pwm_dut); + } + scancode = KEY_RESERVED; //wjx filter the F5 key + break; + case KEY_F20: + if (key_down_flag && cur_keys[16] & (1U << 7)) // wjx 2008.5.19 change close the lcd back light + { + if (REG_PWM_DUT (0) != 0) + { + __lcd_set_backlight_level (0); + } + else + { + __lcd_set_backlight_level (300); + } + } + scancode = KEY_RESERVED; //wjx filter the F5 key + break; +#if 0 + case KEY_F9: + if (cur_keys[col] & (1U << row)) + testcode++; + scancode = testcode; + if (testcode == KEY_MAX) + testcode = KEY_RESERVED; + break; +#endif + } + } + if (scancode == KEY_CAPSLOCK && key_down_flag) //wjx + { + set_capslock_led (); + } + + if (scancode == KEY_NUMLOCK && key_down_flag) + { + set_numlock_led (); + } + + if (numlock_flag) //wjx 2008.2.25 add numlock keyboard function + { + switch (scancode) + { + case KEY_7: + scancode = KEY_KP7; + break; + case KEY_8: + scancode = KEY_KP8; + break; + case KEY_9: + scancode = KEY_KP9; + break; +#if 0 + case KEY_0: + if (key_down_flag) + { + input_report_key (kbd_dev, KEY_RIGHTSHIFT, 1); + scancode = KEY_8; + } + else + { + input_report_key (kbd_dev, KEY_8, 0); + scancode = KEY_KPRIGHTSHIFT; + } + break; +#endif + case KEY_0: + scancode = KEY_KPASTERISK; + break; + case KEY_U: + scancode = KEY_KP4; + break; + case KEY_I: + scancode = KEY_KP5; + break; + case KEY_O: + scancode = KEY_KP6; + break; + case KEY_P: + scancode = KEY_KPMINUS; + break; + + case KEY_J: + scancode = KEY_KP1; + break; + case KEY_K: + scancode = KEY_KP2; + break; + case KEY_L: + scancode = KEY_KP3; + break; +#if 0 + case KEY_SEMICOLON: + if (key_down_flag) + { + input_report_key (kbd_dev, KEY_RIGHTSHIFT, 1); + scancode = KEY_EQUAL; + } + else + { + input_report_key (kbd_dev, KEY_EQUAL, 0); + scancode = KEY_RIGHTSHIFT; + } + break; +#endif + case KEY_SEMICOLON: + scancode = KEY_KPPLUS; + break; + case KEY_SLASH: + scancode = KEY_KPSLASH; + break; + case KEY_M: + scancode = KEY_KP0; + break; + case KEY_DOT: + scancode = KEY_KPDOT; + break; + // case KEY_SLASH: scancode = KEY_SLASH; break; + } + } + + + if (scancode == KEY_F5 && fn_f5_flag) //wjx filter the fn + f5 key + { + scancode = KEY_RESERVED; + fn_f5_flag = 0; + } + if (scancode == KEY_F20) + scancode = KEY_RESERVED; //wjx filter the "zzz" key + + if (scancode != KEY_RESERVED) + input_report_key (kbd_dev, scancode, + (cur_keys[col] & (1U << row)) ? 1 : 0); + } + } + last_keys[col] = cur_keys[col]; + } + } + + /*for the "left-right" buttons beside touch pad.edwin */ + scan_mouse_left (); + scan_mouse_right (); + /*end */ + + start_scan_timer (); +} + +#ifndef SCAN_USE_TIMER +void +minipc_kbd_on_timer (void) +{ + if (kbd_start) + { + kbd_tick++; + kbd_tick %= SCANHZ; + if (0 == kbd_tick) + { + scan_kbd (0); + } + } +} +#endif + +static int +kbd_open (struct input_dev *dev) +{ + DBG ("%s %d\n", __FUNCTION__, kbd_refcount); + if (0 == kbd_refcount) + { +#ifdef SCAN_USE_TIMER + //memset (last_keys, 0, sizeof(last_keys)); + init_timer (&scan_timer); + + start_scan_timer (); +#endif + } + + kbd_refcount++; + return 0; +} + +static void +kbd_close (struct input_dev *dev) +{ + DBG ("%s %d\n", __FUNCTION__, kbd_refcount); + kbd_refcount--; + if (0 == kbd_refcount) + { +#ifdef SCAN_USE_TIMER + del_timer (&scan_timer); +#endif + } +} + +static int +kbd_event (struct input_dev *dev, unsigned int type, unsigned int code, + int value) +{ + return -1; +} + +static int Fn_scancode[] = + { KEY_F11, KEY_F12, KEY_SCROLLLOCK, KEY_PAGEUP, KEY_PAGEDOWN, KEY_HOME, +KEY_END, }; + +int __init +minipc_kbd_init (void) +{ + int nr; + int i, j; + + DBG ("%s 1\n", __FUNCTION__); + setup_keybd (); + DBG ("%s 2\n", __FUNCTION__); + + if (NULL == (kbd_dev = kmalloc (sizeof (*kbd_dev), GFP_KERNEL))) + return -ENOMEM; + + memset (kbd_dev, 0, sizeof (*kbd_dev)); + set_bit (EV_KEY, (kbd_dev->evbit)); + set_bit (EV_REP, (kbd_dev->evbit)); + DBG ("%s 3.2\n", __FUNCTION__); + for (i = 0; i < KB_SCAN_LINE; i++) + { + for (j = 0; j < 8; j++) + { + if (kmap[i][j]) + set_bit (kmap[i][j], (kbd_dev->keybit)); + } + } + for (i = 0; i < (sizeof (Fn_scancode) / sizeof (Fn_scancode[0])); i++) + set_bit (Fn_scancode[i], (kbd_dev->keybit)); + + clear_bit (0, kbd_dev->keybit); + + kbd_dev->event = kbd_event; + kbd_dev->open = kbd_open; + kbd_dev->close = kbd_close; + + input_register_device (kbd_dev); + /*for the "left-right" buttons beside touch pad.edwin */ + tp_mouse_setup (); + DBG ("%s 4 %p\n", __FUNCTION__, kbd_dev->handle); +#ifndef SCAN_USE_TIMER + kbd_start = 1; +#endif + return 0; +} + +static int __init +mod_minipc_kbd_init (void) +{ +#ifdef CONFIG_MINIPC_GPIOKB_MODULE + minipc_kbd_init (); +#endif +} + +static void __exit +minipc_kbd_exit (void) +{ + DBG ("%s 1\n", __FUNCTION__); + if (kbd_dev) + { + input_unregister_device (kbd_dev); + kfree (kbd_dev); + } + /*for the "left-right" buttons beside touch pad.edwin */ + tp_mouse_exit (); +} + +module_init (mod_minipc_kbd_init) module_exit (minipc_kbd_exit); --- celinux-040503.jz/drivers/char/minipc-misc.c 1970-01-01 01:00:00.000000000 +0100 +++ cel.new/drivers/char/minipc-misc.c 2008-09-10 10:45:32.000000000 +0200 @@ -0,0 +1,445 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* get the user-level API */ + +#include +#include +#include + + +#if 1 +#define MINIPC_CHAR_MAJOR 239 + +#define MINIPC_CHAR_POWER_SWITCH 0 + +const static char power_down_cmd[] = "powerdown"; +#define POWER_DOWN_CMD_LEN (sizeof(power_down_cmd)-1) + +static wait_queue_head_t wait_power_sw; + +static int power_off_pending = 0; +static void pic_shutdown (void); + +/*edwin for comunicate with the mcu for bat status*/ +#define MCU_DEV_ADDR (0x50>>1) +#define I2C_CLK 10000 +#define BAT_STAT_REG 0xDB +#define BAT_CHARGE_REG 0XD9 +static int get_battery_stat(unsigned char *data, unsigned char reg) +{ + int nr; + + i2c_open(); + + i2c_setclk(I2C_CLK); + nr = i2c_read(MCU_DEV_ADDR, data, reg, 1); + i2c_close(); + return nr; +} +/**/ +int mcu_exist() +{ + int nr; + unsigned char data; + + i2c_open(); + + i2c_setclk(I2C_CLK); + nr=i2c_read(MCU_DEV_ADDR, &data, BAT_CHARGE_REG, 1); + i2c_close(); + return nr; +} + +static int minipc_char_open(struct inode *inode, struct file *filp) +{ + unsigned char minor = MINOR(inode->i_cdev->dev); + filp->private_data = (void*)(unsigned long)minor; + return 0; +} + +static int minipc_char_release(struct inode *inode, struct file *filp) +{ + return 0; +} + +static int minipc_char_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) +{ + unsigned char data; + int ret; + int usr_time; + time_t timeout; + if( cmd == MCU_QUERY_BAT) + { + if(get_battery_stat(&data, BAT_CHARGE_REG) >= 0){ + copy_to_user((char *)arg, &data, sizeof(data)); + return sizeof(data); + } + } + if(cmd == SCHEDULE_POWEROFF){ + copy_from_user(&usr_time, (int *)arg, sizeof(usr_time)); + if(usr_time<=0) + return -EINVAL; + timeout = usr_time*100;//(jiffies=usr_time*1000(ms)/10(ms)) + set_current_state(TASK_UNINTERRUPTIBLE); + printk("slepp %d jiffies before shutdown\n",timeout); + schedule_timeout(timeout); + current->state = TASK_RUNNING; + pic_shutdown(); + } + return -EINVAL; +} + +static ssize_t minipc_char_read(struct file *filp, char *buf, size_t count, loff_t *ppos) +{ + unsigned char minor = (unsigned long)filp->private_data; + unsigned char data; + + if (MINIPC_CHAR_POWER_SWITCH == minor) + { + /* + int err = count; + while (1) + { + interruptible_sleep_on(&wait_power_sw); + + if (signal_pending(current)) + { + err = -EAGAIN; + break; + } + if (power_off_pending) + break; + schedule(); + } + return err; + */ + if(get_battery_stat(&data, BAT_STAT_REG) < 0) + return -EBUSY; + copy_to_user(buf, &data, sizeof(data)); + return sizeof(data); + + } + return -EINVAL; +} + +static ssize_t minipc_char_write(struct file *filp, const char *buf, size_t count, loff_t *ppos) +{ + unsigned char minor = (unsigned long)filp->private_data; + + if (MINIPC_CHAR_POWER_SWITCH == minor && count) + { + unsigned char tmp[POWER_DOWN_CMD_LEN]; + + if (count >= POWER_DOWN_CMD_LEN)// && copy_from_user(tmp, buf, POWER_DOWN_CMD_LEN)) + { + copy_from_user(tmp, buf, POWER_DOWN_CMD_LEN);//edwin + if (0 == memcmp (tmp, power_down_cmd, POWER_DOWN_CMD_LEN)) + { + pic_shutdown(); + } + } + return -EINVAL; + } + return 0; +} + +static unsigned int minipc_char_poll(struct file* filp, poll_table* wait) +{ + unsigned char minor = (unsigned long)filp->private_data; + + if (MINIPC_CHAR_POWER_SWITCH == minor) + { + poll_wait(filp, &wait_power_sw, wait); + return 0; + } + return -EINVAL; +} + +static struct file_operations minipc_char_fops = { + open: minipc_char_open, + read: minipc_char_read, + write: minipc_char_write, + ioctl: minipc_char_ioctl, + release:minipc_char_release, + poll: minipc_char_poll, +}; + +#define PIC_GPIO (65) //wjx 2007.12.10 89 -> 65 +#define PIC_IRQ (IRQ_GPIO_0 + PIC_GPIO) + +#define LPC915 1 +#ifdef LPC915 //edwin +#define SHUTDOWN_REG 0xD8 +static void pic_shutdown (void) +{ + int nr; + unsigned char data = 1; + printk("pic_shutdown\n"); +#if 0 + while(i2c_open()== 0) + break; +#else + i2c_open(); //wjx +#endif + i2c_setclk(I2C_CLK); + nr = i2c_write(MCU_DEV_ADDR, &data, SHUTDOWN_REG, 1); + i2c_close(); +} +#else +static void pic_shutdown (void) +{ + unsigned long flags; + + printk ("MiniPC Power Off!\n"); + mdelay (200); + local_irq_save(flags); + __gpio_as_output(PIC_GPIO); + __gpio_clear_pin(PIC_GPIO); + mdelay(200); + __gpio_set_pin(PIC_GPIO); + mdelay(50); + __gpio_as_input(PIC_GPIO); + local_irq_restore(flags); +} +#endif + +static void pic_irq(int irq, void *dev_id, struct pt_regs * regs) +{ + power_off_pending ++; + wake_up_interruptible (&wait_power_sw); +} + +static int power_down_read_proc (char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + + len += sprintf (page+len, "Write me '%s' to power down.\n", power_down_cmd); + return len; +} + +static int power_down_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) +{ + if (count >= POWER_DOWN_CMD_LEN) + { + if (0 == memcmp (power_down_cmd, buffer, POWER_DOWN_CMD_LEN)) + pic_shutdown (); + } + return count; +} + +static struct proc_dir_entry *proc_powerdown; + +static void (*_old_machine_power_off)(void); + +static int __init pic_init(void) +{ + int retval; + + __gpio_as_irq(PIC_GPIO, 2); //falling-edge + + init_waitqueue_head(&wait_power_sw); + + proc_powerdown = create_proc_entry("powerdown", 0644, NULL); + if (proc_powerdown) { + proc_powerdown->read_proc = power_down_read_proc; + proc_powerdown->write_proc = power_down_write_proc; + proc_powerdown->data = NULL; + } + + register_chrdev(MINIPC_CHAR_MAJOR, "MiniPC", &minipc_char_fops); + + retval = request_irq (PIC_IRQ, pic_irq, SA_INTERRUPT, "Power switch", NULL); + if (retval) + printk ("Cannot get Power SW irq %d\n", retval); + else + { + _old_machine_power_off = _machine_power_off; + _machine_power_off = pic_shutdown; + } + printk ("Setup MiniPC Power button.\n"); + return retval; +} + +static void __exit pic_exit(void) +{ + free_irq(PIC_IRQ, NULL); + if (proc_powerdown) + remove_proc_entry("powerdown", NULL); + if (_old_machine_power_off) + _machine_power_off = _old_machine_power_off; + + unregister_chrdev(MINIPC_CHAR_MAJOR, "MiniPC"); +} + + +module_init(pic_init); +module_exit(pic_exit); + +#else +#define PIC_DEVADDR (0x31) + +extern void i2c_open(void); +extern void i2c_close(void); +extern int i2c_read(unsigned char device, unsigned char *buf, + unsigned char address, int count); +extern int i2c_write(unsigned char device, unsigned char *buf, + unsigned char address, int count); + +extern int i2c_read_na(unsigned char device, unsigned char *buf, int count); +extern int i2c_write_na(unsigned char device, unsigned char *buf, int count); +extern void i2c_setclk(unsigned int i2cclk); + + +#define I2C_FRAME_LEN 2 + + +static unsigned char i2c_recv[I2C_FRAME_LEN]; +static unsigned long recv_tick; + +static unsigned char i2c_send[I2C_FRAME_LEN]; + + +static void read_pic(void) +{ + int nr; + unsigned char buff[I2C_FRAME_LEN]; + + i2c_open (); + //wjx i2c_setclk(1000); + nr = i2c_read_na (PIC_DEVADDR, buff, I2C_FRAME_LEN); + i2c_close(); + + if (nr == I2C_FRAME_LEN) + { + memcpy (i2c_recv, buff, I2C_FRAME_LEN); + recv_tick = jiffies; + } +} + +static void write_pic(void) +{ + int nr; + + i2c_open(); + //wjx i2c_setclk(1000); + nr = i2c_write_na(PIC_DEVADDR, i2c_send, I2C_FRAME_LEN); + i2c_close(); +} + +/* RTC */ +extern spinlock_t rtc_lock; +static int rtc_status = 0; +static unsigned int epoch = 1900; + +static void get_rtc_time(struct rtc_time* rtc_tm) +{ + +} + +static int set_rtc_time(struct rtc_time* rtc_tm) +{ + return 0; +} + +static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rtc_time wtime, rtc_tm; + + switch (cmd) + { + case RTC_RD_TIME: + get_rtc_time(&wtime); + break; + case RTC_SET_TIME: + if (!capable(CAP_SYS_TIME)) + return -EACCES; + if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time))) + return -EFAULT; + return set_rtc_time(&rtc_tm); + case RTC_EPOCH_READ: + return put_user(epoch, (unsigned long*)arg); + case RTC_EPOCH_SET: + if (arg < 1900) + return -EINVAL; + if (!capable(CAP_SYS_TIME)) + return -EACCES; + epoch = arg; + return 0; + case RTC_ALM_READ: + case RTC_ALM_SET: + default: + return -EINVAL; + } + + return copy_to_user((void*)arg, &wtime, sizeof(wtime))?-EFAULT:0; +} + + +static int rtc_open(struct inode *inode, struct file *file) +{ + spin_lock_irq(&rtc_lock); + + if(rtc_status) + goto out_busy; + + rtc_status = 1; + + spin_unlock_irq (&rtc_lock); + return 0; + +out_busy: + return -EBUSY; +} + +static int rtc_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static struct file_operations rtc_fops = { + owner: THIS_MODULE, + llseek: no_llseek, + ioctl: rtc_ioctl, + open: rtc_open, + release: rtc_release, +}; + +#define RTC_MINOR 135 +static struct miscdevice rtc_dev = { + RTC_MINOR, + "rtc", + &rtc_fops, +}; + + +static int __init pic_init(void) +{ + int r; + + r = misc_register(&rtc_dev); + + return 0; +} + +static void __exit pic_exit(void) +{ + misc_deregister(&rtc_dev); +} + + +module_init(pic_init); +module_exit(pic_exit); +#endif --- celinux-040503.jz/drivers/char/pc_keyb.c 2008-10-02 18:42:11.000000000 +0200 +++ cel.new/drivers/char/pc_keyb.c 2008-09-10 10:45:32.000000000 +0200 @@ -1028,12 +1028,13 @@ void __init pckbd_init_hw(void) /* Flush any pending input. */ kbd_clear_input(); - +/********* maybe we don't need reset keyboard************* if (kbd_startup_reset) { char *msg = initialize_kbd(); if (msg) printk(KERN_WARNING "initialize_kbd: %s\n", msg); } +********* by czj ,wjx add after*****************************************/ #if defined CONFIG_PSMOUSE psaux_init(); #endif --- celinux-040503.jz/drivers/char/tty_ioctl.c 2002-11-29 00:53:12.000000000 +0100 +++ cel.new/drivers/char/tty_ioctl.c 2008-09-10 10:45:34.000000000 +0200 @@ -29,6 +29,48 @@ #undef DEBUG +#define BOTHER 0010000 +#define IBSHIFT 8 + +void tty_termios_encode_baud_rate(struct termios *termios, speed_t ibaud, speed_t obaud); + +/* + * Routine which returns the baud rate of the tty + * + * Note that the baud_table needs to be kept in sync with the + * include/asm/termbits.h file. + */ +static const speed_t baud_table[] = { + 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, + 9600, 19200, 38400, 57600, 115200, 230400, 460800, +#ifdef __sparc__ + 76800, 153600, 307200, 614400, 921600 +#else + 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, + 2500000, 3000000, 3500000, 4000000 +#endif +}; + +#ifndef __sparc__ +static const tcflag_t baud_bits[] = { + B0, B50, B75, B110, B134, B150, B200, B300, B600, + B1200, B1800, B2400, B4800, B9600, B19200, B38400, + B57600, B115200, B230400, B460800, B500000, B576000, + B921600, B1000000, B1152000, B1500000, B2000000, B2500000, + B3000000, B3500000, B4000000 +}; +#else +static const tcflag_t baud_bits[] = { + B0, B50, B75, B110, B134, B150, B200, B300, B600, + B1200, B1800, B2400, B4800, B9600, B19200, B38400, + B57600, B115200, B230400, B460800, B76800, B153600, + B307200, B614400, B921600 +}; +#endif + +static int n_baud_table = ARRAY_SIZE(baud_table); + + /* * Internal flag options for termios setting behavior */ @@ -511,3 +553,58 @@ int n_tty_ioctl(struct tty_struct * tty, } EXPORT_SYMBOL(n_tty_ioctl); + +void tty_termios_copy_hw(struct termios *new, struct termios *old) +{ + /* The bits a dumb device handles in software. Smart devices need + to always provide a set_termios method */ + new->c_cflag &= HUPCL | CREAD | CLOCAL; + new->c_cflag |= old->c_cflag & ~(HUPCL | CREAD | CLOCAL); + new->c_iflag = old->c_iflag; + new->c_oflag = old->c_oflag; +} + +EXPORT_SYMBOL(tty_termios_copy_hw); + +void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud) +{ + tty_termios_encode_baud_rate(tty->termios, ibaud, obaud); //czj +} + + +void tty_termios_encode_baud_rate(struct termios *termios, speed_t ibaud, speed_t obaud) +{ + int i = 0; + int ifound = 0, ofound = 0; + + termios->c_iflag = ibaud; + termios->c_oflag = obaud; + + termios->c_cflag &= ~CBAUD; + /* Identical speed means no input encoding (ie B0 << IBSHIFT)*/ + if (termios->c_iflag == termios->c_oflag) + ifound = 1; + + do { + if (obaud == baud_table[i]) { + termios->c_cflag |= baud_bits[i]; + ofound = 1; + /* So that if ibaud == obaud we don't set it */ + continue; + } + if (ibaud == baud_table[i]) { + termios->c_cflag |= (baud_bits[i] << IBSHIFT);//IBSHIFT + ifound = 1; + } + } + while(++i < n_baud_table); + if (!ofound) + termios->c_cflag |= BOTHER; + if (!ifound) + termios->c_cflag |= (BOTHER << IBSHIFT); +} + +EXPORT_SYMBOL(tty_encode_baud_rate); +EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate); + + --- celinux-040503.jz/drivers/input/input.c 2001-09-30 21:26:05.000000000 +0200 +++ cel.new/drivers/input/input.c 2008-09-30 20:37:50.000000000 +0200 @@ -35,6 +35,9 @@ #include #include +#include //wjx +#include + MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Input layer module"); MODULE_LICENSE("GPL"); @@ -60,6 +63,10 @@ static devfs_handle_t input_devfs_handle static int input_number; static long input_devices[NBITS(INPUT_DEVICES)]; +extern unsigned int not_input_event_time; //wjx from arm/mips/jz4730/common/time.c +//wjx change the lcd backlight +extern inline void __lcd_set_backlight_level(int n); + void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { struct input_handle *handle = dev->handle; @@ -67,10 +74,18 @@ void input_event(struct input_dev *dev, /* * Filter non-events, and bad input values out. */ - if (type > EV_MAX || !test_bit(type, dev->evbit)) return; +#ifdef CONFIG_FB_JZ //wjx + if((0x80®_PWM_CTR(0)) == 0 ) //wjx turn on the backlight if the backlight is off + { + __lcd_set_backlight_level(-1); // Resume backlight with previous level + } +#endif + + not_input_event_time = 0; //wjx any input event happen,so the time set to zero + switch (type) { case EV_KEY: --- celinux-040503.jz/drivers/mtd/nand/jz4730.c 2008-10-02 18:42:12.000000000 +0200 +++ cel.new/drivers/mtd/nand/jz4730.c 2008-09-10 10:45:46.000000000 +0200 @@ -23,7 +23,10 @@ #include #include -#define NAND_DATA_PORT 0xB4000000 /* read-write area */ +#define NAND_DATA_PORT (0xB4000000) /* read-write area */ +#define NAND_DATA_PORT_1 (0xB4000000 | 1 << 17 | 1 << 16) /* wjx add the second 2G nand flash read-write area */ + + #define __nand_ecc() (REG_EMC_NFECC & 0x00ffffff) #define __nand_ecc_enable() (REG_EMC_NFCSR |= EMC_NFCSR_ECCE | EMC_NFCSR_ERST) #define __nand_ecc_disable() (REG_EMC_NFCSR &= ~EMC_NFCSR_ECCE) @@ -32,6 +35,7 @@ * MTD structure for JzSOC board */ static struct mtd_info *jz_mtd = NULL; +static struct mtd_info *jz_mtd_1 = NULL; /* * Define partitions for flash devices @@ -49,7 +53,7 @@ static struct mtd_partition partition_in size: 56 * 0x100000}, { name: "NAND SSFDC partition", offset: 64 * 0x100000, - size: 64 * 0x100000}, + size: 64 * 0x100000s}, }; /* Define max reserved bad blocks for each partition. @@ -64,16 +68,36 @@ static struct mtd_partition partition_in static int partition_reserved_badblocks[] = {2, 2, 10, 10}; #elif CONFIG_MIPS_JZ4730_PMPV1 +//wjx static struct mtd_partition partition_info[] = { - { name: "NAND ROOTFS partition", - offset: 3 * 0x100000, - size: (32-3) * 0x100000}, - { name: "NAND DATAFS partition", - offset: 32 * 0x100000, - size: 32 * 0x100000}, + { name: "bootloader partition", + offset: 0 * 0x100000, + size: (1) * 0x100000}, + { name: "kernel partition", + offset: 1 * 0x100000, + size: (3) * 0x100000}, + { name: "mac partition", + offset: 4 * 0x100000, + size: (1) * 0x100000}, + { name: "mini rootfs partition", + offset: 5 * 0x100000, + size: (5) * 0x100000}, + { name: "yaffs2 rootfs partition", + offset: 10 * 0x100000, + size: 502 * 0x100000}, }; -static int partition_reserved_badblocks[] = {2, 8}; +#ifdef CONFIG_MTD_NAND_2G +static struct mtd_partition partition_info_1[] = { + { name: "extend 1G flash", + offset: 0 * 0x100000, + size: (1024) * 0x100000}, +}; +static int partition_reserved_badblocks[] = {0,0,0,2,40,40}; //wjx +#else +static int partition_reserved_badblocks[] = {0,0,0,2,40}; +#endif + #else static struct mtd_partition partition_info[] = { { name: "NAND ROOTFS partition", @@ -159,6 +183,7 @@ static void jz_device_setup(void) { /* Set NFE bit */ REG_EMC_NFCSR |= EMC_NFCSR_NFE; + REG_EMC_SMCR3 = 0x04444400; //wjx add } static void jzsoc_nand_enable_hwecc(struct mtd_info* mtd, int mode) @@ -282,8 +307,9 @@ static int jzsoc_nand_correct_data(struc int __init jznand_init(void) { struct nand_chip *this; + struct nand_chip *this_1; int nr_partitions; - + int nr_partitions_1; /* Allocate memory for MTD device structure and private data */ jz_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), GFP_KERNEL); @@ -291,7 +317,6 @@ int __init jznand_init(void) printk ("Unable to allocate JzSOC NAND MTD device structure.\n"); return -ENOMEM; } - /* Get pointer to private data */ this = (struct nand_chip *) (&jz_mtd[1]); @@ -302,35 +327,65 @@ int __init jznand_init(void) /* Link the private data with the MTD structure */ jz_mtd->priv = this; - /* Set & initialize NAND Flash controller */ - jz_device_setup(); - /* Set address of NAND IO lines */ this->IO_ADDR_R = (void __iomem *) NAND_DATA_PORT; this->IO_ADDR_W = (void __iomem *) NAND_DATA_PORT; this->hwcontrol = jz_hwcontrol; this->dev_ready = jz_device_ready; + +#ifdef CONFIG_MTD_NAND_2G + + jz_mtd_1 = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), + GFP_KERNEL); + if(!jz_mtd_1) { + printk ("Unable to allocate JzSOC NAND MTD device structure.\n"); + return -ENOMEM; + } + this_1 = (struct nand_chip *) (&jz_mtd_1[1]); + + memset((char *) jz_mtd_1, 0, sizeof(struct mtd_info)); + memset((char *) this_1, 0, sizeof(struct nand_chip)); + + jz_mtd_1->priv = this_1; + + this_1->IO_ADDR_R = (void __iomem *) NAND_DATA_PORT_1; + this_1->IO_ADDR_W = (void __iomem *) NAND_DATA_PORT_1; + this_1->hwcontrol = jz_hwcontrol; + this_1->dev_ready = jz_device_ready; +#endif + + /* Set & initialize NAND Flash controller */ + jz_device_setup(); + #ifdef CONFIG_MTD_HW_HM_ECC this->correct_data = jzsoc_nand_correct_data; this->enable_hwecc = jzsoc_nand_enable_hwecc; this->calculate_ecc = jzsoc_nand_calculate_ecc; - this->eccmode = NAND_ECC_HW3_256;; + this->eccmode = NAND_ECC_HW3_256; + +#ifdef CONFIG_MTD_NAND_2G + this_1->correct_data = jzsoc_nand_correct_data; + this_1->enable_hwecc = jzsoc_nand_enable_hwecc; + this_1->calculate_ecc = jzsoc_nand_calculate_ecc; + this_1->eccmode = NAND_ECC_HW3_256; +#endif #endif #ifdef CONFIG_MTD_SW_HM_ECC this->eccmode = NAND_ECC_SOFT; +#ifdef CONFIG_MTD_NAND_2G + this_1->eccmode = NAND_ECC_SOFT; +#endif #endif /* 20 us command delay time */ this->chip_delay = 20; - /* Scan to find existance of the device */ if (nand_scan(jz_mtd, 1)) { kfree (jz_mtd); return -ENXIO; } - /* Allocate memory for internal data buffer */ this->data_buf = kmalloc (sizeof(u_char) * (jz_mtd->oobblock + jz_mtd->oobsize), GFP_KERNEL); if (!this->data_buf) { @@ -343,8 +398,28 @@ int __init jznand_init(void) /* Register the partitions */ nr_partitions = sizeof(partition_info) / sizeof(struct mtd_partition); + partition_info[nr_partitions - 1].size = (1 << this->chip_shift) - partition_info[nr_partitions - 1].offset; //wjx add_mtd_partitions(jz_mtd, partition_info, nr_partitions); +#ifdef CONFIG_MTD_NAND_2G + this_1->chip_delay = 20; + /* Scan to find existance of the device */ + if (nand_scan(jz_mtd_1, 1)) { + kfree (jz_mtd_1); + return -ENXIO; + } + /* Allocate memory for internal data buffer */ + this_1->data_buf = kmalloc (sizeof(u_char) * (jz_mtd_1->oobblock + jz_mtd_1->oobsize), GFP_KERNEL); + if (!this_1->data_buf) { + printk ("Unable to allocate NAND data buffer for JzSOC.\n"); + kfree (jz_mtd_1); + return -ENOMEM; + } + nr_partitions_1 = sizeof(partition_info_1) / sizeof(struct mtd_partition); + partition_info_1[nr_partitions_1 - 1].size = (1 << this_1->chip_shift) - partition_info_1[nr_partitions_1 - 1].offset; //wjx + add_mtd_partitions(jz_mtd_1, partition_info_1, 1); +#endif + return 0; } --- celinux-040503.jz/drivers/mtd/nand/nand_base.c 2008-10-02 18:42:12.000000000 +0200 +++ cel.new/drivers/mtd/nand/nand_base.c 2008-09-10 10:45:46.000000000 +0200 @@ -1324,7 +1324,7 @@ int nand_do_read_ecc (struct mtd_info *m case NAND_ECC_NONE: { /* No ECC, Read in a page */ static unsigned long lastwhinge = 0; if ((lastwhinge / HZ) != (jiffies / HZ)) { - printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n"); + //printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n"); lastwhinge = jiffies; } this->read_buf(mtd, data_poi, end); --- celinux-040503.jz/drivers/mtd/util/nandwrite.c 2008-10-02 18:42:12.000000000 +0200 +++ cel.new/drivers/mtd/util/nandwrite.c 2008-09-10 10:45:49.000000000 +0200 @@ -327,7 +327,7 @@ int main(int argc, char **argv) blockstart = mtdoffset & (~meminfo.erasesize + 1); offs = blockstart; baderaseblock = 0; - if (!quiet) + if (!quiet && !(blockstart & 0xffffff)) fprintf (stdout, "Writing data to block %x\n", blockstart); /* Check all the blocks in an erase block for bad blocks */ @@ -388,7 +388,7 @@ int main(int argc, char **argv) imglen -= readlen; mtdoffset += meminfo.oobblock; } - + fprintf(stdout,"write data to mtdoffset %d\n",mtdoffset); closeall: close(ifd); --- celinux-040503.jz/drivers/net/Jz_eth.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/net/Jz_eth.c 2008-09-10 10:45:50.000000000 +0200 @@ -16,6 +16,7 @@ #include #include +//#include //wjx #include "Jz_eth.h" #define ALIGN4 ((u_long)4 - 1) /* 1 longword align */ @@ -26,6 +27,7 @@ #define ALIGN128 ((u_long)128 - 1) /* 32 longword align */ #define ALIGN ALIGN64 +#define NETWORK_LED_GPIO 9 //wjx network led gpio //#define DEBUGFLAG #ifdef DEBUGFLAG @@ -245,6 +247,7 @@ static int close_check(struct net_device errprintk("%s: unable to signal thread\n", dev->name); return 1; } + complete(&mp->thr_exited);//wjx vanpro add it to prevent mp->thr_exited wait for null. wait_for_completion (&mp->thr_exited); } return 0; @@ -284,14 +287,21 @@ static int link_check_thread(void *data) break; current_link=mii_link_ok(&mii_info); + if (mp->link_state!=current_link) { if (current_link) { + __gpio_as_output(NETWORK_LED_GPIO); + __gpio_clear_pin(NETWORK_LED_GPIO); //wjx 2008.3.25 up eth0 led + infoprintk("%s: Ethernet Link OK!\n",net_dev->name); //jz_ethernet_hw_init(net_dev); jz_eth_curr_mode(dev); netif_carrier_on(net_dev); } else { + __gpio_as_output(NETWORK_LED_GPIO); + __gpio_set_pin(NETWORK_LED_GPIO); //wjx 2008.3.25 down eth0 led + errprintk("%s: Ethernet Link offline!\n",net_dev->name); netif_carrier_off(net_dev); } @@ -589,12 +599,22 @@ static int read_eeprom(struct net_device } if ((dev->dev_addr[0] & 0xC0) || (flag0 == 0) || (flag1 == 0xff)) { printk(KERN_WARNING "WARNING:There is not MAC address in HCI or command line! Manually set it ..\n"); + //dev->dev_addr[0] = 0x00; + //dev->dev_addr[1] = 0xac; + //dev->dev_addr[2] = 0x47; + //dev->dev_addr[3] = 0x19; + //dev->dev_addr[4] = 0x75; + //dev->dev_addr[5] = 0x11; + /*edwin 08-04-01*/ + { dev->dev_addr[0] = 0x00; - dev->dev_addr[1] = 0xac; - dev->dev_addr[2] = 0x47; - dev->dev_addr[3] = 0x19; - dev->dev_addr[4] = 0x75; - dev->dev_addr[5] = 0x11; + dev->dev_addr[1] = 0x21; + dev->dev_addr[2] = 0x4d; + dev->dev_addr[3] = 0x00; + dev->dev_addr[4] = 0x00; + dev->dev_addr[5] = 0x01; + } + /***/ } return 0; } @@ -934,7 +954,7 @@ static void mii_db_out(struct net_device static int jz_autonet_complete(struct net_device *dev) { struct jz_eth_private *mp = (struct jz_eth_private *)dev->priv; - unsigned int mii_reg1, timeout = 1000; + unsigned int mii_reg1, timeout = 100; //wjx chang 1000 -> 100 to speedup check the network offline status while (timeout) { //read status register for checking @@ -943,6 +963,7 @@ static int jz_autonet_complete(struct ne mdelay(1); timeout--; } + // mii_db_out(dev); //to display all register of MII for debugging if (timeout == 0) return 1; //auto negotiation error @@ -1000,6 +1021,7 @@ static int jz_ethernet_hw_init(struct ne struct ethtool_cmd ecmd; int i; + /* Onchip net module reset */ jz_netdevice_reset(); STOP_ETH; @@ -1074,6 +1096,7 @@ static int jz_ethernet_hw_init(struct ne /* Reset any pending (stale) interrupts */ sts = readl(DMA_STS); writel(sts, DMA_STS); + return 0; } @@ -1137,7 +1160,7 @@ static int jz_eth_open(struct net_device return -EAGAIN; } DBPRINTK("OK! Device Completed!\n"); - start_check(dev); +//start_check(dev); //wjx vanpro move it to jz_eth_module_init return 0; } /*********************************************************************** @@ -1152,7 +1175,7 @@ static int jz_eth_close(struct net_devic del_timer_sync(&mp->timer); MOD_DEC_USE_COUNT; netif_stop_queue(dev); - close_check(dev); + //close_check(dev); //wjx vanpro move it to jz_eth_module_exit STOP_ETH; synchronize_irq (); free_irq (dev->irq, dev); @@ -1467,6 +1490,8 @@ static int __init jz_eth_module_init(voi int result; unsigned int AllocSize; + __gpio_as_eth(); + /* * get the Silicon Revision ID. If this is one of the known * one assume that we found a SONIC ethernet controller at @@ -1519,7 +1544,8 @@ static int __init jz_eth_module_init(voi mp->dma_rx_ring = virt_to_bus(mp->rx_ring); mp->dma_tx_ring = virt_to_bus(mp->tx_ring); mp->full_duplex = 1; - mp->link_state = 1; +//wjx mp->link_state = 1; + mp->link_state = 0; //wjx set to 0 for check the network status after boot kernel /* search MII PHY address */ mp->mii_phy_cnt=jz_search_mii_phy_addr(dev); infoprintk("%s:Find %d PHY (%d) from MAC.\n",dev->name,mp->mii_phy_cnt, mp->valid_phy); @@ -1545,12 +1571,13 @@ static int __init jz_eth_module_init(voi if (mp->pmdev) mp->pmdev->data = dev; #endif - + start_check(dev); //wjx vanpro move it from jz_eth_open to here to prevent mutil thread error. return 0; } static void __exit jz_eth_module_exit(void) { + close_check(dev); //wjx vanpro move it from jz_eth_close to here unregister_netdev (dev); DBPRINTK("exit------- 1"); dma_free(temp_priv); --- celinux-040503.jz/drivers/scsi/hosts.h 2002-11-29 00:53:14.000000000 +0100 +++ cel.new/drivers/scsi/hosts.h 2008-09-10 10:45:51.000000000 +0200 @@ -298,6 +298,8 @@ typedef struct SHT */ char *proc_name; + int usb_disconnect_flag; //edwin + } Scsi_Host_Template; /* --- celinux-040503.jz/drivers/scsi/scsi.c 2002-11-29 00:53:14.000000000 +0100 +++ cel.new/drivers/scsi/scsi.c 2008-09-10 10:45:51.000000000 +0200 @@ -2025,6 +2025,9 @@ static int scsi_register_host(Scsi_Host_ * Similarly, this entry point should be called by a loadable module if it * is trying to remove a low level scsi driver from the system. */ +//#define TRACE(args...) printk(args) +#define TRACE(args...) + static int scsi_unregister_host(Scsi_Host_Template * tpnt) { int online_status; @@ -2037,6 +2040,7 @@ static int scsi_unregister_host(Scsi_Hos struct Scsi_Host *shpnt; char name[10]; /* host_no>=10^9? I don't think so. */ + TRACE("%s 1\n", __FUNCTION__); /* get the big kernel lock, so we don't race with open() */ lock_kernel(); @@ -2044,9 +2048,11 @@ static int scsi_unregister_host(Scsi_Hos * First verify that this host adapter is completely free with no pending * commands */ +#if 0 for (shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next) { for (SDpnt = shpnt->host_queue; SDpnt; SDpnt = SDpnt->next) { + TRACE("%d %d %d\n", SDpnt->host->hostt == tpnt,(int)SDpnt->host->hostt->module,(int)GET_USE_COUNT(SDpnt->host->hostt->module)); if (SDpnt->host->hostt == tpnt && SDpnt->host->hostt->module && GET_USE_COUNT(SDpnt->host->hostt->module)) @@ -2060,6 +2066,8 @@ static int scsi_unregister_host(Scsi_Hos */ } } +#endif + TRACE("%s 2\n", __FUNCTION__); /* * FIXME(eric) put a spinlock on this. We force all of the devices offline @@ -2074,6 +2082,7 @@ static int scsi_unregister_host(Scsi_Hos } } + TRACE("%s 3\n", __FUNCTION__); for (shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next) { if (shpnt->hostt != tpnt) { @@ -2102,6 +2111,13 @@ static int scsi_unregister_host(Scsi_Hos } SDpnt->online = online_status; printk(KERN_ERR "Device busy???\n"); + + /*edwin.If usb is disconnected detach the driver*/ + if(tpnt->usb_disconnect_flag == 1) + break; + /*edwin*/ + + goto err_out; } /* @@ -2114,6 +2130,7 @@ static int scsi_unregister_host(Scsi_Hos } } /* Next we detach the high level drivers from the Scsi_Device structures */ + TRACE("%s 4\n", __FUNCTION__); for (shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next) { if (shpnt->hostt != tpnt) { @@ -2122,17 +2139,27 @@ static int scsi_unregister_host(Scsi_Hos for (SDpnt = shpnt->host_queue; SDpnt; SDpnt = SDpnt->next) { for (sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next) - if (sdtpnt->detach) + if (sdtpnt->detach){ + + /*edwin.Set usb_disconnect_flag*/ + if(tpnt->usb_disconnect_flag == 1) + SDpnt->dev_disconnected = 1; + /*edwin*/ + (*sdtpnt->detach) (SDpnt); + } /* If something still attached, punt */ if (SDpnt->attached) { printk(KERN_ERR "Attached usage count = %d\n", SDpnt->attached); +#if 0 /* for CPC-400 */ goto err_out; +#endif } devfs_unregister (SDpnt->de); } } + TRACE("%s 5\n", __FUNCTION__); /* * Next, kill the kernel error recovery thread for this host. @@ -2149,6 +2176,7 @@ static int scsi_unregister_host(Scsi_Hos shpnt->eh_notify = NULL; } } + TRACE("%s 6\n", __FUNCTION__); /* Next we free up the Scsi_Cmnd structures for this host */ @@ -2167,6 +2195,7 @@ static int scsi_unregister_host(Scsi_Hos } } + TRACE("%s 7\n", __FUNCTION__); /* Next we go through and remove the instances of the individual hosts * that were detected */ @@ -2198,6 +2227,7 @@ static int scsi_unregister_host(Scsi_Hos scsi_unregister(shpnt); tpnt->present--; } + TRACE("%s 8\n", __FUNCTION__); /* * If there are absolutely no more hosts left, it is safe @@ -2217,6 +2247,7 @@ static int scsi_unregister_host(Scsi_Hos (scsi_init_memory_start - scsi_memory_lower_value) / 1024, (scsi_memory_upper_value - scsi_init_memory_start) / 1024); #endif + TRACE("%s 9\n", __FUNCTION__); /* * Remove it from the linked list and /proc if all @@ -2334,6 +2365,7 @@ static int scsi_unregister_device(struct { Scsi_Device *SDpnt; struct Scsi_Host *shpnt; + TRACE("%s 1\n", __FUNCTION__); lock_kernel(); /* @@ -2386,6 +2418,8 @@ error_out: */ int scsi_register_module(int module_type, void *ptr) { + TRACE("%s 1 %d\n", __FUNCTION__, module_type); + switch (module_type) { case MODULE_SCSI_HA: return scsi_register_host((Scsi_Host_Template *) ptr); --- celinux-040503.jz/drivers/scsi/scsi.h 2002-11-29 00:53:14.000000000 +0100 +++ cel.new/drivers/scsi/scsi.h 2008-09-10 10:45:51.000000000 +0200 @@ -611,6 +611,7 @@ struct scsi_device { // Flag to allow revalidate to succeed in sd_open int allow_revalidate; + int dev_disconnected; //edwin }; --- celinux-040503.jz/drivers/scsi/sd.c 2002-08-03 02:39:44.000000000 +0200 +++ cel.new/drivers/scsi/sd.c 2008-09-10 10:45:51.000000000 +0200 @@ -1397,7 +1397,15 @@ static void sd_detach(Scsi_Device * SDp) for (j = max_p - 1; j >= 0; j--) { int index = start + j; + + /*edwin.If "usb_disconnect_flag" is set,don't do fsync_dev*/ + if(SDp->dev_disconnected == 1){ + invalidate_device(MKDEV_SD_PARTITION(index), 0); + destroy_buffers(MKDEV_SD_PARTITION(index)); + }else invalidate_device(MKDEV_SD_PARTITION(index), 1); + /*edwin*/ + sdgd->part[SD_MINOR_NUMBER(index)].start_sect = 0; sdgd->part[SD_MINOR_NUMBER(index)].nr_sects = 0; sd_sizes[index] = 0; --- celinux-040503.jz/drivers/sound/Jz_i2s.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/sound/Jz_i2s.c 2008-09-10 10:45:52.000000000 +0200 @@ -81,7 +81,8 @@ void (*clear_codec_direct_mode)(void) = static int jz_audio_rate; static char jz_audio_format; -static char jz_audio_volume; +//wjx static char jz_audio_volume; +static char jz_audio_volume = 50; static char jz_audio_channels; static int jz_audio_b; /* bits expand multiple */ static int jz_audio_fragments; /* unused fragment amount */ @@ -899,6 +900,32 @@ static struct file_operations jz_i2s_mix open: jz_i2s_open_mixdev, }; +//wjx set the volume from the keyboard 2008.3.22 +#define MAX_VOLUME 100 +void keyboard_set_codec_volume(int lower) +{ + if(lower) + { + if(jz_audio_volume >= MAX_VOLUME) return; //wjx add 2008.2.27 the volume 0 ~ 100 + if(jz_audio_volume > (MAX_VOLUME - 10)) + jz_audio_volume = MAX_VOLUME; + else + jz_audio_volume += 10; + } + else + { + if(jz_audio_volume == 0) return; + if(jz_audio_volume < 10) + jz_audio_volume = 0; + else + jz_audio_volume -= 10; + } + if(set_codec_volume) + { + set_codec_volume(jz_audio_volume); + } +} + static int i2s_mixer_ioctl(struct i2s_codec *codec, unsigned int cmd, unsigned long arg) { int ret; @@ -925,7 +952,8 @@ static int i2s_mixer_ioctl(struct i2s_co val = SOUND_CAP_EXCL_INPUT; return put_user(val, (long *) arg); case SOUND_MIXER_READ_DEVMASK: - break; + val=1;//@vanpro Skytone + return put_user(val, (int *)arg); case SOUND_MIXER_READ_RECMASK: break; case SOUND_MIXER_READ_RECSRC: @@ -981,8 +1009,13 @@ static int i2s_mixer_ioctl(struct i2s_co val = val & 0xff; if(val < 0) val = 0; +/* if(val > 100) val = 100; +*/ + if(val > 99) //wjx 2008.5.5 solve the keyboard cann't turn up the volume first time if the volume set 100 here + val = 99; + jz_audio_volume = val; if(set_codec_volume) --- celinux-040503.jz/drivers/sound/ak4642en.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/sound/ak4642en.c 2008-09-10 10:45:51.000000000 +0200 @@ -39,8 +39,14 @@ extern void (*i2s_resume_codec)(void); extern void (*i2s_suspend_codec)(int wr,int rd); extern void (*set_replay_hp_or_speaker)(void); -#define I2S_PDN 68 -#define JACK_PLUG_PIN 83 +//#define I2S_PDN 68 +//@vanpro Skytone +//we use GPIO 69 instead of GPIO 68 In skytone +#define I2S_PDN 69 +//#define JACK_PLUG_PIN 83 +//@vanpro Skytone +//we use GPIO 25 to detect whether is headphone or speaker +#define JACK_PLUG_PIN 25 #define JACK_PLUG_IRQ (IRQ_GPIO_0 + JACK_PLUG_PIN) static int jack_plug_level, old_level; @@ -103,6 +109,8 @@ static void i2s_codec_write(u8 reg, u16 void set_ak4642en_gpio_pin(void) { //set AIC pin to I2S slave mode,only GPIO70,71,77,78 + __gpio_as_output(24); //wjx + __gpio_clear_pin(24); //wjx disenable the speaker out amplifier __gpio_as_output(68); __gpio_clear_pin(68); __gpio_as_output(69); @@ -172,9 +180,16 @@ void set_ak4642en_replay(void) if(old_level == jack_plug_level) return; old_level = jack_plug_level; + //@vanpro Skytone + //switch headphone or speaker out + if (jack_plug_level) + __gpio_set_pin(24); + else + __gpio_clear_pin(24); + if(spk_hp == 1) { - if(jack_plug_level == 1) + if(jack_plug_level == 0) { //now HeadPhone output,so clear SPK i2s_codec_write(0x02, 0x0020); @@ -192,7 +207,7 @@ void set_ak4642en_replay(void) } } spk_hp = 1; - if(jack_plug_level == 1) + if(jack_plug_level == 0) { //for HeadPhone output i2s_codec_write(0x00, 0x0060); // @@ -209,6 +224,7 @@ void set_ak4642en_replay(void) } else { +#if 0 //for Speaker output i2s_codec_write(0x00, 0x0040); i2s_codec_write(0x02, 0x0020); @@ -230,6 +246,24 @@ void set_ak4642en_replay(void) i2s_codec_write(0x00, 0x0074); i2s_codec_write(0x02, 0x00a0); +#endif + //@vanpro Skytone + //we use Line output instead of Speaker output. + //for Line output + i2s_codec_write(0x05, 0x0027); + i2s_codec_write(0x02, 0x0010); + + i2s_codec_write(0x09, 0x0091); + i2s_codec_write(0x0c, 0x0091); + //printk("codec_volume=%d\n",codec_volume); +// i2s_codec_write(0x0a, 0x0028);//5-10 //wjx not need to set volume here +// i2s_codec_write(0x0d, 0x0028);//5-10 + + i2s_codec_write(0x03, 0x0040);//5-10 + i2s_codec_write(0x00, 0x006c); + + i2s_codec_write(0x03, 0x0000);//5-10 + } } @@ -260,6 +294,7 @@ void clear_ak4642en_replay(void) if(jack_plug_level == 1) { //for HeadPhone output + __gpio_clear_pin(24); //wjx disenable the speaker out amplifier for close pop noise i2s_codec_write(0x01, 0x0039); // for close pop noise mdelay(300); i2s_codec_write(0x01, 0x0009); //PLL on I2S --- celinux-040503.jz/drivers/usb/acm.c 2002-11-29 00:53:14.000000000 +0100 +++ cel.new/drivers/usb/acm.c 2008-09-10 10:45:54.000000000 +0200 @@ -65,6 +65,8 @@ #define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik" #define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" +extern unsigned int usb_modem_access; + /* * CMSPAR, some architectures can't have space and mark parity. */ @@ -512,7 +514,7 @@ static void *acm_probe(struct usb_device struct usb_config_descriptor *cfacm; struct usb_interface_descriptor *ifcom, *ifdata; struct usb_endpoint_descriptor *epctrl, *epread, *epwrite; - int readsize, ctrlsize, minor, i; + int readsize, ctrlsize, minor, i, j; unsigned char *buf; for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { @@ -521,10 +523,17 @@ static void *acm_probe(struct usb_device dbg("probing config %d", cfacm->bConfigurationValue); +#if 0 if (cfacm->bNumInterfaces != 2 || usb_interface_claimed(cfacm->interface + 0) || usb_interface_claimed(cfacm->interface + 1)) continue; +#else + for(j=0; jbNumInterfaces; j++) + if(usb_interface_claimed(cfacm->interface+j)) + break; + if(j != cfacm->bNumInterfaces) continue; +#endif ifcom = cfacm->interface[0].altsetting + 0; ifdata = cfacm->interface[1].altsetting + 0; @@ -596,6 +605,9 @@ static void *acm_probe(struct usb_device acm->writeurb.transfer_flags |= USB_NO_FSBR; printk(KERN_INFO "ttyACM%d: USB ACM device\n", minor); + /*czj add*/ + if ((dev->descriptor.idVendor == 0x1165) && (dev->descriptor.idProduct == 0x0001)) + usb_modem_access = 11; acm_set_control(acm, acm->ctrlout); @@ -648,8 +660,57 @@ static void acm_disconnect(struct usb_de * USB driver structure. */ +#define NO_UNION_NORMAL 1 +#define SINGLE_RX_URB 2 + +#define USB_CDC_SUBCLASS_ACM 2 + +#define USB_CDC_ACM_PROTO_AT_V25TER 1 +#define USB_CDC_ACM_PROTO_AT_PCCA101 2 +#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3 +#define USB_CDC_ACM_PROTO_AT_GSM 4 +#define USB_CDC_ACM_PROTO_AT_3G 5 +#define USB_CDC_ACM_PROTO_AT_CDMA 6 +#define USB_CDC_ACM_PROTO_VENDOR 0xff + static struct usb_device_id acm_ids[] = { { USB_DEVICE_INFO(USB_CLASS_COMM, 0, 0) }, + + /* quirky and broken devices */ + { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ + .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ + }, + { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ + .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ + }, + { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */ + .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ + }, + { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ + .driver_info = SINGLE_RX_URB, /* firmware bug */ + }, + { USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */ + .driver_info = SINGLE_RX_URB, /* firmware bug */ + }, + { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ + .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ + }, + + /* control interfaces with various AT-command sets */ + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_V25TER) }, + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_PCCA101) }, + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_PCCA101_WAKE) }, + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_GSM) }, + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_3G ) }, + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, + USB_CDC_ACM_PROTO_AT_CDMA) }, + + { } }; --- celinux-040503.jz/drivers/usb/gadget/jz4740_udc.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/usb/gadget/jz4740_udc.c 2008-09-10 10:45:55.000000000 +0200 @@ -335,13 +335,13 @@ static void udc_enable(struct jz4740_udc /* Enable interrupts */ usb_setw(USB_REG_INTRINE, USB_INTR_EP0); - usb_setb(USB_REG_INTRUSBE, USB_INTR_RESET); + usb_setb(USB_REG_INTRUSBE, (USB_INTR_RESET | USB_INTR_RESUME)); /* Don't enable rest of the interrupts */ /* usb_setw(USB_REG_INTRINE, USB_INTR_INEP1 | USB_INTR_INEP2); usb_setw(USB_REG_INTROUTE, USB_INTR_OUTEP1); */ /* Enable SUSPEND */ - /* usb_setb(USB_REG_POWER, USB_POWER_SUSPENDM); */ + usb_setb(USB_REG_POWER, USB_POWER_SUSPENDM); /* Enable HS Mode */ usb_setb(USB_REG_POWER, USB_POWER_HSENAB); @@ -1556,9 +1556,6 @@ static void jz4740_ep0_setup(struct jz47 DEBUG_SETUP("USB_REQ_SET_CONFIGURATION (%d)\n", ctrl.wValue); usb_setb(USB_REG_CSR0, (USB_CSR0_SVDOUTPKTRDY | USB_CSR0_DATAEND)); - - /* Enable RESUME and SUSPEND interrupts */ - usb_setb(USB_REG_INTRUSBE, (USB_INTR_RESUME | USB_INTR_SUSPEND)); break; case USB_REQ_SET_INTERFACE: @@ -1809,8 +1806,7 @@ static void jz4740_udc_irq(int irq, void intr_out, intr_in, intr_usb); /* Check for resume from suspend mode */ - if ((intr_usb & USB_INTR_RESUME) && - (usb_readb(USB_REG_INTRUSBE) & USB_INTR_RESUME)) { + if (intr_usb & USB_INTR_RESUME) { DEBUG("USB resume\n"); } @@ -1853,11 +1849,8 @@ static void jz4740_udc_irq(int irq, void } /* Check for suspend mode */ - if ((intr_usb & USB_INTR_SUSPEND) && - (usb_readb(USB_REG_INTRUSBE) & USB_INTR_SUSPEND)) { + if (intr_usb & USB_INTR_SUSPEND) { DEBUG("USB suspend\n"); - /* Host unloaded from us, can do something, such as flushing - the NAND block cache etc. */ } } --- celinux-040503.jz/drivers/usb/storage/unusual_devs.h 2002-11-29 00:53:15.000000000 +0100 +++ cel.new/drivers/usb/storage/unusual_devs.h 2008-09-10 10:45:57.000000000 +0200 @@ -37,6 +37,16 @@ * then by ProductID. */ +/* This prevents the kernel from detecting the virtual cd-drive with the + * Windows drivers. +*/ +UNUSUAL_DEV( 0x12d1, 0x1003, 0x0000, 0xffff, + "HUAWEI", + "E220 USB-UMTS Install", + 0x0, 0x0, NULL, + 0x0), + + UNUSUAL_DEV( 0x03ee, 0x0000, 0x0000, 0x0245, "Mitsumi", "CD-R/RW Drive", @@ -102,7 +112,7 @@ UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x "FinePix 1400Zoom", US_SC_8070, US_PR_CBI, NULL, US_FL_FIX_INQUIRY), -/* Reported by Peter Wächtler +/* Reported by Peter W?chtler * The device needs the flags only. */ UNUSUAL_DEV( 0x04ce, 0x0002, 0x0074, 0x0074, --- celinux-040503.jz/drivers/usb/storage/usb.c 2002-11-29 00:53:15.000000000 +0100 +++ cel.new/drivers/usb/storage/usb.c 2008-09-10 10:45:57.000000000 +0200 @@ -312,7 +312,7 @@ static int usb_stor_control_thread(void int action; lock_kernel(); - + printk("+++++ DEBUG, CZJ ++++\n");//czj /* * This thread doesn't need any user-level access, * so get rid of all our resources.. @@ -349,6 +349,12 @@ static int usb_stor_control_thread(void US_DEBUGP("*** thread awakened.\n"); + /*add by czj, 2008.06.03*/ + if(us->htmplt.usb_disconnect_flag == 1){ + printk("++ u disk has disconnetd , so exit ++\n"); + break; + } + /* lock access to the queue element */ down(&(us->queue_exclusion)); @@ -1075,17 +1081,79 @@ static void storage_disconnect(struct us } up(&(ss->irq_urb_sem)); + /*czj 2008.06.03*/ /* free up the main URB for this device */ - US_DEBUGP("-- releasing main URB\n"); + down(&(ss->current_urb_sem)); //czj result = usb_unlink_urb(ss->current_urb); - US_DEBUGP("-- usb_unlink_urb() returned %d\n", result); + complete(&(ss->current_done)); //czj usb_free_urb(ss->current_urb); ss->current_urb = NULL; + up(&(ss->current_urb_sem)); //czj + + /* + *here we need to handle the srb,queue_srb + */ + down(&(ss->queue_exclusion)); + if(ss->srb){ + ss->srb->result = DID_NO_CONNECT << 16; + set_current_state(TASK_INTERRUPTIBLE);//czj ??? + ss->srb->scsi_done(ss->srb); + ss->srb = NULL; + } + ss->action = 0; + if(ss->queue_srb){ + ss->queue_srb->result = DID_NO_CONNECT << 16; + set_current_state(TASK_INTERRUPTIBLE);//czj ??? + ss->queue_srb->scsi_done(ss->queue_srb); + ss->queue_srb = NULL; + } + up(&(ss->queue_exclusion)); + /*czj 2008.06.03*/ + + // wangjian + { + struct us_data *next; + US_DEBUGP("USB Unregister scsi m\n"); + //ss->htmplt.release(ss->host); + + /*edwin.This flag declare usb disconnected then invalidate_dev() wan't do fsync_dev*/ + ss->htmplt.usb_disconnect_flag = 1; + US_DEBUGP("ss->htmplt.usb_disconnect_flag=%d\n",ss->htmplt.usb_disconnect_flag); + /**/ + + scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); + + down(&us_list_semaphore); + + next = (struct us_data *)&us_list; + while(next && next->next != ss) next = next->next; + if(next && next->next == ss) next->next = ss->next; + + /* release the data structure lock */ + up(&us_list_semaphore); + } /* mark the device as gone */ usb_dec_dev_use(ss->pusb_dev); ss->pusb_dev = NULL; + // wangjian + { + struct us_data *next; + printk ("USB Unregister scsi m\n"); + //ss->htmplt.release(ss->host); + scsi_unregister_module(MODULE_SCSI_HA, &(ss->htmplt)); + + down(&us_list_semaphore); + + next = (struct us_data *)&us_list; + while(next && next->next != ss) next = next->next; + if(next && next->next == ss) next->next = ss->next; + + /* release the data structure lock */ + up(&us_list_semaphore); + } + /* unlock access to the device data structure */ up(&(ss->dev_semaphore)); } --- celinux-040503.jz/drivers/usb/usb-ohci-Jz.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/usb/usb-ohci-Jz.c 2008-09-10 10:45:58.000000000 +0200 @@ -256,7 +256,7 @@ static void __init jz_ohci_configure(voi { #ifdef CONFIG_MIPS_JZ4730 /* USB port 0 is used as device */ - __harb_usb0_udc(); +//wjx __harb_usb0_udc(); /* USB port 1 is used as host */ #endif --- celinux-040503.jz/drivers/usb/usb.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/usb/usb.c 2008-09-10 10:45:57.000000000 +0200 @@ -40,6 +40,8 @@ #include "hcd.h" +unsigned int usb_modem_access= 0; + static const int usb_bandwidth_option = #ifdef CONFIG_USB_BANDWIDTH 1; @@ -922,11 +924,26 @@ static void usb_find_drivers(struct usb_ if (rejected) dbg("unhandled interfaces on device"); + if (!claimed) { warn("USB device %d (vend/prod 0x%x/0x%x) is not claimed by any active driver.", dev->devnum, dev->descriptor.idVendor, dev->descriptor.idProduct); + + /*czj add this to detect the e220,cmda,edge disconnect*/ + + if(((dev->descriptor.idVendor == 0x10ce) && (dev->descriptor.idProduct == 0xea6a)) || ((dev->descriptor.idVendor == 0x1165) && (dev->descriptor.idProduct == 0x0001))) /*edge and cdma*/ + { + usb_modem_access = 9; + } + + if(((dev->descriptor.idVendor == 0x12d1) && (dev->descriptor.idProduct == 0x1003)) && (dev->config->bNumInterfaces == 0x01)) /*e220*/ + usb_modem_access = 2; + + if(((dev->descriptor.idVendor == 0x12d1) && (dev->descriptor.idProduct == 0x1003)) && (dev->config->bNumInterfaces == 0x03)) /*e220*/ + usb_modem_access = 9; + #ifdef DEBUG usb_show_device(dev); #endif @@ -1723,6 +1740,12 @@ void usb_disconnect(struct usb_device ** #endif #endif + /*czj add this to detect e220 disconnect*/ + if(((dev->descriptor.idVendor == 0x12d1) && (dev->descriptor.idProduct == 0x1003)) || ((dev->descriptor.idVendor == 0x10ce) && (dev->descriptor.idProduct == 0xea6a)) || ((dev->descriptor.idVendor == 0x1165) && (dev->descriptor.idProduct == 0x0001))) /*e220 & edge & cdma*/ + { + usb_modem_access = 0; + } + if (dev->actconfig) { for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { struct usb_interface *interface = &dev->actconfig->interface[i]; @@ -2272,6 +2295,17 @@ int usb_new_device(struct usb_device *de return 1; } + + /*czj add this to detect the e220,cmda,edge connect*/ + + if(((dev->descriptor.idVendor == 0x10ce) && (dev->descriptor.idProduct == 0xea6a)) || ((dev->descriptor.idVendor == 0x1165) && (dev->descriptor.idProduct == 0x0001))) /*edge & cdma*/ + { + usb_modem_access = 1; + } + + if(((dev->descriptor.idVendor == 0x12d1) && (dev->descriptor.idProduct == 0x1003)) && (dev->config->bNumInterfaces == 0x03) ) + usb_modem_access = 1; + dbg("new device strings: Mfr=%d, Product=%d, SerialNumber=%d", dev->descriptor.iManufacturer, dev->descriptor.iProduct, dev->descriptor.iSerialNumber); #ifdef DEBUG @@ -2449,4 +2483,5 @@ EXPORT_SYMBOL(usb_control_msg); EXPORT_SYMBOL(usb_bulk_msg); EXPORT_SYMBOL(usb_devfs_handle); +EXPORT_SYMBOL(usb_modem_access); MODULE_LICENSE("GPL"); --- celinux-040503.jz/drivers/video/Jzlcd.c 2008-10-02 18:42:13.000000000 +0200 +++ cel.new/drivers/video/Jzlcd.c 2008-09-10 10:45:59.000000000 +0200 @@ -30,9 +30,9 @@ #include