static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr,const char *buf, size_t size) { //wake_lock(&sec_misc_wake_lock); if((0 == strncmp(buf,"PDA", 3)) || (0 == strncmp(buf, "pda", 3))) { gpio_set_value(GPIO_UART_SEL, 1); // Set UART path to AP gpio_set_value(GPIO_UART_SEL2, 1); // Set UART path to AP klogi("Path Set To UART PDA (AP)\n"); } else if((0 == strncmp(buf, "LTEMODEM", 8)) || (0 == strncmp(buf, "ltemodem", 8))) { gpio_set_value(GPIO_UART_SEL, 1); // Set UART path to LTE gpio_set_value(GPIO_UART_SEL2, 0); // Set UART path to LTE klogi("Path Set To UART LTE\n"); } else if((0 == strncmp(buf, "MODEM", 5)) || (0 == strncmp(buf, "modem", 5))) { gpio_set_value(GPIO_UART_SEL, 0); // Set UART path to CP klogi("Path Set To UART MODEM(CP)\n"); } else printk("Enter PDA(AP uart) or LTE(LTE uart) or MODEM(CP uart)...\n"); //wake_unlock(&sec_misc_wake_lock); return size; }
static ssize_t usb_sel_store(struct device *dev, struct device_attribute *attr,const char *buf, size_t size) { #if 0 int state; if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 2)) return -EINVAL; // prevents the system from entering suspend wake_lock(&sec_misc_wake_lock); if(state == 2) { sec_set_usbpath(USB_SEL_ADC); // Set USB path to CP klogi("Set USB path to ADC\n"); } else if(state == 1) { sec_set_usbpath(USB_SEL_AP_USB); // Set USB path to AP klogi("Set USB path to AP\n"); } else if(state == 0) { sec_set_usbpath(USB_SEL_CP_USB); // Set USB path to CP klogi("Set USB path to CP\n"); } else klogi("Enter 2(ADC usb) or 1(AP usb) or 0(CP usb)...\n"); wake_unlock(&sec_misc_wake_lock); return size; #endif return -EINVAL; }
static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr,const char *buf, size_t size) { int state; if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) return -EINVAL; // prevents the system from entering suspend wake_lock(&sec_misc_wake_lock); if(state == 1) { printk("[denis]Set UART path to AP state : %d\n" ,state); gpio_set_value(GPIO_UART_SEL, 1); // Set UART path to AP klogi("Set UART path to AP\n"); } else if(state == 0) { printk("[denis]Set UART path to CP state : %d\n",state); gpio_set_value(GPIO_UART_SEL, 0); // Set UART path to CP klogi("Set UART path to CP\n"); } else klogi("Enter 1(AP uart) or 0(CP uart)...\n"); wake_unlock(&sec_misc_wake_lock); return size; }
static ssize_t usb_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { int state; if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 2)) return -EINVAL; /* prevents the system from entering suspend */ wake_lock(&sec_misc_wake_lock); if (state == 2) { p3_set_usb_path(USB_SEL_ADC); /* Set USB path to CP */ klogi("Set USB path to ADC\n"); } else if (state == 1) { p3_set_usb_path(USB_SEL_AP_USB); /* Set USB path to AP */ klogi("Set USB path to AP\n"); } else if (state == 0) { p3_set_usb_path(USB_SEL_CP_USB); /* Set USB path to CP */ klogi("Set USB path to CP\n"); } else klogi("Enter 2(ADC usb) or 1(AP usb) or 0(CP usb)...\n"); if (state >= 0 && state <= 2) sec_set_param(param_index_usbsel, &state); wake_unlock(&sec_misc_wake_lock); return size; }
static ssize_t usb_sel_store(struct device *dev, struct device_attribute *attr,const char *buf, size_t size) { // prevents the system from entering suspend //wake_lock(&sec_misc_wake_lock); if((0 == strncmp(buf, "LTEMODEM", 8)) || (0 == strncmp(buf, "ltemodem", 8))) { //p3_set_usb_path(USB_SEL_ADC); // Set USB path to CP if(system_rev > 0x0A) gpio_set_value(GPIO_USB_SEL1, 0); else gpio_set_value(GPIO_USB_SEL1_REV05, 0); gpio_set_value(GPIO_USB_SEL2, 1); usb_sel_status = USB_SEL_ADC; klogi("Set USB path to LTEMODEM(LTE)\n"); if (use_jig_irq) wake_lock_timeout(&wake_lock_usb_modem, HZ / 2); } else if((0 == strncmp(buf, "PDA", 3)) || (0 == strncmp(buf, "pda", 3))) { //p3_set_usb_path(USB_SEL_AP_USB); // Set USB path to AP if(system_rev > 0x0A) gpio_set_value(GPIO_USB_SEL1, 1); else gpio_set_value(GPIO_USB_SEL1_REV05, 1); gpio_set_value(GPIO_USB_SEL2, 1); usb_sel_status = USB_SEL_AP_USB; klogi("Set USB path to PDA(AP)\n"); if (use_jig_irq) wake_lock_timeout(&wake_lock_usb_modem, HZ / 2); } else if((0 == strncmp(buf, "MODEM", 5)) || (0 == strncmp(buf, "modem", 5))) { //p3_set_usb_path(USB_SEL_CP_USB); // Set USB path to CP if(system_rev > 0x0A) gpio_set_value(GPIO_USB_SEL1, 0); else gpio_set_value(GPIO_USB_SEL1_REV05, 0); gpio_set_value(GPIO_USB_SEL2, 0); usb_sel_status = USB_SEL_CP_USB; klogi("Set USB path to MODEM(CP)\n"); if (use_jig_irq == 1 && check_jig_on() == 1) wake_lock(&wake_lock_usb_modem); } else { klogi("Enter LTEMODEM(LTE usb) or PDA(AP usb) or MODEM(CP usb)...\n"); if (use_jig_irq) wake_lock_timeout(&wake_lock_usb_modem, HZ / 2); } //wake_unlock(&sec_misc_wake_lock); return size; }
static int param_check(unsigned char *addr) { status_t *status; status = (status_t *)addr; if ((status->param_magic == PARAM_MAGIC) && (status->param_version == PARAM_VERSION)) { klogi("Checking PARAM... OK"); return 0; } klogi("Checking PARAM... Invalid"); return -1; }
static int __init sec_misc_init(void) { int ret=0; klogi("started!"); printk("[denis]sec_misc_init!\n"); ret = misc_register(&sec_misc_device); if (ret<0) { kloge("misc_register failed!"); return ret; } //sec_switch_class = class_create(THIS_MODULE, "sec"); //if (IS_ERR(sec_switch_class)) //pr_err("Failed to create class named \"sec\"!\n"); //sec_misc_dev = device_create(sec_class, NULL, 0, NULL, "switch"); sec_misc_dev = device_create(sec_class, NULL, 0, NULL, "sec_misc"); //EUR if (IS_ERR(sec_misc_dev)) { kloge("failed to create device!"); return -1; } if (device_create_file(sec_misc_dev, &dev_attr_uartsel) < 0) { kloge("failed to create device file!(%s)!\n", dev_attr_uartsel.attr.name); return -1; } if (device_create_file(sec_misc_dev, &dev_attr_usbsel) < 0) { kloge("failed to create device file!(%s)!\n", dev_attr_usbsel.attr.name); return -1; } if (device_create_file(sec_misc_dev, &dev_attr_usb_state) < 0) //EUR pr_err("Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name); //EUR if (device_create_file(sec_misc_dev, &dev_attr_emmc_checksum_done) < 0) pr_err("failed to create device file - %s\n", dev_attr_emmc_checksum_done.attr.name); if (device_create_file(sec_misc_dev, &dev_attr_emmc_checksum_pass) < 0) pr_err("failed to create device file - %s\n", dev_attr_emmc_checksum_pass.attr.name); wake_lock_init(&sec_misc_wake_lock, WAKE_LOCK_SUSPEND, "sec_misc"); p3_uart_path_init(); p3_usb_path_init(); p3_set_usb_path(USB_SEL_AP_USB); init_jig_on(); return 0; }
static void param_exit(void) { klogi("param_exit"); #ifdef PARAM_USE_INIT_BUFFER kfree(param_buf); kfree(image_buf); #endif #ifdef PARAM_PROCFS_DEBUG remove_proc_entry("debug", param_dir); remove_proc_entry("param", 0); #endif }
static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr,const char *buf, size_t size) { int state; if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) return -EINVAL; #if defined(CONFIG_SEC_KEYBOARD_DOCK) if (g_keyboard) { pr_err("%s - the keyboard is connected.\n", __func__); return size; } #endif // prevents the system from entering suspend wake_lock(&sec_misc_wake_lock); if(state == 1) { printk("[denis]Set UART path to AP state : %d\n" ,state); gpio_set_value(GPIO_UART_SEL, 1); // Set UART path to AP klogi("Set UART path to AP\n"); sec_set_param(param_index_uartsel, &state); } else if(state == 0) { printk("[denis]Set UART path to CP state : %d\n",state); gpio_set_value(GPIO_UART_SEL, 0); // Set UART path to CP klogi("Set UART path to CP\n"); sec_set_param(param_index_uartsel, &state); } else klogi("Enter 1(AP uart) or 0(CP uart)...\n"); wake_unlock(&sec_misc_wake_lock); return size; }
static int param_write_proc_debug(struct file *file, const char *buffer, unsigned long count, void *data) { char *buf; if (count < 1) return -EINVAL; buf = kmalloc(count, GFP_KERNEL); if (!buf) return -ENOMEM; if (copy_from_user(buf, buffer, count)) { kfree(buf); return -EFAULT; } switch(buf[0]) { case '0': param_show_info(); break; case '1': param_set_default(); save_lfs_param_value(); klogi("Parameters have been set as DEFAULT values..."); param_show_info(); break; case '2': param_run_test(); break; case '3': param_lfs_run_test(); break; default: kfree(buf); return -EINVAL; } kfree(buf); return count; }
void set_param_value(int idx, void *value) { int i, str_i; klogi("inside set_param_value1 idx = %d, value = %d", idx, value); for (i = 0; i < MAX_PARAM; i++) { if (i < (MAX_PARAM - MAX_STRING_PARAM)) { if(param_status.param_list[i].ident == idx) { param_status.param_list[i].value = *(int *)value; } } else { str_i = (i - (MAX_PARAM - MAX_STRING_PARAM)); if(param_status.param_str_list[str_i].ident == idx) { strlcpy(param_status.param_str_list[str_i].value, (char *)value, PARAM_STRING_SIZE); } } } save_lfs_param_value(); }
/*! * \brief Print warning * * This function also prints the string to the console, but the text will appear yellow * @param text The string to print */ void printw(const char text[], ...) { klogi(text); }
static int param_init(void) { int ret; #ifdef PARAM_USE_INIT_BUFFER param_buf = kmalloc(PARAM_LEN, GFP_KERNEL); if (!param_buf) { kloge("Unable to alloc param_buf!"); return -ENOMEM; } image_buf = kmalloc(IMAGE_LEN, GFP_KERNEL); if (!image_buf) { kloge("Unable to alloc image_buf!"); kfree(param_buf); return -ENOMEM; } #endif #ifdef PARAM_PROCFS_DEBUG struct proc_dir_entry *ent; /* Creats '/proc/param' directory */ param_dir = proc_mkdir("param", NULL); if (param_dir == NULL) { kloge("Unable to create /proc/param directory\n"); return -ENOMEM; } /* Creats RW '/proc/param/sleep/debug' entry */ ent = create_proc_entry("debug", 0, param_dir); if (ent == NULL) { kloge("Unable to create /proc/param/debug entry"); ret = -ENOMEM; goto fail; } ent->read_proc = param_read_proc_debug; ent->write_proc = param_write_proc_debug; #endif klogi("param_init"); #if 0 ret = load_param_value(); #else ret = load_lfs_param_value(); #endif if (ret < 0) { kloge("Loading parameters failed. Parameters have been initialized as default."); param_set_default(); } sec_set_param_value = set_param_value; sec_get_param_value = get_param_value; return 0; #ifdef PARAM_PROCFS_DEBUG fail: remove_proc_entry("param", 0); #ifdef PARAM_USE_INIT_BUFFER kfree(param_buf); kfree(image_buf); #endif return ret; #endif }
static void param_show_info(void) { klogi("-----------------------------------------------------"); klogi(" Information of Parameters"); klogi("-----------------------------------------------------"); klogi(" - param_magic : 0x%x", param_status.param_magic); klogi(" - param_version : 0x%x", param_status.param_version); klogi(" - %2d. SERIAL_SPEED : %d", param_status.param_list[0].ident, param_status.param_list[0].value); klogi(" - %2d. LOAD_RAMDISK : %d", param_status.param_list[1].ident, param_status.param_list[1].value); klogi(" - %2d. BOOT_DELAY : %d", param_status.param_list[2].ident, param_status.param_list[2].value); klogi(" - %2d. LCD_LEVEL : %d", param_status.param_list[3].ident, param_status.param_list[3].value); klogi(" - %2d. SWITCH_SEL : %d", param_status.param_list[4].ident, param_status.param_list[4].value); klogi(" - %2d. PHONE_DEBUG_ON : %d", param_status.param_list[5].ident, param_status.param_list[5].value); klogi(" - %2d. LCD_DIM_LEVEL : %d", param_status.param_list[6].ident, param_status.param_list[6].value); klogi(" - %2d. LCD_DIM_TIME : %d", param_status.param_list[7].ident, param_status.param_list[7].value); klogi(" - %2d. MELODY_LEVEL : %d", param_status.param_list[8].ident, param_status.param_list[8].value); klogi(" - %2d. REBOOT_MODE : %d", param_status.param_list[9].ident, param_status.param_list[9].value); klogi(" - %2d. NATION_SEL : %d", param_status.param_list[10].ident, param_status.param_list[10].value); klogi(" - %2d. LANGUAGE_SEL : %d", param_status.param_list[11].ident, param_status.param_list[11].value); klogi(" - %2d. SET_DEFAULT_PARAM : %d", param_status.param_list[12].ident, param_status.param_list[12].value); #ifdef CONFIG_TIKAL_MPCS klogi(" - %2d. RESET REASON : %x", param_status.param_list[13].ident, param_status.param_list[13].value); #endif klogi(" - %2d. VERSION(STR) : %s", param_status.param_str_list[0].ident, param_status.param_str_list[0].value); klogi(" - %2d. CMDLINE(STR) : %s", param_status.param_str_list[1].ident, param_status.param_str_list[1].value); klogi("-----------------------------------------------------"); }
static void param_show_info(void) { signed int value = 0; signed char str_val[512]; klogi("-----------------------------------------------------"); klogi(" Information of Parameters"); klogi("-----------------------------------------------------"); klogi(" - param_magic : 0x%x", param_status.param_magic); klogi(" - param_version : 0x%x", param_status.param_version); get_param_value(__SERIAL_SPEED, &value); klogi(" - 00. SERIAL_SPEED : %d", value); get_param_value(__LOAD_TESTKERNEL, &value); klogi(" - 01. LOAD_TESTKERNEL : %d", value); get_param_value(__BOOT_DELAY, &value); klogi(" - 02. BOOT_DELAY : %d", value); get_param_value(__LCD_LEVEL, &value); klogi(" - 03. LCD_LEVEL : %d", value); get_param_value(__SWITCH_SEL, &value); klogi(" - 04. SWITCH_SEL : %d", value); get_param_value(__PHONE_DEBUG_ON, &value); klogi(" - 05. PHONE_DEBUG_ON : %d", value); get_param_value(__LCD_DIM_LEVEL, &value); klogi(" - 06. LCD_DIM_LEVEL : %d", value); get_param_value(__LCD_DIM_TIME, &value); klogi(" - 07. LCD_DIM_TIME : %d", value); get_param_value(__FORCE_PRERECOVERY, &value); klogi(" - 08. FORCE_PRERECOVERY : %d", value); get_param_value(__REBOOT_MODE, &value); klogi(" - 09. REBOOT_MODE : %d", value); get_param_value(__NATION_SEL, &value); klogi(" - 10. NATION_SEL : %d", value); get_param_value(__DEBUG_LEVEL, &value); klogi(" - 11. DEBUG_LEVEL : %d", value); get_param_value(__SET_DEFAULT_PARAM, &value); klogi(" - 12. SET_DEFAULT_PARAM : %d", value); get_param_value(__BATT_CAPACITY, &value); klogi(" - 13. BATTERY_CAPACITY : %d", value); get_param_value(__LOAD_KERNEL2, &value); klogi(" - 14. LOAD_KERNEL2 : %d", value); get_param_value(__FLASH_LOCK_STATUS, &value); klogi(" - 15. FLASH_LOCK_STATUS : %d", value); get_param_value(__PARAM_INT_14, &value); klogi(" - 16. PARAM_INT_14 : %d", value); get_param_value(__VERSION, &str_val); klogi(" - 17. VERSION(STR) : %s", str_val); get_param_value(__CMDLINE, &str_val); klogi(" - 18. CMDLINE(STR) : %s", str_val); get_param_value(__DELTA_LOCATION, &str_val); klogi(" - 19. DELTA_LOCATION(STR) : %s", str_val); get_param_value(__CMDLINE_MODE, &str_val); klogi(" - 20. CMDLINE_MODE(STR) : %s", str_val); get_param_value(__PARAM_STR_4, &str_val); klogi(" - 21. PARAM_STR_4(STR) : %s", str_val); klogi("-----------------------------------------------------"); }