svn commit: r230560 - projects/armv6/sys/dev/fdt
Olivier Houchard
cognet at FreeBSD.org
Thu Jan 26 00:49:06 UTC 2012
Author: cognet
Date: Thu Jan 26 00:49:05 2012
New Revision: 230560
URL: http://svn.freebsd.org/changeset/base/230560
Log:
Handle "ranges;"
Make fdt_reg_to_rl() responsible for mapping the device memory, instead on
just hoping that there's only one simplebus, and using fdt_immr_va as the
base VA.
Tested by: dmarion
Modified:
projects/armv6/sys/dev/fdt/fdt_common.c
projects/armv6/sys/dev/fdt/fdt_common.h
projects/armv6/sys/dev/fdt/fdtbus.c
projects/armv6/sys/dev/fdt/simplebus.c
Modified: projects/armv6/sys/dev/fdt/fdt_common.c
==============================================================================
--- projects/armv6/sys/dev/fdt/fdt_common.c Thu Jan 26 00:07:34 2012 (r230559)
+++ projects/armv6/sys/dev/fdt/fdt_common.c Thu Jan 26 00:49:05 2012 (r230560)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
+#include <sys/limits.h>
#include <machine/fdt.h>
#include <machine/resource.h>
@@ -81,6 +82,11 @@ fdt_get_range(phandle_t node, int range_
len = OF_getproplen(node, "ranges");
if (len > sizeof(ranges))
return (ENOMEM);
+ if (len == 0) {
+ *base = 0;
+ *size = ULONG_MAX;
+ return (0);
+ }
if (!(range_id < len))
return (ERANGE);
@@ -413,16 +419,19 @@ fdt_regsize(phandle_t node, u_long *base
}
int
-fdt_reg_to_rl(phandle_t node, struct resource_list *rl, u_long base)
+fdt_reg_to_rl(phandle_t node, struct resource_list *rl)
{
u_long start, end, count;
pcell_t *reg, *regptr;
pcell_t addr_cells, size_cells;
int tuple_size, tuples;
int i, rv;
+ long vaddr;
+ long busaddr, bussize;
if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells) != 0)
return (ENXIO);
+ fdt_get_range(OF_parent(node), 0, &busaddr, &bussize);
tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
tuples = OF_getprop_alloc(node, "reg", tuple_size, (void **)®);
@@ -444,14 +453,15 @@ fdt_reg_to_rl(phandle_t node, struct res
reg += addr_cells + size_cells;
/* Calculate address range relative to base. */
- start &= 0x000ffffful;
- start = base + start;
- end = start + count - 1;
+ start += busaddr;
+ if (bus_space_map(fdtbus_bs_tag, start, count, 0, &vaddr) != 0)
+ panic("Couldn't map the device memory");
+ end = vaddr + count - 1;
debugf("reg addr start = %lx, end = %lx, count = %lx\n", start,
end, count);
- resource_list_add(rl, SYS_RES_MEMORY, i, start, end,
+ resource_list_add(rl, SYS_RES_MEMORY, i, vaddr, end,
count);
}
rv = 0;
Modified: projects/armv6/sys/dev/fdt/fdt_common.h
==============================================================================
--- projects/armv6/sys/dev/fdt/fdt_common.h Thu Jan 26 00:07:34 2012 (r230559)
+++ projects/armv6/sys/dev/fdt/fdt_common.h Thu Jan 26 00:49:05 2012 (r230560)
@@ -107,7 +107,7 @@ int fdt_pci_ranges_decode(phandle_t, str
struct fdt_pci_range *);
int fdt_pci_route_intr(int, int, int, int, struct fdt_pci_intr *, int *);
int fdt_ranges_verify(pcell_t *, int, int, int, int);
-int fdt_reg_to_rl(phandle_t, struct resource_list *, u_long);
+int fdt_reg_to_rl(phandle_t, struct resource_list *);
int fdt_pm(phandle_t);
#endif /* _FDT_COMMON_H_ */
Modified: projects/armv6/sys/dev/fdt/fdtbus.c
==============================================================================
--- projects/armv6/sys/dev/fdt/fdtbus.c Thu Jan 26 00:07:34 2012 (r230559)
+++ projects/armv6/sys/dev/fdt/fdtbus.c Thu Jan 26 00:49:05 2012 (r230560)
@@ -293,7 +293,7 @@ newbus_device_create(device_t dev_par, p
resource_list_init(&di->di_res);
- if (fdt_reg_to_rl(node, &di->di_res, fdt_immr_va)) {
+ if (fdt_reg_to_rl(node, &di->di_res)) {
device_printf(child, "could not process 'reg' property\n");
newbus_device_destroy(child);
child = NULL;
Modified: projects/armv6/sys/dev/fdt/simplebus.c
==============================================================================
--- projects/armv6/sys/dev/fdt/simplebus.c Thu Jan 26 00:07:34 2012 (r230559)
+++ projects/armv6/sys/dev/fdt/simplebus.c Thu Jan 26 00:49:05 2012 (r230560)
@@ -64,9 +64,6 @@ static MALLOC_DEFINE(M_SIMPLEBUS, "simpl
struct simplebus_softc {
int sc_addr_cells;
int sc_size_cells;
- u_long sc_start_pa;
- u_long sc_start_va;
- u_long sc_size;
};
struct simplebus_devinfo {
@@ -158,10 +155,6 @@ simplebus_attach(device_t dev)
sc = device_get_softc(dev);
- sc->sc_start_pa = fdt_immr_pa;
- sc->sc_start_va = fdt_immr_va;
- sc->sc_size = fdt_immr_size;
-
/*
* Walk simple-bus and add direct subordinates as our children.
*/
@@ -185,10 +178,11 @@ simplebus_attach(device_t dev)
}
resource_list_init(&di->di_res);
-
- if (fdt_reg_to_rl(dt_child, &di->di_res, sc->sc_start_va)) {
- device_printf(dev, "%s: could not process 'reg' "
+ if (fdt_reg_to_rl(dt_child, &di->di_res)) {
+ device_printf(dev,
+ "%s: could not process 'reg' "
"property\n", di->di_ofw.obd_name);
+ /* XXX should unmap */
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
free(di, M_SIMPLEBUS);
continue;
@@ -198,6 +192,7 @@ simplebus_attach(device_t dev)
device_printf(dev, "%s: could not process "
"'interrupts' property\n", di->di_ofw.obd_name);
resource_list_free(&di->di_res);
+ /* XXX should unmap */
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
free(di, M_SIMPLEBUS);
continue;
@@ -209,6 +204,7 @@ simplebus_attach(device_t dev)
device_printf(dev, "could not add child: %s\n",
di->di_ofw.obd_name);
resource_list_free(&di->di_res);
+ /* XXX should unmap */
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
free(di, M_SIMPLEBUS);
continue;
More information about the svn-src-projects
mailing list