From patchwork Thu May 2 22:38:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10927703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C0DC1395 for ; Thu, 2 May 2019 22:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 595531FF83 for ; Thu, 2 May 2019 22:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CD822640A; Thu, 2 May 2019 22:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF4071FF83 for ; Thu, 2 May 2019 22:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2pN+Z1uglEfvohqyOBDlVm4Rb1A59h1K9imGIkUaeU8=; b=aDac3q73pUwikk D8LWnaaIMCXZmzaK8JoUm/lbDZDCb2S9dgoPG0Ul0YBv4vG5PIAzi2vcRK3bqQLvTmIe4OF4RyPsv GBzX/04LdlOadQYSZVtai1bxPsdnk4rI9GrgLTdgJjrMiAYw6QEdQXSOEwfiNeQVeB0mcEjdFI4ph 8iesyzmI2SdBW7wvS7ZcBnO88q7/JaFc9CbD+s/hejvbL1cYB/e9Ldnqd4yn5/4Wx4lnppMBsbHY+ hipPdV6UuRwSCGjqyTlJ+hIsO6aCvUefBU7InM+0BypZ1+axQMYhwY5SVRyGmb2l+pmUPrEsmzgn4 UocvU+7PRa1ALZ7kbj/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hMKLc-0007i8-1n; Thu, 02 May 2019 22:38:36 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hMKLY-0007gt-5l for linux-rockchip@lists.infradead.org; Thu, 02 May 2019 22:38:33 +0000 Received: by mail-pf1-x443.google.com with SMTP id t87so1261197pfa.2 for ; Thu, 02 May 2019 15:38:31 -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:mime-version :content-transfer-encoding; bh=oGCfMQkKfqkKFZ8erX0b7VyU7ofDCnx2g9X0TKrb/HA=; b=DJKuaiHXmnpN5NHgJx3Ha85ILyIu0e1kfwt5qnKUaJz9o3ZLF8arJytmHtO7FqiFBV MBWtO7EXORv02Y2abZgYE36pxCrS+zMp4GRVryBr0oj3TWALLhx8FtS6V3FpEWfVdzdW 96PKjpxXBqXPpYBCEru2M2NeyILoFnAEQplI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oGCfMQkKfqkKFZ8erX0b7VyU7ofDCnx2g9X0TKrb/HA=; b=lvccxHGVvSgaTdiXRt9Ij0nDMnyygTz44Gk/1RIxHVE+0oeKA/+H6pmIR/TFmluqBk sXwknjN6D6fO4RaFci89SdlbipoBsuPVbEvT0y6aGt4bZKVGmjaBWNorntFcxk56xwAG JKwtWkOrLyWjz/GqdofSIXWcl43aSeBj13TiEwlo0sHhZ2OG6MT4Te1GV4X01dnpSO6k mUXnmynEzRKy9+zRnFPfcmJcSuLHQZUITfqhyHupLQe1sKcS0ziteYH9KWgYnpTtJx/N Is5OIRjMtB0139N8jJiT3ddSMriKfOLZyT0MjN9xQjUfhs48bu0/oxrWKc1EXvWIu/e0 fN3A== X-Gm-Message-State: APjAAAUArQRhjzkVakw83PVelX0eLAW0dUuOveoOVuqd2wzxQbNo5hgh c4CvbmR/AoMeabcboJozkT/lKw== X-Google-Smtp-Source: APXvYqzegNUKwWVFGK5+OSJGRGvk9lnvVlziVA8BSgZO2xFC57BLteuXPc+lxQ5gyK9oIUqE+P1Q3g== X-Received: by 2002:a63:cd15:: with SMTP id i21mr6626004pgg.269.1556836711151; Thu, 02 May 2019 15:38:31 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id k186sm244151pfc.137.2019.05.02.15.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 15:38:30 -0700 (PDT) From: Douglas Anderson To: Heiko Stuebner , Sandy Huang , Andrzej Hajda , Laurent Pinchart Subject: [PATCH 1/2] drm: bridge: dw-hdmi: Add hooks for suspend/resume Date: Thu, 2 May 2019 15:38:07 -0700 Message-Id: <20190502223808.185180-1-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190502_153832_244749_D8F96D22 X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , Neil Armstrong , David Airlie , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, mka@chromium.org, Sean Paul , Daniel Vetter , Sam Ravnborg , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Zheng Yang Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Rockchip rk3288-based Chromebooks when you do a suspend/resume cycle: 1. You lose the ability to detect an HDMI device being plugged in. 2. If you're using the i2c bus built in to dw_hdmi then it stops working. Let's add a hook to the core dw-hdmi driver so that we can call it in dw_hdmi-rockchip in the next commit. NOTE: the exact set of steps I've done here in resume come from looking at the normal dw_hdmi init sequence in upstream Linux plus the sequence that we did in downstream Chrome OS 3.14. Testing show that it seems to work, but if an extra step is needed or something here is not needed we could improve it. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 +++++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index db761329a1e3..4b38bfd43e59 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2780,6 +2780,27 @@ void dw_hdmi_unbind(struct dw_hdmi *hdmi) } EXPORT_SYMBOL_GPL(dw_hdmi_unbind); +int dw_hdmi_suspend(struct dw_hdmi *hdmi) +{ + return 0; +} +EXPORT_SYMBOL_GPL(dw_hdmi_suspend); + +int dw_hdmi_resume(struct dw_hdmi *hdmi) +{ + initialize_hdmi_ih_mutes(hdmi); + + dw_hdmi_setup_i2c(hdmi); + if (hdmi->i2c) + dw_hdmi_i2c_init(hdmi); + + if (hdmi->phy.ops->setup_hpd) + hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data); + + return 0; +} +EXPORT_SYMBOL_GPL(dw_hdmi_resume); + MODULE_AUTHOR("Sascha Hauer "); MODULE_AUTHOR("Andy Yan "); MODULE_AUTHOR("Yakir Yang "); diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 66e70770cce5..c4132e9a5ae3 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -154,6 +154,9 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder, const struct dw_hdmi_plat_data *plat_data); +int dw_hdmi_suspend(struct dw_hdmi *hdmi); +int dw_hdmi_resume(struct dw_hdmi *hdmi); + void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense); void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate); From patchwork Thu May 2 22:38:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10927707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F216912 for ; Thu, 2 May 2019 22:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A7A31FF83 for ; Thu, 2 May 2019 22:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E2C92640A; Thu, 2 May 2019 22:38:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EB0701FF83 for ; Thu, 2 May 2019 22:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3vcUOFJUrQwW8rOVbIDOXzIol9bntRF2ZGmd8m46xxk=; b=l1G6vZkyhdNFj3 tmDJRJYB4BX3Jh2RyoAU8gHdcphgWsxyw5XniuQTynwQ9eovgjMQX9Giu9q2WXFlZmZfXmc/7VYt8 AfG0rCDOoylFHzbf+teqNm0gDa924pMbD+j2PVCHHlzMYZefNblGd/OfYkFBvh8XG3ZOi8eCULpdd ZbUUe8DCE7PaFJLOflA425en1D5NK9WbOgbwnZtSs49bdCpwVQFmPr7jOvyEOletn/bIoUabGmwlX 6zlH62XExTc7+E6eOuPoPkRZj8cfXTzPk/wOAsg3ZfhsZl9SNbIfI+i3YcVLr1zR2w2a2E1aY5oND VD3ZdY2mqqJssPSbAfeQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hMKLh-0007oj-2k; Thu, 02 May 2019 22:38:41 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hMKLZ-0007h9-3X for linux-rockchip@lists.infradead.org; Thu, 02 May 2019 22:38:34 +0000 Received: by mail-pf1-x444.google.com with SMTP id v80so1844714pfa.3 for ; Thu, 02 May 2019 15:38:32 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=gBFW9ct9L9kxaMD7soK1MmMiGB02h+kun9/xHdLdz90=; b=T2KhVqVdwh/tHXA/wuJoYTbXZFKGkASbAuQ7K5ZNHDkBqe7WFxueRi4ZQzm45gLf4R Eprg1hoU+uGGZPCaZsQ10mK8879RYaj1HzX7E6Gkx+D50IZ2JbFyfHeg0wUOiVob+Vuq GJ/ylfxE9UI2yU1NYWDMzrpIvzCZQxrMahzGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gBFW9ct9L9kxaMD7soK1MmMiGB02h+kun9/xHdLdz90=; b=pgCohh7CQQ+tXJTDNuW/Pj6FgaLFnEPDGQFeQQ3Uw7+jFVMO2AYf5UA2mW8exWDa7t mWIr0AyRtIcbTHtJa1lz8X34WZDODprnnJz6qh40T+pi9XzifqxeUaQl9b9CbldMceHi TmJNNQ9VlO4PLlN+OfRkcdGmOGo33D7b9Ut0oaQYgdC5LEi6Yx/YLDV8+du1nxc8Hf9X 7NYMlRIUEPkNLnKF242ZhAbr8x2i2I9CPw1epVYp34R/OD3NrjbvbQ6BBxVY2GDQBnov MbD4fMoPy220Lxf6N0vNKvcElHVOeywhEOXcuaqM1aS/5r77P+NaSJOtwj1oblgVQ850 eozA== X-Gm-Message-State: APjAAAX7/EThioY0vtt1epQFYDlLOsDt/EnwgPVLH2ppdjdY4HifLSEh LDXIx4SZnH31LkithhpNyi50gw== X-Google-Smtp-Source: APXvYqzq5JvWDWnU2WBxay5i7m7nGGZ4xrgcUbqlp6Nq6J2U3j8kQ26AAp/Vh8DDfS/M+iUafD66nQ== X-Received: by 2002:a63:9dc8:: with SMTP id i191mr6416756pgd.91.1556836712382; Thu, 02 May 2019 15:38:32 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id k186sm244151pfc.137.2019.05.02.15.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 15:38:31 -0700 (PDT) From: Douglas Anderson To: Heiko Stuebner , Sandy Huang , Andrzej Hajda , Laurent Pinchart Subject: [PATCH 2/2] drm/rockchip: dw_hdmi: Handle suspend/resume Date: Thu, 2 May 2019 15:38:08 -0700 Message-Id: <20190502223808.185180-2-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190502223808.185180-1-dianders@chromium.org> References: <20190502223808.185180-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190502_153833_143198_FFD2F78C X-CRM114-Status: GOOD ( 10.52 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , David Airlie , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, mka@chromium.org, Sean Paul , Daniel Vetter , linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Rockchip rk3288-based Chromebooks when you do a suspend/resume cycle: 1. You lose the ability to detect an HDMI device being plugged in. 2. If you're using the i2c bus built in to dw_hdmi then it stops working. Let's call the core dw-hdmi's suspend/resume functions to restore things. NOTE: in downstream Chrome OS (based on kernel 3.14) we used the "late/early" versions of suspend/resume because we found that the VOP was sometimes resuming before dw_hdmi and then calling into us before we were fully resumed. For now I have gone back to the normal suspend/resume because I can't reproduce the problems. Signed-off-by: Douglas Anderson Reviewed-by: Heiko Stuebner Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index 4cdc9f86c2e5..deb0e8c30c03 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -542,11 +542,31 @@ static int dw_hdmi_rockchip_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused dw_hdmi_rockchip_suspend(struct device *dev) +{ + struct rockchip_hdmi *hdmi = dev_get_drvdata(dev); + + return dw_hdmi_suspend(hdmi->hdmi); +} + +static int __maybe_unused dw_hdmi_rockchip_resume(struct device *dev) +{ + struct rockchip_hdmi *hdmi = dev_get_drvdata(dev); + + return dw_hdmi_resume(hdmi->hdmi); +} + +const struct dev_pm_ops dw_hdmi_rockchip_pm = { + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_rockchip_suspend, + dw_hdmi_rockchip_resume) +}; + struct platform_driver dw_hdmi_rockchip_pltfm_driver = { .probe = dw_hdmi_rockchip_probe, .remove = dw_hdmi_rockchip_remove, .driver = { .name = "dwhdmi-rockchip", + .pm = &dw_hdmi_rockchip_pm, .of_match_table = dw_hdmi_rockchip_dt_ids, }, };