mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
Allow a charge port to be selected as the override port, which means it will always be selected as the charge port, if any charge supplier is available. BUG=chrome-os-partner:32003 TEST=Attach PD charger and BC1.2 charger. Verify that active charge port switches to BC1.2 after running `chargeoverride [port]` from console. Also, pass unit tests. BRANCH=Samus Change-Id: Ia1b48ca89641842d51be7eed3b92d36d3eedc9ef Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227730 Reviewed-by: Alec Berg <alecaberg@chromium.org>
48 lines
1.3 KiB
C
48 lines
1.3 KiB
C
/* 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_SUPPLIER_NONE -1
|
|
#define CHARGE_PORT_NONE -1
|
|
#define CHARGE_CEIL_NONE -1
|
|
|
|
/* Initial charge state */
|
|
#define CHARGE_CURRENT_UNINITIALIZED -1
|
|
#define CHARGE_VOLTAGE_UNINITIALIZED -1
|
|
|
|
/* Port override settings */
|
|
enum {
|
|
OVERRIDE_DONT_CHARGE = -2,
|
|
OVERRIDE_OFF = -1,
|
|
/* [0, PD_PORT_COUNT): Port# */
|
|
};
|
|
|
|
#define POWER(charge_port) ((charge_port.current) * (charge_port.voltage))
|
|
|
|
/* 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(int supplier,
|
|
int charge_port,
|
|
struct charge_port_info *charge);
|
|
|
|
/* Update charge ceiling for a given port */
|
|
void charge_manager_set_ceil(int port, int ceil);
|
|
|
|
/* Select an 'override port', which is always the preferred charge port */
|
|
void charge_manager_set_override(int port);
|
|
|
|
/* Returns the current active charge port, as determined by charge manager */
|
|
int charge_manager_get_active_charge_port(void);
|
|
|
|
#endif /* __CHARGE_MANAGER_H */
|