Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1378829ybi; Wed, 19 Jun 2019 19:40:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyC4l3kIZQLPWKTXTW5ZNN2iT36YVSYAQ3WRIso/K2g63vZNo+JIphxK8UkbGLC3NdCedKF X-Received: by 2002:a63:1226:: with SMTP id h38mr10564487pgl.196.1560998419907; Wed, 19 Jun 2019 19:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560998419; cv=none; d=google.com; s=arc-20160816; b=hul6aWeJ5PX6QCwxQkxZU/6ozynmD+30hnBg1wORItalXgc2BeNYHb2fCV8ej+y61m Ol+mOGNJlDA8y0mXcf2PCqpoBbvdB/vTAzED3QXwWhFuXJdoKZskHzR6wNxidywqEryV XcnbJQTqIMEjrM55n4N2zdjXNaEQ27LbrLfxBD0c4Bqw8eC5oSdUPK72W2I5fksZ+Gd+ ldIO3BHUBRcsQT8JgdIOD7IuDoRiSMcknXXamXSf4MMxBjvFygoXYXN84kF8FZvmfzyN uaYBa6iNet0srPdE8DheALFVnp1gLQPTLHQ9PMjnKw6KOxVax2dgE4TwxJZ6sIPFisW+ yQBA== 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=6g6Bd7a25mr+s3vG6TP98/YGESlD/dInKd/DJZJvkcM=; b=Y9+3A+GF9dQAlr/QIFSsuIXawrS3fsFuKKXhBzh/IpzHj3k8xnu9O2ar8+JxvWowp7 TOXebHQMSiqOGV08AcEU34seWHaocpd1k1ya7itKF2ltg7Z6AODx64Y5/abghMqzKEcl klpdL5NyNYCotjWXrg4Qo8aDzgg4lsYkQRsqDYAwS2UFoPjG5zNnLgxbJ+Ml9B2aDxwD MTC9rPSM3meqe1188jc51K0qoj7iIOXcUf/hDKFPZZE9NS+3NI1v60qOuIeuj9y9Uudw +0XO1jIk0lcB5DoskvMlU5YBwXbOg28xBbIJtEdJA1lbFPvHWCMi02JGyxo/FOsvczhy XTvw== 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 j23si17764982pfh.215.2019.06.19.19.40.04; Wed, 19 Jun 2019 19:40:19 -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 S1731708AbfFTCjO (ORCPT + 99 others); Wed, 19 Jun 2019 22:39:14 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:13850 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730936AbfFTCi3 (ORCPT ); Wed, 19 Jun 2019 22:38:29 -0400 X-UUID: ffa3de41035c427ebf2c237c09b47801-20190620 X-UUID: ffa3de41035c427ebf2c237c09b47801-20190620 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 885691375; Thu, 20 Jun 2019 10:38:20 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 20 Jun 2019 10:38:19 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 20 Jun 2019 10:38:19 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Rob Herring CC: James Liao , Fan Chen , , , , , Weiyi Lu , Yong Wu Subject: [PATCH v6 08/14] soc: mediatek: Refactor bus protection control Date: Thu, 20 Jun 2019 10:38:00 +0800 Message-ID: <1560998286-9189-9-git-send-email-weiyi.lu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1560998286-9189-1-git-send-email-weiyi.lu@mediatek.com> References: <1560998286-9189-1-git-send-email-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain 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 58627ab..178198b 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