static int hsic_open(int id) { int err = 0; unsigned long flags; struct diag_hsic_info *ch = NULL; if (id < 0 || id >= NUM_HSIC_DEV) { pr_err("diag: Invalid index %d in %s\n", id, __func__); return -EINVAL; } ch = &diag_hsic[id]; if (!ch->enabled) return -ENODEV; if (ch->opened) { pr_debug("diag: HSIC channel %d is already opened\n", ch->id); return -ENODEV; } err = diag_bridge_open(ch->id, &diag_hsic_ops[ch->id]); if (err) { pr_err("diag: Unable to open HSIC channel %d, err: %d", ch->id, err); return err; } spin_lock_irqsave(&ch->lock, flags); ch->opened = 1; spin_unlock_irqrestore(&ch->lock, flags); diagmem_init(driver, ch->mempool); /* Notify the bridge that the channel is open */ diag_remote_dev_open(ch->dev_id); queue_work(ch->hsic_wq, &(ch->read_work)); return 0; }
/* diagfwd_cancel_hsic is called to cancel outstanding read/writes */ int diagfwd_cancel_hsic(void) { int err, i; /* Cancel it for all active HSIC bridges */ for (i = 0; i < MAX_HSIC_CH; i++) { if (!diag_bridge[i].enabled) continue; mutex_lock(&diag_bridge[i].bridge_mutex); if (diag_hsic[i].hsic_device_enabled) { if (diag_hsic[i].hsic_device_opened) { diag_hsic[i].hsic_ch = 0; diag_hsic[i].hsic_device_opened = 0; diag_bridge_close(i); hsic_diag_bridge_ops[i].ctxt = (void *)(i); err = diag_bridge_open(i, &hsic_diag_bridge_ops[i]); if (err) { pr_err("diag: HSIC %d channel open error: %d\n", i, err); } else { pr_debug("diag: opened HSIC channel: %d\n", i); diag_hsic[i].hsic_device_opened = 1; diag_hsic[i].hsic_ch = 1; } } } mutex_unlock(&diag_bridge[i].bridge_mutex); } return 0; }
int diagfwd_reset_hsic() { int i; int err = 0; int b_index = 0; for (i = 0; i < MAX_HSIC_DATA_CH; i++) { if (!diag_hsic[i].hsic_device_enabled) continue; b_index = hsic_data_bridge_map[i]; mutex_lock(&diag_bridge[b_index].bridge_mutex); diag_hsic[i].hsic_ch = 0; diag_hsic[i].hsic_device_opened = 0; diag_hsic[i].hsic_data_requested = 0; diag_bridge_close(hsic_data_bridge_map[i]); err = diag_bridge_open(hsic_data_bridge_map[i], &hsic_diag_bridge_ops[i]); if (err) { pr_err("diag: HSIC %d channel open error: %d\n", i, err); } else { pr_debug("diag: opened HSIC channel: %d\n", i); diag_hsic[i].hsic_device_opened = 1; diag_hsic[i].hsic_ch = 1; diag_hsic[i].hsic_data_requested = 1; } mutex_unlock(&diag_bridge[b_index].bridge_mutex); } return err; }
int diagfwd_connect_bridge(int process_cable) { int err; DIAGFWD_INFO("DIAG in %s\n", __func__); if (process_cable) { err = usb_diag_alloc_req(driver->mdm_ch, N_MDM_WRITE, N_MDM_READ); if (err) pr_err("diag: unable to alloc USB req on mdm" " ch err:%d\n", err); driver->qxdmusb_drop = 0; driver->usb_mdm_connected = 1; } if (driver->hsic_device_enabled) { driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; } else if (driver->diag_smux_enabled) { driver->in_busy_smux = 0; diagfwd_connect_smux(); return 0; } if (driver->hsic_device_enabled) { if (!driver->hsic_device_opened) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; } } else { pr_debug("diag: HSIC channel already open\n"); } if (driver->hsic_device_opened) driver->hsic_ch = 1; if (driver->logging_mode == USB_MODE) queue_work(driver->diag_bridge_wq, &driver->diag_read_mdm_work); queue_work(driver->diag_bridge_wq, &driver->diag_read_hsic_work); } else { pr_info("diag: HSIC channel not yet enabled\n"); } return 0; }
void connect_bridge(int process_cable, uint8_t index) { int err; mutex_lock(&diag_bridge[index].bridge_mutex); /* If the usb cable is being connected */ if (process_cable) { err = usb_diag_alloc_req(diag_bridge[index].ch, N_MDM_WRITE, N_MDM_READ); if (err) pr_err("diag: unable to alloc USB req for ch %d err:%d\n", index, err); diag_bridge[index].usb_connected = 1; } if (index == SMUX) { if (driver->diag_smux_enabled) { driver->in_busy_smux = 0; diagfwd_connect_smux(); } } else { if (index >= MAX_HSIC_CH) { pr_err("diag: Invalid hsic channel index %d in %s\n", index, __func__); mutex_unlock(&diag_bridge[index].bridge_mutex); return; } if (diag_hsic[index].hsic_device_enabled && (driver->logging_mode != MEMORY_DEVICE_MODE || diag_hsic[index].hsic_data_requested)) { diag_hsic[index].in_busy_hsic_read_on_device = 0; diag_hsic[index].in_busy_hsic_write = 0; /* If the HSIC (diag_bridge) platform * device is not open */ if (!diag_hsic[index].hsic_device_opened) { hsic_diag_bridge_ops[index].ctxt = (void *)(int)(index); err = diag_bridge_open(index, &hsic_diag_bridge_ops[index]); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened HSIC channel\n"); diag_hsic[index].hsic_device_opened = 1; } } else { pr_debug("diag: HSIC channel already open\n"); } /* * Turn on communication over usb mdm and HSIC, * if the HSIC device driver is enabled * and opened */ if (diag_hsic[index].hsic_device_opened) { diag_hsic[index].hsic_ch = 1; /* Poll USB mdm channel to check for data */ if (driver->logging_mode == USB_MODE) queue_work(diag_bridge[index].wq, &diag_bridge[index].diag_read_work); /* Poll HSIC channel to check for data */ queue_work(diag_bridge[index].wq, &diag_hsic[index].diag_read_hsic_work); } } } mutex_unlock(&diag_bridge[index].bridge_mutex); }
/* diagfwd_connect_hsic is called when the USB mdm channel is connected */ int diagfwd_connect_hsic(int process_cable) { int err; pr_debug("DIAG in %s\n", __func__); /* If the usb cable is being connected */ if (process_cable) { err = usb_diag_alloc_req(driver->mdm_ch, N_MDM_WRITE, N_MDM_READ); if (err) pr_err("DIAG: unable to alloc USB req on mdm" " ch err:%d\n", err); driver->usb_mdm_connected = 1; } if (driver->hsic_device_enabled) { driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; } /* If the hsic (diag_bridge) platform device is not open */ if (driver->hsic_device_enabled) { if (!driver->hsic_device_opened) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("DIAG: HSIC channel open error: %d\n", err); } else { pr_debug("DIAG: opened HSIC channel\n"); driver->hsic_device_opened = 1; } } else { pr_debug("DIAG: HSIC channel already open\n"); } /* * Turn on communication over usb mdm and hsic, if the hsic * device driver is enabled and opened */ if (driver->hsic_device_opened) driver->hsic_ch = 1; /* Poll USB mdm channel to check for data */ if (driver->logging_mode == USB_MODE) queue_work(driver->diag_hsic_wq, &driver->diag_read_mdm_work); /* Poll HSIC channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_hsic_work); } else { /* The hsic device driver has not yet been enabled */ pr_info("DIAG: HSIC channel not yet enabled\n"); } return 0; }
static int diag_hsic_probe_dci(int pdev_id) { int err = 0; int index = hsic_map[pdev_id].struct_idx; int b_index = hsic_map[pdev_id].bridge_idx; if (!diag_bridge_dci || !diag_hsic_dci) return -ENOMEM; mutex_lock(&diag_bridge_dci[index].bridge_mutex); if (!diag_hsic_dci[index].hsic_inited) { diag_hsic_dci[index].data_buf = NULL; if (diag_hsic_dci[index].data == NULL) diag_hsic_dci[index].data = kzalloc(DIAG_MDM_BUF_SIZE, GFP_KERNEL); if (!diag_hsic_dci[index].data) { mutex_unlock(&diag_bridge_dci[index].bridge_mutex); return -ENOMEM; } diag_hsic_dci[index].id = index; diagmem_init(driver, POOL_TYPE_MDM_DCI + index); diagmem_init(driver, POOL_TYPE_MDM_DCI_WRITE + index); INIT_WORK(&(diag_hsic_dci[index].diag_read_hsic_work), diag_read_hsic_dci_work_fn); INIT_WORK(&(diag_hsic_dci[index].diag_process_hsic_work), diag_process_hsic_work_fn); diag_hsic_dci[index].hsic_inited = 1; } if (!diag_hsic_dci[index].hsic_device_opened) { hsic_diag_dci_bridge_ops[index].ctxt = (void *)(int)(index); err = diag_bridge_open(b_index, &hsic_diag_dci_bridge_ops[index]); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened DCI HSIC channel at index %d\n", index); diag_hsic_dci[index].hsic_device_opened = 1; diag_hsic_dci[index].hsic_ch = 1; queue_work(diag_bridge_dci[index].wq, &diag_hsic_dci[index].diag_read_hsic_work); diag_send_dci_log_mask_remote(index + 1); diag_send_dci_event_mask_remote(index + 1); } } else { pr_debug("diag: HSIC DCI channel already open\n"); queue_work(diag_bridge_dci[index].wq, &diag_hsic_dci[index].diag_read_hsic_work); diag_send_dci_log_mask_remote(index + 1); diag_send_dci_event_mask_remote(index + 1); } diag_hsic_dci[index].hsic_device_enabled = 1; mutex_unlock(&diag_bridge_dci[index].bridge_mutex); return err; }
void connect_bridge(int process_cable, int index) { int err; mutex_lock(&diag_bridge[index].bridge_mutex); if (process_cable) { err = usb_diag_alloc_req(diag_bridge[index].ch, N_MDM_WRITE, N_MDM_READ); if (err) pr_err("diag: unable to alloc USB req on mdm ch err:%d\n", err); diag_bridge[index].usb_connected = 1; driver->qxdmusb_drop = 0; } if (index == SMUX && driver->diag_smux_enabled) { driver->in_busy_smux = 0; diagfwd_connect_smux(); } else if (index == HSIC && driver->hsic_device_enabled) { driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (!driver->hsic_device_opened) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; } } else { pr_debug("diag: HSIC channel already open\n"); } if (driver->hsic_device_opened) { driver->hsic_ch = 1; if (driver->logging_mode == USB_MODE) queue_work(diag_bridge[HSIC].wq, &diag_bridge[HSIC].diag_read_work); queue_work(diag_bridge[HSIC].wq, &driver->diag_read_hsic_work); } } mutex_unlock(&diag_bridge[index].bridge_mutex); }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { if (driver->buf_in_hsic == NULL) driver->buf_in_hsic = kzalloc(IN_BUF_SIZE, GFP_KERNEL); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and hsic needs to be turned on. */ if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { /* The hsic (diag_bridge) platform device driver is enabled */ err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_write_on_device = 0; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; driver->in_busy_hsic_read = 0; if (driver->usb_mdm_connected) { /* Poll USB mdm channel to check for data */ queue_work(driver->diag_bridge_wq, &driver->diag_read_mdm_work); } /* Poll HSIC channel to check for data */ queue_work(driver->diag_bridge_wq, &driver->diag_read_hsic_work); } return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err; if (!driver->hsic_device_enabled) { err = diag_hsic_enable(); if (err) { pr_err("DIAG could not enable HSIC, err: %d\n", err); return err; } } /* The hsic (diag_bridge) platform device driver is enabled */ err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("DIAG could not open HSIC channel, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("DIAG opened HSIC channel\n"); driver->hsic_device_opened = 1; /* * The probe function was called after the usb was connected * on the legacy channel. Communication over usb mdm and hsic * needs to be turned on. */ if (driver->usb_connected) { driver->hsic_ch = 1; driver->in_busy_hsic_write_on_mdm = 0; driver->in_busy_hsic_read_on_mdm = 0; driver->in_busy_hsic_write = 0; driver->in_busy_hsic_read = 0; /* Poll USB mdm channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_mdm_work); /* Poll HSIC channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_hsic_work); } return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; DIAGFWD_INFO("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (driver->usb_mdm_connected) { queue_work(driver->diag_bridge_wq, &driver->diag_read_mdm_work); } queue_work(driver->diag_bridge_wq, &driver->diag_read_hsic_work); } return err; }
int diagfwd_cancel_hsic(void) { int err; if (driver->hsic_device_enabled) { if (driver->hsic_device_opened) { driver->hsic_ch = 0; driver->hsic_device_opened = 0; diag_bridge_close(); err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; } } } return 0; }
/* diagfwd_cancel_hsic is called to cancel outstanding read/writes */ int diagfwd_cancel_hsic(void) { int err; mutex_lock(&diag_bridge[HSIC].bridge_mutex); if (driver->hsic_device_enabled) { if (driver->hsic_device_opened) { driver->hsic_ch = 0; driver->hsic_device_opened = 0; diag_bridge_close(0); err = diag_bridge_open(0, &hsic_diag_bridge_ops); if (err) { pr_err("diag: HSIC channel open error: %d\n", err); } else { pr_debug("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; } } } mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return 0; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; /* pdev->Id will indicate which HSIC is working. 0 stands for HSIC * or CP1 1 indicates HS-USB or CP2 */ pr_debug("diag: in %s, ch = %d\n", __func__, pdev->id); mutex_lock(&diag_bridge[pdev->id].bridge_mutex); if (!diag_hsic[pdev->id].hsic_inited) { spin_lock_init(&diag_hsic[pdev->id].hsic_spinlock); diag_hsic[pdev->id].num_hsic_buf_tbl_entries = 0; if (diag_hsic[pdev->id].hsic_buf_tbl == NULL) diag_hsic[pdev->id].hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (diag_hsic[pdev->id].hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return -ENOMEM; } diag_hsic[pdev->id].id = pdev->id; diag_hsic[pdev->id].count_hsic_pool = 0; diag_hsic[pdev->id].count_hsic_write_pool = 0; diag_hsic[pdev->id].itemsize_hsic = READ_HSIC_BUF_SIZE; diag_hsic[pdev->id].poolsize_hsic = N_MDM_WRITE; diag_hsic[pdev->id].itemsize_hsic_write = sizeof(struct diag_request); diag_hsic[pdev->id].poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(pdev->id); INIT_WORK(&(diag_hsic[pdev->id].diag_read_hsic_work), diag_read_hsic_work_fn); diag_hsic[pdev->id].hsic_inited = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and HSIC needs to be turned on. */ if (diag_bridge[pdev->id].usb_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { if (diag_hsic[pdev->id].hsic_device_opened) { /* should not happen. close it before re-opening */ pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(pdev->id); } hsic_diag_bridge_ops[pdev->id].ctxt = (void *)(pdev->id); err = diag_bridge_open(pdev->id, &hsic_diag_bridge_ops[pdev->id]); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); diag_hsic[pdev->id].hsic_device_opened = 0; mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return err; } pr_info("diag: opened HSIC bridge, ch = %d\n", pdev->id); diag_hsic[pdev->id].hsic_device_opened = 1; diag_hsic[pdev->id].hsic_ch = 1; diag_hsic[pdev->id].in_busy_hsic_read_on_device = 0; diag_hsic[pdev->id].in_busy_hsic_write = 0; if (diag_bridge[pdev->id].usb_connected) { /* Poll USB mdm channel to check for data */ queue_work(diag_bridge[pdev->id].wq, &diag_bridge[pdev->id].diag_read_work); } /* Poll HSIC channel to check for data */ queue_work(diag_bridge[pdev->id].wq, &diag_hsic[pdev->id].diag_read_hsic_work); } /* The HSIC (diag_bridge) platform device driver is enabled */ diag_hsic[pdev->id].hsic_device_enabled = 1; mutex_unlock(&diag_bridge[pdev->id].bridge_mutex); return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); if (!driver->hsic_device_enabled) { driver->read_len_mdm = 0; if (driver->usb_buf_mdm_out == NULL) driver->usb_buf_mdm_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL); if (driver->usb_buf_mdm_out == NULL) goto err; if (driver->usb_read_mdm_ptr == NULL) driver->usb_read_mdm_ptr = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_read_mdm_ptr == NULL) goto err; #ifdef CONFIG_DIAG_OVER_USB INIT_WORK(&(driver->diag_read_mdm_work), diag_read_mdm_work_fn); #endif diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_device_enabled = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on. Communication over usb * mdm and hsic needs to be turned on. */ if (driver->usb_mdm_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { /* The hsic (diag_bridge) platform device driver is enabled */ err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (driver->usb_mdm_connected) { /* Poll USB mdm channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_mdm_work); } /* Poll HSIC channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_hsic_work); } return err; err: pr_err("DIAG could not initialize buf for HSIC\n"); kfree(driver->usb_buf_mdm_out); kfree(driver->usb_read_mdm_ptr); if (driver->diag_hsic_wq) destroy_workqueue(driver->diag_hsic_wq); return -ENOMEM; }
static int diag_hsic_probe_data(int pdev_id) { int err = 0; int index = hsic_map[pdev_id].struct_idx; int b_index = hsic_map[pdev_id].bridge_idx; mutex_lock(&diag_bridge[index].bridge_mutex); if (!diag_hsic[index].hsic_inited) { spin_lock_init(&diag_hsic[index].hsic_spinlock); diag_hsic[index].num_hsic_buf_tbl_entries = 0; if (diag_hsic[index].hsic_buf_tbl == NULL) diag_hsic[index].hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (diag_hsic[index].hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[index].bridge_mutex); return -ENOMEM; } diag_hsic[index].id = index; diag_hsic[index].count_hsic_pool = 0; diag_hsic[index].count_hsic_write_pool = 0; diag_hsic[index].itemsize_hsic = READ_HSIC_BUF_SIZE; diag_hsic[index].poolsize_hsic = N_MDM_WRITE; diag_hsic[index].itemsize_hsic_write = sizeof(struct diag_request); diag_hsic[index].poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(index); INIT_WORK(&(diag_hsic[index].diag_read_hsic_work), diag_read_hsic_work_fn); diag_hsic[index].hsic_data_requested = (driver->logging_mode == MEMORY_DEVICE_MODE) ? 0 : 1; diag_hsic[index].hsic_inited = 1; } /* * The probe function was called after the usb was connected * on the legacy channel OR ODL is turned on and hsic data is * requested. Communication over usb mdm and HSIC needs to be * turned on. */ if ((diag_bridge[index].usb_connected && (driver->logging_mode != MEMORY_DEVICE_MODE)) || ((driver->logging_mode == MEMORY_DEVICE_MODE) && diag_hsic[index].hsic_data_requested)) { if (diag_hsic[index].hsic_device_opened) { /* should not happen. close it before re-opening */ pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(hsic_data_bridge_map[index]); } hsic_diag_bridge_ops[index].ctxt = (void *)(index); err = diag_bridge_open(b_index, &hsic_diag_bridge_ops[index]); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); diag_hsic[index].hsic_device_opened = 0; mutex_unlock(&diag_bridge[index].bridge_mutex); return err; } pr_info("diag: opened HSIC bridge, ch = %d\n", index); diag_hsic[index].hsic_device_opened = 1; diag_hsic[index].hsic_ch = 1; diag_hsic[index].in_busy_hsic_read_on_device = 0; diag_hsic[index].in_busy_hsic_write = 0; if (diag_bridge[index].usb_connected) { /* Poll USB mdm channel to check for data */ queue_work(diag_bridge[index].wq, &diag_bridge[index].diag_read_work); } /* Poll HSIC channel to check for data */ queue_work(diag_bridge[index].wq, &diag_hsic[index].diag_read_hsic_work); } /* The HSIC (diag_bridge) platform device driver is enabled */ diag_hsic[index].hsic_device_enabled = 1; mutex_unlock(&diag_bridge[index].bridge_mutex); return err; }
static int diag_hsic_probe(struct platform_device *pdev) { int err = 0; pr_debug("diag: in %s\n", __func__); mutex_lock(&diag_bridge[HSIC].bridge_mutex); if (!driver->hsic_inited) { spin_lock_init(&driver->hsic_spinlock); driver->num_hsic_buf_tbl_entries = 0; if (driver->hsic_buf_tbl == NULL) driver->hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES * sizeof(struct diag_write_device), GFP_KERNEL); if (driver->hsic_buf_tbl == NULL) { mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return -ENOMEM; } driver->count_hsic_pool = 0; driver->count_hsic_write_pool = 0; driver->itemsize_hsic = READ_HSIC_BUF_SIZE; driver->poolsize_hsic = N_MDM_WRITE; driver->itemsize_hsic_write = sizeof(struct diag_request); driver->poolsize_hsic_write = N_MDM_WRITE; diagmem_hsic_init(driver); INIT_WORK(&(driver->diag_read_hsic_work), diag_read_hsic_work_fn); driver->hsic_inited = 1; } if (diag_bridge[HSIC].usb_connected || (driver->logging_mode == MEMORY_DEVICE_MODE)) { if (driver->hsic_device_opened) { pr_warn("diag: HSIC channel already opened in probe\n"); diag_bridge_close(); } err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("diag: could not open HSIC, err: %d\n", err); driver->hsic_device_opened = 0; mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return err; } pr_info("diag: opened HSIC channel\n"); driver->hsic_device_opened = 1; driver->hsic_ch = 1; driver->in_busy_hsic_read_on_device = 0; driver->in_busy_hsic_write = 0; if (diag_bridge[HSIC].usb_connected) { queue_work(diag_bridge[HSIC].wq, &diag_bridge[HSIC].diag_read_work); } queue_work(diag_bridge[HSIC].wq, &driver->diag_read_hsic_work); } driver->hsic_device_enabled = 1; mutex_unlock(&diag_bridge[HSIC].bridge_mutex); return err; }
/* diagfwd_connect_hsic is called when the USB mdm channel is connected */ int diagfwd_connect_hsic(unsigned int mode) { int err; pr_info("DIAG in %s\n", __func__); if (mode == WRITE_TO_USB) { err = usb_diag_alloc_req(driver->mdm_ch, N_MDM_WRITE, N_MDM_READ); if (err) pr_err("DIAG: unable to alloc req on mdm ch err:%d\n", err); driver->usb_mdm_connected = 1; } else { pr_info("silent log %s\n", __func__); driver->usb_mdm_connected = 0; } driver->in_busy_hsic_write_on_mdm = 0; driver->in_busy_hsic_read_on_mdm = 0; driver->in_busy_hsic_write = 0; driver->in_busy_hsic_read = 0; // zero_pky.patch by jagadish /* zero cfg packet variables are set to 0 again here, just in case to prevent any looping */ driver->zero_cfg_mode = 0; driver->zero_cfg_packet_lens_index = 0; driver->zero_cfg_index =0; /* If the hsic (diag_bridge) platform device is not open */ if (driver->hsic_device_enabled) { if (!driver->hsic_device_opened) { err = diag_bridge_open(&hsic_diag_bridge_ops); if (err) { pr_err("DIAG: HSIC channel open error: %d\n", err); } else { pr_debug("DIAG: opened HSIC channel\n"); driver->hsic_device_opened = 1; } } else { pr_debug("DIAG: HSIC channel already open\n"); } /* * Turn on communication over usb mdm and hsic, if the hsic * device driver is enabled and opened */ if (driver->hsic_device_opened) driver->hsic_ch = 1; if (mode == WRITE_TO_USB) { /* Poll USB mdm channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_mdm_work); } /* Poll HSIC channel to check for data */ queue_work(driver->diag_hsic_wq, &driver->diag_read_hsic_work); } else { /* The hsic device driver has not yet been enabled */ pr_info("DIAG: HSIC channel not yet enabled\n"); } return 0; }