summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/pad.h
blob: 33f0c809e583b1c9e231f1d3b7fb3a1947bccd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NVKM_I2C_PAD_H__
#define __NVKM_I2C_PAD_H__
#include <subdev/i2c.h>

struct nvkm_i2c_pad {
	const struct nvkm_i2c_pad_func *func;
	struct nvkm_i2c *i2c;
#define NVKM_I2C_PAD_HYBRID(n) /* 'n' is hw pad index */                     (n)
#define NVKM_I2C_PAD_CCB(n) /* 'n' is ccb index */                 ((n) + 0x100)
#define NVKM_I2C_PAD_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x200)
	int id;

	enum nvkm_i2c_pad_mode {
		NVKM_I2C_PAD_OFF,
		NVKM_I2C_PAD_I2C,
		NVKM_I2C_PAD_AUX,
	} mode;
	struct mutex mutex;
	struct list_head head;
};

struct nvkm_i2c_pad_func {
	int (*bus_new_0)(struct nvkm_i2c_pad *, int id, u8 drive, u8 sense,
			 struct nvkm_i2c_bus **);
	int (*bus_new_4)(struct nvkm_i2c_pad *, int id, u8 drive,
			 struct nvkm_i2c_bus **);

	int (*aux_new_6)(struct nvkm_i2c_pad *, int id, u8 drive,
			 struct nvkm_i2c_aux **);

	void (*mode)(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
};

void nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,
		       int id, struct nvkm_i2c_pad *);
int nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,
		      int id, struct nvkm_i2c_pad **);
void nvkm_i2c_pad_del(struct nvkm_i2c_pad **);
void nvkm_i2c_pad_init(struct nvkm_i2c_pad *);
void nvkm_i2c_pad_fini(struct nvkm_i2c_pad *);
void nvkm_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
int nvkm_i2c_pad_acquire(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
void nvkm_i2c_pad_release(struct nvkm_i2c_pad *);

void g94_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);

int nv04_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);

int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);

int anx9805_pad_new(struct nvkm_i2c_bus *, int, u8, struct nvkm_i2c_pad **);

#define PAD_MSG(p,l,f,a...) do {                                               \
	struct nvkm_i2c_pad *_pad = (p);                                       \
	nvkm_##l(&_pad->i2c->subdev, "pad %04x: "f"\n", _pad->id, ##a);        \
} while(0)
#define PAD_ERR(p,f,a...) PAD_MSG((p), error, f, ##a)
#define PAD_DBG(p,f,a...) PAD_MSG((p), debug, f, ##a)
#define PAD_TRACE(p,f,a...) PAD_MSG((p), trace, f, ##a)
#endif