From patchwork Fri Mar 3 12:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9602641 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 1F77360453 for ; Fri, 3 Mar 2017 12:17:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F21423B23 for ; Fri, 3 Mar 2017 12:17:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 034B726530; Fri, 3 Mar 2017 12:17:03 +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=ham 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 7A2F127B13 for ; Fri, 3 Mar 2017 12:17:02 +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=SPLee/SVfW6uNoEnz7y9nEG1e87cl5PKp5wC8tt6ycE=; b=LkuUpGmnEXJ2xX nNtv14q3JM6N2p9cQ9dDc+p97zooqxF5wAy4GapjHxChUtiGgm/x8sZjgecTdlTYLmBQZ0XSkbt9q 9CI1XLe7UvgXdS89I4k4TzF+8yRvSeOywykucQTGEEXOOHq7i77t4AlvCOjJ+egt7gG1+5HFu2Qxt WilckQ2DL58zTJ9h39eGrgn01k83mmYfpIXJdP5lxcGPS39/NrE/DXoX9iIUF110m+I2MX+SF/k36 ZzZly/38I2Yr3PZKP8wapDGfcN16VLiU1aNFJkUhlA9FfGaxmZFDITQccxf4BSfhTWyHBErhkSyjF 96iqqnes2rHZ1iHZjJQg==; 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 1cjm8l-0002by-HC; Fri, 03 Mar 2017 12:16:55 +0000 Received: from galahad.ideasonboard.com ([2001:4b98:dc2:45:216:3eff:febb:480d]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjm8i-0002Wl-0F for linux-amlogic@lists.infradead.org; Fri, 03 Mar 2017 12:16:54 +0000 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 6D8C620033; Fri, 3 Mar 2017 13:15:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1488543326; bh=06KpPT1SU3C3TcpTlcdOPJhz0EYdqbW+j+aOn/ozMcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=obWeNwGXWlzs0eq0UrUp/eW2KzWQfNHSBx6LiBewf37zh2O417TdOXNFYXIl4h2tQ k4EAcl92n/7ZFRBAe51fvYl8+s4itCXQhWA3jK6UjOvwnIE/Qn1JNEK3FNOpZKV58o WBKxlTnqIf7plv/J5jHtPx3XOvHJnKuMleJhfpYM= From: Laurent Pinchart To: Jose Abreu Subject: Re: [PATCH v2 2/2] drm: bridge: Move HPD handling to PHY operations Date: Fri, 03 Mar 2017 14:16:58 +0200 Message-ID: <19854660.KZ12oiydRY@avalon> User-Agent: KMail/4.14.10 (Linux/4.9.6-gentoo-r1; KDE/4.14.28; x86_64; ; ) In-Reply-To: <67b8ac3e-3227-8f32-7f20-0cd4b6d4510f@synopsys.com> References: <1488468572-31971-1-git-send-email-narmstrong@baylibre.com> <952185cf-16b8-b987-4737-96c2db4a0f6c@baylibre.com> <67b8ac3e-3227-8f32-7f20-0cd4b6d4510f@synopsys.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_041652_373053_7436B7B5 X-CRM114-Status: GOOD ( 17.87 ) 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: laurent.pinchart+renesas@ideasonboard.com, Neil Armstrong , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, kieran.bingham@ideasonboard.com, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jose, On Friday 03 Mar 2017 10:05:36 Jose Abreu wrote: > On 03-03-2017 09:07, Neil Armstrong wrote: > > The problem is that the HPD/RxSense is tied to this phy_mask and glued > > into the dw-hdmi driver. > > > > The *real* solution would be to completely separate the HPD/RxSense irq > > handling to a separate driver as a shared irq... > > > > If Jose is willing to give me some documentation and Freescale some > > boards, I'll be happy to do it ! > > Hmm, why don't get rid of phy_mask totally and just return the > new mask in update_hpd() function? Or add a get_hpd_status() > callback. (I also think there are too many callbacks. For example > we could have: setup, set_status, clear and then just use > parameters when needed: > void setup(bool force, bool disabled, bool rxsense) > void set_status(bool enable, bool enable_ints) > void clear() > > What do you think? I only checked quickly the code, don't know if > this is enough. For the record, that's more or less what I had in mind. The following preparatory patch could be useful. commit 5ceb6a93d78e21e5be195efe52c4c7e5578ac787 Author: Laurent Pinchart Date: Fri Mar 3 14:14:56 2017 +0200 drm: bridge: dw-hdmi: Extract PHY interrupt setup to a function 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 diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 026a0dce7661..1ed8bc12eed7 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -1496,7 +1496,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) } /* Wait until we are registered to enable interrupts */ -static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi) +static void dw_hdmi_fb_registered(struct dw_hdmi *hdmi) { hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, HDMI_PHY_I2CM_INT_ADDR); @@ -1504,15 +1504,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) @@ -1630,6 +1621,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) { @@ -2141,29 +2152,14 @@ __dw_hdmi_probe(struct platform_device *pdev, 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_fb_registered(hdmi); + dw_hdmi_phy_setup_hpd(hdmi); memset(&pdevinfo, 0, sizeof(pdevinfo)); pdevinfo.parent = dev;