mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
When we find that charging is in a wedged state, we may wish to write a PD log entry, but the PD MCU cannot detect such a state on its own. Therefore, add a new command to ask the PD MCU to write a log of a given type, and add a new board-specific custom log event. BUG=chrome-os-partner:36668 TEST=Manual on samus: ./ectool --dev=1 pdwritelog charge 0 ./ectool --dev=1 pdwritelog charge 1 ./ectool --dev=1 pdwritelog 1 0 ./ectool --dev=1 pdwritelog 2 0 ./ectool --dev=1 pdlog Verify log output matches expectation: 2015-02-12 11:12:49.290 P0 SRC 2015-02-12 11:12:49.296 P1 SNK Charger PD 20286mV max 20000mV / 3000mA 2015-02-12 11:12:49.303 P0 New connection 2015-02-12 11:12:49.310 P0 Board-custom event --- END OF LOG -- Also, verify kernel logging of wedged event: [ 181.378420] PDLOG 2015/02/12 19:13:44.019 P0 Event 02 (0000) [] Also, trigger wedged state on Samus and verify log entry is written. BRANCH=Samus Change-Id: I55c7c839cf8300fcd3931dccdaaf16c1065e31a8 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/248981 Reviewed-by: Alec Berg <alecaberg@chromium.org>
71 lines
1.9 KiB
C
71 lines
1.9 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
|
|
|
|
#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
|
|
|
|
/* 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 /* __CHARGE_MANAGER_H */
|