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 kernel.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
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 fcdbe3a..53d0bef 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 e321c58..f6d91a5 100644
--- a/drivers/platform/mips/yeeloong_laptop.c
+++ b/drivers/platform/mips/yeeloong_laptop.c
@@ -23,8 +23,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
@@ -738,7 +759,10 @@ static int crt_detect_handler(int status)
static int displaytoggle_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;
}
@@ -1063,7 +1087,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);
@@ -1074,7 +1099,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.7.0.4
|