Beispiel #1
0
static void sunxi_musb_disable(struct musb *musb)
{
	pr_debug("%s():\n", __func__);

	if (!enabled)
		return;

	if (is_host_enabled(musb))
		sunxi_usb_phy_power_off(0); /* port power off */

	USBC_ForceVbusValidToLow(musb->mregs);
	mdelay(200); /* Wait for the current session to timeout */

	enabled = false;
}
static int sunxi_musb_enable(struct musb *musb)
{
	pr_debug("%s():\n", __func__);

	musb_ep_select(musb->mregs, 0);
	musb_writeb(musb->mregs, MUSB_FADDR, 0);

	if (enabled)
		return 0;

	/* select PIO mode */
	musb_writeb(musb->mregs, USBC_REG_o_VEND0, 0);

	if (is_host_enabled(musb)) {
		int id = sunxi_usb_phy_id_detect(0);

		if (id == 1 && sunxi_usb_phy_power_is_on(0))
			sunxi_usb_phy_power_off(0);

		if (!sunxi_usb_phy_power_is_on(0)) {
			int vbus = sunxi_usb_phy_vbus_detect(0);
			if (vbus == 1) {
				printf("A charger is plugged into the OTG: ");
				return -ENODEV;
			}
		}

		if (id == 1) {
			printf("No host cable detected: ");
			return -ENODEV;
		}

		if (!sunxi_usb_phy_power_is_on(0))
			sunxi_usb_phy_power_on(0);
	}

	USBC_ForceVbusValidToHigh(musb->mregs);

	enabled = true;
	return 0;
}
Beispiel #3
0
static int ohci_usb_remove(struct udevice *dev)
{
	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
	struct ohci_sunxi_priv *priv = dev_get_priv(dev);
	int ret;

	ret = ohci_deregister(dev);
	if (ret)
		return ret;

	sunxi_usb_phy_power_off(priv->phy_index);
	sunxi_usb_phy_exit(priv->phy_index);

#ifdef CONFIG_SUNXI_GEN_SUN6I
	clrbits_le32(&ccm->ahb_reset0_cfg, priv->ahb_gate_mask);
#endif
	clrbits_le32(&ccm->usb_clk_cfg, priv->usb_gate_mask);
	clrbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask);

	return 0;
}