summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRong Dian <b38775@freescale.com>2012-06-21 14:26:45 +0800
committerJason Liu <r64343@freescale.com>2012-07-20 13:38:59 +0800
commitbcb9bb2398e83ab1178a648b6c18023d1aa7c835 (patch)
treeb9e3c5d03c873b0bcfed12cf08b592a53b26d453
parent83093cf018bf03dbb3a2400fca95107b850cabf7 (diff)
ENGR00214367-2 imx6 usb charger: bind usb charger with power supply
Bind usb charger with power supply, and print some attributes about usb charger. Signed-off-by: Rong Dian <b38775@freescale.com>
-rw-r--r--drivers/usb/gadget/imx_usb_charger.c24
-rw-r--r--drivers/usb/gadget/imx_usb_charger.h3
2 files changed, 25 insertions, 2 deletions
diff --git a/drivers/usb/gadget/imx_usb_charger.c b/drivers/usb/gadget/imx_usb_charger.c
index e1020421adb8..33242a7ab4d8 100644
--- a/drivers/usb/gadget/imx_usb_charger.c
+++ b/drivers/usb/gadget/imx_usb_charger.c
@@ -13,6 +13,29 @@
* NOTICE: Currently, it only supports i.mx6q usb charger detect
*/
+static void my_batt_ext_power_changed(struct power_supply *psy)
+{
+ int mA;
+ union power_supply_propval ret = {0,};
+ printk(KERN_INFO "my_batt_ext_power_changed!\n");
+ if (!power_supply_am_i_supplied(psy)) {
+ /* stop charging */
+ printk(KERN_ERR "It is not usb supply!\n");
+ return;
+ }
+ power_supply_get_supplier_property(psy,
+ POWER_SUPPLY_PROP_ONLINE, &ret);
+
+ printk(KERN_INFO "imx6 usb charger online:%d\n", ret.intval);
+
+ power_supply_get_supplier_property(psy,
+ POWER_SUPPLY_PROP_CURRENT_MAX, &ret);
+ /* maximum milliamps we are allowed to draw from VBUS */
+ mA = ret.intval;
+ printk(KERN_INFO "imx6 usb charger limit mA: %d\n", mA);
+}
+
+
static int usb_charger_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -216,6 +239,7 @@ int imx_usb_create_charger(struct usb_charger *charger,
psy->supplied_to = usb_charger_supplied_to;
psy->num_supplicants = sizeof(usb_charger_supplied_to)/sizeof(char *);
+ psy->external_power_changed = my_batt_ext_power_changed;
ret = power_supply_register(charger->dev, psy);
if (ret)
diff --git a/drivers/usb/gadget/imx_usb_charger.h b/drivers/usb/gadget/imx_usb_charger.h
index 5417743a5118..b3beb0fe58d7 100644
--- a/drivers/usb/gadget/imx_usb_charger.h
+++ b/drivers/usb/gadget/imx_usb_charger.h
@@ -160,7 +160,6 @@ struct usb_charger {
struct device *dev; /* udc supplies */
/* charger detect can be enabled/disabled by kernel config */
bool enable;
-
struct power_supply psy;
struct work_struct work;
struct mutex lock;
@@ -182,7 +181,7 @@ struct usb_charger {
};
static char *usb_charger_supplied_to[] = {
- "main-battery",
+ "imx_usb_charger",
};
static enum power_supply_property power_props[] = {