1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2013 NVIDIA Corporation
7 #include <linux/delay.h>
8 #include <linux/gpio.h>
9 #include <linux/interrupt.h>
11 #include <linux/module.h>
12 #include <linux/of_device.h>
13 #include <linux/of_gpio.h>
14 #include <linux/pinctrl/pinconf-generic.h>
15 #include <linux/pinctrl/pinctrl.h>
16 #include <linux/pinctrl/pinmux.h>
17 #include <linux/platform_device.h>
18 #include <linux/pm_runtime.h>
19 #include <linux/regulator/consumer.h>
20 #include <linux/reset.h>
21 #include <linux/workqueue.h>
23 #include <drm/drm_dp_helper.h>
24 #include <drm/drm_panel.h>
31 static DEFINE_MUTEX(dpaux_lock
);
32 static LIST_HEAD(dpaux_list
);
34 struct tegra_dpaux_soc
{
41 struct drm_dp_aux aux
;
44 const struct tegra_dpaux_soc
*soc
;
49 struct tegra_output
*output
;
51 struct reset_control
*rst
;
52 struct clk
*clk_parent
;
55 struct regulator
*vdd
;
57 struct completion complete
;
58 struct work_struct work
;
59 struct list_head list
;
61 #ifdef CONFIG_GENERIC_PINCONF
62 struct pinctrl_dev
*pinctrl
;
63 struct pinctrl_desc desc
;
67 static inline struct tegra_dpaux
*to_dpaux(struct drm_dp_aux
*aux
)
69 return container_of(aux
, struct tegra_dpaux
, aux
);
72 static inline struct tegra_dpaux
*work_to_dpaux(struct work_struct
*work
)
74 return container_of(work
, struct tegra_dpaux
, work
);
77 static inline u32
tegra_dpaux_readl(struct tegra_dpaux
*dpaux
,
80 u32 value
= readl(dpaux
->regs
+ (offset
<< 2));
82 trace_dpaux_readl(dpaux
->dev
, offset
, value
);
87 static inline void tegra_dpaux_writel(struct tegra_dpaux
*dpaux
,
88 u32 value
, unsigned int offset
)
90 trace_dpaux_writel(dpaux
->dev
, offset
, value
);
91 writel(value
, dpaux
->regs
+ (offset
<< 2));
94 static void tegra_dpaux_write_fifo(struct tegra_dpaux
*dpaux
, const u8
*buffer
,
99 for (i
= 0; i
< DIV_ROUND_UP(size
, 4); i
++) {
100 size_t num
= min_t(size_t, size
- i
* 4, 4);
103 for (j
= 0; j
< num
; j
++)
104 value
|= buffer
[i
* 4 + j
] << (j
* 8);
106 tegra_dpaux_writel(dpaux
, value
, DPAUX_DP_AUXDATA_WRITE(i
));
110 static void tegra_dpaux_read_fifo(struct tegra_dpaux
*dpaux
, u8
*buffer
,
115 for (i
= 0; i
< DIV_ROUND_UP(size
, 4); i
++) {
116 size_t num
= min_t(size_t, size
- i
* 4, 4);
119 value
= tegra_dpaux_readl(dpaux
, DPAUX_DP_AUXDATA_READ(i
));
121 for (j
= 0; j
< num
; j
++)
122 buffer
[i
* 4 + j
] = value
>> (j
* 8);
126 static ssize_t
tegra_dpaux_transfer(struct drm_dp_aux
*aux
,
127 struct drm_dp_aux_msg
*msg
)
129 unsigned long timeout
= msecs_to_jiffies(250);
130 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
131 unsigned long status
;
136 /* Tegra has 4x4 byte DP AUX transmit and receive FIFOs. */
141 * Allow zero-sized messages only for I2C, in which case they specify
142 * address-only transactions.
145 switch (msg
->request
& ~DP_AUX_I2C_MOT
) {
146 case DP_AUX_I2C_WRITE_STATUS_UPDATE
:
147 case DP_AUX_I2C_WRITE
:
148 case DP_AUX_I2C_READ
:
149 value
= DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY
;
156 /* For non-zero-sized messages, set the CMDLEN field. */
157 value
= DPAUX_DP_AUXCTL_CMDLEN(msg
->size
- 1);
160 switch (msg
->request
& ~DP_AUX_I2C_MOT
) {
161 case DP_AUX_I2C_WRITE
:
162 if (msg
->request
& DP_AUX_I2C_MOT
)
163 value
|= DPAUX_DP_AUXCTL_CMD_MOT_WR
;
165 value
|= DPAUX_DP_AUXCTL_CMD_I2C_WR
;
169 case DP_AUX_I2C_READ
:
170 if (msg
->request
& DP_AUX_I2C_MOT
)
171 value
|= DPAUX_DP_AUXCTL_CMD_MOT_RD
;
173 value
|= DPAUX_DP_AUXCTL_CMD_I2C_RD
;
177 case DP_AUX_I2C_WRITE_STATUS_UPDATE
:
178 if (msg
->request
& DP_AUX_I2C_MOT
)
179 value
|= DPAUX_DP_AUXCTL_CMD_MOT_RQ
;
181 value
|= DPAUX_DP_AUXCTL_CMD_I2C_RQ
;
185 case DP_AUX_NATIVE_WRITE
:
186 value
|= DPAUX_DP_AUXCTL_CMD_AUX_WR
;
189 case DP_AUX_NATIVE_READ
:
190 value
|= DPAUX_DP_AUXCTL_CMD_AUX_RD
;
197 tegra_dpaux_writel(dpaux
, msg
->address
, DPAUX_DP_AUXADDR
);
198 tegra_dpaux_writel(dpaux
, value
, DPAUX_DP_AUXCTL
);
200 if ((msg
->request
& DP_AUX_I2C_READ
) == 0) {
201 tegra_dpaux_write_fifo(dpaux
, msg
->buffer
, msg
->size
);
205 /* start transaction */
206 value
= tegra_dpaux_readl(dpaux
, DPAUX_DP_AUXCTL
);
207 value
|= DPAUX_DP_AUXCTL_TRANSACTREQ
;
208 tegra_dpaux_writel(dpaux
, value
, DPAUX_DP_AUXCTL
);
210 status
= wait_for_completion_timeout(&dpaux
->complete
, timeout
);
214 /* read status and clear errors */
215 value
= tegra_dpaux_readl(dpaux
, DPAUX_DP_AUXSTAT
);
216 tegra_dpaux_writel(dpaux
, 0xf00, DPAUX_DP_AUXSTAT
);
218 if (value
& DPAUX_DP_AUXSTAT_TIMEOUT_ERROR
)
221 if ((value
& DPAUX_DP_AUXSTAT_RX_ERROR
) ||
222 (value
& DPAUX_DP_AUXSTAT_SINKSTAT_ERROR
) ||
223 (value
& DPAUX_DP_AUXSTAT_NO_STOP_ERROR
))
226 switch ((value
& DPAUX_DP_AUXSTAT_REPLY_TYPE_MASK
) >> 16) {
228 reply
= DP_AUX_NATIVE_REPLY_ACK
;
232 reply
= DP_AUX_NATIVE_REPLY_NACK
;
236 reply
= DP_AUX_NATIVE_REPLY_DEFER
;
240 reply
= DP_AUX_I2C_REPLY_NACK
;
244 reply
= DP_AUX_I2C_REPLY_DEFER
;
248 if ((msg
->size
> 0) && (msg
->reply
== DP_AUX_NATIVE_REPLY_ACK
)) {
249 if (msg
->request
& DP_AUX_I2C_READ
) {
250 size_t count
= value
& DPAUX_DP_AUXSTAT_REPLY_MASK
;
253 * There might be a smarter way to do this, but since
254 * the DP helpers will already retry transactions for
255 * an -EBUSY return value, simply reuse that instead.
257 if (count
!= msg
->size
) {
262 tegra_dpaux_read_fifo(dpaux
, msg
->buffer
, count
);
273 static void tegra_dpaux_hotplug(struct work_struct
*work
)
275 struct tegra_dpaux
*dpaux
= work_to_dpaux(work
);
278 drm_helper_hpd_irq_event(dpaux
->output
->connector
.dev
);
281 static irqreturn_t
tegra_dpaux_irq(int irq
, void *data
)
283 struct tegra_dpaux
*dpaux
= data
;
284 irqreturn_t ret
= IRQ_HANDLED
;
287 /* clear interrupts */
288 value
= tegra_dpaux_readl(dpaux
, DPAUX_INTR_AUX
);
289 tegra_dpaux_writel(dpaux
, value
, DPAUX_INTR_AUX
);
291 if (value
& (DPAUX_INTR_PLUG_EVENT
| DPAUX_INTR_UNPLUG_EVENT
))
292 schedule_work(&dpaux
->work
);
294 if (value
& DPAUX_INTR_IRQ_EVENT
) {
295 /* TODO: handle this */
298 if (value
& DPAUX_INTR_AUX_DONE
)
299 complete(&dpaux
->complete
);
304 enum tegra_dpaux_functions
{
305 DPAUX_PADCTL_FUNC_AUX
,
306 DPAUX_PADCTL_FUNC_I2C
,
307 DPAUX_PADCTL_FUNC_OFF
,
310 static void tegra_dpaux_pad_power_down(struct tegra_dpaux
*dpaux
)
312 u32 value
= tegra_dpaux_readl(dpaux
, DPAUX_HYBRID_SPARE
);
314 value
|= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN
;
316 tegra_dpaux_writel(dpaux
, value
, DPAUX_HYBRID_SPARE
);
319 static void tegra_dpaux_pad_power_up(struct tegra_dpaux
*dpaux
)
321 u32 value
= tegra_dpaux_readl(dpaux
, DPAUX_HYBRID_SPARE
);
323 value
&= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN
;
325 tegra_dpaux_writel(dpaux
, value
, DPAUX_HYBRID_SPARE
);
328 static int tegra_dpaux_pad_config(struct tegra_dpaux
*dpaux
, unsigned function
)
333 case DPAUX_PADCTL_FUNC_AUX
:
334 value
= DPAUX_HYBRID_PADCTL_AUX_CMH(dpaux
->soc
->cmh
) |
335 DPAUX_HYBRID_PADCTL_AUX_DRVZ(dpaux
->soc
->drvz
) |
336 DPAUX_HYBRID_PADCTL_AUX_DRVI(dpaux
->soc
->drvi
) |
337 DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV
|
338 DPAUX_HYBRID_PADCTL_MODE_AUX
;
341 case DPAUX_PADCTL_FUNC_I2C
:
342 value
= DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV
|
343 DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV
|
344 DPAUX_HYBRID_PADCTL_AUX_CMH(dpaux
->soc
->cmh
) |
345 DPAUX_HYBRID_PADCTL_AUX_DRVZ(dpaux
->soc
->drvz
) |
346 DPAUX_HYBRID_PADCTL_AUX_DRVI(dpaux
->soc
->drvi
) |
347 DPAUX_HYBRID_PADCTL_MODE_I2C
;
350 case DPAUX_PADCTL_FUNC_OFF
:
351 tegra_dpaux_pad_power_down(dpaux
);
358 tegra_dpaux_writel(dpaux
, value
, DPAUX_HYBRID_PADCTL
);
359 tegra_dpaux_pad_power_up(dpaux
);
364 #ifdef CONFIG_GENERIC_PINCONF
365 static const struct pinctrl_pin_desc tegra_dpaux_pins
[] = {
366 PINCTRL_PIN(0, "DP_AUX_CHx_P"),
367 PINCTRL_PIN(1, "DP_AUX_CHx_N"),
370 static const unsigned tegra_dpaux_pin_numbers
[] = { 0, 1 };
372 static const char * const tegra_dpaux_groups
[] = {
376 static const char * const tegra_dpaux_functions
[] = {
382 static int tegra_dpaux_get_groups_count(struct pinctrl_dev
*pinctrl
)
384 return ARRAY_SIZE(tegra_dpaux_groups
);
387 static const char *tegra_dpaux_get_group_name(struct pinctrl_dev
*pinctrl
,
390 return tegra_dpaux_groups
[group
];
393 static int tegra_dpaux_get_group_pins(struct pinctrl_dev
*pinctrl
,
394 unsigned group
, const unsigned **pins
,
397 *pins
= tegra_dpaux_pin_numbers
;
398 *num_pins
= ARRAY_SIZE(tegra_dpaux_pin_numbers
);
403 static const struct pinctrl_ops tegra_dpaux_pinctrl_ops
= {
404 .get_groups_count
= tegra_dpaux_get_groups_count
,
405 .get_group_name
= tegra_dpaux_get_group_name
,
406 .get_group_pins
= tegra_dpaux_get_group_pins
,
407 .dt_node_to_map
= pinconf_generic_dt_node_to_map_group
,
408 .dt_free_map
= pinconf_generic_dt_free_map
,
411 static int tegra_dpaux_get_functions_count(struct pinctrl_dev
*pinctrl
)
413 return ARRAY_SIZE(tegra_dpaux_functions
);
416 static const char *tegra_dpaux_get_function_name(struct pinctrl_dev
*pinctrl
,
417 unsigned int function
)
419 return tegra_dpaux_functions
[function
];
422 static int tegra_dpaux_get_function_groups(struct pinctrl_dev
*pinctrl
,
423 unsigned int function
,
424 const char * const **groups
,
425 unsigned * const num_groups
)
427 *num_groups
= ARRAY_SIZE(tegra_dpaux_groups
);
428 *groups
= tegra_dpaux_groups
;
433 static int tegra_dpaux_set_mux(struct pinctrl_dev
*pinctrl
,
434 unsigned int function
, unsigned int group
)
436 struct tegra_dpaux
*dpaux
= pinctrl_dev_get_drvdata(pinctrl
);
438 return tegra_dpaux_pad_config(dpaux
, function
);
441 static const struct pinmux_ops tegra_dpaux_pinmux_ops
= {
442 .get_functions_count
= tegra_dpaux_get_functions_count
,
443 .get_function_name
= tegra_dpaux_get_function_name
,
444 .get_function_groups
= tegra_dpaux_get_function_groups
,
445 .set_mux
= tegra_dpaux_set_mux
,
449 static int tegra_dpaux_probe(struct platform_device
*pdev
)
451 struct tegra_dpaux
*dpaux
;
452 struct resource
*regs
;
456 dpaux
= devm_kzalloc(&pdev
->dev
, sizeof(*dpaux
), GFP_KERNEL
);
460 dpaux
->soc
= of_device_get_match_data(&pdev
->dev
);
461 INIT_WORK(&dpaux
->work
, tegra_dpaux_hotplug
);
462 init_completion(&dpaux
->complete
);
463 INIT_LIST_HEAD(&dpaux
->list
);
464 dpaux
->dev
= &pdev
->dev
;
466 regs
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
467 dpaux
->regs
= devm_ioremap_resource(&pdev
->dev
, regs
);
468 if (IS_ERR(dpaux
->regs
))
469 return PTR_ERR(dpaux
->regs
);
471 dpaux
->irq
= platform_get_irq(pdev
, 0);
472 if (dpaux
->irq
< 0) {
473 dev_err(&pdev
->dev
, "failed to get IRQ\n");
477 if (!pdev
->dev
.pm_domain
) {
478 dpaux
->rst
= devm_reset_control_get(&pdev
->dev
, "dpaux");
479 if (IS_ERR(dpaux
->rst
)) {
481 "failed to get reset control: %ld\n",
482 PTR_ERR(dpaux
->rst
));
483 return PTR_ERR(dpaux
->rst
);
487 dpaux
->clk
= devm_clk_get(&pdev
->dev
, NULL
);
488 if (IS_ERR(dpaux
->clk
)) {
489 dev_err(&pdev
->dev
, "failed to get module clock: %ld\n",
490 PTR_ERR(dpaux
->clk
));
491 return PTR_ERR(dpaux
->clk
);
494 dpaux
->clk_parent
= devm_clk_get(&pdev
->dev
, "parent");
495 if (IS_ERR(dpaux
->clk_parent
)) {
496 dev_err(&pdev
->dev
, "failed to get parent clock: %ld\n",
497 PTR_ERR(dpaux
->clk_parent
));
498 return PTR_ERR(dpaux
->clk_parent
);
501 err
= clk_set_rate(dpaux
->clk_parent
, 270000000);
503 dev_err(&pdev
->dev
, "failed to set clock to 270 MHz: %d\n",
508 dpaux
->vdd
= devm_regulator_get_optional(&pdev
->dev
, "vdd");
509 if (IS_ERR(dpaux
->vdd
)) {
510 if (PTR_ERR(dpaux
->vdd
) != -ENODEV
) {
511 if (PTR_ERR(dpaux
->vdd
) != -EPROBE_DEFER
)
513 "failed to get VDD supply: %ld\n",
514 PTR_ERR(dpaux
->vdd
));
516 return PTR_ERR(dpaux
->vdd
);
522 platform_set_drvdata(pdev
, dpaux
);
523 pm_runtime_enable(&pdev
->dev
);
524 pm_runtime_get_sync(&pdev
->dev
);
526 err
= devm_request_irq(dpaux
->dev
, dpaux
->irq
, tegra_dpaux_irq
, 0,
527 dev_name(dpaux
->dev
), dpaux
);
529 dev_err(dpaux
->dev
, "failed to request IRQ#%u: %d\n",
534 disable_irq(dpaux
->irq
);
536 dpaux
->aux
.transfer
= tegra_dpaux_transfer
;
537 dpaux
->aux
.dev
= &pdev
->dev
;
539 err
= drm_dp_aux_register(&dpaux
->aux
);
544 * Assume that by default the DPAUX/I2C pads will be used for HDMI,
545 * so power them up and configure them in I2C mode.
547 * The DPAUX code paths reconfigure the pads in AUX mode, but there
548 * is no possibility to perform the I2C mode configuration in the
551 err
= tegra_dpaux_pad_config(dpaux
, DPAUX_PADCTL_FUNC_I2C
);
555 #ifdef CONFIG_GENERIC_PINCONF
556 dpaux
->desc
.name
= dev_name(&pdev
->dev
);
557 dpaux
->desc
.pins
= tegra_dpaux_pins
;
558 dpaux
->desc
.npins
= ARRAY_SIZE(tegra_dpaux_pins
);
559 dpaux
->desc
.pctlops
= &tegra_dpaux_pinctrl_ops
;
560 dpaux
->desc
.pmxops
= &tegra_dpaux_pinmux_ops
;
561 dpaux
->desc
.owner
= THIS_MODULE
;
563 dpaux
->pinctrl
= devm_pinctrl_register(&pdev
->dev
, &dpaux
->desc
, dpaux
);
564 if (IS_ERR(dpaux
->pinctrl
)) {
565 dev_err(&pdev
->dev
, "failed to register pincontrol\n");
566 return PTR_ERR(dpaux
->pinctrl
);
569 /* enable and clear all interrupts */
570 value
= DPAUX_INTR_AUX_DONE
| DPAUX_INTR_IRQ_EVENT
|
571 DPAUX_INTR_UNPLUG_EVENT
| DPAUX_INTR_PLUG_EVENT
;
572 tegra_dpaux_writel(dpaux
, value
, DPAUX_INTR_EN_AUX
);
573 tegra_dpaux_writel(dpaux
, value
, DPAUX_INTR_AUX
);
575 mutex_lock(&dpaux_lock
);
576 list_add_tail(&dpaux
->list
, &dpaux_list
);
577 mutex_unlock(&dpaux_lock
);
582 static int tegra_dpaux_remove(struct platform_device
*pdev
)
584 struct tegra_dpaux
*dpaux
= platform_get_drvdata(pdev
);
586 cancel_work_sync(&dpaux
->work
);
588 /* make sure pads are powered down when not in use */
589 tegra_dpaux_pad_power_down(dpaux
);
591 pm_runtime_put_sync(&pdev
->dev
);
592 pm_runtime_disable(&pdev
->dev
);
594 drm_dp_aux_unregister(&dpaux
->aux
);
596 mutex_lock(&dpaux_lock
);
597 list_del(&dpaux
->list
);
598 mutex_unlock(&dpaux_lock
);
604 static int tegra_dpaux_suspend(struct device
*dev
)
606 struct tegra_dpaux
*dpaux
= dev_get_drvdata(dev
);
610 err
= reset_control_assert(dpaux
->rst
);
612 dev_err(dev
, "failed to assert reset: %d\n", err
);
617 usleep_range(1000, 2000);
619 clk_disable_unprepare(dpaux
->clk_parent
);
620 clk_disable_unprepare(dpaux
->clk
);
625 static int tegra_dpaux_resume(struct device
*dev
)
627 struct tegra_dpaux
*dpaux
= dev_get_drvdata(dev
);
630 err
= clk_prepare_enable(dpaux
->clk
);
632 dev_err(dev
, "failed to enable clock: %d\n", err
);
636 err
= clk_prepare_enable(dpaux
->clk_parent
);
638 dev_err(dev
, "failed to enable parent clock: %d\n", err
);
642 usleep_range(1000, 2000);
645 err
= reset_control_deassert(dpaux
->rst
);
647 dev_err(dev
, "failed to deassert reset: %d\n", err
);
651 usleep_range(1000, 2000);
657 clk_disable_unprepare(dpaux
->clk_parent
);
659 clk_disable_unprepare(dpaux
->clk
);
664 static const struct dev_pm_ops tegra_dpaux_pm_ops
= {
665 SET_RUNTIME_PM_OPS(tegra_dpaux_suspend
, tegra_dpaux_resume
, NULL
)
668 static const struct tegra_dpaux_soc tegra124_dpaux_soc
= {
674 static const struct tegra_dpaux_soc tegra210_dpaux_soc
= {
680 static const struct tegra_dpaux_soc tegra194_dpaux_soc
= {
686 static const struct of_device_id tegra_dpaux_of_match
[] = {
687 { .compatible
= "nvidia,tegra194-dpaux", .data
= &tegra194_dpaux_soc
},
688 { .compatible
= "nvidia,tegra186-dpaux", .data
= &tegra210_dpaux_soc
},
689 { .compatible
= "nvidia,tegra210-dpaux", .data
= &tegra210_dpaux_soc
},
690 { .compatible
= "nvidia,tegra124-dpaux", .data
= &tegra124_dpaux_soc
},
693 MODULE_DEVICE_TABLE(of
, tegra_dpaux_of_match
);
695 struct platform_driver tegra_dpaux_driver
= {
697 .name
= "tegra-dpaux",
698 .of_match_table
= tegra_dpaux_of_match
,
699 .pm
= &tegra_dpaux_pm_ops
,
701 .probe
= tegra_dpaux_probe
,
702 .remove
= tegra_dpaux_remove
,
705 struct drm_dp_aux
*drm_dp_aux_find_by_of_node(struct device_node
*np
)
707 struct tegra_dpaux
*dpaux
;
709 mutex_lock(&dpaux_lock
);
711 list_for_each_entry(dpaux
, &dpaux_list
, list
)
712 if (np
== dpaux
->dev
->of_node
) {
713 mutex_unlock(&dpaux_lock
);
717 mutex_unlock(&dpaux_lock
);
722 int drm_dp_aux_attach(struct drm_dp_aux
*aux
, struct tegra_output
*output
)
724 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
725 unsigned long timeout
;
728 output
->connector
.polled
= DRM_CONNECTOR_POLL_HPD
;
729 dpaux
->output
= output
;
732 enum drm_connector_status status
;
735 err
= regulator_enable(dpaux
->vdd
);
740 timeout
= jiffies
+ msecs_to_jiffies(250);
742 while (time_before(jiffies
, timeout
)) {
743 status
= drm_dp_aux_detect(aux
);
745 if (status
== connector_status_connected
)
748 usleep_range(1000, 2000);
751 if (status
!= connector_status_connected
)
755 enable_irq(dpaux
->irq
);
759 int drm_dp_aux_detach(struct drm_dp_aux
*aux
)
761 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
762 unsigned long timeout
;
765 disable_irq(dpaux
->irq
);
767 if (dpaux
->output
->panel
) {
768 enum drm_connector_status status
;
771 err
= regulator_disable(dpaux
->vdd
);
776 timeout
= jiffies
+ msecs_to_jiffies(250);
778 while (time_before(jiffies
, timeout
)) {
779 status
= drm_dp_aux_detect(aux
);
781 if (status
== connector_status_disconnected
)
784 usleep_range(1000, 2000);
787 if (status
!= connector_status_disconnected
)
790 dpaux
->output
= NULL
;
796 enum drm_connector_status
drm_dp_aux_detect(struct drm_dp_aux
*aux
)
798 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
801 value
= tegra_dpaux_readl(dpaux
, DPAUX_DP_AUXSTAT
);
803 if (value
& DPAUX_DP_AUXSTAT_HPD_STATUS
)
804 return connector_status_connected
;
806 return connector_status_disconnected
;
809 int drm_dp_aux_enable(struct drm_dp_aux
*aux
)
811 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
813 return tegra_dpaux_pad_config(dpaux
, DPAUX_PADCTL_FUNC_AUX
);
816 int drm_dp_aux_disable(struct drm_dp_aux
*aux
)
818 struct tegra_dpaux
*dpaux
= to_dpaux(aux
);
820 tegra_dpaux_pad_power_down(dpaux
);