From patchwork Wed Aug 8 03:54:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 1292401 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 E96A2DF223 for ; Wed, 8 Aug 2012 03:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756477Ab2HHDyn (ORCPT ); Tue, 7 Aug 2012 23:54:43 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:48841 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756505Ab2HHDym (ORCPT ); Tue, 7 Aug 2012 23:54:42 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so760482pbb.19 for ; Tue, 07 Aug 2012 20:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=53DMj3FBQBE6RdWmJt+CEjQXDATfWfvLi1G/LQx+WEE=; b=b9EB4cLi+bMliJvVuG5vzp7kBSzmmolBEd86TpOYo6q8H2xbVNmDy93fipuFJDqICm RB853AXk3qWPsUinL49CYpN9AJyaYQfakDejBf6RDZZwHEnnMirgPmvnG/kw4l+osLJm cbP91LB/WsCnDkASjLVPIgGzXXYFeot/kU0rg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=53DMj3FBQBE6RdWmJt+CEjQXDATfWfvLi1G/LQx+WEE=; b=SWA32xa/QvSruIkJG3dPeSj0kzLLXUc3U0IY4py3DwaSTSn/o2F+f5SQNqFBv71f1q yvB5tFDU+nZfq0vTHHlL23WwRQPVTFoDe/oxeGwIU9BxuMzw3h/4jM99VMxtWQrWTx9v l9UQDL66TOWb7Q8JaCm7so7+Mj38YPPrrZoWPCzFKIELGBcR9rrDBvkdzPrrFErv/2e7 oK9Dxgg59O0xyKpz7QyzpW/NRrUWcdilZ3vp2voOrvxqw73aQG+9FoHvIxQoL7jCBUyA k4CFyvm2fSd+1FMekNDbWmG7QO25Z1bJZP9Sa2dKjnDK7l5tqjQiSE2KcksXNaeTM8UR oUNw== Received: by 10.68.222.167 with SMTP id qn7mr32761595pbc.98.1344398082397; Tue, 07 Aug 2012 20:54:42 -0700 (PDT) Received: from anush.mtv.corp.google.com (anush.mtv.corp.google.com [172.22.73.28]) by mx.google.com with ESMTPS id hx9sm12461756pbc.68.2012.08.07.20.54.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 20:54:41 -0700 (PDT) From: Sean Paul To: jg1.han@samsung.com, linux-fbdev@vger.kernel.org Cc: Sean Paul Subject: [PATCH 08/10] video: exynos_dp: Move hotplug into a workqueue Date: Tue, 7 Aug 2012 20:54:22 -0700 Message-Id: <1344398064-13563-9-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1344398064-13563-1-git-send-email-seanpaul@chromium.org> References: <1344398064-13563-1-git-send-email-seanpaul@chromium.org> X-Gm-Message-State: ALoCoQk36HuQJaQ9pJH+P+a8MxJVcKHYTg5wkFrvKaYKnPrGq1luIZMkqsH+RwwTsP0qa+XcWm1A 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 --- drivers/video/exynos/exynos_dp_core.c | 94 +++++++++++++++++---------------- drivers/video/exynos/exynos_dp_core.h | 1 + 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 2882362..68ad494 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -834,6 +834,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; @@ -886,6 +925,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev) goto err_clock; } + 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) { @@ -899,36 +940,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"); - goto err_clock; - } - - 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"); - goto err_clock; - } - - 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"); - goto err_clock; - } - platform_set_drvdata(pdev, dp); + schedule_work(&dp->hotplug_work); return 0; @@ -943,6 +956,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_sync(&dp->hotplug_work); + if (pdata && pdata->phy_exit) pdata->phy_exit(); @@ -959,6 +975,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_sync(&dp->hotplug_work); + if (pdata && pdata->phy_exit) pdata->phy_exit(); @@ -979,22 +998,7 @@ static int exynos_dp_resume(struct device *dev) clk_enable(dp->clock); 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 6431c65..cf1010b 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 */