提交 b8b52471 编写于 作者: A Andrew Bresticker 提交者: Inki Dae

drm/exynos: dp: support hotplug detection via GPIO

Certain bridge chips use a GPIO to indicate the cable status instead
of the I_DP_HPD pin.  This adds an optional device-tree property,
"samsung,hpd-gpio", to the exynos-dp controller which indicates that
the specified GPIO should be used for hotplug detection.
The GPIO is then set up as an edge-triggered interrupt where the
rising edge indicates hotplug-in and the falling edge indicates hotplug-out.
Signed-off-by: NAndrew Bresticker <abrestic@chromium.org>
Signed-off-by: NRahul Sharma <rahul.sharma@samsung.com>
Signed-off-by: NAjay Kumar <ajaykumar.rs@samsung.com>
Acked-by: NJingoo Han <jg1.han@samsung.com>
Signed-off-by: NInki Dae <inki.dae@samsung.com>
上级 fbc2063d
...@@ -62,6 +62,10 @@ Optional properties for dp-controller: ...@@ -62,6 +62,10 @@ Optional properties for dp-controller:
-hsync-active-high: -hsync-active-high:
HSYNC polarity configuration. HSYNC polarity configuration.
High if defined, Low if not defined High if defined, Low if not defined
-samsung,hpd-gpio:
Hotplug detect GPIO.
Indicates which GPIO should be used for hotplug
detection
Example: Example:
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <linux/component.h> #include <linux/component.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <video/of_display_timing.h> #include <video/of_display_timing.h>
...@@ -1217,6 +1219,7 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1217,6 +1219,7 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
struct drm_device *drm_dev = data; struct drm_device *drm_dev = data;
struct resource *res; struct resource *res;
struct exynos_dp_device *dp; struct exynos_dp_device *dp;
unsigned int irq_flags;
int ret = 0; int ret = 0;
...@@ -1254,7 +1257,30 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1254,7 +1257,30 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
if (IS_ERR(dp->reg_base)) if (IS_ERR(dp->reg_base))
return PTR_ERR(dp->reg_base); return PTR_ERR(dp->reg_base);
dp->irq = platform_get_irq(pdev, 0); dp->hpd_gpio = of_get_named_gpio(dev->of_node, "samsung,hpd-gpio", 0);
if (gpio_is_valid(dp->hpd_gpio)) {
/*
* Set up the hotplug GPIO from the device tree as an interrupt.
* Simply specifying a different interrupt in the device tree
* doesn't work since we handle hotplug rather differently when
* 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 ret;
}
dp->irq = gpio_to_irq(dp->hpd_gpio);
irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
} else {
dp->hpd_gpio = -ENODEV;
dp->irq = platform_get_irq(pdev, 0);
irq_flags = 0;
}
if (dp->irq == -ENXIO) { if (dp->irq == -ENXIO) {
dev_err(&pdev->dev, "failed to get irq\n"); dev_err(&pdev->dev, "failed to get irq\n");
return -ENODEV; return -ENODEV;
...@@ -1266,8 +1292,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1266,8 +1292,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
exynos_dp_init_dp(dp); exynos_dp_init_dp(dp);
ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0, ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler,
"exynos-dp", dp); irq_flags, "exynos-dp", dp);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to request irq\n"); dev_err(&pdev->dev, "failed to request irq\n");
return ret; return ret;
......
...@@ -159,6 +159,7 @@ struct exynos_dp_device { ...@@ -159,6 +159,7 @@ struct exynos_dp_device {
struct work_struct hotplug_work; struct work_struct hotplug_work;
struct phy *phy; struct phy *phy;
int dpms_mode; int dpms_mode;
int hpd_gpio;
struct exynos_drm_panel_info panel; struct exynos_drm_panel_info panel;
}; };
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h>
#include "exynos_dp_core.h" #include "exynos_dp_core.h"
#include "exynos_dp_reg.h" #include "exynos_dp_reg.h"
...@@ -326,6 +327,9 @@ void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp) ...@@ -326,6 +327,9 @@ void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp)
{ {
u32 reg; u32 reg;
if (gpio_is_valid(dp->hpd_gpio))
return;
reg = HOTPLUG_CHG | HPD_LOST | PLUG; reg = HOTPLUG_CHG | HPD_LOST | PLUG;
writel(reg, dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4); writel(reg, dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4);
...@@ -337,6 +341,9 @@ void exynos_dp_init_hpd(struct exynos_dp_device *dp) ...@@ -337,6 +341,9 @@ void exynos_dp_init_hpd(struct exynos_dp_device *dp)
{ {
u32 reg; u32 reg;
if (gpio_is_valid(dp->hpd_gpio))
return;
exynos_dp_clear_hotplug_interrupts(dp); exynos_dp_clear_hotplug_interrupts(dp);
reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3); reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3);
...@@ -348,19 +355,27 @@ enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp) ...@@ -348,19 +355,27 @@ enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp)
{ {
u32 reg; u32 reg;
/* Parse hotplug interrupt status register */ if (gpio_is_valid(dp->hpd_gpio)) {
reg = readl(dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4); reg = gpio_get_value(dp->hpd_gpio);
if (reg)
return DP_IRQ_TYPE_HP_CABLE_IN;
else
return DP_IRQ_TYPE_HP_CABLE_OUT;
} else {
/* Parse hotplug interrupt status register */
reg = readl(dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4);
if (reg & PLUG) if (reg & PLUG)
return DP_IRQ_TYPE_HP_CABLE_IN; return DP_IRQ_TYPE_HP_CABLE_IN;
if (reg & HPD_LOST) if (reg & HPD_LOST)
return DP_IRQ_TYPE_HP_CABLE_OUT; return DP_IRQ_TYPE_HP_CABLE_OUT;
if (reg & HOTPLUG_CHG) if (reg & HOTPLUG_CHG)
return DP_IRQ_TYPE_HP_CHANGE; return DP_IRQ_TYPE_HP_CHANGE;
return DP_IRQ_TYPE_UNKNOWN; return DP_IRQ_TYPE_UNKNOWN;
}
} }
void exynos_dp_reset_aux(struct exynos_dp_device *dp) void exynos_dp_reset_aux(struct exynos_dp_device *dp)
...@@ -402,9 +417,14 @@ int exynos_dp_get_plug_in_status(struct exynos_dp_device *dp) ...@@ -402,9 +417,14 @@ int exynos_dp_get_plug_in_status(struct exynos_dp_device *dp)
{ {
u32 reg; u32 reg;
reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3); if (gpio_is_valid(dp->hpd_gpio)) {
if (reg & HPD_STATUS) if (gpio_get_value(dp->hpd_gpio))
return 0; return 0;
} else {
reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3);
if (reg & HPD_STATUS)
return 0;
}
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册