]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
9efc583e BS |
2 | #ifndef __NVKM_I2C_PAD_H__ |
3 | #define __NVKM_I2C_PAD_H__ | |
2aa5eac5 | 4 | #include <subdev/i2c.h> |
9efc583e BS |
5 | |
6 | struct nvkm_i2c_pad { | |
2aa5eac5 BS |
7 | const struct nvkm_i2c_pad_func *func; |
8 | struct nvkm_i2c *i2c; | |
9 | #define NVKM_I2C_PAD_HYBRID(n) /* 'n' is hw pad index */ (n) | |
10 | #define NVKM_I2C_PAD_CCB(n) /* 'n' is ccb index */ ((n) + 0x100) | |
11 | #define NVKM_I2C_PAD_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x200) | |
12 | int id; | |
13 | ||
14 | enum nvkm_i2c_pad_mode { | |
15 | NVKM_I2C_PAD_OFF, | |
16 | NVKM_I2C_PAD_I2C, | |
17 | NVKM_I2C_PAD_AUX, | |
18 | } mode; | |
19 | struct mutex mutex; | |
20 | struct list_head head; | |
21 | }; | |
22 | ||
23 | struct nvkm_i2c_pad_func { | |
24 | int (*bus_new_0)(struct nvkm_i2c_pad *, int id, u8 drive, u8 sense, | |
25 | struct nvkm_i2c_bus **); | |
26 | int (*bus_new_4)(struct nvkm_i2c_pad *, int id, u8 drive, | |
27 | struct nvkm_i2c_bus **); | |
28 | ||
29 | int (*aux_new_6)(struct nvkm_i2c_pad *, int id, u8 drive, | |
30 | struct nvkm_i2c_aux **); | |
31 | ||
32 | void (*mode)(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); | |
9efc583e BS |
33 | }; |
34 | ||
2aa5eac5 BS |
35 | void nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *, |
36 | int id, struct nvkm_i2c_pad *); | |
37 | int nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *, | |
38 | int id, struct nvkm_i2c_pad **); | |
39 | void nvkm_i2c_pad_del(struct nvkm_i2c_pad **); | |
40 | void nvkm_i2c_pad_init(struct nvkm_i2c_pad *); | |
41 | void nvkm_i2c_pad_fini(struct nvkm_i2c_pad *); | |
42 | void nvkm_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); | |
43 | int nvkm_i2c_pad_acquire(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); | |
44 | void nvkm_i2c_pad_release(struct nvkm_i2c_pad *); | |
45 | ||
46 | void g94_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); | |
47 | ||
48 | int nv04_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
49 | int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
50 | int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
51 | int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
52 | int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
db1eb528 | 53 | int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); |
2aa5eac5 BS |
54 | |
55 | int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
56 | int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); | |
db1eb528 | 57 | int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); |
2aa5eac5 BS |
58 | |
59 | int anx9805_pad_new(struct nvkm_i2c_bus *, int, u8, struct nvkm_i2c_pad **); | |
60 | ||
61 | #define PAD_MSG(p,l,f,a...) do { \ | |
62 | struct nvkm_i2c_pad *_pad = (p); \ | |
63 | nvkm_##l(&_pad->i2c->subdev, "pad %04x: "f"\n", _pad->id, ##a); \ | |
9efc583e | 64 | } while(0) |
2aa5eac5 BS |
65 | #define PAD_ERR(p,f,a...) PAD_MSG((p), error, f, ##a) |
66 | #define PAD_DBG(p,f,a...) PAD_MSG((p), debug, f, ##a) | |
67 | #define PAD_TRACE(p,f,a...) PAD_MSG((p), trace, f, ##a) | |
9efc583e | 68 | #endif |