XenevaOS
Loading...
Searching...
No Matches
consumer.h
Go to the documentation of this file.
1#ifndef __LINUX_GPIO_CONSUMER_H__
2#define __LINUX_GPIO_CONSUMER_H__
3
4/*
5 * DCL <linux/gpio/consumer.h> -- the direction enum and the two calls
6 * serial_core.c makes for RS485 transceiver control.
7 *
8 * There is no GPIO controller in Xeneva, and this header is the whole
9 * distance between that fact and a driver that must still compile:
10 *
11 * devm_gpiod_get_optional() returns NULL, which is mainline's own answer
12 * for an *optional* descriptor on a system with
13 * no line behind that name -- the callers at
14 * serial_core.c:3573 and :3583 read it into a
15 * desc and hand it straight to...
16 * gpiod_set_value_cansleep() ...which does nothing. Both are written to
17 * tolerate a NULL desc, because that is the only
18 * value they will ever be given here.
19 *
20 * So the RS485 term and rx-during-tx lines are absent rather than simulated,
21 * which is what an unconnected transceiver-enable pin is: nothing to assert,
22 * nothing to deassert, and the "works fine for short cables" comment at
23 * :3571 becomes "works for the half-duplex case nobody configured".
24 *
25 * The enum is mainline's bit-for-bit (the GPIOD_FLAGS_BIT_* values matter --
26 * `gpiod_get` returns -EPROBE_DEFER based on them upstream, and a wrong
27 * number here would be read back by nothing but is cheap to keep right).
28 *
29 * upstream include/linux/gpio/consumer.h (mainline v7.2)
30 */
31
32struct device;
33struct gpio_desc;
34
35/* mainline's flag bits, verbatim: these are OR-able inputs to gpiod_get(),
36 * and GPIOD_OUT_* are defined in terms of them rather than as fresh numbers so
37 * the two spellings can never disagree. */
38#define GPIOD_FLAGS_BIT_DIR_SET (1 << 0)
39#define GPIOD_FLAGS_BIT_DIR_OUT (1 << 1)
40#define GPIOD_FLAGS_BIT_DIR_VAL (1 << 2)
41#define GPIOD_FLAGS_BIT_OPEN_DRAIN (1 << 3)
42
52
53static inline struct gpio_desc* devm_gpiod_get_optional(struct device* dev,
54 const char* con_id,
55 enum gpiod_flags flags)
56{
57 (void)dev;
58 (void)con_id;
59 (void)flags;
60 return NULL; /* no controller: the line is simply not there */
61}
62
63static inline void gpiod_set_value_cansleep(struct gpio_desc* desc, int value)
64{
65 (void)desc;
66 (void)value;
67}
68
69#endif /* __LINUX_GPIO_CONSUMER_H__ */
uint8_t flags
Definition virtio.h:0
#define NULL
Definition actypes.h:561
#define GPIOD_FLAGS_BIT_OPEN_DRAIN
Definition consumer.h:41
#define GPIOD_FLAGS_BIT_DIR_VAL
Definition consumer.h:40
gpiod_flags
Definition consumer.h:43
@ GPIOD_OUT_HIGH_OPEN_DRAIN
Definition consumer.h:50
@ GPIOD_OUT_HIGH
Definition consumer.h:47
@ GPIOD_IN
Definition consumer.h:45
@ GPIOD_ASIS
Definition consumer.h:44
@ GPIOD_OUT_LOW
Definition consumer.h:46
@ GPIOD_OUT_LOW_OPEN_DRAIN
Definition consumer.h:49
#define GPIOD_FLAGS_BIT_DIR_SET
Definition consumer.h:38
#define GPIOD_FLAGS_BIT_DIR_OUT
Definition consumer.h:39
const struct device * dev
Definition drm_print.h:519
Definition fs.h:255