Merge branch 'next' into for-linus
[cascardo/linux.git] / drivers / gpu / drm / nouveau / core / subdev / i2c / priv.h
1 #ifndef __NVKM_I2C_H__
2 #define __NVKM_I2C_H__
3
4 #include <subdev/i2c.h>
5
6 extern struct nouveau_oclass nv04_i2c_pad_oclass;
7 extern struct nouveau_oclass nv94_i2c_pad_oclass;
8
9 #define nouveau_i2c_port_create(p,e,o,i,a,f,d)                                 \
10         nouveau_i2c_port_create_((p), (e), (o), (i), (a), (f),                 \
11                                  sizeof(**d), (void **)d)
12 #define nouveau_i2c_port_destroy(p) ({                                         \
13         struct nouveau_i2c_port *port = (p);                                   \
14         _nouveau_i2c_port_dtor(nv_object(i2c));                                \
15 })
16 #define nouveau_i2c_port_init(p)                                               \
17         nouveau_object_init(&(p)->base)
18 #define nouveau_i2c_port_fini(p,s)                                             \
19         nouveau_object_fini(&(p)->base, (s))
20
21 int nouveau_i2c_port_create_(struct nouveau_object *, struct nouveau_object *,
22                              struct nouveau_oclass *, u8,
23                              const struct i2c_algorithm *,
24                              const struct nouveau_i2c_func *,
25                              int, void **);
26 void _nouveau_i2c_port_dtor(struct nouveau_object *);
27 #define _nouveau_i2c_port_init nouveau_object_init
28 int  _nouveau_i2c_port_fini(struct nouveau_object *, bool);
29
30 #define nouveau_i2c_create(p,e,o,d)                                            \
31         nouveau_i2c_create_((p), (e), (o), sizeof(**d), (void **)d)
32 #define nouveau_i2c_destroy(p) ({                                              \
33         struct nouveau_i2c *i2c = (p);                                         \
34         _nouveau_i2c_dtor(nv_object(i2c));                                     \
35 })
36 #define nouveau_i2c_init(p) ({                                                 \
37         struct nouveau_i2c *i2c = (p);                                         \
38         _nouveau_i2c_init(nv_object(i2c));                                     \
39 })
40 #define nouveau_i2c_fini(p,s) ({                                               \
41         struct nouveau_i2c *i2c = (p);                                         \
42         _nouveau_i2c_fini(nv_object(i2c), (s));                                \
43 })
44
45 int nouveau_i2c_create_(struct nouveau_object *, struct nouveau_object *,
46                         struct nouveau_oclass *, int, void **);
47 int  _nouveau_i2c_ctor(struct nouveau_object *, struct nouveau_object *,
48                        struct nouveau_oclass *, void *, u32,
49                        struct nouveau_object **);
50 void _nouveau_i2c_dtor(struct nouveau_object *);
51 int  _nouveau_i2c_init(struct nouveau_object *);
52 int  _nouveau_i2c_fini(struct nouveau_object *, bool);
53
54 extern struct nouveau_oclass nouveau_anx9805_sclass[];
55 extern struct nouveau_oclass nvd0_i2c_sclass[];
56
57 extern const struct i2c_algorithm nouveau_i2c_bit_algo;
58 extern const struct i2c_algorithm nouveau_i2c_aux_algo;
59
60 struct nouveau_i2c_impl {
61         struct nouveau_oclass base;
62
63         /* supported i2c port classes */
64         struct nouveau_oclass *sclass;
65         struct nouveau_oclass *pad_x;
66         struct nouveau_oclass *pad_s;
67
68         /* number of native dp aux channels present */
69         int aux;
70
71         /* read and ack pending interrupts, returning only data
72          * for ports that have not been masked off, while still
73          * performing the ack for anything that was pending.
74          */
75         void (*aux_stat)(struct nouveau_i2c *, u32 *, u32 *, u32 *, u32 *);
76
77         /* mask on/off interrupt types for a given set of auxch
78          */
79         void (*aux_mask)(struct nouveau_i2c *, u32, u32, u32);
80 };
81
82 void nv94_aux_stat(struct nouveau_i2c *, u32 *, u32 *, u32 *, u32 *);
83 void nv94_aux_mask(struct nouveau_i2c *, u32, u32, u32);
84
85 #endif