Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1196250pxx; Fri, 30 Oct 2020 04:39:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEllP4GKT/T1Eh2hIu3KoNS3CO2s7l5ydy6Iai/hXCWvsUph0O8bwM40JyNNcgkdiaGEp8 X-Received: by 2002:a50:8acf:: with SMTP id k15mr1805290edk.351.1604057982831; Fri, 30 Oct 2020 04:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604057982; cv=none; d=google.com; s=arc-20160816; b=GpIHgPExJnBDTuieI/yFa26mBmVvcCNtXA59HpNoEu1Y2t96kQOlaD93MUrYzPdpjl xVEyqSJXHCErL+edtAc/3mOu7OpZrS87MQdxOo75rVBiYYSnawRGWZLivE0XqbOlojFe q041qRaV8H5ZWGu7CCDve4vZr4hBfx24jLJtpGBfxuwYqCVaA+8ieJTq5FbiyZHk2xX9 B4yp6UFitIo++mzO9apcr4/HV7aRCaKzcGfmoTqvSS5Rci0sh3lSEXz4mJI2d/91X9/F 5GiR0BpTzYfnhugu4KahloOZjP6fKBJRUV0DCol0wP7iiaQnYUyMrEJeQNAxmmvrX8R/ mLfw== 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=8TuNUgGfLaMhyRZ+U98SXBtHkfj8MtkdVg04l6Nmi6s=; b=XQUUh4BfBr5/nr5iMWsp+QS8Gqw5TQQHsog/Zly2Jn1Zv4Oj9gX3+XGlFxOlAD95A0 +41cjIa8wQRSwUZpxyKlVDMkvoVN6jjqqgeQcl2Vx2Zy1rTSqhfJhN4eK6OgK2R65IUd Klljr9o/nrScwq+0dgwmtXbcGJ1ve1eEEnzzqVnecykykhXsz+6iHxKFGAqvvi5vr10k MGj7ZilniTaXROTYcrOZO+Z49BK6NvxJq76YAVT+0Q2h3nFgv89i5ygutfzKnl9agIx8 AnDdhkpx+9h6JFYfmox333nW8w5++ugnAiDkVy+HOEDcJt+pP7qLMai38FRCOKPnSSZo S4Eg== 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 om24si4057988ejb.610.2020.10.30.04.39.19; Fri, 30 Oct 2020 04:39:42 -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 S1726603AbgJ3Lgl (ORCPT + 99 others); Fri, 30 Oct 2020 07:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbgJ3Lge (ORCPT ); Fri, 30 Oct 2020 07:36:34 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E24C0613D2 for ; Fri, 30 Oct 2020 04:36:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id E7D691F45EC0 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 04/16] soc: mediatek: pm-domains: Add bus protection protocol Date: Fri, 30 Oct 2020 12:36:10 +0100 Message-Id: <20201030113622.201188-5-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 Bus protection will need to update more then one register in infracfg. Add support for several operations. Signed-off-by: Matthias Brugger Signed-off-by: Enric Balletbo i Serra --- Changes in v4: - Define SPM_MAX_BUS_PROT_DATA to 5 to be compatible with MT8192 - Disable the bus protection in the reverse order for scpsys_bus_protect_disable(). Changes in v3: None Changes in v2: None drivers/soc/mediatek/mt8173-pm-domains.h | 4 +-- drivers/soc/mediatek/mtk-pm-domains.c | 36 +++++++++++++++++------- drivers/soc/mediatek/mtk-pm-domains.h | 4 ++- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/soc/mediatek/mt8173-pm-domains.h b/drivers/soc/mediatek/mt8173-pm-domains.h index 5f2b5d4ad02b..72b3acaf74fb 100644 --- a/drivers/soc/mediatek/mt8173-pm-domains.h +++ b/drivers/soc/mediatek/mt8173-pm-domains.h @@ -34,7 +34,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8173[] = { .ctl_offs = SPM_DIS_PWR_CON, .sram_pdn_bits = GENMASK(11, 8), .sram_pdn_ack_bits = GENMASK(12, 12), - .bp_infracfg = { + .bp_infracfg[0] = { .bus_prot_reg_update = true, .bus_prot_mask = MT8173_TOP_AXI_PROT_EN_MM_M0 | MT8173_TOP_AXI_PROT_EN_MM_M1, @@ -76,7 +76,7 @@ static const struct scpsys_domain_data scpsys_domain_data_mt8173[] = { .ctl_offs = SPM_MFG_PWR_CON, .sram_pdn_bits = GENMASK(13, 8), .sram_pdn_ack_bits = GENMASK(21, 16), - .bp_infracfg = { + .bp_infracfg[0] = { .bus_prot_reg_update = true, .bus_prot_mask = MT8173_TOP_AXI_PROT_EN_MFG_S | MT8173_TOP_AXI_PROT_EN_MFG_M0 | diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c index f8e88308f2e0..06a16e45356a 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.c +++ b/drivers/soc/mediatek/mtk-pm-domains.c @@ -88,24 +88,40 @@ static int scpsys_sram_disable(struct scpsys_domain *pd) static int scpsys_bus_protect_enable(struct scpsys_domain *pd) { - const struct scpsys_bus_prot_data *bp_data = &pd->data->bp_infracfg; + const struct scpsys_bus_prot_data *bpd = pd->data->bp_infracfg; + int i, ret; - if (!bp_data->bus_prot_mask) - return 0; + for (i = 0; i < SPM_MAX_BUS_PROT_DATA; i++) { + if (!bpd[i].bus_prot_mask) + break; - return mtk_infracfg_set_bus_protection(pd->infracfg, bp_data->bus_prot_mask, - bp_data->bus_prot_reg_update); + ret = mtk_infracfg_set_bus_protection(pd->infracfg, + bpd[i].bus_prot_mask, + bpd[i].bus_prot_reg_update); + if (ret) + return ret; + } + + return 0; } static int scpsys_bus_protect_disable(struct scpsys_domain *pd) { - const struct scpsys_bus_prot_data *bp_data = &pd->data->bp_infracfg; + const struct scpsys_bus_prot_data *bpd = pd->data->bp_infracfg; + int i, ret; - if (!bp_data->bus_prot_mask) - return 0; + for (i = SPM_MAX_BUS_PROT_DATA; i > 0; i--) { + if (!bpd[i].bus_prot_mask) + continue; - return mtk_infracfg_clear_bus_protection(pd->infracfg, bp_data->bus_prot_mask, - bp_data->bus_prot_reg_update); + ret = mtk_infracfg_clear_bus_protection(pd->infracfg, + bpd[i].bus_prot_mask, + bpd[i].bus_prot_reg_update); + if (ret) + return ret; + } + + return 0; } static int scpsys_power_on(struct generic_pm_domain *genpd) diff --git a/drivers/soc/mediatek/mtk-pm-domains.h b/drivers/soc/mediatek/mtk-pm-domains.h index 7c479021d404..125880a58170 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.h +++ b/drivers/soc/mediatek/mtk-pm-domains.h @@ -32,6 +32,8 @@ #define PWR_STATUS_AUDIO BIT(24) #define PWR_STATUS_USB BIT(25) +#define SPM_MAX_BUS_PROT_DATA 5 + struct scpsys_bus_prot_data { u32 bus_prot_mask; bool bus_prot_reg_update; @@ -52,7 +54,7 @@ struct scpsys_domain_data { u32 sram_pdn_bits; u32 sram_pdn_ack_bits; u8 caps; - const struct scpsys_bus_prot_data bp_infracfg; + const struct scpsys_bus_prot_data bp_infracfg[SPM_MAX_BUS_PROT_DATA]; }; struct scpsys_soc_data { -- 2.28.0