blob: 67703f23e7ba2729c307899126422145055d665e [file] [log] [blame]
Arun Murthy1668f812012-02-29 21:54:25 +05301/*
2 * Copyright (C) ST-Ericsson SA 2012
3 * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#ifndef _UX500_CHARGALG_H
8#define _UX500_CHARGALG_H
9
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 */
18#define psy_to_ux500_charger(x) power_supply_get_drvdata(psy)
Arun Murthy1668f812012-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 Murthy1668f812012-02-29 21:54:25 +053026 int (*kick_wd) (struct ux500_charger *);
27 int (*update_curr) (struct ux500_charger *, int);
Lee Jonesdb43e6c2013-02-14 12:39:15 +000028 int (*pp_enable) (struct ux500_charger *, bool);
29 int (*pre_chg_enable) (struct ux500_charger *, bool);
Arun Murthy1668f812012-02-29 21:54:25 +053030};
31
32/**
33 * struct ux500_charger - power supply ux500 charger sub class
34 * @psy power supply base class
35 * @ops ux500 charger operations
36 * @max_out_volt maximum output charger voltage in mV
37 * @max_out_curr maximum output charger current in mA
Michel JAOUEN01ec8c52012-04-26 10:00:04 +020038 * @enabled indicates if this charger is used or not
Loic Pallardye07a5642012-05-10 15:33:56 +020039 * @external external charger unit (pm2xxx)
Lee Jonesdb43e6c2013-02-14 12:39:15 +000040 * @power_path USB power path support
Arun Murthy1668f812012-02-29 21:54:25 +053041 */
42struct ux500_charger {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010043 struct power_supply *psy;
Arun Murthy1668f812012-02-29 21:54:25 +053044 struct ux500_charger_ops ops;
45 int max_out_volt;
46 int max_out_curr;
Loic Pallardye07a5642012-05-10 15:33:56 +020047 int wdt_refresh;
Michel JAOUEN01ec8c52012-04-26 10:00:04 +020048 bool enabled;
Loic Pallardye07a5642012-05-10 15:33:56 +020049 bool external;
Lee Jonesdb43e6c2013-02-14 12:39:15 +000050 bool power_path;
Arun Murthy1668f812012-02-29 21:54:25 +053051};
52
Lee Jones88917162013-02-13 11:39:19 +000053extern struct blocking_notifier_head charger_notifier_list;
54
Arun Murthy1668f812012-02-29 21:54:25 +053055#endif