From c3503fd02558245ebbb0b48f3ae1d62416e3fd2a Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 10 Aug 2011 21:45:36 +0100 Subject: olpc_battery: Bind to device tree This is cleaner, and allows suspend/resume (wakeup) handlers to be added in an upcoming patch. Signed-off-by: Daniel Drake Acked-by: Andres Salomon Signed-off-by: Anton Vorontsov --- Documentation/devicetree/bindings/power_supply/olpc_battery.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Documentation/devicetree/bindings/power_supply/olpc_battery.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power_supply/olpc_battery.txt b/Documentation/devicetree/bindings/power_supply/olpc_battery.txt new file mode 100644 index 00000000000..c8901b3992d --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/olpc_battery.txt @@ -0,0 +1,5 @@ +OLPC battery +~~~~~~~~~~~~ + +Required properties: + - compatible : "olpc,xo1-battery" -- cgit v1.2.3 From 6c75ea1e582d12120072cae742a0d63ea8ac8c65 Mon Sep 17 00:00:00 2001 From: Rhyland Klein Date: Wed, 14 Sep 2011 13:19:07 -0700 Subject: bq20z75: Devicetree init support Adding support to generate platform data when kernel is configured through device tree. Also adding the binding for the TI bq20z75 fuel gadge and the bq20z75 driver. Signed-off-by: Rhyland Klein Acked-by: Grant Likely Signed-off-by: Anton Vorontsov --- .../bindings/power_supply/ti_bq20z75.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt b/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt new file mode 100644 index 00000000000..7571294f411 --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt @@ -0,0 +1,23 @@ +TI bq20z75 +~~~~~~~~~~ + +Required properties : + - compatible : "ti,bq20z75" + +Optional properties : + - ti,i2c-retry-count : The number of times to retry i2c transactions on i2c + IO failure. + - ti,poll-retry-count : The number of times to try looking for new status + after an external change notification. + - ti,battery-detect-gpios : The gpio which signals battery detection and + a flag specifying its polarity. + +Example: + + bq20z75@b { + compatible = "ti,bq20z75"; + reg = < 0xb >; + ti,i2c-retry-count = <2>; + ti,poll-retry-count = <10>; + ti,battery-detect-gpios = <&gpio-controller 122 1>; + } -- cgit v1.2.3 From 3bb3dbbd56ea39e5537db8f8041ea95d28f16a7f Mon Sep 17 00:00:00 2001 From: Donggeun Kim Date: Tue, 27 Dec 2011 18:47:48 +0900 Subject: power_supply: Add initial Charger-Manager driver Because battery health monitoring should be done even when suspended, it needs to wake up and suspend periodically. Thus, userspace battery monitoring may incur too much overhead; every device and task is woken up periodically. Charger Manager uses suspend-again to provide in-suspend monitoring. This patch allows to monitor battery health in-suspend state. Signed-off-by: Donggeun Kim Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park Signed-off-by: Anton Vorontsov --- Documentation/power/charger-manager.txt | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Documentation/power/charger-manager.txt (limited to 'Documentation') diff --git a/Documentation/power/charger-manager.txt b/Documentation/power/charger-manager.txt new file mode 100644 index 00000000000..081489f3db2 --- /dev/null +++ b/Documentation/power/charger-manager.txt @@ -0,0 +1,149 @@ +Charger Manager + (C) 2011 MyungJoo Ham , GPL + +Charger Manager provides in-kernel battery charger management that +requires temperature monitoring during suspend-to-RAM state +and where each battery may have multiple chargers attached and the userland +wants to look at the aggregated information of the multiple chargers. + +Charger Manager is a platform_driver with power-supply-class entries. +An instance of Charger Manager (a platform-device created with Charger-Manager) +represents an independent battery with chargers. If there are multiple +batteries with their own chargers acting independently in a system, +the system may need multiple instances of Charger Manager. + +1. Introduction +=============== + +Charger Manager supports the following: + +* Support for multiple chargers (e.g., a device with USB, AC, and solar panels) + A system may have multiple chargers (or power sources) and some of + they may be activated at the same time. Each charger may have its + own power-supply-class and each power-supply-class can provide + different information about the battery status. This framework + aggregates charger-related information from multiple sources and + shows combined information as a single power-supply-class. + +* Support for in suspend-to-RAM polling (with suspend_again callback) + While the battery is being charged and the system is in suspend-to-RAM, + we may need to monitor the battery health by looking at the ambient or + battery temperature. We can accomplish this by waking up the system + periodically. However, such a method wakes up devices unncessary for + monitoring the battery health and tasks, and user processes that are + supposed to be kept suspended. That, in turn, incurs unnecessary power + consumption and slow down charging process. Or even, such peak power + consumption can stop chargers in the middle of charging + (external power input < device power consumption), which not + only affects the charging time, but the lifespan of the battery. + + Charger Manager provides a function "cm_suspend_again" that can be + used as suspend_again callback of platform_suspend_ops. If the platform + requires tasks other than cm_suspend_again, it may implement its own + suspend_again callback that calls cm_suspend_again in the middle. + Normally, the platform will need to resume and suspend some devices + that are used by Charger Manager. + +2. Global Charger-Manager Data related with suspend_again +======================================================== +In order to setup Charger Manager with suspend-again feature +(in-suspend monitoring), the user should provide charger_global_desc +with setup_charger_manager(struct charger_global_desc *). +This charger_global_desc data for in-suspend monitoring is global +as the name suggests. Thus, the user needs to provide only once even +if there are multiple batteries. If there are multiple batteries, the +multiple instances of Charger Manager share the same charger_global_desc +and it will manage in-suspend monitoring for all instances of Charger Manager. + +The user needs to provide all the two entries properly in order to activate +in-suspend monitoring: + +struct charger_global_desc { + +char *rtc_name; + : The name of rtc (e.g., "rtc0") used to wakeup the system from + suspend for Charger Manager. The alarm interrupt (AIE) of the rtc + should be able to wake up the system from suspend. Charger Manager + saves and restores the alarm value and use the previously-defined + alarm if it is going to go off earlier than Charger Manager so that + Charger Manager does not interfere with previously-defined alarms. + +bool (*rtc_only_wakeup)(void); + : This callback should let CM know whether + the wakeup-from-suspend is caused only by the alarm of "rtc" in the + same struct. If there is any other wakeup source triggered the + wakeup, it should return false. If the "rtc" is the only wakeup + reason, it should return true. +}; + +3. How to setup suspend_again +============================= +Charger Manager provides a function "extern bool cm_suspend_again(void)". +When cm_suspend_again is called, it monitors every battery. The suspend_ops +callback of the system's platform_suspend_ops can call cm_suspend_again +function to know whether Charger Manager wants to suspend again or not. +If there are no other devices or tasks that want to use suspend_again +feature, the platform_suspend_ops may directly refer to cm_suspend_again +for its suspend_again callback. + +The cm_suspend_again() returns true (meaning "I want to suspend again") +if the system was woken up by Charger Manager and the polling +(in-suspend monitoring) results in "normal". + +4. Charger-Manager Data (struct charger_desc) +============================================= +For each battery charged independently from other batteries (if a series of +batteries are charged by a single charger, they are counted as one independent +battery), an instance of Charger Manager is attached to it. + +struct charger_desc { + +enum polling_modes polling_mode; + : CM_POLL_DISABLE: do not poll this battery. + CM_POLL_ALWAYS: always poll this battery. + CM_POLL_EXTERNAL_POWER_ONLY: poll this battery if and only if + an external power source is attached. + CM_POLL_CHARGING_ONLY: poll this battery if and only if the + battery is being charged. + +unsigned int polling_interval_ms; + : Required polling interval in ms. Charger Manager will poll + this battery every polling_interval_ms or more frequently. + +enum data_source battery_present; + CM_FUEL_GAUGE: get battery presence information from fuel gauge. + CM_CHARGER_STAT: get battery presence from chargers. + +char **psy_charger_stat; + : An array ending with NULL that has power-supply-class names of + chargers. Each power-supply-class should provide "PRESENT" (if + battery_present is "CM_CHARGER_STAT"), "ONLINE" (shows whether an + external power source is attached or not), and "STATUS" (shows whether + the battery is {"FULL" or not FULL} or {"FULL", "Charging", + "Discharging", "NotCharging"}). + +int num_charger_regulators; +struct regulator_bulk_data *charger_regulators; + : Regulators representing the chargers in the form for + regulator framework's bulk functions. + +char *psy_fuel_gauge; + : Power-supply-class name of the fuel gauge. + +int (*temperature_out_of_range)(int *mC); + : This callback returns 0 if the temperature is safe for charging, + a positive number if it is too hot to charge, and a negative number + if it is too cold to charge. With the variable mC, the callback returns + the temperature in 1/1000 of centigrade. +}; + +5. Other Considerations +======================= + +At the charger/battery-related events such as battery-pulled-out, +charger-pulled-out, charger-inserted, DCIN-over/under-voltage, charger-stopped, +and others critical to chargers, the system should be configured to wake up. +At least the following should wake up the system from a suspend: +a) charger-on/off b) external-power-in/out c) battery-in/out (while charging) + +It is usually accomplished by configuring the PMIC as a wakeup source. -- cgit v1.2.3 From ad3d13eee78ec44194bf919a37e2f711e53cbdf0 Mon Sep 17 00:00:00 2001 From: Donggeun Kim Date: Tue, 27 Dec 2011 18:47:49 +0900 Subject: power_supply: Charger-Manager: Add properties for power-supply-class Charger Manager provides power-supply-class aggregating information from multiple chargers and a fuel-gauge. Signed-off-by: Donggeun Kim Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park Signed-off-by: Anton Vorontsov --- Documentation/power/charger-manager.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Documentation') diff --git a/Documentation/power/charger-manager.txt b/Documentation/power/charger-manager.txt index 081489f3db2..fdcca991df3 100644 --- a/Documentation/power/charger-manager.txt +++ b/Documentation/power/charger-manager.txt @@ -98,6 +98,11 @@ battery), an instance of Charger Manager is attached to it. struct charger_desc { +char *psy_name; + : The power-supply-class name of the battery. Default is + "battery" if psy_name is NULL. Users can access the psy entries + at "/sys/class/power_supply/[psy_name]/". + enum polling_modes polling_mode; : CM_POLL_DISABLE: do not poll this battery. CM_POLL_ALWAYS: always poll this battery. @@ -106,6 +111,12 @@ enum polling_modes polling_mode; CM_POLL_CHARGING_ONLY: poll this battery if and only if the battery is being charged. +unsigned int fullbatt_uV; + : If specified with a non-zero value, Charger Manager assumes + that the battery is full (capacity = 100) if the battery is not being + charged and the battery voltage is equal to or greater than + fullbatt_uV. + unsigned int polling_interval_ms; : Required polling interval in ms. Charger Manager will poll this battery every polling_interval_ms or more frequently. @@ -131,10 +142,13 @@ char *psy_fuel_gauge; : Power-supply-class name of the fuel gauge. int (*temperature_out_of_range)(int *mC); +bool measure_battery_temp; : This callback returns 0 if the temperature is safe for charging, a positive number if it is too hot to charge, and a negative number if it is too cold to charge. With the variable mC, the callback returns the temperature in 1/1000 of centigrade. + The source of temperature can be battery or ambient one according to + the value of measure_battery_temp. }; 5. Other Considerations -- cgit v1.2.3 From 1c84b60b813cb10476618b2311a89e31018b2cc4 Mon Sep 17 00:00:00 2001 From: Rhyland Klein Date: Mon, 5 Dec 2011 17:50:47 -0800 Subject: devicetree-bindings: Add vendor entry for Smart Battery Systems Signed-off-by: Rhyland Klein Signed-off-by: Anton Vorontsov --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index e8552782b44..9f7bef601e0 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -32,6 +32,7 @@ powervr Imagination Technologies qcom Qualcomm, Inc. ramtron Ramtron International samsung Samsung Semiconductor +sbs Smart Battery System schindler Schindler simtek sirf SiRF Technology, Inc. -- cgit v1.2.3 From e57f1b68c4066459ed9e49177cdcefa6973ce9d2 Mon Sep 17 00:00:00 2001 From: Rhyland Klein Date: Mon, 5 Dec 2011 17:50:48 -0800 Subject: devicetree-bindings: Propagate bq20z75->sbs rename to dt bindings Signed-off-by: Rhyland Klein Signed-off-by: Anton Vorontsov --- .../bindings/power_supply/sbs_sbs-battery.txt | 23 ++++++++++++++++++++++ .../bindings/power_supply/ti_bq20z75.txt | 23 ---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt delete mode 100644 Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt b/Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt new file mode 100644 index 00000000000..c40e8926fac --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt @@ -0,0 +1,23 @@ +SBS sbs-battery +~~~~~~~~~~ + +Required properties : + - compatible : "sbs,sbs-battery" + +Optional properties : + - sbs,i2c-retry-count : The number of times to retry i2c transactions on i2c + IO failure. + - sbs,poll-retry-count : The number of times to try looking for new status + after an external change notification. + - sbs,battery-detect-gpios : The gpio which signals battery detection and + a flag specifying its polarity. + +Example: + + bq20z75@b { + compatible = "sbs,sbs-battery"; + reg = < 0xb >; + sbs,i2c-retry-count = <2>; + sbs,poll-retry-count = <10>; + sbs,battery-detect-gpios = <&gpio-controller 122 1>; + } diff --git a/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt b/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt deleted file mode 100644 index 7571294f411..00000000000 --- a/Documentation/devicetree/bindings/power_supply/ti_bq20z75.txt +++ /dev/null @@ -1,23 +0,0 @@ -TI bq20z75 -~~~~~~~~~~ - -Required properties : - - compatible : "ti,bq20z75" - -Optional properties : - - ti,i2c-retry-count : The number of times to retry i2c transactions on i2c - IO failure. - - ti,poll-retry-count : The number of times to try looking for new status - after an external change notification. - - ti,battery-detect-gpios : The gpio which signals battery detection and - a flag specifying its polarity. - -Example: - - bq20z75@b { - compatible = "ti,bq20z75"; - reg = < 0xb >; - ti,i2c-retry-count = <2>; - ti,poll-retry-count = <10>; - ti,battery-detect-gpios = <&gpio-controller 122 1>; - } -- cgit v1.2.3