xref: /linux/drivers/gpio/gpio-i8255.h (revision 23c48a124b469cee2eb0c75e6d22d366d1caa118)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2022 William Breathitt Gray */
3 #ifndef _I8255_H_
4 #define _I8255_H_
5 
6 #include <linux/spinlock.h>
7 #include <linux/types.h>
8 
9 /**
10  * struct i8255 - Intel 8255 register structure
11  * @port:	Port A, B, and C
12  * @control:	Control register
13  */
14 struct i8255 {
15 	u8 port[3];
16 	u8 control;
17 };
18 
19 /**
20  * struct i8255_state - Intel 8255 state structure
21  * @lock:		synchronization lock for accessing device state
22  * @control_state:	Control register state
23  */
24 struct i8255_state {
25 	spinlock_t lock;
26 	u8 control_state;
27 };
28 
29 void i8255_direction_input(struct i8255 __iomem *ppi, struct i8255_state *state,
30 			   unsigned long offset);
31 void i8255_direction_output(struct i8255 __iomem *ppi,
32 			    struct i8255_state *state, unsigned long offset,
33 			    unsigned long value);
34 int i8255_get(struct i8255 __iomem *ppi, unsigned long offset);
35 int i8255_get_direction(const struct i8255_state *state, unsigned long offset);
36 void i8255_get_multiple(struct i8255 __iomem *ppi, const unsigned long *mask,
37 			unsigned long *bits, unsigned long ngpio);
38 void i8255_mode0_output(struct i8255 __iomem *const ppi);
39 void i8255_set(struct i8255 __iomem *ppi, struct i8255_state *state,
40 	       unsigned long offset, unsigned long value);
41 void i8255_set_multiple(struct i8255 __iomem *ppi, struct i8255_state *state,
42 			const unsigned long *mask, const unsigned long *bits,
43 			unsigned long ngpio);
44 void i8255_state_init(struct i8255_state *const state, unsigned long nbanks);
45 
46 #endif /* _I8255_H_ */
47