From patchwork Thu Nov 1 10:24:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 1684311 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 54E653FCDF for ; Thu, 1 Nov 2012 10:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761117Ab2KAKYS (ORCPT ); Thu, 1 Nov 2012 06:24:18 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:40832 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753748Ab2KAKYO (ORCPT ); Thu, 1 Nov 2012 06:24:14 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCT00AV30W695X0@mailout3.samsung.com> for linux-fbdev@vger.kernel.org; Thu, 01 Nov 2012 19:24:13 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-b8-50924dcd6f81 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 2C.5A.12699.DCD42905; Thu, 01 Nov 2012 19:24:13 +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 <0MCT009W60WDP930@mmp2.samsung.com> for linux-fbdev@vger.kernel.org; Thu, 01 Nov 2012 19:24:13 +0900 (KST) From: Jingoo Han To: 'Florian Tobias Schandinat' Cc: linux-fbdev@vger.kernel.org, 'Sean Paul' , 'Jingoo Han' References: <011d01cdb81a$4914c1d0$db3e4570$%han@samsung.com> In-reply-to: <011d01cdb81a$4914c1d0$db3e4570$%han@samsung.com> Subject: [PATCH v3 7/8] video: exynos_dp: Move hotplug into a workqueue Date: Thu, 01 Nov 2012 19:24:13 +0900 Message-id: <012301cdb81b$09cf70f0$1d6e52d0$%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: Ac24Gkjta+Tb9VxGTiWIp02dvaPqfwAAKtLw Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jQd2zvpMCDJYfkLA40feB1YHR4/Mm uQDGKC6blNSczLLUIn27BK6MsyumMxa8Vqs4/+E5YwPjY4UuRk4OCQETiS2rVjBC2GISF+6t Z+ti5OIQEpjOKHHvfh8ThDOLSaJv9242kCo2ATWJL18Os3cxcnCICFhJbNqqCWIyC2RJnD4G NlNIwFZiXcsnsJmcAnYSrQ+bmEBsYQF3iZ9zF4F1sgioSlzebQgS5gUq/72mixHCFpT4Mfke C4jNLKAlsX7ncSYIW15i85q3zCCtEgLqEo/+6oKERQSMJD7e+swIUSIise/FO8YJjEKzkEya hWTSLCSTZiFpWcDIsopRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMjOISfSe9gXNVgcYhRgINR iYd3Qt3EACHWxLLiytxDjBIczEoivI+7gUK8KYmVValF+fFFpTmpxYcYpTlYlMR5mz1SAoQE 0hNLUrNTUwtSi2CyTBycUg2MHQ9XHvz6WDTU6eW5t6Gc+rZG2XdSFi4J/LvDUi/g+rUloetb 327anjAt5HfxMhM+0dA9669FTvrAJ3VryqEDh+4d8d9Vb5q54Dsvw6E1blO6u+9rbos5aZsX uJl1Qv/mW8fu/Lbf63W589+yG89/bzW94NriwTiNNy5vQsDr4KSnCiJyD/7Oua3EUpyRaKjF XFScCADS7k3MXQIAAA== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Move the hotplug related code from probe and resume into a workqueue. This allows us to initialize the DP driver (and resume it) when there is no monitor connected. Signed-off-by: Sean Paul Reviewed-by: Olof Johansson Signed-off-by: Jingoo Han --- drivers/video/exynos/exynos_dp_core.c | 93 +++++++++++++++++--------------- drivers/video/exynos/exynos_dp_core.h | 1 + 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index c2b6bf2..ffb6d6d 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -874,6 +874,45 @@ static irqreturn_t exynos_dp_irq_handler(int irq, void *arg) return IRQ_HANDLED; } +static void exynos_dp_hotplug(struct work_struct *work) +{ + struct exynos_dp_device *dp; + int ret; + + dp = container_of(work, struct exynos_dp_device, hotplug_work); + + ret = exynos_dp_detect_hpd(dp); + if (ret) { + dev_err(dp->dev, "unable to detect hpd\n"); + return; + } + + ret = exynos_dp_handle_edid(dp); + if (ret) { + dev_err(dp->dev, "unable to handle edid\n"); + return; + } + + ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count, + dp->video_info->link_rate); + if (ret) { + dev_err(dp->dev, "unable to do link train\n"); + return; + } + + exynos_dp_enable_scramble(dp, 1); + exynos_dp_enable_rx_to_enhanced_mode(dp, 1); + exynos_dp_enable_enhanced_mode(dp, 1); + + exynos_dp_set_lane_count(dp, dp->video_info->lane_count); + exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate); + + exynos_dp_init_video(dp); + ret = exynos_dp_config_video(dp, dp->video_info); + if (ret) + dev_err(dp->dev, "unable to config video\n"); +} + static int __devinit exynos_dp_probe(struct platform_device *pdev) { struct resource *res; @@ -919,6 +958,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) return -ENODEV; } + INIT_WORK(&dp->hotplug_work, exynos_dp_hotplug); + ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0, "exynos-dp", dp); if (ret) { @@ -932,36 +973,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) exynos_dp_init_dp(dp); - ret = exynos_dp_detect_hpd(dp); - if (ret) { - dev_err(&pdev->dev, "unable to detect hpd\n"); - return ret; - } - - exynos_dp_handle_edid(dp); - - ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count, - dp->video_info->link_rate); - if (ret) { - dev_err(&pdev->dev, "unable to do link train\n"); - return ret; - } - - exynos_dp_enable_scramble(dp, 1); - exynos_dp_enable_rx_to_enhanced_mode(dp, 1); - exynos_dp_enable_enhanced_mode(dp, 1); - - exynos_dp_set_lane_count(dp, dp->video_info->lane_count); - exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate); - - exynos_dp_init_video(dp); - ret = exynos_dp_config_video(dp, dp->video_info); - if (ret) { - dev_err(&pdev->dev, "unable to config video\n"); - return ret; - } - platform_set_drvdata(pdev, dp); + schedule_work(&dp->hotplug_work); return 0; } @@ -971,6 +984,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev) struct exynos_dp_platdata *pdata = pdev->dev.platform_data; struct exynos_dp_device *dp = platform_get_drvdata(pdev); + if (work_pending(&dp->hotplug_work)) + flush_work(&dp->hotplug_work); + if (pdata && pdata->phy_exit) pdata->phy_exit(); @@ -986,6 +1002,9 @@ 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); + if (work_pending(&dp->hotplug_work)) + flush_work(&dp->hotplug_work); + if (pdata && pdata->phy_exit) pdata->phy_exit(); @@ -1007,21 +1026,7 @@ static int exynos_dp_resume(struct device *dev) exynos_dp_init_dp(dp); - exynos_dp_detect_hpd(dp); - exynos_dp_handle_edid(dp); - - exynos_dp_set_link_train(dp, dp->video_info->lane_count, - dp->video_info->link_rate); - - exynos_dp_enable_scramble(dp, 1); - exynos_dp_enable_rx_to_enhanced_mode(dp, 1); - exynos_dp_enable_enhanced_mode(dp, 1); - - exynos_dp_set_lane_count(dp, dp->video_info->lane_count); - exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate); - - exynos_dp_init_video(dp); - exynos_dp_config_video(dp, dp->video_info); + schedule_work(&dp->hotplug_work); return 0; } diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h index 57b8a65..66f11f4 100644 --- a/drivers/video/exynos/exynos_dp_core.h +++ b/drivers/video/exynos/exynos_dp_core.h @@ -32,6 +32,7 @@ struct exynos_dp_device { struct video_info *video_info; struct link_train link_train; + struct work_struct hotplug_work; }; /* exynos_dp_reg.c */