static ssize_t usb_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 usb_sel = 0; usb_sel = secsw->switch_sel & USB_SEL_MASK; sec_get_param(param_index_uartsel, &secsw->switch_sel); secsw->is_manualset=1; if (strncmp(buf, "PDA", 3) == 0 || strncmp(buf, "pda", 3) == 0) { if (usb_sel!=SWITCH_APQ8K) { usb_switch_mode(secsw, SWITCH_APQ8K); secsw->switch_sel |= USB_SEL_MASK; } } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { if (usb_sel!=SWITCH_MDM9K) { usb_switch_mode(secsw, SWITCH_MDM9K); secsw->switch_sel &= ~USB_SEL_MASK; } } sec_set_param(param_index_uartsel, &secsw->switch_sel); return size; }
static ssize_t usb_sel_store( struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { dmsg("\n"); if (sec_get_param_value) sec_get_param_value(__SWITCH_SEL, &switch_sel); if(strncmp(buf, "PDA", 3) == 0 || strncmp(buf, "pda", 3) == 0) { usb_switch_mode(SWITCH_PDA); usb_switching_value_update(SWITCH_PDA); switch_sel |= USB_SEL_MASK; } if(strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { usb_switch_mode(SWITCH_MODEM); usb_switching_value_update(SWITCH_MODEM); switch_sel &= ~USB_SEL_MASK; } switching_value_update(); if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &switch_sel); microusb_uart_status(0); return size; }
static ssize_t usb_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 usb_sel = 0; usb_sel = secsw->switch_sel & USB_SEL_MASK; #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) { if (usb_sel!=SWITCH_PDA) { usb_switch_mode(secsw, SWITCH_PDA); secsw->switch_sel |= USB_SEL_MASK; } } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { if (usb_sel!=SWITCH_MODEM) { usb_switch_mode(secsw, SWITCH_MODEM); secsw->switch_sel &= ~USB_SEL_MASK; } } #ifdef CONFIG_SEC_MISC sec_set_param(param_index_uartsel, &secsw->switch_sel); #endif return size; }
static ssize_t usb_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sec_switch_struct *secsw = dev_get_drvdata(dev); printk("\n"); 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) { usb_switch_mode(secsw, SWITCH_PDA); // usb_switching_value_update(SWITCH_PDA); secsw->switch_sel |= USB_SEL_MASK; } if(strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { usb_switch_mode(secsw, SWITCH_MODEM); // usb_switching_value_update(SWITCH_MODEM); secsw->switch_sel &= ~USB_SEL_MASK; } // switching_value_update(); if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &(secsw->switch_sel)); // update shared variable. if(secsw->pdata && secsw->pdata->set_switch_status) secsw->pdata->set_switch_status(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; int ret = 0; int samsung_kies_sel,ums_sel,mtp_sel,vtp_sel,askon_sel; // printk("%s : called!!\n", __func__); if (sec_get_param_value && secsw->pdata && secsw->pdata->set_regulator && 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 if (!regulator_get(NULL, "vbus_ap") || !(secsw->pdata->get_phy_init_status())) { else { schedule_delayed_work(&wq->work_q, msecs_to_jiffies(1000)); return ; } if(secsw->pdata && secsw->pdata->get_regulator) { ret = secsw->pdata->get_regulator(); if(ret != 0) { pr_err("%s : failed to get regulators\n", __func__); return ; } } // init shared variable. if(secsw->pdata && secsw->pdata->set_switch_status) secsw->pdata->set_switch_status(secsw->switch_sel); usb_sel = secsw->switch_sel & (int)(USB_SEL_MASK); uart_sel = (secsw->switch_sel & (int)(UART_SEL_MASK)) >> 1; printk("%s : initial usb_sel(%d), uart_sel(%d)\n", __func__, usb_sel, uart_sel); // init UART/USB path. if(usb_sel) { usb_switch_mode(secsw, SWITCH_PDA); } else { usb_switch_mode(secsw, SWITCH_MODEM); } if(uart_sel) { gpio_set_value(GPIO_UART_SEL, 1); secsw->uart_owner = 1; } else { gpio_set_value(GPIO_UART_SEL, 0); secsw->uart_owner = 0; }
static ssize_t usb_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 = usb_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 == CABLE_CONNECTED) { usb_switch_mode(secsw, SWITCH_PDA); pr_info("[USB Switch] Path : PDA\n"); } else { pr_info("[USB Switch] Path is not change (PDA) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~USB_PATH_MASK) | USB_PATH_PDA; } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { if (value == CABLE_CONNECTED) { usb_switch_mode(secsw, SWITCH_MODEM); pr_info("[USB Switch] Path : MODEM\n"); } else { pr_info("[USB Switch] Path is not change (MODEM) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~USB_PATH_MASK) | USB_PATH_MODEM; } if (strncmp(buf, "LTEMODEM", 3) == 0 || strncmp(buf, "ltemodem", 3) == 0) { if (value == CABLE_CONNECTED) { usb_switch_mode(secsw, SWITCH_LTE); pr_info("[USB Switch] Path : LTEMODEM\n"); } else { pr_info("[USB Switch] Path is not change (LTEMODEM) Connect = %d\n", value); } secsw->switch_sel = (secsw->switch_sel & ~USB_PATH_MASK) | USB_PATH_LTE; } if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &secsw->switch_sel); return size; }
void usb_switch_state(void) { int usb_sel = 0; if(!connectivity_switching_init_state) return; if (sec_get_param_value) sec_get_param_value(__SWITCH_SEL, &switch_sel); usb_sel = switch_sel & (int)(USB_SEL_MASK); if(usb_sel) { usb_switch_mode(SWITCH_PDA); usb_switching_value_update(SWITCH_PDA); } else { usb_switch_mode(SWITCH_MODEM); usb_switching_value_update(SWITCH_MODEM); } }
static ssize_t usb_sel_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sec_switch_struct *secsw = dev_get_drvdata(dev); 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) { usb_switch_mode(secsw, SWITCH_PDA); secsw->switch_sel |= USB_SEL_MASK; } if (strncmp(buf, "MODEM", 5) == 0 || strncmp(buf, "modem", 5) == 0) { usb_switch_mode(secsw, SWITCH_MODEM); secsw->switch_sel &= ~USB_SEL_MASK; } if (sec_set_param_value) sec_set_param_value(__SWITCH_SEL, &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_debug("%s : initial sec switch value = 0x%X\n", __func__, secsw->switch_sel); usb_sel = secsw->switch_sel & USB_SEL_MASK; uart_sel = secsw->switch_sel & UART_SEL_MASK; /* init UART/USB path */ if (usb_sel) usb_switch_mode(secsw, SWITCH_PDA); else usb_switch_mode(secsw, SWITCH_MODEM); if (uart_sel) gpio_set_value(GPIO_UART_SEL, 1); else gpio_set_value(GPIO_UART_SEL, 0); }
void sec_usb_switch(void) { int switch_sel = USB_PATH_PDA; if (!finish_sec_switch_init) { pr_info("%s : skip for initialing\n", __func__); initial_path_sel = USB_PATH_MASK; return; } if (sec_get_param_value) sec_get_param_value(__SWITCH_SEL, &switch_sel); usb_switch_mode(dev_get_drvdata(switch_dev), switch_sel & USB_PATH_MASK); }
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; }