xref: /illumos-gate/usr/src/uts/common/sys/gpio/pca953x.h (revision a3ebb524df668b0fc3a38f33d0049380f5f11ec1)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2025 Oxide Computer Company
14  */
15 
16 #ifndef _SYS_GPIO_PCA953X_H
17 #define	_SYS_GPIO_PCA953X_H
18 
19 /*
20  * PCA953x driver GPIO attribute definitions.
21  *
22  * The PCA953x driver provides a very simple GPIO interface that supports four
23  * basic attributes: controlling the output, controlling the input polarity, and
24  * the standard name attribute.
25  */
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*
32  * PCA953X_GPIO_ATTR_INTPUT -- ro
33  *	uint32_t -- pca953x_gpio_input_t
34  */
35 #define	PCA953X_GPIO_ATTR_INPUT		"pca953x:input"
36 typedef enum {
37 	PCA953X_GPIO_INPUT_LOW,
38 	PCA953X_GPIO_INPUT_HIGH
39 } pca953x_gpio_input_t;
40 
41 /*
42  * PCA953X_GPIO_ATTR_OUTPUT -- rw
43  *	uint32_t -- pca953x_gpio_output_t
44  *
45  * This controls the GPIO's output value. If the GPIO is configured as an input,
46  * modifying this will not impact anything. When the output is set to disabled,
47  * then the pin is put into an input-only mode.
48  */
49 #define	PCA953X_GPIO_ATTR_OUTPUT	"pca953x:output"
50 typedef enum {
51 	PCA953X_GPIO_OUTPUT_DISABLED,
52 	PCA953X_GPIO_OUTPUT_LOW,
53 	PCA953X_GPIO_OUTPUT_HIGH
54 } pca953x_gpio_output_t;
55 
56 /*
57  * PCA953X_GPIO_ATTR_POLARITY -- rw
58  *	uint32_t -- pca953x_gpio_polarity_t
59  *
60  * This controls whether the input register reads back an inverted value or not.
61  */
62 #define	PCA953X_GPIO_ATTR_POLARITY	"pca953x:polarity"
63 typedef enum {
64 	PCA953X_GPIO_POLARITY_NORMAL,
65 	PCA953X_GPIO_POLARITY_INVERTED
66 } pca953x_gpio_polarity_t;
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _SYS_GPIO_PCA953X_H */
73