Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright 2022 William Breathitt Gray */
0003 #ifndef _I8255_H_
0004 #define _I8255_H_
0005 
0006 #include <linux/spinlock.h>
0007 #include <linux/types.h>
0008 
0009 /**
0010  * struct i8255 - Intel 8255 register structure
0011  * @port:   Port A, B, and C
0012  * @control:    Control register
0013  */
0014 struct i8255 {
0015     u8 port[3];
0016     u8 control;
0017 };
0018 
0019 /**
0020  * struct i8255_state - Intel 8255 state structure
0021  * @lock:       synchronization lock for accessing device state
0022  * @control_state:  Control register state
0023  */
0024 struct i8255_state {
0025     spinlock_t lock;
0026     u8 control_state;
0027 };
0028 
0029 void i8255_direction_input(struct i8255 __iomem *ppi, struct i8255_state *state,
0030                unsigned long offset);
0031 void i8255_direction_output(struct i8255 __iomem *ppi,
0032                 struct i8255_state *state, unsigned long offset,
0033                 unsigned long value);
0034 int i8255_get(struct i8255 __iomem *ppi, unsigned long offset);
0035 int i8255_get_direction(const struct i8255_state *state, unsigned long offset);
0036 void i8255_get_multiple(struct i8255 __iomem *ppi, const unsigned long *mask,
0037             unsigned long *bits, unsigned long ngpio);
0038 void i8255_mode0_output(struct i8255 __iomem *const ppi);
0039 void i8255_set(struct i8255 __iomem *ppi, struct i8255_state *state,
0040            unsigned long offset, unsigned long value);
0041 void i8255_set_multiple(struct i8255 __iomem *ppi, struct i8255_state *state,
0042             const unsigned long *mask, const unsigned long *bits,
0043             unsigned long ngpio);
0044 void i8255_state_init(struct i8255_state *const state, unsigned long nbanks);
0045 
0046 #endif /* _I8255_H_ */