From: Wu Zhangjin <wuzhangjin@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org, Wu Zhangjin <wuzhangjin@gmail.com>
Subject: [PATCH 9/9] Loongson: YeeLoong: Co-operate with the revisions of EC
Date: Sun, 23 May 2010 21:58:04 +0800 [thread overview]
Message-ID: <0d086fd3a53756f66baa8ea7cf6a34c96c199140.1274622624.git.wuzhangjin@gmail.com> (raw)
In-Reply-To: <cover.1274622624.git.wuzhangjin@gmail.com>
In-Reply-To: <cover.1274622624.git.wuzhangjin@gmail.com>
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
next prev parent reply other threads:[~2010-05-23 14:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-23 13:57 [PATCH v12 0/9] Loongson: YeeLoong: add platform specific driver Wu Zhangjin
2010-05-23 13:57 ` [PATCH 1/9] MIPS: add subdirectory for platform extension drivers Wu Zhangjin
2010-05-23 13:57 ` [PATCH 3/9] Loongson: YeeLoong: add backlight driver Wu Zhangjin
2010-05-23 13:57 ` [PATCH 4/9] Loongson: YeeLoong: add hardware monitoring driver Wu Zhangjin
2010-05-23 13:58 ` [PATCH 5/9] Loongson: YeeLoong: add video output driver Wu Zhangjin
2010-05-23 13:58 ` [PATCH 6/9] Loongson: YeeLoong: add suspend support Wu Zhangjin
2010-05-23 13:58 ` [PATCH 7/9] Loongson: YeeLoong: add input/hotkey driver Wu Zhangjin
2010-05-23 13:58 ` [PATCH 8/9] Loongson: YeeLoong: add power_supply based battery driver Wu Zhangjin
2010-05-23 13:58 ` Wu Zhangjin [this message]
2010-05-23 13:59 ` [PATCH 2/9] Loongson: YeeLoong: add platform driver Wu Zhangjin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d086fd3a53756f66baa8ea7cf6a34c96c199140.1274622624.git.wuzhangjin@gmail.com \
--to=wuzhangjin@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).