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: 10040643 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 03B7D60384 for ; Fri, 3 Nov 2017 15:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E88742971C for ; Fri, 3 Nov 2017 15:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD6292973A; Fri, 3 Nov 2017 15:44:34 +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 8BEF42971C for ; Fri, 3 Nov 2017 15:44:34 +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=5QRt9NAuqsVZv1YBAli6Bp6QTGi8ecZSHLuQvjVot4Q=; b=GE5 m5iNbUFmFREe+dQW5dcs97+sg5mcmwkbcCn2177WqiNAYEvnxjujHTk2WAc5vnXeIjg0W+RY7myHL 21RvnhdBCA7DWLFc/vS5aqadA9GpKNSQdsxoZ6xuSTC2Eji8zQZOAh3OwKMXX3ksAJVz5SNEVyNnA aFlhvieO/fpMOUp/5YnSb6+FxH4rIMr3fEz4rS1f8Y6v9xXPp63OV4kapbLAayECmcTJljDYOH/rx OjrM1QVUDiBZCthDXObdj+EaJKBxoxPK7YeaOjpvjlQPij7x87PzQH40CuPW25jDvrBrYHxt6qBqW WDKbOqafQJtIQt7Jy23JA8G78z4n0AQ==; 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 1eAe8j-0006hB-Oo; Fri, 03 Nov 2017 15:44:13 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eAe8O-00067p-Bd for linux-amlogic@lists.infradead.org; Fri, 03 Nov 2017 15:43:55 +0000 Received: by mail-wr0-x241.google.com with SMTP id y39so2888236wrd.4 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=kh5tFH6By96VMRLCTvN9fzbzpkLL3FntvGvLsL/KaaYE07JvYsyV72WRl4r4RhUSNm /PJVIhRn3KgDf1OO1+k13wDdOkFcxPkJOG47g+2WknAC0HNgC5JChp5MkDEuXEFpTtZZ uLhbRBjjDrbDlr6sz32yhp0/IZxtxvGHvr5FSyu+LkaVb0LCF9TWWPWJQXL5F2KHUC87 hpLir35TglCmlhP3rVptvBw6tLj/w6wRFJdrOG66lONc1kEVo6L7i22BGAI/2PDMBw+8 nsl0HetilvwoW7x84BqoKzDk0FEj6WvyhISKYtMq0GQL6MGbaqg9CXz4tVQEhXHuSP+l TUDA== X-Gm-Message-State: AMCzsaXutFwqCcXCCZoyRjaSRjyDMQl0oq+HrII/aimv8G0+ejX0LpfH 2EseHwwOnLyto5VZ3cPD3gPpUg== 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_581457_B5EC74DF X-CRM114-Status: GOOD ( 13.43 ) 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: 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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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[] = {