ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"
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> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Link: https://patch.msgid.link/20250703183523.2075276-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
baee26a9d6
commit
bc163baef5
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_address.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_commands.h>
|
||||||
#include <linux/platform_data/cros_ec_proto.h>
|
#include <linux/platform_data/cros_ec_proto.h>
|
||||||
#include <linux/platform_device.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;
|
struct ec_response_ec_codec_get_capabilities r;
|
||||||
int ret;
|
int ret;
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
struct device_node *node;
|
|
||||||
struct resource res;
|
struct resource res;
|
||||||
u64 ec_shm_size;
|
u64 ec_shm_size;
|
||||||
const __be32 *regaddr_p;
|
const __be32 *regaddr_p;
|
||||||
|
|
@ -981,9 +981,7 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)
|
||||||
priv->ec_shm_addr, priv->ec_shm_len);
|
priv->ec_shm_addr, priv->ec_shm_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = of_parse_phandle(dev->of_node, "memory-region", 0);
|
ret = of_reserved_mem_region_to_resource(dev->of_node, 0, &res);
|
||||||
if (node) {
|
|
||||||
ret = of_address_to_resource(node, 0, &res);
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
priv->ap_shm_phys_addr = res.start;
|
priv->ap_shm_phys_addr = res.start;
|
||||||
priv->ap_shm_len = resource_size(&res);
|
priv->ap_shm_len = resource_size(&res);
|
||||||
|
|
@ -996,8 +994,6 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)
|
||||||
dev_dbg(dev, "ap_shm_phys_addr=%#llx len=%#x\n",
|
dev_dbg(dev, "ap_shm_phys_addr=%#llx len=%#x\n",
|
||||||
priv->ap_shm_phys_addr, priv->ap_shm_len);
|
priv->ap_shm_phys_addr, priv->ap_shm_len);
|
||||||
}
|
}
|
||||||
of_node_put(node);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
priv->dev = dev;
|
priv->dev = dev;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
static int imx_parse_ioremap_memory(struct snd_sof_dev *sdev)
|
||||||
{
|
{
|
||||||
const struct imx_chip_info *chip_info;
|
const struct imx_chip_info *chip_info;
|
||||||
struct reserved_mem *reserved;
|
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct device_node *res_np;
|
struct resource *res, _res;
|
||||||
phys_addr_t base, size;
|
|
||||||
struct resource *res;
|
|
||||||
int i, blk_type, ret;
|
int i, blk_type, ret;
|
||||||
|
|
||||||
pdev = to_platform_device(sdev->dev);
|
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",
|
"failed to fetch %s resource\n",
|
||||||
chip_info->memory[i].name);
|
chip_info->memory[i].name);
|
||||||
|
|
||||||
base = res->start;
|
|
||||||
size = resource_size(res);
|
|
||||||
} else {
|
} else {
|
||||||
ret = of_property_match_string(pdev->dev.of_node,
|
ret = of_reserved_mem_region_to_resource_byname(pdev->dev.of_node,
|
||||||
"memory-region-names",
|
chip_info->memory[i].name,
|
||||||
chip_info->memory[i].name);
|
&_res);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return dev_err_probe(sdev->dev, ret,
|
return dev_err_probe(sdev->dev, ret,
|
||||||
"no valid index for %s\n",
|
"no valid entry for %s\n",
|
||||||
chip_info->memory[i].name);
|
chip_info->memory[i].name);
|
||||||
|
res = &_res;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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])
|
if (!sdev->bar[blk_type])
|
||||||
return dev_err_probe(sdev->dev,
|
return dev_err_probe(sdev->dev,
|
||||||
-ENOMEM,
|
-ENOMEM,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/firmware.h>
|
#include <linux/firmware.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/of_address.h>
|
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/of_reserved_mem.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 *mmio;
|
||||||
struct resource res;
|
struct resource res;
|
||||||
struct device_node *mem_region;
|
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct mtk_adsp_chip_info *adsp = data;
|
struct mtk_adsp_chip_info *adsp = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -57,14 +55,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_region = of_parse_phandle(dev->of_node, "memory-region", 1);
|
ret = of_reserved_mem_region_to_resource(dev->of_node, 1, &res);
|
||||||
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);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "of_address_to_resource sysmem failed\n");
|
dev_err(dev, "of_address_to_resource sysmem failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/firmware.h>
|
#include <linux/firmware.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/of_address.h>
|
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/of_reserved_mem.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 *mmio;
|
||||||
struct resource res;
|
struct resource res;
|
||||||
struct device_node *mem_region;
|
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct mtk_adsp_chip_info *adsp = data;
|
struct mtk_adsp_chip_info *adsp = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -57,14 +55,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_region = of_parse_phandle(dev->of_node, "memory-region", 1);
|
ret = of_reserved_mem_region_to_resource(dev->of_node, 1, &res);
|
||||||
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);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "of_address_to_resource sysmem failed\n");
|
dev_err(dev, "of_address_to_resource sysmem failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue