From 86131d933f9a9502d877fb37b90a856e6a8a7ed8 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Mon, 5 Nov 2018 15:39:07 +0800 Subject: power: supply: core: Add one field to present the battery internal resistance Add one field for 'struct power_supply_battery_info' to present the battery factory internal resistance. Signed-off-by: Baolin Wang Reviewed-by: Linus Walleij Signed-off-by: Sebastian Reichel --- include/linux/power_supply.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index f80769175c56..d089566828be 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -326,6 +326,7 @@ struct power_supply_battery_info { int charge_term_current_ua; /* microAmps */ int constant_charge_current_max_ua; /* microAmps */ int constant_charge_voltage_max_uv; /* microVolts */ + int factory_internal_resistance_uohm; /* microOhms */ }; extern struct atomic_notifier_head power_supply_notifier; -- cgit v1.2.3 From 3afb50d7125bcdbf71df843134e96ceffc78c8b8 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Mon, 5 Nov 2018 15:39:09 +0800 Subject: power: supply: core: Add some helpers to use the battery OCV capacity table We have introduced some battery properties to present the OCV table temperatures and OCV capacity table values. Thus this patch add OCV temperature and OCV table for battery information, as well as providing some helper functions to use the OCV capacity table for users. Signed-off-by: Baolin Wang Reviewed-by: Linus Walleij Signed-off-by: Sebastian Reichel --- include/linux/power_supply.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index d089566828be..84fe93f674a0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -309,6 +309,13 @@ struct power_supply_info { int use_for_apm; }; +struct power_supply_battery_ocv_table { + int ocv; /* microVolts */ + int capacity; /* percent */ +}; + +#define POWER_SUPPLY_OCV_TEMP_MAX 20 + /* * This is the recommended struct to manage static battery parameters, * populated by power_supply_get_battery_info(). Most platform drivers should @@ -327,6 +334,9 @@ struct power_supply_battery_info { int constant_charge_current_max_ua; /* microAmps */ int constant_charge_voltage_max_uv; /* microVolts */ int factory_internal_resistance_uohm; /* microOhms */ + int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */ + struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; + int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; }; extern struct atomic_notifier_head power_supply_notifier; @@ -350,6 +360,15 @@ devm_power_supply_get_by_phandle(struct device *dev, const char *property) extern int power_supply_get_battery_info(struct power_supply *psy, struct power_supply_battery_info *info); +extern void power_supply_put_battery_info(struct power_supply *psy, + struct power_supply_battery_info *info); +extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table, + int table_len, int ocv); +extern struct power_supply_battery_ocv_table * +power_supply_find_ocv2cap_table(struct power_supply_battery_info *info, + int temp, int *table_len); +extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info, + int ocv, int temp); extern void power_supply_changed(struct power_supply *psy); extern int power_supply_am_i_supplied(struct power_supply *psy); extern int power_supply_set_input_current_limit_from_supplier( -- cgit v1.2.3 From 7693b5643fd2d682de90733b67fc8032b9646911 Mon Sep 17 00:00:00 2001 From: Oskari Lemmela Date: Tue, 20 Nov 2018 19:52:09 +0200 Subject: power: supply: add AC power supply driver for AXP813 AXP813 and AXP803 PMICs can control input current and minimum voltage. Both of these values are configurable. Signed-off-by: Oskari Lemmela Reviewed-by: Quentin Schulz Reviewed-by: Chen-Yu Tsai Acked-by: Lee Jones Signed-off-by: Sebastian Reichel --- include/linux/mfd/axp20x.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 517e60eecbcb..2302b620d238 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -266,6 +266,7 @@ enum axp20x_variants { #define AXP288_RT_BATT_V_H 0xa0 #define AXP288_RT_BATT_V_L 0xa1 +#define AXP813_ACIN_PATH_CTRL 0x3a #define AXP813_ADC_RATE 0x85 /* Fuel Gauge */ -- cgit v1.2.3 From cef8fe6a382cb556b590269e9d1dfc0241014903 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 27 Sep 2018 15:46:03 +0200 Subject: power: supply: core: add support for custom sysfs attributes Add functionality to setup device specific sysfs attributes in a race condition free manner Signed-off-by: Sebastian Reichel --- include/linux/power_supply.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 84fe93f674a0..57b2ab82b951 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -204,6 +204,9 @@ struct power_supply_config { /* Driver private data */ void *drv_data; + /* Device specific sysfs attributes */ + const struct attribute_group **attr_grp; + char **supplied_to; size_t num_supplicants; }; -- cgit v1.2.3 From 157ba1bb5fcb91366df3be5e63a04b799ff9cf64 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 28 Sep 2018 17:35:37 +0200 Subject: power: supply: charger-manager: fix race-condition in sysfs registration This registers custom sysfs properties using the native functionality of the power-supply framework, which cleans up the code a bit and fixes a race-condition. Before this patch the sysfs attributes were not properly registered to udev. Signed-off-by: Sebastian Reichel --- include/linux/power/charger-manager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h index c4fa907c8f14..2ce8d00c20de 100644 --- a/include/linux/power/charger-manager.h +++ b/include/linux/power/charger-manager.h @@ -119,7 +119,7 @@ struct charger_regulator { struct charger_cable *cables; int num_cables; - struct attribute_group attr_g; + struct attribute_group attr_grp; struct device_attribute attr_name; struct device_attribute attr_state; struct device_attribute attr_externally_control; @@ -186,6 +186,7 @@ struct charger_desc { int num_charger_regulators; struct charger_regulator *charger_regulators; + const struct attribute_group **sysfs_groups; const char *psy_fuel_gauge; -- cgit v1.2.3