Files
OpenCellular/include/charge_manager.h
Bill Richardson 104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00

86 lines
2.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 __CROS_EC_CHARGE_MANAGER_H
#define __CROS_EC_CHARGE_MANAGER_H
#include "common.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
#define USB_BC12_CHARGE_VOLTAGE 5000 /* mV */
/* Commonly-used charge suppliers listed in no particular order */
enum charge_supplier {
CHARGE_SUPPLIER_PD,
CHARGE_SUPPLIER_TYPEC,
CHARGE_SUPPLIER_BC12_DCP,
CHARGE_SUPPLIER_BC12_CDP,
CHARGE_SUPPLIER_BC12_SDP,
CHARGE_SUPPLIER_PROPRIETARY,
CHARGE_SUPPLIER_OTHER,
CHARGE_SUPPLIER_VBUS,
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_charge(int supplier,
int port,
struct charge_port_info *charge);
/* Partner port dualrole capabilities */
enum dualrole_capabilities {
CAP_UNKNOWN,
CAP_DUALROLE,
CAP_DEDICATED,
};
/* Called by charging tasks to indicate partner dualrole capability change */
void charge_manager_update_dualrole(int port, enum dualrole_capabilities cap);
/* 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 */
int charge_manager_set_override(int port);
int charge_manager_get_override(void);
/* Returns the current active charge port, as determined by charge manager */
int charge_manager_get_active_charge_port(void);
#ifdef CONFIG_USB_PD_LOGGING
/* Save power state log entry for the given port */
void charge_manager_save_log(int port);
#endif
/* Board-level callback functions */
/*
* Set the active charge port. Returns EC_SUCCESS if the charge port is
* accepted, returns ec_error_list status otherwise.
*/
int board_set_active_charge_port(int charge_port);
/* Set the charge current limit. */
void board_set_charge_limit(int charge_ma);
/* Called on delayed override timeout */
void board_charge_manager_override_timeout(void);
#endif /* __CROS_EC_CHARGE_MANAGER_H */