Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1142551img; Tue, 19 Mar 2019 01:03:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZaagPmY/oo8OvsuJLOsk8l1e9rQI8e9C3EAQSsbLiiNHIopvTh7Eba2eKuR4Y/T6k3Pcw X-Received: by 2002:a65:508b:: with SMTP id r11mr616249pgp.242.1552982586129; Tue, 19 Mar 2019 01:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552982586; cv=none; d=google.com; s=arc-20160816; b=xNnjsZvYRFKFT3vJmsDPcGQrC0dPVtg85s6Xjh04rc+w5ODTuCGy9uIkFMwY4C33jZ 0ghWnFJwGJXq3P5R2eBdK1yzj/BFjMaoy0X7pqpbUqtCqYy0YDQrxAyDHL5edX6fM3LJ P0KbaPzK1vP5FblFPhbLUKrFz4ESKNzdczJ78+DH88sIr2MU4Ihxx63dsBQlJLw9nk8N I6TmsxnnB7A2fFSRc4pVnk9gLytWpORo1F+jqnFA6Zi5LT7ZajbBVyLNHrs7g1yXVqlC SvKRg8qi0Py/vD6r9BfFCSgFXQgWdQOuRS3jttsaULS8IagzN6TZSsEcVWMvE/e3LAps LhwA== 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=BsahIAKSvu4+Jw2Z/M4h9uJpSHeyZ3yrCyrY+MRSONU=; b=oCi+0B9PlwCCq9CfHk5El+AceVe0Rn22kCb4cxg874zYX78F9PgqOTo1kg5Tg8Zdeq fcqNGkPXQ0sKO+mcUgn5d/Y/jX4vxiMDu7rIAIRKxI+6jiJ0K3TLxv2VIuD7XGPWujnq XK3vmq/yig9g38k3iovFj8MdbtUCX4VvUq6lkBi0VSCgmq3M8fPPLHBEJCi+apoB5cco MRqFstEk/5v/Mr1zUHLkfH+7phbTWfPDGEUiZOqYMyHVXGabsp2PGQ8Soqgoq9+f+PRi vIJ2AHb4sXYrJ6/2EiBFbZYkPrGcFDg/mBwcnzSpdH+7KvraNQjStLokjVjCVaCDbo81 usoA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si10911476pgf.247.2019.03.19.01.02.50; Tue, 19 Mar 2019 01:03:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727463AbfCSICM (ORCPT + 99 others); Tue, 19 Mar 2019 04:02:12 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:26558 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727359AbfCSICI (ORCPT ); Tue, 19 Mar 2019 04:02:08 -0400 X-UUID: d455e296b7c545218c3041a215895bb3-20190319 X-UUID: d455e296b7c545218c3041a215895bb3-20190319 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2035059390; Tue, 19 Mar 2019 16:01: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; Tue, 19 Mar 2019 16:01:57 +0800 Received: from mtkslt210.mediatek.inc (10.21.14.14) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 19 Mar 2019 16:01:57 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Rob Herring CC: James Liao , Fan Chen , , , , , Weiyi Lu Subject: [PATCH v5 08/14] soc: mediatek: Refactor bus protection control Date: Tue, 19 Mar 2019 16:01:34 +0800 Message-ID: <20190319080140.24055-9-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190319080140.24055-1-weiyi.lu@mediatek.com> References: <20190319080140.24055-1-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 7452B14D2C8EAE5A2D00E5AAF9E1BC76113EB804BDB93A28DFE115EE7D9EEA482000: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 | 48 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 65b734b40098..6bf846cb1893 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -279,6 +279,34 @@ 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; + int ret = 0; + + if (scpd->data->bus_prot_mask) { + ret = mtk_infracfg_set_bus_protection(scp->infracfg, + scpd->data->bus_prot_mask, + scp->bus_prot_reg_update); + } + + return ret; +} + +static int scpsys_bus_protect_disable(struct scp_domain *scpd) +{ + struct scp *scp = scpd->scp; + int ret = 0; + + if (scpd->data->bus_prot_mask) { + ret = mtk_infracfg_clear_bus_protection(scp->infracfg, + scpd->data->bus_prot_mask, + scp->bus_prot_reg_update); + } + + return ret; +} + static int scpsys_power_on(struct generic_pm_domain *genpd) { struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); @@ -321,13 +349,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; @@ -349,13 +373,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) -- 2.18.0