Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1195888pxx; Fri, 30 Oct 2020 04:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVlIVcrYMBONB8wjpx+AdrhL5EdQfQ3EqbpKjrRq3c71PudIOrCcvkj+Vl0yYTVkxfOa6b X-Received: by 2002:a17:907:392:: with SMTP id ss18mr2020753ejb.429.1604057950393; Fri, 30 Oct 2020 04:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604057950; cv=none; d=google.com; s=arc-20160816; b=Q4pfW2wMfzvD56NuL9Y3RG/i+j15phlDJmAdK5Ktz5kzMhblL6RhHtyIx3PIq+eJnG 4rveIdnpGpIufS8CbxlBJdHlsdn939MFlbXXzVc4bttim4hvyJ39uoZ48ZEceuEwF9hG /oGR1+CRF53cjXMy5U/qNyISXtlqdWQc5OZdBN7356qRyhpM+/kjjz4VTSA1eyBXTeDT EYbk3Rw0FwFEFBRri1Xj8T6x/K33lykC+tQRNXYZ0BQdHOTgtYOH1VWO07v2OZmGtiD7 HWWY59JRw5OG2BxWLU+i3XvU7oHmo6gLpIU1b2EN/l4CNtNSZ2K2UlQr4GV3fS26h1d6 VG+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wRQo3g7FHon/+esZTtmxggGZ7hr+0MGRReVF6w79CWg=; b=UZviqaqOocJwV3Yoae7KBb6bplcR5a4SKWg0aFau3TA41GFlAS8r3jXRbS/1T/AEl4 YlynGrSLxuGI4Sclfs08c7AISrlsnrwSZyRheyGZr2IW5AyCsyRENVqvj0yc2WMT4YJp tTrXxWlcKWIRooDhK1DHPuhaaKXj8a8g+a0zCGYtSQeIIiVkrCKcO4dnuSJRrcmbL9Jw UWCaMtSbGTxy3TEEYpD/4PUxpUizpm+nOTL2YwbmvlnR1d/NUOMy+vRsQdsLaPzRvv/r Uo68dITNdCO6lpwG+okafjy8NoAbGm0NPRPC2DF9E28eTegHtMoexVt6aSp3TPj7+zid F+/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f2si4034703ejc.542.2020.10.30.04.38.48; Fri, 30 Oct 2020 04:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbgJ3Lgr (ORCPT + 99 others); Fri, 30 Oct 2020 07:36:47 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59004 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbgJ3Lgh (ORCPT ); Fri, 30 Oct 2020 07:36:37 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id C7A211F45EC2 From: Enric Balletbo i Serra To: linux-kernel@vger.kernel.org Cc: matthias.bgg@gmail.com, drinkcat@chromium.org, hsinyi@chromium.org, Collabora Kernel ML , weiyi.lu@mediatek.com, fparent@baylibre.com, Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 07/16] soc: mediatek: pm-domains: Add extra sram control Date: Fri, 30 Oct 2020 12:36:13 +0100 Message-Id: <20201030113622.201188-8-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030113622.201188-1-enric.balletbo@collabora.com> References: <20201030113622.201188-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Brugger For some power domains like vpu_core on MT8183 whose sram need to do clock and internal isolation while power on/off sram. We add a cap "MTK_SCPD_SRAM_ISO" to judge if we need to do the extra sram isolation control or not. Signed-off-by: Weiyi Lu Signed-off-by: Matthias Brugger Signed-off-by: Enric Balletbo i Serra Seires-changes: 4 - Use the regmap_[clear|set]_bits helpers. --- Changes in v4: None Changes in v3: None Changes in v2: - Nit, split readl(ctl_addr) | pd->data->sram_pdn_bits in two lines. - Use regmap API drivers/soc/mediatek/mtk-pm-domains.c | 23 +++++++++++++++++++++-- drivers/soc/mediatek/mtk-pm-domains.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c index 8a21847464c2..a6f25933dbf0 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.c +++ b/drivers/soc/mediatek/mtk-pm-domains.c @@ -24,6 +24,8 @@ #define PWR_ON_BIT BIT(2) #define PWR_ON_2ND_BIT BIT(3) #define PWR_CLK_DIS_BIT BIT(4) +#define PWR_SRAM_CLKISO_BIT BIT(5) +#define PWR_SRAM_ISOINT_B_BIT BIT(6) struct scpsys_domain { struct generic_pm_domain genpd; @@ -65,12 +67,23 @@ static int scpsys_sram_enable(struct scpsys_domain *pd) u32 pdn_ack = pd->data->sram_pdn_ack_bits; struct scpsys *scpsys = pd->scpsys; unsigned int tmp; + int ret; regmap_clear_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); /* Either wait until SRAM_PDN_ACK all 1 or 0 */ - return regmap_read_poll_timeout(scpsys->base, pd->data->ctl_offs, tmp, - (tmp & pdn_ack) == 0, MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); + ret = regmap_read_poll_timeout(scpsys->base, pd->data->ctl_offs, tmp, + (tmp & pdn_ack) == 0, MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); + if (ret < 0) + return ret; + + if (MTK_SCPD_CAPS(pd, MTK_SCPD_SRAM_ISO)) { + regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_SRAM_ISOINT_B_BIT); + udelay(1); + regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_SRAM_CLKISO_BIT); + } + + return 0; } static int scpsys_sram_disable(struct scpsys_domain *pd) @@ -79,6 +92,12 @@ static int scpsys_sram_disable(struct scpsys_domain *pd) struct scpsys *scpsys = pd->scpsys; unsigned int tmp; + if (MTK_SCPD_CAPS(pd, MTK_SCPD_SRAM_ISO)) { + regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_SRAM_CLKISO_BIT); + udelay(1); + regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_SRAM_ISOINT_B_BIT); + } + regmap_set_bits(scpsys->base, pd->data->ctl_offs, pd->data->sram_pdn_bits); /* Either wait until SRAM_PDN_ACK all 1 or 0 */ diff --git a/drivers/soc/mediatek/mtk-pm-domains.h b/drivers/soc/mediatek/mtk-pm-domains.h index c2defbdcdf31..f190a0d9e592 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.h +++ b/drivers/soc/mediatek/mtk-pm-domains.h @@ -5,6 +5,7 @@ #define MTK_SCPD_ACTIVE_WAKEUP BIT(0) #define MTK_SCPD_FWAIT_SRAM BIT(1) +#define MTK_SCPD_SRAM_ISO BIT(2) #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x)) #define SPM_VDE_PWR_CON 0x0210 -- 2.28.0