From: Srinivas Kandagatla <srini@kernel.org>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
arnd@arndb.de, gregkh@linuxfoundation.org, srini@kernel.org,
vkoul@kernel.org, neil.armstrong@linaro.org, sre@kernel.org,
sboyd@kernel.org, krzk@kernel.org,
dmitry.baryshkov@oss.qualcomm.com, quic_wcheng@quicinc.com,
melody.olvera@oss.qualcomm.com, quic_nsekar@quicinc.com,
ivo.ivanov.ivanov1@gmail.com, abelvesa@kernel.org,
luca.weiss@fairphone.com, konrad.dybcio@oss.qualcomm.com,
mitltlatltl@gmail.com, krishna.kurapati@oss.qualcomm.com,
linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
linux-pm@vger.kernel.org, kernel@collabora.com
Subject: Re: [PATCH v8 05/10] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add()
Date: Wed, 11 Mar 2026 07:42:08 +0000 [thread overview]
Message-ID: <604e98e6-dd40-4b44-92c4-5164c02cb996@kernel.org> (raw)
In-Reply-To: <20260114092742.13231-6-angelogioacchino.delregno@collabora.com>
On 1/14/26 9:27 AM, AngeloGioacchino Del Regno wrote:
> Some Qualcomm PMICs integrate a SDAM device, internally located in
> a specific address range reachable through SPMI communication.
>
> Instead of using the parent SPMI device (the main PMIC) as a kind
> of syscon in this driver, register a new SPMI sub-device for SDAM
> and initialize its own regmap with this sub-device's specific base
> address, retrieved from the devicetree.
>
> This allows to stop manually adding the register base address to
> every R/W call in this driver, as this can be, and is now, handled
> by the regmap API instead.
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
Am not sure what is the merge strategy, if you want me to take it via
nvmem tree, please let me know otherwise
Acked-by: Srinivas Kandagatla <srini@kernel.org>
--srini
> drivers/nvmem/Kconfig | 1 +
> drivers/nvmem/qcom-spmi-sdam.c | 38 +++++++++++++++++++++++-----------
> 2 files changed, 27 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index bf47a982cf62..5e924c869e77 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -368,6 +368,7 @@ config NVMEM_SNVS_LPGPR
> config NVMEM_SPMI_SDAM
> tristate "SPMI SDAM Support"
> depends on SPMI
> + select REGMAP_SPMI
> help
> This driver supports the Shared Direct Access Memory Module on
> Qualcomm Technologies, Inc. PMICs. It provides the clients
> diff --git a/drivers/nvmem/qcom-spmi-sdam.c b/drivers/nvmem/qcom-spmi-sdam.c
> index 4f1cca6eab71..4974105dd963 100644
> --- a/drivers/nvmem/qcom-spmi-sdam.c
> +++ b/drivers/nvmem/qcom-spmi-sdam.c
> @@ -9,6 +9,7 @@
> #include <linux/nvmem-provider.h>
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> +#include <linux/spmi.h>
>
> #define SDAM_MEM_START 0x40
> #define REGISTER_MAP_ID 0x40
> @@ -20,7 +21,6 @@
> struct sdam_chip {
> struct regmap *regmap;
> struct nvmem_config sdam_config;
> - unsigned int base;
> unsigned int size;
> };
>
> @@ -73,7 +73,7 @@ static int sdam_read(void *priv, unsigned int offset, void *val,
> return -EINVAL;
> }
>
> - rc = regmap_bulk_read(sdam->regmap, sdam->base + offset, val, bytes);
> + rc = regmap_bulk_read(sdam->regmap, offset, val, bytes);
> if (rc < 0)
> dev_err(dev, "Failed to read SDAM offset %#x len=%zd, rc=%d\n",
> offset, bytes, rc);
> @@ -100,7 +100,7 @@ static int sdam_write(void *priv, unsigned int offset, void *val,
> return -EINVAL;
> }
>
> - rc = regmap_bulk_write(sdam->regmap, sdam->base + offset, val, bytes);
> + rc = regmap_bulk_write(sdam->regmap, offset, val, bytes);
> if (rc < 0)
> dev_err(dev, "Failed to write SDAM offset %#x len=%zd, rc=%d\n",
> offset, bytes, rc);
> @@ -110,8 +110,17 @@ static int sdam_write(void *priv, unsigned int offset, void *val,
>
> static int sdam_probe(struct platform_device *pdev)
> {
> + struct regmap_config sdam_regmap_config = {
> + .reg_bits = 16,
> + .val_bits = 8,
> + .max_register = 0xff,
> + .fast_io = true,
> + };
> struct sdam_chip *sdam;
> struct nvmem_device *nvmem;
> + struct spmi_device *sparent;
> + struct spmi_subdevice *sub_sdev;
> + struct device *dev = &pdev->dev;
> unsigned int val;
> int rc;
>
> @@ -119,19 +128,23 @@ static int sdam_probe(struct platform_device *pdev)
> if (!sdam)
> return -ENOMEM;
>
> - sdam->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> - if (!sdam->regmap) {
> - dev_err(&pdev->dev, "Failed to get regmap handle\n");
> - return -ENXIO;
> - }
> + sparent = to_spmi_device(dev->parent);
> + sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
> + if (IS_ERR(sub_sdev))
> + return PTR_ERR(sub_sdev);
>
> - rc = of_property_read_u32(pdev->dev.of_node, "reg", &sdam->base);
> + rc = device_property_read_u32(dev, "reg", &sdam_regmap_config.reg_base);
> if (rc < 0) {
> - dev_err(&pdev->dev, "Failed to get SDAM base, rc=%d\n", rc);
> + dev_err(dev, "Failed to get SDAM base, rc=%d\n", rc);
> return -EINVAL;
> }
>
> - rc = regmap_read(sdam->regmap, sdam->base + SDAM_SIZE, &val);
> + sdam->regmap = devm_regmap_init_spmi_ext(&sub_sdev->sdev, &sdam_regmap_config);
> + if (IS_ERR(sdam->regmap))
> + return dev_err_probe(dev, PTR_ERR(sdam->regmap),
> + "Failed to get regmap handle\n");
> +
> + rc = regmap_read(sdam->regmap, SDAM_SIZE, &val);
> if (rc < 0) {
> dev_err(&pdev->dev, "Failed to read SDAM_SIZE rc=%d\n", rc);
> return -EINVAL;
> @@ -159,7 +172,7 @@ static int sdam_probe(struct platform_device *pdev)
> }
> dev_dbg(&pdev->dev,
> "SDAM base=%#x size=%u registered successfully\n",
> - sdam->base, sdam->size);
> + sdam_regmap_config.reg_base, sdam->size);
>
> return 0;
> }
> @@ -181,3 +194,4 @@ module_platform_driver(sdam_driver);
>
> MODULE_DESCRIPTION("QCOM SPMI SDAM driver");
> MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS("SPMI");
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-03-11 7:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 9:27 [PATCH v8 00/10] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-01-14 9:27 ` [PATCH v8 01/10] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-01-16 2:03 ` Stephen Boyd
2026-01-14 9:27 ` [PATCH v8 02/10] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-01-16 2:03 ` Stephen Boyd
2026-01-14 9:27 ` [PATCH v8 03/10] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-01-16 2:03 ` Stephen Boyd
2026-01-14 9:27 ` [PATCH v8 04/10] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-01-16 2:08 ` Stephen Boyd
2026-01-14 9:27 ` [PATCH v8 05/10] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-03-11 7:42 ` Srinivas Kandagatla [this message]
2026-01-14 9:27 ` [PATCH v8 06/10] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-01-14 9:27 ` [PATCH v8 07/10] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-01-21 7:39 ` Vinod Koul
2026-01-14 9:27 ` [PATCH v8 08/10] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-01-14 9:27 ` [PATCH v8 09/10] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-01-14 9:27 ` [PATCH v8 10/10] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
2026-01-14 9:43 ` [PATCH v8 00/10] SPMI: Implement sub-devices and migrate drivers Andy Shevchenko
2026-01-14 9:46 ` Andy Shevchenko
2026-01-21 11:00 ` AngeloGioacchino Del Regno
2026-03-05 14:32 ` AngeloGioacchino Del Regno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=604e98e6-dd40-4b44-92c4-5164c02cb996@kernel.org \
--to=srini@kernel.org \
--cc=abelvesa@kernel.org \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arnd@arndb.de \
--cc=dlechner@baylibre.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=ivo.ivanov.ivanov1@gmail.com \
--cc=jic23@kernel.org \
--cc=kernel@collabora.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=krishna.kurapati@oss.qualcomm.com \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=luca.weiss@fairphone.com \
--cc=melody.olvera@oss.qualcomm.com \
--cc=mitltlatltl@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@analog.com \
--cc=quic_nsekar@quicinc.com \
--cc=quic_wcheng@quicinc.com \
--cc=sboyd@kernel.org \
--cc=sre@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox