Lines Matching refs:cbuf
54 static void cmdbuf_add(struct pt3_i2cbuf *cbuf, enum ctl_cmd cmd) in cmdbuf_add() argument
58 if ((cbuf->num_cmds % 2) == 0) in cmdbuf_add()
59 cbuf->tmp = cmd; in cmdbuf_add()
61 cbuf->tmp |= cmd << 4; in cmdbuf_add()
62 buf_idx = cbuf->num_cmds / 2; in cmdbuf_add()
63 if (buf_idx < ARRAY_SIZE(cbuf->data)) in cmdbuf_add()
64 cbuf->data[buf_idx] = cbuf->tmp; in cmdbuf_add()
66 cbuf->num_cmds++; in cmdbuf_add()
69 static void put_end(struct pt3_i2cbuf *cbuf) in put_end() argument
71 cmdbuf_add(cbuf, I_END); in put_end()
72 if (cbuf->num_cmds % 2) in put_end()
73 cmdbuf_add(cbuf, I_END); in put_end()
76 static void put_start(struct pt3_i2cbuf *cbuf) in put_start() argument
78 cmdbuf_add(cbuf, I_DATA_H); in put_start()
79 cmdbuf_add(cbuf, I_CLOCK_H); in put_start()
80 cmdbuf_add(cbuf, I_DATA_L); in put_start()
81 cmdbuf_add(cbuf, I_CLOCK_L); in put_start()
84 static void put_byte_write(struct pt3_i2cbuf *cbuf, u8 val) in put_byte_write() argument
90 cmdbuf_add(cbuf, (val & mask) ? I_DATA_H_NOP : I_DATA_L_NOP); in put_byte_write()
91 cmdbuf_add(cbuf, I_DATA_H_ACK0); in put_byte_write()
94 static void put_byte_read(struct pt3_i2cbuf *cbuf, u32 size) in put_byte_read() argument
100 cmdbuf_add(cbuf, I_DATA_H_READ); in put_byte_read()
101 cmdbuf_add(cbuf, (i == size - 1) ? I_DATA_H_NOP : I_DATA_L_NOP); in put_byte_read()
105 static void put_stop(struct pt3_i2cbuf *cbuf) in put_stop() argument
107 cmdbuf_add(cbuf, I_DATA_L); in put_stop()
108 cmdbuf_add(cbuf, I_CLOCK_H); in put_stop()
109 cmdbuf_add(cbuf, I_DATA_H); in put_stop()
114 static void translate(struct pt3_i2cbuf *cbuf, struct i2c_msg *msgs, int num) in translate() argument
119 cbuf->num_cmds = 0; in translate()
122 put_start(cbuf); in translate()
123 put_byte_write(cbuf, msgs[i].addr << 1 | rd); in translate()
125 put_byte_read(cbuf, msgs[i].len); in translate()
128 put_byte_write(cbuf, msgs[i].buf[j]); in translate()
131 put_stop(cbuf); in translate()
132 put_end(cbuf); in translate()
205 struct pt3_i2cbuf *cbuf; in pt3_i2c_master_xfer() local
210 cbuf = pt3->i2c_buf; in pt3_i2c_master_xfer()
220 translate(cbuf, msgs, num); in pt3_i2c_master_xfer()
222 cbuf->data, cbuf->num_cmds); in pt3_i2c_master_xfer()