[coreboot] New patch to review: 7793ddb X60: use EC events 0x50/0x58 instead of GPIO GPE for Docking/Undocking

Sven Schnelle (svens@stackframe.org) gerrit at coreboot.org
Thu Aug 18 20:34:03 CEST 2011


Sven Schnelle (svens at stackframe.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/161

-gerrit

commit 7793ddb6ddb3040ecf4b49731e2cbb1779d55f1f
Author: Sven Schnelle <svens at stackframe.org>
Date:   Mon Jul 11 18:36:16 2011 +0200

    X60: use EC events 0x50/0x58 instead of GPIO GPE for Docking/Undocking
    
    Change-Id: I674e5166f5fb7ba299e6f1231f30434a5bf731c5
    Signed-off-by: Sven Schnelle <svens at stackframe.org>
---
 src/mainboard/lenovo/x60/acpi/dock.asl   |   14 ++++++++++++--
 src/mainboard/lenovo/x60/acpi/gpe.asl    |   12 ------------
 src/mainboard/lenovo/x60/devicetree.cb   |   11 ++++++++++-
 src/mainboard/lenovo/x60/dock.c          |   10 +++++++++-
 src/mainboard/lenovo/x60/mainboard.c     |    6 ++++++
 src/mainboard/lenovo/x60/mainboard_smi.c |   23 ++++++++++++++++++++---
 6 files changed, 57 insertions(+), 19 deletions(-)

diff --git a/src/mainboard/lenovo/x60/acpi/dock.asl b/src/mainboard/lenovo/x60/acpi/dock.asl
index d393f44..136f888 100644
--- a/src/mainboard/lenovo/x60/acpi/dock.asl
+++ b/src/mainboard/lenovo/x60/acpi/dock.asl
@@ -39,7 +39,6 @@ Scope (\_SB)
 		Method(_DCK, 1, NotSerialized)
 		{
 			if (Arg0) {
-			   Sleep(250)
 			   /* connect dock */
 			   TRAP(SMI_DOCK_CONNECT)
 			} else {
@@ -53,7 +52,7 @@ Scope (\_SB)
 
 		Method(_STA, 0, NotSerialized)
 		{
-		Return (DSTA)
+			Return (DSTA)
 		}
 	}
 }
@@ -64,4 +63,15 @@ Scope(\_SB.PCI0.LPCB.EC)
 	{
 	       Notify(\_SB.DOCK, 3)
 	}
+
+	Method(_Q50, 0, NotSerialized)
+	{
+	       Notify(\_SB.DOCK, 3)
+	}
+
+	Method(_Q58, 0, NotSerialized)
+	{
+	       Notify(\_SB.DOCK, 0)
+	}
+
 }
diff --git a/src/mainboard/lenovo/x60/acpi/gpe.asl b/src/mainboard/lenovo/x60/acpi/gpe.asl
index 11e5dc0..b160b50 100644
--- a/src/mainboard/lenovo/x60/acpi/gpe.asl
+++ b/src/mainboard/lenovo/x60/acpi/gpe.asl
@@ -27,16 +27,4 @@ Scope (\_GPE)
 		/* Read EC register to clear wake status */
 		Store(\_SB.PCI0.LPCB.EC.WAKE, Local0)
 	}
-
-       /* SLICE_ON_3M GPE (Dock status) */
-       Method(_L1D, 0, NotSerialized)
-       {
-               if (GP13) {
-		       Or(GIV1, 0x20, GIV1)
-		       Notify(\_SB.DOCK, 3)
-               } else {
-		       And(GIV1, 0xdf, GIV1)
-		       Notify(\_SB.DOCK, 0)
-               }
-	}
 }
diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb
index 42a45d1..55e0b2d 100644
--- a/src/mainboard/lenovo/x60/devicetree.cb
+++ b/src/mainboard/lenovo/x60/devicetree.cb
@@ -86,6 +86,7 @@ chip northbridge/intel/i945
 					device pnp ff.1 on # dummy
 					end
 					register "backlight_enable" = "0x01"
+					register "dock_event_enable" = "0x01"
 				end
 				chip ec/lenovo/h8
 					device pnp ff.2 on # dummy
@@ -98,7 +99,7 @@ chip northbridge/intel/i945
 					register "config0" = "0xa6"
 					register "config1" = "0x05"
 					register "config2" = "0xa0"
-					register "config3" = "0x05"
+					register "config3" = "0x01"
 
 					register "beepmask0" = "0xfe"
 					register "beepmask1" = "0x96"
@@ -107,7 +108,15 @@ chip northbridge/intel/i945
 					register "event3_enable" = "0xff"
 					register "event4_enable" = "0xf4"
 					register "event5_enable" = "0x3c"
