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>
This commit is contained in:
David Keitel
2011-12-21 12:36:45 -08:00
parent 728bc4d899
commit 6df9cea2c8
2 changed files with 38 additions and 3 deletions

View File

@@ -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 @@ 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) {

View File

@@ -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"
@@ -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;