int s5p_usb_phy_init(struct platform_device *pdev, int type)
{
    int ret = -EINVAL;

    if (exynos_usb_phy_clock_enable(pdev))
        return ret;

    mutex_lock(&phy_lock);

    if (type == S5P_USB_PHY_HOST) {
        if (!strcmp(pdev->name, "s5p-ehci"))
            set_bit(HOST_PHY_EHCI, &usb_phy_control.flags);
        else if (!strcmp(pdev->name, "s5p-ohci"))
            set_bit(HOST_PHY_OHCI, &usb_phy_control.flags);

#if defined(CONFIG_LINK_DEVICE_HSIC) || defined(CONFIG_LINK_DEVICE_USB) \
		|| defined(CONFIG_MDM_HSIC_PM)
        /* HSIC LPA: Let CP know the slave wakeup from LPA wakeup */
        if (!strcmp(pdev->name, "s5p-ehci"))
            set_hsic_lpa_states(STATE_HSIC_LPA_PHY_INIT);
#endif
        if (soc_is_exynos4210())
            ret = exynos4_usb_phy1_init(pdev);
        else if (soc_is_exynos4212() || soc_is_exynos4412()) {
            ret = exynos4_usb_phy20_init(pdev);
            set_exynos_usb_phy_tune(type);
        } else
            ret = exynos5_usb_phy20_init(pdev);
    } else if (type == S5P_USB_PHY_DEVICE) {
        if (soc_is_exynos4210())
            ret = exynos4_usb_phy0_init(pdev);
        else {
            ret = exynos_usb_dev_phy20_init(pdev);
            set_exynos_usb_phy_tune(type);
        }
        /* set custom usb phy tune */
        if (pdev->dev.platform_data)
            ret = s5p_usb_phy0_tune(pdev->dev.platform_data, 0);
    } else if (type == S5P_USB_PHY_OTGHOST) {
        if (soc_is_exynos4210())
            ret = exynos4_usb_phy0_init(pdev);
        else
            ret = exynos_usb_dev_phy20_init(pdev);
    } else if (type == S5P_USB_PHY_DRD)
        ret = exynos5_usb_phy30_init(pdev);

    mutex_unlock(&phy_lock);
    exynos_usb_phy_clock_disable(pdev);

    return ret;
}
int s5p_usb_phy_exit(struct platform_device *pdev, int type)
{
	int ret = -EINVAL;

	if (exynos_usb_phy_clock_enable(pdev))
		return ret;

	mutex_lock(&phy_lock);

	if (type == S5P_USB_PHY_HOST) {
		if (soc_is_exynos4210())
			ret = exynos4_usb_phy1_exit(pdev);
		else if (soc_is_exynos4212() || soc_is_exynos4412())
			ret = exynos4_usb_phy20_exit(pdev);
		else
			ret = exynos5_usb_phy20_exit(pdev);

		if (!strcmp(pdev->name, "s5p-ehci"))
			clear_bit(HOST_PHY_EHCI, &usb_phy_control.flags);
		else if (!strcmp(pdev->name, "s5p-ohci"))
			clear_bit(HOST_PHY_OHCI, &usb_phy_control.flags);
	} else if (type == S5P_USB_PHY_DEVICE) {
		/* set default usb phy tune */
		if (pdev->dev.platform_data && soc_is_exynos4210())
			ret = s5p_usb_phy0_tune(pdev->dev.platform_data, 1);
		if (soc_is_exynos4210())
			ret = exynos4_usb_phy0_exit(pdev);
		else
			ret = exynos_usb_dev_phy20_exit(pdev);
	} else if (type == S5P_USB_PHY_DRD)
		ret = exynos5_usb_phy30_exit(pdev);
	else if (type == S5P_USB_PHY_OTGHOST) {
		if (soc_is_exynos4210())
			ret = exynos4_usb_phy0_exit(pdev);
		else
			ret = exynos_usb_dev_phy20_exit(pdev);
	}

	mutex_unlock(&phy_lock);
	exynos_usb_phy_clock_disable(pdev);

	return ret;
}