+					register "event6_enable" = "0x80"
+					register "event7_enable" = "0x01"
 					register "eventc_enable" = "0x3c"
+					register "event8_enable" = "0x01"
+					register "event9_enable" = "0xff"
+					register "eventa_enable" = "0xff"
+					register "eventb_enable" = "0xff"
+					register "eventc_enable" = "0xff"
+					register "eventd_enable" = "0xff"
 
 					register "wlan_enable" = "0x01"
 					register "trackpoint_enable" = "0x03"
diff --git a/src/mainboard/lenovo/x60/dock.c b/src/mainboard/lenovo/x60/dock.c
index 49e2d21..eed00a1 100644
--- a/src/mainboard/lenovo/x60/dock.c
+++ b/src/mainboard/lenovo/x60/dock.c
@@ -132,10 +132,12 @@ int dock_connect(void)
 
 	/* Assert D_PLTRST# */
 	outb(0xfe, 0x1680);
-	udelay(1000);
+	udelay(100000);
 	/* Deassert D_PLTRST# */
 	outb(0xff, 0x1680);
 
+	udelay(1000);
+
 	/* startup 14.318MHz Clock */
 	dock_write_register(0x29, 0x06);
 	/* wait until clock is settled */
@@ -232,11 +234,17 @@ int dock_connect(void)
 
 	/* Enable USB and Ultrabay power */
 	outb(0x03, 0x1628);
+
+	dock_write_register(0x07, 0x03);
+	dock_write_register(0x30, 0x01);
+	console_init();
 	return 0;
 }
 
 void dock_disconnect(void)
 {
+	/* disable Ultrabay and USB Power */
+	outb(0x00, 0x1628);
 	/* disconnect LPC bus */
 	outb(0x00, 0x164c);
 	/* Assert PLTRST and DLPCPD */
diff --git a/src/mainboard/lenovo/x60/mainboard.c b/src/mainboard/lenovo/x60/mainboard.c
index 8cd68bc..bf3d8d3 100644
--- a/src/mainboard/lenovo/x60/mainboard.c
+++ b/src/mainboard/lenovo/x60/mainboard.c
@@ -45,6 +45,12 @@ static void mainboard_enable(device_t dev)
 	/* enable Audio */
 	h8_set_audio_mute(0);
 
+	ec_clr_bit(0x03, 2);
+
+	if (inb(0x164c) & 0x08) {
+		ec_set_bit(0x03, 2);
+		ec_write(0x0c, 0x88);
+	}
 	/* If we're resuming from suspend, blink suspend LED */
 	dev0 = dev_find_slot(0, PCI_DEVFN(0,0));
 	if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC)
diff --git a/src/mainboard/lenovo/x60/mainboard_smi.c b/src/mainboard/lenovo/x60/mainboard_smi.c
index a0df76a..34f1d36 100644
--- a/src/mainboard/lenovo/x60/mainboard_smi.c
+++ b/src/mainboard/lenovo/x60/mainboard_smi.c
@@ -71,19 +71,23 @@ int mainboard_io_trap_handler(int smif)
 
 	switch (smif) {
 	case SMI_DOCK_CONNECT:
+		ec_clr_bit(0x03, 2);
 		dlpc_init();
-		if (!dock_connect()) {
+		if (!dlpc_init() && !dock_connect()) {
+			ec_set_bit(0x03, 2);
 			/* set dock LED to indicate status */
+			ec_write(0x0c, 0x09);
 			ec_write(0x0c, 0x88);
 		} else {
 			/* blink dock LED to indicate failure */
-			ec_write(0x0c, 0xc8);
+			ec_write(0x0c, 0x08);
+			ec_write(0x0c, 0xc9);
 		}
 		break;
 
 	case SMI_DOCK_DISCONNECT:
+		ec_clr_bit(0x03, 2);
 		dock_disconnect();
-		ec_write(0x0c, 0x08);
 		break;
 
 	case SMI_SAVE_CMOS:
@@ -136,6 +140,19 @@ static void mainboard_smi_handle_ec_sci(void)
 			mainboard_smi_brightness_down();
 			mainboard_smi_save_cmos();
 			break;
+			/* Fn-F9 key */
+		case 0x18:
+			/* Power loss */
+		case 0x27:
+			/* Undock Key */
+		case 0x50:
+			mainboard_io_trap_handler(SMI_DOCK_DISCONNECT);
+			break;
+			/* Dock Event */
+		case 0x37:
+		case 0x58:
+			mainboard_io_trap_handler(SMI_DOCK_CONNECT);
+			break;
 		default:
 			break;
 	}




More information about the coreboot mailing list