Lines Matching refs:aux
45 static ssize_t dp_aux_write(struct dp_aux_private *aux, in dp_aux_write() argument
55 if (aux->read) in dp_aux_write()
71 if (aux->read) in dp_aux_write()
86 aux->catalog->aux_data = reg; in dp_aux_write()
87 dp_catalog_aux_write_data(aux->catalog); in dp_aux_write()
90 dp_catalog_aux_clear_trans(aux->catalog, false); in dp_aux_write()
91 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_write()
94 if (!aux->native) { /* i2c */ in dp_aux_write()
97 if (aux->no_send_addr) in dp_aux_write()
100 if (aux->no_send_stop) in dp_aux_write()
105 aux->catalog->aux_data = reg; in dp_aux_write()
106 dp_catalog_aux_write_trans(aux->catalog); in dp_aux_write()
111 static ssize_t dp_aux_cmd_fifo_tx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_tx() argument
117 reinit_completion(&aux->comp); in dp_aux_cmd_fifo_tx()
119 ret = dp_aux_write(aux, msg); in dp_aux_cmd_fifo_tx()
123 time_left = wait_for_completion_timeout(&aux->comp, in dp_aux_cmd_fifo_tx()
131 static ssize_t dp_aux_cmd_fifo_rx(struct dp_aux_private *aux, in dp_aux_cmd_fifo_rx() argument
139 dp_catalog_aux_clear_trans(aux->catalog, true); in dp_aux_cmd_fifo_rx()
144 aux->catalog->aux_data = data; in dp_aux_cmd_fifo_rx()
145 dp_catalog_aux_write_data(aux->catalog); in dp_aux_cmd_fifo_rx()
150 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
153 data = dp_catalog_aux_read_data(aux->catalog); in dp_aux_cmd_fifo_rx()
164 static void dp_aux_native_handler(struct dp_aux_private *aux, u32 isr) in dp_aux_native_handler() argument
167 aux->aux_error_num = DP_AUX_ERR_NONE; in dp_aux_native_handler()
169 aux->aux_error_num = DP_AUX_ERR_ADDR; in dp_aux_native_handler()
171 aux->aux_error_num = DP_AUX_ERR_TOUT; in dp_aux_native_handler()
173 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_native_handler()
175 aux->aux_error_num = DP_AUX_ERR_PHY; in dp_aux_native_handler()
176 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_native_handler()
180 static void dp_aux_i2c_handler(struct dp_aux_private *aux, u32 isr) in dp_aux_i2c_handler() argument
184 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_i2c_handler()
186 aux->aux_error_num = DP_AUX_ERR_NONE; in dp_aux_i2c_handler()
189 aux->aux_error_num = DP_AUX_ERR_ADDR; in dp_aux_i2c_handler()
191 aux->aux_error_num = DP_AUX_ERR_TOUT; in dp_aux_i2c_handler()
193 aux->aux_error_num = DP_AUX_ERR_NACK_DEFER; in dp_aux_i2c_handler()
195 aux->aux_error_num = DP_AUX_ERR_NACK; in dp_aux_i2c_handler()
197 aux->aux_error_num = DP_AUX_ERR_DEFER; in dp_aux_i2c_handler()
199 aux->aux_error_num = DP_AUX_ERR_PHY; in dp_aux_i2c_handler()
200 dp_catalog_aux_clear_hw_interrupts(aux->catalog); in dp_aux_i2c_handler()
205 static void dp_aux_update_offset_and_segment(struct dp_aux_private *aux, in dp_aux_update_offset_and_segment() argument
214 if (aux->native || i2c_read || ((input_msg->address != edid_address) && in dp_aux_update_offset_and_segment()
221 aux->segment = *data; in dp_aux_update_offset_and_segment()
223 aux->offset = *data; in dp_aux_update_offset_and_segment()
238 static void dp_aux_transfer_helper(struct dp_aux_private *aux, in dp_aux_transfer_helper() argument
259 if (!(aux->offset % edid_block_length) || !send_seg) in dp_aux_transfer_helper()
262 aux->read = false; in dp_aux_transfer_helper()
263 aux->cmd_busy = true; in dp_aux_transfer_helper()
264 aux->no_send_addr = true; in dp_aux_transfer_helper()
265 aux->no_send_stop = true; in dp_aux_transfer_helper()
275 if (aux->segment) { in dp_aux_transfer_helper()
278 helper_msg.buffer = &aux->segment; in dp_aux_transfer_helper()
280 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
292 helper_msg.buffer = &aux->offset; in dp_aux_transfer_helper()
294 dp_aux_cmd_fifo_tx(aux, &helper_msg); in dp_aux_transfer_helper()
297 aux->offset += message_size; in dp_aux_transfer_helper()
298 if (aux->offset == 0x80 || aux->offset == 0x100) in dp_aux_transfer_helper()
299 aux->segment = 0x0; /* reset segment at end of block */ in dp_aux_transfer_helper()
313 struct dp_aux_private *aux; in dp_aux_transfer() local
315 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_transfer()
317 aux->native = msg->request & (DP_AUX_NATIVE_WRITE & DP_AUX_NATIVE_READ); in dp_aux_transfer()
321 msg->reply = aux->native ? in dp_aux_transfer()
327 if ((aux->native && msg->size > aux_cmd_native_max) || in dp_aux_transfer()
334 mutex_lock(&aux->mutex); in dp_aux_transfer()
335 if (!aux->initted) { in dp_aux_transfer()
340 dp_aux_update_offset_and_segment(aux, msg); in dp_aux_transfer()
341 dp_aux_transfer_helper(aux, msg, true); in dp_aux_transfer()
343 aux->read = msg->request & (DP_AUX_I2C_READ & DP_AUX_NATIVE_READ); in dp_aux_transfer()
344 aux->cmd_busy = true; in dp_aux_transfer()
346 if (aux->read) { in dp_aux_transfer()
347 aux->no_send_addr = true; in dp_aux_transfer()
348 aux->no_send_stop = false; in dp_aux_transfer()
350 aux->no_send_addr = true; in dp_aux_transfer()
351 aux->no_send_stop = true; in dp_aux_transfer()
354 ret = dp_aux_cmd_fifo_tx(aux, msg); in dp_aux_transfer()
356 if (aux->native) { in dp_aux_transfer()
357 aux->retry_cnt++; in dp_aux_transfer()
358 if (!(aux->retry_cnt % MAX_AUX_RETRIES)) in dp_aux_transfer()
359 dp_catalog_aux_update_cfg(aux->catalog); in dp_aux_transfer()
362 if (dp_catalog_link_is_connected(aux->catalog)) in dp_aux_transfer()
363 dp_catalog_aux_reset(aux->catalog); in dp_aux_transfer()
365 aux->retry_cnt = 0; in dp_aux_transfer()
366 switch (aux->aux_error_num) { in dp_aux_transfer()
368 if (aux->read) in dp_aux_transfer()
369 ret = dp_aux_cmd_fifo_rx(aux, msg); in dp_aux_transfer()
370 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_ACK : DP_AUX_I2C_REPLY_ACK; in dp_aux_transfer()
373 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_DEFER : DP_AUX_I2C_REPLY_DEFER; in dp_aux_transfer()
379 msg->reply = aux->native ? DP_AUX_NATIVE_REPLY_NACK : DP_AUX_I2C_REPLY_NACK; in dp_aux_transfer()
387 aux->cmd_busy = false; in dp_aux_transfer()
390 mutex_unlock(&aux->mutex); in dp_aux_transfer()
398 struct dp_aux_private *aux; in dp_aux_isr() local
405 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_isr()
407 isr = dp_catalog_aux_get_irq(aux->catalog); in dp_aux_isr()
409 if (!aux->cmd_busy) in dp_aux_isr()
412 if (aux->native) in dp_aux_isr()
413 dp_aux_native_handler(aux, isr); in dp_aux_isr()
415 dp_aux_i2c_handler(aux, isr); in dp_aux_isr()
417 complete(&aux->comp); in dp_aux_isr()
422 struct dp_aux_private *aux; in dp_aux_reconfig() local
424 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_reconfig()
426 dp_catalog_aux_update_cfg(aux->catalog); in dp_aux_reconfig()
427 dp_catalog_aux_reset(aux->catalog); in dp_aux_reconfig()
432 struct dp_aux_private *aux; in dp_aux_init() local
439 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_init()
441 mutex_lock(&aux->mutex); in dp_aux_init()
443 dp_catalog_aux_enable(aux->catalog, true); in dp_aux_init()
444 aux->retry_cnt = 0; in dp_aux_init()
445 aux->initted = true; in dp_aux_init()
447 mutex_unlock(&aux->mutex); in dp_aux_init()
452 struct dp_aux_private *aux; in dp_aux_deinit() local
454 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_deinit()
456 mutex_lock(&aux->mutex); in dp_aux_deinit()
458 aux->initted = false; in dp_aux_deinit()
459 dp_catalog_aux_enable(aux->catalog, false); in dp_aux_deinit()
461 mutex_unlock(&aux->mutex); in dp_aux_deinit()
466 struct dp_aux_private *aux; in dp_aux_register() local
474 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_register()
476 aux->dp_aux.name = "dpu_dp_aux"; in dp_aux_register()
477 aux->dp_aux.dev = aux->dev; in dp_aux_register()
478 aux->dp_aux.transfer = dp_aux_transfer; in dp_aux_register()
479 ret = drm_dp_aux_register(&aux->dp_aux); in dp_aux_register()
496 struct dp_aux_private *aux; in dp_aux_get() local
503 aux = devm_kzalloc(dev, sizeof(*aux), GFP_KERNEL); in dp_aux_get()
504 if (!aux) in dp_aux_get()
507 init_completion(&aux->comp); in dp_aux_get()
508 aux->cmd_busy = false; in dp_aux_get()
509 mutex_init(&aux->mutex); in dp_aux_get()
511 aux->dev = dev; in dp_aux_get()
512 aux->catalog = catalog; in dp_aux_get()
513 aux->retry_cnt = 0; in dp_aux_get()
515 return &aux->dp_aux; in dp_aux_get()
520 struct dp_aux_private *aux; in dp_aux_put() local
525 aux = container_of(dp_aux, struct dp_aux_private, dp_aux); in dp_aux_put()
527 mutex_destroy(&aux->mutex); in dp_aux_put()
529 devm_kfree(aux->dev, aux); in dp_aux_put()