1 #ifndef __NOUVEAU_GPIO_H__
2 #define __NOUVEAU_GPIO_H__
4 #include <core/subdev.h>
5 #include <core/device.h>
7 #include <subdev/bios.h>
8 #include <subdev/bios/gpio.h>
11 struct nouveau_subdev base;
13 /* hardware interfaces */
14 void (*reset)(struct nouveau_gpio *);
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);
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);
26 /* interrupt handling */
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);
37 static inline struct nouveau_gpio *
38 nouveau_gpio(void *obj)
40 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_GPIO];
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))
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 *);
54 extern struct nouveau_oclass nv10_gpio_oclass;
55 extern struct nouveau_oclass nv50_gpio_oclass;
56 extern struct nouveau_oclass nvd0_gpio_oclass;
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);