Rework ACPI CST table generation

... in order to unify the Sandybridge and Lenovo implementations
currently used in the tree.

- use acpi_addr_t in acpigen_write_register()
- use acpi_cstate_t for cstate tables (and fix up
  the x60 and t60)
- drop cst_entry from acpigen.h

Change-Id: Icb87418d44d355f607c4a67300107b40f40b3b3f
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/943
Tested-by: build bot (Jenkins)
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
diff --git a/src/arch/x86/boot/acpigen.c b/src/arch/x86/boot/acpigen.c
index 6d2832c..46d2413 100644
--- a/src/arch/x86/boot/acpigen.c
+++ b/src/arch/x86/boot/acpigen.c
@@ -374,7 +374,7 @@
 	return len + lenh;
 }
 
-static int acpigen_write_CST_package_entry(struct cst_entry *entry)
+static int acpigen_write_CST_package_entry(acpi_cstate_t *cstate)
 {
 	int len, len0;
 	char *start, *end;
@@ -382,19 +382,19 @@
 	len0 = acpigen_write_package(4);
 	len = acpigen_write_resourcetemplate_header();
 	start = acpigen_get_current();
-	acpigen_write_register(entry->type, entry->width, entry->offset, entry->addrsize, entry->address);
+	acpigen_write_register(&cstate->resource);
 	end = acpigen_get_current();
-	len += end-start;
+	len += end - start;
 	len += acpigen_write_resourcetemplate_footer(len);
 	len += len0;
-	len += acpigen_write_dword(entry->ctype);
-	len += acpigen_write_dword(entry->latency);
-	len += acpigen_write_dword(entry->power);
+	len += acpigen_write_dword(cstate->ctype);
+	len += acpigen_write_dword(cstate->latency);
+	len += acpigen_write_dword(cstate->power);
 	acpigen_patch_len(len - 1);
 	return len;
 }
 
-int acpigen_write_CST_package(struct cst_entry *entry, int nentries)
+int acpigen_write_CST_package(acpi_cstate_t *cstate, int nentries)
 {
 	int len, lenh, lenp, i;
 	lenh = acpigen_write_name("_CST");
@@ -402,7 +402,7 @@
 	len = acpigen_write_dword(nentries);
 
 	for (i = 0; i < nentries; i++)
-		len += acpigen_write_CST_package_entry(entry + i);
+		len += acpigen_write_CST_package_entry(cstate + i);
 
 	len += lenp;
 	acpigen_patch_len(len - 1);
@@ -434,25 +434,23 @@
 	return 12;
 }
 
-int acpigen_write_register(int type, int width, int offset, int addrsize, u64 address)
+int acpigen_write_register(acpi_addr_t *addr)
 {
-	acpigen_emit_byte(0x82);
-	/* Byte 1+2: length (0x000c) */
-	acpigen_emit_byte(0x0c);
-	acpigen_emit_byte(0x00);
-	/* bit1-7 are ignored */
-	acpigen_emit_byte(type); /* FFixedHW */
-	acpigen_emit_byte(width); /* register width */
-	acpigen_emit_byte(offset); /* register offset */
-	acpigen_emit_byte(addrsize); /* register address size */
-	acpigen_emit_byte(address & 0xff); /* register address 0-7 */
-	acpigen_emit_byte((address >> 8) & 0xff); /* register address 8-15 */
-	acpigen_emit_byte((address >> 16) & 0xff); /* register address 16-23 */
-	acpigen_emit_byte((address >> 24) & 0xff); /* register address 24-31 */
-	acpigen_emit_byte((address >> 32) & 0xff); /* register address 32-39 */
-	acpigen_emit_byte((address >> 40) & 0xff); /* register address 40-47 */
-	acpigen_emit_byte((address >> 48) & 0xff); /* register address 48-55 */
-	acpigen_emit_byte((address >> 56) & 0xff); /* register address 56-63 */
+	acpigen_emit_byte(0x82);		/* Register Descriptor */
+	acpigen_emit_byte(0x0c);		/* Register Length 7:0 */
+	acpigen_emit_byte(0x00);		/* Register Length 15:8 */
+	acpigen_emit_byte(addr->space_id);	/* Address Space ID */
+	acpigen_emit_byte(addr->bit_width);	/* Register Bit Width */
+	acpigen_emit_byte(addr->bit_offset);	/* Register Bit Offset */
+	acpigen_emit_byte(addr->resv);		/* Register Access Size */
+	acpigen_emit_byte(addr->addrl & 0xff);	/* Register Address Low */
+	acpigen_emit_byte((addr->addrl >> 8) & 0xff);
+	acpigen_emit_byte((addr->addrl >> 16) & 0xff);
+	acpigen_emit_byte((addr->addrl >> 24) & 0xff);
+	acpigen_emit_byte(addr->addrh & 0xff);	/* Register Address High */
+	acpigen_emit_byte((addr->addrh >> 8) & 0xff);
+	acpigen_emit_byte((addr->addrh >> 16) & 0xff);
+	acpigen_emit_byte((addr->addrh >> 24) & 0xff);
 	return 15;
 }