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: 10040637 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 5306060384 for ; Fri, 3 Nov 2017 15:43:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA1EE296F6 for ; Fri, 3 Nov 2017 15:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEEA529739; Fri, 3 Nov 2017 15:43:33 +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=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F833296F6 for ; Fri, 3 Nov 2017 15:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754754AbdKCPnc (ORCPT ); Fri, 3 Nov 2017 11:43:32 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46965 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752968AbdKCPnb (ORCPT ); Fri, 3 Nov 2017 11:43:31 -0400 Received: by mail-wr0-f194.google.com with SMTP id l1so2886918wrc.3 for ; Fri, 03 Nov 2017 08:43:30 -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=YY9b4MwyjUcTpqdJva0TX/ZZoZDJse1IzvinGZR0Qsd20Vib1472aELLkdWl3TDBEr KCvUAM/ncukQePQdpQULrXuXie6MFszlSi9uqffRZ8WlItDrFN8AxNIiAbsiSvgCUQ7V o+eYzQA6SqjKnJRfwIc3KV0stI1YiuRnqTXan4iSQOVFPU9ViicPfBeOokBaD82Pw7N3 b5LMpDPMHTdkwOjL5IMz6FvFGL0fMhMVdYDZFgC+1Gi+ucuGS4XQkCvMYwG1JXqiVJeK NyIgC/d6eTtjqBX5cdAvIRIvwwAEvdMBtGROQYPeWOWwot4dYcND4aPub+EeNnl+MzTK gb9g== X-Gm-Message-State: AMCzsaWsdCz98EKkL+X1mKhUx3FyVSnxnhxHDVhvVTLZDc3DOdr0gXPZ ADC2Cjo4XvK+Ce1b6pLoaU+6yg== 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 Cc: Neil Armstrong , linux-pm@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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[] = {