Commit bbad6407 authored by Thierry Reding's avatar Thierry Reding

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: default avatarThierry Reding <treding@nvidia.com>
parent 31fa25f1
...@@ -127,8 +127,7 @@ struct tegra_output { ...@@ -127,8 +127,7 @@ struct tegra_output {
const struct edid *edid; const struct edid *edid;
struct cec_notifier *cec; struct cec_notifier *cec;
unsigned int hpd_irq; unsigned int hpd_irq;
int hpd_gpio; struct gpio_desc *hpd_gpio;
enum of_gpio_flags hpd_gpio_flags;
struct drm_encoder encoder; struct drm_encoder encoder;
struct drm_connector connector; struct drm_connector connector;
......
...@@ -53,18 +53,11 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force) ...@@ -53,18 +53,11 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force)
struct tegra_output *output = connector_to_output(connector); struct tegra_output *output = connector_to_output(connector);
enum drm_connector_status status = connector_status_unknown; enum drm_connector_status status = connector_status_unknown;
if (gpio_is_valid(output->hpd_gpio)) { if (output->hpd_gpio) {
if (output->hpd_gpio_flags & OF_GPIO_ACTIVE_LOW) { if (gpiod_get_value(output->hpd_gpio) == 0)
if (gpio_get_value(output->hpd_gpio) != 0) status = connector_status_disconnected;
status = connector_status_disconnected; else
else status = connector_status_connected;
status = connector_status_connected;
} else {
if (gpio_get_value(output->hpd_gpio) == 0)
status = connector_status_disconnected;
else
status = connector_status_connected;
}
} else { } else {
if (!output->panel) if (!output->panel)
status = connector_status_disconnected; status = connector_status_disconnected;
...@@ -102,6 +95,7 @@ static irqreturn_t hpd_irq(int irq, void *data) ...@@ -102,6 +95,7 @@ static irqreturn_t hpd_irq(int irq, void *data)
int tegra_output_probe(struct tegra_output *output) int tegra_output_probe(struct tegra_output *output)
{ {
struct device_node *ddc, *panel; struct device_node *ddc, *panel;
unsigned long flags;
int err, size; int err, size;
if (!output->of_node) if (!output->of_node)
...@@ -130,23 +124,18 @@ int tegra_output_probe(struct tegra_output *output) ...@@ -130,23 +124,18 @@ int tegra_output_probe(struct tegra_output *output)
of_node_put(ddc); of_node_put(ddc);
} }
output->hpd_gpio = of_get_named_gpio_flags(output->of_node, output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
"nvidia,hpd-gpio", 0, output->of_node,
&output->hpd_gpio_flags); "nvidia,hpd-gpio", 0,
if (gpio_is_valid(output->hpd_gpio)) { GPIOD_IN,
unsigned long flags; "HDMI hotplug detect");
if (IS_ERR(output->hpd_gpio))
return PTR_ERR(output->hpd_gpio);
err = gpio_request_one(output->hpd_gpio, GPIOF_DIR_IN, if (output->hpd_gpio) {
"HDMI hotplug detect"); err = gpiod_to_irq(output->hpd_gpio);
if (err < 0) { if (err < 0) {
dev_err(output->dev, "gpio_request_one(): %d\n", err); dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
return err;
}
err = gpio_to_irq(output->hpd_gpio);
if (err < 0) {
dev_err(output->dev, "gpio_to_irq(): %d\n", err);
gpio_free(output->hpd_gpio);
return err; return err;
} }
...@@ -160,7 +149,6 @@ int tegra_output_probe(struct tegra_output *output) ...@@ -160,7 +149,6 @@ int tegra_output_probe(struct tegra_output *output)
if (err < 0) { if (err < 0) {
dev_err(output->dev, "failed to request IRQ#%u: %d\n", dev_err(output->dev, "failed to request IRQ#%u: %d\n",
output->hpd_irq, err); output->hpd_irq, err);
gpio_free(output->hpd_gpio);
return err; return err;
} }
...@@ -186,10 +174,8 @@ void tegra_output_remove(struct tegra_output *output) ...@@ -186,10 +174,8 @@ void tegra_output_remove(struct tegra_output *output)
if (output->cec) if (output->cec)
cec_notifier_put(output->cec); cec_notifier_put(output->cec);
if (gpio_is_valid(output->hpd_gpio)) { if (output->hpd_gpio)
free_irq(output->hpd_irq, output); free_irq(output->hpd_irq, output);
gpio_free(output->hpd_gpio);
}
if (output->ddc) if (output->ddc)
put_device(&output->ddc->dev); put_device(&output->ddc->dev);
...@@ -209,7 +195,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output) ...@@ -209,7 +195,7 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
* The connector is now registered and ready to receive hotplug events * The connector is now registered and ready to receive hotplug events
* so the hotplug interrupt can be enabled. * so the hotplug interrupt can be enabled.
*/ */
if (gpio_is_valid(output->hpd_gpio)) if (output->hpd_gpio)
enable_irq(output->hpd_irq); enable_irq(output->hpd_irq);
return 0; return 0;
...@@ -221,7 +207,7 @@ void tegra_output_exit(struct tegra_output *output) ...@@ -221,7 +207,7 @@ void tegra_output_exit(struct tegra_output *output)
* The connector is going away, so the interrupt must be disabled to * The connector is going away, so the interrupt must be disabled to
* prevent the hotplug interrupt handler from potentially crashing. * prevent the hotplug interrupt handler from potentially crashing.
*/ */
if (gpio_is_valid(output->hpd_gpio)) if (output->hpd_gpio)
disable_irq(output->hpd_irq); disable_irq(output->hpd_irq);
if (output->panel) if (output->panel)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment