[rtems-libbsd commit] linux/of_address.h: of_address_to_resource()
Sebastian Huber
sebh at rtems.org
Tue Jan 23 13:58:10 UTC 2018
Module: rtems-libbsd
Branch: master
Commit: e4923c85c950f499259dd0efb0fe8b63ca1164b0
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=e4923c85c950f499259dd0efb0fe8b63ca1164b0
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jan 17 14:30:44 2018 +0100
linux/of_address.h: of_address_to_resource()
Translate address in of_address_to_resource().
Update #3277.
---
linux/drivers/net/ethernet/freescale/fman/fman.c | 28 +++++++-----------------
linux/drivers/soc/fsl/qbman/qman_ccsr.c | 3 ---
rtemsbsd/powerpc/include/linux/device.h | 2 +-
rtemsbsd/sys/powerpc/compat.c | 22 ++++++-------------
4 files changed, 16 insertions(+), 39 deletions(-)
diff --git a/linux/drivers/net/ethernet/freescale/fman/fman.c b/linux/drivers/net/ethernet/freescale/fman/fman.c
index 0b7230a..4c8d853 100644
--- a/linux/drivers/net/ethernet/freescale/fman/fman.c
+++ b/linux/drivers/net/ethernet/freescale/fman/fman.c
@@ -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) {
diff --git a/linux/drivers/soc/fsl/qbman/qman_ccsr.c b/linux/drivers/soc/fsl/qbman/qman_ccsr.c
index b26bfdd..817bb50 100644
--- a/linux/drivers/soc/fsl/qbman/qman_ccsr.c
+++ b/linux/drivers/soc/fsl/qbman/qman_ccsr.c
@@ -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;
diff --git a/rtemsbsd/powerpc/include/linux/device.h b/rtemsbsd/powerpc/include/linux/device.h
index 4a6bc30..f4c344a 100644
--- a/rtemsbsd/powerpc/include/linux/device.h
+++ b/rtemsbsd/powerpc/include/linux/device.h
@@ -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) \
diff --git a/rtemsbsd/sys/powerpc/compat.c b/rtemsbsd/sys/powerpc/compat.c
index 8113eb2..45f06e5 100644
--- a/rtemsbsd/sys/powerpc/compat.c
+++ b/rtemsbsd/sys/powerpc/compat.c
@@ -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);
}
More information about the vc
mailing list