From patchwork Fri Nov 9 05:53:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 1718791 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 53A46DF264 for ; Fri, 9 Nov 2012 05:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750903Ab2KIFxw (ORCPT ); Fri, 9 Nov 2012 00:53:52 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:29512 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810Ab2KIFxv (ORCPT ); Fri, 9 Nov 2012 00:53:51 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD700BIMHPGI2O0@mailout3.samsung.com> for linux-fbdev@vger.kernel.org; Fri, 09 Nov 2012 14:53:50 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.47]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 29.58.01231.E6A9C905; Fri, 09 Nov 2012 14:53:50 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-3a-509c9a6eec9a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C8.58.01231.E6A9C905; Fri, 09 Nov 2012 14:53:50 +0900 (KST) Received: from DOJG1HAN02 ([12.23.120.99]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MD700BDHHPQVJ40@mmp2.samsung.com> for linux-fbdev@vger.kernel.org; Fri, 09 Nov 2012 14:53:50 +0900 (KST) From: Jingoo Han To: 'Florian Tobias Schandinat' Cc: linux-fbdev@vger.kernel.org, 'Sean Paul' , 'Jingoo Han' References: In-reply-to: Subject: [PATCH v4 8/8] video: exynos_dp: Enable hotplug interrupts Date: Fri, 09 Nov 2012 14:53:49 +0900 Message-id: <002001cdbe3e$975d3410$c6179c30$%han@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac2+Pd0+5OZ6ri/CQOacII/BjUUEfAAAJosg Content-language: ko DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsVy+t8zfd28WXMCDA5/EbY40feB1YHR4/Mm uQDGKC6blNSczLLUIn27BK6MDRcusxc0GlS8u9XP2sC4VqOLkZNDQsBE4sacCUwQtpjEhXvr 2boYuTiEBJYxSsxceYQNpujy1zVgRUIC0xkl/t43gbBnMUl8Pl8JYrMJqEl8+XKYvYuRg0NE wEpi01ZNEJNZIEvi9DEFEFNIgFtidXMQSDGnAI/Euj+dzCC2sICzxLz9fSwgNouAqsS31bPB bF4BW4kHU7cyQ9iCEj8m3wOLMwtoSazfeZwJwpaX2LzmLTPIeAkBdYlHf3VBwiICRhJvJ06B KhGR2PfiHSPEeAGJb5MPsUCUy0psOsAM8quEwDx2iasXpjJD/CopcXDFDZYJjBKzkGyehWTz LCSbZyFZsYCRZRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGSERJ7WBc2WBxiFGAg1GJhzfx wewAIdbEsuLK3EOMEhzMSiK8czPnBAjxpiRWVqUW5ccXleakFh9i9AG6fCKzlGhyPjDa80ri DY2NTcxMTE3MLU3NTXEIK4nzNnukBAgJpCeWpGanphakFsGMY+LglGpgzNGs2fv7UKPm7MD0 +6VFkxRaXxUv0RY1Lln65FtAy7qbWRveae3zq+J2PjbX/W4Ye/WMjvr2sAd9RVtfs4tXea41 Xb7gZUrVzRmXK94fuWvfne032XjX6T7NWx08ImdC+fO8X289KL5yD3vBvBfKK1z/p7y1Ssvi NciUEi3iWN6bWSq9KyBJiaU4I9FQi7moOBEA7HS3Y9UCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRmVeSWpSXmKPExsVy+t9jQd28WXMCDPZt5bc40feB1YHR4/Mm uQDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwjrGjA0XLrMXNBpUvLvVz9rA uFaji5GTQ0LAROLy1zVMELaYxIV769lAbCGB6YwSf++bQNizmCQ+n68EsdkE1CS+fDnM3sXI wSEiYCWxaasmiMkskCVx+pgCiCkkwC2xujkIpJhTgEdi3Z9OZhBbWMBZYt7+PhYQm0VAVeLb 6tlgNq+ArcSDqVuZIWxBiR+T74HFmQW0JNbvPM4EYctLbF7zlhlkvISAusSjv7ogYREBI4m3 E6dAlYhI7HvxjnECo9AsJJNmIZk0C8mkWUhaFjCyrGIUTS1ILihOSs811CtOzC0uzUvXS87P 3cQIjtdnUjsYVzZYHGIU4GBU4uFNfDA7QIg1say4MvcQowQHs5II79zMOQFCvCmJlVWpRfnx RaU5qcWHGH2AHp3ILCWanA9MJXkl8YbGJmZGlkZmFkYm5uY4hJXEeZs9UgKEBNITS1KzU1ML UotgxjFxcEo1MHZx3+v9uY75w70b6s8+uwSa+NyTN/8d9kieIfWTzLbz9QbZOrOLgo4uuesw per4pnKVLRsnPXxzPViZf4pGeAgHZ/H1JMnIGc/l+NJ1LzK/V3CQzGdQzP3i5y+1oOrPxLDD L6XaN+4OmNBka/n00VRb1UXupWKnbhfX3OP/8XHx4VOdEmnVKkosxRmJhlrMRcWJADZhBC8E AwAA X-CFilter-Loop: Reflected Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Sean Paul Enable hotplug interrupts and move the hotplug scheduling into the interrupt handler. This allows us to introduce a screen at any time while we're running. [jg1.han@samsung.com: moved the bit masking of hotplug interrupts] Signed-off-by: Sean Paul Reviewed-by: Olof Johansson Signed-off-by: Jingoo Han --- drivers/video/exynos/exynos_dp_core.c | 38 ++++++++++++++++++++++++++------- drivers/video/exynos/exynos_dp_core.h | 9 +++++++ drivers/video/exynos/exynos_dp_reg.c | 38 +++++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 79ba1ea..7cbba4a 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -48,10 +48,6 @@ static int exynos_dp_detect_hpd(struct exynos_dp_device *dp) { int timeout_loop = 0; - exynos_dp_init_hpd(dp); - - usleep_range(200, 210); - while (exynos_dp_get_plug_in_status(dp) != 0) { timeout_loop++; if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) { @@ -833,7 +829,32 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg) { struct exynos_dp_device *dp = arg; - dev_err(dp->dev, "exynos_dp_irq_handler\n"); + enum dp_irq_type irq_type; + + irq_type = exynos_dp_get_irq_type(dp); + switch (irq_type) { + case DP_IRQ_TYPE_HP_CABLE_IN: + dev_dbg(dp->dev, "Received irq - cable in\n"); + schedule_work(&dp->hotplug_work); + exynos_dp_clear_hotplug_interrupts(dp); + break; + case DP_IRQ_TYPE_HP_CABLE_OUT: + dev_dbg(dp->dev, "Received irq - cable out\n"); + exynos_dp_clear_hotplug_interrupts(dp); + break; + case DP_IRQ_TYPE_HP_CHANGE: + /* + * We get these change notifications once in a while, but there + * is nothing we can do with them. Just ignore it for now and + * only handle cable changes. + */ + dev_dbg(dp->dev, "Received irq - hotplug change; ignoring.\n"); + exynos_dp_clear_hotplug_interrupts(dp); + break; + default: + dev_err(dp->dev, "Received irq - unknown type!\n"); + break; + } return IRQ_HANDLED; } @@ -846,7 +867,7 @@ static void exynos_dp_hotplug(struct work_struct *work) ret = exynos_dp_detect_hpd(dp); if (ret) { - dev_err(dp->dev, "unable to detect hpd\n"); + /* Cable has been disconnected, we're done */ return; } @@ -937,7 +958,6 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) exynos_dp_init_dp(dp); platform_set_drvdata(pdev, dp); - schedule_work(&dp->hotplug_work); return 0; } @@ -965,6 +985,8 @@ static int exynos_dp_suspend(struct device *dev) struct exynos_dp_platdata *pdata = pdev->dev.platform_data; struct exynos_dp_device *dp = platform_get_drvdata(pdev); + disable_irq(dp->irq); + if (work_pending(&dp->hotplug_work)) flush_work(&dp->hotplug_work); @@ -989,7 +1011,7 @@ static int exynos_dp_resume(struct device *dev) exynos_dp_init_dp(dp); - schedule_work(&dp->hotplug_work); + enable_irq(dp->irq); return 0; } diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h index 66f11f4..520486e 100644 --- a/drivers/video/exynos/exynos_dp_core.h +++ b/drivers/video/exynos/exynos_dp_core.h @@ -13,6 +13,13 @@ #ifndef _EXYNOS_DP_CORE_H #define _EXYNOS_DP_CORE_H +enum dp_irq_type { + DP_IRQ_TYPE_HP_CABLE_IN, + DP_IRQ_TYPE_HP_CABLE_OUT, + DP_IRQ_TYPE_HP_CHANGE, + DP_IRQ_TYPE_UNKNOWN, +}; + struct link_train { int eq_loop; int cr_loop[4]; @@ -51,6 +58,8 @@ void exynos_dp_set_analog_power_down(struct exynos_dp_device *dp, bool enable); void exynos_dp_init_analog_func(struct exynos_dp_device *dp); void exynos_dp_init_hpd(struct exynos_dp_device *dp); +enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp); +void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp); void exynos_dp_reset_aux(struct exynos_dp_device *dp); void exynos_dp_init_aux(struct exynos_dp_device *dp); int exynos_dp_get_plug_in_status(struct exynos_dp_device *dp); diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c index fc19ef6..9fb901b 100644 --- a/drivers/video/exynos/exynos_dp_reg.c +++ b/drivers/video/exynos/exynos_dp_reg.c @@ -19,11 +19,11 @@ #include "exynos_dp_core.h" #include "exynos_dp_reg.h" -#define COMMON_INT_MASK_1 (0) -#define COMMON_INT_MASK_2 (0) -#define COMMON_INT_MASK_3 (0) -#define COMMON_INT_MASK_4 (0) -#define INT_STA_MASK (0) +#define COMMON_INT_MASK_1 0 +#define COMMON_INT_MASK_2 0 +#define COMMON_INT_MASK_3 0 +#define COMMON_INT_MASK_4 (HOTPLUG_CHG | HPD_LOST | PLUG) +#define INT_STA_MASK INT_HPD void exynos_dp_enable_video_mute(struct exynos_dp_device *dp, bool enable) { @@ -324,7 +324,7 @@ void exynos_dp_init_analog_func(struct exynos_dp_device *dp) writel(reg, dp->reg_base + EXYNOS_DP_FUNC_EN_2); } -void exynos_dp_init_hpd(struct exynos_dp_device *dp) +void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp) { u32 reg; @@ -333,12 +333,38 @@ void exynos_dp_init_hpd(struct exynos_dp_device *dp) reg = INT_HPD; writel(reg, dp->reg_base + EXYNOS_DP_INT_STA); +} + +void exynos_dp_init_hpd(struct exynos_dp_device *dp) +{ + u32 reg; + + exynos_dp_clear_hotplug_interrupts(dp); reg = readl(dp->reg_base + EXYNOS_DP_SYS_CTL_3); reg &= ~(F_HPD | HPD_CTRL); writel(reg, dp->reg_base + EXYNOS_DP_SYS_CTL_3); } +enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp) +{ + u32 reg; + + /* Parse hotplug interrupt status register */ + reg = readl(dp->reg_base + EXYNOS_DP_COMMON_INT_STA_4); + + if (reg & PLUG) + return DP_IRQ_TYPE_HP_CABLE_IN; + + if (reg & HPD_LOST) + return DP_IRQ_TYPE_HP_CABLE_OUT; + + if (reg & HOTPLUG_CHG) + return DP_IRQ_TYPE_HP_CHANGE; + + return DP_IRQ_TYPE_UNKNOWN; +} + void exynos_dp_reset_aux(struct exynos_dp_device *dp) { u32 reg;