blob: 07e6ff50084f0e2a5054086ce48e8e7fea6d2481 [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
34 * @max_out_volt maximum output charger voltage in mV
35 * @max_out_curr maximum output charger current in mA
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;
42 int max_out_volt;
43 int max_out_curr;
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_ */