]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: otg: tegra: seperate extcon dev for id, vbus
authorRakesh Bodla <rbodla@nvidia.com>
Thu, 28 Mar 2013 14:25:51 +0000 (19:55 +0530)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:07:38 +0000 (13:07 -0700)
Use seperate extcon dev for id and vbus.
Platforms can use different pmu for each
detection.

Bug 1262180

Change-Id: I58dcfd4b822089049197855b8241f6f362768243
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/214005
(cherry picked from commit 36997afffa15443d1c4633647e97738f1e524af7)
Reviewed-on: http://git-master/r/216532
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/usb/otg/tegra-otg.c

index 1a17431306bab00cf4354bbfc9ce257d18df7243..e6df33b1f7551b7a44562e92ec23a51029f5a4fd 100644 (file)
@@ -75,11 +75,13 @@ struct tegra_otg_data {
        bool support_pmu_id;
        bool support_gpio_id;
        int id_det_gpio;
-       struct extcon_dev *edev;
+       struct extcon_dev *id_extcon_dev;
+       struct extcon_dev *vbus_extcon_dev;
 };
 
 static struct tegra_otg_data *tegra_clone;
-static struct notifier_block otg_nb;
+static struct notifier_block otg_vbus_nb;
+static struct notifier_block otg_id_nb;
 struct extcon_specific_cable_nb *extcondev;
 
 static int otg_notifications(struct notifier_block *nb,
@@ -92,14 +94,14 @@ static int otg_notifications(struct notifier_block *nb,
        spin_lock_irqsave(&tegra->lock, flags);
 
        if (tegra->support_pmu_vbus) {
-               if (extcon_get_cable_state(tegra->edev, "USB"))
+               if (extcon_get_cable_state(tegra->vbus_extcon_dev, "USB"))
                        tegra->int_status |= USB_VBUS_STATUS ;
                else
                        tegra->int_status &= ~USB_VBUS_STATUS;
        }
 
        if (tegra->support_pmu_id) {
-               if (extcon_get_cable_state(tegra->edev, "USB-Host")) {
+               if (extcon_get_cable_state(tegra->id_extcon_dev, "USB-Host")) {
                        tegra->int_status &= ~USB_ID_STATUS;
                        tegra->int_status |= USB_ID_INT_EN;
                 } else
@@ -632,16 +634,30 @@ static int tegra_otg_probe(struct platform_device *pdev)
                }
        }
 
-       if (tegra->support_pmu_vbus || tegra->support_pmu_id) {
-               tegra->edev = extcon_get_extcon_dev(pdata->extcon_dev_name);
-               if (!tegra->edev) {
+       if (tegra->support_pmu_vbus) {
+               tegra->vbus_extcon_dev =
+                       extcon_get_extcon_dev(pdata->vbus_extcon_dev_name);
+               if (!tegra->vbus_extcon_dev) {
                        dev_err(&pdev->dev, "Cannot get the %s extcon dev\n",
-                                               pdata->extcon_dev_name);
+                                               pdata->vbus_extcon_dev_name);
                        err = -ENODEV;
                        goto err_irq;
                }
-               otg_nb.notifier_call = otg_notifications;
-               extcon_register_notifier(tegra->edev, &otg_nb);
+               otg_vbus_nb.notifier_call = otg_notifications;
+               extcon_register_notifier(tegra->vbus_extcon_dev, &otg_vbus_nb);
+       }
+
+       if (tegra->support_pmu_id) {
+               tegra->id_extcon_dev =
+                       extcon_get_extcon_dev(pdata->id_extcon_dev_name);
+               if (!tegra->id_extcon_dev) {
+                       dev_err(&pdev->dev, "Cannot get the %s extcon dev\n",
+                                               pdata->id_extcon_dev_name);
+                       err = -ENODEV;
+                       goto err_irq;
+               }
+               otg_id_nb.notifier_call = otg_notifications;
+               extcon_register_notifier(tegra->id_extcon_dev, &otg_id_nb);
        }
 
        tegra_pd_add_device(&tegra_mc_chain_b, tegra->phy.dev);
@@ -673,9 +689,14 @@ static int __exit tegra_otg_remove(struct platform_device *pdev)
        if (tegra->support_gpio_id && gpio_is_valid(tegra->id_det_gpio)) {
                free_irq(gpio_to_irq(tegra->id_det_gpio), tegra);
                gpio_free(tegra->id_det_gpio);
+       } else if (tegra->support_pmu_id) {
+               extcon_unregister_notifier(tegra->id_extcon_dev, &otg_id_nb);
        }
-       if (tegra->support_pmu_vbus || tegra->support_pmu_id)
-               extcon_unregister_notifier(tegra->edev, &otg_nb);
+
+       if (tegra->support_pmu_vbus)
+               extcon_unregister_notifier(tegra->vbus_extcon_dev,
+                                                       &otg_vbus_nb);
+
        pm_runtime_disable(tegra->phy.dev);
        usb_remove_phy(&tegra->phy);
        iounmap(tegra->regs);