blob: f47a0061c36a2963a67ccc25417db34289611fe1 [file] [log] [blame]
Thomas Gleixneraf873fc2019-05-28 09:57:21 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Arun Murthy1668f81152012-02-29 21:54:25 +05302/*
3 * Copyright (C) ST-Ericsson SA 2012
4 * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
Arun Murthy1668f81152012-02-29 21:54:25 +05305 */
6
Linus Walleija65aa0c2021-03-12 09:36:03 +01007#ifndef _AB8500_CHARGALG_H_
8#define _AB8500_CHARGALG_H_
Arun Murthy1668f81152012-02-29 21:54:25 +05309
10#include <linux/power_supply.h>
11
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010012/*
13 * Valid only for supplies of type:
14 * - POWER_SUPPLY_TYPE_MAINS,
15 * - POWER_SUPPLY_TYPE_USB,
16 * because only them store as drv_data pointer to struct ux500_charger.
17 */
Linus Walleijf1c74a62021-06-27 01:47:49 +020018#define psy_to_ux500_charger(x) power_supply_get_drvdata(x)
Arun Murthy1668f81152012-02-29 21:54:25 +053019
20/* Forward declaration */
21struct ux500_charger;
22
23struct ux500_charger_ops {
24 int (*enable) (struct ux500_charger *, int, int, int);
Lee Jones4dcdf572013-02-14 09:24:10 +000025 int (*check_enable) (struct ux500_charger *, int, int);
Arun Murthy1668f81152012-02-29 21:54:25 +053026 int (*kick_wd) (struct ux500_charger *);
27 int (*update_curr) (struct ux500_charger *, int);
28};
29
30/**
31 * struct ux500_charger - power supply ux500 charger sub class
32 * @psy power supply base class
33 * @ops ux500 charger operations
Linus Walleijbc6e0282021-11-20 16:53:24 +010034 * @max_out_volt_uv maximum output charger voltage in uV
Linus Walleij83e5aa72021-11-20 16:53:23 +010035 * @max_out_curr_ua maximum output charger current in uA
Michel JAOUEN01ec8c52012-04-26 10:00:04 +020036 * @enabled indicates if this charger is used or not
Loic Pallardye07a5642012-05-10 15:33:56 +020037 * @external external charger unit (pm2xxx)
Arun Murthy1668f81152012-02-29 21:54:25 +053038 */
39struct ux500_charger {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010040 struct power_supply *psy;
Arun Murthy1668f81152012-02-29 21:54:25 +053041 struct ux500_charger_ops ops;
Linus Walleijbc6e0282021-11-20 16:53:24 +010042 int max_out_volt_uv;
Linus Walleij83e5aa72021-11-20 16:53:23 +010043 int max_out_curr_ua;
Loic Pallardye07a5642012-05-10 15:33:56 +020044 int wdt_refresh;
Michel JAOUEN01ec8c52012-04-26 10:00:04 +020045 bool enabled;
Loic Pallardye07a5642012-05-10 15:33:56 +020046 bool external;
Arun Murthy1668f81152012-02-29 21:54:25 +053047};
48
Lee Jones88917162013-02-13 11:39:19 +000049extern struct blocking_notifier_head charger_notifier_list;
50
Linus Walleija65aa0c2021-03-12 09:36:03 +010051#endif /* _AB8500_CHARGALG_H_ */