summaryrefslogtreecommitdiff
path: root/include/charge_manager.h
blob: a5b4b6d2755072169780f79f2c265719c094f5ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __CHARGE_MANAGER_H
#define __CHARGE_MANAGER_H

/* Charge port that indicates no active port */
#define CHARGE_PORT_NONE -1
/* Initial charge state */
#define CHARGE_CURRENT_UNINITIALIZED -1
#define CHARGE_VOLTAGE_UNINITIALIZED -1

#define POWER(charge_port) ((charge_port.current) * (charge_port.voltage))

/* Charge suppliers, sorted by priority */
enum charge_supplier {
	CHARGE_SUPPLIER_NONE = -1,
	/* Highest priority supplier first */
	CHARGE_SUPPLIER_PD = 0,
	CHARGE_SUPPLIER_TYPEC = 1,
	CHARGE_SUPPLIER_BC12 = 2,
	CHARGE_SUPPLIER_COUNT
};

/* Charge tasks report available current and voltage */
struct charge_port_info {
	int current;
	int voltage;
};

/* Called by charging tasks to update their available charge */
void charge_manager_update(enum charge_supplier supplier,
			   int charge_port,
			   struct charge_port_info *charge);

#endif /* __CHARGE_MANAGER_H */