From patchwork Thu Jul 13 15:04:13 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: 119966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1898581vqm; Thu, 13 Jul 2023 08:22:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCzpir9FqgVdyZ/BsMon+N+EEW4csquyosqDStgJOqYLfpTFyjI9YnAgdgHNbbXzJpx8yD X-Received: by 2002:a17:902:c1d4:b0:1b3:8862:9823 with SMTP id c20-20020a170902c1d400b001b388629823mr1305707plc.28.1689261728057; Thu, 13 Jul 2023 08:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689261728; cv=none; d=google.com; s=arc-20160816; b=qhsTTG/wXdOY6lTqRocl2ZKxH8lhqfRTWDZsaOTDfHU9r/c9MBzbthkI3/FJQhwrDM GRSL1XDXrNyrtZ8t8+OuM5UcWTUVg3ZXrRQW5ugzyGnK7Yu+hnF7AHD4sGxDIKrw1h/Q Jtr1niGBs0gZROpxOZch7omKxjLN1cW8TPb80zb8jOTEf21AubRwTwTzj4RPUIMt+8JJ Zi4aai4Pp8tMXxhu7a2GWTruerDI6RsXa2XgO2oFtCQDEnueMGJlEHRoRoZ039cb4mEE WnkkOQGyK+5B2XS8qLG9MpMNc/V6mLBLKOJiKqkXVEJpHMOtrjhOUYmC0FdJzazULdYp zI4w== 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=pHY2zl9AlSScSWcascrM1mTFlsb4P2jY07NseXNj/VE=; fh=XnwVpWxFxLK3iZkTw3j9eQ6SmlShykRDEj+suivMe+0=; b=N6KNGzniKjW4Knx+OueBwjq2KCWMop9r3QkfzF/xcWy4vMKe3QAEhWfESzGbr8MGoH Fd/5HGI6EPO8Xk7PCpVGMnjShigHlEGbuEiSADm+SAAioxKDddivV2Go8ILhxqmefxlI RrUiomKCtQw31gp6BW835CkflbHJcXyUxBDHE/ld+YX/YG6m0QhVje7c8Y7k+khbkX1N 8AhSaB+U9Oy+dxQ6aU7VsqpBvPxgoC5GTp7a0hB6G2OUliDZXGi2UhorzQlZt3kgeiai 6uLuILq/Dznrj5zozUJnjSi6eFAdYTD1P7/qSrawq/SV8zrRAx/sVMWT/3ooHtM+FsT0 SNiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=mzmHcYpO; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kn15-20020a170903078f00b001b8ae9058d3si5184627plb.516.2023.07.13.08.21.54; Thu, 13 Jul 2023 08:22:08 -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=mzmHcYpO; 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 S232406AbjGMPEx (ORCPT + 99 others); Thu, 13 Jul 2023 11:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbjGMPEi (ORCPT ); Thu, 13 Jul 2023 11:04:38 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA062707 for ; Thu, 13 Jul 2023 08:04:35 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9926623e367so122388466b.0 for ; Thu, 13 Jul 2023 08:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1689260673; x=1691852673; 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=pHY2zl9AlSScSWcascrM1mTFlsb4P2jY07NseXNj/VE=; b=mzmHcYpO1Htg+w3gGK9nVRXLug+Zfktq+X2nX57AkyIlOIctmeiIFiEggRCmsPceSI hpj9oFlfwpOLgfthbCIgD95Xf+YP7hPgOlRuID6GUtE4pLdCZUYT6/s7Ws4aOAqjxeKA ZhDsk+Awp5Q98GnSLXrhFRZ1Lm17gTGghB7sbjNgXqJKKkgcZmL10MxhAO19rwiMJcDr KQJYhp5OJloQWmN+3nNCFA+Trjj9SmHKh3ugm8JN+anu1c2pZbT6BS0ypdeWj8FAnv5g dk9Bf8Ex7dvgp7GFf88QETIsb2tR56TcSDcrIOiD/aQU8cJ6vbJqljOeQxngVQ6VlfvY XQSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689260673; x=1691852673; 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=pHY2zl9AlSScSWcascrM1mTFlsb4P2jY07NseXNj/VE=; b=f3aaGcb5rB2YLmZ70BPVGeHVmQDMmgUFaGWirxwrC8MAV2O66HsifHpYVM4ltUQHtm QkjLmK4CCqUoqY1erWnrxMEaX0iS1olxa+FF6R/tl8CVMrsA/KjvSJMMBNpJjGH4G08c x5D7lgB60gz1xIuSE3wSef+R5R1Xb/xCz+eZ1RzlxIzjWHkSRufW8MMqJRdIBfalTku7 fWpgk5QRVsnh0EqTFZhEk0GhiReghpmbIwM9uAfsfY1PPu82MA+OjKD2yXjjSqYo7+Jj iPUS1qqtUSyMpAdZ1MC+FqXDM+YimGpZo1GV8RVDPtM4AdTvf3TdV58KCdPKL3bEScue laEA== X-Gm-Message-State: ABy/qLZAcSjhvGFAY4ZlehM19XJ0PLY+9ctqSghSraUFY4XXhthQrhjz LNJFsOih2g5eQWnLfwXAwf7BVw== X-Received: by 2002:a17:907:2a52:b0:992:1964:cd57 with SMTP id fe18-20020a1709072a5200b009921964cd57mr1338543ejc.75.1689260673551; Thu, 13 Jul 2023 08:04:33 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:1d6d:d215:e7c4:dd5e]) by smtp.gmail.com with ESMTPSA id cd26-20020a170906b35a00b009929c39d5c4sm4102939ejb.36.2023.07.13.08.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 08:04:33 -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 , Alexandre Mergnat Subject: [PATCH v7 7/8] soc: mediatek: Add support for MTK_SCPD_STRICT_BUS_PROTECTION cap Date: Thu, 13 Jul 2023 17:04:13 +0200 Message-Id: <20230713150414.891893-8-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713150414.891893-1-msp@baylibre.com> References: <20230713150414.891893-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771319305669958205 X-GMAIL-MSGID: 1771319305669958205 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/soc/mediatek/mtk-pm-domains.c | 27 +++++++++++++++++++++++---- drivers/soc/mediatek/mtk-pm-domains.h | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c index a9ac79e5c295..cf45e29420b2 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 17c033217704..aaba5e6b0536 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 @@ -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;