From nobody Thu Nov 14 17:10:09 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF1A3CD3423 for ; Mon, 18 Sep 2023 09:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241011AbjIRJjD (ORCPT ); Mon, 18 Sep 2023 05:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240956AbjIRJib (ORCPT ); Mon, 18 Sep 2023 05:38:31 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA1D12A for ; Mon, 18 Sep 2023 02:38:24 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9adb9fa7200so860869066b.0 for ; Mon, 18 Sep 2023 02:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695029902; x=1695634702; 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=xmBaiRUeRt+55ioUYPSma19exdAZQxKKsEgvUwNh0oM=; b=c3ki/w0S+YubNQMMl6TmdYKr7O5VTC/qC3iV0wB/dbkJd5Z9g2g9pNAsehpoVUqUoo zNqbD6ZpWFUJ/x1sZ/5lVDcD2fkztqZIowQsWt7h5cPnzUfV5dzlhm1YWLjWIu3gaqGF hoMfPaJe8Q8d57FhbdPD4sTdgme/S611Yz/0g2rlRqwabaKL78kBxfLMN/4bCoRnGgsY QcaU+EFkt4EW98cmIBzdChaZd1CjMyUji5myKa8XzdKIMHoZyL9aUhAWZb8ahLhTcvLT DJpILqW6TdKRdSCMPCAz7Qxeo3DXcvcqqqLXxNVk3fg+iAotuyO9d6ytZRGZHjYMAbZ8 +XlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695029902; x=1695634702; 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=xmBaiRUeRt+55ioUYPSma19exdAZQxKKsEgvUwNh0oM=; b=QG/g5RS03CqsZqcG6IDwQKYyu6SlmemrmEvNuxc8N8lJlXlP3eEIVKSSfj214lE7Dk csF4HYAJFtzwl9f6lMfMGMSFDheumHLa0SfGoGSWLqBv5oMOy5XVvNqf6KxYC7pCrF9P pKGsgWPewY8rnxz28tDtQH2JEn7i0BdN7Y8f+CRuHvJQxsVHB0UfXSFEPyzVxTguRkgI XJZKcb7Xz4+K4IDYCINF17Mi4Wugz0oDakvoZAXE/lzol5y4t6kut2s4Wo81TN8GQBJH 5XH+B1nAzDleIENifEi/nC3PKMqOsAmxlYzPGxChJEng9+YcBjJlTbuiSzjCkw9OCF7D wkGg== X-Gm-Message-State: AOJu0YzHYe1uGZS7xUqLnoIDu+UhcK4n2sCSqtIIh5APu/Tbq4YrEB/+ ix/rQmzKlrOIg5RvOA6vp4qv4A== X-Google-Smtp-Source: AGHT+IFalAgWKxViYbzYsG+o021uxkUxBvgs9JUpyWldMNZcLignfgl5INl7y8Bw5zVLkaMOU8PIpg== X-Received: by 2002:a17:906:dc8b:b0:96f:9cea:a34d with SMTP id cs11-20020a170906dc8b00b0096f9ceaa34dmr15647396ejc.21.1695029902555; Mon, 18 Sep 2023 02:38:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:38:22 -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, Markus Schneider-Pargmann Subject: [PATCH v8 4/8] soc: mediatek: pm-domains: Create bus protection operation functions Date: Mon, 18 Sep 2023 11:37:48 +0200 Message-Id: <20230918093751.1188668-5-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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Separate the register access used for bus protection enable/disable into their own functions. These will be used later for WAY_EN support. 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 | 68 +++++++++++++--------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/= mediatek/mtk-pm-domains.c index dbb268e96310..5b694fde7b56 100644 --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c @@ -118,26 +118,50 @@ static int scpsys_sram_disable(struct scpsys_domain *= pd) MTK_POLL_TIMEOUT); } =20 +static int scpsys_bus_protect_clear(const struct scpsys_bus_prot_data *bpd, + struct regmap *regmap) +{ + u32 sta_mask =3D bpd->bus_prot_sta_mask; + u32 val; + + if (bpd->flags & BUS_PROT_REG_UPDATE) + regmap_clear_bits(regmap, bpd->bus_prot_clr, bpd->bus_prot_set_clr_mask); + else + regmap_write(regmap, bpd->bus_prot_clr, bpd->bus_prot_set_clr_mask); + + if (bpd->flags & BUS_PROT_IGNORE_CLR_ACK) + return 0; + + return regmap_read_poll_timeout(regmap, bpd->bus_prot_sta, + val, !(val & sta_mask), + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); +} + +static int scpsys_bus_protect_set(const struct scpsys_bus_prot_data *bpd, + struct regmap *regmap) +{ + u32 sta_mask =3D bpd->bus_prot_sta_mask; + u32 val; + + if (bpd->flags & BUS_PROT_REG_UPDATE) + regmap_set_bits(regmap, bpd->bus_prot_set, bpd->bus_prot_set_clr_mask); + else + regmap_write(regmap, bpd->bus_prot_set, bpd->bus_prot_set_clr_mask); + + return regmap_read_poll_timeout(regmap, bpd->bus_prot_sta, + val, (val & sta_mask) =3D=3D sta_mask, + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); +} + static int _scpsys_bus_protect_enable(const struct scpsys_bus_prot_data *b= pd, struct regmap *regmap) { int i, ret; =20 for (i =3D 0; i < SPM_MAX_BUS_PROT_DATA; i++) { - u32 set_clr_mask =3D bpd[i].bus_prot_set_clr_mask; - u32 sta_mask =3D bpd[i].bus_prot_sta_mask; - u32 val; - - if (!set_clr_mask) + if (!bpd[i].bus_prot_set_clr_mask) break; =20 - if (bpd[i].flags & BUS_PROT_REG_UPDATE) - regmap_set_bits(regmap, bpd[i].bus_prot_set, set_clr_mask); - else - regmap_write(regmap, bpd[i].bus_prot_set, set_clr_mask); - - ret =3D regmap_read_poll_timeout(regmap, bpd[i].bus_prot_sta, - val, (val & sta_mask) =3D=3D sta_mask, - MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); + ret =3D scpsys_bus_protect_set(&bpd[i], regmap); if (ret) return ret; } @@ -162,24 +186,10 @@ static int _scpsys_bus_protect_disable(const struct s= cpsys_bus_prot_data *bpd, int i, ret; =20 for (i =3D SPM_MAX_BUS_PROT_DATA - 1; i >=3D 0; i--) { - u32 set_clr_mask =3D bpd[i].bus_prot_set_clr_mask; - u32 sta_mask =3D bpd[i].bus_prot_sta_mask; - u32 val; - - if (!set_clr_mask) - continue; - - if (bpd[i].flags & BUS_PROT_REG_UPDATE) - regmap_clear_bits(regmap, bpd[i].bus_prot_clr, set_clr_mask); - else - regmap_write(regmap, bpd[i].bus_prot_clr, set_clr_mask); - - if (bpd[i].flags & BUS_PROT_IGNORE_CLR_ACK) + if (!bpd[i].bus_prot_set_clr_mask) continue; =20 - ret =3D regmap_read_poll_timeout(regmap, bpd[i].bus_prot_sta, - val, !(val & sta_mask), - MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); + ret =3D scpsys_bus_protect_clear(&bpd[i], regmap); if (ret) return ret; } --=20 2.40.1