From patchwork Wed Sep 25 21:35:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 11161491 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A314D76 for ; Wed, 25 Sep 2019 21:36:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80F3620872 for ; Wed, 25 Sep 2019 21:36:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IP/uZm56"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="B7uNmOfQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80F3620872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=bs7qps+zeGTmLVt2J0KDjD2Wwe4bVDI8tMrGhKmxtW0=; b=IP/uZm56JmuoHM wjyaMDVLovRTaFWDpBEMFGasQrdzFKz6fnUxItebdTuEJhaiziViWf1E0ldKu9vAWv8TxLWuhaehf ue36IKDKYWFDK2O7sOZXgU/QjYHUZtbkTgZWyVeNX/7bCOAFJP9boP6drq17u7jg1f2qktFuGYu3t JUEr+I88HxqjM3c0h9UGW9+cODbe3tUrYmts4jNKYxYAO1Rq3waIQ6yWdLcm08hy4hFbNkvcDiqBc mN5PTOBoZXLsEe+XVhGe3iccOCxZFoZkm0K7B4gd8Mysa43PjmnliFRlGJymYgWp7oM6HwhHCvyMO hYiDFJpQDx0pEkrddV1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iDExD-0001Ee-T7; Wed, 25 Sep 2019 21:36:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iDEwb-0000Vr-FR; Wed, 25 Sep 2019 21:35:35 +0000 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 2898F21D81; 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=0ILfSUBG4uQytNVjbplPPbgoUcFq5ZroUW/hsHpzr7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7uNmOfQJzG9BVj1hi32RQ+3NG5ntnIPjAo0rmjUHFDYHoEg8hFGsz7dvgolaNCyr a2ztZZ3SPSih3NHMsKhKzu0YNFp4SO0G6JyGNGMK4kW7MIuhOOin08NShv2Mo5fpgj 7XizgPcxjox4OMHSOXPIL/uKzBs4ktLSaRv5T2Oo= From: Kevin Hilman To: linux-amlogic@lists.infradead.org, Neil Armstrong Subject: [PATCH v2 1/2] soc: amlogic: ee-pwrc: rename get_power Date: Wed, 25 Sep 2019 14:35:27 -0700 Message-Id: <20190925213528.21515-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190925_143532_645951_46D0F47C X-CRM114-Status: GOOD ( 11.19 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org From: Kevin Hilman The function named _get_power() is misleading since it returns true if the power is off. Rename to _is_off() for better readability. Signed-off-by: Kevin Hilman --- drivers/soc/amlogic/meson-ee-pwrc.c | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c index 5823f5b67d16..dcce8e694a07 100644 --- a/drivers/soc/amlogic/meson-ee-pwrc.c +++ b/drivers/soc/amlogic/meson-ee-pwrc.c @@ -56,7 +56,7 @@ struct meson_ee_pwrc_domain_desc { struct meson_ee_pwrc_top_domain *top_pd; unsigned int mem_pd_count; struct meson_ee_pwrc_mem_domain *mem_pd; - bool (*get_power)(struct meson_ee_pwrc_domain *pwrc_domain); + bool (*is_off)(struct meson_ee_pwrc_domain *pwrc_domain); }; struct meson_ee_pwrc_domain_data { @@ -173,7 +173,7 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = { { HHI_AUDIO_MEM_PD_REG0, GENMASK(27, 26) }, }; -#define VPU_PD(__name, __top_pd, __mem, __get_power, __resets, __clks) \ +#define VPU_PD(__name, __top_pd, __mem, __is_off, __resets, __clks) \ { \ .name = __name, \ .reset_names_count = __resets, \ @@ -181,40 +181,40 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = { .top_pd = __top_pd, \ .mem_pd_count = ARRAY_SIZE(__mem), \ .mem_pd = __mem, \ - .get_power = __get_power, \ + .is_off = __is_off, \ } -#define TOP_PD(__name, __top_pd, __mem, __get_power) \ +#define TOP_PD(__name, __top_pd, __mem, __is_off) \ { \ .name = __name, \ .top_pd = __top_pd, \ .mem_pd_count = ARRAY_SIZE(__mem), \ .mem_pd = __mem, \ - .get_power = __get_power, \ + .is_off = __is_off, \ } #define MEM_PD(__name, __mem) \ TOP_PD(__name, NULL, __mem, NULL) -static bool pwrc_ee_get_power(struct meson_ee_pwrc_domain *pwrc_domain); +static bool pwrc_ee_is_off(struct meson_ee_pwrc_domain *pwrc_domain); static struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = { [PWRC_G12A_VPU_ID] = VPU_PD("VPU", &g12a_pwrc_vpu, g12a_pwrc_mem_vpu, - pwrc_ee_get_power, 11, 2), + pwrc_ee_is_off, 11, 2), [PWRC_G12A_ETH_ID] = MEM_PD("ETH", g12a_pwrc_mem_eth), }; static struct meson_ee_pwrc_domain_desc sm1_pwrc_domains[] = { [PWRC_SM1_VPU_ID] = VPU_PD("VPU", &sm1_pwrc_vpu, sm1_pwrc_mem_vpu, - pwrc_ee_get_power, 11, 2), + pwrc_ee_is_off, 11, 2), [PWRC_SM1_NNA_ID] = TOP_PD("NNA", &sm1_pwrc_nna, sm1_pwrc_mem_nna, - pwrc_ee_get_power), + pwrc_ee_is_off), [PWRC_SM1_USB_ID] = TOP_PD("USB", &sm1_pwrc_usb, sm1_pwrc_mem_usb, - pwrc_ee_get_power), + pwrc_ee_is_off), [PWRC_SM1_PCIE_ID] = TOP_PD("PCI", &sm1_pwrc_pci, sm1_pwrc_mem_pcie, - pwrc_ee_get_power), + pwrc_ee_is_off), [PWRC_SM1_GE2D_ID] = TOP_PD("GE2D", &sm1_pwrc_ge2d, sm1_pwrc_mem_ge2d, - pwrc_ee_get_power), + pwrc_ee_is_off), [PWRC_SM1_AUDIO_ID] = MEM_PD("AUDIO", sm1_pwrc_mem_audio), [PWRC_SM1_ETH_ID] = MEM_PD("ETH", g12a_pwrc_mem_eth), }; @@ -237,7 +237,7 @@ struct meson_ee_pwrc { struct genpd_onecell_data xlate; }; -static bool pwrc_ee_get_power(struct meson_ee_pwrc_domain *pwrc_domain) +static bool pwrc_ee_is_off(struct meson_ee_pwrc_domain *pwrc_domain) { u32 reg; @@ -367,7 +367,7 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, * 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.get_power && !dom->desc.get_power(dom)) { + 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; @@ -375,8 +375,8 @@ static int meson_ee_pwrc_init_domain(struct platform_device *pdev, pm_genpd_init(&dom->base, &pm_domain_always_on_gov, false); } else pm_genpd_init(&dom->base, NULL, - (dom->desc.get_power ? - dom->desc.get_power(dom) : true)); + (dom->desc.is_off ? + dom->desc.is_off(dom) : true)); return 0; } @@ -454,7 +454,7 @@ static void meson_ee_pwrc_shutdown(struct platform_device *pdev) for (i = 0 ; i < pwrc->xlate.num_domains ; ++i) { struct meson_ee_pwrc_domain *dom = &pwrc->domains[i]; - if (dom->desc.get_power && !dom->desc.get_power(dom)) + if (dom->desc.is_off && !dom->desc.is_off(dom)) meson_ee_pwrc_off(&dom->base); } } 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: 11161473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B52B376 for ; Wed, 25 Sep 2019 21:35:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 933BF21D80 for ; Wed, 25 Sep 2019 21:35:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ew29mUdQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="h/y8cEL1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 933BF21D80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=qj6uLeZQwCuX2kZ9J9moMTPNV6hxp7q0lWgBMs/FmgM=; b=Ew29mUdQkKmcJV eoi4Y3oAoopaFZ/1+1OKKfk89/gMM73s9Ne6YW9OS6HE998dW+5aV+v3dG33TBDcqUC4nvDyFpT7l HgR3sKh4cOJcF9W/kEnf07f16YiCqzUQRHO7+aJfvi3LS/YyBr0dZe24dvZFUoIX7QthHp1Dr5+vd 0EjEmTMqY8/u/PzUfrsB3A9OmNrnGWWor2GtLfGs1e5EErppQU1ll127opTbo7yj979FOEMKenvTU o28p00Fo/av/ZjN6EvvnH/Ukkjx3bbTg0rTgI3PigqVV9NMsW2Bo0ZIp3NpTlIBPQwDCcZ1ct9aIV E1OrXQl0TIKqQ4JcNu3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iDEwi-0000YM-7H; Wed, 25 Sep 2019 21:35:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iDEwb-0000Vs-RT; Wed, 25 Sep 2019 21:35:33 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190925_143532_635045_C4379FE8 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.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(-) 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; }