From patchwork Thu Nov 1 10:28:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 1684381 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 1763D3FE1F for ; Thu, 1 Nov 2012 10:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759526Ab2KAK2w (ORCPT ); Thu, 1 Nov 2012 06:28:52 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:41373 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759478Ab2KAK2w (ORCPT ); Thu, 1 Nov 2012 06:28:52 -0400 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 <0MCT0030S142O9Z0@mailout3.samsung.com> for linux-fbdev@vger.kernel.org; Thu, 01 Nov 2012 19:28:50 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-00-50924ee2e7e9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id B5.4E.01231.2EE42905; Thu, 01 Nov 2012 19:28:50 +0900 (KST) Received: from DOJG1HAN02 ([12.23.120.99]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCT009Q8142S460@mmp1.samsung.com> for linux-fbdev@vger.kernel.org; Thu, 01 Nov 2012 19:28:50 +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: Subject: [PATCH v3 7/8] video: exynos_dp: Move hotplug into a workqueue Date: Thu, 01 Nov 2012 19:28:50 +0900 Message-id: <012501cdb81b$af336060$0d9a2120$%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+Tb9VxGTiWIp02dvaPqfwAAKtLwAAAdlKA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jAd1HfpMCDPr7TSxO9H1gdWD0+LxJ LoAxissmJTUnsyy1SN8ugSvjxrH6guPqFavvTWdrYNyg2MXIySEhYCLxuOsDO4QtJnHh3nq2 LkYuDiGBRYwSW/a0sUA4s5gklr94wgJSxSagJvHly2GgDg4OEQEriU1bNUFMZoEsidPHFEAq hARsJda1fGIEsTkFeCTW/elkBrGFBdwlfs5dBLaLRUBVonHeKrAaXqD6I9PesELYghI/Jt8D 28QsoCWxfudxJghbXmLzmrfMIKskBNQlHv3VBQmDHPBm7nZWiBIRiX0v3jFOYBSahWTSLCST ZiGZNAtJywJGllWMoqkFyQXFSem5hnrFibnFpXnpesn5uZsYwSH8TGoH48oGi0OMAhyMSjy8 hqUTA4RYE8uKK3MPMUpwMCuJ8D7uBgrxpiRWVqUW5ccXleakFh9ilOZgURLnbfZICRASSE8s Sc1OTS1ILYLJMnFwSjUwJgT1Sj8Sc2aW+tX4Un5/+2VL90nvhZwa1v4P/OXe/7J6b3nIJ9VX koeOpch91Ga3vJif9/KXdXD52y2hPy7NEFsnvX7KgmOvXiVwWf6Q/hjemsKw2Oz97m+7Fxyf 8G3Pk4Xs+3S3n0jaNmvffLvslh07p+4N67D4oxyos+EQg/LnR23s0fvMC5VYijMSDbWYi4oT AV6eflNdAgAA Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Sean Paul 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 --- Add 'From: Sean Paul ' 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 */