1 #ifndef __NOUVEAU_I2C_H__
2 #define __NOUVEAU_I2C_H__
4 #include <core/subdev.h>
5 #include <core/device.h>
7 #include <subdev/bios.h>
8 #include <subdev/bios/i2c.h>
10 #define NV_I2C_PORT(n) (0x00 + (n))
11 #define NV_I2C_DEFAULT(n) (0x80 + (n))
13 #define NV_I2C_TYPE_DCBI2C(n) (0x0000 | (n))
14 #define NV_I2C_TYPE_EXTDDC(e) (0x0005 | (e) << 8)
15 #define NV_I2C_TYPE_EXTAUX(e) (0x0006 | (e) << 8)
22 NVKM_I2C_ANY
= (NVKM_I2C_PLUG
|
28 struct nouveau_i2c_port
{
29 struct nouveau_object base
;
30 struct i2c_adapter adapter
;
33 struct list_head head
;
37 const struct nouveau_i2c_func
*func
;
40 struct nouveau_i2c_func
{
41 void (*drive_scl
)(struct nouveau_i2c_port
*, int);
42 void (*drive_sda
)(struct nouveau_i2c_port
*, int);
43 int (*sense_scl
)(struct nouveau_i2c_port
*);
44 int (*sense_sda
)(struct nouveau_i2c_port
*);
46 int (*aux
)(struct nouveau_i2c_port
*, bool, u8
, u32
, u8
*, u8
);
47 int (*pattern
)(struct nouveau_i2c_port
*, int pattern
);
48 int (*lnk_ctl
)(struct nouveau_i2c_port
*, int nr
, int bw
, bool enh
);
49 int (*drv_ctl
)(struct nouveau_i2c_port
*, int lane
, int sw
, int pe
);
52 struct nouveau_i2c_board_info
{
53 struct i2c_board_info dev
;
54 u8 udelay
; /* set to 0 to use the standard delay */
58 struct nouveau_subdev base
;
59 struct nouveau_event
*ntfy
;
61 struct nouveau_i2c_port
*(*find
)(struct nouveau_i2c
*, u8 index
);
62 struct nouveau_i2c_port
*(*find_type
)(struct nouveau_i2c
*, u16 type
);
63 int (*acquire_pad
)(struct nouveau_i2c_port
*, unsigned long timeout
);
64 void (*release_pad
)(struct nouveau_i2c_port
*);
65 int (*acquire
)(struct nouveau_i2c_port
*, unsigned long timeout
);
66 void (*release
)(struct nouveau_i2c_port
*);
67 int (*identify
)(struct nouveau_i2c
*, int index
,
68 const char *what
, struct nouveau_i2c_board_info
*,
69 bool (*match
)(struct nouveau_i2c_port
*,
70 struct i2c_board_info
*, void *), void *);
72 wait_queue_head_t wait
;
73 struct list_head ports
;
76 static inline struct nouveau_i2c
*
77 nouveau_i2c(void *obj
)
79 return (void *)nv_device(obj
)->subdev
[NVDEV_SUBDEV_I2C
];
82 extern struct nouveau_oclass
*nv04_i2c_oclass
;
83 extern struct nouveau_oclass
*nv4e_i2c_oclass
;
84 extern struct nouveau_oclass
*nv50_i2c_oclass
;
85 extern struct nouveau_oclass
*nv94_i2c_oclass
;
86 extern struct nouveau_oclass
*nvd0_i2c_oclass
;
87 extern struct nouveau_oclass
*gf117_i2c_oclass
;
88 extern struct nouveau_oclass
*nve0_i2c_oclass
;
91 nv_rdi2cr(struct nouveau_i2c_port
*port
, u8 addr
, u8 reg
)
94 struct i2c_msg msgs
[] = {
95 { .addr
= addr
, .flags
= 0, .len
= 1, .buf
= ®
},
96 { .addr
= addr
, .flags
= I2C_M_RD
, .len
= 1, .buf
= &val
},
99 int ret
= i2c_transfer(&port
->adapter
, msgs
, 2);
107 nv_wri2cr(struct nouveau_i2c_port
*port
, u8 addr
, u8 reg
, u8 val
)
109 u8 buf
[2] = { reg
, val
};
110 struct i2c_msg msgs
[] = {
111 { .addr
= addr
, .flags
= 0, .len
= 2, .buf
= buf
},
114 int ret
= i2c_transfer(&port
->adapter
, msgs
, 1);
122 nv_probe_i2c(struct nouveau_i2c_port
*port
, u8 addr
)
124 return nv_rdi2cr(port
, addr
, 0) >= 0;
127 int nv_rdaux(struct nouveau_i2c_port
*, u32 addr
, u8
*data
, u8 size
);
128 int nv_wraux(struct nouveau_i2c_port
*, u32 addr
, u8
*data
, u8 size
);
This page took 0.032901 seconds and 5 git commands to generate.