[coreboot-gerrit] New patch to review for coreboot: 697832f Vladimir Serbinenko's x201 drop, EC part

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Fri Jun 7 00:38:42 CEST 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3402

-gerrit

commit 697832f1539cdd72d35ea5f789b2c99d7f007194
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Fri Jun 7 00:37:07 2013 +0200

    Vladimir Serbinenko's x201 drop, EC part
    
    WIP, DO NOT SUBMIT
    
    Change-Id: Id2904e805103f98b8b50a007a73c30e7fa496a56
    Signed-off-by: Vladimir Serbinenko <phcoder at gmail.com>
---
 src/ec/acpi/Makefile.inc          |   1 +
 src/ec/acpi/ec.c                  |  13 +++
 src/ec/lenovo/h8/acpi/ec.asl      | 210 ++++++++++++++++++++++++++++++++++++--
 src/ec/lenovo/h8/acpi/thermal.asl |  11 ++
 src/ec/lenovo/h8/h8.c             |  45 ++++++--
 5 files changed, 264 insertions(+), 16 deletions(-)

diff --git a/src/ec/acpi/Makefile.inc b/src/ec/acpi/Makefile.inc
index 34c5136..b39aaa2 100644
--- a/src/ec/acpi/Makefile.inc
+++ b/src/ec/acpi/Makefile.inc
@@ -1,2 +1,3 @@
 ramstage-y += ec.c
 smm-$(CONFIG_HAVE_SMI_HANDLER) += ec.c
+romstage-$(CONFIG_BOARD_LENOVO_X201) += ec.c
diff --git a/src/ec/acpi/ec.c b/src/ec/acpi/ec.c
index d3a6aaf..ab287d6 100644
--- a/src/ec/acpi/ec.c
+++ b/src/ec/acpi/ec.c
@@ -25,9 +25,18 @@
 #include <delay.h>
 #include "ec.h"
 
+#ifdef __PRE_RAM__
+
+static const int ec_cmd_reg = EC_SC;
+static const int ec_data_reg = EC_DATA;
+
+#else
+
 static int ec_cmd_reg = EC_SC;
 static int ec_data_reg = EC_DATA;
 
+#endif
+
 int send_ec_command(u8 command)
 {
 	int timeout;
@@ -132,12 +141,16 @@ void ec_clr_bit(u8 addr, u8 bit)
 	ec_write(addr, ec_read(addr) &  ~(1 << bit));
 }
 
+#ifndef __PRE_RAM__
+
 void ec_set_ports(u16 cmd_reg, u16 data_reg)
 {
 	ec_cmd_reg = cmd_reg;
 	ec_data_reg = data_reg;
 }
 
