From patchwork Thu Jul 13 15:04:09 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: 119974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1902359vqm; Thu, 13 Jul 2023 08:28:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlG142NEw8hfucuFWEA4Jnk5PHsd8I/jWc69ynf1rhO/nZhQVUJuY+C7gujcSGx05ThwxBvW X-Received: by 2002:a17:906:5301:b0:988:f559:47b with SMTP id h1-20020a170906530100b00988f559047bmr1424312ejo.31.1689262115279; Thu, 13 Jul 2023 08:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689262115; cv=none; d=google.com; s=arc-20160816; b=d/7O7tChUBaGuN/HxYSXhix7UJE+MzedL5ojKcL5UbCZoxLCQ5apLrSwRIil5U5PEr xhXIV1ofm03rMPwJr4a4AbUVWh5CBlb5wLb3r5M83AOpbs4LonfSrj5Q1UfJMshDaae1 zGyZ4PTpA1d4LR0FLpTLDipLKrT7KT7cmSrMxL0nXbjt851qDhjbpnCMMNwq6DEoBObE eICqGthChrp7WRTwgPNhbSpZYJo049QkQ7CVFq0cqIO34YhFnGYVi2RMAmYIpvX8a4w9 x4M6gBRCBOe/9FQ1q/XisMeBWwW8GPJhOagOT4RFO4Htk0lt7utttIdL1N4LNMn7fL/+ aY7Q== 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=4fJVgs69a0vak6J/NLAFz8I6bUO3AICjOQJQyaRhIOA=; fh=ZkfO3kmhsON5Yb4LvDZH6rGriA0Hc3F6D4oI1q4NOLk=; b=qOiIFvPrLhHCqsX01n5wHE2fLxAp+ykRsFl9L506XrffSmBN5Vo02USzADQkoTM3+y u/EClr9c/8lZ8an1HmCwir4LQEl/ItYm5Ak2bHmTL9bwqXZuGrdt1xTTw8tAPGv3mhYa MyfkT8kWVD8ZZQDTPhkvvcJGmhznbQs46fM4xRWH4cFZ6L8TFusTVL+a8/fZOavTM+0z sZrq1lbyV4ARQ4n4NITNI7B1vMzZAmOu694tB9gGxsR9wIVc2aKyo+tQbzORa8SDpEwf srXoiX0ZMiVXH4Ra4FuRr9E9jFo7I7kNIhVZ6lZIwxGaFanVyMi7+M+KzaYq45rbC2mn RRLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=CoK5DBYM; 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 ke5-20020a17090798e500b00993150ec3c7si7018820ejc.966.2023.07.13.08.28.11; Thu, 13 Jul 2023 08:28:35 -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=CoK5DBYM; 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 S232700AbjGMPEk (ORCPT + 99 others); Thu, 13 Jul 2023 11:04:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbjGMPEc (ORCPT ); Thu, 13 Jul 2023 11:04:32 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D69106 for ; Thu, 13 Jul 2023 08:04:31 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99384a80af7so112686566b.2 for ; Thu, 13 Jul 2023 08:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1689260669; x=1691852669; 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=4fJVgs69a0vak6J/NLAFz8I6bUO3AICjOQJQyaRhIOA=; b=CoK5DBYMxx9cCxe33RN4hRbqkUEMD0yC6Pc0uLgsdZuTw1VXUUB5lxO3chLNvtVmVq Hpw6yODKgm6jKPPCPrYzIDtiLNXz/envMg2iSjME6Xm4XRcXEWUh1SgK7jlkVrMIIbBO feITJGl3v/0Li2W1lgrldmqlOBZkDg2Yqcms1MZTHYArzKzHpuj5FfM5a1x2h8V5GLRL Lt3LlWsJrkmDKqwiaDrTf4mt3R0mNa+M2OH3hpugdp36/NB/RtTeOILAwA3PWNhmTZW+ JBrNnKDtPARGAvoBcJ06+m1K3pQtyMWXprQYqcbECOkUnty6vrMzwYVNd0+MHJCG7v/B 0w6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689260669; x=1691852669; 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=4fJVgs69a0vak6J/NLAFz8I6bUO3AICjOQJQyaRhIOA=; b=FsTXTzUq+f7C0ZYnlgqA5Pj36I8cCpFs7196V1dJLH48rMDdp6Ok8FcY+gch++6PhY ubsubktFBi/qg+IAcvwjryA0zcyT6rlzYKxjf15aLF7t+k+BUdjXB8EqatwSy7vIecpx 6Py7gUwFIUQqAw8acTqzTWH3ZJoekUfPi2GFQPKeFJZTC1XK/VXoOOLx6H/awITj+XR7 cZ4js1t5D79E+AoTF7acnB6glViXOizduhNAl3r91w3fG2G49vzXHa/e9k2mhydqapac HHmrcLfwBZOB1T0AxYOkHg5Cnrpm4l/I7m+R9kxSwDSj1MIEJJ+mZF/PGibsU2eNVgK3 19mg== X-Gm-Message-State: ABy/qLYhvzUjSCP5FtGvEM4vmAoVGnTpWzC51uSG33UMquIJv75E4/3U CbRWX8xumFypSCsquKyRN+8p8w== X-Received: by 2002:a17:907:7656:b0:993:c267:3612 with SMTP id kj22-20020a170907765600b00993c2673612mr1508568ejc.12.1689260669469; Thu, 13 Jul 2023 08:04:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 08:04:29 -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 , Alexandre Mergnat Subject: [PATCH v7 3/8] soc: mediatek: pm-domains: Split bus_prot_mask Date: Thu, 13 Jul 2023 17:04:09 +0200 Message-Id: <20230713150414.891893-4-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=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: INBOX X-GMAIL-THRID: 1771319711408084890 X-GMAIL-MSGID: 1771319711408084890 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat Tested-by: Alexandre Mergnat --- 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..a2c8f5313124 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 set_clr_mask = bpd[i].bus_prot_set_clr_mask; + u32 sta_mask = bpd[i].bus_prot_sta_mask; + u32 val; - 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 set_clr_mask = bpd[i].bus_prot_set_clr_mask; + u32 sta_mask = bpd[i].bus_prot_sta_mask; + u32 val; - 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 d8c0c299dd45..4c3ab72a907b 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; u8 flags; };