]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
power: extcon: register for y-cable extcon dev
authorRakesh Bodla <rbodla@nvidia.com>
Thu, 29 May 2014 12:30:18 +0000 (18:00 +0530)
committerSimone Willett <swillett@nvidia.com>
Tue, 3 Jun 2014 17:18:47 +0000 (10:18 -0700)
Register to otg extcon dev for y-cable notification.

Bug 200004368
Bug 1456628

Change-Id: Ie63e29b90885ef713b96d30d05fedbbb89d3cd30
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/416656
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/power/power_supply_extcon.c
include/linux/power/power_supply_extcon.h

index 58a157d5567592218cfd4c14b47cee80b0399fb8..4d75d7f757279a7d678f68321e1272cf41c8755d 100644 (file)
@@ -35,6 +35,7 @@
 struct power_supply_extcon {
        struct device                           *dev;
        struct extcon_dev                       *edev;
+       struct extcon_dev                       *y_cable_edev;
        struct power_supply                     ac;
        struct power_supply                     usb;
        uint8_t                                 ac_online;
@@ -83,6 +84,9 @@ static struct power_supply_cables psy_cables[] = {
        {
                .name   = "Apple 2A-charger",
        },
+       {
+               .name   = "Y-cable",
+       },
 };
 
 static enum power_supply_property power_supply_extcon_props[] = {
@@ -171,6 +175,9 @@ static int power_supply_extcon_attach_cable(
                psy_extcon->ac_online = 1;
                dev_info(psy_extcon->dev,
                        "USB Apple 2A-charger cable detected\n");
+       } else if (true == extcon_get_cable_state(edev, "Y-cable")) {
+               psy_extcon->ac_online = 1;
+               dev_info(psy_extcon->dev, "Y cable charging detected\n");
        } else {
                dev_info(psy_extcon->dev, "Unknown cable detected\n");
        }
@@ -272,9 +279,17 @@ static int psy_extcon_probe(struct platform_device *pdev)
                cable->psy_extcon = psy_extcon;
                cable->nb.notifier_call = psy_extcon_extcon_notifier;
 
-               ret = extcon_register_interest(cable->extcon_dev,
+               if (strcmp(cable->name, "Y-cable") == 0 &&
+                               pdata->y_cable_extcon_name) {
+                       ret = extcon_register_interest(cable->extcon_dev,
+                               pdata->y_cable_extcon_name,
+                               cable->name, &cable->nb);
+               } else {
+                       ret = extcon_register_interest(cable->extcon_dev,
                                pdata->extcon_name,
                                cable->name, &cable->nb);
+               }
+
                if (ret < 0)
                        dev_err(psy_extcon->dev, "Cannot register for cable: %s\n",
                                        cable->name);
@@ -287,6 +302,19 @@ static int psy_extcon_probe(struct platform_device *pdev)
        mutex_lock(&psy_extcon->lock);
        power_supply_extcon_attach_cable(psy_extcon, psy_extcon->edev);
        mutex_unlock(&psy_extcon->lock);
+
+       if (pdata->y_cable_extcon_name) {
+               psy_extcon->y_cable_edev =
+                       extcon_get_extcon_dev(pdata->y_cable_extcon_name);
+               if (!psy_extcon->y_cable_edev)
+                       goto econ_err;
+
+               mutex_lock(&psy_extcon->lock);
+               power_supply_extcon_attach_cable(psy_extcon,
+                               psy_extcon->y_cable_edev);
+               mutex_unlock(&psy_extcon->lock);
+       }
+
        dev_info(&pdev->dev, "%s() get success\n", __func__);
        return 0;
 
index ff8621b8f376b7d21a473e32737a66fe7b9d0820..e125f3830c257b97e2c23e517933f781caf4b9b5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * power_supply_extcon: Power supply detection through extcon.
  *
- * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2012-2014, NVIDIA CORPORATION.  All rights reserved.
  * Laxman Dewangan <ldewangan@nvidia.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
 
 struct power_supply_extcon_plat_data {
        const char *extcon_name;
+       const char *y_cable_extcon_name;
 };
 
 #endif