From patchwork Fri Nov 3 15:43:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10040641 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 1081A60384 for ; Fri, 3 Nov 2017 15:43:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3CDF29733 for ; Fri, 3 Nov 2017 15:43:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E74AB2973C; Fri, 3 Nov 2017 15:43:58 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 D6E4629733 for ; Fri, 3 Nov 2017 15:43:57 +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: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=33+EtTR6ep2WjoQO2xBOb+4cN7V1E/O5lKsebNgt/qA=; b=rFV jlTGariDC005Guo1DHocknO5A8ytOzu0OGHXh/ERrvCqIox6x2u0tLcrqlhAcGP7TeOSqZbhb+51l Bu0n2VP0iNfT5GU0jrLCaVlIhQ+5hI9xTMby543v2YPvDAHYLueDE2j6XRmrzYBvhP7Ux5M/k0Suy dF46Ik2zQdSG+aR7IctBMZZ8FJ/ezPGLZt1Kv0Vgerwo0DomObhRJJuMv0AdhU2JA/N/ZgTXfbejb lIYnlxJo8CVWrmUuPbk3B+Oys1RSenTch4Ux1YTltw0CGdaD1pc1g0hW0aN7kG7UqWbOzmeBWhMWt BQShoXbSO4dlCTuPVKswUR3N9Tf2oXQ==; 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 1eAe8T-0006Qr-1r; Fri, 03 Nov 2017 15:43:57 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eAe8O-00067q-Bd for linux-arm-kernel@lists.infradead.org; Fri, 03 Nov 2017 15:43:55 +0000 Received: by mail-wr0-x243.google.com with SMTP id u40so2855686wrf.10 for ; Fri, 03 Nov 2017 08:43:31 -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; bh=is80e3MsLjFSRQb3YC1gcvPWSbxy4knq7iyNNa5lowc=; b=A3PqW1oyij9u5fWcDKa+n59Pgyz9iEzChbLkHIHcZvLEThw7bN21Wn3H//qM8UwJNn 10/2nCMJSgkBTO1qlX2c5oOUaVPnUM2afNj+RW84JjfegxnD4uaoNq5mtOW6Wc8/yPhY jT7q0oFESpzZJVtUuvB+VAxdlwqitl65yYZpN90lMgTtbM6mLgCEusEXvUDE04huua6N Eb0PAgSsVZM1zPDAsqyKhT86OSVXofChlmYyFtSPi5MZYUSBzzLEg2y1ucUzHHQ6k7+O j238bkD/h2cSwXSbAMQJfcMB+7Z7hAqOklGfDzazeRJ3Q7O3Y+DeRWpFDG+GGwurAWvq DIMg== 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; bh=is80e3MsLjFSRQb3YC1gcvPWSbxy4knq7iyNNa5lowc=; b=IHnh+S6V6IU0o8VNdZUBWOewuO4ZtjWveiwRj6YrCVt8XfPPUNX1+PvEsW8EVpNe4Z eUU/I6MiW93PiQdDwXQQ6H5LtWO3pLKfNsErWxb7o31wi9xq7G6zMEdOVgluSKBfbP7W Eau9mwBmhx3UUdXA+6h4+Qg1PxGUhG0C8WsaiFPFrDRWLhKQ9Q7QjLjX9/b4KNtBaBs6 WjF8b/cu0SEZGr5AayIiqdCY9gxMIV05opE68slnsFFdy/bmrS3X4dlJvjh0jaQUn1lw As9fqTAXyBLWpG9FXaOxFuBYRtTmrqgRxJVd6CYo7NsNq7SsP11AMnPP6C325AeSFYX4 3qIQ== X-Gm-Message-State: AMCzsaW/xrY9Vlh/XGZwc6FLxScP3VaeAaqLaMRyECuDwmx1r3vaj9BV LqMqkiovmD1WzGpG0XHpElVGVA== X-Google-Smtp-Source: ABhQp+TdZOKmM720xuAb4epnXwu4yNfNLf5Goe+t0mXWxiqz+m2H4dqgeCLZn3yvotICKdlbDw+epA== X-Received: by 10.223.183.13 with SMTP id l13mr6710990wre.1.1509723809909; Fri, 03 Nov 2017 08:43:29 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id q3sm4248144wrd.78.2017.11.03.08.43.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Nov 2017 08:43:29 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com, carlo@caione.org Subject: [PATCH] soc: amlogic: meson-gx-pwrc-vpu: fix power-off when powered by bootloader Date: Fri, 3 Nov 2017 16:43:24 +0100 Message-Id: <1509723804-21114-1-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171103_084352_579294_4989783F X-CRM114-Status: GOOD ( 14.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In the case the VPU power domain has been powered on by the bootloader and no driver are attached to this power domain, the genpd will power it off after a certain amount of time, but the clocks hasn't been enabled by the kernel itself and the power-off will trigger some faults. This patch enable the clocks to have a coherent state for an eventual poweroff and switches to the pm_domain_always_on_gov governor. Fixes: 75fcb5ca4b46 ("soc: amlogic: add Meson GX VPU Domains driver") Signed-off-by: Neil Armstrong Tested-by: Kevin Hilman --- drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c index bf5190b..2bdeebc 100644 --- a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c +++ b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c @@ -34,7 +34,6 @@ struct meson_gx_pwrc_vpu { struct reset_control *rstc; struct clk *vpu_clk; struct clk *vapb_clk; - bool powered; }; static inline @@ -78,8 +77,6 @@ static int meson_gx_pwrc_vpu_power_off(struct generic_pm_domain *genpd) clk_disable_unprepare(pd->vpu_clk); clk_disable_unprepare(pd->vapb_clk); - pd->powered = false; - return 0; } @@ -91,7 +88,11 @@ static int meson_gx_pwrc_vpu_setup_clk(struct meson_gx_pwrc_vpu *pd) if (ret) return ret; - return clk_prepare_enable(pd->vapb_clk); + ret = clk_prepare_enable(pd->vapb_clk); + if (ret) + clk_disable_unprepare(pd->vpu_clk); + + return ret; } static int meson_gx_pwrc_vpu_power_on(struct generic_pm_domain *genpd) @@ -139,8 +140,6 @@ static int meson_gx_pwrc_vpu_power_on(struct generic_pm_domain *genpd) if (ret) return ret; - pd->powered = true; - return 0; } @@ -167,6 +166,8 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev) struct reset_control *rstc; struct clk *vpu_clk; struct clk *vapb_clk; + bool powered_off; + int ret; regmap_ao = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node)); if (IS_ERR(regmap_ao)) { @@ -205,8 +206,17 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev) vpu_hdmi_pd.vpu_clk = vpu_clk; vpu_hdmi_pd.vapb_clk = vapb_clk; - pm_genpd_init(&vpu_hdmi_pd.genpd, &simple_qos_governor, - meson_gx_pwrc_vpu_get_power(&vpu_hdmi_pd)); + powered_off = meson_gx_pwrc_vpu_get_power(&vpu_hdmi_pd); + + /* If already powered, sync the clock states */ + if (!powered_off) { + ret = meson_gx_pwrc_vpu_setup_clk(&vpu_hdmi_pd); + if (ret) + return ret; + } + + pm_genpd_init(&vpu_hdmi_pd.genpd, &pm_domain_always_on_gov, + powered_off); return of_genpd_add_provider_simple(pdev->dev.of_node, &vpu_hdmi_pd.genpd); @@ -214,8 +224,7 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev) static void meson_gx_pwrc_vpu_shutdown(struct platform_device *pdev) { - if (vpu_hdmi_pd.powered) - meson_gx_pwrc_vpu_power_off(&vpu_hdmi_pd.genpd); + meson_gx_pwrc_vpu_power_off(&vpu_hdmi_pd.genpd); } static const struct of_device_id meson_gx_pwrc_vpu_match_table[] = {