X60: use EC events 0x50/0x58 instead of GPIO GPE for Docking/Undocking
authorSven Schnelle <svens@stackframe.org>
Mon, 11 Jul 2011 16:36:16 +0000 (18:36 +0200)
committerSven Schnelle <svens@stackframe.org>
Thu, 18 Aug 2011 18:50:55 +0000 (20:50 +0200)
Change-Id: I674e5166f5fb7ba299e6f1231f30434a5bf731c5
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-on: http://review.coreboot.org/161
Tested-by: build bot (Jenkins)
src/mainboard/lenovo/x60/acpi/dock.asl
src/mainboard/lenovo/x60/acpi/gpe.asl
src/mainboard/lenovo/x60/devicetree.cb
src/mainboard/lenovo/x60/dock.c
src/mainboard/lenovo/x60/mainboard.c
src/mainboard/lenovo/x60/mainboard_smi.c

index d393f44f32c9af843cba5ad6076ded397f58b24f..136f8884b734aadbae315285fcb12b82adb88849 100644 (file)
@@ -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)
+       }
+
 }
index 11e5dc03c0f50fdcc8834482c0033037ca6c8b2b..b160b5015fe5e6386b5a8cf827901f30e9910341 100644 (file)
@@ -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)
-               }
-       }
 }
index 42a45d1a5c71193c5fb42f49a2742d77274ee337..55e0b2d4990dd52217fdc53eeba3fe59d2d5b1d8 100644 (file)
@@ -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"
index 49e2d21b1f0866a41a0e74f5d2f2152c1c4bd573..eed00a1a26a2bbf3c9d74822ee90640e57895101 100644 (file)
@@ -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 */
index 8cd68bc88e26907eb0a812fa18f38023fca056b4..bf3d8d3c6643ec6c310503e011c22c33fd33c2ce 100644 (file)
@@ -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)
index a0df76a3982a4c014cfbbb6724885db3a14779f9..34f1d36bb1d80db2d68882e66f30959411aa0a87 100644 (file)
@@ -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;
        }