From a17796e6012041e2d8ebe16b0bde0b99809ee87c Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Sun, 17 Dec 2017 13:34:30 +0100 Subject: [PATCH] mb/lenovo/x200/dock.asl: Issue DOCK ACPI events based on Dock ID Some Dock events only need to happen based on the Dock Id (which functions as a presence detect GPIO). Inspired by vendor bios DSDT. This fixes undock ACPI events being issued when pulling out the power when docked or undocked (but still generates one when forcibly undocked) Tested on X200: pull power and see if undock events are generated in dmesg. Change-Id: I1eef971d49508bcd94d5d1cf2b70395b7cd80b1c Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/22919 Tested-by: build bot (Jenkins) Reviewed-by: Kevin Keijzer Reviewed-by: Stefan Reinauer --- src/mainboard/lenovo/x200/acpi/dock.asl | 41 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/mainboard/lenovo/x200/acpi/dock.asl b/src/mainboard/lenovo/x200/acpi/dock.asl index 0c7c9abcfb..93ad24c418 100644 --- a/src/mainboard/lenovo/x200/acpi/dock.asl +++ b/src/mainboard/lenovo/x200/acpi/dock.asl @@ -41,6 +41,24 @@ Scope (\_SB) { Return (\_SB.PCI0.LPCB.EC.DKR1) } + + Name (G_ID, 0xFFFFFFFF) + /* Returns 0x7 (dock absent) or 0x3 (dock present) */ + Method(GGID, 0, NotSerialized) + { + Store(G_ID, Local0) + if (LEqual(Local0, 0xFFFFFFFF)) + { + Store(Or (Or (GP02, ShiftLeft(GP03, 1)), + ShiftLeft(GP04, 2)), Local0) + If (LEqual(Local0, 0x00)) + { + Store(0x03, Local0) + } + Store(Local0, G_ID) + } + return (Local0) + } } } @@ -61,9 +79,14 @@ Scope(\_SB.PCI0.LPCB.EC) Notify(\_SB.DOCK, 3) } + /* Undock button on dock */ Method(_Q50, 0, NotSerialized) { - Notify(\_SB.DOCK, 3) + Store(\_SB.DOCK.GGID (), Local0) + if (LNotEqual(Local0, 0x07)) + { + Notify(\_SB.DOCK, 3) + } } Method(_Q58, 0, NotSerialized) @@ -71,8 +94,22 @@ Scope(\_SB.PCI0.LPCB.EC) Notify(\_SB.DOCK, 0) } + /* Unplug power: only disconnect dock on force eject */ Method(_Q5A, 0, NotSerialized) { - Notify(\_SB.DOCK, 3) + Store(\_SB.DOCK.GGID (), Local0) + if (LEqual(Local0, 0x07)) + { + Notify(\_SB.DOCK, 3) + } + if (LEqual(Local0, 0x03)) + { + Sleep(0x64) + Store(DKR1, Local1) + if (LEqual(Local1, 1)) + { + Notify(\_SB.DOCK, 0) + } + } } }