brintos

brintos / linux-shallow public Read only

0
0
Text · 2.7 KiB · 44b7bb7 Raw
69 lines · c
1/* SPDX-License-Identifier: MIT */2#ifndef __NVKM_I2C_PAD_H__3#define __NVKM_I2C_PAD_H__4#include "priv.h"5 6struct nvkm_i2c_pad {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 23struct 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);33};34 35void nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,36		       int id, struct nvkm_i2c_pad *);37int nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,38		      int id, struct nvkm_i2c_pad **);39void nvkm_i2c_pad_del(struct nvkm_i2c_pad **);40void nvkm_i2c_pad_init(struct nvkm_i2c_pad *);41void nvkm_i2c_pad_fini(struct nvkm_i2c_pad *);42void nvkm_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);43int nvkm_i2c_pad_acquire(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);44void nvkm_i2c_pad_release(struct nvkm_i2c_pad *);45 46void g94_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);47 48int nv04_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);49int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);50int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);51int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);52int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);53int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);54 55int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);56int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);57int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);58 59int 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);        \64} while(0)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)68#endif69