power_supply: Introduce Power Supply Charging Framework
Subsystems (2)
cover power_supply: Introduce Power Supply Charging Framework
The Power Supply charging framework connects multiple subsystems to do charging in a generic way. The framework makes use of different new features - Battery Identification framework, pluggable charging algorithms, charger cable arbitrations. PSE compliant charging algorithm also enabled as part of this patch set.
With this framework the charging logic can be kept outside the charger driver.The charger driver just need to expose th get_property and set_property functions to get and set a specific set of power supply properties. The driver can convert these values to the hardware configurations to setup charging.
Jenny TC (7):
power_supply: Add charger control properties power_supply : add charger cable properties
power_supply: add throttle state
power_supply: Add power_supply notifier power_supply : Introduce battery identification framework
power_supply: Introduce Power Supply charging framework
power_supply: Introduce PSE compliant algorithm
Documentation/power/power_supply_class.txt | 202 ++++++ drivers/power/Kconfig | 30 + drivers/power/Makefile | 3 + drivers/power/battery_id.c | 87 +++ drivers/power/charging_algo_pse.c | 202 ++++++ drivers/power/power_supply.h | 21 + drivers/power/power_supply_charger.c | 1011 ++++++++++++++++++++++++++++ drivers/power/power_supply_charger.h | 130 ++++ drivers/power/power_supply_core.c | 38 ++ drivers/power/power_supply_sysfs.c | 8 + include/linux/power/battery_id.h | 100 +++ include/linux/power_supply.h | 335 +++++++++ 12 files changed, 2167 insertions(+) create mode 100644 drivers/power/battery_id.c create mode 100644 drivers/power/charging_algo_pse.c create mode 100644 drivers/power/power_supply_charger.c create mode 100644 drivers/power/power_supply_charger.h create mode 100644 include/linux/power/battery_id.h
Signature · 1 line
1.7.9.5
PATCH 1/7 power_supply: Add charger control properties
The battery charger needs to have control path along
with the reporting charger properties. In existing solutions this is implemented using regulator framework. A regulator framework doesn't fit a charger driver requirement because of the following reason
Charger needs support two paths - charger path (charger to platform) and charging (charger to battery).Disabling the charging path alone (eg over battery temperature) will allow the platform to work with power from charger without discharging the battery. And the charger may need to be disabled completely based on the charger temperature or the platform temperature.
Charger has more than one pair of voltage/current to control (CC,CV,INLMT) These features will not directly fit in the regulator framework
Since the charger driver sits in the power supply subsystem it make sense to add the properties to control the charger.
Change-Id: Id91dbbd8f34499afa97b7d8f11ecf5467847f6a8
--- Documentation/power/power_supply_class.txt | 16 ++++++++++++++++ drivers/power/power_supply_sysfs.c | 8 ++++++++ include/linux/power_supply.h | 8 ++++++++ 3 files changed, 32 insertions(+)
Documentation/power/power_supply_class.txt +16 -0
@@ -118,6 +118,10 @@ relative, time-based measurements. CONSTANT_CHARGE_CURRENT - constant charge current programmed by charger. CONSTANT_CHARGE_CURRENT_MAX - maximum charge current supported by the power supply object. +INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates +the current drawn from a charging source. +CHARGE_TERM_CUR - Charge termination current used to detect the end of charge +condition CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger. CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported by the
@@ -140,12 +144,24 @@ TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature. TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade. TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade. +MIN_TEMP - minimum operatable temperature +MAX_TEMP - maximum operatable temperature TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e. while battery powers a load) TIME_TO_FULL - seconds left for battery to be considered full (i.e. while battery is charging) +ENABLE_CHARGING - Enable/disable charging. Write is used to enable/disable charging. +Reading the interface indicates whether the charging is enabled/disabled by the charger h/w. +ENABLE_CHARGER - Enable/disable charger. Write is used to enable/disable charger. +Reading the interface indicates whether the charger is enabled/disabled. When charger +is disabled platform is not expected to draw current from charging source. + +CABLE_TYPE - Used to indicate the type of cable used for charging. +PRIORITY - Indicates the priority of a power supply charger object. Useful +to setup charging on platforms with multiple charger chips.(Wireless/USB/AC etc.) + Battery <-> external power supply interaction ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/power/power_supply_sysfs.c +8 -0
@@ -167,6 +167,7 @@ static struct device_attribute power_supply_attrs[] = {POWER_SUPPLY_ATTR (constant_charge_voltage_max),POWER_SUPPLY_ATTR (charge_control_limit),POWER_SUPPLY_ATTR (charge_control_limit_max), +POWER_SUPPLY_ATTR (input_cur_limit),POWER_SUPPLY_ATTR (energy_full_design),POWER_SUPPLY_ATTR (energy_empty_design), POWER_SUPPLY_ATTR(energy_full),
@@ -178,6 +179,8 @@ static struct device_attribute power_supply_attrs[] = {POWER_SUPPLY_ATTR (capacity_alert_max),POWER_SUPPLY_ATTR (capacity_level),POWER_SUPPLY_ATTR (temp), +POWER_SUPPLY_ATTR (max_temp), +POWER_SUPPLY_ATTR (min_temp),POWER_SUPPLY_ATTR (temp_alert_min),POWER_SUPPLY_ATTR (temp_alert_max), POWER_SUPPLY_ATTR(temp_ambient),
@@ -189,6 +192,11 @@ static struct device_attribute power_supply_attrs[] = {POWER_SUPPLY_ATTR (time_to_full_avg),POWER_SUPPLY_ATTR (type),POWER_SUPPLY_ATTR (scope), +POWER_SUPPLY_ATTR (charge_term_cur), +POWER_SUPPLY_ATTR (enable_charging), +POWER_SUPPLY_ATTR (enable_charger), +POWER_SUPPLY_ATTR (cable_type), +POWER_SUPPLY_ATTR (priority),/* Properties of type `const char *' */ POWER_SUPPLY_ATTR (model_name), POWER_SUPPLY_ATTR(manufacturer),
include/linux/power_supply.h +8 -0
@@ -119,6 +119,7 @@ enum power_supply_property {POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX ,POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT ,POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX , +POWER_SUPPLY_PROP_INLMT ,POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN ,POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN , POWER_SUPPLY_PROP_ENERGY_FULL,
@@ -130,6 +131,8 @@ enum power_supply_property {POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX ,/* in percents! */ POWER_SUPPLY_PROP_CAPACITY_LEVEL ,POWER_SUPPLY_PROP_TEMP , +POWER_SUPPLY_PROP_MAX_TEMP , +POWER_SUPPLY_PROP_MIN_TEMP ,POWER_SUPPLY_PROP_TEMP_ALERT_MIN ,POWER_SUPPLY_PROP_TEMP_ALERT_MAX , POWER_SUPPLY_PROP_TEMP_AMBIENT,
@@ -141,6 +144,11 @@ enum power_supply_property {POWER_SUPPLY_PROP_TIME_TO_FULL_AVG ,POWER_SUPPLY_PROP_TYPE ,/* use power_supply.type instead */ POWER_SUPPLY_PROP_SCOPE , +POWER_SUPPLY_PROP_CHARGE_TERM_CUR , +POWER_SUPPLY_PROP_ENABLE_CHARGING , +POWER_SUPPLY_PROP_ENABLE_CHARGER , +POWER_SUPPLY_PROP_CABLE_TYPE , +POWER_SUPPLY_PROP_PRIORITY ,/* Properties of type `const char *' */ POWER_SUPPLY_PROP_MODEL_NAME , POWER_SUPPLY_PROP_MANUFACTURER,
Signature · 1 line
1.7.9.5
Re: [PATCH 1/7] power_supply: Add charger control properties
Hello Jenny,
Thanks a lot for your work on this!
Quoted 6 lines · Jenny TC
The battery charger needs to have control path along with the reporting charger properties. In existing solutions this is implemented using regulator framework. A regulator framework doesn't fit a charger driver requirement because of the following reason
General note:
Please always Cc as many relevant developers as possible, not just me. For me it takes months to review patches, and you surely want to get at least a preliminary review from other power supply folks. By Cc'ing just me you are slowing yourself down.
If you get some Acks/Reviews from other developers on your patches that shows that the feature is surely in demand and makes sense in general.
"git shortlog -s -n -e drivers/power/*charg*" is a good start to see whom you'd better Cc in this case.
(Unrelated to these patches, but just FYI, having a chain of
...
Works in opposite direction, it makes me suspicious. :)
Quoted 10 lines
and charging (charger to battery).Disabling the charging path alone (eg over battery temperature) will allow the platform to work with power from charger without discharging the battery. And the charger may need to be disabled completely based on the charger temperature or the platform temperature.
Charger has more than one pair of voltage/current to control (CC,CV,INLMT) These features will not directly fit in the regulator frameworkSince the charger driver sits in the power supply subsystem it make sense to add the properties to control the charger.
Looking into the patches, it seems that we are putting a lot of charger-specific knobs into the power supply class, but the primary idea of power supply subsystem is to monitor the power supplies of the system itself and system's devices like mouse/keyboard's batteries.
The border of what we define as power supply class object is blurry, so there is a lot of confusion indeed. For example, some chargers register TYPE_MAINS or TYPE_USB power_supply objects, but they do it since the charger chip itself is responsible for monitoring these supplies, so it is fine, and it does not affect the power supply class itself.
But do we really want to control the chargers through the power_supply's user-visible interface? It makes the whole power supply thing so complicated that I'm already losing track of it. Right now I think I would prefer to move all the charger logic out of the psy class.
More specifically, this code:
Review int power_supply_register(struct device *parent, struct power_supply *psy) · line 582
Quoted 9 lines
(quoted diff) +5
-0@@ -561,6 +575,11 @@ int power_supply_register(struct device *parent, struct power_supply *psy) if (rc) goto create_triggers_failed; + if (psy_is_charger(psy)) + rc = power_supply_register_charger(psy); + if (rc) + pr_debug("device: '%s': power_supply_register_charger failed\n", + dev_name(dev));
I have a weird feeling about the fact that the power_supply_register() registers a charger. OK, we have thermal stuff registration there, but it is completely different. We have the cooling device registration there as well, and this stuff would be really nice to move out to some "chargers subsystem".
So, Jenny, the question is: can we separate chargers logic from the power supply? So that we don't have "charger enable"/"charger disable" knobs in the psy class itself. It is still fine if you need to have some interface to the psy class so that the chargers subsystem would interface with it, though. But I think that charger drivers have to register itself with two
subsystems: chargers and power_supply (optionally).
Thanks,
Anton
Quoted 25 lines
Signed-off-by Jenny TC <[email protected]>Change-Id: Id91dbbd8f34499afa97b7d8f11ecf5467847f6a8
--- Documentation/power/power_supply_class.txt | 16 ++++++++++++++++ drivers/power/power_supply_sysfs.c | 8 ++++++++ include/linux/power_supply.h | 8 ++++++++ 3 files changed, 32 insertions(+)Documentation/power/power_supply_class.txt +4
-0@@ -118,6 +118,10 @@ relative, time-based measurements. CONSTANT_CHARGE_CURRENT - constant charge current programmed by charger. CONSTANT_CHARGE_CURRENT_MAX - maximum charge current supported by the power supply object. +INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates +the current drawn from a charging source. +CHARGE_TERM_CUR - Charge termination current used to detect the end of charge +condition CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger. CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported by the
Documentation/power/power_supply_class.txt TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. · line 148
Quoted 5 lines
Documentation/power/power_supply_class.txt +2
-0@@ -140,12 +144,24 @@ TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature. TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade. TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade. +MIN_TEMP - minimum operatable temperature +MAX_TEMP - maximum operatable temperature
TEMP_MAX, TEMP_MIN. Be consistent with the rest of the properties...
RE: [PATCH 1/7] power_supply: Add charger control properties
Anton,
Quoted 5 lines
But do we really want to control the chargers through the power_supply's user-visible interface? It makes the whole power supply thing so complicated that I'm already losing track of it. Right now I think I would prefer to move all the charger logic out of the psy class.
I think exposing properties make the logic generic, otherwise it may end up in having callback functions. Also there are some scenarios where the charging algorithm has to be in the user space. If the driver need to remove the control interface from the user space, it can use property_is_writeable callback. Using standard power supply properties, provide the flexibility to interface the charging algorithms from the user space or the kernel space. This makes the charger driver implementation simple - it just need to register with psy class, no extra API or callback required.
Quoted 18 lines
More specifically, this code:
Review int power_supply_register(struct device *parent, struct
Quoted 1 line
(quoted diff) +0
-0@@ -561,6 +575,11 @@ int power_supply_register(struct device *parent, struct
power_supply*psy)Review int power_supply_register(struct device *parent, struct · line 582
Quoted 8 lines
(quoted diff) +5
-0if (rc) goto create_triggers_failed; + if (psy_is_charger(psy)) + rc = power_supply_register_charger(psy); + if (rc) + pr_debug("device: '%s': power_supply_register_charger failed\n", + dev_name(dev));I have a weird feeling about the fact that the
power_supply_register()registers a charger. OK, we have thermal stuff registration there, but it is completely different. We have the cooling device registration there as well, and this stuff would be really nice to move out to some "chargers subsystem".
Quoted 6 lines
So, Jenny, the question is: can we separate chargers logic from the power supply? So that we don't have "charger enable"/"charger disable" knobs in the psy class itself. It is still fine if you need to have some interface to the psy class so that the chargers subsystem would interface with it, though. But I think that charger drivers have to register itself with two
subsystems: chargers andpower_supply(optionally).
If your concern is in clubbing the charger framework related changes with psy class, then I have an alternate proposal. Using the patch https://lkml.org/lkml/2013/7/25/204,
the power supply change notification can be broadcasted. We can add notifier events for power_supply_register and thermal throttling. This way power_supply_charger.c can be a separate driver and it can listen to psy notifications to take actions.
Quoted 35 lines
Thanks,
Anton
Quoted 15 lines
Signed-off-by Jenny TC <[email protected]>Change-Id: Id91dbbd8f34499afa97b7d8f11ecf5467847f6a8
--- Documentation/power/power_supply_class.txt | 16 ++++++++++++++++ drivers/power/power_supply_sysfs.c | 8 ++++++++ include/linux/power_supply.h | 8 ++++++++ 3 files changed, 32 insertions(+)Documentation/power/power_supply_class.txt +0
-0Documentation/power/power_supply_class.txt relative, time-based measurements. · line 119
Quoted 2 lines
Documentation/power/power_supply_class.txt +0
-0@@ -118,6 +118,10 @@ relative, time-based measurements. CONSTANT_CHARGE_CURRENT - constant charge current programmed by charger. CONSTANT_CHARGE_CURRENT_MAX - maximum charge current supported bythe
Documentation/power/power_supply_class.txt
Quoted 8 lines
power supply object.
Documentation/power/power_supply_class.txt +4
-0+INPUT_CURRENT_LIMIT - input current limit programmed by charger. +Indicates the current drawn from a charging source. +CHARGE_TERM_CUR - Charge termination current used to detect the end +of charge condition CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger. CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported bythe
Documentation/power/power_supply_class.txt TEMP_ALERT_MAX - maximum battery temperature alert
Quoted 1 line
Documentation/power/power_supply_class.txt +0
-0@@ -140,12 +144,24 @@ TEMP_ALERT_MAX - maximum battery temperature alertvalue in milli centigrade.
Documentation/power/power_supply_class.txt TEMP_ALERT_MAX - maximum battery temperature alert · line 145
Quoted 2 lines
Documentation/power/power_supply_class.txt +0
-0TEMP_AMBIENT - ambient temperature. TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli
Quoted 7 lines
centigrade.
Documentation/power/power_supply_class.txt TEMP_ALERT_MAX - maximum battery temperature alert · line 146
Quoted 1 line
Documentation/power/power_supply_class.txt +0
-0TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in millicentigrade.
Documentation/power/power_supply_class.txt TEMP_ALERT_MAX - maximum battery temperature alert · line 148
Quoted 2 lines
Documentation/power/power_supply_class.txt +2
-0+MIN_TEMP - minimum operatable temperature MAX_TEMP - maximum +operatable temperature
TEMP_MAX,TEMP_MIN. Be consistent with the rest of the properties...
Agreed. Will fix it ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Re: [PATCH 1/7] power_supply: Add charger control properties
Quoted 11 lines · Jenny
Quoted 5 lines
But do we really want to control the chargers through the power_supply's user-visible interface? It makes the whole power supply thing so complicated that I'm already losing track of it. Right now I think I would prefer to move all the charger logic out of the psy class.
I think exposing properties make the logic generic, otherwise it may end up in having callback functions.
Also there are some scenarios where the charging algorithm has to be in the user space.
Which scenarios?
Plus, I am more questioning if the power supply framework is the right thing to control the *chargers*. Chargers are not the power supply to the system or any device (well, except for the batteries themselves).
Quoted 4 lines
Using the patch https://lkml.org/lkml/2013/7/25/204,
the power supply change notification can be broadcasted. We can add notifier events forpower_supply_registerand thermal throttling. This waypower_supply_charger.ccan be a separate driver and it can listen to psy notifications to take actions.
If you ever need this particular notifier, I am OK with it (but I'll consider applying it only together with some its users).
Basically, I am more against these three patches:
[PATCH 3/7] power_supply: add throttle state
[PATCH 2/7] power_supply: add charger cable properties
[PATCH 1/7] power_supply: Add charger control properties (enable_charger part)
These three add too much "charger" specifics to the power_supply stuff. I think they deserve their own subsystem/class/whatever.
Also, the battid framework is written without any notion of device/driver separation, uses global variables, and I suspect it should not exist at all (psy_get_batt_prop function makes me think that you should just register the i2c/spi/w1 battery with the power_supply and not use the ad-hoc stuff).
Anton
Re: [PATCH 1/7] power_supply: Add charger control properties
Quoted 10 lines · On Sun, 27 Oct 2013 23:18:08 -0700 Anton Vorontsov <[email protected]> wrote:
Quoted 9 lines · Jenny
Quoted 5 lines
But do we really want to control the chargers through the power_supply's user-visible interface? It makes the whole power supply thing so complicated that I'm already losing track of it. Right now I think I would prefer to move all the charger logic out of the psy class.
I think exposing properties make the logic generic, otherwise it may end up in having callback functions.
Quoted 8 lines
Quoted 2 lines
Also there are some scenarios where the charging algorithm has to be in the user space.
Which scenarios?
Plus, I am more questioning if the power supply framework is the right thing to control the *chargers*. Chargers are not the power supply to the system or any device (well, except for the batteries themselves).
I'm not sure this is (always) true.
On my device (gta04.org) the battery, the USB OTG port, and a separate 5VDC input can each be the power source of the whole device.
The USB and 5VDC cannot both be active concurrently, but either can be active together with the battery.
The device can function without the battery, so the charger plugged into the USB-OTG must be supplying power to the system (not just the battery).
The "charger" functionality sits between the battery and the external power supply monitoring the voltage on the battery and the current from the external supply. Based on these values (and some timers and a state machine) it enabled or disables the external supply and possibly imposes a current-limit on it.
The three power sources all have "power_supply" devices registered (though the battery only does because it contains a bq27000 charger counter). I've been wondering where to put sysfs attributes to control the charging. I currently place them in the power_supply device for each external power source.
That makes some sense for the 'current limit' value, but not for the 'battery volts at which to re-start charging' value.
There is also a setting which affects whether the external source is switched off if the voltage drops below 4.4V. In some circumstances I want to leave the charger enabled then, as it could just mean the cyclist is taking a break and there should be current again soon.
I think the sensible place for these tune-ables is with the battery. i.e. the power_supply that corresponds to the battery could register "min voltage" and "min current".
The charger driver needs to know about this battery and about any power sources that can charge it, and uses the state of the battery to decide how to tune the state of the charger.
I note that there is already something a lot like this between
88pm860x_battery.c
and
88pm860x_charger.c
They manage to locate each other and the charger call get_property and set_property on the battery.
Maybe formalising this might be a useful way forward.
I'm not sure that we really need a new driver-class for chargers. Maybe just a way to link external power supplies to battery power supplies, and maybe some agreement on what they are allowed to say to each other.
Jenny: would something like that work for you??
Thanks,
NeilBrown
Quoted 30 lines
Quoted 5 lines
Using the patch https://lkml.org/lkml/2013/7/25/204,
the power supply change notification can be broadcasted. We can add notifier events forpower_supply_registerand thermal throttling. This waypower_supply_charger.ccan be a separate driver and it can listen to psy notifications to take actions.If you ever need this particular notifier, I am OK with it (but I'll consider applying it only together with some its users).
Basically, I am more against these three patches:
[PATCH 3/7]
power_supply: add throttle state
[PATCH 2/7]power_supply: add charger cable properties
[PATCH 1/7]power_supply: Add charger control properties (enable_chargerpart)These three add too much "charger" specifics to the
power_supplystuff. I think they deserve their own subsystem/class/whatever.Also, the battid framework is written without any notion of device/driver separation, uses global variables, and I suspect it should not exist at all (
psy_get_batt_propfunction makes me think that you should just register the i2c/spi/w1 battery with thepower_supplyand not use the ad-hoc stuff).Anton
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 2/7 power_supply : add charger cable properties
In reply to Jenny TCSince the charger cables are related to power supply subsystem it makes sense to define the properties associate with charger cables. The properties include cable events and the input current. The cable properties may come from different sources. Since they are associated with power_supply subsystem, it make sense to unify the properties in the power supply susbsyem layer.
Also a charger can support different types of charger sources (cables). It make sense to define a field to inform the power supply subsystem what kind of cable a charger driver supports. Since a bitmask would be the easy way to do define, it's good to have a enum which has the bitmask definition for each cable types
--- include/linux/power_supply.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
include/linux/power_supply.h +38 -0
@@ -166,6 +166,43 @@ enum power_supply_type { POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */ }; +enum psy_charger_cable_event { +PSY_CHARGER_CABLE_EVENT_CONNECT =0 , +PSY_CHARGER_CABLE_EVENT_UPDATE , +PSY_CHARGER_CABLE_EVENT_RESUME , +PSY_CHARGER_CABLE_EVENT_SUSPEND , +PSY_CHARGER_CABLE_EVENT_DISCONNECT , +}; + +enum psy_charger_cable_type { +PSY_CHARGER_CABLE_TYPE_NONE =0 , +PSY_CHARGER_CABLE_TYPE_USB_SDP =1 <<0 , +PSY_CHARGER_CABLE_TYPE_USB_DCP =1 <<1 , +PSY_CHARGER_CABLE_TYPE_USB_CDP =1 <<2 , +PSY_CHARGER_CABLE_TYPE_USB_ACA =1 <<3 , +PSY_CHARGER_CABLE_TYPE_AC =1 <<4 , +PSY_CHARGER_CABLE_TYPE_ACA_DOCK =1 <<5 , +PSY_CHARGER_CABLE_TYPE_ACA_A =1 <<6 , +PSY_CHARGER_CABLE_TYPE_ACA_B =1 <<7 , +PSY_CHARGER_CABLE_TYPE_ACA_C =1 <<8 , +PSY_CHARGER_CABLE_TYPE_SE1 =1 <<9 , +PSY_CHARGER_CABLE_TYPE_MHL =1 <<10 , +PSY_CHARGER_CABLE_TYPE_B_DEVICE =1 <<11 , +}; + +struct psy_cable_props { +enum psy_charger_cable_event chrg_evt; +enum psy_charger_cable_type chrg_type; +unsigned int mA;/* input current limit */ +}; + +#define PSY_CHARGER_CABLE_TYPE_USB \ + (PSY_CHARGER_CABLE_TYPE_USB_SDP | \ + PSY_CHARGER_CABLE_TYPE_USB_DCP | \ + PSY_CHARGER_CABLE_TYPE_USB_CDP | \ + PSY_CHARGER_CABLE_TYPE_USB_ACA | \ + PSY_CHARGER_CABLE_TYPE_ACA_DOCK) +union power_supply_propval {int intval;const char *strval;
@@ -181,6 +218,7 @@ struct power_supply {char **supplied_to;size_t num_supplicants; +unsigned long supported_cables;char **supplied_from;size_t num_supplies;
Signature · 1 line
1.7.9.5
PATCH 3/7 power_supply: add throttle state
In reply to Jenny TCThe charger and battery temperature contribute to the platform thermal. The only way to control the temperature
is to control the charging. The charging can be controlled in different way. This could be disabling charger, disabling charging, adjusting CC, or by adjusting the INLMT. This patch adds a structure to define the charger throttle actions. Also this patch adds a throttle_states field to the struct power_supply which can be used by the charger driver to define it's throttle actions for different states
--- include/linux/power_supply.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/linux/power_supply.h +15 -0
@@ -210,6 +210,18 @@ union power_supply_propval {struct device_node ; +enum psy_throttle_action { + +PSY_THROTTLE_DISABLE_CHARGER =0 , +PSY_THROTTLE_DISABLE_CHARGING , +PSY_THROTTLE_CC_LIMIT , +PSY_THROTTLE_INPUT_LIMIT , +}; + +struct psy_throttle_state { +enum psy_throttle_action throttle_action; +unsigned throttle_val; +};struct power_supply {const char *name;enum power_supply_type type;
@@ -224,6 +236,9 @@ struct power_supply {size_t num_supplies;struct device_node *of_node; +struct psy_throttle_state *throttle_states; +size_t num_throttle_states; +int (*get_property)(struct power_supply *psy,enum power_supply_property psp,union power_supply_propval *val);
Signature · 1 line
1.7.9.5
PATCH 4/7 power_supply: Add power_supply notifier
In reply to Jenny TCThis patch adds a notifier chain to the power_supply.
This notifier helps drivers in other subsystem to listen to changes in power supply subsystem. This would help to take some actions in those drivers on changing the power supply properties. One such scenario is to increase/decrease system performance based on the battery capacity/voltage. Another scenario is to adjust the h/w peak current detection voltage/current thresholds based on battery voltage/capacity. The notifier helps drivers to listen to changes in power_suppy susbystem without polling the power_supply properties
--- drivers/power/power_supply_core.c | 17 +++++++++++++++++ include/linux/power_supply.h | 10 ++++++++++ 2 files changed, 27 insertions(+)
drivers/power/power_supply_core.c +17 -0
@@ -24,6 +24,9 @@struct class *power_supply_class;EXPORT_SYMBOL_GPL (power_supply_class); +ATOMIC_NOTIFIER_HEAD (power_supply_notifier); +EXPORT_SYMBOL_GPL (power_supply_notifier); +static struct device_type power_supply_dev_type; static bool __power_supply_is_supplied_by(struct power_supply *supplier,
@@ -80,6 +83,8 @@ static void power_supply_changed_work(struct work_struct *work)class_for_each_device (power_supply_class,NULL , psy, __power_supply_changed_work);power_supply_update_leds (psy); +atomic_notifier_call_chain (&power_supply_notifier, +PSY_EVENT_PROP_CHANGED , psy);kobject_uevent (&psy->dev->kobj,KOBJ_CHANGE );spin_lock_irqsave (&psy->changed_lock, flags); }
@@ -347,6 +352,18 @@ static void power_supply_dev_release(struct device *dev)kfree (dev); } +int power_supply_reg_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&power_supply_notifier, nb); +} +EXPORT_SYMBOL_GPL (power_supply_reg_notifier); + +void power_supply_unreg_notifier (struct notifier_block *nb) +{ +atomic_notifier_chain_unregister (&power_supply_notifier, nb); +} +EXPORT_SYMBOL_GPL (power_supply_unreg_notifier); +#ifdef CONFIG_THERMAL static int power_supply_read_temp (struct thermal_zone_device *tzd,unsigned long *temp)
include/linux/power_supply.h +10 -0
@@ -218,6 +218,13 @@ enum psy_throttle_action { PSY_THROTTLE_INPUT_LIMIT, }; +enum power_supply_notifier_events { +PSY_EVENT_NONE , +PSY_EVENT_PROP_CHANGED , +PSY_EVENT_BATTERY , +PSY_EVENT_CABLE , +}; +struct psy_throttle_state {enum psy_throttle_action throttle_action;unsigned throttle_val;
@@ -296,6 +303,9 @@ struct power_supply_info {int use_for_apm; }; +extern struct atomic_notifier_head power_supply_notifier; +extern int power_supply_reg_notifier (struct notifier_block *nb); +extern void power_supply_unreg_notifier (struct notifier_block *nb);extern struct power_supply *power_supply_get_by_name (const char *name);extern void power_supply_changed (struct power_supply *psy);extern int power_supply_am_i_supplied (struct power_supply *psy);
Signature · 1 line
1.7.9.5
PATCH 5/7 power_supply : Introduce battery identification framework
In reply to Jenny TCThis patch introduces generic battid framework. Different battid drivers sitting on different linux kernel subsystem (1wire, I2C, SFI etc) can interface with the power supply susbsytem using the APIs exposed in the power supply usbsystem. The consumers (charger driver/battery driver/power management drivers) can register for notification from the battery id drivers using the APIs from this framework
--- Documentation/power/power_supply_class.txt | 12 ++++ drivers/power/Kconfig | 8 +++ drivers/power/Makefile | 1 + drivers/power/battery_id.c | 87 ++++++++++++++++++++++++++++ include/linux/power/battery_id.h | 55 ++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 drivers/power/battery_id.c create mode 100644 include/linux/power/battery_id.h
Documentation/power/power_supply_class.txt +12 -0
@@ -177,6 +177,18 @@ External power supply (AC) lists supplicants (batteries) names in issued by external power supply will notify supplicants via external_power_changed callback. +Reading Battery charging profile +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Power Supply class battery identification framework (battery_id.c) +exposes APIs to retrieve battery profile of a battery. The battery +profile can be read by battery identification driver which may be +1wire/I2C/SFI driver. Battery identification driver can register +the battery profile with the power supply class using the API +psy_battery_prop_changed(). The framework also exposes API +psy_get_batt_prop() to retrieve the battery profile which can be +used by power supply drivers to setup the charging. Also drivers +can register for battery removal/insertion notifications using +power_supply_reg_notifier() QA ~~
drivers/power/Kconfig +8 -0
@@ -8,6 +8,14 @@ menuconfig POWER_SUPPLY if POWER_SUPPLY +config POWER_SUPPLY_BATTID + bool "Power Supply Battery Identification Framework" + help + Say Y here to enable the power supply battery idnetification + framework. The framework would allow different battery identification + drivers to interface with power supply subsystem. Also it allows consumer + drivers to register for notification from the power_supply subsystem. + config POWER_SUPPLY_DEBUG bool "Power supply debug" help
drivers/power/Makefile +1 -0
@@ -3,6 +3,7 @@ ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG power_supply-y := power_supply_core.o power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o +power_supply-$(CONFIG_POWER_SUPPLY_BATTID) += battery_id.o obj-$(CONFIG_POWER_SUPPLY) += power_supply.o obj-$(CONFIG_GENERIC_ADC_BATTERY) += generic-adc-battery.o
drivers/power/battery_id.c new file +87 -0
87 lines not on this page · raw message
include/linux/power/battery_id.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 6/7 power_supply: Introduce Power Supply charging framework
In reply to Jenny TCThe Power Supply charging framework connects multiple subsystems to do charging in a generic way. The subsystems involves power_supply, extcon, and thermal. With this the charging is handled in a generic way.
The framework makes use of different new features - Battery Identification framework, pluggable charging algorithms, charger cable arbitrations etc.
At present the charging is done based on the static battery characteristics. This is done at the boot time by passing the battery properties (max_voltage, capacity) etc. as platform data to the charger/battery driver. But new generation high volt batteries needs to be identified dynamically to do charging in a safe manner. The batteries are coming with different communication protocols. It become necessary to communicate with battery and identify it's charging profiles before setup charging
Also the charging algorithms can vary based on the battery characteristics and the platform characteristics. To handle charging in a generic way it's necessary to support pluggable charging algorithms. Charging framework uses selected algorithms based on the type of battery charging profile. This is a simple binding and can be improved later. This may be improved to select the algorithms based on the platform requirements. Also we can extend this framework to plug algorithms from the user space.
The framework also introduces the charger cable arbitration. A charger may supports multiple cables, but it may not be able to charge with multiple cables at a time. The arbitration logic inside the framework selects the cable based on it's capabilities and the maximum charge current the platform can support
Also this framework exposes features to control charging on different platform states. One such feature is thermal. The framework register with the thermal subsystem and control charging based on the thermal subsystem requirements.
Overall this framework removes the charging logic out of the charger driver and the charger driver can just listen to the request from the framework to set the charger properties. This can be implemented by exposing get_property and set property callbacks.
--- Documentation/power/power_supply_class.txt | 174 +++++ drivers/power/Kconfig | 10 + drivers/power/Makefile | 1 + drivers/power/power_supply.h | 21 + drivers/power/power_supply_charger.c | 1023 ++++++++++++++++++++++++++++ drivers/power/power_supply_charger.h | 130 ++++ drivers/power/power_supply_core.c | 21 + include/linux/power_supply.h | 264 +++++++ 8 files changed, 1644 insertions(+) create mode 100644 drivers/power/power_supply_charger.c create mode 100644 drivers/power/power_supply_charger.h
Documentation/power/power_supply_class.txt +174 -0
@@ -190,6 +190,180 @@ used by power supply drivers to setup the charging. Also drivers can register for battery removal/insertion notifications using power_supply_reg_notifier() +Use Charging Framework to setup charging +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Register the driver with the power_supply class and pass the + charging framework related parameters +* Expose set_property and get_property functions so that charging + framework can control the charging + +Registering charger driver with power supply class +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +struct power_supply_class psy_usb; +psy_usb.name = DEV_NAME; +psy_usb.type = POWER_SUPPLY_TYPE_USB; + +/* pointer to power supply property structure */ +psy_usb.properties = &psy_usb_props; +psy_usb.num_properties = ARRAY_SIZE(psy_usb_props); + +/* pointer to power supply get property function */ +psy_usb.get_property = psy_usb_get_property; + +/* pointer to power supply set property function */ +psy_usb.set_property = psy_usb_set_property; + +/* pointer to the supplied_to argument to indicate the batteries + to which this charger is supplying power */ +psy_usb.supplied_to = supplied_to; +psy_usb.num_supplicants = num_supplicants; + +/* Additional Interfaces to support charging framework */ + +/* pointer to throttle states */ +psy_usb.throttle_states = throttle_states; + +/* Number of throttle states */ +psy_usb.num_throttle_states = num_throttle_states; + +/* define supported cable types for this driver */ +psy_usb.supported_cables = POWER_SUPPLY_CHARGER_TYPE_USB; + +/* register with power_supply subsystem */ +power_supply_registe(device, &psy_usb); + +Properties exposed by charger driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* POWER_SUPPLY_PROP_ONLINE + * Read access using get_property_function + * Returns the online property set using the set_property function + * Write access using set_property function + * Expose the value through get_property_fucntion. +* POWER_SUPPLY_PROP_PRESENT + * Read access using get_property_function + * Returns the present property set using the set_property function + * Write access using set_property function + * Expose the value through get_property_fucntion. +* POWER_SUPPLY_PROP_HEALTH + * Read access using get_property_function + * Returns charger health +* POWER_SUPPLY_PROP_TYPE + * Read access using power_supply structure + * Returns charger type +* POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT + * Read access using get property + * Returns the present charge control limit + * Write access using set property + * Set charge control limit. + * Action: Driver is not expected to take any actions on this. + Instead need to expose this on the read interface. + Charging framework process this and notifies the + charging parameters accordingly. +* POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX + * Read access using get property + * Returns the maximum charge control limit +* POWER_SUPPLY_PROP_ENABLE_CHARGING + * Read access using get property + * Return 1 if charging is enabled else return 0 + * Write access using set property + * Enable/disable charging + * Action : Write h/w register to enable/disable charging +* POWER_SUPPLY_PROP_ENABLE_CHARGER + * Read access using get property + * Return 1 if charger is enabled else return 0 + * Write access using set property + * Enable/disable charger + * Action : Write h/w register to enable/disable charger +* POWER_SUPPLY_PROP_INLMT + * Read access using get property + * Returns the input current limit passed by set_property function + * Default value : 0 + * Write access using set property + * Set input current limit + * Action : Write h/w register to set the input current limit + based on the value +* POWER_SUPPLY_PROP_CHARGE_CURRENT + * Read access using get property + * Returns charge current passed by set_property function + * Default value : 0 + * Write access using set property + * Set charge current + * Action : Write h/w register to set the charge current based + on the value +* POWER_SUPPLY_PROP_CHARGE_VOLTAGE + * Read access using get property + * Returns charge voltage passed by set_property function + * Default value: 0 + * Write access using set property + * Set charge voltage + * Action : Write h/w register to set the charge voltage based + on the value +* POWER_SUPPLY_PROP_CHARGE_TERM_CUR + * Read access using get property + * Returns charge termination current passed by set_property function + * Default value : 0 + * Write access using set property + * Set charge termination current + * Action : Write h/w register to set the charge termination current + based on the value +* POWER_SUPPLY_PROP_CABLE_TYPE + * Read access using get property + * Returns cable type passed by set_property function + * Default value : POWER_SUPPLY_CABLE_TYPE_UNKNOWN + * Write access using set property + * Set cable type + * Action : Used by the driver to report POWER_SUPPLY_PROP_TYPE. + * Report POWER_SUPPLY_PROP_TYPE + * Set type field of struct power_supply based on the cable type +* POWER_SUPPLY_PROP_MIN_TEMP + * Read access using get property + * Returns minimum charging temperature passed by set_property + * Default value : Platform dependant + * Write access using set_property + * Set Minimum charging temperature + * Action : Write h/w register to set the minimum charging temperature + based on the value +* POWER_SUPPLY_PROP_MAX_TEMP + * Write access using set_property + * Set Maximum charging temperature + * Action : Write h/w register to set the maximum charging temperature + based on the value + * Read access using get property + * Returns maximum charging temperature passed by set_property + * Default value : Platform dependent +* POWER_SUPPLY_PROP_MAX_CHARGE_CURRENT + * Read access using get property + * Returns maximum charging current passed by set_property + * Default value : Platform dependent + * Write access using set_property + * Set Maximum charging current + * Action: Configure safety charging registers if any. If not no actions + expected for this. +* POWER_SUPPLY_PROP_MAX_CHARGE_VOLTAGE + * Read access using get property + * Returns maximum charging current passed by set_property + * Default value : Platform dependent + * Write access using set_property + * Set Maximum charging voltage + * Action: Configure safety charging registers if any. If not, + no actions expected for this. +Registering new charging alogorithm +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Populate algorithm structure + struct psy_charging_algo new_algo; + /* populate the type charging profile the algorithm handles */ + pse_algo.chrg_prof_type = PSY_CHRG_PROF_PSE; + pse_algo.name = "my_algo"; + /* callback function to retrieve CC and CV */ + pse_algo.get_next_cc_cv = my_algo_get_next_cc_cv; + /* callback function to retreive battery thresholds */ + pse_algo.get_batt_thresholds = my_algo__get_bat_thresholds; + /* register charging algorithm */ + power_supply_register_charging_algo(&pse_algo); + +When the type of charging profile reported by battery and algorithm matches, +the algorithm will be invoked to get the charging parameters. + QA ~~ Q: Where is POWER_SUPPLY_PROP_XYZ attribute?
drivers/power/Kconfig +10 -0
@@ -8,6 +8,16 @@ menuconfig POWER_SUPPLY if POWER_SUPPLY +config POWER_SUPPLY_CHARGER + bool "Power Supply Charger" + select EXTCON + select POWER_SUPPLY_BATTID + help + Say Y here to enable the power supply charger framework. Charger + framework supports charging in a generic way. This allows the charger + drivers to keep the charging logic outside and the charger driver + just need to abstract the charger hardware + config POWER_SUPPLY_BATTID bool "Power Supply Battery Identification Framework" help
drivers/power/Makefile +1 -0
@@ -3,6 +3,7 @@ ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG power_supply-y := power_supply_core.o power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o +power_supply-$(CONFIG_POWER_SUPPLY_CHARGER) += power_supply_charger.o power_supply-$(CONFIG_POWER_SUPPLY_BATTID) += battery_id.o obj-$(CONFIG_POWER_SUPPLY) += power_supply.o
drivers/power/power_supply.h +21 -0
@@ -40,3 +40,24 @@ static inline int power_supply_create_triggers(struct power_supply *psy)static inline void power_supply_remove_triggers (struct power_supply *psy) {}#endif /* CONFIG_LEDS_TRIGGERS */ +#ifdef CONFIG_POWER_SUPPLY_CHARGER + +extern void power_supply_trigger_charging_handler (struct power_supply *psy); +extern int power_supply_register_charger (struct power_supply *psy); +extern int power_supply_unregister_charger (struct power_supply *psy); +extern int psy_charger_throttle_charger (struct power_supply *psy, +unsigned long state); + +#else + +static inline void +power_supply_trigger_charging_handler (struct power_supply *psy) { } +static inline int power_supply_register_charger (struct power_supply *psy) +{return 0 ; } +static inline int power_supply_unregister_charger (struct power_supply *psy) +{return 0 ; } +static inline int psy_charger_throttle_charger (struct power_supply *psy, +unsigned long state) +{return 0 ; } + +#endif
drivers/power/power_supply_charger.c new file +1023 -0
1,023 lines not on this page · raw message
drivers/power/power_supply_charger.h new file +130 -0
130 lines not on this page · raw message
drivers/power/power_supply_core.c +21 -0
@@ -19,6 +19,7 @@#include <linux/power_supply.h> #include <linux/thermal.h> #include "power_supply.h" +#include "power_supply_charger.h" /* exported for the APM Power driver, APM emulation */ struct class *power_supply_class;
@@ -83,6 +84,7 @@ static void power_supply_changed_work(struct work_struct *work)class_for_each_device (power_supply_class,NULL , psy, __power_supply_changed_work);power_supply_update_leds (psy); +power_supply_trigger_charging_handler (psy);atomic_notifier_call_chain (&power_supply_notifier,PSY_EVENT_PROP_CHANGED , psy);kobject_uevent (&psy->dev->kobj,KOBJ_CHANGE );
@@ -102,6 +104,18 @@ void power_supply_changed(struct power_supply *psy) {unsigned long flags; +/* If psy == NULL, invoke charging handler. This can be +* used by drivers to notify charging framework without +* notifying the user space. This would avoid frequent +* wakeup of the user space stack when charger/battery +* driver notifies the framework. +*/ + +if (psy ==NULL ) { +power_supply_trigger_charging_handler (psy); +return ; + } +dev_dbg (psy->dev,"%s\n" , __func__);spin_lock_irqsave (&psy->changed_lock, flags);
@@ -561,6 +575,11 @@ int power_supply_register(struct device *parent, struct power_supply *psy)if (rc) goto create_triggers_failed; +if (psy_is_charger (psy)) + rc =power_supply_register_charger (psy); +if (rc) +pr_debug ("device: '%s': power_supply_register_charger failed\n" , +dev_name (dev));power_supply_changed (psy); goto success;
@@ -586,6 +605,8 @@ void power_supply_unregister(struct power_supply *psy)cancel_work_sync (&psy->changed_work);sysfs_remove_link (&psy->dev->kobj,"powers" );power_supply_remove_triggers (psy); +if (psy_is_charger (psy)) +power_supply_unregister_charger (psy);psy_unregister_cooler (psy);psy_unregister_thermal (psy);device_init_wakeup (psy->dev, false);
include/linux/power_supply.h +264 -0
268 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 7/7 power_supply: Introduce PSE compliant algorithm
In reply to Jenny TCAs per PSE standard the battery characteristics and thereby the charging rates can vary on different temperature zones. This patch introduces a PSE compliant charging algorithm with maintenance charging support. The algorithm can be selected by the charging framework based on the type of the battery charging profile.
--- drivers/power/Kconfig | 12 ++ drivers/power/Makefile | 1 + drivers/power/charging_algo_pse.c | 202 ++++++++++++++++++++++++++++++++++ drivers/power/power_supply_charger.c | 12 -- include/linux/power/battery_id.h | 45 ++++++++ 5 files changed, 260 insertions(+), 12 deletions(-) create mode 100644 drivers/power/charging_algo_pse.c
drivers/power/Kconfig +12 -0
@@ -18,6 +18,18 @@ config POWER_SUPPLY_CHARGER drivers to keep the charging logic outside and the charger driver just need to abstract the charger hardware +config POWER_SUPPLY_CHARGING_ALGO_PSE + bool "PSE compliant charging algorithm" + help + Say Y here to select PSE compliant charging algorithm. As per PSE + standard the battery characteristics and thereby the charging rates + can vary on different temperature zones. This config will enable PSE + compliant charging algorithm with maintenance charging support. The + algorithm can be selected by the charging framework based on the type + of the battery charging profile. + + depends on POWER_SUPPLY_CHARGER + config POWER_SUPPLY_BATTID bool "Power Supply Battery Identification Framework" help
drivers/power/Makefile +1 -0
@@ -9,6 +9,7 @@ power_supply-$(CONFIG_POWER_SUPPLY_BATTID) += battery_id.o obj-$(CONFIG_POWER_SUPPLY) += power_supply.o obj-$(CONFIG_GENERIC_ADC_BATTERY) += generic-adc-battery.o +obj-$(CONFIG_POWER_SUPPLY_CHARGING_ALGO_PSE) += charging_algo_pse.o obj-$(CONFIG_PDA_POWER) += pda_power.o obj-$(CONFIG_APM_POWER) += apm_power.o obj-$(CONFIG_MAX8925_POWER) += max8925_power.o
drivers/power/charging_algo_pse.c new file +202 -0
202 lines not on this page · raw message
drivers/power/power_supply_charger.c +0 -12
@@ -988,18 +988,6 @@ int power_supply_unregister_charging_algo(struct psy_charging_algo *algo) }EXPORT_SYMBOL (power_supply_unregister_charging_algo); -static struct psy_charging_algo *get_charging_algo_byname (char *algo_name) -{ -struct psy_charging_algo *algo; - -list_for_each_entry (algo, &algo_list, node) { -if (!strcmp (algo->name, algo_name)) -return algo; - } - -return NULL ; -} -static struct psy_charging_algo *get_charging_algo_by_type (enum psy_batt_chrg_prof_type chrg_prof_type) {
include/linux/power/battery_id.h +45 -0
57 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 7/7] power_supply: Introduce PSE compliant algorithm
On Mon, Sep 23, 2013 at 11:34:05PM +0530, Jenny TC wrote:
[...]
Quoted 13 lines
include/linux/power/battery_id.h +13
-0+#define BATTID_STR_LEN 8 +#define BATT_TEMP_NR_RNG 6 +/* Charging Profile */ +struct psy_ps_pse_mod_prof { +/* battery id */ +char batt_id[BATTID_STR_LEN ]; +/* type of battery */ +u16 battery_type; +u16 capacity; +u16 voltage_max; +/* charge termination current */ +u16 chrg_term_mA; +/* Low battery level voltage */
include/linux/power/battery_id.h struct psy_ps_batt_chg_prof { · line 84
Quoted 10 lines
include/linux/power/battery_id.h +10
-0+u16 low_batt_mV; +/* upper and lower temperature limits on discharging */ +u8 disch_tmp_ul; +u8 disch_tmp_ll; +/* number of temperature monitoring ranges */ +u16 temp_mon_ranges; +struct psy_ps_temp_chg_table temp_mon_range[BATT_TEMP_NR_RNG ]; +/* Lowest temperature supported */ +short int temp_low_lim; +} __packed;
These all seem like properties of a battery. Why the battery is not registered with the power_supply framework?
What is PSE, by the way?
Anton
Anton,
Could you please review these patches?
-Jenny
Quoted 48 lines
-----Original Message-----
From: Tc, Jenny
Sent: Monday, September 23, 2013 11:34 PM
To: [email protected]; Anton Vorontsov; Anton Vorontsov
Cc: Tc, Jenny
Subject: [PATCH 0/7]power_supply: Introduce Power Supply Charging FrameworkThe Power Supply charging framework connects multiple subsystems to do charging in a generic way. The framework makes use of different new features - Battery Identification framework, pluggable charging algorithms, charger cable arbitrations. PSE compliant charging algorithm also enabled as part of this patch set.
With this framework the charging logic can be kept outside the charger driver.The charger driver just need to expose th
get_propertyandset_propertyfunctions to get and set a specific set of power supply properties. The driver can convert these values to the hardware configurations to setup charging.Jenny TC (7):
power_supply: Add charger control propertiespower_supply: add charger cable properties
power_supply: add throttle state
power_supply: Addpower_supplynotifierpower_supply: Introduce battery identification framework
power_supply: Introduce Power Supply charging framework
power_supply: Introduce PSE compliant algorithmDocumentation/power/power_supply_class.txt | 202 ++++++ drivers/power/Kconfig | 30 + drivers/power/Makefile | 3 + drivers/power/battery_id.c | 87 +++ drivers/power/charging_algo_pse.c | 202 ++++++ drivers/power/power_supply.h | 21 + drivers/power/power_supply_charger.c | 1011 ++++++++++++++++++++++++++++ drivers/power/power_supply_charger.h | 130 ++++ drivers/power/power_supply_core.c | 38 ++ drivers/power/power_supply_sysfs.c | 8 + include/linux/power/battery_id.h | 100 +++ include/linux/power_supply.h | 335 +++++++++ 12 files changed, 2167 insertions(+) create mode 100644 drivers/power/battery_id.c create mode 100644 drivers/power/charging_algo_pse.c create mode 100644 drivers/power/power_supply_charger.c create mode 100644 drivers/power/power_supply_charger.h create mode 100644 include/linux/power/battery_id.h--
1.7.9.5