Message ID | 20190609231339.22136-1-linus.walleij@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/bridge: analogix_dp: Convert to GPIO descriptors | expand |
Hi, On 10/6/19 1:13, Linus Walleij wrote: > This converts the Analogix display port to use GPIO descriptors > instead of DT-extracted numbers. > > Cc: Douglas Anderson <dianders@chromium.org> > Cc: Sean Paul <seanpaul@chromium.org> > Cc: Marek Szyprowski <m.szyprowski@samsung.com> > Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> > --- > .../drm/bridge/analogix/analogix_dp_core.c | 28 +++++++++---------- > .../drm/bridge/analogix/analogix_dp_core.h | 4 ++- > .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 14 +++++----- > 3 files changed, 23 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > index 225f5e5dd69b..64842bbb2f3d 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > @@ -18,8 +18,7 @@ > #include <linux/iopoll.h> > #include <linux/interrupt.h> > #include <linux/of.h> > -#include <linux/of_gpio.h> > -#include <linux/gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/component.h> > #include <linux/phy/phy.h> > > @@ -1585,12 +1584,18 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, > > dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd"); > > - dp->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0); > - if (!gpio_is_valid(dp->hpd_gpio)) > - dp->hpd_gpio = of_get_named_gpio(dev->of_node, > - "samsung,hpd-gpio", 0); > + /* Try two different names */ > + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); > + if (!dp->hpd_gpiod) > + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "samsung,hpd", > + GPIOD_IN); > + if (IS_ERR(dp->hpd_gpiod)) { > + dev_err(dev, "error getting HDP GPIO: %ld\n", > + PTR_ERR(dp->hpd_gpiod)); > + return ERR_CAST(dp->hpd_gpiod); > + } > > - if (gpio_is_valid(dp->hpd_gpio)) { > + if (dp->hpd_gpiod) { > /* > * Set up the hotplug GPIO from the device tree as an interrupt. > * Simply specifying a different interrupt in the device tree > @@ -1598,16 +1603,9 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, > * using a GPIO. We also need the actual GPIO specifier so > * that we can get the current state of the GPIO. > */ > - ret = devm_gpio_request_one(&pdev->dev, dp->hpd_gpio, GPIOF_IN, > - "hpd_gpio"); > - if (ret) { > - dev_err(&pdev->dev, "failed to get hpd gpio\n"); > - return ERR_PTR(ret); > - } > - dp->irq = gpio_to_irq(dp->hpd_gpio); > + dp->irq = gpiod_to_irq(dp->hpd_gpiod); > irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; > } else { > - dp->hpd_gpio = -ENODEV; > dp->irq = platform_get_irq(pdev, 0); > irq_flags = 0; > } > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > index 769255dc6e99..dc65c2bafa63 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > @@ -38,6 +38,8 @@ > #define DPCD_VOLTAGE_SWING_SET(x) (((x) & 0x3) << 0) > #define DPCD_VOLTAGE_SWING_GET(x) (((x) >> 0) & 0x3) > > +struct gpio_desc; > + > enum link_lane_count_type { > LANE_COUNT1 = 1, > LANE_COUNT2 = 2, > @@ -171,7 +173,7 @@ struct analogix_dp_device { > struct link_train link_train; > struct phy *phy; > int dpms_mode; > - int hpd_gpio; > + struct gpio_desc *hpd_gpiod; > bool force_hpd; > bool psr_enable; > bool fast_train_enable; > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > index a5f2763d72e4..7aab2d6d710c 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > @@ -12,7 +12,7 @@ > > #include <linux/delay.h> > #include <linux/device.h> > -#include <linux/gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/io.h> > #include <linux/iopoll.h> > > @@ -397,7 +397,7 @@ void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) > + if (dp->hpd_gpiod) > return; > > reg = HOTPLUG_CHG | HPD_LOST | PLUG; > @@ -411,7 +411,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) > + if (dp->hpd_gpiod) > return; > > analogix_dp_clear_hotplug_interrupts(dp); > @@ -434,8 +434,8 @@ enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) { > - reg = gpio_get_value(dp->hpd_gpio); > + if (dp->hpd_gpiod) { > + reg = gpiod_get_value(dp->hpd_gpiod); > if (reg) > return DP_IRQ_TYPE_HP_CABLE_IN; > else > @@ -507,8 +507,8 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) { > - if (gpio_get_value(dp->hpd_gpio)) > + if (dp->hpd_gpiod) { > + if (gpiod_get_value(dp->hpd_gpiod)) > return 0; > } else { > reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3); >
Hi Linus, On 2019-06-10 01:13, Linus Walleij wrote: > This converts the Analogix display port to use GPIO descriptors > instead of DT-extracted numbers. > > Cc: Douglas Anderson <dianders@chromium.org> > Cc: Sean Paul <seanpaul@chromium.org> > Cc: Marek Szyprowski <m.szyprowski@samsung.com> > Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> although this patch doesn't apply cleanly on current linux-next. > --- > .../drm/bridge/analogix/analogix_dp_core.c | 28 +++++++++---------- > .../drm/bridge/analogix/analogix_dp_core.h | 4 ++- > .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 14 +++++----- > 3 files changed, 23 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > index 225f5e5dd69b..64842bbb2f3d 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > @@ -18,8 +18,7 @@ > #include <linux/iopoll.h> > #include <linux/interrupt.h> > #include <linux/of.h> > -#include <linux/of_gpio.h> > -#include <linux/gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/component.h> > #include <linux/phy/phy.h> > > @@ -1585,12 +1584,18 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, > > dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd"); > > - dp->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0); > - if (!gpio_is_valid(dp->hpd_gpio)) > - dp->hpd_gpio = of_get_named_gpio(dev->of_node, > - "samsung,hpd-gpio", 0); > + /* Try two different names */ > + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); > + if (!dp->hpd_gpiod) > + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "samsung,hpd", > + GPIOD_IN); > + if (IS_ERR(dp->hpd_gpiod)) { > + dev_err(dev, "error getting HDP GPIO: %ld\n", > + PTR_ERR(dp->hpd_gpiod)); > + return ERR_CAST(dp->hpd_gpiod); > + } > > - if (gpio_is_valid(dp->hpd_gpio)) { > + if (dp->hpd_gpiod) { > /* > * Set up the hotplug GPIO from the device tree as an interrupt. > * Simply specifying a different interrupt in the device tree > @@ -1598,16 +1603,9 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, > * using a GPIO. We also need the actual GPIO specifier so > * that we can get the current state of the GPIO. > */ > - ret = devm_gpio_request_one(&pdev->dev, dp->hpd_gpio, GPIOF_IN, > - "hpd_gpio"); > - if (ret) { > - dev_err(&pdev->dev, "failed to get hpd gpio\n"); > - return ERR_PTR(ret); > - } > - dp->irq = gpio_to_irq(dp->hpd_gpio); > + dp->irq = gpiod_to_irq(dp->hpd_gpiod); > irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; > } else { > - dp->hpd_gpio = -ENODEV; > dp->irq = platform_get_irq(pdev, 0); > irq_flags = 0; > } > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > index 769255dc6e99..dc65c2bafa63 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > @@ -38,6 +38,8 @@ > #define DPCD_VOLTAGE_SWING_SET(x) (((x) & 0x3) << 0) > #define DPCD_VOLTAGE_SWING_GET(x) (((x) >> 0) & 0x3) > > +struct gpio_desc; > + > enum link_lane_count_type { > LANE_COUNT1 = 1, > LANE_COUNT2 = 2, > @@ -171,7 +173,7 @@ struct analogix_dp_device { > struct link_train link_train; > struct phy *phy; > int dpms_mode; > - int hpd_gpio; > + struct gpio_desc *hpd_gpiod; > bool force_hpd; > bool psr_enable; > bool fast_train_enable; > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > index a5f2763d72e4..7aab2d6d710c 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > @@ -12,7 +12,7 @@ > > #include <linux/delay.h> > #include <linux/device.h> > -#include <linux/gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/io.h> > #include <linux/iopoll.h> > > @@ -397,7 +397,7 @@ void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) > + if (dp->hpd_gpiod) > return; > > reg = HOTPLUG_CHG | HPD_LOST | PLUG; > @@ -411,7 +411,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) > + if (dp->hpd_gpiod) > return; > > analogix_dp_clear_hotplug_interrupts(dp); > @@ -434,8 +434,8 @@ enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) { > - reg = gpio_get_value(dp->hpd_gpio); > + if (dp->hpd_gpiod) { > + reg = gpiod_get_value(dp->hpd_gpiod); > if (reg) > return DP_IRQ_TYPE_HP_CABLE_IN; > else > @@ -507,8 +507,8 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp) > { > u32 reg; > > - if (gpio_is_valid(dp->hpd_gpio)) { > - if (gpio_get_value(dp->hpd_gpio)) > + if (dp->hpd_gpiod) { > + if (gpiod_get_value(dp->hpd_gpiod)) > return 0; > } else { > reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3); Best regards
On 10.06.2019 01:13, Linus Walleij wrote: > This converts the Analogix display port to use GPIO descriptors > instead of DT-extracted numbers. > > Cc: Douglas Anderson <dianders@chromium.org> > Cc: Sean Paul <seanpaul@chromium.org> > Cc: Marek Szyprowski <m.szyprowski@samsung.com> > Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Will be queued to drm-misc-next. -- Regards Andrzej
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 225f5e5dd69b..64842bbb2f3d 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -18,8 +18,7 @@ #include <linux/iopoll.h> #include <linux/interrupt.h> #include <linux/of.h> -#include <linux/of_gpio.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/component.h> #include <linux/phy/phy.h> @@ -1585,12 +1584,18 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd"); - dp->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0); - if (!gpio_is_valid(dp->hpd_gpio)) - dp->hpd_gpio = of_get_named_gpio(dev->of_node, - "samsung,hpd-gpio", 0); + /* Try two different names */ + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); + if (!dp->hpd_gpiod) + dp->hpd_gpiod = devm_gpiod_get_optional(dev, "samsung,hpd", + GPIOD_IN); + if (IS_ERR(dp->hpd_gpiod)) { + dev_err(dev, "error getting HDP GPIO: %ld\n", + PTR_ERR(dp->hpd_gpiod)); + return ERR_CAST(dp->hpd_gpiod); + } - if (gpio_is_valid(dp->hpd_gpio)) { + if (dp->hpd_gpiod) { /* * Set up the hotplug GPIO from the device tree as an interrupt. * Simply specifying a different interrupt in the device tree @@ -1598,16 +1603,9 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, * using a GPIO. We also need the actual GPIO specifier so * that we can get the current state of the GPIO. */ - ret = devm_gpio_request_one(&pdev->dev, dp->hpd_gpio, GPIOF_IN, - "hpd_gpio"); - if (ret) { - dev_err(&pdev->dev, "failed to get hpd gpio\n"); - return ERR_PTR(ret); - } - dp->irq = gpio_to_irq(dp->hpd_gpio); + dp->irq = gpiod_to_irq(dp->hpd_gpiod); irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; } else { - dp->hpd_gpio = -ENODEV; dp->irq = platform_get_irq(pdev, 0); irq_flags = 0; } diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h index 769255dc6e99..dc65c2bafa63 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h @@ -38,6 +38,8 @@ #define DPCD_VOLTAGE_SWING_SET(x) (((x) & 0x3) << 0) #define DPCD_VOLTAGE_SWING_GET(x) (((x) >> 0) & 0x3) +struct gpio_desc; + enum link_lane_count_type { LANE_COUNT1 = 1, LANE_COUNT2 = 2, @@ -171,7 +173,7 @@ struct analogix_dp_device { struct link_train link_train; struct phy *phy; int dpms_mode; - int hpd_gpio; + struct gpio_desc *hpd_gpiod; bool force_hpd; bool psr_enable; bool fast_train_enable; diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c index a5f2763d72e4..7aab2d6d710c 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c @@ -12,7 +12,7 @@ #include <linux/delay.h> #include <linux/device.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/io.h> #include <linux/iopoll.h> @@ -397,7 +397,7 @@ void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp) { u32 reg; - if (gpio_is_valid(dp->hpd_gpio)) + if (dp->hpd_gpiod) return; reg = HOTPLUG_CHG | HPD_LOST | PLUG; @@ -411,7 +411,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) { u32 reg; - if (gpio_is_valid(dp->hpd_gpio)) + if (dp->hpd_gpiod) return; analogix_dp_clear_hotplug_interrupts(dp); @@ -434,8 +434,8 @@ enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp) { u32 reg; - if (gpio_is_valid(dp->hpd_gpio)) { - reg = gpio_get_value(dp->hpd_gpio); + if (dp->hpd_gpiod) { + reg = gpiod_get_value(dp->hpd_gpiod); if (reg) return DP_IRQ_TYPE_HP_CABLE_IN; else @@ -507,8 +507,8 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp) { u32 reg; - if (gpio_is_valid(dp->hpd_gpio)) { - if (gpio_get_value(dp->hpd_gpio)) + if (dp->hpd_gpiod) { + if (gpiod_get_value(dp->hpd_gpiod)) return 0; } else { reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
This converts the Analogix display port to use GPIO descriptors instead of DT-extracted numbers. Cc: Douglas Anderson <dianders@chromium.org> Cc: Sean Paul <seanpaul@chromium.org> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- .../drm/bridge/analogix/analogix_dp_core.c | 28 +++++++++---------- .../drm/bridge/analogix/analogix_dp_core.h | 4 ++- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 14 +++++----- 3 files changed, 23 insertions(+), 23 deletions(-)