From patchwork Thu Apr 3 15:10:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Sharma X-Patchwork-Id: 3932901 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 472B0BFF02 for ; Thu, 3 Apr 2014 15:12:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64D84201F9 for ; Thu, 3 Apr 2014 15:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69C242021B for ; Thu, 3 Apr 2014 15:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553AbaDCPMW (ORCPT ); Thu, 3 Apr 2014 11:12:22 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:37028 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752490AbaDCPMO (ORCPT ); Thu, 3 Apr 2014 11:12:14 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3G00DTJNKBFU10@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 04 Apr 2014 00:12:11 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id E6.C4.10364.B4A7D335; Fri, 04 Apr 2014 00:12:11 +0900 (KST) X-AuditID: cbfee690-b7f266d00000287c-5d-533d7a4b4c09 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 08.A2.29263.B4A7D335; Fri, 04 Apr 2014 00:12:11 +0900 (KST) Received: from localhost.localdomain ([107.108.83.245]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N3G00IVZNJBV460@mmp2.samsung.com>; Fri, 04 Apr 2014 00:12:11 +0900 (KST) From: Rahul Sharma To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, r.sh.open@gmail.com, joshi@samsung.com, Sean Paul , Rahul Sharma Subject: [PATCH 2/7] drm/exynos: Debounce HDMI hotplug interrupts Date: Thu, 03 Apr 2014 20:40:59 +0530 Message-id: <1396537864-29291-3-git-send-email-rahul.sharma@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1396537864-29291-1-git-send-email-rahul.sharma@samsung.com> References: <1396537864-29291-1-git-send-email-rahul.sharma@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGLMWRmVeSWpSXmKPExsWyRsSkTte7yjbY4N81ZYsrX9+zWUy6P4HF 4vuuL+wWM87vY7JY+CLeYsqiw6wWdzecZXRg95jdcJHFY+esu+we97uPM3n0bVnF6PF5k1wA axSXTUpqTmZZapG+XQJXxqv3s5gKdkpUPOicx9TAeEGki5GTQ0LARKJt8kNGCFtM4sK99Wxd jFwcQgJLGSUmXXvPCFP048hJqMR0Rom5DfsZIZx2JomZV5ezgFSxCehKzD74DKxDRMBNounw TFaQImaBPkaJ/oufwRLCAo4SHes2soHYLAKqEvMu/WUGsXkFPCRmrzgLFOcAWqcgMWeSDUiY U8BT4svnT2CtQkAlP/cdYgeZKSEwnV3i0OYZjBBzBCS+TT7EAtErK7HpADPE1ZISB1fcYJnA KLyAkWEVo2hqQXJBcVJ6kYlecWJucWleul5yfu4mRmCYn/73bMIOxnsHrA8xJgONm8gsJZqc D4yTvJJ4Q2MzIwtTE1NjI3NLM9KElcR51R4lBQkJpC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M8uUdP45HU1Q8Rb5VYijMSDbWYi4oTAQG8U/vmAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul This patch debounces hotplug interrupts generated by the HDMI hotplug gpio. The reason this is needed is that we get multiple (5) interrupts every time a monitor is inserted which causes us to needlessly enable and disable the IP block. Signed-off-by: Sean Paul Signed-off-by: Rahul Sharma --- drivers/gpu/drm/exynos/exynos_hdmi.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 79f98ac..f6d4435 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -51,6 +51,8 @@ #define get_hdmi_display(dev) platform_get_drvdata(to_platform_device(dev)) #define ctx_from_connector(c) container_of(c, struct hdmi_context, connector) +#define HOTPLUG_DEBOUNCE_MS 1100 + /* AVI header and aspect ratio */ #define HDMI_AVI_VERSION 0x02 #define HDMI_AVI_LENGTH 0x0D @@ -189,6 +191,7 @@ struct hdmi_context { void __iomem *regs; int irq; + struct delayed_work hotplug_work; struct i2c_adapter *ddc_adpt; struct i2c_client *hdmiphy_port; @@ -2058,6 +2061,8 @@ static void hdmi_poweroff(struct exynos_drm_display *display) hdmiphy_poweroff(hdata); + cancel_delayed_work(&hdata->hotplug_work); + clk_disable_unprepare(res->sclk_hdmi); clk_disable_unprepare(res->hdmi); /* reset pmu hdmiphy control bit to disable hdmiphy */ @@ -2108,9 +2113,11 @@ static struct exynos_drm_display hdmi_display = { .ops = &hdmi_display_ops, }; -static irqreturn_t hdmi_irq_thread(int irq, void *arg) +static void hdmi_hotplug_work_func(struct work_struct *work) { - struct hdmi_context *hdata = arg; + struct hdmi_context *hdata; + + hdata = container_of(work, struct hdmi_context, hotplug_work.work); mutex_lock(&hdata->hdmi_mutex); hdata->hpd = 1;//gpio_get_value(hdata->hpd_gpio); @@ -2118,6 +2125,14 @@ static irqreturn_t hdmi_irq_thread(int irq, void *arg) if (hdata->drm_dev) drm_helper_hpd_irq_event(hdata->drm_dev); +} + +static irqreturn_t hdmi_irq_thread(int irq, void *arg) +{ + struct hdmi_context *hdata = arg; + + mod_delayed_work(system_wq, &hdata->hotplug_work, + msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS)); return IRQ_HANDLED; } @@ -2315,6 +2330,8 @@ static int hdmi_probe(struct platform_device *pdev) hdata->hpd = 1;//gpio_get_value(hdata->hpd_gpio); + INIT_DELAYED_WORK(&hdata->hotplug_work, hdmi_hotplug_work_func); + ret = devm_request_threaded_irq(dev, hdata->irq, NULL, hdmi_irq_thread, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, @@ -2351,6 +2368,8 @@ static int hdmi_remove(struct platform_device *pdev) struct exynos_drm_display *display = get_hdmi_display(dev); struct hdmi_context *hdata = display->ctx; + cancel_delayed_work_sync(&hdata->hotplug_work); + put_device(&hdata->hdmiphy_port->dev); put_device(&hdata->ddc_adpt->dev); pm_runtime_disable(&pdev->dev);