aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-06-05 04:46:46 -0400
committerThierry Reding <treding@nvidia.com>2019-06-05 09:06:03 -0400
commitbbad640709fd43ff77b8838c409c977c0b28430c (patch)
tree40985cea4da204a3ae6e0e20c54cc115d2717acb /drivers/gpu
parent31fa25f100ec0ce25ccf61d1468928c64d1c2fd9 (diff)
drm/tegra: Use GPIO descriptor API
The legacy GPIO API has long been deprecated. Move the driver over to the descriptor-based API, which allows us to get rid of some boilerplate while at it. Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/tegra/drm.h3
-rw-r--r--drivers/gpu/drm/tegra/output.c52
2 files changed, 20 insertions, 35 deletions
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 70154c253d45..488f36f00bd8 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -127,8 +127,7 @@ struct tegra_output {
127 const struct edid *edid; 127 const struct edid *edid;
128 struct cec_notifier *cec; 128 struct cec_notifier *cec;
129 unsigned int hpd_irq; 129 unsigned int hpd_irq;
130 int hpd_gpio; 130 struct gpio_desc *hpd_gpio;
131 enum of_gpio_flags hpd_gpio_flags;
132 131
133 struct drm_encoder encoder; 132 struct drm_encoder encoder;
134 struct drm_connector connector; 133 struct drm_connector connector;
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 9c2b9dad55c3..e4d242ca27b8 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -53,18 +53,11 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force)
53 struct tegra_output *output = connector_to_output(connector); 53 struct tegra_output *output = connector_to_output(connector);
54 enum drm_connector_status status = connector_status_unknown; 54 enum drm_connector_status status = connector_status_unknown;
55 55
56 if (gpio_is_valid(output->hpd_gpio)) { 56 if (output->hpd_gpio) {
57 if (output->hpd_gpio_flags & OF_GPIO_ACTIVE_LOW) { 57 if (gpiod_get_value(output->hpd_gpio) == 0)
58 if (gpio_get_value(output->hpd_gpio) != 0) 58 status = connector_status_disconnected;
59 status = connector_status_disconnected; 59 else
60 else 60 status = connector_status_connected;
61 status = connector_status_connected;
62 } else {
63 if (gpio_get_value(output->hpd_gpio) == 0)
64 status = connector_status_disconnected;
65 else
66 status = connector_status_connected;
67 }
68 } else { 61 } else {
69 if (!output->panel) 62 if (!output->panel)
70 status = connector_status_disconnected; 63 status = connector_status_disconnected;
@@ -102,6 +95,7 @@ static irqreturn_t hpd_irq(int irq, void *data)
102int tegra_output_probe(struct tegra_output *output) 95int tegra_output_probe(struct tegra_output *output)
103{ 96{
104 struct device_node *ddc, *panel; 97 struct device_node *ddc, *panel;
98 unsigned long flags;
105 int err, size; 99 int err, size;
106 100
107 if (!output->of_node) 101 if (!output->of_node)
@@ -130,23 +124,18 @@ int tegra_output_probe(struct tegra_output *output)
130 of_node_put(ddc); 124 of_node_put(ddc);
131 } 125 }
132 126
133 output->hpd_gpio = of_get_named_gpio_flags(output->of_node, 127 output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
134 "nvidia,hpd-gpio", 0, 128 output->of_node,
135 &output->hpd_gpio_flags); 129 "nvidia,hpd-gpio", 0,
136 if (gpio_is_valid(output->hpd_gpio)) { 130 GPIOD_IN,
137 unsigned long flags; 131 "HDMI hotplug detect");
132 if (IS_ERR(output->hpd_gpio))
133 return PTR_ERR(output->hpd_gpio);
138 134
139 err = gpio_request_one(output->hpd_gpio, GPIOF_DIR_IN, 135 if (output->hpd_gpio) {
140 "HDMI hotplug detect"); 136 err = gpiod_to_irq(output->hpd_gpio);
141 if (err < 0) { 137 if (err < 0) {
142 dev_err(output->dev, "gpio_request_one(): %d\n", err); 138 dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
143 return err;
144 }
145
146 err = gpio_to_irq(output->hpd_gpio);
147 if (err < 0) {
148 dev_err(output->dev, "gpio_to_irq(): %d\n", err);
149 gpio_free(output->hpd_gpio);
150 return err; 139 return err;
151 } 140 }
152 141
@@ -160,7 +149,6 @@ int tegra_output_probe(struct tegra_output *output)
160 if (err < 0) { 149 if (err < 0) {
161 dev_err(output->dev, "failed to request IRQ#%u: %d\n", 150 dev_err(output->dev, "failed to request IRQ#%u: %d\n",
162 output->hpd_irq, err); 151 output->hpd_irq, err);
163 gpio_free(output->hpd_gpio);
164 return err; 152 return err;
165 } 153 }
166 154
@@ -186,10 +174,8 @@ void tegra_output_remove(struct tegra_output *output)
186 if (output->cec) 174 if (output->cec)
187 cec_notifier_put(output->cec); 175 cec_notifier_put(output->cec);
188 176
189 if (gpio_is_valid(output->hpd_gpio)) { 177 if (output->hpd_gpio)
190 free_irq(output->hpd_irq, output); 178 free_irq(output->hpd_irq, output);
191 gpio_free(output->hpd_gpio);
192 }
193 179
194 if (output->ddc) 180 if (output->ddc)
195 put_device(&output->ddc->dev); 181 put_device(&output->ddc->dev);
@@ -209,7 +195,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
209 * The connector is now registered and ready to receive hotplug events 195 * The connector is now registered and ready to receive hotplug events
210 * so the hotplug interrupt can be enabled. 196 * so the hotplug interrupt can be enabled.
211 */ 197 */
212 if (gpio_is_valid(output->hpd_gpio)) 198 if (output->hpd_gpio)
213 enable_irq(output->hpd_irq); 199 enable_irq(output->hpd_irq);
214 200
215 return 0; 201 return 0;
@@ -221,7 +207,7 @@ void tegra_output_exit(struct tegra_output *output)
221 * The connector is going away, so the interrupt must be disabled to 207 * The connector is going away, so the interrupt must be disabled to
222 * prevent the hotplug interrupt handler from potentially crashing. 208 * prevent the hotplug interrupt handler from potentially crashing.
223 */ 209 */
224 if (gpio_is_valid(output->hpd_gpio)) 210 if (output->hpd_gpio)
225 disable_irq(output->hpd_irq); 211 disable_irq(output->hpd_irq);
226 212
227 if (output->panel) 213 if (output->panel)