phy: exynos4212-usb: Use refcount to power device PHY for HSIC0 19/20019/1
authorTomasz Figa <t.figa@samsung.com>
Thu, 24 Apr 2014 11:25:34 +0000 (13:25 +0200)
committerTomasz Figa <t.figa@samsung.com>
Thu, 24 Apr 2014 15:07:39 +0000 (17:07 +0200)
HSIC0 requires device PHY to be powered up and the driver handles that
already, but there is no reference counting of device PHY power state,
so unplugging USB cable powers it down, breaking modem IF operation.

This patch fixes the issue by adding handling of reference counting of
device PHY to HSIC0 power-down/-up.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Change-Id: I14b1825fec3cd9c1b2652b89f275a50c73359ad6

drivers/phy/phy-exynos4212-usb.c

index c6af66d..6d426a4 100644 (file)
@@ -263,6 +263,11 @@ static int exynos4212_power_on(struct uphy_instance *inst)
        if (inst->cfg->id == EXYNOS4212_HSIC0) {
                struct uphy_instance *device =
                                        &drv->uphy_instances[EXYNOS4212_DEVICE];
+
+               device->ref_cnt++;
+               if (device->ref_cnt > 1)
+                       return 0;
+
                exynos4212_phy_pwr(device, 1);
                exynos4212_isol(device, 0);
        }
@@ -292,6 +297,11 @@ static int exynos4212_power_off(struct uphy_instance *inst)
        if (inst->cfg->id == EXYNOS4212_HSIC0) {
                struct uphy_instance *device =
                                        &drv->uphy_instances[EXYNOS4212_DEVICE];
+
+               device->ref_cnt--;
+               if (device->ref_cnt > 0)
+                       return 0;
+
                exynos4212_phy_pwr(device, 0);
                exynos4212_isol(device, 1);
        }