static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sec_switch_struct *secsw = dev_get_drvdata(dev); #ifdef CONFIG_SEC_MISC sec_get_param(param_index_uartsel, &secsw->switch_sel); #endif if (strncmp(buf, "PDA", 3) == 0 || strncmp(buf, "pda", 3) == 0) { uart_switch_mode(secsw, SWITCH_PDA); secsw->switch_sel |= UART_SEL_MASK; pr_err("[UART Switch] Path : PDA\n"); } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { uart_switch_mode(secsw, SWITCH_MODEM); secsw->switch_sel &= ~UART_SEL_MASK; pr_err("[UART Switch] Path : MODEM\n"); } pr_err("end %s value = 0x%X \n", __func__, secsw->switch_sel); #ifdef CONFIG_SEC_MISC sec_set_param(param_index_uartsel, &secsw->switch_sel); #endif return size; }
static void sec_switch_init_work(struct work_struct *work) { struct delayed_work *dw = container_of(work, struct delayed_work, work); struct sec_switch_wq *wq = container_of(dw, struct sec_switch_wq, work_q); struct sec_switch_struct *secsw = wq->sdata; int usb_sel = 0; int uart_sel = 0; cancel_delayed_work(&wq->work_q); sec_get_param(param_index_uartsel, &secsw->switch_sel); if ( secsw->switch_sel == 0 ) { secsw->switch_sel = 0x4; // UART_SEL default to MDM9K & USB_SEL default to APQ8K : 0100 sec_set_param(param_index_uartsel, &secsw->switch_sel); } pr_err("sec_switch_probe enter %s value = 0x%X \n", __func__, secsw->switch_sel); usb_sel = secsw->switch_sel & USB_SEL_MASK; uart_sel = secsw->switch_sel & UART_SEL_MASK; if (uart_sel) uart_switch_mode(secsw, SWITCH_APQ8K); else uart_switch_mode(secsw, SWITCH_MDM9K); }
static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sec_switch_struct *secsw = dev_get_drvdata(dev); int value; value = uart_cable; pr_info("%s\n", __func__); pr_info("%s the device type detected is %x\n", __func__, value); if (sec_get_param_value) sec_get_param_value(__SWITCH_SEL, &secsw->switch_sel); if (strncmp(buf, "PDA", 3) == 0 || strncmp(buf, "pda", 3) == 0) { if ((value == UART_JIG_ON_CONNECTED) || (value == UART_JIG_OFF_CONNECTED)) { uart_switch_mode(secsw, SWITCH_PDA); pr_info("[UART Switch] Path : PDA\n"); } else { pr_info("[UART Switch] Path is not change (PDA) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~UART_PATH_MASK) | UART_PATH_PDA; } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { if ((value == UART_JIG_ON_CONNECTED) || (value == UART_JIG_OFF_CONNECTED)) { uart_switch_mode(secsw, SWITCH_MODEM); pr_info("[UART Switch] Path : MODEM\n"); } else { pr_info("[UART Switch] Path is not change (MODEM) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~UART_PATH_MASK) | UART_PATH_MODEM; } if (strncmp(buf, "LTEMODEM", 8) == 0 || strncmp(buf, "ltemodem", 8) == 0) { if ((value == UART_JIG_ON_CONNECTED) || (value == UART_JIG_OFF_CONNECTED)) { uart_switch_mode(secsw, SWITCH_LTE); pr_info("[UART Switch] Path : LTEMODEM\n"); } else { pr_info("[UART Switch] Path is not change (LTEMODEM) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~UART_PATH_MASK) | UART_PATH_LTE; } if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &secsw->switch_sel); return size; }
static ssize_t uart_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sec_switch_struct *secsw = dev_get_drvdata(dev); sec_get_param(param_index_uartsel, &secsw->switch_sel); if (strncmp(buf, "PDA", 3) == 0 || strncmp(buf, "pda", 3) == 0) { uart_switch_mode(secsw, SWITCH_APQ8K); secsw->switch_sel |= UART_SEL_MASK; pr_debug("[UART Switch] Path : PDA\n"); } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { uart_switch_mode(secsw, SWITCH_MDM9K); secsw->switch_sel &= ~UART_SEL_MASK; pr_debug("[UART Switch] Path : MODEM\n"); } sec_set_param(param_index_uartsel, &secsw->switch_sel); return size; }
static void sec_switch_init_work(struct work_struct *work) { struct delayed_work *dw = container_of(work, struct delayed_work, work); struct sec_switch_wq *wq = container_of(dw, struct sec_switch_wq, work_q); struct sec_switch_struct *secsw = wq->sdata; int usb_sel = 0; int uart_sel = 0; if (sec_get_param_value && secsw->pdata && secsw->pdata->set_vbus_status && secsw->pdata->get_phy_init_status && secsw->pdata->get_phy_init_status()) { sec_get_param_value(__SWITCH_SEL, &secsw->switch_sel); cancel_delayed_work(&wq->work_q); } else { schedule_delayed_work(&wq->work_q, msecs_to_jiffies(1000)); return; } pr_info("%s : initial sec switch value = 0x%X\n", __func__, secsw->switch_sel); if (!(secsw->switch_sel & UART_DEBUG_MASK) || ((secsw->switch_sel & UART_PATH_MASK) == UART_PATH_MASK)) secsw->switch_sel = (secsw->switch_sel & ~UART_PATH_MASK) | UART_PATH_MODEM; if ((secsw->switch_sel & USB_PATH_MASK) == USB_PATH_MASK) secsw->switch_sel = (secsw->switch_sel & ~USB_PATH_MASK) | USB_PATH_PDA; if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &secsw->switch_sel); usb_sel = secsw->switch_sel & USB_PATH_MASK; uart_sel = (secsw->switch_sel & UART_PATH_MASK) >> 2; if (initial_path_sel == USB_PATH_MASK) usb_switch_mode(secsw, usb_sel); else if (initial_path_sel == UART_PATH_MASK) uart_switch_mode(secsw, uart_sel); finish_sec_switch_init = 1; }
static void sec_switch_init_work(struct work_struct *work) { struct delayed_work *dw = container_of(work, struct delayed_work, work); struct sec_switch_wq *wq = container_of(dw, struct sec_switch_wq, work_q); struct sec_switch_struct *secsw = wq->sdata; int usb_sel = 0; int uart_sel = 0; #if 0 if (sec_get_param_value && secsw->pdata && secsw->pdata->set_vbus_status && secsw->pdata->get_phy_init_status && secsw->pdata->get_phy_init_status() && check_for_cp_boot()) { sec_get_param_value(__SWITCH_SEL, &secsw->switch_sel); #endif if (secsw->pdata && secsw->pdata->set_vbus_status && secsw->pdata->get_phy_init_status && secsw->pdata->get_phy_init_status()) { #ifdef CONFIG_SEC_MISC if ( (!sec_get_param(param_index_uartsel, &secsw->switch_sel)) && (gRetryCount++ < 9) ) { pr_err("%s error value = %d \n", __func__, secsw->switch_sel); schedule_delayed_work(&wq->work_q, msecs_to_jiffies(1000)); return; } //To prevent lock up during getting parameter about switch_sel. if(gRetryCount > 9) { secsw->switch_sel = 1; // default modem pr_err("%s failed 10 times... So switch_sel is set by [1]\n", __func__); } gRetryCount = 0; #endif pr_err("%s value = %d \n", __func__, secsw->switch_sel); cancel_delayed_work(&wq->work_q); } else { schedule_delayed_work(&wq->work_q, msecs_to_jiffies(1000)); return; } usb_sel = secsw->switch_sel & USB_SEL_MASK; uart_sel = secsw->switch_sel & UART_SEL_MASK; // USB switch not use LTE if (usb_sel) usb_switch_mode(secsw, SWITCH_PDA); else usb_switch_mode(secsw, SWITCH_MODEM); // UART switch mode if (uart_sel) uart_switch_mode(secsw, SWITCH_PDA); else uart_switch_mode(secsw, SWITCH_MODEM); } static int sec_switch_probe(struct platform_device *pdev) { struct sec_switch_struct *secsw; struct sec_switch_platform_data *pdata = pdev->dev.platform_data; struct sec_switch_wq *wq; pr_err("sec_switch_probe enter %s\n", __func__); if (!pdata) { pr_err("%s : pdata is NULL.\n", __func__); return -ENODEV; } secsw = kzalloc(sizeof(struct sec_switch_struct), GFP_KERNEL); if (!secsw) { pr_err("%s : failed to allocate memory\n", __func__); return -ENOMEM; } secsw->pdata = pdata; #if defined (CONFIG_TARGET_LOCALE_US_ATT_REV01) || defined(CONFIG_KOR_MODEL_SHV_E160S)|| defined (CONFIG_KOR_MODEL_SHV_E160K) || defined (CONFIG_KOR_MODEL_SHV_E160L) || defined (CONFIG_JPN_MODEL_SC_05D) secsw->switch_sel = 3; #else secsw->switch_sel = 1; #endif dev_set_drvdata(switch_dev, secsw); /* create sysfs files */ if (device_create_file(switch_dev, &dev_attr_uart_sel) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_uart_sel.attr.name); if (device_create_file(switch_dev, &dev_attr_usb_sel) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_usb_sel.attr.name); if (device_create_file(switch_dev, &dev_attr_usb_state) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name); if (device_create_file(switch_dev, &dev_attr_disable_vbus) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name); if (device_create_file(switch_dev, &dev_attr_device_type) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_device_type.attr.name); #ifdef _SEC_DM_ usb_lock = device_create(sec_class, switch_dev, MKDEV(0, 0), NULL, ".usb_lock"); if (IS_ERR(usb_lock)) { pr_err("Failed to create device (usb_lock)!\n"); return PTR_ERR(usb_lock); } dev_set_drvdata(usb_lock, secsw); if (device_create_file(usb_lock, &dev_attr_enable) < 0) { pr_err("Failed to create device file(%s)!\n", dev_attr_enable.attr.name); device_destroy((struct class *)usb_lock, MKDEV(0, 0)); } #endif /* run work queue */ wq = kmalloc(sizeof(struct sec_switch_wq), GFP_ATOMIC); if (wq) { wq->sdata = secsw; INIT_DELAYED_WORK(&wq->work_q, sec_switch_init_work); schedule_delayed_work(&wq->work_q, msecs_to_jiffies(100)); } else return -ENOMEM; return 0; }