Lines Matching refs:i3c
68 RemoteI3C *i3c = REMOTE_I3C(t); in remote_i3c_recv() local
72 qemu_chr_fe_write_all(&i3c->chr, &type, 1); in remote_i3c_recv()
74 qemu_chr_fe_write_all(&i3c->chr, (uint8_t *)&num_to_read_le, in remote_i3c_recv()
79 qemu_chr_fe_read_all(&i3c->chr, (uint8_t *)&num_read, sizeof(num_read)); in remote_i3c_recv()
82 qemu_chr_fe_read_all(&i3c->chr, data, num_read); in remote_i3c_recv()
83 trace_remote_i3c_recv(i3c->cfg.name, num_read, num_to_read); in remote_i3c_recv()
87 static inline bool remote_i3c_tx_in_progress(RemoteI3C *i3c) in remote_i3c_tx_in_progress() argument
89 return !fifo8_is_empty(&i3c->tx_fifo); in remote_i3c_tx_in_progress()
92 static int remote_i3c_chr_send_bytes(RemoteI3C *i3c) in remote_i3c_chr_send_bytes() argument
95 uint32_t num_bytes = fifo8_num_used(&i3c->tx_fifo); in remote_i3c_chr_send_bytes()
98 qemu_chr_fe_write_all(&i3c->chr, &i3c->current_cmd, in remote_i3c_chr_send_bytes()
99 sizeof(i3c->current_cmd)); in remote_i3c_chr_send_bytes()
103 buf[i] = fifo8_pop(&i3c->tx_fifo); in remote_i3c_chr_send_bytes()
107 qemu_chr_fe_write_all(&i3c->chr, (uint8_t *)&num_bytes_le, 4); in remote_i3c_chr_send_bytes()
108 qemu_chr_fe_write_all(&i3c->chr, buf, num_bytes); in remote_i3c_chr_send_bytes()
109 trace_remote_i3c_send(i3c->cfg.name, num_bytes, i3c->current_cmd == in remote_i3c_chr_send_bytes()
115 static bool remote_i3c_tx_fifo_push(RemoteI3C *i3c, const uint8_t *data, in remote_i3c_tx_fifo_push() argument
127 if (fifo8_num_free(&i3c->tx_fifo) < num_to_send) { in remote_i3c_tx_fifo_push()
129 object_get_canonical_path(OBJECT(i3c)), i3c->cfg.name); in remote_i3c_tx_fifo_push()
130 num_to_push = fifo8_num_free(&i3c->tx_fifo); in remote_i3c_tx_fifo_push()
136 fifo8_push(&i3c->tx_fifo, data[i]); in remote_i3c_tx_fifo_push()
145 RemoteI3C *i3c = REMOTE_I3C(t); in remote_i3c_send() local
146 i3c->current_cmd = REMOTE_I3C_SEND; in remote_i3c_send()
147 if (!remote_i3c_tx_fifo_push(i3c, data, num_to_send, num_sent)) { in remote_i3c_send()
157 RemoteI3C *i3c = REMOTE_I3C(t); in remote_i3c_handle_ccc_read() local
160 qemu_chr_fe_write_all(&i3c->chr, &type, 1); in remote_i3c_handle_ccc_read()
164 qemu_chr_fe_read_all(&i3c->chr, (uint8_t *)num_read, 4); in remote_i3c_handle_ccc_read()
166 qemu_chr_fe_read_all(&i3c->chr, data, *num_read); in remote_i3c_handle_ccc_read()
167 trace_remote_i3c_ccc_read(i3c->cfg.name, *num_read, num_to_read); in remote_i3c_handle_ccc_read()
175 RemoteI3C *i3c = REMOTE_I3C(t); in remote_i3c_handle_ccc_write() local
176 i3c->current_cmd = REMOTE_I3C_HANDLE_CCC_WRITE; in remote_i3c_handle_ccc_write()
177 if (!remote_i3c_tx_fifo_push(i3c, data, num_to_send, num_sent)) { in remote_i3c_handle_ccc_write()
186 RemoteI3C *i3c = REMOTE_I3C(t); in remote_i3c_event() local
188 trace_remote_i3c_event(i3c->cfg.name, event); in remote_i3c_event()
204 object_get_canonical_path(OBJECT(i3c)), i3c->cfg.name, in remote_i3c_event()
213 if (remote_i3c_tx_in_progress(i3c)) { in remote_i3c_event()
214 remote_i3c_chr_send_bytes(i3c); in remote_i3c_event()
217 qemu_chr_fe_write_all(&i3c->chr, &type, 1); in remote_i3c_event()
239 static void remote_i3c_rx_ibi(RemoteI3C *i3c, const uint8_t *buf, int size) in remote_i3c_rx_ibi() argument
243 switch (i3c->ibi_rx_state) { in remote_i3c_rx_ibi()
246 i3c->ibi_rx_state = IBI_RX_STATE_READ_ADDR; in remote_i3c_rx_ibi()
250 i3c->ibi_data.addr = buf[p_buf]; in remote_i3c_rx_ibi()
252 i3c->ibi_rx_state = IBI_RX_STATE_READ_RNW; in remote_i3c_rx_ibi()
255 i3c->ibi_data.is_recv = buf[p_buf]; in remote_i3c_rx_ibi()
257 i3c->ibi_rx_state = IBI_RX_STATE_READ_SIZE; in remote_i3c_rx_ibi()
260 i3c->ibi_data.num_bytes |= ((uint32_t)buf[p_buf] << in remote_i3c_rx_ibi()
261 (8 * i3c->ibi_bytes_rxed)); in remote_i3c_rx_ibi()
262 i3c->ibi_bytes_rxed++; in remote_i3c_rx_ibi()
268 if (i3c->ibi_bytes_rxed == sizeof(i3c->ibi_data.num_bytes)) { in remote_i3c_rx_ibi()
269 i3c->ibi_data.num_bytes = le32_to_cpu(i3c->ibi_data.num_bytes); in remote_i3c_rx_ibi()
270 i3c->ibi_bytes_rxed = 0; in remote_i3c_rx_ibi()
271 i3c->ibi_rx_state = IBI_RX_STATE_READ_DATA; in remote_i3c_rx_ibi()
273 if (i3c->ibi_data.num_bytes == 0) { in remote_i3c_rx_ibi()
286 object_get_canonical_path(OBJECT(i3c)), in remote_i3c_rx_ibi()
287 i3c->cfg.name); in remote_i3c_rx_ibi()
290 i3c->ibi_rx_state = IBI_RX_STATE_DONE; in remote_i3c_rx_ibi()
296 i3c->ibi_data.data = g_new0(uint8_t, in remote_i3c_rx_ibi()
297 i3c->ibi_data.num_bytes); in remote_i3c_rx_ibi()
302 i3c->ibi_data.data[i3c->ibi_bytes_rxed] = buf[p_buf]; in remote_i3c_rx_ibi()
303 i3c->ibi_bytes_rxed++; in remote_i3c_rx_ibi()
305 if (i3c->ibi_bytes_rxed == i3c->ibi_data.num_bytes) { in remote_i3c_rx_ibi()
317 object_get_canonical_path(OBJECT(i3c)), i3c->cfg.name); in remote_i3c_rx_ibi()
320 i3c->ibi_rx_state = IBI_RX_STATE_DONE; in remote_i3c_rx_ibi()
326 object_get_canonical_path(OBJECT(i3c)), i3c->cfg.name, in remote_i3c_rx_ibi()
327 i3c->ibi_rx_state); in remote_i3c_rx_ibi()
333 static void remote_i3c_ibi_rx_state_reset(RemoteI3C *i3c) in remote_i3c_ibi_rx_state_reset() argument
335 if (i3c->ibi_data.num_bytes) { in remote_i3c_ibi_rx_state_reset()
336 free(i3c->ibi_data.data); in remote_i3c_ibi_rx_state_reset()
338 i3c->ibi_data.addr = 0; in remote_i3c_ibi_rx_state_reset()
339 i3c->ibi_data.is_recv = 0; in remote_i3c_ibi_rx_state_reset()
340 i3c->ibi_data.num_bytes = 0; in remote_i3c_ibi_rx_state_reset()
341 i3c->ibi_bytes_rxed = 0; in remote_i3c_ibi_rx_state_reset()
342 i3c->ibi_rx_state = IBI_RX_STATE_DONE; in remote_i3c_ibi_rx_state_reset()
345 static void remote_i3c_do_ibi(RemoteI3C *i3c) in remote_i3c_do_ibi() argument
350 trace_remote_i3c_do_ibi(i3c->cfg.name, i3c->ibi_data.addr, in remote_i3c_do_ibi()
351 i3c->ibi_data.is_recv); in remote_i3c_do_ibi()
352 if (i3c_target_send_ibi(&i3c->parent_obj, i3c->ibi_data.addr, in remote_i3c_do_ibi()
353 i3c->ibi_data.is_recv)) { in remote_i3c_do_ibi()
356 for (i = 0; i < i3c->ibi_data.num_bytes; i++) { in remote_i3c_do_ibi()
357 if (i3c_target_send_ibi_bytes(&i3c->parent_obj, in remote_i3c_do_ibi()
358 i3c->ibi_data.data[i])) { in remote_i3c_do_ibi()
365 if (i3c_target_ibi_finish(&i3c->parent_obj, 0x00)) { in remote_i3c_do_ibi()
368 qemu_chr_fe_write_all(&i3c->chr, &resp, sizeof(resp)); in remote_i3c_do_ibi()
369 remote_i3c_ibi_rx_state_reset(i3c); in remote_i3c_do_ibi()
379 RemoteI3C *i3c = REMOTE_I3C(opaque); in remote_i3c_chr_receive() local
389 if (i3c->ibi_rx_state != IBI_RX_STATE_DONE) { in remote_i3c_chr_receive()
390 remote_i3c_rx_ibi(i3c, buf, size); in remote_i3c_chr_receive()
392 if (i3c->ibi_rx_state == IBI_RX_STATE_DONE) { in remote_i3c_chr_receive()
393 remote_i3c_do_ibi(i3c); in remote_i3c_chr_receive()
403 "target\n", object_get_canonical_path(OBJECT(i3c)), in remote_i3c_chr_receive()
404 i3c->cfg.name); in remote_i3c_chr_receive()
407 remote_i3c_rx_ibi(i3c, buf, size); in remote_i3c_chr_receive()
409 if (i3c->ibi_rx_state == IBI_RX_STATE_DONE) { in remote_i3c_chr_receive()
410 remote_i3c_do_ibi(i3c); in remote_i3c_chr_receive()
415 object_get_canonical_path(OBJECT(i3c)), i3c->cfg.name, in remote_i3c_chr_receive()
423 RemoteI3C *i3c = REMOTE_I3C(dev); in remote_i3c_realize() local
425 fifo8_create(&i3c->tx_fifo, i3c->cfg.buf_size); in remote_i3c_realize()
426 fifo8_create(&i3c->rx_fifo, i3c->cfg.buf_size); in remote_i3c_realize()
427 i3c->ibi_data.data = g_new0(uint8_t, i3c->cfg.buf_size); in remote_i3c_realize()
428 remote_i3c_ibi_rx_state_reset(i3c); in remote_i3c_realize()
430 qemu_chr_fe_set_handlers(&i3c->chr, remote_i3c_chr_can_receive, in remote_i3c_realize()
432 NULL, OBJECT(i3c), NULL, true); in remote_i3c_realize()