[coreboot-gerrit] New patch to review for coreboot: sconfig: Add a new generic device type

Duncan Laurie (dlaurie@google.com) gerrit at coreboot.org
Thu May 12 16:17:23 CEST 2016


Duncan Laurie (dlaurie at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14789

-gerrit

commit 2f508a120c72e82aa8405eaf85ca7ed506f7a642
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Sat May 7 20:01:34 2016 -0700

    sconfig: Add a new generic device type
    
    Add support for a basic generic device in the devicetree to bind to a
    device that does not have a specific bus, but may need to be described
    in tables for the operating system.  For instance some chips may have
    various GPIO connections that need described but do not fall under any
    other device.
    
    In order to support this export the basic 'scan_static_bus()' that can
    be used in a device_operations->scan_bus() method to scan for the generic
    devices.
    
    It has been possible to get a semi-generic device by using a fake PNP
    device, but that isn't really appropriate for many devices.
    
    Change-Id: If45a5b18825bdb2cf1e4ba4297ee426cbd1678e3
    Signed-off-by: Duncan Laurie <dlaurie at chromium.org>
---
 src/device/device_util.c    | 12 ++++++++++++
 src/device/root_device.c    |  2 +-
 src/include/device/device.h |  1 +
 src/include/device/path.h   | 11 ++++++++++-
 util/sconfig/main.c         |  4 ++++
 util/sconfig/sconfig.l      |  1 +
 util/sconfig/sconfig.y      |  2 +-
 7 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/device/device_util.c b/src/device/device_util.c
index b538212..56afefd 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -222,6 +222,9 @@ u32 dev_path_encode(device_t dev)
 	case DEVICE_PATH_IOAPIC:
 		ret |= dev->path.ioapic.ioapic_id;
 		break;
+	case DEVICE_PATH_GENERIC:
+		ret |= dev->path.generic.subid << 8 | dev->path.generic.id;
+		break;
 	case DEVICE_PATH_NONE:
 	default:
 		break;
@@ -286,6 +289,11 @@ const char *dev_path(device_t dev)
 			snprintf(buffer, sizeof (buffer),
 				 "CPU_BUS: %02x", dev->path.cpu_bus.id);
 			break;
+		case DEVICE_PATH_GENERIC:
+			snprintf(buffer, sizeof (buffer),
+				 "GENERIC: %d.%d", dev->path.generic.id,
+				 dev->path.generic.subid);
+			break;
 		default:
 			printk(BIOS_ERR, "Unknown device path type: %d\n",
 			       dev->path.type);
@@ -353,6 +361,10 @@ int path_eq(struct device_path *path1, struct device_path *path2)
 	case DEVICE_PATH_CPU_BUS:
 		equal = (path1->cpu_bus.id == path2->cpu_bus.id);
 		break;
+	case DEVICE_PATH_GENERIC:
+		equal = (path1->generic.id == path2->generic.id) &&
+			(path1->generic.subid == path2->generic.subid);
+		break;
 	default:
 		printk(BIOS_ERR, "Unknown device type: %d\n", path1->type);
 		break;
diff --git a/src/device/root_device.c b/src/device/root_device.c
index 6b96100..7ff10ae 100644
--- a/src/device/root_device.c
+++ b/src/device/root_device.c
@@ -43,7 +43,7 @@ const char mainboard_name[] = CONFIG_MAINBOARD_VENDOR " " CONFIG_MAINBOARD_PART_
  * @param bus Pointer to the device to which the static buses are attached to.
  */
 
-static void scan_static_bus(device_t bus)
+void scan_static_bus(device_t bus)
 {
 	device_t child;
 	struct bus *link;
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 62460ae..d9af64a 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -232,6 +232,7 @@ void fixed_mem_resource(device_t dev, unsigned long index,
 		  unsigned long basek, unsigned long sizek, unsigned long type);
 
 void scan_smbus(device_t bus);
+void scan_static_bus(device_t bus);
 void scan_lpc_bus(device_t bus);
 
 /* It is the caller's responsibility to adjust regions such that ram_resource()
diff --git a/src/include/device/path.h b/src/include/device/path.h
index 8421a38..9d7fb38 100644
--- a/src/include/device/path.h
+++ b/src/include/device/path.h
@@ -13,6 +13,7 @@ enum device_path_type {
 	DEVICE_PATH_CPU,
 	DEVICE_PATH_CPU_BUS,
 	DEVICE_PATH_IOAPIC,
+	DEVICE_PATH_GENERIC,
 
 	/*
 	 * When adding path types to this table, please also update the
@@ -31,7 +32,8 @@ enum device_path_type {
 		"DEVICE_PATH_CPU_CLUSTER",	\
 		"DEVICE_PATH_CPU",		\
 		"DEVICE_PATH_CPU_BUS",		\
-		"DEVICE_PATH_IOAPIC"		\
+		"DEVICE_PATH_IOAPIC",		\
+		"DEVICE_PATH_GENERIC"		\
 }
 
 struct domain_path
@@ -85,6 +87,12 @@ struct cpu_bus_path
 	unsigned id;
 };
 
+struct generic_path
+{
+	unsigned id;
+	unsigned subid;
+};
+
 
 struct device_path {
 	enum device_path_type type;
@@ -98,6 +106,7 @@ struct device_path {
 		struct cpu_cluster_path cpu_cluster;
 		struct cpu_path		cpu;
 		struct cpu_bus_path	cpu_bus;
+		struct generic_path	generic;
 	};
 };
 
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index fea90f4..a398c0b 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -279,6 +279,10 @@ struct device *new_device(struct device *parent, struct device *busdev, const in
 	case IOAPIC:
 		new_d->path = ".type=DEVICE_PATH_IOAPIC,{.ioapic={ .ioapic_id = 0x%x }}";
 		break;
+
+	case GENERIC:
+		new_d->path = ".type=DEVICE_PATH_GENERIC,{.generic={ .id = 0x%x, .subid = 0x%x }}";
+		break;
 	}
 	return new_d;
 }
diff --git a/util/sconfig/sconfig.l b/util/sconfig/sconfig.l
index 40fb164..e361508 100755
--- a/util/sconfig/sconfig.l
+++ b/util/sconfig/sconfig.l
@@ -37,6 +37,7 @@ lapic		{yylval.number=APIC; return(BUS);}
 cpu_cluster	{yylval.number=CPU_CLUSTER; return(BUS);}
 cpu		{yylval.number=CPU; return(BUS);}
 domain		{yylval.number=DOMAIN; return(BUS);}
+generic		{yylval.number=GENERIC; return(BUS);}
 irq		{yylval.number=IRQ; return(RESOURCE);}
 drq		{yylval.number=DRQ; return(RESOURCE);}
 io		{yylval.number=IO; return(RESOURCE);}
diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y
index a5a063f..b1e37a8 100755
--- a/util/sconfig/sconfig.y
+++ b/util/sconfig/sconfig.y
@@ -29,7 +29,7 @@ static struct device *cur_parent, *cur_bus;
 	int number;
 }
 
-%token CHIP DEVICE REGISTER BOOL BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT
+%token CHIP DEVICE REGISTER BOOL BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC
 %%
 devtree: { cur_parent = cur_bus = head; } chip { postprocess_devtree(); } ;
 



More information about the coreboot-gerrit mailing list