svn commit: r332016 - head/sys/dev/ofw

Marcin Wojtas mw at FreeBSD.org
Wed Apr 4 12:47:42 UTC 2018


Author: mw
Date: Wed Apr  4 12:47:41 2018
New Revision: 332016
URL: https://svnweb.freebsd.org/changeset/base/332016

Log:
  Add api for creating resource list based on 'assigned-addresses'
  
  According to device tree binding 'assigned-addresses' can refer to PCIE MMIO
  register space. New function ofw_bus_assigned_addresses_to_rl is
  provided to support it.
  
  Submitted by: Rafal Kozik <rk at semihalf.com>
  Obtained from: Semihalf
  Sponsored by: Stormshield
  Differential Revision: https://reviews.freebsd.org/D14750

Modified:
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/ofw_bus_subr.h

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c	Wed Apr  4 12:41:42 2018	(r332015)
+++ head/sys/dev/ofw/ofw_bus_subr.c	Wed Apr  4 12:47:41 2018	(r332016)
@@ -489,9 +489,9 @@ ofw_bus_msimap(phandle_t node, uint16_t pci_rid, phand
 	return (err);
 }
 
-int
-ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells,
-    struct resource_list *rl)
+static int
+ofw_bus_reg_to_rl_helper(device_t dev, phandle_t node, pcell_t acells, pcell_t scells,
+    struct resource_list *rl, const char *reg_source)
 {
 	uint64_t phys, size;
 	ssize_t i, j, rid, nreg, ret;
@@ -506,7 +506,7 @@ ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_
 	if (ret == -1)
 		name = NULL;
 
-	ret = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+	ret = OF_getencprop_alloc(node, reg_source, sizeof(*reg), (void **)&reg);
 	nreg = (ret == -1) ? 0 : ret;
 
 	if (nreg % (acells + scells) != 0) {
@@ -535,6 +535,23 @@ ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_
 	free(reg, M_OFWPROP);
 
 	return (0);
+}
+
+int
+ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells,
+    struct resource_list *rl)
+{
+
+	return (ofw_bus_reg_to_rl_helper(dev, node, acells, scells, rl, "reg"));
+}
+
+int
+ofw_bus_assigned_addresses_to_rl(device_t dev, phandle_t node, pcell_t acells,
+    pcell_t scells, struct resource_list *rl)
+{
+
+	return (ofw_bus_reg_to_rl_helper(dev, node, acells, scells,
+	    rl, "assigned-addresses"));
 }
 
 /*

Modified: head/sys/dev/ofw/ofw_bus_subr.h
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.h	Wed Apr  4 12:41:42 2018	(r332015)
+++ head/sys/dev/ofw/ofw_bus_subr.h	Wed Apr  4 12:47:41 2018	(r332016)
@@ -95,6 +95,8 @@ int ofw_bus_msimap(phandle_t, uint16_t, phandle_t *, u
 /* Routines for parsing device-tree data into resource lists. */
 int ofw_bus_reg_to_rl(device_t, phandle_t, pcell_t, pcell_t,
     struct resource_list *);
+int ofw_bus_assigned_addresses_to_rl(device_t, phandle_t, pcell_t, pcell_t,
+    struct resource_list *);
 int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *, int *);
 int ofw_bus_intr_by_rid(device_t, phandle_t, int, phandle_t *, int *,
     pcell_t **);


More information about the svn-src-all mailing list