0001
0002 #ifndef __NVKM_I2C_PAD_H__
0003 #define __NVKM_I2C_PAD_H__
0004 #include "priv.h"
0005
0006 struct nvkm_i2c_pad {
0007 const struct nvkm_i2c_pad_func *func;
0008 struct nvkm_i2c *i2c;
0009 #define NVKM_I2C_PAD_HYBRID(n) (n)
0010 #define NVKM_I2C_PAD_CCB(n) ((n) + 0x100)
0011 #define NVKM_I2C_PAD_EXT(n) ((n) + 0x200)
0012 int id;
0013
0014 enum nvkm_i2c_pad_mode {
0015 NVKM_I2C_PAD_OFF,
0016 NVKM_I2C_PAD_I2C,
0017 NVKM_I2C_PAD_AUX,
0018 } mode;
0019 struct mutex mutex;
0020 struct list_head head;
0021 };
0022
0023 struct nvkm_i2c_pad_func {
0024 int (*bus_new_0)(struct nvkm_i2c_pad *, int id, u8 drive, u8 sense,
0025 struct nvkm_i2c_bus **);
0026 int (*bus_new_4)(struct nvkm_i2c_pad *, int id, u8 drive,
0027 struct nvkm_i2c_bus **);
0028
0029 int (*aux_new_6)(struct nvkm_i2c_pad *, int id, u8 drive,
0030 struct nvkm_i2c_aux **);
0031
0032 void (*mode)(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
0033 };
0034
0035 void nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,
0036 int id, struct nvkm_i2c_pad *);
0037 int nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *,
0038 int id, struct nvkm_i2c_pad **);
0039 void nvkm_i2c_pad_del(struct nvkm_i2c_pad **);
0040 void nvkm_i2c_pad_init(struct nvkm_i2c_pad *);
0041 void nvkm_i2c_pad_fini(struct nvkm_i2c_pad *);
0042 void nvkm_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
0043 int nvkm_i2c_pad_acquire(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
0044 void nvkm_i2c_pad_release(struct nvkm_i2c_pad *);
0045
0046 void g94_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode);
0047
0048 int nv04_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0049 int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0050 int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0051 int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0052 int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0053 int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0054
0055 int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0056 int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0057 int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
0058
0059 int anx9805_pad_new(struct nvkm_i2c_bus *, int, u8, struct nvkm_i2c_pad **);
0060
0061 #define PAD_MSG(p,l,f,a...) do { \
0062 struct nvkm_i2c_pad *_pad = (p); \
0063 nvkm_##l(&_pad->i2c->subdev, "pad %04x: "f"\n", _pad->id, ##a); \
0064 } while(0)
0065 #define PAD_ERR(p,f,a...) PAD_MSG((p), error, f, ##a)
0066 #define PAD_DBG(p,f,a...) PAD_MSG((p), debug, f, ##a)
0067 #define PAD_TRACE(p,f,a...) PAD_MSG((p), trace, f, ##a)
0068 #endif