+#endif
+
 #if !defined(__SMM__) && !defined(__PRE_RAM__)
 struct chip_operations ec_acpi_ops = {
 	CHIP_NAME("ACPI Embedded Controller")
diff --git a/src/ec/lenovo/h8/acpi/ec.asl b/src/ec/lenovo/h8/acpi/ec.asl
index 368afa8..ef09b89 100644
--- a/src/ec/lenovo/h8/acpi/ec.asl
+++ b/src/ec/lenovo/h8/acpi/ec.asl
@@ -20,21 +20,30 @@
  */
 
 #include "smi.h"
+#ifdef CONFIG_BOARD_LENOVO_X201
+#define THINKPAD_EC_GPE 0x11
+#else
+#define THINKPAD_EC_GPE 28
+#endif
 Device(EC)
 {
 	Name (_HID, EISAID("PNP0C09"))
 	Name (_UID, 0)
 
-	Name (_GPE, 28)
+	Name (_GPE, THINKPAD_EC_GPE)
 	Mutex (ECLK, 0)
 
 	OperationRegion(ERAM, EmbeddedControl, 0x00, 0x100)
 	Field (ERAM, ByteAcc, NoLock, Preserve)
 	{
+		Offset (0x02),
+		                DKR1, 1,
 		Offset (0x05),
 				HSPA, 1,
 		Offset (0x0C),
 				LEDS, 8,	/* LED state */
+		Offset (0x1a),
+		                DKR2, 1,
 		Offset (0x2a),
 				EVNT, 8,	/* write will trigger EC event */
 		Offset (0x3a),
@@ -50,7 +59,10 @@ Device(EC)
 				TMP0, 8,	/* Thermal Zone 0 temperature */
 				TMP1, 8,	/* Thermal Zone 1 temperature */
 		Offset (0x81),
-				PAGE, 8		/* Information Page Selector */
+				PAGE, 8,	/* Information Page Selector */
+		Offset (0xfe),
+		                    , 4,
+		                DKR3, 1
         }
 
 	Method (_CRS, 0)
@@ -86,9 +98,28 @@ Device(EC)
 	/* Sleep Button pressed */
 	Method(_Q13, 0, NotSerialized)
 	{
-		Notify(\_SB.PCI0.LPCB.EC.SLPB, 0x80)
+		Notify(^SLPB, 0x80)
 	}
 
+#if CONFIG_BOARD_LENOVO_X201
+	/* Brightness up GPE */
+	Method(_Q14, 0, NotSerialized)
+	{
+                Notify (\_SB.PCI0.GFX0.LCD0, 0x86)
+	}
+
+	/* Brightness down GPE */
+	Method(_Q15, 0, NotSerialized)
+	{
+                Notify (\_SB.PCI0.GFX0.LCD0, 0x87)
+	}
+
+	/* Next display GPE */
+	Method(_Q16, 0, NotSerialized)
+	{
+                Notify (\_SB.PCI0.GFX0, 0x82)
+	}
+#else
 	/* Brightness up GPE */
 	Method(_Q14, 0, NotSerialized)
 	{
@@ -100,7 +131,7 @@ Device(EC)
 	{
 		\DSPC.BRTD()
 	}
-
+#endif
 	/* AC status change: present */
 	Method(_Q26, 0, NotSerialized)
 	{
@@ -116,14 +147,181 @@ Device(EC)
 
        Method(_Q2A, 0, NotSerialized)
        {
-               Notify(\_SB.PCI0.LPCB.EC.LID, 0x80)
+               Notify(^LID, 0x80)
        }
 
        Method(_Q2B, 0, NotSerialized)
        {
-               Notify(\_SB.PCI0.LPCB.EC.LID, 0x80)
+               Notify(^LID, 0x80)
+       }
+
+
+       /* IBM proprietary buttons.  */
+
+       Method (_Q10, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x01)
+       }
+
+       Method (_Q11, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x02)
+       }
+
+       Method (_Q12, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x03)
+       }
+
+       Method (_Q64, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x05)
+       }
+
+       Method (_Q65, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x06)
+       }
+
+       Method (_Q17, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x08)
+       }
+
+       Method (_Q66, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0A)
+       }
+
+       Method (_Q6A, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x1B)
+       }
+
+       Method (_Q1A, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0B)
        }
 
+       Method (_Q1B, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0C)
+       }
+
+       Method (_Q62, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0D)
+       }
+
+       Method (_Q60, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0E)
+       }
+
+       Method (_Q61, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x0F)
+       }
+
+       Method (_Q1F, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x12)
+       }
+
+       Method (_Q67, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x13)
+       }
+
+       Method (_Q63, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x14)
+       }
+
+       Method (_Q19, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x18)
+       }
+
+#if CONFIG_BOARD_LENOVO_X201
+       Method (_Q1C, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x19)
+       }
+
+       Method (_Q1D, 0, NotSerialized)
+       {
+            ^HKEY.RHK (0x1A)
+       }
+#endif
+
+       Device (HKEY)
+       {
+               Name (_HID, EisaId ("IBM0068"))
+  	       Name (BTN, 0)
+	       /* MASK */
+	       Name (DHKN, 0x080C)
+	       /* Effective Mask */
+	       Name (EMSK, 0)
+	       Name (EN, 0)
+               Method (_STA, 0, NotSerialized)
+               {
+                    Return (0x0F)
+               }
+               Method (MHKP, 0, NotSerialized)
+               {
+	            Store (BTN, Local0)
+		    If (LEqual (Local0, Zero)) {
+		       Return (Zero)
+                    }
+		    Store (Zero, BTN)
+		    Add (Local0, 0x1000, Local0)
+		    Return (Local0)
+               }
+	       /* Report event  */
+               Method (RHK, 1, NotSerialized) {
+                      ShiftLeft (One, Subtract (Arg0, 1), Local0)
+	              If (And (EMSK, Local0)) {
+                         Store (Arg0, BTN)
+                         Notify (HKEY, 0x80)
+                      }
+               }
+               Method (MHKC, 1, NotSerialized) {
+	                 If (Arg0) {
+		                Store (DHKN, EMSK)
+			 }
+			 Else
+			 {
+				Store (Zero, EMSK)
+			 }
+                         Store (Arg0, EN)
+               }
+               Method (MHKM, 2, NotSerialized) {
+                    If (LLessEqual (Arg0, 0x20)) {
+                                ShiftLeft (One, Subtract (Arg0, 1), Local0)
+                                If (Arg1)
+                                {
+                                    Or (DHKN, Local0, DHKN)
+                                }
+                                Else
+                                {
+                                    And (DHKN, Not (Local0), DHKN)
+                                }
+                                If (EN)
+				{
+				     Store (DHKN, EMSK)
+				}
+                    }
+               }
+               Method (MHKA, 0, NotSerialized)
+               {
+                    Return (0x07FFFFFF)
+               }
+               Method (MHKV, 0, NotSerialized)
+               {
+                    Return (0x0100)
+               }
+       }
 
 #include "ac.asl"
 #include "battery.asl"
