From nobody Thu Apr 9 18:46:41 2026 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4F0F37D124 for ; Fri, 6 Mar 2026 10:29:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772793004; cv=none; b=J8S0QcC46IsvbFchzza68msUR5t8rqJ2rggZxZ68H1F9uJVC2EA6jyoeVKOU+2FNiN3ZxDOwli8maXh8Pg2wGkE2X49aez9Rj5WrmSjoAP6F78R2k2I12QnifWJqUEJrDQA6nHgkWvWpTvAlxpvil3hzh8ug7wXszRUsWl1HXIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772793004; c=relaxed/simple; bh=F1S+e9a469QdSHta0n9ziXmHQDihxHrwcFmPJNecLNg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q4mLlg6PUoFppXviNZhCpwp6z7chvV8JRfjZPfRLUuKxJDyQpxBZ/aTum8sXt+JXmM+pnaMBoWU1vKN7UjkX62TZa8Vz3VPOcG6rjG0ZxNsC+wGBxyoPOAUGuQlPIzjSuKzdca2iNdeExnr9dfTkomHcuFDeMydl+hi18LTa714= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kzh62mRL; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kzh62mRL" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-65f94011dfaso2798860a12.0 for ; Fri, 06 Mar 2026 02:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772792998; x=1773397798; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aJ65cMxmtD9hm2QF0vSs9PHPLSm4kdpoTVF35SUjEBw=; b=kzh62mRLtj6dodZ1vZhlgSbPGX37bmVRJ9S4aJLf5OcY0XT/yIq0Zv7M7nZUkUeq9d oL55HcptLpcKXkXX8v+PKcYlcGUj8d4Jc32Vkp6RnE0pUdyK/ClDhQrTlqeCrlBnlg5k NGJ8mRJGgbD7kua/AVxRU/J2CiEK/bD9umXzc4qLT05YyZLOdI2b/vpFblpofpOb5ss7 TzF8Yso2GYDwZvgJYBM//LWySOJJGJynHBVfzOEkko/l5gdQjsJWeXiOOBVu0iE0t3P2 7WKDx57Xu3RrvfLL6JPRCiGexNdIkK3j/duNBN1Lk9xHr4278wtjz1mO+HX7bz7DbP6z 0Saw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772792998; x=1773397798; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aJ65cMxmtD9hm2QF0vSs9PHPLSm4kdpoTVF35SUjEBw=; b=ATHrGu0jgtFLKxmKhhD808pwYijjOTUit6GxmLNpXWo7s6xXEE9vGeCA9hTw1z3W5l E56GQ0hS4ZplK5gBOEzDi79uRzgJPfLTzazRgTHEVI0pZh2ROU0ragvZnE462oidLnTN 9JU2k0/kUtNZtroVI792l+3in9xSMPWFM6ibGD6WlcVy0g4uXLSM4WWyiyB7S6M1/c0z DOOa0yJAp/S4WIWRcUOF7obXUS0Rje7jwsWLS/tM5ulODi5rc36j456F44DXaXo2Sniy pZXLKVEqCAQQL5BYGPquxPxGaH5mocThrGFIhfDZNVb/p2cVcXOEYKS8/d1yWVlcZ1uN 13oQ== X-Forwarded-Encrypted: i=1; AJvYcCWKWg9vD7EstcE+ZEZ55L7BmFGHy+hTQtmR3HjaIbXXYkGYuCrjfDpE2gmq2F8o425AFi1bqB5hdVIHJM8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/k7PAFF9ztxRXCOJyOrXUOJFxAay2vCXZslZVzPK8hQdEtU2P mY7LiZnamyH9+/IVlYB3D6dB2p+LF825H8pyyUbZbqMqcgmEmrH78DxNc9A0bRlTRC0= X-Gm-Gg: ATEYQzxujwMmZd9H201N0FU0N+AnuA9slmFAVcnuKK3wFQovkMq8M1sEhiylqu0wKOO oeShugD6+vHyVDselM0XLwVnDFzlcfnLS2vDVqQlMWoJzYSD2a0J+viPEuykJrmXhCqLFtzG8c+ jNgfUAp21vh2KrxI59k6m/Xha5FNkcT3Sl1PYYsrQN4yndB/gSPb7puP382Z3e2u5QFyzzg4Np4 FWKLJpR8s6rGVTHs1hbGDdeJJk0+Un+TJ7z4Onlvz0oUtjqaH8TG/Sac1Gv2OaVkJyEssrlC4NS rV5eFgsiNom3P8aLuDhXzY5Sp4nfEctW8+UznKE5pgQ5ysznMA9gkyXe2ZKThSujJnJVbvJdSdX 5u5iX77ugby10zMjrQjZbMlKw07DVOVku6Cw+2x7n70l4O5iRZfwWEA2KIB/vd5T1i8OjRbO1JT w0TfFa9B/4FGik58wddSWViNgm7TnTlC7Em1iQjJ7PL6jhGTlTIewe4ADoVhpJhNy0J2uY0Cv4M 5AVG3H3cIhfBJn+1H26NhHxsg== X-Received: by 2002:a17:907:6ea6:b0:b86:fca7:3dc2 with SMTP id a640c23a62f3a-b942da71fb2mr86532966b.10.1772792997560; Fri, 06 Mar 2026 02:29:57 -0800 (PST) Received: from puffmais2.c.googlers.com (221.210.91.34.bc.googleusercontent.com. [34.91.210.221]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b942ef8c95csm42907266b.21.2026.03.06.02.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 02:29:57 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 06 Mar 2026 10:29:56 +0000 Subject: [PATCH v7 05/10] pmdomain: samsung: convert to using regmap Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260306-gs101-pd-v7-5-03f7c7965ba5@linaro.org> References: <20260306-gs101-pd-v7-0-03f7c7965ba5@linaro.org> In-Reply-To: <20260306-gs101-pd-v7-0-03f7c7965ba5@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Rob Herring , Conor Dooley , Krzysztof Kozlowski , Ulf Hansson , Liam Girdwood , Mark Brown Cc: Peter Griffin , Tudor Ambarus , Juan Yescas , Will McVicker , kernel-team@android.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= , Marek Szyprowski X-Mailer: b4 0.14.3 On platforms such as Google gs101, direct mmio register access to the PMU registers doesn't necessarily work and access must happen via a regmap created by the PMU driver instead. In preparation for supporting such SoCs convert the existing mmio accesses to using a regmap wrapper. With this change in place, a follow-up patch can update the driver to optionally acquire the PMU-created regmap without having to change the rest of the code. Tested-by: Marek Szyprowski Signed-off-by: Andr=C3=A9 Draszik Reviewed-by: Peter Griffin --- There is one checkpatch warning, relating to the non-const regmap_config. It can not easily be made const at this stage, but a follow-up patch allows us to make it const and the warning will go away anyway. v4: - rework the loop in exynos_pd_power() slightly, to not return 0 early to allow more code to be run after pd on/off register write without changing the loop again, required for gs101. - add error message in case first regmap write in exynos_pd_power() fails --- drivers/pmdomain/samsung/exynos-pm-domains.c | 83 +++++++++++++++++++++---= ---- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomai= n/samsung/exynos-pm-domains.c index 5c3aa8983087..3bcba7d38ac1 100644 --- a/drivers/pmdomain/samsung/exynos-pm-domains.c +++ b/drivers/pmdomain/samsung/exynos-pm-domains.c @@ -9,15 +9,14 @@ // conjunction with runtime-pm. Support for both device-tree and non-devic= e-tree // based power domain support is included. =20 -#include #include #include #include #include #include #include -#include #include +#include =20 struct exynos_pm_domain_config { /* Value for LOCAL_PWR_CFG and STATUS fields for each domain */ @@ -28,7 +27,7 @@ struct exynos_pm_domain_config { * Exynos specific wrapper around the generic power domain */ struct exynos_pm_domain { - void __iomem *base; + struct regmap *regmap; struct generic_pm_domain pd; u32 local_pwr_cfg; }; @@ -36,31 +35,42 @@ struct exynos_pm_domain { static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) { struct exynos_pm_domain *pd; - void __iomem *base; u32 timeout, pwr; - char *op; + int err; =20 pd =3D container_of(domain, struct exynos_pm_domain, pd); - base =3D pd->base; =20 pwr =3D power_on ? pd->local_pwr_cfg : 0; - writel_relaxed(pwr, base); + err =3D regmap_write(pd->regmap, 0, pwr); + if (err) { + pr_err("Regmap write for power domain %s %sable failed: %d\n", + domain->name, power_on ? "en" : "dis", err); + return err; + } =20 /* Wait max 1ms */ timeout =3D 10; - - while ((readl_relaxed(base + 0x4) & pd->local_pwr_cfg) !=3D pwr) { - if (!timeout) { - op =3D (power_on) ? "enable" : "disable"; - pr_err("Power domain %s %s failed\n", domain->name, op); - return -ETIMEDOUT; + while (timeout-- > 0) { + unsigned int val; + + err =3D regmap_read(pd->regmap, 0x4, &val); + if (err || ((val & pd->local_pwr_cfg) !=3D pwr)) { + cpu_relax(); + usleep_range(80, 100); + continue; } - timeout--; - cpu_relax(); - usleep_range(80, 100); + + break; } =20 - return 0; + if (!timeout && !err) + /* Only return timeout if no other error also occurred. */ + err =3D -ETIMEDOUT; + if (err) + pr_err("Power domain %s %sable failed: %d\n", domain->name, + power_on ? "en" : "dis", err); + + return err; } =20 static int exynos_pd_power_on(struct generic_pm_domain *domain) @@ -109,8 +119,18 @@ static int exynos_pd_probe(struct platform_device *pde= v) struct device_node *np =3D dev->of_node; struct of_phandle_args child, parent; struct exynos_pm_domain *pd; + struct resource *res; + void __iomem *base; + unsigned int val; int on, ret; =20 + struct regmap_config reg_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, + .use_relaxed_mmio =3D true, + }; + pm_domain_cfg =3D of_device_get_match_data(dev); pd =3D devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); if (!pd) @@ -120,9 +140,26 @@ static int exynos_pd_probe(struct platform_device *pde= v) if (!pd->pd.name) return -ENOMEM; =20 - pd->base =3D of_iomap(np, 0); - if (!pd->base) - return -ENODEV; + /* + * The resource typically points into the address space of the PMU. + * Therefore, avoid using devm_platform_get_and_ioremap_resource() and + * instead use platform_get_resource() and devm_ioremap() to avoid + * conflicts due to address space overlap. + */ + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return dev_err_probe(dev, -ENXIO, "missing IO resources"); + + base =3D devm_ioremap(dev, res->start, resource_size(res)); + if (!base) + return dev_err_probe(dev, -ENOMEM, + "failed to ioremap PMU registers"); + + reg_config.max_register =3D resource_size(res) - reg_config.reg_stride; + pd->regmap =3D devm_regmap_init_mmio(dev, base, ®_config); + if (IS_ERR(pd->regmap)) + return dev_err_probe(dev, PTR_ERR(base), + "failed to init regmap"); =20 pd->pd.power_off =3D exynos_pd_power_off; pd->pd.power_on =3D exynos_pd_power_on; @@ -137,7 +174,11 @@ static int exynos_pd_probe(struct platform_device *pde= v) of_device_is_compatible(np, "samsung,exynos4210-pd")) exynos_pd_power_off(&pd->pd); =20 - on =3D readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg; + ret =3D regmap_read(pd->regmap, 0x4, &val); + if (ret) + return dev_err_probe(dev, ret, "failed to read status"); + + on =3D val & pd->local_pwr_cfg; =20 pm_genpd_init(&pd->pd, NULL, !on); ret =3D of_genpd_add_provider_simple(np, &pd->pd); --=20 2.53.0.473.g4a7958ca14-goog