gpio-i8255.h 1.5 KB

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