From 6df9cea2c826573d97ff59da91b5e224d440f9f2 Mon Sep 17 00:00:00 2001 From: David Keitel Date: Wed, 21 Dec 2011 12:36:45 -0800 Subject: [PATCH] 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 --- drivers/power/pm8921-charger.c | 22 ++++++++++++++++++++-- include/linux/mfd/pm8xxx/pm8921-charger.h | 19 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c index 1e856284489..c169025e8e0 100644 --- a/drivers/power/pm8921-charger.c +++ b/drivers/power/pm8921-charger.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -896,7 +895,10 @@ static int pm_power_get_property(struct power_supply *psy, 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 @@ bool pm8921_is_battery_charging(int *source) } 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 eb1005cbe6f..3e574ff600a 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 +#include #define PM8921_CHARGER_DEV_NAME "pm8921-charger" @@ -210,6 +211,18 @@ int pm8921_set_max_battery_charge_current(int ma); */ 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 @@ static inline int pm8921_disable_input_current_limit(bool disable) { 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;