* [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
@ 2025-07-03 18:35 Rob Herring (Arm)
2025-07-04 2:46 ` Tzung-Bi Shih
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2025-07-03 18:35 UTC (permalink / raw)
To: Cheng-Yi Chiang, Tzung-Bi Shih, Guenter Roeck, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, Benson Leung,
Peter Ujfalusi, Bard Liao, Ranjani Sridharan, Daniel Baluta,
Kai Vehmanen, Pierre-Louis Bossart, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: chrome-platform, linux-sound, linux-kernel, sound-open-firmware,
imx, linux-arm-kernel, linux-mediatek
Use the newly added of_reserved_mem_region_to_resource() function to
handle "memory-region" properties.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
sound/soc/codecs/cros_ec_codec.c | 30 ++++++++++-----------
sound/soc/sof/imx/imx-common.c | 36 +++++---------------------
sound/soc/sof/mediatek/mt8186/mt8186.c | 11 +-------
sound/soc/sof/mediatek/mt8195/mt8195.c | 11 +-------
4 files changed, 22 insertions(+), 66 deletions(-)
diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
index 571222ec520c..937c8cec682a 100644
--- a/sound/soc/codecs/cros_ec_codec.c
+++ b/sound/soc/codecs/cros_ec_codec.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_reserved_mem.h>
#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_data/cros_ec_proto.h>
#include <linux/platform_device.h>
@@ -961,7 +962,6 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)
struct ec_response_ec_codec_get_capabilities r;
int ret;
#ifdef CONFIG_OF
- struct device_node *node;
struct resource res;
u64 ec_shm_size;
const __be32 *regaddr_p;
@@ -981,22 +981,18 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)
priv->ec_shm_addr, priv->ec_shm_len);
}
- node = of_parse_phandle(dev->of_node, "memory-region", 0);
- if (node) {
- ret = of_address_to_resource(node, 0, &res);
- if (!ret) {
- priv->ap_shm_phys_addr = res.start;
- priv->ap_shm_len = resource_size(&res);
- priv->ap_shm_addr =
- (uint64_t)(uintptr_t)devm_ioremap_wc(
- dev, priv->ap_shm_phys_addr,
- priv->ap_shm_len);
- priv->ap_shm_last_alloc = priv->ap_shm_phys_addr;
-
- dev_dbg(dev, "ap_shm_phys_addr=%#llx len=%#x\n",
- priv->ap_shm_phys_addr, priv->ap_shm_len);
- }
- of_node_put(node);
+ ret = of_reserved_mem_region_to_resource(dev->of_node, 0, &res);
+ if (!ret) {
+ priv->ap_shm_phys_addr = res.start;
+ priv->ap_shm_len = resource_size(&res);
+ priv->ap_shm_addr =
+ (uint64_t)(uintptr_t)devm_ioremap_wc(
+ dev, priv->ap_shm_phys_addr,
+ priv->ap_shm_len);
+ priv->ap_shm_last_alloc = priv->ap_shm_phys_addr;
+
+ dev_dbg(dev, "ap_shm_phys_addr=%#llx len=%#x\n",
+ priv->ap_shm_phys_addr, priv->ap_shm_len);
}
#endif
diff --git a/sound/soc/sof/imx/imx-common.c b/sound/soc/sof/imx/imx-common.c
index 62bf707aa909..f00b381cec3b 100644
--- a/sound/soc/sof/imx/imx-common.c
+++ b/sound/soc/sof/imx/imx-common.c
@@ -282,11 +282,8 @@ static int imx_region_name_to_blk_type(const char *region_name)
static int imx_parse_ioremap_memory(struct snd_sof_dev *sdev)
{
const struct imx_chip_info *chip_info;
- struct reserved_mem *reserved;
struct platform_device *pdev;
- struct device_node *res_np;
- phys_addr_t base, size;
- struct resource *res;
+ struct resource *res, _res;
int i, blk_type, ret;
pdev = to_platform_device(sdev->dev);
@@ -307,37 +304,18 @@ static int imx_parse_ioremap_memory(struct snd_sof_dev *sdev)
"failed to fetch %s resource\n",
chip_info->memory[i].name);
- base = res->start;
- size = resource_size(res);
} else {
- ret = of_property_match_string(pdev->dev.of_node,
- "memory-region-names",
- chip_info->memory[i].name);
+ ret = of_reserved_mem_region_to_resource_byname(pdev->dev.of_node,
+ chip_info->memory[i].name,
+ &_res);
if (ret < 0)
return dev_err_probe(sdev->dev, ret,
- "no valid index for %s\n",
+ "no valid entry for %s\n",
chip_info->memory[i].name);
-
- res_np = of_parse_phandle(pdev->dev.of_node,
- "memory-region",
- ret);
- if (!res_np)
- return dev_err_probe(sdev->dev, -ENODEV,
- "failed to parse phandle %s\n",
- chip_info->memory[i].name);
-
- reserved = of_reserved_mem_lookup(res_np);
- of_node_put(res_np);
- if (!reserved)
- return dev_err_probe(sdev->dev, -ENODEV,
- "failed to get %s reserved\n",
- chip_info->memory[i].name);
-
- base = reserved->base;
- size = reserved->size;
+ res = &_res;
}
- sdev->bar[blk_type] = devm_ioremap(sdev->dev, base, size);
+ sdev->bar[blk_type] = devm_ioremap_resource(sdev->dev, res);
if (!sdev->bar[blk_type])
return dev_err_probe(sdev->dev,
-ENOMEM,
diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c
index 7ff080452cbe..c1bea967737d 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -12,7 +12,6 @@
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/io.h>
-#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
@@ -46,7 +45,6 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
{
struct resource *mmio;
struct resource res;
- struct device_node *mem_region;
struct device *dev = &pdev->dev;
struct mtk_adsp_chip_info *adsp = data;
int ret;
@@ -57,14 +55,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
return ret;
}
- mem_region = of_parse_phandle(dev->of_node, "memory-region", 1);
- if (!mem_region) {
- dev_err(dev, "no memory-region sysmem phandle\n");
- return -ENODEV;
- }
-
- ret = of_address_to_resource(mem_region, 0, &res);
- of_node_put(mem_region);
+ ret = of_reserved_mem_region_to_resource(dev->of_node, 1, &res);
if (ret) {
dev_err(dev, "of_address_to_resource sysmem failed\n");
return ret;
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index 3b3582d74510..4d6e9300a9c0 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -12,7 +12,6 @@
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/io.h>
-#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
@@ -46,7 +45,6 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
{
struct resource *mmio;
struct resource res;
- struct device_node *mem_region;
struct device *dev = &pdev->dev;
struct mtk_adsp_chip_info *adsp = data;
int ret;
@@ -57,14 +55,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
return ret;
}
- mem_region = of_parse_phandle(dev->of_node, "memory-region", 1);
- if (!mem_region) {
- dev_err(dev, "no memory-region sysmem phandle\n");
- return -ENODEV;
- }
-
- ret = of_address_to_resource(mem_region, 0, &res);
- of_node_put(mem_region);
+ ret = of_reserved_mem_region_to_resource(dev->of_node, 1, &res);
if (ret) {
dev_err(dev, "of_address_to_resource sysmem failed\n");
return ret;
--
2.47.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
2025-07-03 18:35 [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region" Rob Herring (Arm)
@ 2025-07-04 2:46 ` Tzung-Bi Shih
2025-07-04 3:39 ` Cheng-yi Chiang
2025-07-04 15:57 ` Mark Brown
2025-07-07 9:37 ` AngeloGioacchino Del Regno
2 siblings, 1 reply; 5+ messages in thread
From: Tzung-Bi Shih @ 2025-07-04 2:46 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Cheng-Yi Chiang, Guenter Roeck, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Benson Leung, Peter Ujfalusi,
Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
Pierre-Louis Bossart, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Matthias Brugger,
AngeloGioacchino Del Regno, chrome-platform, linux-sound,
linux-kernel, sound-open-firmware, imx, linux-arm-kernel,
linux-mediatek
On Thu, Jul 03, 2025 at 01:35:21PM -0500, Rob Herring (Arm) wrote:
> Use the newly added of_reserved_mem_region_to_resource() function to
> handle "memory-region" properties.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
2025-07-04 2:46 ` Tzung-Bi Shih
@ 2025-07-04 3:39 ` Cheng-yi Chiang
0 siblings, 0 replies; 5+ messages in thread
From: Cheng-yi Chiang @ 2025-07-04 3:39 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: Rob Herring (Arm), Guenter Roeck, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Benson Leung, Peter Ujfalusi,
Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
Pierre-Louis Bossart, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Matthias Brugger,
AngeloGioacchino Del Regno, chrome-platform, linux-sound,
linux-kernel, sound-open-firmware, imx, linux-arm-kernel,
linux-mediatek
On Fri, Jul 4, 2025 at 10:46 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> On Thu, Jul 03, 2025 at 01:35:21PM -0500, Rob Herring (Arm) wrote:
> > Use the newly added of_reserved_mem_region_to_resource() function to
> > handle "memory-region" properties.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
>
> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Thanks for the patch!
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
2025-07-03 18:35 [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region" Rob Herring (Arm)
2025-07-04 2:46 ` Tzung-Bi Shih
@ 2025-07-04 15:57 ` Mark Brown
2025-07-07 9:37 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-07-04 15:57 UTC (permalink / raw)
To: Cheng-Yi Chiang, Tzung-Bi Shih, Guenter Roeck, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Benson Leung, Peter Ujfalusi,
Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
Pierre-Louis Bossart, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Matthias Brugger,
AngeloGioacchino Del Regno, Rob Herring (Arm)
Cc: chrome-platform, linux-sound, linux-kernel, sound-open-firmware,
imx, linux-arm-kernel, linux-mediatek
On Thu, 03 Jul 2025 13:35:21 -0500, Rob Herring (Arm) wrote:
> Use the newly added of_reserved_mem_region_to_resource() function to
> handle "memory-region" properties.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
commit: bc163baef57002c08b3afe64cdd2f55f55a765eb
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
2025-07-03 18:35 [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region" Rob Herring (Arm)
2025-07-04 2:46 ` Tzung-Bi Shih
2025-07-04 15:57 ` Mark Brown
@ 2025-07-07 9:37 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-07 9:37 UTC (permalink / raw)
To: Rob Herring (Arm), Cheng-Yi Chiang, Tzung-Bi Shih, Guenter Roeck,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Benson Leung, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Pierre-Louis Bossart, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Matthias Brugger
Cc: chrome-platform, linux-sound, linux-kernel, sound-open-firmware,
imx, linux-arm-kernel, linux-mediatek
Il 03/07/25 20:35, Rob Herring (Arm) ha scritto:
> Use the newly added of_reserved_mem_region_to_resource() function to
> handle "memory-region" properties.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
For MediaTek:
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-07 10:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 18:35 [PATCH] ASoC: Use of_reserved_mem_region_to_resource() for "memory-region" Rob Herring (Arm)
2025-07-04 2:46 ` Tzung-Bi Shih
2025-07-04 3:39 ` Cheng-yi Chiang
2025-07-04 15:57 ` Mark Brown
2025-07-07 9:37 ` AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).