mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
power: supply: Static data for Samsung batteries
If we detect a Samsung SDI battery, we return a static struct power_supply_battery_info and avoid looking further. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
committed by
Sebastian Reichel
parent
bc5d4a24ec
commit
c8aee3f41c
@@ -181,6 +181,12 @@ config BATTERY_OLPC
|
||||
help
|
||||
Say Y to enable support for the battery on the OLPC laptop.
|
||||
|
||||
config BATTERY_SAMSUNG_SDI
|
||||
bool "Samsung SDI batteries"
|
||||
help
|
||||
Say Y to enable support for Samsung SDI battery data.
|
||||
These batteries are used in Samsung mobile phones.
|
||||
|
||||
config BATTERY_TOSA
|
||||
tristate "Sharp SL-6000 (tosa) battery"
|
||||
depends on MACH_TOSA && MFD_TC6393XB && TOUCHSCREEN_WM97XX
|
||||
|
||||
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_GOLDFISH) += goldfish_battery.o
|
||||
obj-$(CONFIG_BATTERY_LEGO_EV3) += lego_ev3_battery.o
|
||||
obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
|
||||
obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o
|
||||
obj-$(CONFIG_BATTERY_SAMSUNG_SDI) += samsung-sdi-battery.o
|
||||
obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
|
||||
obj-$(CONFIG_BATTERY_COLLIE) += collie_battery.o
|
||||
obj-$(CONFIG_BATTERY_INGENIC) += ingenic-battery.o
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/thermal.h>
|
||||
#include <linux/fixp-arith.h>
|
||||
#include "power_supply.h"
|
||||
#include "samsung-sdi-battery.h"
|
||||
|
||||
/* exported for the APM Power driver, APM emulation */
|
||||
struct class *power_supply_class;
|
||||
@@ -578,9 +579,42 @@ int power_supply_get_battery_info(struct power_supply *psy,
|
||||
const __be32 *list;
|
||||
u32 min_max[2];
|
||||
|
||||
if (psy->of_node) {
|
||||
battery_np = of_parse_phandle(psy->of_node, "monitored-battery", 0);
|
||||
if (!battery_np)
|
||||
return -ENODEV;
|
||||
|
||||
fwnode = fwnode_handle_get(of_fwnode_handle(battery_np));
|
||||
} else {
|
||||
err = fwnode_property_get_reference_args(
|
||||
dev_fwnode(psy->dev.parent),
|
||||
"monitored-battery", NULL, 0, 0, &args);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fwnode = args.fwnode;
|
||||
}
|
||||
|
||||
err = fwnode_property_read_string(fwnode, "compatible", &value);
|
||||
if (err)
|
||||
goto out_put_node;
|
||||
|
||||
|
||||
/* Try static batteries first */
|
||||
err = samsung_sdi_battery_get_info(&psy->dev, value, &info);
|
||||
if (!err)
|
||||
goto out_ret_pointer;
|
||||
|
||||
if (strcmp("simple-battery", value)) {
|
||||
err = -ENODEV;
|
||||
goto out_put_node;
|
||||
}
|
||||
|
||||
info = devm_kmalloc(&psy->dev, sizeof(*info), GFP_KERNEL);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
if (!info) {
|
||||
err = -ENOMEM;
|
||||
goto out_put_node;
|
||||
}
|
||||
|
||||
info->technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
|
||||
info->energy_full_design_uwh = -EINVAL;
|
||||
@@ -617,31 +651,6 @@ int power_supply_get_battery_info(struct power_supply *psy,
|
||||
info->ocv_table_size[index] = -EINVAL;
|
||||
}
|
||||
|
||||
if (psy->of_node) {
|
||||
battery_np = of_parse_phandle(psy->of_node, "monitored-battery", 0);
|
||||
if (!battery_np)
|
||||
return -ENODEV;
|
||||
|
||||
fwnode = fwnode_handle_get(of_fwnode_handle(battery_np));
|
||||
} else {
|
||||
err = fwnode_property_get_reference_args(
|
||||
dev_fwnode(psy->dev.parent),
|
||||
"monitored-battery", NULL, 0, 0, &args);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fwnode = args.fwnode;
|
||||
}
|
||||
|
||||
err = fwnode_property_read_string(fwnode, "compatible", &value);
|
||||
if (err)
|
||||
goto out_put_node;
|
||||
|
||||
if (strcmp("simple-battery", value)) {
|
||||
err = -ENODEV;
|
||||
goto out_put_node;
|
||||
}
|
||||
|
||||
/* The property and field names below must correspond to elements
|
||||
* in enum power_supply_property. For reasoning, see
|
||||
* Documentation/power/power_supply_class.rst.
|
||||
|
||||
918
drivers/power/supply/samsung-sdi-battery.c
Normal file
918
drivers/power/supply/samsung-sdi-battery.c
Normal file
File diff suppressed because it is too large
Load Diff
13
drivers/power/supply/samsung-sdi-battery.h
Normal file
13
drivers/power/supply/samsung-sdi-battery.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#if IS_ENABLED(CONFIG_BATTERY_SAMSUNG_SDI)
|
||||
extern int samsung_sdi_battery_get_info(struct device *dev,
|
||||
const char *compatible,
|
||||
struct power_supply_battery_info **info);
|
||||
#else
|
||||
static inline int samsung_sdi_battery_get_info(struct device *dev,
|
||||
const char *compatible,
|
||||
struct power_supply_battery_info **info)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user