X60: trigger save cmos on volume/brightness change
authorSven Schnelle <svens@stackframe.org>
Sun, 12 Jun 2011 12:35:11 +0000 (14:35 +0200)
committerSven Schnelle <svens@stackframe.org>
Wed, 15 Jun 2011 06:51:18 +0000 (08:51 +0200)
Change-Id: I020e06bc311c4e4327c9d3cf2c379dc8fe070a7a
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-on: http://review.coreboot.org/25
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
src/lib/Makefile.inc
src/lib/cbfs.c
src/mainboard/lenovo/x60/acpi/ec.asl
src/mainboard/lenovo/x60/acpi/video.asl
src/mainboard/lenovo/x60/cmos.layout
src/mainboard/lenovo/x60/mainboard_smi.c
src/mainboard/lenovo/x60/smi.h
src/pc80/Makefile.inc

index 38171615ac40515b065a6b0d04631f8bec24b614..54935cabad912432261747d84fbd065c67f36b4b 100644 (file)
@@ -36,7 +36,7 @@ ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
 
 driver-$(CONFIG_CONSOLE_NE2K) += ne2k.c
 
-smm-y += memcpy.c
+smm-y += memcpy.c cbfs.c memset.c memcmp.c
 smm-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
 smm-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
 
index 690033e6b037e1dd43079a6f082c05ef290bfdb9..7cfa3e2a402926e031f64b671f468dcc931e2fe1 100644 (file)
 #include <arch/byteorder.h>
 
 
-/**
- * Decompression wrapper for CBFS
- * @param algo
- * @param src
- * @param dst
- * @param len
- * @return 0 on success, -1 on failure
- */
-static int cbfs_decompress(int algo, void *src, void *dst, int len)
-{
-       switch(algo) {
-       case CBFS_COMPRESS_NONE:
-               memcpy(dst, src, len);
-               return 0;
-
-       case CBFS_COMPRESS_LZMA:
-               if (!ulzma(src, dst)) {
-                       printk(BIOS_ERR, "CBFS: LZMA decompression failed!\n");
-                       return -1;
-               }
-               return 0;
-
-       default:
-               printk(BIOS_INFO,  "CBFS:  Unknown compression type %d\n", algo);
-               return -1;
-       }
-}
-
 static int cbfs_check_magic(struct cbfs_file *file)
 {
        return !strcmp(file->magic, CBFS_FILE_MAGIC) ? 1 : 0;
@@ -132,6 +104,7 @@ void *cbfs_find_file(const char *name, int type)
        return (void *) CBFS_SUBHEADER(file);
 }
 
+#ifndef __SMM__
 static inline int tohex4(unsigned int c)
 {
        return (c<=9)?(c+'0'):(c-10+'a');
@@ -145,6 +118,34 @@ static void tohex16(unsigned int val, char* dest)
        dest[3]=tohex4(val & 0xf);
 }
 
+/**
+ * Decompression wrapper for CBFS
+ * @param algo
+ * @param src
+ * @param dst
+ * @param len
+ * @return 0 on success, -1 on failure
+ */
+static int cbfs_decompress(int algo, void *src, void *dst, int len)
+{
+       switch(algo) {
+       case CBFS_COMPRESS_NONE:
+               memcpy(dst, src, len);
+               return 0;
+
+       case CBFS_COMPRESS_LZMA:
+               if (!ulzma(src, dst)) {
+                       printk(BIOS_ERR, "CBFS: LZMA decompression failed!\n");
+                       return -1;
+               }
+               return 0;
+       default:
+               printk(BIOS_INFO,  "CBFS:  Unknown compression type %d\n", algo);
+               return -1;
+       }
+}
+
+
 void *cbfs_load_optionrom(u16 vendor, u16 device, void * dest)
 {
        char name[17]="pciXXXX,XXXX.rom";
@@ -246,4 +247,4 @@ int run_address(void *f)
        v = f;
        return v();
 }
-
+#endif
index c3569e8c41fa57fa93012f7c3eeba76559e8fb01..5c043397251c89fbb27547f08e0a2e2b9fd336af 100644 (file)
@@ -1 +1,24 @@
 #include <ec/lenovo/h8/acpi/ec.asl>
