summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/gpio_signal.h
blob: 698ef126bb9306f900e76d011b9244b13f814ab5 (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
/* 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.
 */

#ifndef __CROS_EC_GPIO_SIGNAL_H
#define __CROS_EC_GPIO_SIGNAL_H

#include <devicetree.h>

#define GPIO_SIGNAL(id) _CONCAT(GPIO_, id)
#define GPIO_SIGNAL_WITH_COMMA(id) GPIO_SIGNAL(id),
enum gpio_signal {
#if DT_NODE_EXISTS(DT_PATH(named_gpios))
	DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_SIGNAL_WITH_COMMA)
#endif
	GPIO_COUNT
};
#undef GPIO_SIGNAL_WITH_COMMA

/** @brief Converts a node identifier under named gpios to enum
 *
 * Converts the specified node identifier name, which should be nested under
 * the named_gpios node, into the correct enum gpio_signal that can be used
 * with platform/ec gpio API
 */
#define NAMED_GPIO(name) GPIO_SIGNAL(DT_PATH(named_gpios, name))

#endif  /* __CROS_EC_GPIO_SIGNAL_H */