예제 #1
0
/**
 * omap_usb2_set_comparator - links the comparator present in the sytem with
 *	this phy
 * @comparator - the companion phy(comparator) for this phy
 *
 * The phy companion driver should call this API passing the phy_companion
 * filled with set_vbus and start_srp to be used by usb phy.
 *
 * For use by phy companion driver
 */
void omap_usb2_set_comparator(struct phy_companion *comparator)
{
	struct usb_phy	*x = usb_get_phy(USB_PHY_TYPE_USB2);
	struct omap_usb	*phy = phy_to_omapusb(x);

	phy->comparator = comparator;
}
예제 #2
0
static int omap_usb_start_srp(struct usb_otg *otg)
{
	struct omap_usb *phy = phy_to_omapusb(otg->phy);
	if (phy->comparator)
		return phy->comparator->start_srp(phy->comparator);
	else
		return -ENODEV;
}
예제 #3
0
static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
{
	struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);

	if (!phy->comparator)
		return -ENODEV;

	return phy->comparator->set_vbus(phy->comparator, enabled);
}
예제 #4
0
파일: omap-usb3.c 프로젝트: AiWinters/linux
static int omap_usb3_init(struct usb_phy *x)
{
	struct omap_usb	*phy = phy_to_omapusb(x);

	omap_usb_dpll_lock(phy);
	omap_control_usb3_phy_power(phy->control_dev, 1);

	return 0;
}
예제 #5
0
/**
 * omap_usb2_set_comparator - links the comparator present in the sytem with
 *	this phy
 * @comparator - the companion phy(comparator) for this phy
 *
 * The phy companion driver should call this API passing the phy_companion
 * filled with set_vbus and start_srp to be used by usb phy.
 *
 * For use by phy companion driver
 */
int omap_usb2_set_comparator(struct phy_companion *comparator)
{
	struct omap_usb	*phy;
	struct usb_phy	*x = usb_get_phy(USB_PHY_TYPE_USB2);

	if (IS_ERR(x))
		return -ENODEV;

	phy = phy_to_omapusb(x);
	phy->comparator = comparator;
	return 0;
}
예제 #6
0
int omap_usb2_charger_detect(struct phy_companion *comparator)
{
	struct usb_phy  *x = usb_get_phy(USB_PHY_TYPE_USB2);
	struct omap_usb *phy = phy_to_omapusb(x);
	int charger = 0;

	omap_usb2_suspend(x, 0);
	charger = omap_usb_charger_detect(phy->control_dev);
	omap_usb2_suspend(x, 1);

	return charger;
}
예제 #7
0
static int omap_usb2_suspend(struct usb_phy *x, int suspend)
{
	u32		ret;
	struct omap_usb *phy = phy_to_omapusb(x);

	if (suspend && !phy->is_suspended) {
		omap4_usb_phy_power(phy->control_dev, 0);

		pm_runtime_put_sync(phy->dev);
		clk_disable(phy->wkupclk);
		clk_disable(phy->optclk);

		phy->is_suspended = 1;
	} else if (!suspend && phy->is_suspended) {
		if (phy->optclk) {
			ret = clk_enable(phy->optclk);
			if (ret) {
				dev_err(phy->dev,
					"Failed to enable optclk %d\n", ret);
				goto err3;
			}
		}
		ret = clk_enable(phy->wkupclk);
		if (ret) {
			dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
			goto err2;
		}
		ret = pm_runtime_get_sync(phy->dev);
		if (ret < 0) {
			dev_err(phy->dev, "get_sync failed with err %d\n",
									ret);
			goto err1;
		}

		omap4_usb_phy_power(phy->control_dev, 1);

		phy->is_suspended = 0;
	}

	return 0;

err1:
	clk_disable(phy->wkupclk);
err2:
	clk_disable(phy->optclk);
err3:
	return ret;
}
예제 #8
0
static int omap_usb2_suspend(struct usb_phy *x, int suspend)
{
	struct omap_usb *phy = phy_to_omapusb(x);
	int ret;

	if (suspend && !phy->is_suspended) {
		omap_control_usb_phy_power(phy->control_dev, 0);
		pm_runtime_put_sync(phy->dev);
		phy->is_suspended = 1;
	} else if (!suspend && phy->is_suspended) {
		ret = pm_runtime_get_sync(phy->dev);
		if (ret < 0) {
			dev_err(phy->dev, "get_sync failed with err %d\n", ret);
			return ret;
		}
		omap_control_usb_phy_power(phy->control_dev, 1);
		phy->is_suspended = 0;
	}

	return 0;
}
예제 #9
0
파일: omap-usb3.c 프로젝트: AiWinters/linux
static int omap_usb3_suspend(struct usb_phy *x, int suspend)
{
	struct omap_usb *phy = phy_to_omapusb(x);
	int	val;
	int timeout = PLL_IDLE_TIME;

	if (suspend && !phy->is_suspended) {
		val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
		val |= PLL_IDLE;
		omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val);

		do {
			val = omap_usb_readl(phy->pll_ctrl_base, PLL_STATUS);
			if (val & PLL_TICOPWDN)
				break;
			udelay(1);
		} while (--timeout);

		omap_control_usb3_phy_power(phy->control_dev, 0);

		phy->is_suspended	= 1;
	} else if (!suspend && phy->is_suspended) {
		phy->is_suspended	= 0;

		val = omap_usb_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
		val &= ~PLL_IDLE;
		omap_usb_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val);

		do {
			val = omap_usb_readl(phy->pll_ctrl_base, PLL_STATUS);
			if (!(val & PLL_TICOPWDN))
				break;
			udelay(1);
		} while (--timeout);
	}

	return 0;
}