void oem_reset_modem(void) { wake_lock_timeout(&vmdata->wlock, MDM_RST_LOCK_TIME * HZ); if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST)){ oem_gpio_direction_output(GPIO_VIATEL_CRASH_CBP, 1); oem_gpio_direction_output(GPIO_VIATEL_MDM_RST, 1); mdelay(MDM_RST_HOLD_DELAY); oem_gpio_direction_output(GPIO_VIATEL_MDM_RST, 0); mdelay(MDM_RST_HOLD_DELAY); } printk("Warnning: reset vmodem\n"); }
void oem_power_on_modem(void) { #ifdef OEM_HAVE_VOLT_PROTECTION/*take care,it should be modified if platform if changed*/ via_sync_on(); #endif //add by yfu to control LDO VGP2 //turn on VGP2 and set 2.8v hwPowerOn(MT6323_POWER_LDO_VGP2, VOL_2800,"VIA"); if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_PWR_EN)){ if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST)){ oem_gpio_direction_output(GPIO_VIATEL_CRASH_CBP, 1); oem_gpio_direction_output(GPIO_VIATEL_MDM_RST, 0); mdelay(MDM_RST_HOLD_DELAY); } oem_gpio_direction_output(GPIO_VIATEL_MDM_PWR_EN, 1); mdelay(MDM_PWR_HOLD_DELAY); } printk("Warnning: power on vmodem\n"); }
static int modem_boot_remove(struct platform_device *pdev) { if(GPIO_OEM_VALID(cbp_rst_ind_gpio)){ free_irq(oem_gpio_to_irq(cbp_rst_ind_gpio), vmdata); oem_gpio_free(cbp_rst_ind_gpio); modem_unregister_notifier(&vmdata->rst_ntf); } if(vmdata) wake_lock_destroy(&vmdata->wlock); return 0; }
ssize_t modem_power_show( struct kobject *kobj, struct kobj_attribute *attr, char *buf) { int power = 0; int ret = 0; if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_PWR_IND)){ power = !!oem_gpio_get_value(GPIO_VIATEL_MDM_PWR_IND); }else if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_PWR_EN)){ printk("No MDM_PWR_IND, just detect MDM_PWR_EN\n"); power = !!oem_gpio_get_value(GPIO_VIATEL_MDM_PWR_EN); }else if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST)){ printk("No MDM_PWR_IND, just detect MDM_PWR_RST\n"); power = !!oem_gpio_get_value(GPIO_VIATEL_MDM_RST); } if(power){ ret += sprintf(buf + ret, "on\n"); }else{ ret += sprintf(buf + ret, "off\n"); } return ret; }
void oem_power_on_modem(void) { if(GPIO_OEM_VALID(cbp_pwr_en_gpio)){ printk("%s %d\n",__func__,__LINE__); if(GPIO_OEM_VALID(cbp_rst_gpio)){ printk("%s %d\n",__func__,__LINE__); oem_gpio_direction_output(GPIO_VIATEL_CRASH_CBP, 1); oem_gpio_direction_output(cbp_rst_gpio, 0); mdelay(MDM_RST_HOLD_DELAY); printk("%s %d\n",__func__,__LINE__); } oem_gpio_direction_output(cbp_pwr_en_gpio, 1); mdelay(MDM_PWR_HOLD_DELAY); printk("%s %d\n",__func__,__LINE__); } if (cbp_need_apr){ set_time_stamp(); schedule_delayed_work(&apr_log_wk, msecs_to_jiffies(60*1000));/*wait for 1 minute due to ramdump may later*/ cbp_need_apr = 0; } printk("Warnning: power on vmodem\n"); }
ssize_t modem_boot_select_store( struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_BOOT_SEL)){ if ( !strncmp(buf, "1", strlen("1"))) { oem_gpio_direction_output(GPIO_VIATEL_MDM_BOOT_SEL, 1); }else if( !strncmp(buf, "0", strlen("0"))){ oem_gpio_direction_output(GPIO_VIATEL_MDM_BOOT_SEL, 0); }else{ printk("Unknow command.\n"); } } return n; }
ssize_t modem_via_rst_mdm_show(struct device *dev, struct device_attribute *attr, char *buf) { int reset = 0; if(GPIO_OEM_VALID(cbp_rst_ind_gpio)) { reset = !!oem_gpio_get_cbp_rst_ind_value(); } if(reset) { return snprintf(buf,PAGE_SIZE,"via_reset_on\n"); } else { return snprintf(buf,PAGE_SIZE,"via_reset_off\n"); } }
static irqreturn_t modem_reset_indication_irq(int irq, void *data) { printk("%s %d \n",__FUNCTION__,__LINE__); if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST_IND)){ oem_gpio_set_irq_type(GPIO_VIATEL_MDM_RST_IND, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); if(oem_gpio_get_value(GPIO_VIATEL_MDM_RST_IND)){ printk("%s %d ON\n",__FUNCTION__,__LINE__); wake_lock_timeout(&vmdata->wlock, MDM_RST_LOCK_TIME * HZ); modem_notify_event(MDM_EVT_NOTIFY_RESET_ON); }else{ printk("%s %d OFF\n",__FUNCTION__,__LINE__); modem_notify_event(MDM_EVT_NOTIFY_RESET_OFF); } } gpio_irq_cbp_rst_ind(); oem_gpio_irq_unmask(GPIO_VIATEL_MDM_RST_IND); return IRQ_HANDLED; }
ssize_t modem_diecbp_store( struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { if(GPIO_OEM_VALID(GPIO_VIATEL_CRASH_CBP)){ if ( !strncmp(buf, "1", strlen("1"))) { oem_gpio_direction_output(GPIO_VIATEL_CRASH_CBP, 1); }else if( !strncmp(buf, "0", strlen("0"))){ oem_gpio_direction_output(GPIO_VIATEL_CRASH_CBP, 0); }else{ printk("Unknow command.\n"); } }else{ printk("invalid gpio.\n"); } return n; }
ssize_t modem_sim_switch_show(struct device *dev, struct device_attribute *attr, char *buf) { int reset = 0; int ret = 0; if(GPIO_OEM_VALID(cbp_sim_switch_gpio)) { reset = !!oem_gpio_get_value(cbp_sim_switch_gpio); } if(reset) { ret += sprintf(buf + ret, "sim_to_VIA\n"); } else { ret += sprintf(buf + ret, "sim_to_Balong\n"); } return ret; }
static int __init modem_init(void) { int ret = 0; vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL); if(!vmdata){ ret = -ENOMEM; printk("No memory to alloc vmdata"); goto err_create_vmdata; } ret = modem_data_init(vmdata); if(ret < 0){ printk("Fail to init modem data\n"); goto err_init_modem_data; } ret = platform_device_register(&platform_modem_device); if (ret) { printk("platform_device_register failed\n"); goto err_platform_device_register; } ret = platform_driver_register(&platform_modem_driver); if (ret) { printk("platform_driver_register failed\n"); goto err_platform_driver_register; } ret = misc_register(&misc_modem_device); if(ret < 0){ printk("misc regiser via modem failed\n"); goto err_misc_device_register; } //make the default ETS output through USB if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_ETS_SEL)){ oem_gpio_direction_output(GPIO_VIATEL_MDM_ETS_SEL, 0); } if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_PWR_IND)){ oem_gpio_irq_mask(GPIO_VIATEL_MDM_PWR_IND); oem_gpio_direction_input_for_irq(GPIO_VIATEL_MDM_PWR_IND); oem_gpio_set_irq_type(GPIO_VIATEL_MDM_PWR_IND, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(GPIO_VIATEL_MDM_PWR_IND, modem_power_indication_irq, \ IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, \ "mdm_power_ind", vmdata); oem_gpio_irq_unmask(GPIO_VIATEL_MDM_PWR_IND); if (ret < 0) { printk("fail to request mdm_power_ind irq\n"); } modem_register_notifier(&vmdata->pwr_ntf); } if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST_IND)){ oem_gpio_irq_mask(GPIO_VIATEL_MDM_RST_IND); oem_gpio_direction_input_for_irq(GPIO_VIATEL_MDM_RST_IND); oem_gpio_set_irq_type(GPIO_VIATEL_MDM_RST_IND, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(GPIO_VIATEL_MDM_RST_IND, modem_reset_indication_irq, \ IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, \ "mdm_reset_ind", vmdata); oem_gpio_irq_unmask(GPIO_VIATEL_MDM_RST_IND); if (ret < 0) { printk("fail to request mdm_rst_ind irq\n"); } modem_register_notifier(&vmdata->rst_ntf); } //oem_gpio_direction_output(GPIO_VIATEL_MDM_RST, 0); //oem_gpio_direction_output(GPIO_VIATEL_MDM_PWR_EN, 1); ret = sysfs_create_group(vmdata->modem_kobj, &g_attr_group); if(ret){ printk("sysfs_create_group failed\n"); goto err_sysfs_create_group; } return 0; err_sysfs_create_group: misc_deregister(&misc_modem_device); err_misc_device_register: platform_driver_unregister(&platform_modem_driver); err_platform_driver_register: platform_device_unregister(&platform_modem_device); err_platform_device_register: err_init_modem_data: kfree(vmdata); vmdata = NULL; err_create_vmdata: return ret; }
static int modem_sync_init(void) { int ret = 0; struct asc_infor user; struct asc_config cfg; /*Registe the cbp tx handle*/ if(GPIO_OEM_VALID(GPIO_VIATEL_AP_WAKE_MDM) && GPIO_OEM_VALID(GPIO_VIATEL_MDM_RDY)){ memset(&cfg, 0, sizeof(struct asc_config)); strncpy(cfg.name, CBP_TX_HD_NAME, ASC_NAME_LEN); cfg.gpio_wake = GPIO_VIATEL_AP_WAKE_MDM; cfg.gpio_ready = GPIO_VIATEL_MDM_RDY; cfg.polar = 1; ret = asc_tx_register_handle(&cfg); if(ret < 0){ printk("%s: fail to regist tx handle %s\n", __FUNCTION__, CBP_TX_HD_NAME); goto end_sync_init; } } /*Registe the usb rx handle*/ if(GPIO_OEM_VALID(GPIO_VIATEL_USB_MDM_WAKE_AP) && GPIO_OEM_VALID(GPIO_VIATEL_USB_AP_RDY)){ memset(&cfg, 0, sizeof(struct asc_config)); strncpy(cfg.name, USB_RX_HD_NAME, ASC_NAME_LEN); cfg.gpio_wake = GPIO_VIATEL_USB_MDM_WAKE_AP; cfg.gpio_ready = GPIO_VIATEL_USB_AP_RDY; cfg.polar = 1; ret = asc_rx_register_handle(&cfg); if(ret < 0){ printk("%s: fail to regist rx handle %s\n", __FUNCTION__, USB_RX_HD_NAME); goto end_sync_init; } memset(&user, 0, sizeof(struct asc_infor)); user.notifier = modem_userspace_notifier, user.data = USB_RX_HD_NAME, snprintf(user.name, ASC_NAME_LEN, USB_RX_USER_NAME); ret = asc_rx_add_user(USB_RX_HD_NAME, &user); if(ret < 0){ printk("%s: fail to regist rx user %s\n", __FUNCTION__, USB_RX_USER_NAME); goto end_sync_init; } } /*Registe the uart rx handle*/ if(GPIO_OEM_VALID(GPIO_VIATEL_UART_MDM_WAKE_AP) && GPIO_OEM_VALID(GPIO_VIATEL_UART_AP_RDY)){ memset(&cfg, 0, sizeof(struct asc_config)); strncpy(cfg.name, UART_RX_HD_NAME, ASC_NAME_LEN); cfg.gpio_wake = GPIO_VIATEL_UART_MDM_WAKE_AP; cfg.gpio_ready = GPIO_VIATEL_UART_AP_RDY; cfg.polar = 1; ret = asc_rx_register_handle(&cfg); if(ret < 0){ printk("%s: fail to regist rx handle %s\n", __FUNCTION__, UART_RX_HD_NAME); goto end_sync_init; } memset(&user, 0, sizeof(struct asc_infor)); user.notifier = modem_userspace_notifier, user.data = UART_RX_HD_NAME, snprintf(user.name, ASC_NAME_LEN, UART_RX_USER_NAME); ret = asc_rx_add_user(UART_RX_HD_NAME, &user); if(ret < 0){ printk("%s: fail to regist rx user %s\n", __FUNCTION__, UART_RX_USER_NAME); goto end_sync_init; } } end_sync_init: if(ret){ printk("%s: error\n", __FUNCTION__); } return ret; }
static int modem_boot_probe(struct platform_device *dev) { int ret = 0; vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL); if(!vmdata) { ret = -ENOMEM; printk("No memory to alloc vmdata"); goto err_create_vmdata; } vmdata->via_pdev = dev; vmdata->tail = 0; vmdata->head = 0; ret = modem_data_init(vmdata); if(ret < 0) { printk("Fail to init modem data\n"); goto err_init_modem_data; } ret = device_create_file(&(dev->dev), &dev_attr_state); if(ret < 0) { dev_err(&dev->dev, "Failed to create sysfs entry state\n"); goto err_create_sysfs_state; } ret = device_create_file(&(dev->dev), &dev_attr_modem_state); if(ret < 0) { dev_err(&dev->dev, "Failed to create sysfs entry modem_state\n"); goto err_create_sysfs_modem_state; } ret = device_create_file(&(dev->dev), &dev_attr_sim_switch); if(ret < 0) { dev_err(&dev->dev, "Failed to create sysfs entry sim_switch\n"); goto err_create_sysfs_sim_switch; } ret = oem_get_gpio_number(CBP_VIATEL_RST_IND_STR,&cbp_rst_ind_gpio); if (ret) goto err_get_gpio; pr_info("%s get CBP_VIATEL_RST_IND_STR gpio %d\n", __func__, cbp_rst_ind_gpio); if(GPIO_OEM_VALID(cbp_rst_ind_gpio)){ ret = oem_gpio_request(cbp_rst_ind_gpio, "GPIO_VIATEL_MDM_RST_IND"); oem_gpio_irq_mask(cbp_rst_ind_gpio); oem_gpio_direction_input_for_irq(cbp_rst_ind_gpio); oem_gpio_set_irq_type(cbp_rst_ind_gpio, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \ IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \ "mdm_reset_ind", vmdata); oem_gpio_irq_unmask(cbp_rst_ind_gpio); if (ret < 0) { printk("fail to request mdm_rst_ind irq\n"); } modem_register_notifier(&vmdata->rst_ntf); } ret = oem_get_gpio_number(CBP_VIATEL_PWR_EN_STR, &cbp_pwr_en_gpio); if (ret) goto err_get_gpio; pr_info(">>>> %s get gpio %d\n", __func__, cbp_pwr_en_gpio); if(GPIO_OEM_VALID(cbp_pwr_en_gpio)){ ret = oem_gpio_request(cbp_pwr_en_gpio, "GPIO_VIATEL_MDM_PWR_EN"); if (0 > ret) { printk("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__); } oem_gpio_direction_output(cbp_pwr_en_gpio, 0); } ret = oem_get_gpio_number(CBP_VIATEL_RST_STR, &cbp_rst_gpio); if (ret) goto err_get_gpio; pr_info(">>>> %s get gpio %d\n", __func__,cbp_rst_gpio); if(GPIO_OEM_VALID(cbp_rst_gpio)){ ret = oem_gpio_request(cbp_rst_gpio, "GPIO_VIATEL_MDM_RST"); if (0 > ret) { printk("%s: gpio request GPIO_VIATEL_MDM_RST failed", __FUNCTION__); } oem_gpio_direction_output(cbp_rst_gpio, 0); } ret = oem_get_gpio_number(CBP_VIATEL_SIM_SWITCH_STR, &cbp_sim_switch_gpio); if(ret){ printk("%s: Sim connection switch isn't supported on this board", __FUNCTION__); }else{ printk("%s: Sim connection switch is supported on this board", __FUNCTION__); } pr_info(">>>> %s get gpio %d\n", __func__,cbp_sim_switch_gpio); if(GPIO_OEM_VALID(cbp_sim_switch_gpio)){ ret = oem_gpio_request(cbp_sim_switch_gpio, "GPIO_VIATEL_MDM_SIM_SWITCH"); if(0 > ret){ printk("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__); } oem_gpio_direction_output(cbp_sim_switch_gpio, 0); } /*add gpio function to make cp ramdump*/ ret = oem_get_gpio_number(CBP_VIATEL_GPIO_BACKUP_STR, &cbp_backup_gpio); if (ret) goto err_get_gpio; ret = oem_gpio_request(cbp_backup_gpio, "gpio_cbp_crash"); if(0 > ret){ printk("%s: gpio request GPIO_6_0 failed", __FUNCTION__); } oem_gpio_direction_output(cbp_backup_gpio, 0); return 0; err_get_gpio: device_remove_file(&(dev->dev), &dev_attr_sim_switch); err_create_sysfs_sim_switch: device_remove_file(&(dev->dev), &dev_attr_modem_state); err_create_sysfs_modem_state: device_remove_file(&(dev->dev), &dev_attr_state); err_create_sysfs_state: err_init_modem_data: kfree(vmdata); vmdata = NULL; err_create_vmdata: return ret; }
//static int __devinit cbp_probe(struct platform_device *pdev) static int cbp_probe(struct platform_device *pdev) { struct cbp_platform_data *plat = pdev->dev.platform_data; int ret = -1; /* must have platform data */ if (!plat) { LOGPRT(LOG_ERR, "%s: no platform data!\n", __func__); ret = -EINVAL; goto out; } if(plat->bus && !strcmp(plat->bus,"sdio")){ if(plat->detect_host){ ret = plat->detect_host(plat->host_id); if(ret){ LOGPRT(LOG_ERR, "%s: host %s dectect failed!\n", __func__, plat->host_id); goto out; } } else{ LOGPRT(LOG_ERR, "%s: bus %s have no dectect function!\n", __func__, plat->bus); goto out; } } else{ LOGPRT(LOG_ERR, "%s: unknow bus!\n", __func__); goto out; } if((GPIO_OEM_VALID(plat->gpio_sd_select)) && (GPIO_OEM_VALID(plat->gpio_mc3_enable))){ ret = oem_gpio_request(plat->gpio_mc3_enable, DRIVER_NAME"(MC3_EN_N)"); if(ret < 0){ LOGPRT(LOG_ERR, "%s: %d fail to requset MC3_EN_N gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_mc3_enable,ret); goto out; } ret = oem_gpio_request(plat->gpio_sd_select, DRIVER_NAME"(SD_SEL_N)"); if(ret < 0){ LOGPRT(LOG_ERR, "%s: %d fail to requset SD_SEL_N gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_sd_select,ret); goto err_req_sd_sel; } oem_gpio_direction_output(GPIO_VIATEL_MC3_EN_N, 0); //MC3_EN_N oem_gpio_direction_output(GPIO_VIATEL_SD_SEL_N, 0); //SD_SEL_N } if(GPIO_OEM_VALID(plat->gpio_data_ack)){ cbp_data_ack = kzalloc(sizeof(struct cbp_wait_event), GFP_KERNEL); if (!cbp_data_ack){ ret = -ENOMEM; LOGPRT(LOG_ERR, "%s %d kzalloc cbp_data_ack failed \n",__func__, __LINE__); goto err_kzalloc_cbp_data_ack; } init_waitqueue_head(&cbp_data_ack->wait_q); atomic_set(&cbp_data_ack->state, MODEM_ST_UNKNOW); cbp_data_ack->wait_gpio = plat->gpio_data_ack; cbp_data_ack->wait_polar = plat->gpio_data_ack_polar; LOGPRT(LOG_ERR, "cbp_data_ack->wait_gpio=%d\n",cbp_data_ack->wait_gpio); LOGPRT(LOG_ERR, "cbp_data_ack->wait_polar=%d\n",cbp_data_ack->wait_polar); ret = oem_gpio_request(plat->gpio_data_ack, DRIVER_NAME "(data_ack)"); if(ret < 0){ LOGPRT(LOG_ERR, "%s: %d fail to requset data_ack gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_data_ack, ret); goto err_req_data_ack; } oem_gpio_irq_mask(plat->gpio_data_ack); oem_gpio_direction_input_for_irq(plat->gpio_data_ack); oem_gpio_set_irq_type(plat->gpio_data_ack, IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(plat->gpio_data_ack, gpio_irq_data_ack, IRQF_SHARED | IRQF_TRIGGER_FALLING, DRIVER_NAME "(data_ack)", cbp_data_ack); oem_gpio_irq_unmask(plat->gpio_data_ack); if (ret < 0) { LOGPRT(LOG_ERR, "%s: %d fail to request irq for data_ack!!\n", __func__, __LINE__); goto err_req_irq_data_ack; } plat->cbp_data_ack = cbp_data_ack; plat->data_ack_wait_event = data_ack_wait_event; plat->data_ack_enable =true; } if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ cbp_flow_ctrl = kzalloc(sizeof(struct cbp_wait_event), GFP_KERNEL); if (!cbp_flow_ctrl){ ret = -ENOMEM; LOGPRT(LOG_ERR, "%s %d kzalloc cbp_flow_ctrl failed \n",__func__, __LINE__); goto err_kzalloc_cbp_flow_ctrl; } init_waitqueue_head(&cbp_flow_ctrl->wait_q); atomic_set(&cbp_flow_ctrl->state, FLOW_CTRL_DISABLE); cbp_flow_ctrl->wait_gpio = plat->gpio_flow_ctrl; cbp_flow_ctrl->wait_polar = plat->gpio_flow_ctrl_polar; LOGPRT(LOG_ERR, "cbp_flow_ctrl->wait_gpio=%d\n",cbp_flow_ctrl->wait_gpio); LOGPRT(LOG_ERR, "cbp_flow_ctrl->wait_polar=%d\n",cbp_flow_ctrl->wait_polar); ret = oem_gpio_request(plat->gpio_flow_ctrl, DRIVER_NAME "(flow_ctrl)"); if(ret < 0){ LOGPRT(LOG_ERR, "%s: %d fail to requset flow_ctrl gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_flow_ctrl, ret); goto err_req_flow_ctrl; } oem_gpio_irq_mask(plat->gpio_flow_ctrl); oem_gpio_direction_input_for_irq(plat->gpio_flow_ctrl); //oem_gpio_set_irq_type(plat->gpio_flow_ctrl, IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_LEVEL_HIGH); oem_gpio_set_irq_type(plat->gpio_flow_ctrl, IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(plat->gpio_flow_ctrl, gpio_irq_flow_ctrl, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, DRIVER_NAME "(flow_ctrl)", cbp_flow_ctrl); oem_gpio_irq_unmask(plat->gpio_flow_ctrl); if (ret < 0) { LOGPRT(LOG_ERR, "%s: %d fail to request irq for flow_ctrl!!\n", __func__, __LINE__); goto err_req_irq_flow_ctrl; } plat->cbp_flow_ctrl= cbp_flow_ctrl; plat->flow_ctrl_wait_event = flow_ctrl_wait_event; plat->flow_ctrl_enable = true; } if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ cbp_rst_ind = kzalloc(sizeof(struct cbp_reset), GFP_KERNEL); if (!cbp_rst_ind){ ret = -ENOMEM; LOGPRT(LOG_ERR, "%s %d kzalloc cbp_rst_ind failed \n",__func__, __LINE__); goto err_kzalloc_cbp_rst_ind; } cbp_rst_ind->name = "cbp_rst_ind_wq"; cbp_rst_ind->reset_wq = create_singlethread_workqueue(cbp_rst_ind->name); if (cbp_rst_ind->reset_wq == NULL) { ret = -ENOMEM; LOGPRT(LOG_ERR, "%s %d error creat rst_ind_workqueue \n",__func__, __LINE__); goto err_create_work_queue; } INIT_WORK(&cbp_rst_ind->reset_work, modem_detect); cbp_rst_ind->rst_ind_gpio = plat->gpio_rst_ind; cbp_rst_ind->rst_ind_polar = plat->gpio_rst_ind_polar; cbp_rst_ind->host = NULL; #if 0 ret = oem_gpio_request(plat->gpio_rst_ind, DRIVER_NAME "(rst_ind)"); if(ret < 0){ LOGPRT(LOG_ERR, "%s: %d fail to requset rst_ind gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_rst_ind, ret); goto err_req_rst_ind; } oem_gpio_irq_mask(plat->gpio_rst_ind); oem_gpio_direction_input_for_irq(plat->gpio_rst_ind); oem_gpio_set_irq_type(plat->gpio_rst_ind, IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING); ret = oem_gpio_request_irq(plat->gpio_rst_ind, gpio_irq_cbp_rst_ind, IRQF_SHARED |IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING, DRIVER_NAME "(rst_ind)", cbp_rst_ind); oem_gpio_irq_unmask(plat->gpio_rst_ind); if (ret < 0) { LOGPRT(LOG_ERR, "%s: %d fail to request irq for rst_ind!!\n", __func__, __LINE__); goto err_req_irq_rst_ind; } #endif plat->rst_ind_enable = true; } if((GPIO_OEM_VALID(plat->gpio_ap_wkup_cp)) && (GPIO_OEM_VALID(plat->gpio_cp_ready)) && (GPIO_OEM_VALID(plat->gpio_cp_wkup_ap)) && (GPIO_OEM_VALID(plat->gpio_ap_ready))){ sdio_tx_handle.gpio_wake = plat->gpio_ap_wkup_cp; sdio_tx_handle.gpio_ready = plat->gpio_cp_ready; sdio_tx_handle.polar = plat->gpio_sync_polar; ret = asc_tx_register_handle(&sdio_tx_handle); if(ret){ LOGPRT(LOG_ERR, "%s %d asc_tx_register_handle failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } ret = asc_tx_add_user(sdio_tx_handle.name, &sdio_tx_user); if(ret){ LOGPRT(LOG_ERR, "%s %d asc_tx_add_user failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } sdio_rx_handle.gpio_wake = plat->gpio_cp_wkup_ap; sdio_rx_handle.gpio_ready = plat->gpio_ap_ready; sdio_rx_handle.polar = plat->gpio_sync_polar; ret = asc_rx_register_handle(&sdio_rx_handle); if(ret){ LOGPRT(LOG_ERR, "%s %d asc_rx_register_handle failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } ret = asc_rx_add_user(sdio_rx_handle.name, &sdio_rx_user); if(ret){ LOGPRT(LOG_ERR, "%s %d asc_rx_add_user failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } plat->ipc_enable = true; plat->tx_handle = &sdio_tx_handle; } ret = plat->cbp_setup(plat); if(ret){ LOGPRT(LOG_ERR, "%s: host %s setup failed!\n", __func__, plat->host_id); goto err_ipc; } cbp_power_kobj = viatel_kobject_add("power"); if (!cbp_power_kobj){ LOGPRT(LOG_ERR, "error viatel_kobject_add!\n"); ret = -ENOMEM; goto err_create_kobj; } LOGPRT(LOG_INFO, " cbp initialized on host %s successfully, bus is %s !\n", plat->host_id, plat->bus); return sysfs_create_group(cbp_power_kobj, &g_power_attr_group); err_create_kobj: plat->cbp_destroy(); err_ipc: #if 0 if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ free_irq(oem_gpio_to_irq(plat->gpio_rst_ind), cbp_rst_ind); } err_req_irq_rst_ind: if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ oem_gpio_free(plat->gpio_rst_ind); } #endif err_req_rst_ind: if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ destroy_workqueue(cbp_rst_ind->reset_wq); } err_create_work_queue: if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ kfree(cbp_rst_ind); } err_kzalloc_cbp_rst_ind: if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ free_irq(oem_gpio_to_irq(plat->gpio_flow_ctrl), cbp_flow_ctrl); } err_req_irq_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ oem_gpio_free(plat->gpio_flow_ctrl); } err_req_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ kfree(cbp_flow_ctrl); } err_kzalloc_cbp_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ free_irq(oem_gpio_to_irq(plat->gpio_data_ack), cbp_data_ack); } err_req_irq_data_ack: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ oem_gpio_free(plat->gpio_data_ack); } err_req_data_ack: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ kfree(cbp_data_ack); } err_kzalloc_cbp_data_ack: if((GPIO_OEM_VALID(plat->gpio_sd_select)) && (GPIO_OEM_VALID(plat->gpio_mc3_enable))){ oem_gpio_free(plat->gpio_sd_select); } err_req_sd_sel: if((GPIO_OEM_VALID(plat->gpio_sd_select)) && (GPIO_OEM_VALID(plat->gpio_mc3_enable))){ oem_gpio_free(plat->gpio_mc3_enable); } out: return ret; }
static int cbp_probe(struct platform_device *pdev) { struct cbp_platform_data *plat = NULL; int ret = -1; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; ret = platform_device_add_data(pdev, &cbp_data, sizeof(struct cbp_platform_data)); if (ret < 0) { hwlog_err("%s: add platform_data failed!\n", __func__); goto err_add_data_to_platform_device; } plat = pdev->dev.platform_data; /* must have platform data */ if (!plat) { hwlog_err("%s: no platform data!\n", __func__); ret = -EINVAL; goto err_add_data_to_platform_device; } plat->gpio_data_ack = of_get_named_gpio(np, "via_data_ack", 0); hwlog_info(">>>> %s get via_data_ack gpio %d\n", __func__, plat->gpio_data_ack); if(GPIO_OEM_VALID(plat->gpio_data_ack)){ cbp_data_ack = kzalloc(sizeof(struct cbp_wait_event), GFP_KERNEL); if (!cbp_data_ack){ ret = -ENOMEM; hwlog_err("%s %d kzalloc cbp_data_ack failed \n",__func__, __LINE__); goto err_kzalloc_cbp_data_ack; } init_waitqueue_head(&cbp_data_ack->wait_q); atomic_set(&cbp_data_ack->state, MODEM_ST_UNKNOW); cbp_data_ack->wait_gpio = plat->gpio_data_ack; cbp_data_ack->wait_polar = plat->gpio_data_ack_polar; hwlog_info("cbp_data_ack->wait_gpio=%d\n",cbp_data_ack->wait_gpio); hwlog_info("cbp_data_ack->wait_polar=%d\n",cbp_data_ack->wait_polar); ret = oem_gpio_request(plat->gpio_data_ack, DRIVER_NAME "(data_ack)"); if(ret < 0){ hwlog_err("%s: %d fail to requset data_ack gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_data_ack, ret); goto err_req_data_ack; } oem_gpio_irq_mask(plat->gpio_data_ack); oem_gpio_direction_input_for_irq(plat->gpio_data_ack); //on powerup, there is ack low level to high level jump. oem_gpio_set_irq_type(plat->gpio_data_ack, IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(plat->gpio_data_ack, gpio_irq_via_spi_tx_rx_fifo_empty_ack, IRQF_SHARED | IRQF_TRIGGER_FALLING, DRIVER_NAME "(data_ack)", cbp_data_ack); oem_gpio_irq_unmask(plat->gpio_data_ack); if (ret < 0) { hwlog_err("%s: %d fail to request irq for data_ack!!\n", __func__, __LINE__); goto err_req_irq_data_ack; } plat->cbp_data_ack = cbp_data_ack; plat->data_ack_wait_event = data_ack_wait_event; plat->data_ack_enable =true; } plat->gpio_flow_ctrl = of_get_named_gpio(np, "via_flow_ctrl", 0); hwlog_info(">>>> %s get via_flow_ctrl gpio %d\n", __func__, plat->gpio_flow_ctrl); if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ cbp_flow_ctrl = kzalloc(sizeof(struct cbp_wait_event), GFP_KERNEL); if (!cbp_flow_ctrl){ ret = -ENOMEM; hwlog_err("%s %d kzalloc cbp_flow_ctrl failed \n",__func__, __LINE__); goto err_kzalloc_cbp_flow_ctrl; } init_waitqueue_head(&cbp_flow_ctrl->wait_q); atomic_set(&cbp_flow_ctrl->state, FLOW_CTRL_DISABLE); cbp_flow_ctrl->wait_gpio = plat->gpio_flow_ctrl; cbp_flow_ctrl->wait_polar = plat->gpio_flow_ctrl_polar; hwlog_info("cbp_flow_ctrl->wait_gpio=%d\n",cbp_flow_ctrl->wait_gpio); hwlog_info("cbp_flow_ctrl->wait_polar=%d\n",cbp_flow_ctrl->wait_polar); ret = oem_gpio_request(plat->gpio_flow_ctrl, DRIVER_NAME "(flow_ctrl)"); if(ret < 0){ hwlog_err("%s: %d fail to requset flow_ctrl gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_flow_ctrl, ret); goto err_req_flow_ctrl; } oem_gpio_irq_mask(plat->gpio_flow_ctrl); oem_gpio_direction_input_for_irq(plat->gpio_flow_ctrl); oem_gpio_set_irq_type(plat->gpio_flow_ctrl, IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(plat->gpio_flow_ctrl, gpio_irq_flow_ctrl, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, DRIVER_NAME "(flow_ctrl)", cbp_flow_ctrl); oem_gpio_irq_unmask(plat->gpio_flow_ctrl); if (ret < 0) { hwlog_err("%s: %d fail to request irq for flow_ctrl!!\n", __func__, __LINE__); goto err_req_irq_flow_ctrl; } plat->cbp_flow_ctrl= cbp_flow_ctrl; plat->flow_ctrl_wait_event = flow_ctrl_wait_event; plat->flow_ctrl_enable = true; } plat->gpio_via_requst_to_send = of_get_named_gpio(np, "via_requst_to_send", 0); hwlog_info(">>>> %s get via_requst_to_send gpio %d\n", __func__, plat->gpio_via_requst_to_send); if(GPIO_OEM_VALID(plat->gpio_via_requst_to_send)){ ret = oem_gpio_request(plat->gpio_via_requst_to_send, DRIVER_NAME "(via_requst_to_send)"); if(ret < 0){ hwlog_err("%s: %d fail to requset flow_ctrl gpio %d ret =%d!!\n", __func__, __LINE__, plat->gpio_via_requst_to_send, ret); goto err_req_via_requst_to_send; } oem_gpio_irq_mask(plat->gpio_via_requst_to_send); oem_gpio_direction_input_for_irq(plat->gpio_via_requst_to_send); oem_gpio_set_irq_type(plat->gpio_via_requst_to_send, IRQF_TRIGGER_FALLING); ret = oem_gpio_request_irq(plat->gpio_via_requst_to_send, gpio_irq_via_rts, IRQF_SHARED | IRQF_TRIGGER_RISING, DRIVER_NAME "(via_requst_to_send)", &cbp_data); //api request the fifth argu NOT NULL. oem_gpio_irq_unmask(plat->gpio_via_requst_to_send); if (ret < 0) { hwlog_err("%s: %d fail to request irq for via_requst_to_send!!\n", __func__, __LINE__); goto err_req_irq_via_requst_to_send; } } plat->gpio_rst_ind = of_get_named_gpio(np, "via_reset_ind", 0); hwlog_info(">>>> %s get rst_ind gpio %d\n", __func__, plat->gpio_rst_ind); if(GPIO_OEM_VALID(plat->gpio_rst_ind)){ cbp_data.gpio_rst_ind= plat->gpio_rst_ind; cbp_data.gpio_rst_ind_polar = plat->gpio_rst_ind_polar; atomic_set(&cbp_rst_ind_finished, 0); plat->rst_ind_enable = true; } plat->gpio_ap_wkup_cp= of_get_named_gpio(np, "via_ap_wkup_cp", 0); hwlog_info(">>>> %s get ap_wkup_cp gpio %d\n", __func__, plat->gpio_ap_wkup_cp); plat->gpio_cp_ready= of_get_named_gpio(np, "via_cp_ready", 0); hwlog_info(">>>> %s get cp_ready gpio %d\n", __func__, plat->gpio_cp_ready); plat->gpio_cp_wkup_ap= of_get_named_gpio(np, "via_cp_wkup_ap", 0); hwlog_info(">>>> %s get cp_wkup_ap gpio %d\n", __func__, plat->gpio_cp_wkup_ap); plat->gpio_ap_ready= of_get_named_gpio(np, "via_ap_ready", 0); hwlog_info(">>>> %s get ap_ready gpio %d\n", __func__, plat->gpio_ap_ready); if((GPIO_OEM_VALID(plat->gpio_ap_wkup_cp)) && (GPIO_OEM_VALID(plat->gpio_cp_ready)) && (GPIO_OEM_VALID(plat->gpio_cp_wkup_ap)) && (GPIO_OEM_VALID(plat->gpio_ap_ready))){ spi_tx_handle.gpio_wake = plat->gpio_ap_wkup_cp; spi_tx_handle.gpio_ready = plat->gpio_cp_ready; spi_tx_handle.polar = plat->gpio_sync_polar; ret = asc_tx_register_handle(&spi_tx_handle); if(ret){ hwlog_err("%s %d asc_tx_register_handle failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } ret = asc_tx_add_user(spi_tx_handle.name, &spi_tx_user); if(ret){ hwlog_err("%s %d asc_tx_add_user failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } spi_rx_handle.gpio_wake = plat->gpio_cp_wkup_ap; spi_rx_handle.gpio_ready = plat->gpio_ap_ready; spi_rx_handle.polar = plat->gpio_sync_polar; ret = asc_rx_register_handle(&spi_rx_handle); if(ret){ hwlog_err("%s %d asc_rx_register_handle failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } ret = asc_rx_add_user(spi_rx_handle.name, &spi_rx_user); if(ret){ hwlog_err("%s %d asc_rx_add_user failed.\n",__FUNCTION__,__LINE__); goto err_ipc; } plat->ipc_enable = true; plat->tx_handle = &spi_tx_handle; } ret = plat->cbp_setup(plat); if(ret){ hwlog_err("%s: host %s setup failed!\n", __func__, plat->host_id); goto err_ipc; } cbp_power_kobj = viatel_kobject_add("power"); if (!cbp_power_kobj){ hwlog_err("error viatel_kobject_add!\n"); ret = -ENOMEM; goto err_create_kobj; } hwlog_debug(" cbp initialized on host %s successfully, bus is %s !\n", plat->host_id, plat->bus); return sysfs_create_group(cbp_power_kobj, &g_power_attr_group); err_create_kobj: plat->cbp_destroy(); err_ipc: if(GPIO_OEM_VALID(plat->gpio_via_requst_to_send)){ free_irq(oem_gpio_to_irq(plat->gpio_via_requst_to_send), NULL); } err_req_irq_via_requst_to_send: if(GPIO_OEM_VALID(plat->gpio_via_requst_to_send)){ oem_gpio_free(plat->gpio_via_requst_to_send); } err_req_via_requst_to_send: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ free_irq(oem_gpio_to_irq(plat->gpio_flow_ctrl), cbp_flow_ctrl); } err_req_irq_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ oem_gpio_free(plat->gpio_flow_ctrl); } err_req_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_flow_ctrl)){ kfree(cbp_flow_ctrl); } err_kzalloc_cbp_flow_ctrl: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ free_irq(oem_gpio_to_irq(plat->gpio_data_ack), cbp_data_ack); } err_req_irq_data_ack: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ oem_gpio_free(plat->gpio_data_ack); } err_req_data_ack: if(GPIO_OEM_VALID(plat->gpio_data_ack)){ kfree(cbp_data_ack); } err_kzalloc_cbp_data_ack: err_add_data_to_platform_device: return ret; }
static int modem_boot_probe(struct platform_device *pdev) { int ret = 0; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL); if(!vmdata) { ret = -ENOMEM; hwlog_err("No memory to alloc vmdata"); goto err_create_vmdata; } vmdata->via_pdev = pdev; vmdata->tail = 0; vmdata->head = 0; ret = modem_data_init(vmdata); if(ret < 0) { hwlog_err("Fail to init modem data\n"); goto err_init_modem_data; } ret = platform_device_register(&viacbp82d_3rd_modem_info); if (ret) { hwlog_err( "%s: platform_device_register failed, ret:%d.\n", __func__, ret); goto err_register_platform_device; } ret = sysfs_create_group(&viacbp82d_3rd_modem_info.dev.kobj, &viacbp82d_3rd_modem_node); if (ret) { hwlog_err( "sensor_input_info_init sysfs_create_group error ret =%d", ret); platform_device_unregister(&viacbp82d_3rd_modem_info); goto err_create_sysfs_group; } ret = of_property_read_u32(np, "via_reset_ind_connect_to_codec", &cbp_reset_ind_connect_to_codec); if(ret) { hwlog_err("can't get cbp_reset_ind_connect_to_codec property in viacbp82d_power device node\n"); goto err_get_gpio; } hwlog_info("get cbp_reset_ind_connect_to_codec:%u\n", cbp_reset_ind_connect_to_codec); /* rst_ind is connect to hi6402 codec in fifa */ cbp_rst_ind_gpio = of_get_named_gpio(np, "via_reset_ind", 0);//gpio is 254 hwlog_info("%s get CBP_VIATEL_RST_IND_STR gpio %d\n", __func__, cbp_rst_ind_gpio); if(GPIO_OEM_VALID(cbp_rst_ind_gpio)){ int irq = 0; ret = oem_gpio_request(cbp_rst_ind_gpio, "GPIO_VIATEL_MDM_RST_IND"); if(ret < 0 ) { hwlog_err("%s:%d gpio_request %d fail, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret); } oem_gpio_irq_mask(cbp_rst_ind_gpio); ret = oem_gpio_direction_input_for_irq(cbp_rst_ind_gpio); if(ret < 0 ) { hwlog_err("%s:%d gpio_direction_inout_for_irq %d fail, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret); } irq = oem_gpio_to_irq(cbp_rst_ind_gpio); hwlog_info("%s:%d cbp_rst_ind_gpio:%d irq is:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, irq); oem_gpio_set_irq_type(cbp_rst_ind_gpio, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING); if( cbp_reset_ind_connect_to_codec ) { //connected to hi6402, then use task context api to register irq handler. ret = oem_gpio_request_threaded_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \ IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \ "mdm_reset_ind", vmdata); } else { ret = oem_gpio_request_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \ IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \ "mdm_reset_ind", vmdata); } oem_gpio_irq_unmask(cbp_rst_ind_gpio); if (ret < 0) { hwlog_err("%s:%d fail to request mdm_rst_ind %d irq, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret); } hwlog_info("%s:%d gpio via_reset_ind %d init successfully\n", __func__, __LINE__, cbp_rst_ind_gpio); modem_register_notifier(&vmdata->rst_ntf); } else { hwlog_err("%s:%d via_reset_ind is invalid gpio\n", __func__, __LINE__); goto err_get_gpio; } cbp_pwr_en_gpio = of_get_named_gpio(np, "via_pwr_en", 0); hwlog_info("%s get CBP_VIATEL_PWR_EN_STR gpio %d\n", __func__, cbp_pwr_en_gpio); if(GPIO_OEM_VALID(cbp_pwr_en_gpio)){ ret = oem_gpio_request(cbp_pwr_en_gpio, "GPIO_VIATEL_MDM_PWR_EN"); if (0 > ret) { hwlog_err("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__); } oem_gpio_direction_output(cbp_pwr_en_gpio, 0); } else { goto err_get_gpio; } cbp_rst_gpio = of_get_named_gpio(np, "via_rst_mdm", 0); hwlog_info("%s get CBP_VIATEL_CBP_RST_STR gpio %d\n", __func__, cbp_rst_gpio); if(GPIO_OEM_VALID(cbp_rst_gpio)){ ret = oem_gpio_request(cbp_rst_gpio, "GPIO_VIATEL_MDM_RST"); if (0 > ret) { hwlog_err("%s: gpio request GPIO_VIATEL_MDM_RST failed", __FUNCTION__); } oem_gpio_direction_output(cbp_rst_gpio, 0); } else { goto err_get_gpio; } #if 0 //don't delete. there is no gpio for sim switch cbp_sim_switch_gpio = of_get_named_gpio(np, "via_sim_switch", 0); hwlog_info("%s get CBP_VIATEL_CBP_SIM_SWITCH gpio %d\n", __func__, cbp_sim_switch_gpio); if(GPIO_OEM_VALID(cbp_sim_switch_gpio)){ ret = oem_gpio_request(cbp_sim_switch_gpio, "GPIO_VIATEL_MDM_SIM_SWITCH"); if(0 > ret){ hwlog_err("%s: gpio request GPIO_VIATEL_MDM_SIM_SWITCH failed", __FUNCTION__); } oem_gpio_direction_output(cbp_sim_switch_gpio, 0); } else { goto err_get_gpio; } #endif /*add gpio function to make cp ramdump*/ cbp_backup_gpio = of_get_named_gpio(np, "via_backup", 0); hwlog_info("%s get CBP_VIATEL_CBP_BACKUP gpio %d\n", __func__, cbp_backup_gpio); if(GPIO_OEM_VALID(cbp_backup_gpio)){ ret = oem_gpio_request(cbp_backup_gpio, "gpio_cbp_crash"); if(0 > ret){ hwlog_err("%s: gpio request gpio_cbp_crash failed", __FUNCTION__); } oem_gpio_direction_output(cbp_backup_gpio, 0); setup_timer(&cbp_backup_timer, cbp_backup_check_ramdump_timer, (unsigned long)NULL); } else { goto err_get_gpio; } return 0; err_get_gpio: sysfs_remove_group(&viacbp82d_3rd_modem_info.dev.kobj, &viacbp82d_3rd_modem_node); err_create_sysfs_group: platform_device_unregister(&viacbp82d_3rd_modem_info); err_register_platform_device: err_init_modem_data: kfree(vmdata); vmdata = NULL; err_create_vmdata: return ret; }