summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/battery_enum.h
blob: a461829a314b1d95c754417d6411e6b4b2feeac9 (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
/* Copyright 2021 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_CONFIG_CHIP_H
#error "This file must only be included from config_chip.h and it should be" \
	"included in all zephyr builds automatically"
#endif

#define BATTERY_ENUM(val)	DT_CAT(BATTERY_, val)
#define BATTERY_TYPE(id) BATTERY_ENUM(DT_STRING_UPPER_TOKEN(id, enum_name))
#define BATTERY_TYPE_WITH_COMMA(id)	BATTERY_TYPE(id),

/* This produces a list of BATTERY_<ENUM_NAME> identifiers */
#if DT_NODE_EXISTS(DT_PATH(batteries))

enum battery_type {
	DT_FOREACH_CHILD(DT_PATH(batteries), BATTERY_TYPE_WITH_COMMA)

	BATTERY_TYPE_COUNT,
};

#else /* DT_NODE_EXISTS(DT_PATH(batteries)) */

enum battery_type {
#if DT_NODE_EXISTS(DT_PATH(named_batteries))
	DT_FOREACH_CHILD(DT_PATH(named_batteries), BATTERY_TYPE_WITH_COMMA)
#endif

	BATTERY_TYPE_COUNT,
};

#endif /* DT_NODE_EXISTS(DT_PATH(batteries)) */

#undef BATTERY_TYPE_WITH_COMMA