From patchwork Tue Apr 4 12:31:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9661751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D309160352 for ; Tue, 4 Apr 2017 13:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B08D628494 for ; Tue, 4 Apr 2017 13:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A444E284BA; Tue, 4 Apr 2017 13:44:15 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 5485E28494 for ; Tue, 4 Apr 2017 13:44:15 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=MIWxB2YKCxwOLoWrAFM2OAEuPobi4ISEJll+ouPfHSs=; b=EYZr5UcujnwxUOeRlVYfQ6sFDi YFVY4g+j+bmokq3Kf8YEkyaZQK37luYEwQHYr/93Y86r1OpMGpxdnI+3LQjplIu3cPDHK5c2mSVwx nnxQtVytBQ2xDGdAK1x1+DLGnLxK46upsHTzVYz3QanXswx3suIzSIekW64Ru0GOknNIxfDTv+ndH tM3Xv+aUKo1kEa7H3/K5NHtXbyga3bgv7augXyfF6LK02v68k3LfT44dAzLhP1t3AuUm9+06b9jHX HgMA4MH8sCqaHDEPlrvbUgk2Ws2sw4kBT8FGFmJec0G54nX9Qlxqi90PZ/0hBtv7dSNHabPgIDan1 oQxfYEIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvOkg-0000LI-7W; Tue, 04 Apr 2017 13:44:06 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvOke-0000KT-DJ for linux-amlogic@bombadil.infradead.org; Tue, 04 Apr 2017 13:44:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z43qKndURXKF5VRvpzJrgkBoYWoEBFK8lQ5K4S9LJFY=; b=wM8eEG/WbKcLQNMoYskZKSWjP tecalIDsMbnm6f8fQK3iruDZtvwjXa4ivl24ggvutsQsPxwWPbpRVPSSDskOqootA5/9a24ke9UUk bUc1PXeJAKYGzOarmXy1HXPrZMZu/oq0Gv6DD3OazZWU6BwpFqhTNNohGWfYMjyRxwz4cVYU+B8aJ BIk/iMicGq0WDeU37mJueMNZx3wKd1Ae5sIPZz9YCwlQaabSFdL+JxWoYPqF13QMfZworBZZOIpdn 4j/dwozwXUwYNUnIdJSiUouW+vBwIW7wp62tT7eXOlTQQtEZz17NZ8K6CItzEi/DcuJmzr5ZvVMYM 17zHiTxOg==; Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvNdL-0003VQ-4T for linux-amlogic@lists.infradead.org; Tue, 04 Apr 2017 12:32:27 +0000 Received: by mail-wr0-x235.google.com with SMTP id t20so8402133wra.1 for ; Tue, 04 Apr 2017 05:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z43qKndURXKF5VRvpzJrgkBoYWoEBFK8lQ5K4S9LJFY=; b=iKecTFZHVq/lhcEnFY6U69V+GdX82E+hgLK+RbvPnbnaIFilXTuo+bSZplaQ337NB4 N7qDFfe1knlWTkKOE1t+oAyKPGQGwTph5Luf903fHsnhWFoYgaoEbRW5mu6nyED4fQhQ +1MLryN1MB0IpdFXRzNwUeVxXJJ/D3MRhB5s0MoHPJHBrhLe6/1tA9omvq0sPP9chgZx 38EvFs+Mw1j6yvSrT3SJ+f6WnTdXT2f7n5JzUW4c7oTaHkznFviaQwp7N1DHYRCGJjfF +3gnj39N5S2+dIDticCPKYINZsvcJhAq9FG7wJ5Ze7UFEBLDftta4d1gHmLgTZ9duQPf 4yQw== 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; bh=Z43qKndURXKF5VRvpzJrgkBoYWoEBFK8lQ5K4S9LJFY=; b=XLDn+OZ5Pl3Wtdq08NKTkrIbRqHWEtZTyCCaMj/uNvhWe9xqxb2LsPD9iwCXT/W/r2 uj8o7IYla8dzowgNOLnQF8CAp0YFZojqUMU7dgMOmN9R00Gj5LXz8BtRslMlumcd0QCB h78mYpvXc9v+Wyi6NTjvMaR4VKLl1kFarmcquGKrTXht4YVPZcNvf2JxGC0OP3jVxwxw QSKKZZ5LPdbFNVqkI0e53vQ4RPHQxuDj+Ckc9r2cMdY1blnGtSeEKxNyJEgDKo/fMW0d 72QBs7vU2bWrWgZC25OJmZZUqZzEqEbCq3I5nsSE13/mJbF7aZ6OYagtWjCE2neL8if8 jr8g== X-Gm-Message-State: AFeK/H1o98x1Y9En/NRtV2dTl3gMqoOU6HfCJMjy2jKZQ566fF4Dl03qqw/uL2GvP9HFyob3 X-Received: by 10.28.157.150 with SMTP id g144mr14682511wme.89.1491309124450; Tue, 04 Apr 2017 05:32:04 -0700 (PDT) Received: from zoidberg.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id h187sm18361855wma.32.2017.04.04.05.32.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Apr 2017 05:32:03 -0700 (PDT) From: Neil Armstrong To: dri-devel@lists.freedesktop.org, laurent.pinchart+renesas@ideasonboard.com, architt@codeaurora.org Subject: [PATCH v6.1 1/4] drm: bridge: dw-hdmi: Extract PHY interrupt setup to a function Date: Tue, 4 Apr 2017 14:31:56 +0200 Message-Id: <1491309119-24220-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491309119-24220-1-git-send-email-narmstrong@baylibre.com> References: <1491309119-24220-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170404_083227_299940_2D8601C4 X-CRM114-Status: GOOD ( 11.47 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jose.Abreu@synopsys.com, Neil Armstrong , kieran.bingham@ideasonboard.com, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Pinchart In preparation for adding PHY operations to handle RX SENSE and HPD, group all the PHY interrupt setup code in a single location and extract it to a separate function. Signed-off-by: Laurent Pinchart Reviewed-by: Jose Abreu [narmstrong: renamed dw_hdmi_fb_registered to dw_hdmi_setup_i2c] Reviewed-by: Archit Taneja Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 51 ++++++++++++++----------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 32f02e9..ff1fae3 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -1558,8 +1558,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) return 0; } -/* Wait until we are registered to enable interrupts */ -static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi) +static void dw_hdmi_setup_i2c(struct dw_hdmi *hdmi) { hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, HDMI_PHY_I2CM_INT_ADDR); @@ -1567,15 +1566,6 @@ static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi) hdmi_writeb(hdmi, HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL | HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_POL, HDMI_PHY_I2CM_CTLINT_ADDR); - - /* enable cable hot plug irq */ - hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); - - /* Clear Hotplug interrupts */ - hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, - HDMI_IH_PHY_STAT0); - - return 0; } static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi) @@ -1693,6 +1683,26 @@ static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi) hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); } +static void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi) +{ + /* + * Configure the PHY RX SENSE and HPD interrupts polarities and clear + * any pending interrupt. + */ + hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); + hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, + HDMI_IH_PHY_STAT0); + + /* Enable cable hot plug irq. */ + hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); + + /* Clear and unmute interrupts. */ + hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, + HDMI_IH_PHY_STAT0); + hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), + HDMI_IH_MUTE_PHY_STAT0); +} + static enum drm_connector_status dw_hdmi_connector_detect(struct drm_connector *connector, bool force) { @@ -2204,29 +2214,14 @@ static int dw_hdmi_detect_phy(struct dw_hdmi *hdmi) hdmi->ddc = NULL; } - /* - * Configure registers related to HDMI interrupt - * generation before registering IRQ. - */ - hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); - - /* Clear Hotplug interrupts */ - hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, - HDMI_IH_PHY_STAT0); - hdmi->bridge.driver_private = hdmi; hdmi->bridge.funcs = &dw_hdmi_bridge_funcs; #ifdef CONFIG_OF hdmi->bridge.of_node = pdev->dev.of_node; #endif - ret = dw_hdmi_fb_registered(hdmi); - if (ret) - goto err_iahb; - - /* Unmute interrupts */ - hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), - HDMI_IH_MUTE_PHY_STAT0); + dw_hdmi_setup_i2c(hdmi); + dw_hdmi_phy_setup_hpd(hdmi); memset(&pdevinfo, 0, sizeof(pdevinfo)); pdevinfo.parent = dev;