iwlwifi: pcie: fix polling in various places
[cascardo/linux.git] / drivers / gpu / drm / nouveau / core / subdev / gpio / priv.h
1 #ifndef __NVKM_GPIO_H__
2 #define __NVKM_GPIO_H__
3
4 #include <subdev/gpio.h>
5
6 #define nouveau_gpio_create(p,e,o,d)                                           \
7         nouveau_gpio_create_((p), (e), (o), sizeof(**d), (void **)d)
8 #define nouveau_gpio_destroy(p) ({                                             \
9         struct nouveau_gpio *gpio = (p);                                       \
10         _nouveau_gpio_dtor(nv_object(gpio));                                   \
11 })
12 #define nouveau_gpio_init(p) ({                                                \
13         struct nouveau_gpio *gpio = (p);                                       \
14         _nouveau_gpio_init(nv_object(gpio));                                   \
15 })
16 #define nouveau_gpio_fini(p,s) ({                                              \
17         struct nouveau_gpio *gpio = (p);                                       \
18         _nouveau_gpio_fini(nv_object(gpio), (s));                              \
19 })
20
21 int  nouveau_gpio_create_(struct nouveau_object *, struct nouveau_object *,
22                           struct nouveau_oclass *, int, void **);
23 int  _nouveau_gpio_ctor(struct nouveau_object *, struct nouveau_object *,
24                         struct nouveau_oclass *, void *, u32,
25                         struct nouveau_object **);
26 void _nouveau_gpio_dtor(struct nouveau_object *);
27 int  _nouveau_gpio_init(struct nouveau_object *);
28 int  _nouveau_gpio_fini(struct nouveau_object *, bool);
29
30 struct nouveau_gpio_impl {
31         struct nouveau_oclass base;
32         int lines;
33
34         /* read and ack pending interrupts, returning only data
35          * for lines that have not been masked off, while still
36          * performing the ack for anything that was pending.
37          */
38         void (*intr_stat)(struct nouveau_gpio *, u32 *, u32 *);
39
40         /* mask on/off interrupts for hi/lo transitions on a
41          * given set of gpio lines
42          */
43         void (*intr_mask)(struct nouveau_gpio *, u32, u32, u32);
44
45         /* configure gpio direction and output value */
46         int  (*drive)(struct nouveau_gpio *, int line, int dir, int out);
47
48         /* sense current state of given gpio line */
49         int  (*sense)(struct nouveau_gpio *, int line);
50
51         /*XXX*/
52         void (*reset)(struct nouveau_gpio *, u8);
53 };
54
55 void nv50_gpio_reset(struct nouveau_gpio *, u8);
56 int  nv50_gpio_drive(struct nouveau_gpio *, int, int, int);
57 int  nv50_gpio_sense(struct nouveau_gpio *, int);
58
59 void nv92_gpio_intr_stat(struct nouveau_gpio *, u32 *, u32 *);
60 void nv92_gpio_intr_mask(struct nouveau_gpio *, u32, u32, u32);
61
62 void nvd0_gpio_reset(struct nouveau_gpio *, u8);
63 int  nvd0_gpio_drive(struct nouveau_gpio *, int, int, int);
64 int  nvd0_gpio_sense(struct nouveau_gpio *, int);
65
66
67 #endif