xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/priv.h (revision 3ce095c16263630dde46d6051854073edaacf3d7)
1 #ifndef __NVKM_GPIO_PRIV_H__
2 #define __NVKM_GPIO_PRIV_H__
3 #include <subdev/gpio.h>
4 
5 #define nvkm_gpio_create(p,e,o,d)                                           \
6 	nvkm_gpio_create_((p), (e), (o), sizeof(**d), (void **)d)
7 #define nvkm_gpio_destroy(p) ({                                             \
8 	struct nvkm_gpio *gpio = (p);                                       \
9 	_nvkm_gpio_dtor(nv_object(gpio));                                   \
10 })
11 #define nvkm_gpio_init(p) ({                                                \
12 	struct nvkm_gpio *gpio = (p);                                       \
13 	_nvkm_gpio_init(nv_object(gpio));                                   \
14 })
15 #define nvkm_gpio_fini(p,s) ({                                              \
16 	struct nvkm_gpio *gpio = (p);                                       \
17 	_nvkm_gpio_fini(nv_object(gpio), (s));                              \
18 })
19 
20 int  nvkm_gpio_create_(struct nvkm_object *, struct nvkm_object *,
21 			  struct nvkm_oclass *, int, void **);
22 int  _nvkm_gpio_ctor(struct nvkm_object *, struct nvkm_object *,
23 			struct nvkm_oclass *, void *, u32,
24 			struct nvkm_object **);
25 void _nvkm_gpio_dtor(struct nvkm_object *);
26 int  _nvkm_gpio_init(struct nvkm_object *);
27 int  _nvkm_gpio_fini(struct nvkm_object *, bool);
28 
29 struct nvkm_gpio_impl {
30 	struct nvkm_oclass base;
31 	int lines;
32 
33 	/* read and ack pending interrupts, returning only data
34 	 * for lines that have not been masked off, while still
35 	 * performing the ack for anything that was pending.
36 	 */
37 	void (*intr_stat)(struct nvkm_gpio *, u32 *, u32 *);
38 
39 	/* mask on/off interrupts for hi/lo transitions on a
40 	 * given set of gpio lines
41 	 */
42 	void (*intr_mask)(struct nvkm_gpio *, u32, u32, u32);
43 
44 	/* configure gpio direction and output value */
45 	int  (*drive)(struct nvkm_gpio *, int line, int dir, int out);
46 
47 	/* sense current state of given gpio line */
48 	int  (*sense)(struct nvkm_gpio *, int line);
49 
50 	/*XXX*/
51 	void (*reset)(struct nvkm_gpio *, u8);
52 };
53 
54 void nv50_gpio_reset(struct nvkm_gpio *, u8);
55 int  nv50_gpio_drive(struct nvkm_gpio *, int, int, int);
56 int  nv50_gpio_sense(struct nvkm_gpio *, int);
57 
58 void g94_gpio_intr_stat(struct nvkm_gpio *, u32 *, u32 *);
59 void g94_gpio_intr_mask(struct nvkm_gpio *, u32, u32, u32);
60 
61 void gf110_gpio_reset(struct nvkm_gpio *, u8);
62 int  gf110_gpio_drive(struct nvkm_gpio *, int, int, int);
63 int  gf110_gpio_sense(struct nvkm_gpio *, int);
64 #endif
65