power: pm8921-charger: Add pm8921_set_usb_power_supply_type
USB can distinguish between types of USB connections such as a
DC charger or PC connection.
Let the USB drivers set the specifc power_supply_type via this
function.
CRs-Fixed: 326548
Change-Id: I31954b3f8d2b1e5fd72712e1f94f67fdbc2e205d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index 1e85628..c169025 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -22,7 +22,6 @@
#include <linux/mfd/pm8xxx/ccadc.h>
#include <linux/mfd/pm8xxx/core.h>
#include <linux/interrupt.h>
-#include <linux/power_supply.h>
#include <linux/delay.h>
#include <linux/bitops.h>
#include <linux/workqueue.h>
@@ -896,7 +895,10 @@
dc_psy);
val->intval = is_dc_chg_plugged_in(chip);
}
- if (psy->type == POWER_SUPPLY_TYPE_USB) {
+ if (psy->type == POWER_SUPPLY_TYPE_USB ||
+ psy->type == POWER_SUPPLY_TYPE_USB_DCP ||
+ psy->type == POWER_SUPPLY_TYPE_USB_CDP ||
+ psy->type == POWER_SUPPLY_TYPE_USB_ACA) {
chip = container_of(psy, struct pm8921_chg_chip,
usb_psy);
val->intval = is_usb_chg_plugged_in(chip);
@@ -1441,6 +1443,22 @@
}
EXPORT_SYMBOL(pm8921_is_battery_charging);
+int pm8921_set_usb_power_supply_type(enum power_supply_type type)
+{
+ if (!the_chip) {
+ pr_err("called before init\n");
+ return -EINVAL;
+ }
+
+ if (type < POWER_SUPPLY_TYPE_USB)
+ return -EINVAL;
+
+ the_chip->usb_psy.type = type;
+ power_supply_changed(&the_chip->usb_psy);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pm8921_set_usb_power_supply_type);
+
int pm8921_batt_temperature(void)
{
if (!the_chip) {
diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h
index eb1005c..3e574ff 100644
--- a/include/linux/mfd/pm8xxx/pm8921-charger.h
+++ b/include/linux/mfd/pm8xxx/pm8921-charger.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -14,6 +14,7 @@
#define __PM8XXX_CHARGER_H
#include <linux/errno.h>
+#include <linux/power_supply.h>
#define PM8921_CHARGER_DEV_NAME "pm8921-charger"
@@ -211,6 +212,18 @@
int pm8921_disable_input_current_limit(bool disable);
/**
+ * pm8921_set_usb_power_supply_type - set USB supply type
+ *
+ * @type: power_supply_type enum
+ *
+ * This api lets one set a specific usb power_supply_type.
+ * USB drivers can distinguish between types of USB connections
+ * and set the appropriate type for the USB supply.
+ */
+
+int pm8921_set_usb_power_supply_type(enum power_supply_type type);
+
+/**
* pm8921_disable_source_current - disable drawing current from source
* @disable: true to disable current drawing from source false otherwise
*
@@ -317,6 +330,10 @@
{
return -ENXIO;
}
+static inline int pm8921_set_usb_power_supply_type(enum power_supply_type type)
+{
+ return -ENXIO;
+}
static inline int pm8921_set_max_battery_charge_current(int ma)
{
return -ENXIO;