From patchwork Mon Sep 18 09:37:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 141369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2592758vqi; Mon, 18 Sep 2023 04:49:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE44EuUgA2yuaIgUJg5GEKMRqYczmpJ9eLAurPn/33k9cBiu6RlGnH9xFnIg2uu/56lAXwl X-Received: by 2002:a05:6870:ec92:b0:1bc:1651:10e with SMTP id eo18-20020a056870ec9200b001bc1651010emr11171999oab.30.1695037786893; Mon, 18 Sep 2023 04:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695037786; cv=none; d=google.com; s=arc-20160816; b=T6nTg5duw8rpile0x5TLo6ckGWXEQ1LRfUxsms1vJgNjrD0rqqlKFwJK4LzVVxUUVj OG9oj+662qVFMRhNsiml2te2s2HgTerEj7iOltMIwXjBblOpnVq8YbtbATqPb/sY0tAI 1azLO1RoJdkyjR06lqE4buVeMs3zrmCIMjdTl61QnWoi4f+vj+KHsujn+/0LL1eJbAyF 95EqGUGnuqicHBiyUTrB2KKlXT3cKLpgsxCHuwO+rcTU/d6czZbAAqq0GsDyzt8LPLK6 SrMxXtvvu4WB9um9/rMifj1C1IE9xjYdt6oJWjKJSAE8uCXX9awp5MqiY1cqMwqifJFs CJoQ== 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=K+o3x+uJ9YzwXJ706ogofqn/rKhanyRMaKp/8ksBhmQ=; fh=thsjkMd7bcRVPLxPw6q8lk+LSzWpHvhT0sExk33xdq0=; b=E05ibHQv8QgXb2oWCvY8Q7MIVYZShmbz+h/mDNTKVZlILK5dAYM3Vk9eQ1lVSA5vsW Mx0PmJFmY1EL3kSCQWZ1bFnmjL2vBIOOmivzQXuVnpbHWPXT+l5Gsu5X1T79UWbRqNge SX19LKBWtiJvqdwlzGwZF6Webv9TI0OK+VSNmuHnHiKf/U7NNS4Hgr1EVVozTBPDs1nm 3axxgPwrqoI1GXzY/ITb1De2YaZMkopFTTBkSLlQLAAU4Q1lyseRm7Rn1yF5jkB5w6n3 IeqwRPOtShdSl2sBY+TJ3kuzWFYeIu9O77+GJXr++wSkkIyMKpfxDz7jkI72NvWWNt/t k7MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=DiPjgD3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id oc16-20020a17090b1c1000b0026824d6cb0fsi10757160pjb.164.2023.09.18.04.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=DiPjgD3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E88AD81A4446; Mon, 18 Sep 2023 02:40:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241049AbjIRJjO (ORCPT + 27 others); Mon, 18 Sep 2023 05:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240984AbjIRJih (ORCPT ); Mon, 18 Sep 2023 05:38:37 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE51E1 for ; Mon, 18 Sep 2023 02:38:27 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-99bdcade7fbso542162166b.1 for ; Mon, 18 Sep 2023 02:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695029906; x=1695634706; darn=vger.kernel.org; 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=K+o3x+uJ9YzwXJ706ogofqn/rKhanyRMaKp/8ksBhmQ=; b=DiPjgD3m+0WNfEcSo/14O40oKDh633g93rbYKSLYVoRZgqfOR2ly4nZXUPfBSBIKC7 OIeApOUCEu/ruE7sA41y5wCTbROrk7j6kF02hi3arHceI5cs2odJYt2ynIdIqMdxua3I QRJrMu/3BMKTZqqe1OZWpa0EThJKh/NWUrH+/aXa69baFhWj5T4no+iLDD+OVsEOrPez pV5zaoNGCYx3HqddzJJyYeGnnTaDLG1Y1htStdmpodQNg7wYrMiO3CBlL/Fqu+d+dGyl cDLJp9kbozMlvDIChHblDcxKJ527ukDx48h/DhtHOP6Qp6XZTJSsNFrAiWYQYtbAicWV a1zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695029906; x=1695634706; 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=K+o3x+uJ9YzwXJ706ogofqn/rKhanyRMaKp/8ksBhmQ=; b=fPgVvUZ29KuHjechJjuKWjWEg6WqtRJCqRwlDc+jMLDq0mAkKqM07ajgCbr3/56uQ5 qlIso9w37JX/VQga6oeUP0YkGspFjavoM+19ZoG1mp0EncltdzgNEfzNv+7XzVbh1Mg4 90MurmCrMzAm54DU1Uq8n56SoujaVofAAnrtQ0rKNNuemO+wsi/Tq/SQNLt/a7O5Km3B 7RTkKgNeodBxJw+i4mEvowpihxpg0MhQlQR/VnmYPLr3vDFCln1UDvMLBi8DRFxd5Rjg fZB1ox1vrymMGW7Z6pI1PGhHc/Bt6h/4AbnelDAU2wSuiwj9LCkwQktOeW3EBU11uX2J T+SA== X-Gm-Message-State: AOJu0Yw2TC/frXRxipzRwnU3f6DeTcX/IBiowmKA3QTGpxOnAIqhiKgq 4snYupRQYLom5UdXx7p3zZJ1Ig== X-Received: by 2002:a17:906:292a:b0:9ae:f0:17e1 with SMTP id v10-20020a170906292a00b009ae00f017e1mr2538052ejd.74.1695029906014; Mon, 18 Sep 2023 02:38:26 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a246:8222:872:4a5b:b69c:1318]) by smtp.gmail.com with ESMTPSA id o10-20020a1709061d4a00b0099293cdbc98sm6251164ejh.145.2023.09.18.02.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:38:25 -0700 (PDT) From: Markus Schneider-Pargmann To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger Cc: Ulf Hansson , Alexandre Mergnat , Chun-Jie Chen , AngeloGioacchino Del Regno , Tinghan Shen , Fabien Parent , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Alexandre Bailon , Fabien Parent , Markus Schneider-Pargmann Subject: [PATCH v8 7/8] soc: mediatek: Add support for MTK_SCPD_STRICT_BUS_PROTECTION cap Date: Mon, 18 Sep 2023 11:37:51 +0200 Message-Id: <20230918093751.1188668-8-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230918093751.1188668-1-msp@baylibre.com> References: <20230918093751.1188668-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 02:40:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777375942495328230 X-GMAIL-MSGID: 1777375942495328230 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat Tested-by: Alexandre Mergnat --- drivers/pmdomain/mediatek/mtk-pm-domains.c | 27 ++++++++++++++++++---- drivers/pmdomain/mediatek/mtk-pm-domains.h | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c index 4bf3a375b749..69cdf6ff00b8 100644 --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c +++ b/drivers/pmdomain/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/pmdomain/mediatek/mtk-pm-domains.h b/drivers/pmdomain/mediatek/mtk-pm-domains.h index 17c033217704..aaba5e6b0536 100644 --- a/drivers/pmdomain/mediatek/mtk-pm-domains.h +++ b/drivers/pmdomain/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 @@ -107,7 +108,7 @@ struct scpsys_domain_data { u32 sram_pdn_ack_bits; int ext_buck_iso_offs; u32 ext_buck_iso_mask; - u8 caps; + u16 caps; const struct scpsys_bus_prot_data bp_cfg[SPM_MAX_BUS_PROT_DATA]; int pwr_sta_offs; int pwr_sta2nd_offs;