Lines Matching +full:sbs +full:- +full:battery

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * This adds support for sbs-charger compilant chips as defined here:
6 * http://sbs-forum.org/specs/sbc110.pdf
8 * Implemetation based on sbs-battery.c
51 reg = chip->last_state; in sbs_get_property()
55 val->intval = !!(reg & SBS_CHARGER_STATUS_BATTERY_PRESENT); in sbs_get_property()
59 val->intval = !!(reg & SBS_CHARGER_STATUS_AC_PRESENT); in sbs_get_property()
63 val->intval = POWER_SUPPLY_STATUS_UNKNOWN; in sbs_get_property()
66 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in sbs_get_property()
69 val->intval = POWER_SUPPLY_STATUS_CHARGING; in sbs_get_property()
71 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in sbs_get_property()
77 val->intval = POWER_SUPPLY_HEALTH_COLD; in sbs_get_property()
79 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; in sbs_get_property()
81 val->intval = POWER_SUPPLY_HEALTH_GOOD; in sbs_get_property()
86 return -EINVAL; in sbs_get_property()
97 ret = regmap_read(chip->regmap, SBS_CHARGER_REG_STATUS, &reg); in sbs_check_state()
98 if (!ret && reg != chip->last_state) { in sbs_check_state()
99 chip->last_state = reg; in sbs_check_state()
100 power_supply_changed(chip->power_supply); in sbs_check_state()
113 schedule_delayed_work(&chip->work, in sbs_delayed_work()
159 .name = "sbs-charger",
173 chip = devm_kzalloc(&client->dev, sizeof(struct sbs_info), GFP_KERNEL); in sbs_probe()
175 return -ENOMEM; in sbs_probe()
177 chip->client = client; in sbs_probe()
178 psy_cfg.of_node = client->dev.of_node; in sbs_probe()
183 chip->regmap = devm_regmap_init_i2c(client, &sbs_regmap); in sbs_probe()
184 if (IS_ERR(chip->regmap)) in sbs_probe()
185 return PTR_ERR(chip->regmap); in sbs_probe()
189 * to the battery. in sbs_probe()
191 ret = regmap_read(chip->regmap, SBS_CHARGER_REG_STATUS, &val); in sbs_probe()
193 dev_err(&client->dev, "Failed to get device status\n"); in sbs_probe()
196 chip->last_state = val; in sbs_probe()
198 chip->power_supply = devm_power_supply_register(&client->dev, &sbs_desc, in sbs_probe()
200 if (IS_ERR(chip->power_supply)) { in sbs_probe()
201 dev_err(&client->dev, "Failed to register power supply\n"); in sbs_probe()
202 return PTR_ERR(chip->power_supply); in sbs_probe()
206 * The sbs-charger spec doesn't impose the use of an interrupt. So in in sbs_probe()
210 if (client->irq) { in sbs_probe()
211 ret = devm_request_threaded_irq(&client->dev, client->irq, in sbs_probe()
214 dev_name(&client->dev), chip); in sbs_probe()
216 dev_err(&client->dev, "Failed to request irq, %d\n", ret); in sbs_probe()
220 INIT_DELAYED_WORK(&chip->work, sbs_delayed_work); in sbs_probe()
221 schedule_delayed_work(&chip->work, in sbs_probe()
225 dev_info(&client->dev, in sbs_probe()
226 "%s: smart charger device registered\n", client->name); in sbs_probe()
235 cancel_delayed_work_sync(&chip->work); in sbs_remove()
242 { .compatible = "sbs,sbs-charger" },
249 { "sbs-charger", 0 },
259 .name = "sbs-charger",
266 MODULE_DESCRIPTION("SBS smart charger driver");