mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 18:41:59 +08:00
linux/of_address.h: of_address_to_resource()
Translate address in of_address_to_resource(). Update #3277.
This commit is contained in:
@@ -2788,6 +2788,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
|
||||
#else /* __rtems__ */
|
||||
const char *fdt = bsp_fdt_get();
|
||||
struct device_node *fm_node;
|
||||
struct device_node muram_node_storage;
|
||||
struct device_node *muram_node;
|
||||
#endif /* __rtems__ */
|
||||
u32 val, range[2];
|
||||
int err, irq;
|
||||
@@ -2891,6 +2893,12 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
|
||||
__func__);
|
||||
goto fman_node_put;
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
memset(&muram_node_storage, 0, sizeof(muram_node_storage));
|
||||
muram_node = &muram_node_storage;
|
||||
muram_node->offset = fdt_node_offset_by_compatible(fdt,
|
||||
fm_node->offset, "fsl,fman-muram");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
err = of_address_to_resource(muram_node, 0,
|
||||
&fman->dts_params.muram_res);
|
||||
@@ -2900,27 +2908,7 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
|
||||
__func__, err);
|
||||
goto fman_node_put;
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
int node = fdt_node_offset_by_compatible(fdt,
|
||||
fm_node->offset, "fsl,fman-muram");
|
||||
struct device_node muram_node = {
|
||||
.offset = node
|
||||
};
|
||||
struct resource res;
|
||||
|
||||
err = of_address_to_resource(&muram_node, 0, &res);
|
||||
if (err != 0) {
|
||||
pr_err("could not find MURAM node\n");
|
||||
goto fman_node_put;
|
||||
}
|
||||
fman->dts_params.muram_res.start = phys_base_addr + res.start;
|
||||
fman->dts_params.muram_res.end = phys_base_addr + res.end - 1;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
#ifndef __rtems__
|
||||
of_node_put(muram_node);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
err = devm_request_irq(&of_dev->dev, irq, fman_irq, 0, "fman", fman);
|
||||
if (err < 0) {
|
||||
|
@@ -872,9 +872,6 @@ qman_sysinit(void)
|
||||
|
||||
memset(&dev, 0, sizeof(dev));
|
||||
dev.pdev.dev.of_node = &dev.of_node;
|
||||
#if QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)
|
||||
dev.pdev.dev.base = (uintptr_t)&qoriq;
|
||||
#endif
|
||||
dev.of_node.offset = node;
|
||||
dev.of_node.full_name = name;
|
||||
|
||||
|
@@ -79,7 +79,7 @@ static inline void __iomem *
|
||||
devm_ioremap(struct device *dev, resource_size_t offset, resource_size_t size)
|
||||
{
|
||||
|
||||
return (void __iomem *)(dev->base + (uintptr_t)offset);
|
||||
return (void __iomem *)(uintptr_t)offset;
|
||||
}
|
||||
|
||||
#define devm_alloc_percpu(dev, type) \
|
||||
|
@@ -329,6 +329,7 @@ of_address_to_resource(struct device_node *dn, int index,
|
||||
struct resource *res)
|
||||
{
|
||||
const void *fdt = bsp_fdt_get();
|
||||
int node;
|
||||
int ac;
|
||||
int sc;
|
||||
int len;
|
||||
@@ -336,16 +337,17 @@ of_address_to_resource(struct device_node *dn, int index,
|
||||
int i;
|
||||
|
||||
memset(res, 0, sizeof(*res));
|
||||
node = dn->offset;
|
||||
|
||||
ac = get_address_cells(fdt, dn->offset);
|
||||
ac = get_address_cells(fdt, node);
|
||||
if (ac < 0)
|
||||
return (-EINVAL);
|
||||
|
||||
sc = get_size_cells(fdt, dn->offset);
|
||||
sc = get_size_cells(fdt, node);
|
||||
if (sc < 0)
|
||||
return (-EINVAL);
|
||||
|
||||
p = fdt_getprop(fdt, dn->offset, "reg", &len);
|
||||
p = fdt_getprop(fdt, node, "reg", &len);
|
||||
if (p == NULL)
|
||||
return (-EINVAL);
|
||||
|
||||
@@ -354,19 +356,9 @@ of_address_to_resource(struct device_node *dn, int index,
|
||||
if (i + ac + sc > len)
|
||||
return (-EINVAL);
|
||||
|
||||
while (ac > 0) {
|
||||
res->start = (res->start << 32) | fdt32_to_cpu(p[i]);
|
||||
++i;
|
||||
--ac;
|
||||
}
|
||||
|
||||
while (sc > 0) {
|
||||
res->end = (res->end << 32) | fdt32_to_cpu(p[i]);
|
||||
++i;
|
||||
--sc;
|
||||
}
|
||||
res->start = translate_address(fdt, node, ac, sc, &p[i]);
|
||||
res->end = of_read_number(&p[i + ac], sc);
|
||||
res->end += res->start;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user