static int cpcap_usb_connected_remove(struct platform_device *pdev)
{
	struct cpcap_usb_connected_data *data = platform_get_drvdata(pdev);

	mdm_ctrl_set_usb_ipc(false);

	/* Configure CPCAP-AP20 USB Mux to CPCAP */
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x0);
	NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin);
	NvOdmGpioClose(data->h_gpio);

	if((data->accy == CPCAP_ACCY_USB) || (data->accy == CPCAP_ACCY_FACTORY))
		android_usb_set_connected(0, data->accy);

#ifdef CONFIG_USB_TEGRA_OTG
	tegra_otg_set_mode(2);
#endif

	kfree(data);

        return 0;
}
Esempio n. 2
0
static int cpcap_usb_connected_remove(struct platform_device *pdev)
{
/*	struct cpcap_usb_connected_data *data = platform_get_drvdata(pdev);*/
	struct cpcap_accy_platform_data *pdata = pdev->dev.platform_data;

	int nr_gpio;
#ifdef CONFIG_MDM_CTRL
	mdm_ctrl_set_usb_ipc(false);
#endif
#if 0
	/* Configure CPCAP-AP20 USB Mux to CPCAP */
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x0);
	printk(KERN_INFO "pICS_%s: NvOdmGpioSetState (data->h_gpio, data->h_pin, 0x0)\n",__func__);
	NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin);
	printk(KERN_INFO "pICS_%s: NvOdmGpioReleasePinHandle(data->h_gpio, data->h_pin)\n",__func__);
	NvOdmGpioClose(data->h_gpio);
	printk(KERN_INFO "pICS_%s: NvOdmGpioClose(data->h_gpio)\n",__func__);
#endif
	
	nr_gpio = 174;
	gpio_set_value(nr_gpio, 0);

	gpio_free(nr_gpio);
/*	gpio_data[nr_gpio].val = false;
	gpio_data[nr_gpio].alloc = false;*/
	
	tegra_gpio_disable(nr_gpio);
#ifdef CONFIG_USB_MOT_ANDROID
	if((pdata->accy == CPCAP_ACCY_USB) || (pdata->accy == CPCAP_ACCY_FACTORY))
		android_usb_set_connected(0, pdata->accy);
#endif

	tegra_otg_set_mode(2);

/*	kfree(data);*/

        return 0;
}
static int cpcap_usb_connected_probe(struct platform_device *pdev)
{
	struct cpcap_usb_connected_data *data;
	struct cpcap_accy_platform_data *pdata = pdev->dev.platform_data;

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if(!data)
		return -ENOMEM;

	data->accy = pdata->accy;

	/* Configure CPCAP-AP20 USB Mux to AP20 */
	data->port = NVODM_PORT('v');
	data->pin = 6;
	data->h_gpio = NvOdmGpioOpen();
	data->h_pin = NvOdmGpioAcquirePinHandle(data->h_gpio, data->port, data->pin);
	NvOdmGpioConfig(data->h_gpio, data->h_pin, NvOdmGpioPinMode_Output);
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x1);

	platform_set_drvdata(pdev, data);

	/* when the phone is the host do not start the gadget driver */
	if((data->accy == CPCAP_ACCY_USB) || (data->accy == CPCAP_ACCY_FACTORY)) {
#ifdef CONFIG_USB_TEGRA_OTG
		tegra_otg_set_mode(0);
#endif
		android_usb_set_connected(1, data->accy);
	}
	if(data->accy == CPCAP_ACCY_USB_DEVICE) {
#ifdef CONFIG_USB_TEGRA_OTG
		tegra_otg_set_mode(1);
#endif
	}
	mdm_ctrl_set_usb_ipc(true);

	return 0;
}
Esempio n. 4
0
static int cpcap_usb_connected_probe(struct platform_device *pdev)
{
/*	struct cpcap_usb_connected_data *data;*/
	struct cpcap_accy_platform_data *pdata = pdev->dev.platform_data;

	int nr_gpio;
	int ret;
	static int count_f7 = 0;

#if 0
	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if(!data)
		return -ENOMEM;

	data->accy = pdata->accy;



	
	/* Configure CPCAP-AP20 USB Mux to AP20 */
	data->port = NVODM_PORT('v'); 
	printk(KERN_INFO "pICS_%s: data->port = NVODM_PORT('v') = %lu\n",__func__, data->port);
	data->pin = 6;
	data->h_gpio = NvOdmGpioOpen(); 
	printk(KERN_INFO "pICS_%s: data->h_gpio = NvOdmGpioOpen()\n",__func__);
	data->h_pin = NvOdmGpioAcquirePinHandle(data->h_gpio, data->port, data->pin);
	printk(KERN_INFO "pICS_%s: data->h_pin = NvOdmGpioAcquirePinHandle(data->h_gpio, data->port, data->pin)\n",__func__);
	NvOdmGpioConfig(data->h_gpio, data->h_pin, NvOdmGpioPinMode_Output);
	printk(KERN_INFO "pICS_%s: NvOdmGpioConfig(data->h_gpio, data->h_pin, NvOdmGpioPinMode_Output)\n",__func__);
	NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x1);
	printk(KERN_INFO "pICS_%s: NvOdmGpioSetState(data->h_gpio, data->h_pin, 0x1)\n",__func__);
#endif
/*	data->port = 21;
	data->pin = 6;
	data->h_gpio = 174;
	data->h_pin = */

try_f7:

	nr_gpio = 174;
    	ret = gpio_request(nr_gpio, "nvrm_gpio");
    	printk(KERN_INFO "pICS_%s: gpio_request(nr_gpio=%i, 'nvrm_gpio') => %i;\n",__func__, nr_gpio, ret);

    	if (ret) {
		if(TEGRA_GPIO_PF7 == nr_gpio && !count_f7)
		{
			pr_err("%s: gpio_request for 47 failed (%d). Special case to free and retry\n",	__func__, ret);
			// F7 is allocated early by lights driver but really should be owned by disp driver
			gpio_free(nr_gpio);
			/*gpio_data[nr_gpio].val = false;
			gpio_data[nr_gpio].alloc = false;*/
			count_f7 = 1;
			goto try_f7;
		}

		/*gpio_to_name(nr_gpio, gpio_name);*/
		pr_err("%s: gpio_request for %d failed (%d)\n",
		       __func__, nr_gpio, ret);
	}

/*	gpio_data[nr_gpio].alloc = true;
	gpio_data[nr_gpio].val = false;*/

	tegra_gpio_enable(nr_gpio);
	gpio_direction_output(nr_gpio, 0);	
	gpio_set_value(nr_gpio, 1);

	platform_set_drvdata(pdev, pdata);

	/* when the phone is the host do not start the gadget driver */
	if((pdata->accy == CPCAP_ACCY_USB) || (pdata->accy == CPCAP_ACCY_FACTORY)) {
		tegra_otg_set_mode(0);
#ifdef CONFIG_USB_MOT_ANDROID
		android_usb_set_connected(1, pdata->accy);
#endif
	}
	if(pdata->accy == CPCAP_ACCY_USB_DEVICE) {
		tegra_otg_set_mode(1);
	}
#ifdef CONFIG_MDM_CTRL
	mdm_ctrl_set_usb_ipc(true);
#endif

	return 0;
}