+
+Scope(\_SB.PCI0.LPCB.EC)
+{
+       /* Volume down */
+       Method(_Q1C, 0, NotSerialized)
+       {
+               Trap(SMI_SAVE_CMOS)
+       }
+
+       /* Volume up */
+       Method(_Q1D, 0, NotSerialized)
+       {
+               Trap(SMI_SAVE_CMOS)
+       }
+
+       /* Mute key pressed */
+       Method(_Q1E, 0, NotSerialized)
+       {
+               Trap(SMI_SAVE_CMOS)
+       }
+
+
+}
index c2f9dfb4590dcff4b01c60b925bdde6f1ae8bc9a..b38d82b6a5d6c9daa2a2f8f389809ab105cd83a2 100644 (file)
@@ -19,6 +19,8 @@
  * MA 02110-1301 USA
  */
 
+#include "smi.h"
+
 Device (DSPC)
 {
        Name (_ADR, 0x00020001)
@@ -36,6 +38,7 @@ Device (DSPC)
                {
                        Subtract(Local0, 16, Local0)
                        Store(Local0, BRTC)
+                       Trap(SMI_SAVE_CMOS)
                }
        }
 
@@ -46,6 +49,7 @@ Device (DSPC)
                {
                        Add (Local0, 16, Local0)
                        Store(Local0, BRTC)
+                       Trap(SMI_SAVE_CMOS)
                }
        }
 }
index 1875e599e69e15fd253e0c2cbfc0afa4339a4bb8..a1575137c7e5f305f22216a8c2f05cccb603a250 100644 (file)
@@ -108,6 +108,7 @@ entries
 1052         4       r       0        C1DRT1
 
 1064         8       h       0        volume
+1072         8       h       0        tft_brightness
 # -----------------------------------------------------------------
 
 enumerations
index d13055ee70fd502ab55f0584b320dffd1afd2b85..769432f618565da08edfb003647ac3972cd8c350 100644 (file)
@@ -25,6 +25,8 @@
 #include <cpu/x86/smm.h>
 #include "southbridge/intel/i82801gx/nvs.h"
 #include <ec/acpi/ec.h>
+#include <pc80/mc146818rtc.h>
+#include <ec/lenovo/h8/h8.h>
 #include "dock.h"
 #include "smi.h"
 
@@ -38,7 +40,25 @@ static void mainboard_smm_init(void)
        printk(BIOS_DEBUG, "initializing SMI\n");
        /* Enable 0x1600/0x1600 register pair */
        ec_set_bit(0x00, 0x05);
-       ec_set_ports(0x1604, 0x1600);
+}
+
+static void mainboard_smi_save_cmos(void)
+{
+       u8 val;
+       u8 tmp70, tmp72, tmpcf8;
+
+       tmp70 = inb(0x70);
+       tmp72 = inb(0x72);
+       tmpcf8 = inl(0xcf8);
+
+       val = pci_read_config8(PCI_DEV(0, 2, 1), 0xf4);
+       set_option("tft_brightness", &val);
+       val = ec_read(H8_VOLUME_CONTROL);
+       set_option("volume", &val);
+
+       outb(tmp70, 0x70);
+       outb(tmp72, 0x72);
+       outb(tmpcf8, 0xcf8);
 }
 
 int mainboard_io_trap_handler(int smif)
@@ -67,6 +87,9 @@ int mainboard_io_trap_handler(int smif)
                ec_write(0x0c, 0x08);
                break;
 
+       case SMI_SAVE_CMOS:
+               mainboard_smi_save_cmos();
+               break;
        default:
                return 0;
        }
index 6eb840256abc5d3c5fa07bfe8b53fe48e499b751..ad096b9cb9d6d961c38625fdf472583fbe3ec936 100644 (file)
@@ -3,5 +3,6 @@
 
 #define SMI_DOCK_CONNECT 0x01
 #define SMI_DOCK_DISCONNECT 0x02
+#define SMI_SAVE_CMOS  0x03
 
 #endif
index 0bc57b2ced1db23e8f1f33091218b39915ce6df1..4f126f681deb91b8a985f1ee9ed7d84704680187 100644 (file)
@@ -11,3 +11,4 @@ cbfs-files-$(CONFIG_HAVE_CMOS_DEFAULT) += cmos.default
 cmos.default-file = $(CONFIG_CMOS_DEFAULT_FILE)
 cmos.default-type = 0xaa
 
+smm-y += mc146818rtc.c