[PATCH v11 8/9] Loongson: YeeLoong: Co-operate with the revisions of EC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wu Zhangjin <wuzhangjin@xxxxxxxxx>

This patch makes the platform drivers work with the revisions of EC.

  O When EC >= PQ1D26, EC will response the key of Fn+F2 and turn off
  the video output of LCD, we can no do it again in kernel.

  O When EC >= PQ1D27, EC will response the LID key and turn off the
  video output of LCD, we can not do it again in kerne.

Signed-off-by: Wu Zhangjin <wuzhangjin@xxxxxxxxx>
---
 arch/mips/include/asm/mach-loongson/loongson.h |    6 ++++
 arch/mips/loongson/common/cmdline.c            |    8 ++++++
 drivers/platform/mips/yeeloong_laptop.c        |   32 +++++++++++++++++++++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 1cf7b14..2894019 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -42,6 +42,12 @@ static inline void prom_init_uart_base(void)
 #endif
 }
 
+/*
+ * Copy kernel command line from arcs_cmdline
+ */
+#include <asm/setup.h>
+extern char loongson_cmdline[COMMAND_LINE_SIZE];
+
 /* irq operation functions */
 extern void bonito_irqdispatch(void);
 extern void __init bonito_irq_init(void);
diff --git a/arch/mips/loongson/common/cmdline.c b/arch/mips/loongson/common/cmdline.c
index 1a06def..8f290c3 100644
--- a/arch/mips/loongson/common/cmdline.c
+++ b/arch/mips/loongson/common/cmdline.c
@@ -17,10 +17,15 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  */
+#include <linux/module.h>
 #include <asm/bootinfo.h>
 
 #include <loongson.h>
 
+/* the kernel command line copied from arcs_cmdline */
+char loongson_cmdline[COMMAND_LINE_SIZE];
+EXPORT_SYMBOL(loongson_cmdline);
+
 void __init prom_init_cmdline(void)
 {
 	int prom_argc;
@@ -50,4 +55,7 @@ void __init prom_init_cmdline(void)
 		strcat(arcs_cmdline, " root=/dev/hda1");
 
 	prom_init_machtype();
+
+	/* copy arcs_cmdline into loongson_cmdline */
+	strncpy(loongson_cmdline, arcs_cmdline, COMMAND_LINE_SIZE);
 }
diff --git a/drivers/platform/mips/yeeloong_laptop.c b/drivers/platform/mips/yeeloong_laptop.c
index 4008a3f..877257a 100644
--- a/drivers/platform/mips/yeeloong_laptop.c
+++ b/drivers/platform/mips/yeeloong_laptop.c
@@ -22,8 +22,29 @@
 
 #include <cs5536/cs5536.h>
 
+#include <loongson.h>		/* for loongson_cmdline */
 #include <ec_kb3310b.h>
 
+/* common function */
+#define EC_VER_LEN 64
+
+static int ec_version_before(char *version)
+{
+	char *p, ec_ver[EC_VER_LEN];
+
+	p = strstr(loongson_cmdline, "EC_VER=");
+	if (!p)
+		memset(ec_ver, 0, EC_VER_LEN);
+	else {
+		strncpy(ec_ver, p, EC_VER_LEN);
+		p = strstr(ec_ver, " ");
+		if (p)
+			*p = '\0';
+	}
+
+	return (strncasecmp(ec_ver, version, 64) < 0);
+}
+
 /* backlight subdriver */
 #define MAX_BRIGHTNESS	8
 
@@ -527,7 +548,10 @@ static int crt_detect_handler(int status)
 
 static int black_screen_handler(int status)
 {
-	yeeloong_lcd_vo_set(status);
+	/* EC(>=PQ1D26) does this job for us, we can not do it again,
+	 * otherwise, the brightness will not resume to the normal level! */
+	if (ec_version_before("EC_VER=PQ1D26"))
+		yeeloong_lcd_vo_set(status);
 
 	return status;
 }
@@ -840,7 +864,8 @@ static void usb_ports_set(int status)
 
 static int yeeloong_suspend(struct device *dev)
 {
-	yeeloong_lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+	if (ec_version_before("EC_VER=PQ1D27"))
+		yeeloong_lcd_vo_set(BIT_DISPLAY_LCD_OFF);
 	yeeloong_crt_vo_set(BIT_CRT_DETECT_UNPLUG);
 	usb_ports_set(BIT_USB_FLAG_OFF);
 
@@ -851,7 +876,8 @@ static int yeeloong_resume(struct device *dev)
 {
 	usb_ports_set(BIT_USB_FLAG_ON);
 	yeeloong_crt_vo_set(BIT_CRT_DETECT_PLUG);
-	yeeloong_lcd_vo_set(BIT_DISPLAY_LCD_ON);
+	if (ec_version_before("EC_VER=PQ1D27"))
+		yeeloong_lcd_vo_set(BIT_DISPLAY_LCD_ON);
 
 	return 0;
 }
-- 
1.6.6



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux