blob: b24fa246bf288406dfcb55ca84da29c817185142 (
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
|
/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CROS_EC_CHARGER_CHIPS_H
#define __CROS_EC_CHARGER_CHIPS_H
#include "charger.h"
#include <zephyr/devicetree.h>
extern const struct charger_config_t chg_chips_alt[];
#define ALT_CHG_CHIP_CHK(usbc_id, usb_port_num) \
COND_CODE_1(DT_REG_HAS_IDX(usbc_id, usb_port_num), \
(COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, chg_alt), (|| 1), \
(|| 0))), \
(|| 0))
#define CHG_ENABLE_ALTERNATE(usb_port_num) \
do { \
BUILD_ASSERT( \
(0 DT_FOREACH_STATUS_OKAY_VARGS(named_usbc_port, \
ALT_CHG_CHIP_CHK, \
usb_port_num)), \
"Selected USB node does not exist or does not specify" \
"a charger alternate chip"); \
memcpy(&chg_chips[usb_port_num], &chg_chips_alt[usb_port_num], \
sizeof(struct charger_config_t)); \
} while (0)
#endif /* __CROS_EC_CHARGER_CHIPS_H */
|