コード例 #1
0
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;
}
コード例 #2
0
static int diagfwd_smux_probe(struct platform_device *pdev)
{
	int ret = 0;

	pr_info("diag: SMUX probe called\n");
	driver->lcid = LCID_INVALID;
	driver->diag_smux_enabled = 1;
	if (driver->buf_in_smux == NULL) {
		driver->buf_in_smux = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_smux == NULL)
			goto err;
	}
	/* Only required for Local loopback test
	 * ret = msm_smux_set_ch_option(LCID_VALID,
				 SMUX_CH_OPTION_LOCAL_LOOPBACK, 0);
	 * if (ret)
	 *	pr_err("diag: error setting SMUX ch option, r = %d\n", ret);
	 */
	if (driver->write_ptr_mdm == NULL)
		driver->write_ptr_mdm = kzalloc(sizeof(struct diag_request),
								 GFP_KERNEL);
	if (driver->write_ptr_mdm == NULL)
		goto err;
	ret = diagfwd_connect_smux();
	return ret;

err:
	pr_err("diag: Could not initialize SMUX buffer\n");
	kfree(driver->buf_in_smux);
	return ret;
}
コード例 #3
0
ファイル: diagfwd_bridge.c プロジェクト: FrozenCow/FIRE-ICE
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);
}
コード例 #4
0
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);
}
コード例 #5
0
/* diagfwd_connect_bridge is called when the USB mdm channel is connected */
int diagfwd_connect_bridge(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_write_on_device = 0;
        driver->in_busy_hsic_read_on_device = 0;
        driver->in_busy_hsic_write = 0;
        driver->in_busy_hsic_read = 0;
    } else if (driver->diag_smux_enabled) {
        driver->in_busy_smux = 0;
        diagfwd_connect_smux();
        return 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_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);
    } else {
        /* The hsic device driver has not yet been enabled */
        pr_info("diag: HSIC channel not yet enabled\n");
    }

    return 0;
}