Commit 6800234c authored by Maxime Ripard's avatar Maxime Ripard

drm/vc4: hdmi: Convert to gpiod

The new gpiod interface takes care of parsing the GPIO flags and to
return the logical value when accessing an active-low GPIO, so switching
to it simplifies a lot the driver.
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210524131852.263883-2-maxime@cerno.tech
parent e075a781
...@@ -166,10 +166,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) ...@@ -166,10 +166,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
bool connected = false; bool connected = false;
if (vc4_hdmi->hpd_gpio) { if (vc4_hdmi->hpd_gpio &&
if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^ gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) {
vc4_hdmi->hpd_active_low) connected = true;
connected = true;
} else if (drm_probe_ddc(vc4_hdmi->ddc)) { } else if (drm_probe_ddc(vc4_hdmi->ddc)) {
connected = true; connected = true;
} else if (HDMI_READ(HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED) { } else if (HDMI_READ(HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED) {
...@@ -2105,7 +2104,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -2105,7 +2104,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
struct vc4_hdmi *vc4_hdmi; struct vc4_hdmi *vc4_hdmi;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct device_node *ddc_node; struct device_node *ddc_node;
u32 value;
int ret; int ret;
vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL); vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL);
...@@ -2144,18 +2142,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -2144,18 +2142,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
/* Only use the GPIO HPD pin if present in the DT, otherwise /* Only use the GPIO HPD pin if present in the DT, otherwise
* we'll use the HDMI core's register. * we'll use the HDMI core's register.
*/ */
if (of_find_property(dev->of_node, "hpd-gpios", &value)) { vc4_hdmi->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
enum of_gpio_flags hpd_gpio_flags; if (IS_ERR(vc4_hdmi->hpd_gpio)) {
ret = PTR_ERR(vc4_hdmi->hpd_gpio);
vc4_hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node, goto err_put_ddc;
"hpd-gpios", 0,
&hpd_gpio_flags);
if (vc4_hdmi->hpd_gpio < 0) {
ret = vc4_hdmi->hpd_gpio;
goto err_put_ddc;
}
vc4_hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
} }
vc4_hdmi->disable_wifi_frequencies = vc4_hdmi->disable_wifi_frequencies =
......
...@@ -148,8 +148,7 @@ struct vc4_hdmi { ...@@ -148,8 +148,7 @@ struct vc4_hdmi {
/* VC5 Only */ /* VC5 Only */
void __iomem *rm_regs; void __iomem *rm_regs;
int hpd_gpio; struct gpio_desc *hpd_gpio;
bool hpd_active_low;
/* /*
* On some systems (like the RPi4), some modes are in the same * On some systems (like the RPi4), some modes are in the same
......
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