--- ../linux/arch/arm/mach-pxa/sharpsl_apm.c 2004-03-08 14:14:21.000000000 +0900 +++ linux/arch/arm/mach-pxa/sharpsl_apm.c 2004-07-12 23:07:27.000000000 +0900 @@ -73,6 +73,12 @@ #include #include +extern int errno; + +// unistd.h is included for the configuration ioctl stuff +#define __KERNEL_SYSCALLS__ 1 +#include + #ifdef CONFIG_ARCH_SHARP_SL #include #include @@ -128,6 +134,10 @@ extern int HWR_flag; #endif +#if defined(CONFIG_SL_CCCR_CHANGE) +extern unsigned int cccr_clkparam; +#endif + #if defined(CONFIG_SABINAL_DISCOVERY) #define SHARPSL_AC_LINE_STATUS (( ASIC3_GPIO_PSTS_D & AC_IN )? APM_AC_OFFLINE : APM_AC_ONLINE) #define BACKPACK_IN_DETECT() ( ASIC3_GPIO_PSTS_D & BACKPACK_DETECT ) /* 0: exist , 1: not in */ @@ -352,6 +362,7 @@ }; #define ERROR_COUNT (sizeof(error_table)/sizeof(lookup_t)) +#define APP_NAME_LIST "/etc/suspend.lst" /* * Function */ @@ -639,24 +650,75 @@ struct task_struct* p = NULL; struct task_struct* tsk = current; + int fd,x; + mm_segment_t old_fs = get_fs (); + char line_buffer[256]; + if (! spin_trylock(&lock)) return; + + // Try opening the send sig application name list + set_fs(KERNEL_DS); +// printk("open sig file\n"); + fd = open(APP_NAME_LIST, O_RDONLY, 0); + set_fs(old_fs); /* send signal to all procs except for kernel-threads */ read_lock(&tasklist_lock); - for_each_task(p) { - struct siginfo si; - if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) - continue; + if(fd < 0){ + for_each_task(p) { + struct siginfo si; + + if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) + continue; + if (!strcmp(p->comm,"cardmgr")) { //Send sig to cardmgr +// printk ("Send SIG to application\n"); + si.si_signo = signo; + si.si_errno = 0; + si.si_code = SI_KERNEL; + si.si_pid = tsk->pid; + si.si_uid = tsk->uid; + send_sig_info(signo, &si, p); + } + } + + }else { + for(;;){ + memset(line_buffer, '\0', 256); + set_fs(KERNEL_DS); + for (x = 0; x < 256; x++) { + if (!read(fd, &line_buffer[x], 1)) + goto sig_send_done; + if (line_buffer[x] == '\n' || line_buffer[x] == '\r') + break; + } + set_fs(old_fs); + + for_each_task(p) { + struct siginfo si; - si.si_signo = signo; - si.si_errno = 0; - si.si_code = SI_KERNEL; - si.si_pid = tsk->pid; - si.si_uid = tsk->uid; - send_sig_info(signo, &si, p); + if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) + continue; + if (!strncmp(p->comm,line_buffer,strlen(p->comm))) { //Send sig to cardmgr +// printk ("Send SIG to application\n"); + si.si_signo = signo; + si.si_errno = 0; + si.si_code = SI_KERNEL; + si.si_pid = tsk->pid; + si.si_uid = tsk->uid; + send_sig_info(signo, &si, p); + } + } + } + + sig_send_done: +// printk("close sig\n"); + close(fd); } + + + read_unlock(&tasklist_lock); if (signo == SIGSTOP) { @@ -668,16 +730,58 @@ schedule(); set_current_state(state); + set_fs(KERNEL_DS); + fd = open(APP_NAME_LIST, O_RDONLY, 0); +// printk("open sigstop\n"); + set_fs(old_fs); + read_lock(&tasklist_lock); - for_each_task(p) { - if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) - continue; - if (p->state != TASK_STOPPED) { - read_unlock(&tasklist_lock); - goto retry; + if(fd < 0){ + for_each_task(p) { + if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) + continue; + if (!strcmp(p->comm,"cardmgr")) { +// printk ("Check application stopped\n"); + + if (p->state != TASK_STOPPED) { + read_unlock(&tasklist_lock); + goto retry; + } + } } + }else { + + for(;;){ + memset(line_buffer, '\0', 256); + old_fs = get_fs(); + set_fs(KERNEL_DS); + for (x = 0; x < 256; x++) { + if (!read(fd, &line_buffer[x], 1)) + goto sig_stop_done; + if (line_buffer[x] == '\n' || line_buffer[x] == '\r') + break; + } + set_fs(old_fs); + + for_each_task(p) { + if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p)) + continue; + if (!strncmp(p->comm,line_buffer,strlen(p->comm))) { +// printk ("Check application stopped\n"); + + if (p->state != TASK_STOPPED) { + read_unlock(&tasklist_lock); + goto retry; + } + } + } + } + sig_stop_done: +// printk("close sigstop\n"); + close(fd); } + read_unlock(&tasklist_lock); } @@ -1006,6 +1110,49 @@ EXPORT_SYMBOL(lock_FCS); +#if defined(CONFIG_SL_CCCR_CHANGE) +static ssize_t cccr_change_read_params(struct file *file, char *buf, + size_t nbytes, loff_t *ppos) +{ + char outputbuf[32]; + int count; + + if (*ppos>0) /* Assume reading completed in previous read*/ + return 0; + count = sprintf(outputbuf, "0x%08X\n", (unsigned int)cccr_clkparam); + count++; + *ppos += count; + if (count>nbytes) /* Assume output can be read at one time */ + return -EINVAL; + if (copy_to_user(buf, outputbuf, count+1)) + return -EFAULT; + return count; +} + +static ssize_t cccr_change_write_params(struct file *file, const char *buf, + size_t nbytes, loff_t *ppos) +{ + unsigned int param=0; + + sscanf(buf,"%x",¶m); + if (param) { + printk("Change CCCR = %x.\n",param); + cccr_clkparam = param; + sharpsl_chg_freq = param; + cpu_xscale_sl_change_speed_num(); + cccr_reg = CCCR; + printk("Changed CCCR = %x.\n",cccr_reg); + + } + return nbytes; +} + +static struct file_operations proc_cccr_change_params_operations = { + read: cccr_change_read_params, + write: cccr_change_write_params, +}; +#endif + #ifdef CONFIG_APM_CPU_IDLE #ifdef SHARPSL_NEW_IDLE static int save_icmr; @@ -1145,16 +1292,30 @@ } else if ( cccr_reg == 0x145 ) { cpu_xscale_sl_change_speed_145(); +#if defined(CONFIG_SL_CCCR_CHANGE) + } else { + cccr_clkparam = (unsigned int)cccr_reg; + cpu_xscale_sl_change_speed_num(); + } +#else } else { cpu_xscale_change_speed_241(); } +#endif #else if ( cccr_reg == 0x145 ) { cpu_xscale_sl_change_speed_145(); +#if defined(CONFIG_SL_CCCR_CHANGE) + } else { + cccr_clkparam = (unsigned int)cccr_reg; + cpu_xscale_sl_change_speed_num(); + } +#else } else { cpu_xscale_change_speed_241(); } #endif +#endif #if defined(CONFIG_ARCH_PXA_TOSA) CKEN |= CKEN2_AC97; @@ -2723,6 +2884,7 @@ struct proc_dir_entry *apm_proc; struct proc_dir_entry *lock_fcs_proc; struct proc_dir_entry *power_mode_proc; + struct proc_dir_entry *cccr_change_proc; apm_info.bios = apm_bios_info; if (apm_info.bios.version == 0) { @@ -2741,16 +2903,36 @@ #if defined(CONFIG_ARCH_PXA_POODLE) || defined(CONFIG_ARCH_PXA_CORGI) || defined(CONFIG_ARCH_PXA_TOSA) +#if defined(CONFIG_SL_CCCR242) + sharpsl_chg_freq = (unsigned int)0x00000242; + cccr_clkparam = (unsigned int)sharpsl_chg_freq; + cpu_xscale_sl_change_speed_num(); +#elif defined(CONFIG_SL_CCCR162) + sharpsl_chg_freq = (unsigned int)0x00000162; + cccr_clkparam = (unsigned int)sharpsl_chg_freq; + cpu_xscale_sl_change_speed_num(); +#elif defined(CONFIG_SL_CCCR163) + sharpsl_chg_freq = (unsigned int)0x00000163; + cccr_clkparam = (unsigned int)sharpsl_chg_freq; + cpu_xscale_sl_change_speed_num(); +#else #if defined(CONFIG_ARCH_PXA_SHEPHERD) || defined(CONFIG_ARCH_PXA_TOSA) sharpsl_chg_freq = (unsigned int)0x00000161; +#if defined(CONFIG_SL_CCCR_CHANGE) + cccr_clkparam = (unsigned int)sharpsl_chg_freq; +#endif cpu_xscale_sl_change_speed_161(); #else #if 1 // default 400MHz sharpsl_chg_freq = (unsigned int)0x00000241; +#if defined(CONFIG_SL_CCCR_CHANGE) + cccr_clkparam = (unsigned int)sharpsl_chg_freq; +#endif #else cpu_xscale_sl_change_speed_145_without_lcd(); #endif #endif +#endif cccr_reg = CCCR; // printk("FCS : CCCR = %x\n",cccr_reg); #endif @@ -2832,6 +3014,13 @@ power_mode_proc->proc_fops = &proc_power_mode_params_operations; } +#if defined(CONFIG_SL_CCCR_CHANGE) + cccr_change_proc = create_proc_entry("cccr_change", 0, NULL); + if (cccr_change_proc) { + cccr_change_proc->proc_fops = &proc_cccr_change_params_operations; + } +#endif + kernel_thread(apm_thread, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD); #if defined(CONFIG_SABINAL_DISCOVERY) || defined(CONFIG_ARCH_PXA_TOSA)