From 020a3ce90b025e342faec9479ded07e3ce055146 Mon Sep 17 00:00:00 2001 From: Dennis Wassenberg Date: Thu, 10 Sep 2015 12:17:49 +0200 Subject: ec/roda/it8518: Add another embedded controller The embedded-controller interface of Roda's Ivy Bridge notebooks is supposedly programmed by AMI. Change-Id: I153d831fcea8a3132c7bd1927ff3b445d9a8e92c Signed-off-by: Dennis Wassenberg Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/17288 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan --- src/ec/roda/it8518/Kconfig | 20 ++++ src/ec/roda/it8518/Makefile.inc | 16 +++ src/ec/roda/it8518/acpi/ac.asl | 29 +++++ src/ec/roda/it8518/acpi/battery.asl | 123 +++++++++++++++++++++ src/ec/roda/it8518/acpi/ec.asl | 210 ++++++++++++++++++++++++++++++++++++ src/ec/roda/it8518/acpi/lid.asl | 27 +++++ src/ec/roda/it8518/chip.h | 28 +++++ src/ec/roda/it8518/ec.c | 58 ++++++++++ 8 files changed, 511 insertions(+) create mode 100644 src/ec/roda/it8518/Kconfig create mode 100644 src/ec/roda/it8518/Makefile.inc create mode 100644 src/ec/roda/it8518/acpi/ac.asl create mode 100644 src/ec/roda/it8518/acpi/battery.asl create mode 100644 src/ec/roda/it8518/acpi/ec.asl create mode 100644 src/ec/roda/it8518/acpi/lid.asl create mode 100644 src/ec/roda/it8518/chip.h create mode 100644 src/ec/roda/it8518/ec.c (limited to 'src/ec/roda/it8518') diff --git a/src/ec/roda/it8518/Kconfig b/src/ec/roda/it8518/Kconfig new file mode 100644 index 0000000000..452c34541e --- /dev/null +++ b/src/ec/roda/it8518/Kconfig @@ -0,0 +1,20 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2015 secunet Security Networks AG +## +## 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 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. +## + +config EC_RODA_IT8518 + bool + select EC_ACPI + help + Interface to IT8518 embedded controller in Roda notebooks. diff --git a/src/ec/roda/it8518/Makefile.inc b/src/ec/roda/it8518/Makefile.inc new file mode 100644 index 0000000000..a0998880d9 --- /dev/null +++ b/src/ec/roda/it8518/Makefile.inc @@ -0,0 +1,16 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2015 secunet Security Networks AG +## +## 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 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. +## + +ramstage-$(CONFIG_EC_RODA_IT8518) += ec.c diff --git a/src/ec/roda/it8518/acpi/ac.asl b/src/ec/roda/it8518/acpi/ac.asl new file mode 100644 index 0000000000..33c62ee8dd --- /dev/null +++ b/src/ec/roda/it8518/acpi/ac.asl @@ -0,0 +1,29 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 secunet Security Networks AG + * + * 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 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. + */ + +//SCOPE EC0 + +Device (AC) +{ + Name (_HID, "ACPI0003") + Name (_PCL, Package () { \_SB }) + + Method (_PSR, 0, NotSerialized) // _PSR: Power Source + { + Store ("-----> AC: _PSR", Debug) + Store ("<----- AC: _PSR", Debug) + Return (PWRS) + } +} diff --git a/src/ec/roda/it8518/acpi/battery.asl b/src/ec/roda/it8518/acpi/battery.asl new file mode 100644 index 0000000000..ffe2c2f6e9 --- /dev/null +++ b/src/ec/roda/it8518/acpi/battery.asl @@ -0,0 +1,123 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 secunet Security Networks AG + * + * 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 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. + */ + +//SCOPE EC0 + +Device (BAT0) +{ + Name (_HID, EISAID ("PNP0C0A")) + Name (_UID, 1) + Name (_PCL, Package () { \_SB }) + + + // + // Default Static Battery Information + // + Name (PBIF, Package (13) + { + 1, // 0: Power Unit + 4800, // 1: Design Capacity + 4650, // 2: Last Full Charge Capacity + 1, // 3: Battery Technology(Rechargeable) + 12608, // 4: Design Voltage 10.8V + 0, // 5: Design capacity of warning + 0, // 6: Design capacity of low + 0, // 7: Battery capacity granularity 1 + 0, // 8: Battery capacity granularity 2 + "BAT0", // 9: Model Number + "RT672", // 10: Serial Number + "LiON", // 11: Battery Type + "ASP" // 12: OEM Information + }) + + + Name (PBST, Package (4) + { + 0x00000000, // Battery State + 0xFFFFFFFF, // Battery Present Rate + 0xFFFFFFFF, // Battery Remaining Capacity + 0xFFFFFFFF, // Battery Present Voltage + }) + + + // Battery Slot Status + Method (_STA, 0, Serialized) + { + Store ("-----> BAT0: _STA", Debug) + + Store (0x0F, Local0) + + Store (ECPS, Local1) + And (Local1, 0x02, Local1) + If (LEqual (Local1, 0x02)) + { + Store (0x1F, Local0) + } + + Store ("<----- BAT0: _STA", Debug) + + Return (Local0) + } + + Method (_BIF, 0, Serialized) + { + Store ("-----> BAT0: _BIF", Debug) + + Store (B0FC, Index (PBIF, 0x02)) + Store (Divide (Multiply (B0FC, 6), 100), Index (PBIF, 0x05)) + Store (Divide (Multiply (B0FC, 3), 100), Index (PBIF, 0x06)) + + Store ("<----- BAT0: _BIF", Debug) + + Return (PBIF) + } + + Method (_BST, 0, Serialized) + { + Store ("-----> BAT0: _BST", Debug) + + Store (B0ST, Local0) + And (Local0, 0x40, Local0) + If (LEqual (Local0, 0x40)) + { + If (LEqual (PWRS, 1)) + { + Store (0x00, Index (PBST, 0x00)) + } + Else + { + Store (0x01, Index (PBST, 0x00)) + } + } + Else + { + Store (0x02, Index (PBST, 0x00)) + } + + Store (B0AC, Local1) + If (LGreaterEqual (Local1, 0x8000)) + { + Subtract (0x00010000, Local1, Local1) + } + + Store (Local1, Index (PBST, 0x01)) + Store (B0RC, Index (PBST, 0x02)) + Store (B0VT, Index (PBST, 0x03)) + + Store ("<----- BAT0: _BST", Debug) + + Return (PBST) + } +} diff --git a/src/ec/roda/it8518/acpi/ec.asl b/src/ec/roda/it8518/acpi/ec.asl new file mode 100644 index 0000000000..e0639e2590 --- /dev/null +++ b/src/ec/roda/it8518/acpi/ec.asl @@ -0,0 +1,210 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 secunet Security Networks AG + * + * 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 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. + */ + +#include + +Device (EC0) +{ + Name (_HID, EISAID ("PNP0C09")) // ACPI Embedded Controller + Name (_UID, 1) + Name (_GPE, Add(EC_SCI_GPI, 16)) // GPE for Runtime SCI + Name (PWRS, 1) + Name (LIDS, 1) + + // EC RAM fields + OperationRegion(ERAM, EmbeddedControl, 0, 0xFF) + Field (ERAM, ByteAcc, NoLock, Preserve) + { + Offset(0x00), // [Configuration Space 0x0] + Offset(0x02), // [Configuration Space 0x2] + B0ST, 16, // Battery 0 State + B0FC, 16, // Battery 0 Last Full Charge Capacity + B0RC, 16, // Battery 0 Remaining Capacity + B0U1, 16, // Unknown + B0VT, 16, // Battery 0 Present Voltage + B0AC, 16, // Battery 0 Present Rate + Offset(0x40), // [Configuration Space 0x40] + ECOS, 8, // OS System Type (0: DOS, 1: ACPI-compatible) + CPUT, 8, // CPU Temperature + LOCT, 8, // LOC Temperature + OEMT, 8, // OEM Temperature + Offset (0x48), // [Configuration Space 0x48] + ECPS, 8, // EC Power Source + Offset (0x50), // [Configuration Space 0x50] + LUXH, 8, // Ambient Light Illuminance High + LUXL, 8, // Ambient Light Illuminance Low + Offset (0x5B), // [Configuration Space 0x5B] + BRIG, 8, // Brightness + } // End of ERAM + + Method (_STA, 0, NotSerialized) // _STA: Status + { + Return (0x0F) + } + + Method (_CRS, 0, NotSerialized) + { + Return (ResourceTemplate() + { + IO (Decode16, 0x62, 0x62, 0x00, 0x01) + IO (Decode16, 0x66, 0x66, 0x00, 0x01) + }) + } + + Method (_REG, 2, NotSerialized) + { + Store ("-----> EC: _REG", Debug) + + Store (0x01, ECOS) + + Store ("<----- EC: _REG", Debug) + } + + Method (_Q29, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q29", Debug) + + Store (1, PWRS) + Notify (AC, 0x80) + Notify (AC, 0x00) + Notify (BAT0, 0x00) + Notify (BAT0, 0x80) + + Store ("<----- EC: _Q29", Debug) + } + + Method (_Q31, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q31", Debug) + + Store (0, PWRS) + Notify (AC, 0x80) + Notify (AC, 0x00) + Notify (BAT0, 0x00) + Notify (BAT0, 0x80) + + Store ("<----- EC: _Q31", Debug) + } + + Method (_Q32, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q32", Debug) + + Sleep (2500) + Notify (BAT0, 0x00) + Notify (BAT0, 0x80) + Notify (BAT0, 0x81) + Notify (BAT0, 0x82) + + Store ("<----- EC: _Q32", Debug) + } + + Method (_Q33, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q33", Debug) + + Sleep (2500) + Notify (BAT0, 0x00) + Notify (BAT0, 0x80) + Notify (BAT0, 0x81) + Notify (BAT0, 0x82) + + Store ("<---- EC: _Q33", Debug) + } + + Method (_Q36, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q36", Debug) + + Notify (BAT0, 0x80) + + Store ("<----- EC: _Q36", Debug) + } + + Method (_Q37, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q37", Debug) + + Notify (BAT0, 0x80) + + Store ("<----- EC: _Q37", Debug) + } + + Method (_Q43, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q43", Debug) + + Store (BRIG, Local0) + Increment (Local0) + If (LGreater (Local0, 0xAA)) { + Store (0xAA, Local0) + } + Store (Local0, BRIG) + + \_SB.PCI0.GFX0.INCB () + + Store ("<---- EC: _Q43", Debug) + } + + Method (_Q44, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q44", Debug) + + Store (BRIG, Local0) + Decrement (Local0) + If (LLess (Local0, 0xA0)) + { + Store (0xA0, Local0) + } + Store (Local0, BRIG) + + \_SB.PCI0.GFX0.DECB () + + Store ("<---- EC: _Q44", Debug) + } + + Method (_Q45, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q45", Debug) + + Store (0, LIDS) + Notify (LID, 0x80) + + Store ("<----- EC: _Q45", Debug) + } + + Method (_Q46, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q46", Debug) + + Store (1, LIDS) + Notify (LID, 0x80) + + Store ("<----- EC: _Q46", Debug) + } + + Method (_Q70, 0, NotSerialized) // _Qxx: EC Query + { + Store ("-----> EC: _Q70", Debug) + + Notify (ALSD, 0x80) + + Store ("<----- EC: _Q70", Debug) + } + + #include "battery.asl" + #include "ac.asl" + #include "lid.asl" +} diff --git a/src/ec/roda/it8518/acpi/lid.asl b/src/ec/roda/it8518/acpi/lid.asl new file mode 100644 index 0000000000..f793838863 --- /dev/null +++ b/src/ec/roda/it8518/acpi/lid.asl @@ -0,0 +1,27 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 secunet Security Networks AG + * + * 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 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. + */ + +//SCOPE EC0 + +Device (LID) +{ + Name (_HID, EisaId ("PNP0C0D")) // _HID: Hardware ID + Method (_LID, 0, NotSerialized) // _LID: Lid Status + { + Store ("-----> LID0: _LID", Debug) + Store ("<----- LID0: _LID", Debug) + Return (LIDS) + } +} diff --git a/src/ec/roda/it8518/chip.h b/src/ec/roda/it8518/chip.h new file mode 100644 index 0000000000..44891e84fa --- /dev/null +++ b/src/ec/roda/it8518/chip.h @@ -0,0 +1,28 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015-2016 secunet Security Networks AG + * + * 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 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. + */ + +#ifndef _EC_RODA_IT8518_CHIP_H +#define _EC_RODA_IT8518_CHIP_H + +#include + +struct chip_operations; +extern struct chip_operations ec_roda_it8518_ops; + +struct ec_roda_it8518_config { + u8 cpuhot_limit; /* temperature in °C which asserts PROCHOT# */ +}; + +#endif /* _EC_RODA_IT8518_CHIP_H */ diff --git a/src/ec/roda/it8518/ec.c b/src/ec/roda/it8518/ec.c new file mode 100644 index 0000000000..707d9e9371 --- /dev/null +++ b/src/ec/roda/it8518/ec.c @@ -0,0 +1,58 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 secunet Security Networks AG + * + * 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 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. + */ + +#include +#include +#include +#include +#include +#include + +#include "chip.h" + +static void it8518_init(struct device *dev) +{ + const struct ec_roda_it8518_config *const conf = dev->chip_info; + + if (!dev->enabled) + return; + + if (conf && conf->cpuhot_limit) + ec_write(0xb2, conf->cpuhot_limit); + + printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n"); + pc_keyboard_init(NO_AUX_DEVICE); +} + +static struct device_operations ops = { + .init = it8518_init, + .read_resources = DEVICE_NOOP, + .enable_resources = DEVICE_NOOP, +}; + +static struct pnp_info pnp_dev_info[] = { + { &ops, 0, 0, { 0, 0 }, } +}; + +static void enable_dev(struct device *dev) +{ + pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), + pnp_dev_info); +} + +struct chip_operations ec_roda_it8518_ops = { + CHIP_NAME("Roda IT8518 EC") + .enable_dev = enable_dev +}; -- cgit v1.2.3