]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/core/include/subdev/gpio.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / core / include / subdev / gpio.h
1 #ifndef __NOUVEAU_GPIO_H__
2 #define __NOUVEAU_GPIO_H__
3
4 #include <core/subdev.h>
5 #include <core/device.h>
6
7 #include <subdev/bios.h>
8 #include <subdev/bios/gpio.h>
9
10 struct nouveau_gpio {
11         struct nouveau_subdev base;
12
13         /* hardware interfaces */
14         void (*reset)(struct nouveau_gpio *, u8 func);
15         int  (*drive)(struct nouveau_gpio *, int line, int dir, int out);
16         int  (*sense)(struct nouveau_gpio *, int line);
17         void (*irq_enable)(struct nouveau_gpio *, int line, bool);
18
19         /* software interfaces */
20         int  (*find)(struct nouveau_gpio *, int idx, u8 tag, u8 line,
21                      struct dcb_gpio_func *);
22         int  (*set)(struct nouveau_gpio *, int idx, u8 tag, u8 line, int state);
23         int  (*get)(struct nouveau_gpio *, int idx, u8 tag, u8 line);
24         int  (*irq)(struct nouveau_gpio *, int idx, u8 tag, u8 line, bool on);
25
26         /* interrupt handling */
27         struct list_head isr;
28         spinlock_t lock;
29
30         void (*isr_run)(struct nouveau_gpio *, int idx, u32 mask);
31         int  (*isr_add)(struct nouveau_gpio *, int idx, u8 tag, u8 line,
32                         void (*)(void *, int state), void *data);
33         void (*isr_del)(struct nouveau_gpio *, int idx, u8 tag, u8 line,
34                         void (*)(void *, int state), void *data);
35 };
36
37 static inline struct nouveau_gpio *
38 nouveau_gpio(void *obj)
39 {
40         return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_GPIO];
41 }
42
43 #define nouveau_gpio_create(p,e,o,d)                                           \
44         nouveau_gpio_create_((p), (e), (o), sizeof(**d), (void **)d)
45 #define nouveau_gpio_destroy(p)                                                \
46         nouveau_subdev_destroy(&(p)->base)
47 #define nouveau_gpio_fini(p,s)                                                 \
48         nouveau_subdev_fini(&(p)->base, (s))
49
50 int nouveau_gpio_create_(struct nouveau_object *, struct nouveau_object *,
51                          struct nouveau_oclass *, int, void **);
52 int nouveau_gpio_init(struct nouveau_gpio *);
53
54 extern struct nouveau_oclass nv10_gpio_oclass;
55 extern struct nouveau_oclass nv50_gpio_oclass;
56 extern struct nouveau_oclass nvd0_gpio_oclass;
57
58 void nv50_gpio_dtor(struct nouveau_object *);
59 int  nv50_gpio_init(struct nouveau_object *);
60 int  nv50_gpio_fini(struct nouveau_object *, bool);
61 void nv50_gpio_intr(struct nouveau_subdev *);
62 void nv50_gpio_irq_enable(struct nouveau_gpio *, int line, bool);
63
64 #endif