Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1 | #ifndef __NOUVEAU_I2C_H__ |
| 2 | #define __NOUVEAU_I2C_H__ |
| 3 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 4 | #include <core/subdev.h> |
| 5 | #include <core/device.h> |
| 6 | |
| 7 | #include <subdev/bios.h> |
| 8 | #include <subdev/bios/i2c.h> |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 9 | |
Ben Skeggs | 486a45c | 2011-11-11 10:22:19 +1000 | [diff] [blame] | 10 | #define NV_I2C_PORT(n) (0x00 + (n)) |
Ben Skeggs | 486a45c | 2011-11-11 10:22:19 +1000 | [diff] [blame] | 11 | #define NV_I2C_DEFAULT(n) (0x80 + (n)) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 12 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 13 | struct nouveau_i2c_port { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 14 | struct i2c_adapter adapter; |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 15 | struct nouveau_i2c *i2c; |
Ben Skeggs | ec9b3a9 | 2012-05-04 14:38:49 +1000 | [diff] [blame] | 16 | struct i2c_algo_bit_data bit; |
Ben Skeggs | 486a45c | 2011-11-11 10:22:19 +1000 | [diff] [blame] | 17 | struct list_head head; |
| 18 | u8 index; |
Ben Skeggs | 548ddb6 | 2013-02-16 13:19:18 +1000 | [diff] [blame^] | 19 | u16 type; |
Ben Skeggs | 486a45c | 2011-11-11 10:22:19 +1000 | [diff] [blame] | 20 | u32 dcb; |
Ben Skeggs | 2bdb06e | 2011-11-17 13:56:14 +1000 | [diff] [blame] | 21 | u32 drive; |
| 22 | u32 sense; |
| 23 | u32 state; |
Ben Skeggs | 31a34aa | 2013-02-14 20:59:41 -0500 | [diff] [blame] | 24 | void (*aux_mux)(struct nouveau_i2c_port *); |
| 25 | int (*aux)(struct nouveau_i2c_port *, u8, u32, u8 *, u8); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 26 | }; |
| 27 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 28 | struct nouveau_i2c { |
| 29 | struct nouveau_subdev base; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 30 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 31 | struct nouveau_i2c_port *(*find)(struct nouveau_i2c *, u8 index); |
Ben Skeggs | 548ddb6 | 2013-02-16 13:19:18 +1000 | [diff] [blame^] | 32 | struct nouveau_i2c_port *(*find_type)(struct nouveau_i2c *, u16 type); |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 33 | int (*identify)(struct nouveau_i2c *, int index, |
| 34 | const char *what, struct i2c_board_info *, |
| 35 | bool (*match)(struct nouveau_i2c_port *, |
| 36 | struct i2c_board_info *)); |
| 37 | struct list_head ports; |
| 38 | }; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 39 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 40 | static inline struct nouveau_i2c * |
| 41 | nouveau_i2c(void *obj) |
| 42 | { |
| 43 | return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_I2C]; |
| 44 | } |
| 45 | |
| 46 | extern struct nouveau_oclass nouveau_i2c_oclass; |
| 47 | |
| 48 | void nouveau_i2c_drive_scl(void *, int); |
| 49 | void nouveau_i2c_drive_sda(void *, int); |
| 50 | int nouveau_i2c_sense_scl(void *); |
| 51 | int nouveau_i2c_sense_sda(void *); |
| 52 | |
| 53 | int nv_rdi2cr(struct nouveau_i2c_port *, u8 addr, u8 reg); |
| 54 | int nv_wri2cr(struct nouveau_i2c_port *, u8 addr, u8 reg, u8 val); |
| 55 | bool nv_probe_i2c(struct nouveau_i2c_port *, u8 addr); |
| 56 | |
| 57 | int nv_rdaux(struct nouveau_i2c_port *, u32 addr, u8 *data, u8 size); |
| 58 | int nv_wraux(struct nouveau_i2c_port *, u32 addr, u8 *data, u8 size); |
| 59 | |
| 60 | extern const struct i2c_algorithm nouveau_i2c_bit_algo; |
| 61 | extern const struct i2c_algorithm nouveau_i2c_aux_algo; |
| 62 | |
Ben Skeggs | 31a34aa | 2013-02-14 20:59:41 -0500 | [diff] [blame] | 63 | void nv94_aux_mux(struct nouveau_i2c_port *); |
| 64 | int nv94_aux(struct nouveau_i2c_port *, u8, u32, u8 *, u8); |
| 65 | |
Ben Skeggs | 4196faa | 2012-07-10 14:36:38 +1000 | [diff] [blame] | 66 | #endif |