Vladimir Serbinenko (phcoder@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5239
-gerrit
commit 611dc008b2496b4b9f1671d71a9a043cb332d17f Author: Vladimir Serbinenko phcoder@gmail.com Date: Sat Feb 15 17:00:46 2014 +0100
NOTFORMERGE: Lenovo tablet support, shared images
Change-Id: I5b0399a8edca3b73aa7d515d2c446c31b3239fa5 Signed-off-by: Vladimir Serbinenko phcoder@gmail.com --- src/arch/x86/boot/acpigen.c | 44 +++++++ src/arch/x86/include/arch/acpigen.h | 2 + src/drivers/i2c/at24rf08c/lenovo.h | 5 + src/drivers/i2c/at24rf08c/lenovo_serials.c | 8 +- src/drivers/lenovo/Kconfig | 0 src/mainboard/lenovo/t60/acpi/superio.asl | 16 +++ src/mainboard/lenovo/t60/devicetree.cb | 4 + src/mainboard/lenovo/t60/romstage.c | 2 +- src/mainboard/lenovo/x201/Kconfig | 3 +- src/mainboard/lenovo/x201/acpi_tables.c | 2 + src/mainboard/lenovo/x201/devicetree.cb | 14 +++ src/mainboard/lenovo/x201/romstage.c | 2 +- src/mainboard/lenovo/x60/Kconfig | 3 +- src/mainboard/lenovo/x60/acpi_tables.c | 2 + src/mainboard/lenovo/x60/devicetree.cb | 11 +- src/mainboard/lenovo/x60/mainboard.c | 5 + src/mainboard/lenovo/x60/romstage.c | 2 +- src/superio/nsc/Kconfig | 2 + src/superio/nsc/pc87382/Kconfig | 28 +++++ src/superio/nsc/pc87382/Makefile.inc | 1 + src/superio/nsc/pc87382/superio.c | 6 + src/superio/nsc/pc87382/wacom.c | 195 +++++++++++++++++++++++++++++ 22 files changed, 349 insertions(+), 8 deletions(-)
diff --git a/src/arch/x86/boot/acpigen.c b/src/arch/x86/boot/acpigen.c index 6496d75..872acf8 100644 --- a/src/arch/x86/boot/acpigen.c +++ b/src/arch/x86/boot/acpigen.c @@ -623,6 +623,22 @@ int acpigen_write_register(acpi_addr_t *addr) return 15; }
+int acpigen_write_irq(u16 mask, u8 flags) +{ + /* + * acpi 4.0 section 6.4.2.6: I/O Port Descriptor + * Byte 0: + * Bit7 : 0 => small item + * Bit6-3: 0100 (0x4) => IRQ port descriptor + * Bit2-0: 010 (0x2) => 2 Bytes long + */ + acpigen_emit_byte(0x22); + acpigen_emit_byte(mask & 0xff); + acpigen_emit_byte((mask >> 8) & 0xff); + acpigen_emit_byte(flags); + return 4; +} + int acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16) { /* @@ -739,3 +755,31 @@ int acpigen_write_mainboard_resources(const char *scope, const char *name) acpigen_patch_len(len - 1); return len; } + +static int hex2bin(char c) +{ + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + return c - '0'; +} + +int acpigen_emit_eisaid(const char *eisaid) +{ + u32 compact = 0; + compact |= (eisaid[0] - 'A') << 26; + compact |= (eisaid[1] - 'A') << 21; + compact |= (eisaid[2] - 'A') << 16; + compact |= hex2bin (eisaid[3]) << 12; + compact |= hex2bin (eisaid[4]) << 8; + compact |= hex2bin (eisaid[5]) << 4; + compact |= hex2bin (eisaid[6]); + + acpigen_emit_byte(0xc); + acpigen_emit_byte((compact >> 24) & 0xff); + acpigen_emit_byte((compact >> 16) & 0xff); + acpigen_emit_byte((compact >> 8) & 0xff); + acpigen_emit_byte(compact & 0xff); + return 5; +} diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h index be138ce..d8bdbc8 100644 --- a/src/arch/x86/include/arch/acpigen.h +++ b/src/arch/x86/include/arch/acpigen.h @@ -62,6 +62,8 @@ int acpigen_write_resourcetemplate_header(void); int acpigen_write_resourcetemplate_footer(int len); int acpigen_write_mainboard_resource_template(void); int acpigen_write_mainboard_resources(const char *scope, const char *name); +int acpigen_emit_eisaid(const char *eisaid); +int acpigen_write_irq(u16 mask, u8 flags);
int get_cst_entries(acpi_cstate_t **);
diff --git a/src/drivers/i2c/at24rf08c/lenovo.h b/src/drivers/i2c/at24rf08c/lenovo.h new file mode 100644 index 0000000..9abda4b --- /dev/null +++ b/src/drivers/i2c/at24rf08c/lenovo.h @@ -0,0 +1,5 @@ +const char *lenovo_mainboard_partnumber(void); +int drivers_lenovo_is_wacom_present(void); +void drivers_lenovo_serial_ports_ssdt_generate(const char *scope, + int have_dock_serial, + int have_infrared); diff --git a/src/drivers/i2c/at24rf08c/lenovo_serials.c b/src/drivers/i2c/at24rf08c/lenovo_serials.c index 8c63d7d..7a5b259 100644 --- a/src/drivers/i2c/at24rf08c/lenovo_serials.c +++ b/src/drivers/i2c/at24rf08c/lenovo_serials.c @@ -24,6 +24,7 @@ #include <device/smbus.h> #include <smbios.h> #include <console/console.h> +#include "lenovo.h"
static void at24rf08c_read_string(u8 bank, u8 start, u8 len, char *result) { @@ -71,7 +72,7 @@ const char *smbios_mainboard_serial_number(void) return result; }
-const char *smbios_mainboard_product_name(void) +const char *lenovo_mainboard_partnumber(void) { static char result[12]; static int already_read; @@ -86,6 +87,11 @@ const char *smbios_mainboard_product_name(void) return result; }
+const char *smbios_mainboard_product_name(void) +{ + return lenovo_mainboard_partnumber(); +} + void smbios_mainboard_set_uuid(u8 *uuid) { static char result[16]; diff --git a/src/drivers/lenovo/Kconfig b/src/drivers/lenovo/Kconfig new file mode 100644 index 0000000..e69de29 diff --git a/src/mainboard/lenovo/t60/acpi/superio.asl b/src/mainboard/lenovo/t60/acpi/superio.asl index e69de29..a0d8e0a 100644 --- a/src/mainboard/lenovo/t60/acpi/superio.asl +++ b/src/mainboard/lenovo/t60/acpi/superio.asl @@ -0,0 +1,16 @@ + Device (FIR) // Infrared + { + Name(_HID, EISAID("IBM0071")) + Name(_CID, EISAID("PNP0511")) + + Name(_CRS, ResourceTemplate() + { + IO (Decode16, 0x2f8, 0x2f8, 0x01, 0x08) + IRQNoFlags () {3} + }) + + Method (_STA, 0) + { + Return (0xf) + } + } diff --git a/src/mainboard/lenovo/t60/devicetree.cb b/src/mainboard/lenovo/t60/devicetree.cb index b87a223..cce5f93 100644 --- a/src/mainboard/lenovo/t60/devicetree.cb +++ b/src/mainboard/lenovo/t60/devicetree.cb @@ -148,6 +148,10 @@ chip northbridge/intel/i945 chip superio/nsc/pc87382 device pnp 164e.2 on # IR io 0x60 = 0x2f8 + irq 0x29 = 0xb0 + irq 0x70 = 0x3 + drq 0x74 = 0x1 + irq 0xf0 = 0x82 end
device pnp 164e.3 off # Serial Port diff --git a/src/mainboard/lenovo/t60/romstage.c b/src/mainboard/lenovo/t60/romstage.c index dae917c..237e967 100644 --- a/src/mainboard/lenovo/t60/romstage.c +++ b/src/mainboard/lenovo/t60/romstage.c @@ -79,7 +79,7 @@ static void ich7_enable_lpc(void) // decode range pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0210); // decode range - pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x1f0d); + pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x1f0f);
/* range 0x1600 - 0x167f */ pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x84, 0x1601); diff --git a/src/mainboard/lenovo/x201/Kconfig b/src/mainboard/lenovo/x201/Kconfig index 8e7ebae..f0f2010 100644 --- a/src/mainboard/lenovo/x201/Kconfig +++ b/src/mainboard/lenovo/x201/Kconfig @@ -18,6 +18,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select HAVE_ACPI_RESUME select EARLY_CBMEM_INIT select MAINBOARD_HAS_NATIVE_VGA_INIT + select DRIVERS_LENOVO_WACOM
config MAINBOARD_DIR string @@ -29,7 +30,7 @@ config MAINBOARD_PART_NUMBER
config MAINBOARD_VERSION string - default "ThinkPad X201" + default "ThinkPad X201 / X201s / X201t"
config MAINBOARD_VENDOR string diff --git a/src/mainboard/lenovo/x201/acpi_tables.c b/src/mainboard/lenovo/x201/acpi_tables.c index 165de0d..2bb6a43 100644 --- a/src/mainboard/lenovo/x201/acpi_tables.c +++ b/src/mainboard/lenovo/x201/acpi_tables.c @@ -31,6 +31,7 @@ #include <device/pci.h> #include <device/pci_ids.h> #include "southbridge/intel/ibexpeak/nvs.h" +#include "drivers/i2c/at24rf08c/lenovo.h"
extern const unsigned char AmlCode[]; #if CONFIG_HAVE_ACPI_SLIC @@ -93,6 +94,7 @@ unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id) { generate_cpu_entries(); + drivers_lenovo_serial_ports_ssdt_generate("\_SB.PCI0.LPCB", 0, 0); return (unsigned long)(acpigen_get_current()); }
diff --git a/src/mainboard/lenovo/x201/devicetree.cb b/src/mainboard/lenovo/x201/devicetree.cb index 37a430c..0b978de 100644 --- a/src/mainboard/lenovo/x201/devicetree.cb +++ b/src/mainboard/lenovo/x201/devicetree.cb @@ -139,6 +139,20 @@ chip northbridge/intel/nehalem end device pci 1f.0 on # PCI-LPC bridge subsystemid 0x17aa 0x2166 + chip superio/nsc/pc87382 + device pnp 164e.3 on # Digitizer + io 0x60 = 0x200 + irq 0x29 = 0xb0 + irq 0x70 = 0x5 + irq 0xf0 = 0x82 + end + # IR, not connected + device pnp 164e.2 off end + # GPIO, not connected + device pnp 164e.7 off end + # DLPC, not connected + device pnp 164e.19 off end + end end device pci 1f.2 on # IDE/SATA subsystemid 0x17aa 0x2168 diff --git a/src/mainboard/lenovo/x201/romstage.c b/src/mainboard/lenovo/x201/romstage.c index f0874d3..9b99c4e 100644 --- a/src/mainboard/lenovo/x201/romstage.c +++ b/src/mainboard/lenovo/x201/romstage.c @@ -53,7 +53,7 @@ static void pch_enable_lpc(void) /* Enable EC, PS/2 Keyboard/Mouse */ pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | - COMA_LPC_EN); + COMA_LPC_EN | GAMEL_LPC_EN);
pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); diff --git a/src/mainboard/lenovo/x60/Kconfig b/src/mainboard/lenovo/x60/Kconfig index 7ed2665..8c1417e 100644 --- a/src/mainboard/lenovo/x60/Kconfig +++ b/src/mainboard/lenovo/x60/Kconfig @@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select MAINBOARD_HAS_NATIVE_VGA_INIT select EARLY_CBMEM_INIT select H8_DOCK_EARLY_INIT + select DRIVERS_LENOVO_WACOM
config MAINBOARD_DIR string @@ -41,7 +42,7 @@ config DCACHE_RAM_SIZE
config MAINBOARD_PART_NUMBER string - default "ThinkPad X60 / X60s" + default "ThinkPad X60 / X60s / X60t"
config MMCONF_BASE_ADDRESS hex diff --git a/src/mainboard/lenovo/x60/acpi_tables.c b/src/mainboard/lenovo/x60/acpi_tables.c index f6ed4ae..485de6b 100644 --- a/src/mainboard/lenovo/x60/acpi_tables.c +++ b/src/mainboard/lenovo/x60/acpi_tables.c @@ -29,6 +29,7 @@ #include <device/device.h> #include <device/pci.h> #include <device/pci_ids.h> +#include "drivers/i2c/at24rf08c/lenovo.h"
extern const unsigned char AmlCode[]; #if CONFIG_HAVE_ACPI_SLIC @@ -86,6 +87,7 @@ unsigned long acpi_fill_madt(unsigned long current) unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id) { generate_cpu_entries(); + drivers_lenovo_serial_ports_ssdt_generate("\_SB.PCI0.LPCB", 1, 1); return (unsigned long) (acpigen_get_current()); }
diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb index 3880f18..acd5af3 100644 --- a/src/mainboard/lenovo/x60/devicetree.cb +++ b/src/mainboard/lenovo/x60/devicetree.cb @@ -125,10 +125,17 @@ chip northbridge/intel/i945 chip superio/nsc/pc87382 device pnp 164e.2 on # IR io 0x60 = 0x2f8 + irq 0x29 = 0xb0 + irq 0x70 = 0x3 + drq 0x74 = 0x1 + irq 0xf0 = 0x82 end
- device pnp 164e.3 off # Serial Port - io 0x60 = 0x3f8 + device pnp 164e.3 on # Digitizer + io 0x60 = 0x200 + irq 0x29 = 0xb0 + irq 0x70 = 0x5 + irq 0xf0 = 0x82 end
device pnp 164e.7 on # GPIO diff --git a/src/mainboard/lenovo/x60/mainboard.c b/src/mainboard/lenovo/x60/mainboard.c index d1fcb7b..be39674 100644 --- a/src/mainboard/lenovo/x60/mainboard.c +++ b/src/mainboard/lenovo/x60/mainboard.c @@ -150,8 +150,13 @@ static int mainboard_smbios_data(device_t dev, int *handle, unsigned long *curre
static void mainboard_enable(device_t dev) { + device_t devwacom; dev->ops->init = mainboard_init; dev->ops->get_smbios_data = mainboard_smbios_data; + + devwacom = dev_find_slot_pnp (0x164e, 3); + if (devwacom) + devwacom->enabled = IS_ENABLED(CONFIG_BOARD_LENOVO_X60T); }
struct chip_operations mainboard_ops = { diff --git a/src/mainboard/lenovo/x60/romstage.c b/src/mainboard/lenovo/x60/romstage.c index 1198fb2..8eca464 100644 --- a/src/mainboard/lenovo/x60/romstage.c +++ b/src/mainboard/lenovo/x60/romstage.c @@ -86,7 +86,7 @@ static void ich7_enable_lpc(void) // decode range pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0210); // decode range - pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x1f0d); + pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x1f0f);
/* range 0x1600 - 0x167f */ pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x84, 0x1601); diff --git a/src/superio/nsc/Kconfig b/src/superio/nsc/Kconfig index 4aa28f8..4239b44 100644 --- a/src/superio/nsc/Kconfig +++ b/src/superio/nsc/Kconfig @@ -42,3 +42,5 @@ config SUPERIO_NSC_PC97307 bool config SUPERIO_NSC_PC97317 bool + +source "src/superio/nsc/pc87382/Kconfig" \ No newline at end of file diff --git a/src/superio/nsc/pc87382/Kconfig b/src/superio/nsc/pc87382/Kconfig new file mode 100644 index 0000000..5056b1e --- /dev/null +++ b/src/superio/nsc/pc87382/Kconfig @@ -0,0 +1,28 @@ +config DRIVERS_LENOVO_WACOM + bool + default n + +if DRIVERS_LENOVO_WACOM + +choice + prompt "Digitizer" + +config DIGITIZER_AUTODETECT + bool "Autodetect" + help + The presence of digitizer is inferred from model number stored in + AT24RF chip. + +config DIGITIZER_PRESENT + bool "Present" + help + The digitizer is assumed to be present. + +config DIGITIZER_ABSENT + bool "Absent" + help + The digitizer is assumed to be absent. + +endchoice + +endif diff --git a/src/superio/nsc/pc87382/Makefile.inc b/src/superio/nsc/pc87382/Makefile.inc index 7100a5d..c420394 100644 --- a/src/superio/nsc/pc87382/Makefile.inc +++ b/src/superio/nsc/pc87382/Makefile.inc @@ -19,4 +19,5 @@ ##
ramstage-$(CONFIG_SUPERIO_NSC_PC87382) += superio.c +ramstage-$(CONFIG_DRIVERS_LENOVO_WACOM) += wacom.c
diff --git a/src/superio/nsc/pc87382/superio.c b/src/superio/nsc/pc87382/superio.c index 3c0cda0..ee2ad28 100644 --- a/src/superio/nsc/pc87382/superio.c +++ b/src/superio/nsc/pc87382/superio.c @@ -58,6 +58,12 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev) { +#if IS_ENABLED(CONFIG_DRIVERS_LENOVO_WACOM) + if (dev->path.type == DEVICE_PATH_PNP && + dev->path.pnp.device == 3) + dev->enabled = drivers_lenovo_is_wacom_present(); +#endif + pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); } diff --git a/src/superio/nsc/pc87382/wacom.c b/src/superio/nsc/pc87382/wacom.c new file mode 100644 index 0000000..43b0895 --- /dev/null +++ b/src/superio/nsc/pc87382/wacom.c @@ -0,0 +1,195 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2009 coresystems GmbH + * Copyright (C) 2011 The Chromium OS Authors. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; version 2, or (at your + * option) any later version, of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include <types.h> +#include <console/console.h> +#include <arch/acpi.h> +#include <arch/acpigen.h> +#include <device/device.h> +#include <device/pnp.h> +#include <string.h> +#include "drivers/i2c/at24rf08c/lenovo.h" + +const char tablet_numbers[][5] = { "6366", "2985", "3093", "3113" }; + +int +drivers_lenovo_is_wacom_present(void) +{ +#if IS_ENABLED(CONFIG_DIGITIZER_PRESENT) + return 1; +#elif IS_ENABLED(CONFIG_DIGITIZER_ABSENT) + return 0; +#else + const char *pn; + int i; + static int result = -1; + device_t superio; + + if (result != -1) + return result; + superio = dev_find_slot_pnp (0x164e, 3); + if (!superio) + return (result = 0); + + /* Probe ID. */ + if (pnp_read_config(superio, 0x20) != 0xf2) + return (result = 0); + + pn = lenovo_mainboard_partnumber(); + if (!pn) + return 0; + for (i = 0; i < sizeof (tablet_numbers) / sizeof (tablet_numbers[0]); + i++) + if (memcmp (tablet_numbers[i], pn, 4) == 0) + return (result = 1); + return (result = 0); +#endif +} + +void +drivers_lenovo_serial_ports_ssdt_generate(const char *scope, + int have_dock_serial, + int have_infrared) +{ + int scopelen, devicelen, reslen, methodlen; + + scopelen = acpigen_write_scope(scope); + + if (drivers_lenovo_is_wacom_present()) { + /* Device op. */ + scopelen += acpigen_emit_byte(0x5b); + scopelen += acpigen_emit_byte(0x82); + devicelen = acpigen_write_len_f(); + devicelen += acpigen_emit_namestring("DTR"); + + devicelen += acpigen_write_name("_HID"); + devicelen += acpigen_emit_eisaid("WACF004"); + + devicelen += acpigen_write_name("_CRS"); + + reslen = acpigen_write_resourcetemplate_header(); + reslen += acpigen_write_io16(0x200, 0x200, 1, 8, 1); + reslen += acpigen_write_irq(0x20, 0x79); + + devicelen += reslen; + devicelen += acpigen_write_resourcetemplate_footer(reslen); + + /* method op */ + devicelen += acpigen_emit_byte(0x14); + methodlen = acpigen_write_len_f(); + methodlen += acpigen_emit_namestring("_STA"); + /* no fnarg */ + methodlen += acpigen_emit_byte(0x00); + /* return */ + methodlen += acpigen_emit_byte(0xa4); + methodlen += acpigen_write_byte(0xf); + + acpigen_patch_len(methodlen - 1); + devicelen += methodlen; + + acpigen_patch_len(devicelen - 1); + scopelen += devicelen; + } + + if (have_infrared) { + /* Device op. */ + scopelen += acpigen_emit_byte(0x5b); + scopelen += acpigen_emit_byte(0x82); + devicelen = acpigen_write_len_f(); + devicelen += acpigen_emit_namestring("FIR"); + + devicelen += acpigen_write_name("_HID"); + devicelen += acpigen_emit_eisaid("IBM0071"); + devicelen += acpigen_write_name("_CID"); + devicelen += acpigen_emit_eisaid("PNP0511"); + devicelen += acpigen_write_name("_UID"); + /* One */ + methodlen += acpigen_write_byte(0x1); + + devicelen += acpigen_write_name("_CRS"); + + reslen = acpigen_write_resourcetemplate_header(); + reslen += acpigen_write_io16(0x2f8, 0x2f8, 1, 8, 1); + reslen += acpigen_write_irq(0x80, 0x79); + + devicelen += reslen; + devicelen += acpigen_write_resourcetemplate_footer(reslen); + + /* method op */ + devicelen += acpigen_emit_byte(0x14); + methodlen = acpigen_write_len_f(); + methodlen += acpigen_emit_namestring("_STA"); + /* no fnarg */ + methodlen += acpigen_emit_byte(0x00); + /* return */ + methodlen += acpigen_emit_byte(0xa4); + methodlen += acpigen_write_byte(0xf); + acpigen_patch_len(methodlen - 1); + + devicelen += methodlen; + + acpigen_patch_len(devicelen - 1); + scopelen += devicelen; + } + + if (have_dock_serial) { + /* Device op. */ + scopelen += acpigen_emit_byte(0x5b); + scopelen += acpigen_emit_byte(0x82); + devicelen = acpigen_write_len_f(); + devicelen += acpigen_emit_namestring("COMA"); + + devicelen += acpigen_write_name("_HID"); + devicelen += acpigen_emit_eisaid("PNP0511"); + devicelen += acpigen_write_name("_UID"); + /* Byte */ + methodlen += acpigen_write_byte(0xa); + methodlen += acpigen_write_byte(0x2); + + devicelen += acpigen_write_name("_CRS"); + + reslen = acpigen_write_resourcetemplate_header(); + reslen += acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1); + reslen += acpigen_write_irq(0x10, 0x79); + + devicelen += reslen; + devicelen += acpigen_write_resourcetemplate_footer(reslen); + + /* method op */ + devicelen += acpigen_emit_byte(0x14); + methodlen = acpigen_write_len_f(); + methodlen += acpigen_emit_namestring("_STA"); + /* no fnarg */ + methodlen += acpigen_emit_byte(0x00); + /* return */ + methodlen += acpigen_emit_byte(0xa4); + methodlen += acpigen_write_byte(0xf); + acpigen_patch_len(methodlen - 1); + + devicelen += methodlen; + + acpigen_patch_len(devicelen - 1); + scopelen += devicelen; + } + + acpigen_patch_len(scopelen - 1); +}