[coreboot-gerrit] Change in coreboot[master]: acpi_device: New function to add a list of properties

Duncan Laurie (Code Review) gerrit at coreboot.org
Tue Aug 29 17:45:30 CEST 2017


Duncan Laurie has uploaded this change for review. ( https://review.coreboot.org/21269


Change subject: acpi_device: New function to add a list of properties
......................................................................

acpi_device: New function to add a list of properties

Provide a new function that will allow adding arbitrary properties
to devicetree entries without needing a custom driver for the device.

This will allow the 'generic i2c' driver to support kernel drivers
that need additional device properties exposed and have those board
specific properties set with values from devicetree.

BUG=b:63413023
TEST=not used yet, compiles cleanly

Change-Id: Id272256639a8525406635e168a3db5ab1ba4df6b
Signed-off-by: Duncan Laurie <dlaurie at google.com>
---
M src/arch/x86/acpi_device.c
M src/arch/x86/include/arch/acpi_device.h
2 files changed, 68 insertions(+), 23 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/21269/1

diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index aac7b88..13fcd5b 100644
--- a/src/arch/x86/acpi_device.c
+++ b/src/arch/x86/acpi_device.c
@@ -26,29 +26,6 @@
 #define ACPI_DP_UUID		"daffd814-6eba-4d8c-8a91-bc9bbf4aa301"
 #define ACPI_DP_CHILD_UUID	"dbb8e3e6-5886-4ba6-8795-1319f52a966b"
 
-enum acpi_dp_type {
-	ACPI_DP_TYPE_INTEGER,
-	ACPI_DP_TYPE_STRING,
-	ACPI_DP_TYPE_REFERENCE,
-	ACPI_DP_TYPE_TABLE,
-	ACPI_DP_TYPE_ARRAY,
-	ACPI_DP_TYPE_CHILD,
-};
-
-struct acpi_dp {
-	enum acpi_dp_type type;
-	const char *name;
-	struct acpi_dp *next;
-	union {
-		struct acpi_dp *child;
-		struct acpi_dp *array;
-	};
-	union {
-		uint64_t integer;
-		const char *string;
-	};
-};
-
 /* Write empty word value and return pointer to it */
 static void *acpi_device_write_zero_len(void)
 {
@@ -705,6 +682,45 @@
 	return acpi_dp_new(NULL, ACPI_DP_TYPE_TABLE, name);
 }
 
+int acpi_dp_add_property_list(struct acpi_dp *dp,
+			      struct acpi_dp *property_list,
+			      size_t property_count)
+{
+	struct acpi_dp *prop;
+	int i, properties_added = 0;
+
+	for (i = 0; i < property_count; i++) {
+		prop = &property_list[i];
+
+		if (prop->type == ACPI_DP_TYPE_UNKNOWN || !prop->name)
+			continue;
+
+		switch (prop->type) {
+		case ACPI_DP_TYPE_INTEGER:
+			acpi_dp_add_integer(dp, prop->name, prop->integer);
+			break;
+		case ACPI_DP_TYPE_STRING:
+			acpi_dp_add_string(dp, prop->name, prop->string);
+			break;
+		case ACPI_DP_TYPE_REFERENCE:
+			acpi_dp_add_string(dp, prop->name, prop->string);
+			break;
+		case ACPI_DP_TYPE_ARRAY:
+			acpi_dp_add_array(dp, prop->array);
+			break;
+		case ACPI_DP_TYPE_CHILD:
+			acpi_dp_add_child(dp, prop->name, prop->child);
+			break;
+		default:
+			continue;
+		}
+
+		++properties_added;
+	}
+
+	return properties_added;
+}
+
 struct acpi_dp *acpi_dp_add_integer(struct acpi_dp *dp, const char *name,
 				    uint64_t value)
 {
diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h
index f904cc6..e8fe722 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -20,6 +20,30 @@
 #include <stdint.h>
 #include <spi-generic.h>
 
+enum acpi_dp_type {
+	ACPI_DP_TYPE_UNKNOWN,
+	ACPI_DP_TYPE_INTEGER,
+	ACPI_DP_TYPE_STRING,
+	ACPI_DP_TYPE_REFERENCE,
+	ACPI_DP_TYPE_TABLE,
+	ACPI_DP_TYPE_ARRAY,
+	ACPI_DP_TYPE_CHILD,
+};
+
+struct acpi_dp {
+	enum acpi_dp_type type;
+	const char *name;
+	struct acpi_dp *next;
+	union {
+		struct acpi_dp *child;
+		struct acpi_dp *array;
+	};
+	union {
+		uint64_t integer;
+		const char *string;
+	};
+};
+
 #define ACPI_DESCRIPTOR_LARGE		(1 << 7)
 #define ACPI_DESCRIPTOR_INTERRUPT	(ACPI_DESCRIPTOR_LARGE | 9)
 #define ACPI_DESCRIPTOR_GPIO		(ACPI_DESCRIPTOR_LARGE | 12)
@@ -370,6 +394,11 @@
 struct acpi_dp *acpi_dp_add_child(struct acpi_dp *dp, const char *name,
 				  struct acpi_dp *child);
 
+/* Add a list of Device Properties, returns the number of properties added */
+int acpi_dp_add_property_list(struct acpi_dp *dp,
+			      struct acpi_dp *property_list,
+			      size_t property_count);
+
 /* Write Device Property hierarchy and clean up resources */
 void acpi_dp_write(struct acpi_dp *table);
 

-- 
To view, visit https://review.coreboot.org/21269
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id272256639a8525406635e168a3db5ab1ba4df6b
Gerrit-Change-Number: 21269
Gerrit-PatchSet: 1
Gerrit-Owner: Duncan Laurie <dlaurie at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170829/885aa3d6/attachment.html>


More information about the coreboot-gerrit mailing list