1b7019ac5SIlia Mirkin /* SPDX-License-Identifier: MIT */ 2c39f472eSBen Skeggs #ifndef __NVKM_I2C_PAD_H__ 3c39f472eSBen Skeggs #define __NVKM_I2C_PAD_H__ 4*8ad95edcSBen Skeggs #include "priv.h" 5c39f472eSBen Skeggs 6c39f472eSBen Skeggs struct nvkm_i2c_pad { 72aa5eac5SBen Skeggs const struct nvkm_i2c_pad_func *func; 82aa5eac5SBen Skeggs struct nvkm_i2c *i2c; 92aa5eac5SBen Skeggs #define NVKM_I2C_PAD_HYBRID(n) /* 'n' is hw pad index */ (n) 102aa5eac5SBen Skeggs #define NVKM_I2C_PAD_CCB(n) /* 'n' is ccb index */ ((n) + 0x100) 112aa5eac5SBen Skeggs #define NVKM_I2C_PAD_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x200) 122aa5eac5SBen Skeggs int id; 132aa5eac5SBen Skeggs 142aa5eac5SBen Skeggs enum nvkm_i2c_pad_mode { 152aa5eac5SBen Skeggs NVKM_I2C_PAD_OFF, 162aa5eac5SBen Skeggs NVKM_I2C_PAD_I2C, 172aa5eac5SBen Skeggs NVKM_I2C_PAD_AUX, 182aa5eac5SBen Skeggs } mode; 192aa5eac5SBen Skeggs struct mutex mutex; 202aa5eac5SBen Skeggs struct list_head head; 21c39f472eSBen Skeggs }; 22c39f472eSBen Skeggs 232aa5eac5SBen Skeggs struct nvkm_i2c_pad_func { 242aa5eac5SBen Skeggs int (*bus_new_0)(struct nvkm_i2c_pad *, int id, u8 drive, u8 sense, 252aa5eac5SBen Skeggs struct nvkm_i2c_bus **); 262aa5eac5SBen Skeggs int (*bus_new_4)(struct nvkm_i2c_pad *, int id, u8 drive, 272aa5eac5SBen Skeggs struct nvkm_i2c_bus **); 28c39f472eSBen Skeggs 292aa5eac5SBen Skeggs int (*aux_new_6)(struct nvkm_i2c_pad *, int id, u8 drive, 302aa5eac5SBen Skeggs struct nvkm_i2c_aux **); 31c39f472eSBen Skeggs 322aa5eac5SBen Skeggs void (*mode)(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); 332aa5eac5SBen Skeggs }; 34c39f472eSBen Skeggs 352aa5eac5SBen Skeggs void nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *, 362aa5eac5SBen Skeggs int id, struct nvkm_i2c_pad *); 372aa5eac5SBen Skeggs int nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *, struct nvkm_i2c *, 382aa5eac5SBen Skeggs int id, struct nvkm_i2c_pad **); 392aa5eac5SBen Skeggs void nvkm_i2c_pad_del(struct nvkm_i2c_pad **); 402aa5eac5SBen Skeggs void nvkm_i2c_pad_init(struct nvkm_i2c_pad *); 412aa5eac5SBen Skeggs void nvkm_i2c_pad_fini(struct nvkm_i2c_pad *); 422aa5eac5SBen Skeggs void nvkm_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); 432aa5eac5SBen Skeggs int nvkm_i2c_pad_acquire(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); 442aa5eac5SBen Skeggs void nvkm_i2c_pad_release(struct nvkm_i2c_pad *); 45c39f472eSBen Skeggs 462aa5eac5SBen Skeggs void g94_i2c_pad_mode(struct nvkm_i2c_pad *, enum nvkm_i2c_pad_mode); 472aa5eac5SBen Skeggs 482aa5eac5SBen Skeggs int nv04_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 492aa5eac5SBen Skeggs int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 502aa5eac5SBen Skeggs int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 512aa5eac5SBen Skeggs int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 522aa5eac5SBen Skeggs int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 53db1eb528SBen Skeggs int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 542aa5eac5SBen Skeggs 552aa5eac5SBen Skeggs int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 562aa5eac5SBen Skeggs int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 57db1eb528SBen Skeggs int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **); 582aa5eac5SBen Skeggs 592aa5eac5SBen Skeggs int anx9805_pad_new(struct nvkm_i2c_bus *, int, u8, struct nvkm_i2c_pad **); 602aa5eac5SBen Skeggs 612aa5eac5SBen Skeggs #define PAD_MSG(p,l,f,a...) do { \ 622aa5eac5SBen Skeggs struct nvkm_i2c_pad *_pad = (p); \ 632aa5eac5SBen Skeggs nvkm_##l(&_pad->i2c->subdev, "pad %04x: "f"\n", _pad->id, ##a); \ 64c39f472eSBen Skeggs } while(0) 652aa5eac5SBen Skeggs #define PAD_ERR(p,f,a...) PAD_MSG((p), error, f, ##a) 662aa5eac5SBen Skeggs #define PAD_DBG(p,f,a...) PAD_MSG((p), debug, f, ##a) 672aa5eac5SBen Skeggs #define PAD_TRACE(p,f,a...) PAD_MSG((p), trace, f, ##a) 68c39f472eSBen Skeggs #endif 69