Merge tag 'drm-intel-gt-next-2023-12-08' of git://anongit.freedesktop.org/drm/drm...
[linux-2.6-microblaze.git] / include / linux / comedi / comedi_8255.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * comedi_8255.h
4  * Generic 8255 digital I/O subdevice support
5  *
6  * COMEDI - Linux Control and Measurement Device Interface
7  * Copyright (C) 1998 David A. Schleef <ds@schleef.org>
8  */
9
10 #ifndef _COMEDI_8255_H
11 #define _COMEDI_8255_H
12
13 #include <linux/errno.h>
14
15 #define I8255_SIZE              0x04
16
17 #define I8255_DATA_A_REG        0x00
18 #define I8255_DATA_B_REG        0x01
19 #define I8255_DATA_C_REG        0x02
20 #define I8255_CTRL_REG          0x03
21 #define I8255_CTRL_C_LO_IO      BIT(0)
22 #define I8255_CTRL_B_IO         BIT(1)
23 #define I8255_CTRL_B_MODE       BIT(2)
24 #define I8255_CTRL_C_HI_IO      BIT(3)
25 #define I8255_CTRL_A_IO         BIT(4)
26 #define I8255_CTRL_A_MODE(x)    ((x) << 5)
27 #define I8255_CTRL_CW           BIT(7)
28
29 struct comedi_device;
30 struct comedi_subdevice;
31
32 #ifdef CONFIG_HAS_IOPORT
33 int subdev_8255_io_init(struct comedi_device *dev, struct comedi_subdevice *s,
34                         unsigned long regbase);
35 #else
36 static inline int subdev_8255_io_init(struct comedi_device *dev,
37                                       struct comedi_subdevice *s,
38                                       unsigned long regbase)
39 {
40         return -ENXIO;
41 }
42 #endif
43
44 int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s,
45                         unsigned long regbase);
46
47 int subdev_8255_cb_init(struct comedi_device *dev, struct comedi_subdevice *s,
48                         int (*io)(struct comedi_device *dev, int dir, int port,
49                                   int data, unsigned long context),
50                         unsigned long context);
51
52 unsigned long subdev_8255_regbase(struct comedi_subdevice *s);
53
54 #endif