|
@@ -19,6 +19,13 @@
|
|
#include <plat/cpu.h>
|
|
#include <plat/cpu.h>
|
|
#include <plat/usb-phy.h>
|
|
#include <plat/usb-phy.h>
|
|
|
|
|
|
|
|
+static atomic_t host_usage;
|
|
|
|
+
|
|
|
|
+static int exynos4_usb_host_phy_is_on(void)
|
|
|
|
+{
|
|
|
|
+ return (readl(EXYNOS4_PHYPWR) & PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1;
|
|
|
|
+}
|
|
|
|
+
|
|
static int exynos4_usb_phy1_init(struct platform_device *pdev)
|
|
static int exynos4_usb_phy1_init(struct platform_device *pdev)
|
|
{
|
|
{
|
|
struct clk *otg_clk;
|
|
struct clk *otg_clk;
|
|
@@ -27,6 +34,8 @@ static int exynos4_usb_phy1_init(struct platform_device *pdev)
|
|
u32 rstcon;
|
|
u32 rstcon;
|
|
int err;
|
|
int err;
|
|
|
|
|
|
|
|
+ atomic_inc(&host_usage);
|
|
|
|
+
|
|
otg_clk = clk_get(&pdev->dev, "otg");
|
|
otg_clk = clk_get(&pdev->dev, "otg");
|
|
if (IS_ERR(otg_clk)) {
|
|
if (IS_ERR(otg_clk)) {
|
|
dev_err(&pdev->dev, "Failed to get otg clock\n");
|
|
dev_err(&pdev->dev, "Failed to get otg clock\n");
|
|
@@ -39,6 +48,9 @@ static int exynos4_usb_phy1_init(struct platform_device *pdev)
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (exynos4_usb_host_phy_is_on())
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
writel(readl(S5P_USBHOST_PHY_CONTROL) | S5P_USBHOST_PHY_ENABLE,
|
|
writel(readl(S5P_USBHOST_PHY_CONTROL) | S5P_USBHOST_PHY_ENABLE,
|
|
S5P_USBHOST_PHY_CONTROL);
|
|
S5P_USBHOST_PHY_CONTROL);
|
|
|
|
|
|
@@ -95,6 +107,9 @@ static int exynos4_usb_phy1_exit(struct platform_device *pdev)
|
|
struct clk *otg_clk;
|
|
struct clk *otg_clk;
|
|
int err;
|
|
int err;
|
|
|
|
|
|
|
|
+ if (atomic_dec_return(&host_usage) > 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
otg_clk = clk_get(&pdev->dev, "otg");
|
|
otg_clk = clk_get(&pdev->dev, "otg");
|
|
if (IS_ERR(otg_clk)) {
|
|
if (IS_ERR(otg_clk)) {
|
|
dev_err(&pdev->dev, "Failed to get otg clock\n");
|
|
dev_err(&pdev->dev, "Failed to get otg clock\n");
|