From patchwork Wed Sep 25 21:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 174424 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1192892ill; Wed, 25 Sep 2019 14:35:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDS1w+41kN1Yp/8snu659CBB4k63iM0t2bBqVVOZtvrsAvUSZZvYcAkWlPNCHxFUrWwfue X-Received: by 2002:a50:f0d4:: with SMTP id a20mr76831edm.149.1569447333137; Wed, 25 Sep 2019 14:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569447333; cv=none; d=google.com; s=arc-20160816; b=hNJAhxpHaQnCUr3SqUZtJZ7z5L95kS33n3Va56ewrKtzqiFCpe1nvnOSCsD8xUGLqF cqLR6/J+XoSs7zLSeRQTkqXfiRrn1RMOxO7jq3y4ONrQx2oi2pkDPLrxIFiIfdBmPBV9 Q4XKhwEenbruJtRJqp4jhkkPAaIsBimXlaIOT8eaYaa3ei4weP/vpwkhlwnM1qlMbYHL SLtPgSKQjbeRwHcsTQdx5I/LjSmzqThb08X49JRJquOzCY0K7HxbmF+7lVpZVxHYhOZL /csyJYPyeroFvXZBY+LF+bVY/LmwkJKl3sBNbZ5L5x9TCICzD9nM8Ii6FXCiaQurFzoO 0Djw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JrRNM0I4EavA4pv1P0nHERhiF9dPO/BTRC4agBUek+8=; b=fgsNCsXk/aFAdds01gH0OvLhrXcdH89XNWtb8XnVfi2f38HxzdA2DP8pBXy10DaqFZ ThgI0lg2GmNsasvOPl2//sEJKMW/nVK5mm9X9wkoBuV2BHE5nsH6Nz+QEcekgokQNErn gsRRT4Vjx4qylXVUlzJGwbPinzaebuqog3GuC1+cMcQNicENi3HiBxcnBUfUIpTk0wpm +Gg2YkIATmkq9RUDKpKvuO3yK5hTT+2Fw2Y+m6uSzrBe3jNiCMsLM2AXFS5Hc5fQBJO2 MpQzUVxGi/uhEpO03U7l0fK7YCR6eiXVvDMaK6cUOKZ1nbHYKk0ZAFzjmCu5R/rDPkaF aywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="h/y8cEL1"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si46361eju.265.2019.09.25.14.35.32; Wed, 25 Sep 2019 14:35:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="h/y8cEL1"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbfIYVfa (ORCPT + 11 others); Wed, 25 Sep 2019 17:35:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbfIYVfa (ORCPT ); Wed, 25 Sep 2019 17:35:30 -0400 Received: from localhost (c-71-197-186-152.hsd1.wa.comcast.net [71.197.186.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83E3A21D82; Wed, 25 Sep 2019 21:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569447329; bh=qm/TdfonbBzBB/AEHmYGEpSlc7ICBztPIwTfuRqbwv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/y8cEL15FyXJTSLNSZSc+k2fzrMcA62zUDP0csgm/5a/oHeq7hjHdO3+TE3RC6st W0uleeTy6Jz39AWP6uZQlF8WwahXXnzNjcv89jO03sDOcmtDn15/oUMF/iZWaTM+Gn F/uJ1kwkcR8hqxdOs6ZKMUQaCbUeagY49RY0o+Yo= From: Kevin Hilman To: linux-amlogic@lists.infradead.org, Neil Armstrong Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v2 2/2] soc: amlogic: ee-pwrc: ensure driver state maches HW state Date: Wed, 25 Sep 2019 14:35:28 -0700 Message-Id: <20190925213528.21515-3-khilman@kernel.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190925213528.21515-1-khilman@kernel.org> References: <20190925213528.21515-1-khilman@kernel.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Kevin Hilman During init, ensure that the driver on/off state as well as clock and reset state matches the hardware state. Do this by always calling the drivers 'on' function, and then callling the 'off' function if the HW state was initially detected as off. Signed-off-by: Kevin Hilman --- drivers/soc/amlogic/meson-ee-pwrc.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) -- 2.22.0 diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c index dcce8e694a07..2e8eee0dc166 100644 --- a/drivers/soc/amlogic/meson-ee-pwrc.c +++ b/drivers/soc/amlogic/meson-ee-pwrc.c @@ -323,6 +323,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, struct meson_ee_pwrc *pwrc, struct meson_ee_pwrc_domain *dom) { + bool is_off; + dom->pwrc = pwrc; dom->num_rstc = dom->desc.reset_names_count; dom->num_clks = dom->desc.clk_names_count; @@ -356,27 +358,12 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, dom->base.power_on = meson_ee_pwrc_on; dom->base.power_off = meson_ee_pwrc_off; - /* - * TOFIX: This is a special case for the VPU power domain, which can - * be enabled previously by the bootloader. In this case the VPU - * pipeline may be functional but no driver maybe never attach - * to this power domain, and if the domain is disabled it could - * cause system errors. This is why the pm_domain_always_on_gov - * is used here. - * For the same reason, the clocks should be enabled in case - * we need to power the domain off, otherwise the internal clocks - * prepare/enable counters won't be in sync. - */ - if (dom->num_clks && dom->desc.is_off && !dom->desc.is_off(dom)) { - int ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks); - if (ret) - return ret; - - pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false); - } else - pm_genpd_init(&dom->base, NULL, - (dom->desc.is_off ? - dom->desc.is_off(dom) : true)); + /* Ensure that driver state matches HW state */ + is_off = dom->desc.is_off ? dom->desc.is_off(dom) : true; + meson_ee_pwrc_on(&dom->base); + if (is_off) + meson_ee_pwrc_off(&dom->base); + pm_genpd_init(&dom->base, NULL, is_off); return 0; }