1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
From 35e2ec234646f04eb0e17e4c3a4cf21faed3655a Mon Sep 17 00:00:00 2001
From: Wen He <wen.he_1@nxp.com>
Date: Wed, 18 Sep 2019 11:05:31 +0800
Subject: [PATCH] drm: bridge: cadence: Add support for periodically poll the
connector
Normally, DP/HDMI PHY use HPD_IRQ to monitor the connector connection
status, but LS1028A doesn't support HPD_IRQ signals response.
This patch allows periodically poll the connector for connection and
disconnection.
Signed-off-by: Wen He <wen.he_1@nxp.com>
---
drivers/gpu/drm/bridge/cadence/cdns-dp-core.c | 86 +++++++++++++++++----------
include/drm/bridge/cdns-mhdp-common.h | 1 +
2 files changed, 54 insertions(+), 33 deletions(-)
--- a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
@@ -276,7 +276,11 @@ static int cdns_dp_bridge_attach(struct
connector->interlace_allowed = 1;
- connector->polled = DRM_CONNECTOR_POLL_HPD;
+ if (mhdp->is_hpd)
+ connector->polled = DRM_CONNECTOR_POLL_HPD;
+ else
+ connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+ DRM_CONNECTOR_POLL_DISCONNECT;
drm_connector_helper_add(connector, &cdns_dp_connector_helper_funcs);
@@ -439,22 +443,34 @@ static int __cdns_dp_probe(struct platfo
INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func);
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mhdp->regs_base = devm_ioremap(dev, iores->start, resource_size(iores));
- if (IS_ERR(mhdp->regs_base))
- return -ENOMEM;
+ if (iores) {
+ mhdp->regs_base = devm_ioremap(dev, iores->start,
+ resource_size(iores));
+ if (IS_ERR(mhdp->regs_base))
+ return -ENOMEM;
+ }
iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- mhdp->regs_sec = devm_ioremap(dev, iores->start, resource_size(iores));
- if (IS_ERR(mhdp->regs_sec))
- return -ENOMEM;
+ if (iores) {
+ mhdp->regs_sec = devm_ioremap(dev, iores->start,
+ resource_size(iores));
+ if (IS_ERR(mhdp->regs_sec))
+ return -ENOMEM;
+ }
+
+ mhdp->is_hpd = true;
mhdp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in");
- if (mhdp->irq[IRQ_IN] < 0)
+ if (mhdp->irq[IRQ_IN] < 0) {
+ mhdp->is_hpd = false;
dev_info(dev, "No plug_in irq number\n");
+ }
mhdp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out");
- if (mhdp->irq[IRQ_OUT] < 0)
+ if (mhdp->irq[IRQ_OUT] < 0) {
+ mhdp->is_hpd = false;
dev_info(dev, "No plug_out irq number\n");
+ }
cdns_dp_parse_dt(mhdp);
@@ -474,33 +490,37 @@ static int __cdns_dp_probe(struct platfo
cdns_mhdp_plat_call(mhdp, phy_set);
/* Enable Hotplug Detect IRQ thread */
- irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN);
- ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN],
- NULL, cdns_dp_irq_thread,
- IRQF_ONESHOT, dev_name(dev),
- mhdp);
- if (ret) {
- dev_err(dev, "can't claim irq %d\n",
- mhdp->irq[IRQ_IN]);
- return -EINVAL;
- }
+ if (mhdp->is_hpd) {
+ irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN);
+ ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN],
+ NULL, cdns_dp_irq_thread,
+ IRQF_ONESHOT, dev_name(dev),
+ mhdp);
- irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN);
- ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT],
- NULL, cdns_dp_irq_thread,
- IRQF_ONESHOT, dev_name(dev),
- mhdp);
- if (ret) {
- dev_err(dev, "can't claim irq %d\n",
- mhdp->irq[IRQ_OUT]);
- return -EINVAL;
+ if (ret) {
+ dev_err(dev, "can't claim irq %d\n",
+ mhdp->irq[IRQ_IN]);
+ return -EINVAL;
+ }
+
+ irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN);
+ ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT],
+ NULL, cdns_dp_irq_thread,
+ IRQF_ONESHOT, dev_name(dev),
+ mhdp);
+
+ if (ret) {
+ dev_err(dev, "can't claim irq %d\n",
+ mhdp->irq[IRQ_OUT]);
+ return -EINVAL;
+ }
+
+ if (cdns_mhdp_read_hpd(mhdp))
+ enable_irq(mhdp->irq[IRQ_OUT]);
+ else
+ enable_irq(mhdp->irq[IRQ_IN]);
}
- if (cdns_mhdp_read_hpd(mhdp))
- enable_irq(mhdp->irq[IRQ_OUT]);
- else
- enable_irq(mhdp->irq[IRQ_IN]);
-
mhdp->bridge.base.driver_private = mhdp;
mhdp->bridge.base.funcs = &cdns_dp_bridge_funcs;
#ifdef CONFIG_OF
--- a/include/drm/bridge/cdns-mhdp-common.h
+++ b/include/drm/bridge/cdns-mhdp-common.h
@@ -683,6 +683,7 @@ struct cdns_mhdp_device {
bool link_up;
bool power_up;
bool plugged;
+ bool is_hpd;
struct mutex lock;
int irq[IRQ_NUM];
|