Lines Matching refs:aux
46 static ssize_t dp_aux_write(struct dp_aux_private *aux, in dp_aux_write() argument
56 if (aux->read) in dp_aux_write()
72 if (aux->read) in dp_aux_write()
87 aux->catalog->aux_data = reg; in dp_aux_write()
88 dp_catalog_aux_write_data(aux->catalog); in dp_aux_write()
91 dp_catalog_aux_clear_trans(aux->catalog, false); in dp_aux_write()
92 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_write()
95 if (!aux->native) { /* i2c */ in dp_aux_write()
98 if (aux->no_send_addr) in dp_aux_write()
101 if (aux->no_send_stop) in dp_aux_write()
106 aux->catalog->aux_data = reg; in dp_aux_write()
107 dp_catalog_aux_write_trans(aux->catalog); in dp_aux_write()
112 static ssize_t dp_aux_cmd_fifo_tx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_tx() argument
118 reinit_completion(&aux->comp); in dp_aux_cmd_fifo_tx()
120 ret = dp_aux_write(aux, msg); in dp_aux_cmd_fifo_tx()
124 time_left = wait_for_completion_timeout(&aux->comp, in dp_aux_cmd_fifo_tx()
132 static ssize_t dp_aux_cmd_fifo_rx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_rx() argument
140 dp_catalog_aux_clear_trans(aux->catalog, true); in dp_aux_cmd_fifo_rx()
145 aux->catalog->aux_data = data; in dp_aux_cmd_fifo_rx()
146 dp_catalog_aux_write_data(aux->catalog); in dp_aux_cmd_fifo_rx()
151 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
154 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
165 static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux, in dp_aux_update_offset_and_segment() argument
174 if (aux->native || i2c_read || ((input_msg->address != edid_address) && in dp_aux_update_offset_and_segment()
181 aux->segment = *data; in dp_aux_update_offset_and_segment()
183 aux->offset = *data; in dp_aux_update_offset_and_segment()
198 static void dp_aux_transfer_helper(struct dp_aux_private *aux, in dp_aux_transfer_helper() argument
219 if (!(aux->offset % edid_block_length) || !send_seg) in dp_aux_transfer_helper()
222 aux->read = false; in dp_aux_transfer_helper()
223 aux->cmd_busy = true; in dp_aux_transfer_helper()
224 aux->no_send_addr = true; in dp_aux_transfer_helper()
225 aux->no_send_stop = true; in dp_aux_transfer_helper()
235 if (aux->segment) { in dp_aux_transfer_helper()
238 helper_msg.buffer = &aux->segment; in dp_aux_transfer_helper()
240 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
252 helper_msg.buffer = &aux->offset; in dp_aux_transfer_helper()
254 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
257 aux->offset += message_size; in dp_aux_transfer_helper()
258 if (aux->offset == 0x80 || aux->offset == 0x100) in dp_aux_transfer_helper()
259 aux->segment = 0x0; /* reset segment at end of block */ in dp_aux_transfer_helper()
273 struct dp_aux_private *aux; in dp_aux_transfer() local
275 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_transfer()
277 aux->native = msg->request & (DP_AUX_NATIVE_WRITE & DP_AUX_NATIVE_READ); in dp_aux_transfer()
281 msg->reply = aux->native ? in dp_aux_transfer()
287 if ((aux->native && msg->size > aux_cmd_native_max) || in dp_aux_transfer()
294 mutex_lock(&aux->mutex); in dp_aux_transfer()
295 if (!aux->initted) { in dp_aux_transfer()
308 if (aux->is_edp) { in dp_aux_transfer()
309 ret = dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog); in dp_aux_transfer()
316 dp_aux_update_offset_and_segment(aux, msg); in dp_aux_transfer()
317 dp_aux_transfer_helper(aux, msg, true); in dp_aux_transfer()
319 aux->read = msg->request & (DP_AUX_I2C_READ & DP_AUX_NATIVE_READ); in dp_aux_transfer()
320 aux->cmd_busy = true; in dp_aux_transfer()
322 if (aux->read) { in dp_aux_transfer()
323 aux->no_send_addr = true; in dp_aux_transfer()
324 aux->no_send_stop = false; in dp_aux_transfer()
326 aux->no_send_addr = true; in dp_aux_transfer()
327 aux->no_send_stop = true; in dp_aux_transfer()
330 ret = dp_aux_cmd_fifo_tx(aux, msg); in dp_aux_transfer()
332 if (aux->native) { in dp_aux_transfer()
333 aux->retry_cnt++; in dp_aux_transfer()
334 if (!(aux->retry_cnt % MAX_AUX_RETRIES)) in dp_aux_transfer()
335 dp_catalog_aux_update_cfg(aux->catalog); in dp_aux_transfer()
338 if (dp_catalog_link_is_connected(aux->catalog)) in dp_aux_transfer()
339 dp_catalog_aux_reset(aux->catalog); in dp_aux_transfer()
341 aux->retry_cnt = 0; in dp_aux_transfer()
342 switch (aux->aux_error_num) { in dp_aux_transfer()
344 if (aux->read) in dp_aux_transfer()
345 ret = dp_aux_cmd_fifo_rx(aux, msg); in dp_aux_transfer()
346 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_ACK : DP_AUX_I2C_REPLY_ACK; in dp_aux_transfer()
349 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_DEFER : DP_AUX_I2C_REPLY_DEFER; in dp_aux_transfer()
355 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_NACK : DP_AUX_I2C_REPLY_NACK; in dp_aux_transfer()
363 aux->cmd_busy = false; in dp_aux_transfer()
366 mutex_unlock(&aux->mutex); in dp_aux_transfer()
374 struct dp_aux_private *aux; in dp_aux_isr() local
381 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_isr()
383 isr = dp_catalog_aux_get_irq(aux->catalog); in dp_aux_isr()
389 if (!aux->cmd_busy) { in dp_aux_isr()
404 aux->aux_error_num = DP_AUX_ERR_PHY; in dp_aux_isr()
405 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_isr()
407 aux->aux_error_num = DP_AUX_ERR_NACK_DEFER; in dp_aux_isr()
409 aux->aux_error_num = DP_AUX_ERR_ADDR; in dp_aux_isr()
411 aux->aux_error_num = DP_AUX_ERR_TOUT; in dp_aux_isr()
412 } else if (!aux->native && (isr & DP_INTR_I2C_NACK)) { in dp_aux_isr()
413 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_isr()
414 } else if (!aux->native && (isr & DP_INTR_I2C_DEFER)) { in dp_aux_isr()
416 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_isr()
418 aux->aux_error_num = DP_AUX_ERR_DEFER; in dp_aux_isr()
420 aux->aux_error_num = DP_AUX_ERR_NONE; in dp_aux_isr()
426 complete(&aux->comp); in dp_aux_isr()
433 struct dp_aux_private *aux; in dp_aux_reconfig() local
435 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_reconfig()
437 dp_catalog_aux_update_cfg(aux->catalog); in dp_aux_reconfig()
438 dp_catalog_aux_reset(aux->catalog); in dp_aux_reconfig()
443 struct dp_aux_private *aux; in dp_aux_init() local
450 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_init()
452 mutex_lock(&aux->mutex); in dp_aux_init()
454 dp_catalog_aux_enable(aux->catalog, true); in dp_aux_init()
455 aux->retry_cnt = 0; in dp_aux_init()
456 aux->initted = true; in dp_aux_init()
458 mutex_unlock(&aux->mutex); in dp_aux_init()
463 struct dp_aux_private *aux; in dp_aux_deinit() local
465 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_deinit()
467 mutex_lock(&aux->mutex); in dp_aux_deinit()
469 aux->initted = false; in dp_aux_deinit()
470 dp_catalog_aux_enable(aux->catalog, false); in dp_aux_deinit()
472 mutex_unlock(&aux->mutex); in dp_aux_deinit()
477 struct dp_aux_private *aux; in dp_aux_register() local
485 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_register()
487 aux->dp_aux.name = "dpu_dp_aux"; in dp_aux_register()
488 aux->dp_aux.dev = aux->dev; in dp_aux_register()
489 aux->dp_aux.transfer = dp_aux_transfer; in dp_aux_register()
490 ret = drm_dp_aux_register(&aux->dp_aux); in dp_aux_register()
508 struct dp_aux_private *aux; in dp_aux_get() local
515 aux = devm_kzalloc(dev, sizeof(*aux), GFP_KERNEL); in dp_aux_get()
516 if (!aux) in dp_aux_get()
519 init_completion(&aux->comp); in dp_aux_get()
520 aux->cmd_busy = false; in dp_aux_get()
521 aux->is_edp = is_edp; in dp_aux_get()
522 mutex_init(&aux->mutex); in dp_aux_get()
524 aux->dev = dev; in dp_aux_get()
525 aux->catalog = catalog; in dp_aux_get()
526 aux->retry_cnt = 0; in dp_aux_get()
528 return &aux->dp_aux; in dp_aux_get()
533 struct dp_aux_private *aux; in dp_aux_put() local
538 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_put()
540 mutex_destroy(&aux->mutex); in dp_aux_put()
542 devm_kfree(aux->dev, aux); in dp_aux_put()