1 #ifndef __NVKM_I2C_PRIV_H__
2 #define __NVKM_I2C_PRIV_H__
3 #include <subdev/i2c.h>
4 
5 extern struct nvkm_oclass nv04_i2c_pad_oclass;
6 extern struct nvkm_oclass g94_i2c_pad_oclass;
7 extern struct nvkm_oclass gm204_i2c_pad_oclass;
8 
9 #define nvkm_i2c_port_create(p,e,o,i,a,f,d)                                 \
10 	nvkm_i2c_port_create_((p), (e), (o), (i), (a), (f),                 \
11 				 sizeof(**d), (void **)d)
12 #define nvkm_i2c_port_destroy(p) ({                                         \
13 	struct nvkm_i2c_port *port = (p);                                   \
14 	_nvkm_i2c_port_dtor(nv_object(i2c));                                \
15 })
16 #define nvkm_i2c_port_init(p)                                               \
17 	nvkm_object_init(&(p)->base)
18 #define nvkm_i2c_port_fini(p,s)                                             \
19 	nvkm_object_fini(&(p)->base, (s))
20 
21 int nvkm_i2c_port_create_(struct nvkm_object *, struct nvkm_object *,
22 			     struct nvkm_oclass *, u8,
23 			     const struct i2c_algorithm *,
24 			     const struct nvkm_i2c_func *,
25 			     int, void **);
26 void _nvkm_i2c_port_dtor(struct nvkm_object *);
27 #define _nvkm_i2c_port_init nvkm_object_init
28 int  _nvkm_i2c_port_fini(struct nvkm_object *, bool);
29 
30 #define nvkm_i2c_create(p,e,o,d)                                            \
31 	nvkm_i2c_create_((p), (e), (o), sizeof(**d), (void **)d)
32 #define nvkm_i2c_destroy(p) ({                                              \
33 	struct nvkm_i2c *i2c = (p);                                         \
34 	_nvkm_i2c_dtor(nv_object(i2c));                                     \
35 })
36 #define nvkm_i2c_init(p) ({                                                 \
37 	struct nvkm_i2c *i2c = (p);                                         \
38 	_nvkm_i2c_init(nv_object(i2c));                                     \
39 })
40 #define nvkm_i2c_fini(p,s) ({                                               \
41 	struct nvkm_i2c *i2c = (p);                                         \
42 	_nvkm_i2c_fini(nv_object(i2c), (s));                                \
43 })
44 
45 int nvkm_i2c_create_(struct nvkm_object *, struct nvkm_object *,
46 			struct nvkm_oclass *, int, void **);
47 int  _nvkm_i2c_ctor(struct nvkm_object *, struct nvkm_object *,
48 		       struct nvkm_oclass *, void *, u32,
49 		       struct nvkm_object **);
50 void _nvkm_i2c_dtor(struct nvkm_object *);
51 int  _nvkm_i2c_init(struct nvkm_object *);
52 int  _nvkm_i2c_fini(struct nvkm_object *, bool);
53 
54 extern struct nvkm_oclass nvkm_anx9805_sclass[];
55 extern struct nvkm_oclass gf110_i2c_sclass[];
56 
57 extern const struct i2c_algorithm nvkm_i2c_bit_algo;
58 extern const struct i2c_algorithm nvkm_i2c_aux_algo;
59 
60 struct nvkm_i2c_impl {
61 	struct nvkm_oclass base;
62 
63 	/* supported i2c port classes */
64 	struct nvkm_oclass *sclass;
65 	struct nvkm_oclass *pad_x;
66 	struct nvkm_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 nvkm_i2c *, u32 *, u32 *, u32 *, u32 *);
76 
77 	/* mask on/off interrupt types for a given set of auxch
78 	 */
79 	void (*aux_mask)(struct nvkm_i2c *, u32, u32, u32);
80 };
81 
82 void g94_aux_stat(struct nvkm_i2c *, u32 *, u32 *, u32 *, u32 *);
83 void g94_aux_mask(struct nvkm_i2c *, u32, u32, u32);
84 
85 void gk104_aux_stat(struct nvkm_i2c *, u32 *, u32 *, u32 *, u32 *);
86 void gk104_aux_mask(struct nvkm_i2c *, u32, u32, u32);
87 #endif
88