From nobody Mon Feb 9 17:58:28 2026 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) (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 9D92C33506D for ; Thu, 5 Feb 2026 21:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770327756; cv=none; b=A6oopVme6tLdQxZKDAHOgfarNL6QnCJRmsxoNld5fy/DFT1z6Fw53EJjq1dMQwzl6eUId5RXRHJUjCMOI/kBCBo4nVYxON64bPTvhxiISmnNx49We1m0kL+oAltxHGgHBeJvNnmLTJBQK+2Q17LfolxAFokAfzowQdV3npy7kgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770327756; c=relaxed/simple; bh=uB20qy/vVXEtCtRT2uVJX5h7neGT+7RwSgorsCbFxOI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jvNM9mBtQrOTS07riZ1TJ3RAxRvPovk4B6l1QG1C88NFP2Gn2FQMTTFaTqQxoa292qFSOy/Le7Zm9ZA70495nnrjRoYo6yQ01Fzslkz+2SRg5VFWXsliG4qEbdq0rp0VsLgqiqmLrWQpjJ0EcT+cyV7e2n4UOs/5XJQmcpCWUKE= 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=RueCvCdM; arc=none smtp.client-ip=209.85.218.67 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="RueCvCdM" Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-b885e8c679bso3551766b.1 for ; Thu, 05 Feb 2026 13:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1770327755; x=1770932555; 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=BCXzqfHYm7jOM4K764nK1wT55TlXGLUYpjCnio4Cc9c=; b=RueCvCdMhoeKF06r+/Cy/8n7XV0b0lzrBM70SsxeO1PWJluBXcbvZsC5HwJj/gX6zT EcriDYM4RapbIsO7jzYZWcal5OTn4+TT4oI5WLRNGW7ecZU1SQC4wjjyAgxHUYwJQQsw mQWS0YHpZu7kn/zC8G+CUQ6/vItV1fDNMeX0pvDzI+IF61DmbMQPs2+pky6b81LjdzmF NV3UaFLCIzqxXkkBQD9gGTcoBLpA0gE/m+VsITCvoDP716cuF7K7ZQiDJiYHk8l9urhP OrTeiOrB5gWZ8IVd/Z5qDd08bAqMXohHOYJuH3y3eH3nQH7T+zm2CsKcwEoTNz92DDm/ Bkdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770327755; x=1770932555; 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=BCXzqfHYm7jOM4K764nK1wT55TlXGLUYpjCnio4Cc9c=; b=h9GlXbC7riIPpDQ9rAu318z3x+NMBvxJE01iLwGWC4AJiv2foR6mtwY/Y+HjSw270o O58bzFzoOF+m7X3U1WQyfKfFq4twiqAdHG6VR9yPLuv2vqalyN6EhU85g88dTvzpZ0Y1 LQDUo4V5S1GBA+8MDnArS+/oyhKPObhzFbJPxwH07m6X3u59AuwasbMML6TSvbykDH7k 6wmGpGikCjfrOGvjVePLTtYlvE7/k8ubn1lDLaDj8PygNrAxrCvWMq9Iomw5UKimhiP5 tdTELdQzTFg/IlnWrxcOU56niBqCNWHCwATfHJ7sE7W7MJmId1PuVoXuPvQh4WPP+Mwm axhA== X-Forwarded-Encrypted: i=1; AJvYcCVsTdLDExgoosONmyVHc7OmPn5BkaoJbOBlV2ZmMsCCad6kPKVHrqf2HMW5uoV2j5hYMFwiBSRfn7Tjt7M=@vger.kernel.org X-Gm-Message-State: AOJu0YyEwajRva+pUvfyW3JWeoIilY5NjGGm5SrnteYhmbmiOSyT8uif b0e0vn1+ozp5p5ObM5JHzk5mZjiYWfXl4WaeVD9v/zVqh501BMGIzQbswcT+s9EhhaA= X-Gm-Gg: AZuq6aL9SY9GsW9Q8UkNFOxucmmtKuEwaiI3e912n5d1Cu7rIbBZu/bT1bCKxZps5Az jdQHhauiyId4BUKPLCoo6/Z2HEiq9L2DjmR38PvcdLZWWShjVGr3yh8HKO588Zw6SEQEoDbMPEj H5AUJNxGLQ8WxTjFORLlqj3t4revS7XsZzsysGwl+yeeUq2/id6sImLlmWZkCK2pKBDW1K6o7Lp gHa5+6qoY8WaDIJn7ES3lDemQJjw9XY2B2XgPBoCXskSGlN16h8gx+D9PevlwQjIMuddiROhyZ9 Yb09nO81QAiz0da62k9N800FaZkjhIOglWh37TTHre+G9LvUCk2MAI6eutQzdY1sfDh04MihokG GO/8JJ1NwtBdlwcIX3W3a8zYD5X1Fj4DMaXi9dVBfl/E5ylIafWzoLVQX+/drYC1spAenKWU7OV wX5MQjm9QGmg4gHmzh+ERGLWO2wKdbhU/LW0Ecmc1wu1scT7u43PgmqIzGzTngEJmlbHZdg8xrY D8+eA== X-Received: by 2002:a17:907:9717:b0:b87:65c5:602f with SMTP id a640c23a62f3a-b8edf2f9bf5mr26839566b.34.1770327754876; Thu, 05 Feb 2026 13:42:34 -0800 (PST) Received: from puffmais2.c.googlers.com (244.175.141.34.bc.googleusercontent.com. [34.141.175.244]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8eda7a0074sm21859966b.18.2026.02.05.13.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 13:42:34 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Thu, 05 Feb 2026 21:42:33 +0000 Subject: [PATCH v5 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: <20260205-gs101-pd-v5-5-ede49cdb57a6@linaro.org> References: <20260205-gs101-pd-v5-0-ede49cdb57a6@linaro.org> In-Reply-To: <20260205-gs101-pd-v5-0-ede49cdb57a6@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.2 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 --- 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 5c3aa898308793d424fb761c58ca01ba2580aeb5..3bcba7d38ac1572ef4bc2f4052c= 904dd6c4a7bfd 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.rc2.204.g2597b5adb4-goog