/* 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; }
static int diag_hsic_close(void) { // zero_pky.patch by jagadish /* if zero cfg mode is enabled, dont close the bridge */ if (driver->zero_cfg_mode) { pr_info("%s sending zero_cfg packet start\n", __func__); driver->in_busy_hsic_write = 0; driver->in_busy_hsic_read = 0; queue_work(driver->diag_hsic_wq, &driver->diag_zero_cfg_hsic_work); return 0; } if (driver->hsic_device_enabled) { driver->hsic_ch = 0; if (driver->hsic_device_opened) { driver->hsic_device_opened = 0; // zero_pky.patch by jagadish driver->zero_cfg_packet_lens_index = 0; driver->zero_cfg_index =0; diag_bridge_close(); } pr_debug("DIAG in %s: closed successfully\n", __func__); } else { pr_debug("DIAG in %s: already closed\n", __func__); } return 0; }
static int hsic_close(int id) { 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 closed\n", ch->id); return -ENODEV; } spin_lock_irqsave(&ch->lock, flags); ch->opened = 0; spin_unlock_irqrestore(&ch->lock, flags); diag_bridge_close(ch->id); diagmem_exit(driver, ch->mempool); diag_remote_dev_close(ch->dev_id); 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; }
static int diag_hsic_close(void) { if (driver->hsic_device_enabled) { driver->hsic_ch = 0; if (driver->hsic_device_opened) { driver->hsic_device_opened = 0; diag_bridge_close(); } pr_debug("DIAG in %s: closed successfully\n", __func__); } else { pr_debug("DIAG in %s: already closed\n", __func__); } return 0; }
void diag_hsic_close(void) { if (driver->hsic_device_enabled) { driver->hsic_ch = 0; if (driver->hsic_device_opened) { driver->hsic_device_opened = 0; diag_bridge_close(); pr_debug("diag: %s: closed successfully\n", __func__); } else { pr_debug("diag: %s: already closed\n", __func__); } } else { pr_debug("diag: %s: HSIC device already removed\n", __func__); } }
void diag_hsic_close(int ch_id) { if (diag_hsic[ch_id].hsic_device_enabled) { diag_hsic[ch_id].hsic_ch = 0; if (diag_hsic[ch_id].hsic_device_opened) { diag_hsic[ch_id].hsic_device_opened = 0; diag_bridge_close(ch_id); pr_debug("diag: %s: closed successfully ch %d\n", __func__, ch_id); } else { pr_debug("diag: %s: already closed ch %d\n", __func__, ch_id); } } else { pr_debug("diag: %s: HSIC device already removed ch %d\n", __func__, ch_id); } }
void diag_hsic_dci_close(int ch_id) { if (diag_hsic_dci[ch_id].hsic_device_enabled) { diag_hsic_dci[ch_id].hsic_ch = 0; if (diag_hsic_dci[ch_id].hsic_device_opened) { diag_hsic_dci[ch_id].hsic_device_opened = 0; diag_bridge_close(hsic_dci_bridge_map[ch_id]); dci_ops_tbl[DCI_MDM_PROC].peripheral_status = 0; diag_dci_notify_client(DIAG_CON_APSS, DIAG_STATUS_CLOSED, DCI_MDM_PROC); pr_debug("diag: %s: closed successfully ch %d\n", __func__, ch_id); } else { pr_debug("diag: %s: already closed ch %d\n", __func__, ch_id); } } else { pr_debug("diag: %s: HSIC device already removed ch %d\n", __func__, ch_id); } }
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_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; }
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; }