Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp580809ybl; Wed, 28 Aug 2019 02:15:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwudn0+l2UB6wIPEApOjPT0wdvH6IE9lANbJuLRXKAqMTUWcNQrZ7nvVGL5ai6fyCW7UTqU X-Received: by 2002:a62:ab13:: with SMTP id p19mr3536290pff.20.1566983752997; Wed, 28 Aug 2019 02:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566983752; cv=none; d=google.com; s=arc-20160816; b=L8HCKqErCmKmivoKuF1rNHf88Ku/eONrnKVMmqvOQIWyf/xoUlSgdkTb0voOLZ7PXP 1mZnfvmeqBdyaQ7DJwevKgbmAuxEE9NNVmVvA3igud7Jc57TBobOjF2yvNjEQIy2w8wI L78PzpdzHFQy461NPjXtzTzZVDmo84xxHHcg2LMCBqqXeDAC0pQhfbE2j7ei4ScYlRW/ 1UXZxsaRfjpkiGWsqS2l6rzREZEvXFqvdY+32bZquzUqyVX8A5qCKzQtta/LpVr5fpKq mkcFPFFFrsuPRN4X2eCdblVux+5J4UxCkkpzjcREmtBOoQ+CbVsjVZqSTveFhVmxPZCs j+NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=C3pI3JBBgFlE/xa7LEajozk07dxriaX6H5rdCNHDQZQ=; b=cNMDT2vlvE5H2cyBe7tVs4pK17y9aoXwTAUUYrUdNYzWi8JgwUssObnLS3Wvl2HVWi H+Sz9IMGeFi2BM0fEzFatDysc6gRlUc8rW+rWEAw/NKQh+0KezOLp5+L9ue+hTvxhskg 5qucwAX9ytQaRkrz0DPrAKxyRNx6le8g9WkeSathvv6dgNLlsVLNH+M3R08Aq8Z0WlIA EudBDLDcxShDTxjZ/TFxnE7EbaLWmmgSmkd68KmdpeBw1Flv8ok1m4XUbsjYKG6Aw1wq ej+Tg0XKsYvuTOcj1CRwjjWBhjo3ayGhHww+PYekUp6PjgP12BVDid+R5Qp5hlZscvfO Jr1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si1923352pfn.94.2019.08.28.02.15.37; Wed, 28 Aug 2019 02:15:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfH1JNB (ORCPT + 99 others); Wed, 28 Aug 2019 05:13:01 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:25070 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726586AbfH1JMF (ORCPT ); Wed, 28 Aug 2019 05:12:05 -0400 X-UUID: 43435760c789432d9cf932b76ae369fb-20190828 X-UUID: 43435760c789432d9cf932b76ae369fb-20190828 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 115752348; Wed, 28 Aug 2019 17:11:59 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 28 Aug 2019 17:12:05 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 28 Aug 2019 17:12:04 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Rob Herring CC: James Liao , Fan Chen , , , , , Weiyi Lu , Yong Wu Subject: [PATCH v7 07/13] soc: mediatek: Refactor bus protection control Date: Wed, 28 Aug 2019 17:11:40 +0800 Message-ID: <1566983506-26598-8-git-send-email-weiyi.lu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1566983506-26598-1-git-send-email-weiyi.lu@mediatek.com> References: <1566983506-26598-1-git-send-email-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: CECD0B24204F4528E02BAC5A3B092088CD14B0F68055E3EE39B9525D0F003D092000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Put bus protection enable and disable control in separate functions. Signed-off-by: Weiyi Lu --- drivers/soc/mediatek/mtk-scpsys.c | 44 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index ad0f619..fb2b027 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -274,6 +274,30 @@ static int scpsys_sram_disable(struct scp_domain *scpd, void __iomem *ctl_addr) MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); } +static int scpsys_bus_protect_enable(struct scp_domain *scpd) +{ + struct scp *scp = scpd->scp; + + if (!scpd->data->bus_prot_mask) + return 0; + + return mtk_infracfg_set_bus_protection(scp->infracfg, + scpd->data->bus_prot_mask, + scp->bus_prot_reg_update); +} + +static int scpsys_bus_protect_disable(struct scp_domain *scpd) +{ + struct scp *scp = scpd->scp; + + if (!scpd->data->bus_prot_mask) + return 0; + + return mtk_infracfg_clear_bus_protection(scp->infracfg, + scpd->data->bus_prot_mask, + scp->bus_prot_reg_update); +} + static int scpsys_power_on(struct generic_pm_domain *genpd) { struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); @@ -316,13 +340,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) if (ret < 0) goto err_pwr_ack; - if (scpd->data->bus_prot_mask) { - ret = mtk_infracfg_clear_bus_protection(scp->infracfg, - scpd->data->bus_prot_mask, - scp->bus_prot_reg_update); - if (ret) - goto err_pwr_ack; - } + ret = scpsys_bus_protect_disable(scpd); + if (ret < 0) + goto err_pwr_ack; return 0; @@ -344,13 +364,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) u32 val; int ret, tmp; - if (scpd->data->bus_prot_mask) { - ret = mtk_infracfg_set_bus_protection(scp->infracfg, - scpd->data->bus_prot_mask, - scp->bus_prot_reg_update); - if (ret) - goto out; - } + ret = scpsys_bus_protect_enable(scpd); + if (ret < 0) + goto out; ret = scpsys_sram_disable(scpd, ctl_addr); if (ret < 0) -- 1.8.1.1.dirty