[coreboot-gerrit] Change in ...coreboot[master]: [WIP] mb/lenovo/dock.asl: Add proper dock support
Arthur Heymans (Code Review)
gerrit at coreboot.org
Sun Dec 23 17:29:41 CET 2018
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30397
Change subject: [WIP] mb/lenovo/dock.asl: Add proper dock support
......................................................................
[WIP] mb/lenovo/dock.asl: Add proper dock support
Todo:
- Add parallel port and serial port ACPI code
- Clean up. A lot of code is slightly modified vendor code which isn't
that well written. Also lots of unneeded regs presented here.
Working:
- Dock LED
- Docking and undocking events
Change-Id: Ifa4a5a0272c6d3ec0b65871e5c1448d395bc74a8
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/mainboard/lenovo/t400/acpi/dock.asl
1 file changed, 308 insertions(+), 30 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/97/30397/1
diff --git a/src/mainboard/lenovo/t400/acpi/dock.asl b/src/mainboard/lenovo/t400/acpi/dock.asl
index 4a0ccf3..b71e4e3 100644
--- a/src/mainboard/lenovo/t400/acpi/dock.asl
+++ b/src/mainboard/lenovo/t400/acpi/dock.asl
@@ -14,60 +14,338 @@
* GNU General Public License for more details.
*/
-Scope (\_SB)
+#include "dock.h"
+
+Scope(\_SB.PCI0.LPCB)
{
- Device(DOCK)
+ OperationRegion (NCFG, SystemIO, 0x2E, 0x02)
+ Field (NCFG, ByteAcc, NoLock, Preserve)
{
- Name(_HID, "ACPI0003")
- Name(_UID, 0x00)
- Name(_PCL, Package() { \_SB } )
+ INDX, 8,
+ DATA, 8
+ }
- Method(_DCK, 1, NotSerialized)
+ IndexField (INDX, DATA, ByteAcc, NoLock, Preserve)
+ {
+ Offset (0x07),
+ LDN, 8,
+ Offset (0x20),
+ SIOD, 8,
+ Offset (0x22),
+ SCF2, 8,
+ Offset (0x24),
+ SCF4, 8,
+ , 2,
+ PPSE, 1,
+ , 4,
+ PNF, 1,
+ FDCD, 1,
+ PPD, 1,
+ SP2D, 1,
+ SP1D, 1,
+ , 1,
+ GPSR, 2,
+ Offset (0x27),
+ SRID, 8,
+ Offset (0x29),
+ SCF9, 8,
+ Offset (0x2B),
+ Offset (0x30),
+ LDA, 1,
+ Offset (0x31),
+ Offset (0x60),
+ IOHI, 8,
+ IOLW, 8,
+ Offset (0x70),
+ IRQN, 4,
+ IRQW, 1,
+ Offset (0x71),
+ IRQT, 1,
+ IRQL, 1,
+ Offset (0x72),
+ Offset (0x74),
+ DMA0, 3,
+ Offset (0x75),
+ DMA1, 3,
+ Offset (0x76)
+ }
+
+ IndexField (INDX, DATA, ByteAcc, NoLock, Preserve)
+ {
+ Offset (0xF0),
+ GPPS, 8,
+ GPPC, 8,
+ GPER, 8
+ }
+
+ Method(LCON, 1, NotSerialized)
+ {
+ if (Arg0)
{
- if (Arg0) {
- /* connect dock */
- Store (1, \GP28)
- Store (1, \_SB.PCI0.LPCB.EC.DKR1)
- } else {
- /* disconnect dock */
- Store (0, \GP28)
- Store (0, \_SB.PCI0.LPCB.EC.DKR1)
+ if (\_SB.PCI0.LPCB.EC.DPWR)
+ {
+ \_SB.DOCK.DLPD = 0x01
+ \_SB.DOCK.DLPC = 0x07
+ While (!(0x08 & \_SB.DOCK.DLPC))
+ {
+ Sleep(0x01)
+ }
+
+ \_SB.DOCK.DRST = 0x01
+ if ((SIOD != 0xff))
+ {
+ /* Enable 14.318MHz CLK on CLKIN */
+ SCF9 |= 0xa0
+ While (!(0x10 & SCF9))
+ {
+ Sleep (0x01)
+ }
+ /* set GPIO pins to Serial/Parallel Port functions */
+ SCF2 |= 0xeb
+ LDN = 0x07 /* r_gpio */
+ Local0 = (0x1620 & 0xff)
+ IOLW = Local0
+ Local0 = (0x1620 >> 0x8)
+ IOHI = (Local0 & 0xff)
+ GPPS = 0x01
+ GPPC = 0x03
+ GPPS = 0x02
+ GPPC = 0x03
+ \_SB.DOCK.DUSB = 0
+
+ }
+
}
- Xor(Arg0, \_SB.PCI0.LPCB.EC.DKR1, Local0)
- Return (Local0)
}
-
- Method(_STA, 0, NotSerialized)
+ else
{
- Return (\_SB.PCI0.LPCB.EC.DKR1)
+ \_SB.DOCK.DUSB = 1
+ \_SB.DOCK.DRST = 0
+ \_SB.DOCK.DLPD = 0
+ \_SB.DOCK.DLPC = 0
}
}
}
-Scope(\_SB.PCI0.LPCB.EC)
+Scope (\_SB)
{
- Method(_Q18, 0, NotSerialized)
+ Device(DOCK)
{
- Notify(\_SB.DOCK, 3)
+ OperationRegion (NSDL, SystemIO, DLPC_CONTROL, 0x01)
+ Field (NSDL, ByteAcc, NoLock, Preserve)
+ {
+ DLPC, 8
+ }
+
+ OperationRegion (NSIO, SystemIO, DLPC_GPIO_BASE, 0x0C)
+ Field (NSIO, ByteAcc, NoLock, Preserve)
+ {
+ DRST, 1,
+ DLPD, 1,
+ ULRT, 1,
+ ULPD, 1,
+ Offset (0x01),
+ , 4,
+ DKI0, 1,
+ Offset (0x02),
+ Offset (0x09),
+ DKI1, 1,
+ DKI2, 1
+ }
+
+ OperationRegion (DSIO, SystemIO, DOCK_GPIO_BASE, 0x0C)
+ Field (DSIO, ByteAcc, NoLock, Preserve)
+ {
+ , 1,
+ DUSB, 1,
+ Offset (0x01)
+ }
+
+ Name(_HID, "ACPI0003")
+ Name(_UID, 0x00)
+ Name(_PCL, Package() { \_SB } )
+ Name (G_ID, 0xffffffff)
+ Name (DOID, 0xffffffff)
+
+ Method (GDID, 0, NotSerialized)
+ {
+ If ((DOID == 0xFFFFFFFF))
+ {
+ \_SB.DOCK.G_ID = 0xFFFFFFFF
+ DOID = RDID ()
+ }
+
+ Return (DOID) /* \_SB_.DOCK.DOID */
+ }
+
+ Method (RDID, 0, NotSerialized)
+ {
+ Local0 = 0x00
+ If (\_SB.PCI0.LPCB.EC.DPWR)
+ {
+ If ((\_SB.DOCK.GGID () == 0x00))
+ {
+ Local0 = 0x4C004D24
+ }
+
+ If ((\_SB.DOCK.GGID () == 0x01))
+ {
+ Local0 = 0x44004D24
+ }
+ }
+ Return (Local0)
+ }
+
+ Method (GGID, 0, NotSerialized)
+ {
+ Local0 = G_ID
+ If ((Local0 == 0xFFFFFFFF))
+ {
+ Local0 = DKI0
+ Local1 = DKI1
+ Local2 = DKI2
+ Local0 |= (Local1 << 0x01)
+ Local0 |= (Local2 << 0x02)
+ G_ID = Local0
+ }
+ return (Local0)
+ }
+
+ Method (_STA, 0, NotSerialized)
+ {
+ Debug = "Dock Status"
+ Local0 = GGID ()
+ Local1 = 0x00
+ if ((Local0 == 0) || (Local0 == 1))
+ {
+ if ((GDID () == 0x4C004D24) || (GDID () == 0x44004D24))
+ {
+ Local1 = 0x0f
+ }
+ }
+ Debug = Local1
+ return (Local1)
+ }
+
+ Method (DDCK, 1, NotSerialized)
+ {
+ If (Arg0)
+ {
+ \_SB.PCI0.LPCB.EC.LEDS = 0x08
+ \_SB.PCI0.LPCB.EC.LEDS = 0x89
+ \_SB.PCI0.LPCB.LCON (0x01)
+ }
+ Else
+ {
+ \_SB.PCI0.LPCB.EC.LEDS = 0x88
+ \_SB.PCI0.LPCB.EC.LEDS = 0xc9
+ \_SB.PCI0.LPCB.LCON (0x00)
+ }
+
+ Return (0x01)
+ }
+
+ Method (_DCK, 1, NotSerialized)
+ {
+ Debug = "_DCK"
+ Debug = Arg0
+ Local0 = 0x0
+ If ((GGID () == 0x0) || (GGID () == 1))
+ {
+ Local0 = DDCK(Arg0)
+ }
+ Return (Local0)
+ }
+
+ Method (_EJ0, 1, NotSerialized)
+ {
+ Local0 = GGID ()
+ If ((Local0 == 0) || (Local0 == 1))
+ {
+ if (Arg0)
+ {
+ DOID = 0
+ }
+ \_SB.PCI0.LPCB.EC.LEDS = 0x08
+ \_SB.PCI0.LPCB.EC.LEDS = 0x09
+ }
+ }
+ }
+}
+
+ Scope(\_SB.PCI0.LPCB.EC)
+{
+ OperationRegion(PMH7, SystemIO, 0x15e0, 0x10)
+ Field(PMH7, ByteAcc, NoLock, Preserve)
+ {
+ Offset(0x0c),
+ PIDX, 8,
+ Offset(0x0e),
+ PDAT, 8,
}
- Method(_Q45, 0, NotSerialized)
+ IndexField(PIDX, PDAT, ByteAcc, NoLock, Preserve)
{
- Notify(\_SB.DOCK, 3)
+ Offset (0x61),
+ DPWR, 1,
}
- Method(_Q50, 0, NotSerialized)
+ Method(_Q18, 0, NotSerialized) /* FN + F9 */
{
+ Debug = "_Q18"
Notify(\_SB.DOCK, 3)
}
- Method(_Q58, 0, NotSerialized)
- {
- Notify(\_SB.DOCK, 0)
- }
-
Method(_Q37, 0, NotSerialized)
{
+ Debug = "_Q37"
+ Debug = "DPWR: "
+ Debug = DPWR
+ if (DPWR) {
+ Local0 = 2000
+ Sleep (100)
+ \_SB.DOCK.G_ID = 0xffffffff
+ While((\_SB.DOCK.GGID () == 0x07) && Local0)
+ {
+ Sleep(1)
+ \_SB.DOCK.G_ID = 0xffffffff
+ Local0--
+ }
+ Debug = "GGID: "
+ Debug = \_SB.DOCK.GGID ()
+ \_SB.DOCK.DOID = 0xFFFFFFFF
+ If (((\_SB.DOCK.GDID () == 0x4C004D24) || (\_SB.DOCK.GDID () == 0x44004D24)))
+ {
+ Debug = "Notifying Dock 0"
+ \_SB.DOCK.DRST = 0
+ Notify(\_SB.DOCK, 0)
+ }
+ Debug = "GDID: "
+ Debug = \_SB.DOCK.GDID ()
+ }
+ }
+
+ Method(_Q45, 0, NotSerialized)
+ {
+ Debug = "_Q45"
+ Notify(\_SB.DOCK, 3)
+ }
+
+ Method(_Q50, 0, NotSerialized) /* Undock Button */
+ {
+ Debug = "_Q50"
+ Local0 = \_SB.DOCK.GGID ()
+ If (((Local0 == 0x00) || (Local0 == 0x01)))
+ {
+ \_SB.PCI0.LPCB.EC.LEDS = 0x88
+ \_SB.PCI0.LPCB.EC.LEDS = 0xc9
+ Notify (\_SB.DOCK, 0x03) // Eject Request
+ }
+ }
+
+ Method(_Q58, 0, NotSerialized)
+ {
+ Debug = "_Q58"
Notify(\_SB.DOCK, 0)
}
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/30397
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ifa4a5a0272c6d3ec0b65871e5c1448d395bc74a8
Gerrit-Change-Number: 30397
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181223/ae0d6c59/attachment-0001.html>
More information about the coreboot-gerrit
mailing list