Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6127401rwd; Mon, 19 Jun 2023 02:46:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5A3aAmzL02ee6OHBOSmFt3srIqcP4bdRdnP/wb8rIUrUEkApCdWpYo7crAl5ej5TuYjLMo X-Received: by 2002:a05:6a21:3295:b0:121:7b0b:c28e with SMTP id yt21-20020a056a21329500b001217b0bc28emr4031505pzb.46.1687167970716; Mon, 19 Jun 2023 02:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687167970; cv=none; d=google.com; s=arc-20160816; b=Lhl0iokStHxN9Q9fDSOyx22Za02TjUCLk5RAhf2f9F3Huk8Ped1aX338fEhb7+DDtK rcvrrCAkWte6NTfEGwETuzfM0GyK/R1sBC9Vi2ETjcVGQo9GM53xe5xDibXr+pJvq5mS bcWns+8W5r4l4ddDdHe1C4FgKGf8+syFnLK55DHEy7qEkSe5K7juHX9fH0c2wuc4Nib2 GQweviu2IZitQu5LbtBlaCKlIg45Gf3y6Z6O702ATQaDxgUYHo06QBrq0/R5vdMqUomu xy2ITAl0fzmxhDZxA+epGfCbWnbN4f0YzjJWzAK25T3JXza/VoNzPrs2mf35khqSpglx u6mA== 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 :dkim-signature; bh=UjL7PyODR4xjZUQH06VhkEHWT7Au/HHZMcOL+cz1CHs=; b=n9eOsWOr0kZhbt1p3b09xGfJtiNjDyaQ8Q4EFMIaqh6Oy9ZNSqqAfMjeb7DZTtCl5Z 2zzJB1iQKorY6XOfx9kWt/x+yxwg2t3JMzOEOvpWH/Yu7vCN6sAKPxuwVYtkR4QuFXHL UljUY7uyVzNhqFg6PR1/zs6TZPYCVNqLCLshSH51pC1s2b6ExlcECTJPK+rB+6j9zVwo scnpEAUYDigFP/vnOab04bI01hngaAV5eBwwADNsJYS4UmVT5AX2jtwzirsDRErU2XDe aEWa7kXv+uQOtR2Pz2zt+fw42p2Ug0GgLEUwIq2UaMSoZLQNzOFwpqNH0T0qwz18xAI6 aTMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=Ahov2+FB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k62-20020a636f41000000b0054201a157fesi20313162pgc.427.2023.06.19.02.45.53; Mon, 19 Jun 2023 02:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=Ahov2+FB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231213AbjFSIze (ORCPT + 99 others); Mon, 19 Jun 2023 04:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjFSIzF (ORCPT ); Mon, 19 Jun 2023 04:55:05 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C071710D8 for ; Mon, 19 Jun 2023 01:54:20 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-98377c5d53eso455742066b.0 for ; Mon, 19 Jun 2023 01:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687164859; x=1689756859; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UjL7PyODR4xjZUQH06VhkEHWT7Au/HHZMcOL+cz1CHs=; b=Ahov2+FBRKJ2DJvXO0m6d3KytOULMc30murjslT7irsJzedit/iAHdiYZSzFHi7lFy O/yaBumy4uUCCt3NByTZ5WLyJ/4Vd6VXBASsxD26DZqvTxeB/QOBefmdkwEAgE36tWkB HPx+oDCcPFpemRB3VS4Z4tTxBvZtlhOE3kfGoSLrbc8nza3Em+sANYrYpthsKgh7sApO yD52bEkJDsdv0Zo7bm1AKmDJJiSyzGbAriMXpDuMJZ+RPHfCjGbsKx3z8/H2qrusAEX8 hvZWGVqwbBp1GtkpYnXT1SzNVdSx9QzG/Hi7x8Jbt622QImZluU+TUviunpPeK3ou+PR z7lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687164859; x=1689756859; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UjL7PyODR4xjZUQH06VhkEHWT7Au/HHZMcOL+cz1CHs=; b=OUmaoa+eZk/+io7YZ5/ocpb4Alqt7hMNIeA/Sqrpbzp3w/O56sU+PEvmH10wjnlp9/ YSD93dvEqGZJ6ecWjW5mbbD5JXToxl7QUIBstp/Jw0ed2Xy5vZxTeoaijhqTCEpyxaFH suy3pYl8xZC/x/kmVFZuctWqc47V3bSJBYavrs1iBE/KUMUSiebPvbNagtXJ0y/i5uxB l+mxCa895N2nCclxvCPEZyH4zhYPlY4fVkZXi4V6LX4aLcDh1y+62MLAZ1+e0hygjGIO z26Mz75sAuyJANRd520Y1Glv2D+6EXtyFyL6u+PASrbf81E1cSdZQe7JPdF2WtxdZ8b4 Wh4w== X-Gm-Message-State: AC+VfDyJ+XWe0uRtLYNC1wxFhjgNrfjMdHRWiXGvJfOO+jy0ekmEwLIX OO9RQI9eqTikQEoZfmZcMZFC1w== X-Received: by 2002:a17:907:e87:b0:96f:6c70:c012 with SMTP id ho7-20020a1709070e8700b0096f6c70c012mr8522591ejc.45.1687164859332; Mon, 19 Jun 2023 01:54:19 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a245:802c:bc2b:8db8:9210:41eb]) by smtp.gmail.com with ESMTPSA id h27-20020a17090619db00b00987a6e01e94sm2994339ejd.214.2023.06.19.01.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 01:54:18 -0700 (PDT) From: Markus Schneider-Pargmann To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger Cc: Chun-Jie Chen , AngeloGioacchino Del Regno , Tinghan Shen , Fabien Parent , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Alexandre Bailon , Fabien Parent , Markus Schneider-Pargmann Subject: [PATCH v5 7/8] soc: mediatek: Add support for MTK_SCPD_STRICT_BUS_PROTECTION cap Date: Mon, 19 Jun 2023 10:53:43 +0200 Message-Id: <20230619085344.2885311-8-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619085344.2885311-1-msp@baylibre.com> References: <20230619085344.2885311-1-msp@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Bailon This adds support for MTK_SCPD_STRICT_BUS_PROTECTION capability. It is a strict bus protection policy that requires the bus protection to be disabled before accessing the bus. This is required by the mt8365, for the MM power domain. Signed-off-by: Alexandre Bailon Signed-off-by: Fabien Parent Signed-off-by: Markus Schneider-Pargmann --- drivers/soc/mediatek/mtk-pm-domains.c | 27 +++++++++++++++++++++++---- drivers/soc/mediatek/mtk-pm-domains.h | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c index 4659f0a0aa08..5c458aa2ddbe 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.c +++ b/drivers/soc/mediatek/mtk-pm-domains.c @@ -262,9 +262,17 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT); regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT); - ret = clk_bulk_prepare_enable(pd->num_subsys_clks, pd->subsys_clks); - if (ret) - goto err_pwr_ack; + /* + * In few Mediatek platforms(e.g. MT6779), the bus protect policy is + * stricter, which leads to bus protect release must be prior to bus + * access. + */ + if (!MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUS_PROTECTION)) { + ret = clk_bulk_prepare_enable(pd->num_subsys_clks, + pd->subsys_clks); + if (ret) + goto err_pwr_ack; + } ret = scpsys_sram_enable(pd); if (ret < 0) @@ -274,12 +282,23 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) if (ret < 0) goto err_disable_sram; + if (MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUS_PROTECTION)) { + ret = clk_bulk_prepare_enable(pd->num_subsys_clks, + pd->subsys_clks); + if (ret) + goto err_enable_bus_protect; + } + return 0; +err_enable_bus_protect: + scpsys_bus_protect_enable(pd); err_disable_sram: scpsys_sram_disable(pd); err_disable_subsys_clks: - clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks); + if (!MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUS_PROTECTION)) + clk_bulk_disable_unprepare(pd->num_subsys_clks, + pd->subsys_clks); err_pwr_ack: clk_bulk_disable_unprepare(pd->num_clks, pd->clks); err_reg: diff --git a/drivers/soc/mediatek/mtk-pm-domains.h b/drivers/soc/mediatek/mtk-pm-domains.h index 562d4e92ce16..116c7875f74c 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.h +++ b/drivers/soc/mediatek/mtk-pm-domains.h @@ -12,6 +12,7 @@ #define MTK_SCPD_ALWAYS_ON BIT(5) #define MTK_SCPD_EXT_BUCK_ISO BIT(6) #define MTK_SCPD_HAS_INFRA_NAO BIT(7) +#define MTK_SCPD_STRICT_BUS_PROTECTION BIT(8) #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x)) #define SPM_VDE_PWR_CON 0x0210 -- 2.40.1