blob: 9dbd372ae5c992d7027420e18adba0e02d83baea (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* Copyright 2020 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.
*/
/*
* OCPC - One Charger IC per Type-C
*/
#ifndef __CROS_EC_OCPC_H_
#define __CROS_EC_OCPC_H_
#define PRIMARY_CHARGER 0
#define SECONDARY_CHARGER 1
#define OCPC_UNINIT 0xdededede
struct ocpc_data {
/* Index into chg_chips[] table for the charger IC that is switching. */
int active_chg_chip;
int combined_rsys_rbatt_mo; /* System resistance b/w output and Vbatt */
/* ADC values */
int primary_vbus_mv; /* VBUS measured by the primary charger IC */
int primary_ibus_ma; /* IBUS measrued by the primary charger IC */
int secondary_vbus_mv; /* VBUS measured by the secondary charger IC */
int secondary_ibus_ma; /* IBUS measure by the secondary charger IC */
/* PID values */
int last_error;
int integral;
int last_vsys;
};
/** Set the VSYS target for the secondary charger IC.
*
* @param curr: Pointer to desired_input_current
* @param ocpc: Pointer to OCPC data
* @param voltage_mv: The desired voltage
* @param current_ma: The desired current
* @return EC_SUCCESS on success, error otherwise.
*/
int ocpc_config_secondary_charger(int *desired_input_current,
struct ocpc_data *ocpc,
int voltage_mv, int current_ma);
/** Get the runtime data from the various ADCs.
*
* @param ocpc: Pointer to OCPC data
*/
void ocpc_get_adcs(struct ocpc_data *ocpc);
/* Set the PID constants for the charging loop */
__overridable void ocpc_get_pid_constants(int *kp, int *kp_div,
int *ki, int *ki_div,
int *kd, int *kd_div);
#endif /* __CROS_EC_OCPC_H */
|