示例#1
0
/* OTG transceiver interface */
static int tegra_otg_set_peripheral(struct otg_transceiver *otg,
				struct usb_gadget *gadget)
{
	unsigned int temp;
	unsigned long flags;

	otg->gadget = gadget;

	if (sg_tegra_otg->vbus_connected) {
		temp = readl(sg_tegra_otg->regs + TEGRA_USB_WAKEUP_REG_OFFSET);
		temp |= (TEGRA_USB_VBUS_INT_ENABLE | TEGRA_USB_VBUS_WAKEUP_ENABLE);
		temp &= ~TEGRA_USB_VBUS_INT_STATUS;
		writel(temp, (sg_tegra_otg->regs + TEGRA_USB_WAKEUP_REG_OFFSET));
	} else {
		temp = readl(sg_tegra_otg->regs + TEGRA_USB_WAKEUP_REG_OFFSET);
	}

	/* Check if we detect any device connected */
	if (sg_tegra_otg->id_connected && !(temp & TEGRA_USB_ID_STATUS)) {
		struct usb_hcd *hcd = (struct usb_hcd *)otg->host;
		spin_lock_irqsave(&sg_tegra_otg->lock, flags);
		otg->state = OTG_STATE_A_HOST;
		/* set HCD flags to start host ISR */
		set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
		spin_unlock_irqrestore(&sg_tegra_otg->lock, flags);
		NvDdkUsbPhyPowerUp(sg_tegra_otg->usb_phy, NV_TRUE, 0);
	}

	return 0;
}
示例#2
0
static void tegra_ehci_power_up(struct usb_hcd *hcd)
{
	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
	struct tegra_hcd_platform_data *pdata;

	pdata = hcd->self.controller->platform_data;

	NV_ASSERT_SUCCESS(NvDdkUsbPhyPowerUp(pdata->hUsbPhy, true, 0));
	ehci->host_resumed = 1;
}
示例#3
0
int tegra_udc_clk_init(struct platform_device *pdev)
{
	NvError nverr;

	nverr = NvDdkUsbPhyOpen(s_hRmGlobal, pdev->id, &s_hUsbPhy);
	if (nverr != NvSuccess)
		return -ENODEV;

	/* Power up the USB phy */
	NV_ASSERT_SUCCESS(NvDdkUsbPhyPowerUp(s_hUsbPhy, NV_FALSE, 0));
	wake_lock_init(&s_wake_lock, WAKE_LOCK_SUSPEND, "tegra-udc");
	return 0;
}
示例#4
0
/* platform driver interface */
static int __devinit tegra_otg_probe(struct platform_device *pdev)
{
	int err = 0;
	struct resource *res;
	int instance = pdev->id;
	NvError e;
	struct tegra_otg_platform_data *pdata;

	sg_tegra_otg = kzalloc(sizeof(struct tegra_otg_data), GFP_KERNEL);
	if (!sg_tegra_otg)
		return -ENOMEM;

	spin_lock_init(&sg_tegra_otg->lock);
	platform_set_drvdata(pdev, sg_tegra_otg);

	NV_CHECK_ERROR_CLEANUP(
		NvDdkUsbPhyOpen(s_hRmGlobal, instance, &sg_tegra_otg->usb_phy)
	);
	NV_CHECK_ERROR_CLEANUP(
		NvDdkUsbPhyPowerUp(sg_tegra_otg->usb_phy, NV_FALSE, 0)
	);
	sg_tegra_otg->instance = pdev->id;
	sg_tegra_otg->dev = &pdev->dev;
	sg_tegra_otg->otg.label = driver_name;
	sg_tegra_otg->otg.state = OTG_STATE_UNDEFINED;
	sg_tegra_otg->otg.set_peripheral = tegra_otg_set_peripheral;
	sg_tegra_otg->otg.set_host = tegra_otg_set_host;
	sg_tegra_otg->otg.set_power = tegra_otg_set_power;
	sg_tegra_otg->otg.set_suspend = tegra_otg_set_suspend;
	pdata = sg_tegra_otg->dev->platform_data;
	if(pdata->usb_property->IdPinDetectionType == NvOdmUsbIdPinType_CableId)
		sg_tegra_otg->id_connected = 1;
	if(pdata->usb_property->UseInternalPhyWakeup)
		sg_tegra_otg->vbus_connected = 1;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		err = -ENXIO;
		goto err_irq;
	}

	sg_tegra_otg->regs = ioremap(res->start, resource_size(res));
	if (!sg_tegra_otg->regs) {
		err = -ENOMEM;
		goto err_irq;
	}

	sg_tegra_otg->irq = platform_get_irq(pdev, 0);
	if (!sg_tegra_otg->irq) {
		err = -ENODEV;
		goto err_irq;
	}

	err = request_irq(sg_tegra_otg->irq, tegra_otg_irq, IRQF_SHARED,
			driver_name, pdev);
	if (err) {
		printk("cannot request irq %d err %d\n",
				sg_tegra_otg->irq, err);
		goto err_mem_map;
	}

	/* only active when a gadget is registered */
	err = otg_set_transceiver(&sg_tegra_otg->otg);
	if (err) {
		dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
			err);
		goto err_otg;
	}

	NvDdkUsbPhyPowerDown(sg_tegra_otg->usb_phy, NV_FALSE, 0);

	return 0;

err_otg:
	free_irq(sg_tegra_otg->irq, &pdev->dev);
err_mem_map:
	iounmap(sg_tegra_otg->regs);
err_irq:
	NvDdkUsbPhyClose(sg_tegra_otg->usb_phy);
fail:
	platform_set_drvdata(pdev, NULL);
	kfree(sg_tegra_otg);
	return err;
}
示例#5
0
void tegra_udc_clk_resume(void)
{
	wake_lock_timeout(&s_wake_lock, msecs_to_jiffies(10*1000)); /* lock for 10 seconds */
	NV_ASSERT_SUCCESS(NvDdkUsbPhyPowerUp(s_hUsbPhy, NV_FALSE, 0));
}