diff --git a/src/ec/lenovo/h8/acpi/thermal.asl b/src/ec/lenovo/h8/acpi/thermal.asl
index 35b6f14..70259f4 100644
--- a/src/ec/lenovo/h8/acpi/thermal.asl
+++ b/src/ec/lenovo/h8/acpi/thermal.asl
@@ -1,5 +1,9 @@
 Scope(\_TZ)
 {
+#ifdef CONFIG_BOARD_LENOVO_X201
+	Name (MEBT, 0)
+#endif
+
 	Method(C2K, 1, NotSerialized)
 	{
 		Multiply(Arg0, 10, Local0)
@@ -20,6 +24,13 @@ Scope(\_TZ)
 			Return (C2K(127))
 		}
 		Method(_TMP) {
+#ifdef CONFIG_BOARD_LENOVO_X201
+		        /* Avoid tripping alarm if ME isn't booted at all yet */
+		        If (LAnd (LNot (MEBT), LEqual (\_SB.PCI0.LPCB.EC.TMP0, 128))) {
+                            Return (C2K(40))
+                        }
+#endif
+			Store (1, MEBT)
 			Return (C2K(\_SB.PCI0.LPCB.EC.TMP0))
 		}
 	}
diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c
index 9ffdfc1..350cc77 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -27,6 +27,10 @@
 #include "chip.h"
 #include <pc80/mc146818rtc.h>
 
+#if defined (CONFIG_BOARD_LENOVO_X201) && CONFIG_BOARD_LENOVO_X201
+#include "mainboard/lenovo/x201/dock.h"
+#endif
+
 static void h8_bluetooth_enable(int on)
 {
 	if (on)
@@ -37,8 +41,7 @@ static void h8_bluetooth_enable(int on)
 
 void h8_trackpoint_enable(int on)
 {
-	ec_write(H8_TRACKPOINT_CTRL,
-		 on ? H8_TRACKPOINT_ON : H8_TRACKPOINT_OFF);
+	ec_write(H8_TRACKPOINT_CTRL, on ? H8_TRACKPOINT_ON : H8_TRACKPOINT_OFF);
 
 }
 
@@ -50,6 +53,14 @@ void h8_wlan_enable(int on)
 		ec_clr_bit(0x3a, 5);
 }
 
+static void h8_3g_enable(int on)
+{
+	if (on)
+		ec_set_bit(0x3a, 6);
+	else
+		ec_clr_bit(0x3a, 6);
+}
+
 static void h8_log_ec_version(void)
 {
 	unsigned char ecfw[9], c;
@@ -150,17 +161,31 @@ static void h8_enable(device_t dev)
 	if (!get_option(&val, "volume"))
 		ec_write(H8_VOLUME_CONTROL, val);
 
+	if (get_option(&val, "bluetooth"))
+		val = 1;
+	h8_bluetooth_enable(val);
 
-	if (!get_option(&val, "bluetooth"))
-		h8_bluetooth_enable(val);
+	if (get_option(&val, "umts"))
+		val = 1;
 
-	if (!get_option(&val, "first_battery")) {
-		tmp = ec_read(H8_CONFIG3);
-		tmp &= ~(1 << 4);
-		tmp |= (val & 1)<< 4;
-		ec_write(H8_CONFIG3, tmp);
-	}
+	h8_3g_enable(val);
+
+	if (get_option(&val, "first_battery"))
+		val = 1;
+
+	tmp = ec_read(H8_CONFIG3);
+	tmp &= ~(1 << 4);
+	tmp |= (val & 1) << 4;
+	ec_write(H8_CONFIG3, tmp);
 	h8_set_audio_mute(0);
+
+#if defined (CONFIG_BOARD_LENOVO_X201) && CONFIG_BOARD_LENOVO_X201
+	if (dock_present()) {
+		printk(BIOS_DEBUG, "dock is connected\n");
+		dock_connect();
+	} else
+		printk(BIOS_DEBUG, "dock is not connected\n");
+#endif
 }
 
 struct chip_operations ec_lenovo_h8_ops = {



More information about the coreboot-gerrit mailing list