Lines Matching full:aux
50 static ssize_t dp_aux_write(struct dp_aux_private *aux, in dp_aux_write() argument
60 if (aux->read) in dp_aux_write()
76 if (aux->read) in dp_aux_write()
91 dp_catalog_aux_write_data(aux->catalog, reg); in dp_aux_write()
94 dp_catalog_aux_clear_trans(aux->catalog, false); in dp_aux_write()
95 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_write()
98 if (!aux->native) { /* i2c */ in dp_aux_write()
101 if (aux->no_send_addr) in dp_aux_write()
104 if (aux->no_send_stop) in dp_aux_write()
109 dp_catalog_aux_write_trans(aux->catalog, reg); in dp_aux_write()
114 static ssize_t dp_aux_cmd_fifo_tx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_tx() argument
120 reinit_completion(&aux->comp); in dp_aux_cmd_fifo_tx()
122 ret = dp_aux_write(aux, msg); in dp_aux_cmd_fifo_tx()
126 time_left = wait_for_completion_timeout(&aux->comp, in dp_aux_cmd_fifo_tx()
134 static ssize_t dp_aux_cmd_fifo_rx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_rx() argument
142 dp_catalog_aux_clear_trans(aux->catalog, true); in dp_aux_cmd_fifo_rx()
147 dp_catalog_aux_write_data(aux->catalog, data); in dp_aux_cmd_fifo_rx()
152 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
155 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
166 static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux, in dp_aux_update_offset_and_segment() argument
175 if (aux->native || i2c_read || ((input_msg->address != edid_address) && in dp_aux_update_offset_and_segment()
182 aux->segment = *data; in dp_aux_update_offset_and_segment()
184 aux->offset = *data; in dp_aux_update_offset_and_segment()
190 * @aux: DP AUX private structure
199 static void dp_aux_transfer_helper(struct dp_aux_private *aux, in dp_aux_transfer_helper() argument
217 * duplicate AUX transactions related to this while reading the in dp_aux_transfer_helper()
220 if (!(aux->offset % edid_block_length) || !send_seg) in dp_aux_transfer_helper()
223 aux->read = false; in dp_aux_transfer_helper()
224 aux->cmd_busy = true; in dp_aux_transfer_helper()
225 aux->no_send_addr = true; in dp_aux_transfer_helper()
226 aux->no_send_stop = true; in dp_aux_transfer_helper()
236 if (aux->segment) { in dp_aux_transfer_helper()
239 helper_msg.buffer = &aux->segment; in dp_aux_transfer_helper()
241 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
249 * native AUX transfer function. in dp_aux_transfer_helper()
253 helper_msg.buffer = &aux->offset; in dp_aux_transfer_helper()
255 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
258 aux->offset += message_size; in dp_aux_transfer_helper()
259 if (aux->offset == 0x80 || aux->offset == 0x100) in dp_aux_transfer_helper()
260 aux->segment = 0x0; /* reset segment at end of block */ in dp_aux_transfer_helper()
264 * This function does the real job to process an AUX transaction.
265 * It will call aux_reset() function to reset the AUX channel,
274 struct dp_aux_private *aux; in dp_aux_transfer() local
276 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_transfer()
278 aux->native = msg->request & (DP_AUX_NATIVE_WRITE & DP_AUX_NATIVE_READ); in dp_aux_transfer()
282 msg->reply = aux->native ? in dp_aux_transfer()
288 if ((aux->native && msg->size > aux_cmd_native_max) || in dp_aux_transfer()
299 mutex_lock(&aux->mutex); in dp_aux_transfer()
300 if (!aux->initted) { in dp_aux_transfer()
308 * can end up with long timeouts if someone tries to access the DP AUX in dp_aux_transfer()
311 if (!aux->is_edp && !aux->enable_xfers) { 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 phy_calibrate(aux->phy); in dp_aux_transfer()
337 /* reset aux if link is in connected state */ 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()
375 struct dp_aux_private *aux; in dp_aux_isr() local
382 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_isr()
384 isr = dp_catalog_aux_get_irq(aux->catalog); in dp_aux_isr()
390 if (!aux->cmd_busy) { in dp_aux_isr()
391 DRM_ERROR("Unexpected DP AUX IRQ %#010x when not busy\n", isr); in dp_aux_isr()
402 DRM_WARN("Some DP AUX interrupts unhandled: %#010x\n", isr); in dp_aux_isr()
405 aux->aux_error_num = DP_AUX_ERR_PHY; in dp_aux_isr()
406 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_isr()
408 aux->aux_error_num = DP_AUX_ERR_NACK_DEFER; in dp_aux_isr()
410 aux->aux_error_num = DP_AUX_ERR_ADDR; in dp_aux_isr()
412 aux->aux_error_num = DP_AUX_ERR_TOUT; in dp_aux_isr()
413 } else if (!aux->native && (isr & DP_INTR_I2C_NACK)) { in dp_aux_isr()
414 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_isr()
415 } else if (!aux->native && (isr & DP_INTR_I2C_DEFER)) { in dp_aux_isr()
417 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_isr()
419 aux->aux_error_num = DP_AUX_ERR_DEFER; in dp_aux_isr()
421 aux->aux_error_num = DP_AUX_ERR_NONE; in dp_aux_isr()
427 complete(&aux->comp); in dp_aux_isr()
434 struct dp_aux_private *aux; in dp_aux_enable_xfers() local
436 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_enable_xfers()
437 aux->enable_xfers = enabled; in dp_aux_enable_xfers()
442 struct dp_aux_private *aux; in dp_aux_reconfig() local
444 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_reconfig()
446 phy_calibrate(aux->phy); in dp_aux_reconfig()
447 dp_catalog_aux_reset(aux->catalog); in dp_aux_reconfig()
452 struct dp_aux_private *aux; in dp_aux_init() local
459 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_init()
461 mutex_lock(&aux->mutex); in dp_aux_init()
463 dp_catalog_aux_enable(aux->catalog, true); in dp_aux_init()
464 aux->retry_cnt = 0; in dp_aux_init()
465 aux->initted = true; in dp_aux_init()
467 mutex_unlock(&aux->mutex); in dp_aux_init()
472 struct dp_aux_private *aux; in dp_aux_deinit() local
474 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_deinit()
476 mutex_lock(&aux->mutex); in dp_aux_deinit()
478 aux->initted = false; in dp_aux_deinit()
479 dp_catalog_aux_enable(aux->catalog, false); in dp_aux_deinit()
481 mutex_unlock(&aux->mutex); in dp_aux_deinit()
495 DRM_ERROR("%s: failed to register drm aux: %d\n", __func__, in dp_aux_register()
512 struct dp_aux_private *aux; in dp_wait_hpd_asserted() local
514 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_wait_hpd_asserted()
516 ret = pm_runtime_resume_and_get(aux->dev); in dp_wait_hpd_asserted()
520 ret = dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog, wait_us); in dp_wait_hpd_asserted()
521 pm_runtime_put_sync(aux->dev); in dp_wait_hpd_asserted()
530 struct dp_aux_private *aux; in dp_aux_get() local
537 aux = devm_kzalloc(dev, sizeof(*aux), GFP_KERNEL); in dp_aux_get()
538 if (!aux) in dp_aux_get()
541 init_completion(&aux->comp); in dp_aux_get()
542 aux->cmd_busy = false; in dp_aux_get()
543 aux->is_edp = is_edp; in dp_aux_get()
544 mutex_init(&aux->mutex); in dp_aux_get()
546 aux->dev = dev; in dp_aux_get()
547 aux->catalog = catalog; in dp_aux_get()
548 aux->phy = phy; in dp_aux_get()
549 aux->retry_cnt = 0; in dp_aux_get()
552 * Use the drm_dp_aux_init() to use the aux adapter in dp_aux_get()
553 * before registering AUX with the DRM device so that in dp_aux_get()
556 aux->dp_aux.name = "dpu_dp_aux"; in dp_aux_get()
557 aux->dp_aux.dev = dev; in dp_aux_get()
558 aux->dp_aux.transfer = dp_aux_transfer; in dp_aux_get()
559 aux->dp_aux.wait_hpd_asserted = dp_wait_hpd_asserted; in dp_aux_get()
560 drm_dp_aux_init(&aux->dp_aux); in dp_aux_get()
562 return &aux->dp_aux; in dp_aux_get()
567 struct dp_aux_private *aux; in dp_aux_put() local
572 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_put()
574 mutex_destroy(&aux->mutex); in dp_aux_put()
576 devm_kfree(aux->dev, aux); in dp_aux_put()