From patchwork Mon Jun 19 08:53:39 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: 109835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2864134vqr; Mon, 19 Jun 2023 02:09:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6scLURVyTsPlMjVjPvWZaKXbSRubMIjg0dqDMgQUwPxXJXgOp2nLZ0qXq6zj6CztcyGGIy X-Received: by 2002:a17:90a:4145:b0:23f:9445:318e with SMTP id m5-20020a17090a414500b0023f9445318emr11788635pjg.3.1687165748425; Mon, 19 Jun 2023 02:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687165748; cv=none; d=google.com; s=arc-20160816; b=ACpPNa3e8qDsqDn5zT7/onxaN2TALmNvywz/UVB4RV0E6gUnhXK8+q8eexmyy/QMaC s1iCOgrsEFfh2tBi683UcH+HQRfXTXAG6u8dDxv8mcYA1l4WTcVE7WXC/d2xa4wmLKrV 1F0++OF/ifpgtgRYgJoye3wFu2NQcFxgZX0TakPGPimgYCuYiRn+Bk+ZmcBXm4DG0kM6 Oa/EPB6j4JjhXF33vL0WYrULxuTmV4foQRb+U4DCX/R45tZiXjS2fSMiIHArYjwIOETH 56P/Ec1yxQJ86QZ2xETvWV4VVph+ozm49yX1ze0xcSLQjMJ/6R+3uRInlZ5l+TO5kWyB QvaQ== 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=IB0YKxiHZ8DB3Y8Qmqnlcj3VWS+ISdU+7bweNmsmUSQ=; b=BNsBv7ix8KIgRumCah3MAsVYw/EfJTn0e3Dz0RzkrCHBT8/6Wd32gmi/zWxJEjQ+VU 3DrCa+KUlA6IY0t7squItrPVfKFooYYmVu2HwPgPm70YHKH8vSGqQonKDAWnJqVqHEzB ysXZxOW1GNE37qgMEV457M089v0V9QAu6MFg1C33W/tKyUh/2wlc7RO1eoRPP6zhwlcW uPOlsrtKRqbkYBCEOBsuBwP6EW228/hpjIxPfig9Ro89DmUyfDbgRVqXZsgErJmHqLSY naBXMXzxdHxBSgC4S5XQwIXWDU7lVpQUpf6hzOqf8PF0RXrilEQtkwLjwfN4+7bNHNzk fawg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=sPZqt4RX; 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 l6-20020a170902f68600b001aafb271d16si8933482plg.461.2023.06.19.02.08.53; Mon, 19 Jun 2023 02:09: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=sPZqt4RX; 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 S230499AbjFSIz0 (ORCPT + 99 others); Mon, 19 Jun 2023 04:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbjFSIzA (ORCPT ); Mon, 19 Jun 2023 04:55:00 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29BF8D1 for ; Mon, 19 Jun 2023 01:54:17 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-970028cfb6cso538322766b.1 for ; Mon, 19 Jun 2023 01:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687164855; x=1689756855; 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=IB0YKxiHZ8DB3Y8Qmqnlcj3VWS+ISdU+7bweNmsmUSQ=; b=sPZqt4RXse4I8brwY7tIH9aa2GKODIRjMib1+lGhecwJQYLQakUQarpfazvhlelJUX H0wjc9s537G5xqRMcg5+x70EYgLj2F/lFm7Gl3sxike3v/t7LrWTmAKDu/Tb//B6THa3 ot9Vme1U8jirST3HKVhCzDLsyMdej4/tAfsSgWPdf/MNKvyifc+eHKtd6aSA3NzSRfDE MWaJb+xiZJP9GmUAkW16aKND8YQN4s5ZNNwyoizo7cCuRGzhtZbKaiGCDzv1uKWOY7/L AclpHhMBSSvO16/sVaep0inKPNP0HeLkis89rd0GPKcxhycAsIMi34oLXDkqQ33yfpya J2qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687164855; x=1689756855; 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=IB0YKxiHZ8DB3Y8Qmqnlcj3VWS+ISdU+7bweNmsmUSQ=; b=I+1MvhAfbBE5qYI4cbssAYe6ANIV3RD9ZVEtqL4ABQxX7D1ubBw0LTHW+ApzmboyD2 5yFn5UPMH6M6UceaEOKZnTgBrTj0HeYxHOHXHVehgSDl+kCCQJn2CEg8x+187elSjDPJ 7e980pVQRJ+iE/BwCSWVmJqBXSCml2/jTOqVkd75MdSNGn37dzm02MlkVQeC4L3KeuLt j2mHKzo5jxNZqNAyswmQNZNMih3/8QJKIlevy1cSE1F6Zx7Hysdka9SkwBBKPJEhZfgN TNPPx/9ZaqRJAuiTTQWVN4jpkVcabRWrjQ04DAVJe7C0KS2Seo9AKU2AIzMGp5znVIrN XWjw== X-Gm-Message-State: AC+VfDwpCjPAxoWYwYj75rEEKwnswYdM86uOQyO0ttSm8ukAVsdkyTtb 5wNcT2i0I/t/6A9b5X08EZP3gw== X-Received: by 2002:a17:907:843:b0:94f:7a8:a902 with SMTP id ww3-20020a170907084300b0094f07a8a902mr9457696ejb.14.1687164855169; Mon, 19 Jun 2023 01:54:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 01:54:14 -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, Markus Schneider-Pargmann Subject: [PATCH v5 3/8] soc: mediatek: pm-domains: Split bus_prot_mask Date: Mon, 19 Jun 2023 10:53:39 +0200 Message-Id: <20230619085344.2885311-4-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 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=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769121511637884554?= X-GMAIL-MSGID: =?utf-8?q?1769121511637884554?= bus_prot_mask is used for all operations, set clear and acknowledge. In preparation of m8365 power domain support split this one mask into two, one mask for set and clear, another one for acknowledge. Signed-off-by: Markus Schneider-Pargmann --- drivers/soc/mediatek/mtk-pm-domains.c | 24 ++++++++++++++---------- drivers/soc/mediatek/mtk-pm-domains.h | 14 ++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c index aa9ab413479e..c801fa763e89 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.c +++ b/drivers/soc/mediatek/mtk-pm-domains.c @@ -123,18 +123,20 @@ static int _scpsys_bus_protect_enable(const struct scpsys_bus_prot_data *bpd, st int i, ret; for (i = 0; i < SPM_MAX_BUS_PROT_DATA; i++) { - u32 val, mask = bpd[i].bus_prot_mask; + u32 val; + u32 set_clr_mask = bpd[i].bus_prot_set_clr_mask; + u32 sta_mask = bpd[i].bus_prot_sta_mask; - if (!mask) + if (!set_clr_mask) break; if (bpd[i].flags & BUS_PROT_REG_UPDATE) - regmap_set_bits(regmap, bpd[i].bus_prot_set, mask); + regmap_set_bits(regmap, bpd[i].bus_prot_set, set_clr_mask); else - regmap_write(regmap, bpd[i].bus_prot_set, mask); + regmap_write(regmap, bpd[i].bus_prot_set, set_clr_mask); ret = regmap_read_poll_timeout(regmap, bpd[i].bus_prot_sta, - val, (val & mask) == mask, + val, (val & sta_mask) == sta_mask, MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); if (ret) return ret; @@ -160,21 +162,23 @@ static int _scpsys_bus_protect_disable(const struct scpsys_bus_prot_data *bpd, int i, ret; for (i = SPM_MAX_BUS_PROT_DATA - 1; i >= 0; i--) { - u32 val, mask = bpd[i].bus_prot_mask; + u32 val; + u32 set_clr_mask = bpd[i].bus_prot_set_clr_mask; + u32 sta_mask = bpd[i].bus_prot_sta_mask; - if (!mask) + if (!set_clr_mask) continue; if (bpd[i].flags & BUS_PROT_REG_UPDATE) - regmap_clear_bits(regmap, bpd[i].bus_prot_clr, mask); + regmap_clear_bits(regmap, bpd[i].bus_prot_clr, set_clr_mask); else - regmap_write(regmap, bpd[i].bus_prot_clr, mask); + regmap_write(regmap, bpd[i].bus_prot_clr, set_clr_mask); if (bpd[i].flags & BUS_PROT_IGNORE_CLR_ACK) continue; ret = regmap_read_poll_timeout(regmap, bpd[i].bus_prot_sta, - val, !(val & mask), + val, !(val & sta_mask), MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); if (ret) return ret; diff --git a/drivers/soc/mediatek/mtk-pm-domains.h b/drivers/soc/mediatek/mtk-pm-domains.h index e26c8c317a6b..4b6ae56e7c95 100644 --- a/drivers/soc/mediatek/mtk-pm-domains.h +++ b/drivers/soc/mediatek/mtk-pm-domains.h @@ -47,22 +47,23 @@ enum scpsys_bus_prot_flags { BUS_PROT_IGNORE_CLR_ACK = BIT(2), }; -#define _BUS_PROT(_mask, _set, _clr, _sta, _flags) { \ - .bus_prot_mask = (_mask), \ +#define _BUS_PROT(_set_clr_mask, _set, _clr, _sta_mask, _sta, _flags) { \ + .bus_prot_set_clr_mask = (_set_clr_mask), \ .bus_prot_set = _set, \ .bus_prot_clr = _clr, \ + .bus_prot_sta_mask = (_sta_mask), \ .bus_prot_sta = _sta, \ .flags = _flags \ } #define BUS_PROT_WR(_mask, _set, _clr, _sta) \ - _BUS_PROT(_mask, _set, _clr, _sta, 0) + _BUS_PROT(_mask, _set, _clr, _mask, _sta, 0) #define BUS_PROT_WR_IGN(_mask, _set, _clr, _sta) \ - _BUS_PROT(_mask, _set, _clr, _sta, BUS_PROT_IGNORE_CLR_ACK) + _BUS_PROT(_mask, _set, _clr, _mask, _sta, BUS_PROT_IGNORE_CLR_ACK) #define BUS_PROT_UPDATE(_mask, _set, _clr, _sta) \ - _BUS_PROT(_mask, _set, _clr, _sta, BUS_PROT_REG_UPDATE) + _BUS_PROT(_mask, _set, _clr, _mask, _sta, BUS_PROT_REG_UPDATE) #define BUS_PROT_UPDATE_TOPAXI(_mask) \ BUS_PROT_UPDATE(_mask, \ @@ -71,9 +72,10 @@ enum scpsys_bus_prot_flags { INFRA_TOPAXI_PROTECTSTA1) struct scpsys_bus_prot_data { - u32 bus_prot_mask; + u32 bus_prot_set_clr_mask; u32 bus_prot_set; u32 bus_prot_clr; + u32 bus_prot_sta_mask; u32 bus_prot_sta; u32 flags; };