All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers
@ 2009-11-28 13:31 Wu Zhangjin
  2009-11-28 13:31 ` [PATCH v5 1/8] Loongson: Lemote-2F: add platform specific submenu Wu Zhangjin
                   ` (8 more replies)
  0 siblings, 9 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:31 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patchset adds platform specific drivers for YeeLoong.

Changes from the v4 revision:
	
	- Split the drivers into its own module
	- Incorporates with the feedback of the Input(hotkey) driver from
	Dmitry Torokhov.
	- Cleanups and fixups

Wu Zhangjin (8):
  Loongson: Lemote-2F: add platform specific submenu
  Loongson: YeeLoong: add platform specific option
  Loongson: YeeLoong: add backlight driver
  Loongson: YeeLoong: add battery driver
  Loongson: YeeLoong: add hwmon driver
  Loongson: YeeLoong: add video output driver
  Loongson: YeeLoong: add suspend driver
  Loongson: YeeLoong: add hotkey driver

 arch/mips/kernel/setup.c                           |    1 +
 arch/mips/loongson/Kconfig                         |   21 +
 arch/mips/loongson/lemote-2f/Makefile              |    7 +-
 arch/mips/loongson/lemote-2f/ec_kb3310b.c          |  130 ------
 arch/mips/loongson/lemote-2f/ec_kb3310b.h          |  188 --------
 arch/mips/loongson/lemote-2f/pm.c                  |    4 +-
 arch/mips/loongson/lemote-2f/reset.c               |    2 +-
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |   69 +++
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |   10 +
 .../loongson/lemote-2f/yeeloong_laptop/backlight.c |   93 ++++
 .../loongson/lemote-2f/yeeloong_laptop/battery.c   |  127 ++++++
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.c         |  126 ++++++
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |  194 ++++++++
 .../loongson/lemote-2f/yeeloong_laptop/hotkey.c    |  468 ++++++++++++++++++++
 .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++
 .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++
 .../lemote-2f/yeeloong_laptop/video_output.c       |  164 +++++++
 17 files changed, 1664 insertions(+), 322 deletions(-)
 delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.c
 delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.h
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hotkey.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v5 1/8] Loongson: Lemote-2F: add platform specific submenu
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
@ 2009-11-28 13:31 ` Wu Zhangjin
  2009-11-28 13:34 ` [PATCH v5 2/8] Loongson: YeeLoong: add platform specific option Wu Zhangjin
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:31 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/loongson/Kconfig |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 3df1967..a34dfcc 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -83,3 +83,23 @@ config LOONGSON_UART_BASE
 	bool
 	default y
 	depends on EARLY_PRINTK || SERIAL_8250
+
+#
+# Loongson Platform Specific Drivers
+#
+
+menuconfig LOONGSON_PLATFORM_DEVICES
+	bool "Loongson Platform Drivers"
+	default y
+	help
+	  Say Y here to get to see options for device drivers of various
+	  loongson platforms, including vendor-specific laptop/pc extension
+	  drivers.  This option alone does not add any kernel code.
+
+	  If you say N, all options in this submenu will be skipped and disabled.
+
+if LOONGSON_PLATFORM_DEVICES
+# Put platform specific stuff here
+
+
+endif # LOONGSON_PLATFORM_DEVICES
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 2/8] Loongson: YeeLoong: add platform specific option
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
  2009-11-28 13:31 ` [PATCH v5 1/8] Loongson: Lemote-2F: add platform specific submenu Wu Zhangjin
@ 2009-11-28 13:34 ` Wu Zhangjin
  2009-11-28 13:36 ` [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangjin
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:34 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch add a new LEMOTE_YEELOONG2F option, a yeeloong_laptop/
directory for the coming yeeloong specific support, and for the
ec_kb3310b belongs to yeeloong, so, move it to yeeloong_laptop/ too.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/loongson/Kconfig                         |    1 +
 arch/mips/loongson/lemote-2f/Makefile              |    7 +-
 arch/mips/loongson/lemote-2f/ec_kb3310b.c          |  130 --------------
 arch/mips/loongson/lemote-2f/ec_kb3310b.h          |  188 --------------------
 arch/mips/loongson/lemote-2f/pm.c                  |    4 +-
 arch/mips/loongson/lemote-2f/reset.c               |    2 +-
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |   15 ++
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    3 +
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.c         |  126 +++++++++++++
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |  187 +++++++++++++++++++
 10 files changed, 341 insertions(+), 322 deletions(-)
 delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.c
 delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.h
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h

diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index a34dfcc..d440c32 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -101,5 +101,6 @@ menuconfig LOONGSON_PLATFORM_DEVICES
 if LOONGSON_PLATFORM_DEVICES
 # Put platform specific stuff here
 
+source "arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig"
 
 endif # LOONGSON_PLATFORM_DEVICES
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile
index 4d84b27..0ada6c9 100644
--- a/arch/mips/loongson/lemote-2f/Makefile
+++ b/arch/mips/loongson/lemote-2f/Makefile
@@ -2,10 +2,15 @@
 # Makefile for lemote loongson2f family machines
 #
 
-obj-y += irq.o reset.o ec_kb3310b.o
+obj-y += irq.o reset.o
 
 #
 # Suspend Support
 #
 
 obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o
+
+#
+# Platform Drivers
+#
+obj-y += yeeloong_laptop/
diff --git a/arch/mips/loongson/lemote-2f/ec_kb3310b.c b/arch/mips/loongson/lemote-2f/ec_kb3310b.c
deleted file mode 100644
index 4d84111..0000000
--- a/arch/mips/loongson/lemote-2f/ec_kb3310b.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Basic KB3310B Embedded Controller support for the YeeLoong 2F netbook
- *
- *  Copyright (C) 2008 Lemote Inc.
- *  Author: liujl <liujl@lemote.com>, 2008-04-20
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/delay.h>
-
-#include "ec_kb3310b.h"
-
-static DEFINE_SPINLOCK(index_access_lock);
-static DEFINE_SPINLOCK(port_access_lock);
-
-unsigned char ec_read(unsigned short addr)
-{
-	unsigned char value;
-	unsigned long flags;
-
-	spin_lock_irqsave(&index_access_lock, flags);
-	outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
-	outb((addr & 0x00ff), EC_IO_PORT_LOW);
-	value = inb(EC_IO_PORT_DATA);
-	spin_unlock_irqrestore(&index_access_lock, flags);
-
-	return value;
-}
-EXPORT_SYMBOL_GPL(ec_read);
-
-void ec_write(unsigned short addr, unsigned char val)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&index_access_lock, flags);
-	outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
-	outb((addr & 0x00ff), EC_IO_PORT_LOW);
-	outb(val, EC_IO_PORT_DATA);
-	/*  flush the write action */
-	inb(EC_IO_PORT_DATA);
-	spin_unlock_irqrestore(&index_access_lock, flags);
-
-	return;
-}
-EXPORT_SYMBOL_GPL(ec_write);
-
-/*
- * This function is used for EC command writes and corresponding status queries.
- */
-int ec_query_seq(unsigned char cmd)
-{
-	int timeout;
-	unsigned char status;
-	unsigned long flags;
-	int ret = 0;
-
-	spin_lock_irqsave(&port_access_lock, flags);
-
-	/* make chip goto reset mode */
-	udelay(EC_REG_DELAY);
-	outb(cmd, EC_CMD_PORT);
-	udelay(EC_REG_DELAY);
-
-	/* check if the command is received by ec */
-	timeout = EC_CMD_TIMEOUT;
-	status = inb(EC_STS_PORT);
-	while (timeout-- && (status & (1 << 1))) {
-		status = inb(EC_STS_PORT);
-		udelay(EC_REG_DELAY);
-	}
-
-	if (timeout <= 0) {
-		printk(KERN_ERR "%s: deadable error : timeout...\n", __func__);
-		ret = -EINVAL;
-	} else
-		printk(KERN_INFO
-			   "(%x/%d)ec issued command %d status : 0x%x\n",
-			   timeout, EC_CMD_TIMEOUT - timeout, cmd, status);
-
-	spin_unlock_irqrestore(&port_access_lock, flags);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(ec_query_seq);
-
-/*
- * Send query command to EC to get the proper event number
- */
-int ec_query_event_num(void)
-{
-	return ec_query_seq(CMD_GET_EVENT_NUM);
-}
-EXPORT_SYMBOL(ec_query_event_num);
-
-/*
- * Get event number from EC
- *
- * NOTE: This routine must follow the query_event_num function in the
- * interrupt.
- */
-int ec_get_event_num(void)
-{
-	int timeout = 100;
-	unsigned char value;
-	unsigned char status;
-
-	udelay(EC_REG_DELAY);
-	status = inb(EC_STS_PORT);
-	udelay(EC_REG_DELAY);
-	while (timeout-- && !(status & (1 << 0))) {
-		status = inb(EC_STS_PORT);
-		udelay(EC_REG_DELAY);
-	}
-	if (timeout <= 0) {
-		pr_info("%s: get event number timeout.\n", __func__);
-
-		return -EINVAL;
-	}
-	value = inb(EC_DAT_PORT);
-	udelay(EC_REG_DELAY);
-
-	return value;
-}
-EXPORT_SYMBOL(ec_get_event_num);
diff --git a/arch/mips/loongson/lemote-2f/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/ec_kb3310b.h
deleted file mode 100644
index 1595a21..0000000
--- a/arch/mips/loongson/lemote-2f/ec_kb3310b.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * KB3310B Embedded Controller
- *
- *  Copyright (C) 2008 Lemote Inc.
- *  Author: liujl <liujl@lemote.com>, 2008-03-14
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef _EC_KB3310B_H
-#define _EC_KB3310B_H
-
-extern unsigned char ec_read(unsigned short addr);
-extern void ec_write(unsigned short addr, unsigned char val);
-extern int ec_query_seq(unsigned char cmd);
-extern int ec_query_event_num(void);
-extern int ec_get_event_num(void);
-
-typedef int (*sci_handler) (int status);
-extern sci_handler yeeloong_report_lid_status;
-
-#define SCI_IRQ_NUM 0x0A
-
-/*
- * The following registers are determined by the EC index configuration.
- * 1, fill the PORT_HIGH as EC register high part.
- * 2, fill the PORT_LOW as EC register low part.
- * 3, fill the PORT_DATA as EC register write data or get the data from it.
- */
-#define	EC_IO_PORT_HIGH	0x0381
-#define	EC_IO_PORT_LOW	0x0382
-#define	EC_IO_PORT_DATA	0x0383
-
-/*
- * EC delay time is 500us for register and status access
- */
-#define	EC_REG_DELAY	500	/* unit : us */
-#define	EC_CMD_TIMEOUT	0x1000
-
-/*
- * EC access port for SCI communication
- */
-#define	EC_CMD_PORT		0x66
-#define	EC_STS_PORT		0x66
-#define	EC_DAT_PORT		0x62
-#define	CMD_INIT_IDLE_MODE	0xdd
-#define	CMD_EXIT_IDLE_MODE	0xdf
-#define	CMD_INIT_RESET_MODE	0xd8
-#define	CMD_REBOOT_SYSTEM	0x8c
-#define	CMD_GET_EVENT_NUM	0x84
-#define	CMD_PROGRAM_PIECE	0xda
-
-/* temperature & fan registers */
-#define	REG_TEMPERATURE_VALUE	0xF458
-#define	REG_FAN_AUTO_MAN_SWITCH 0xF459
-#define	BIT_FAN_AUTO		0
-#define	BIT_FAN_MANUAL		1
-#define	REG_FAN_CONTROL		0xF4D2
-#define	BIT_FAN_CONTROL_ON	(1 << 0)
-#define	BIT_FAN_CONTROL_OFF	(0 << 0)
-#define	REG_FAN_STATUS		0xF4DA
-#define	BIT_FAN_STATUS_ON	(1 << 0)
-#define	BIT_FAN_STATUS_OFF	(0 << 0)
-#define	REG_FAN_SPEED_HIGH	0xFE22
-#define	REG_FAN_SPEED_LOW	0xFE23
-#define	REG_FAN_SPEED_LEVEL	0xF4CC
-/* fan speed divider */
-#define	FAN_SPEED_DIVIDER	480000	/* (60*1000*1000/62.5/2)*/
-
-/* battery registers */
-#define	REG_BAT_DESIGN_CAP_HIGH		0xF77D
-#define	REG_BAT_DESIGN_CAP_LOW		0xF77E
-#define	REG_BAT_FULLCHG_CAP_HIGH	0xF780
-#define	REG_BAT_FULLCHG_CAP_LOW		0xF781
-#define	REG_BAT_DESIGN_VOL_HIGH		0xF782
-#define	REG_BAT_DESIGN_VOL_LOW		0xF783
-#define	REG_BAT_CURRENT_HIGH		0xF784
-#define	REG_BAT_CURRENT_LOW		0xF785
-#define	REG_BAT_VOLTAGE_HIGH		0xF786
-#define	REG_BAT_VOLTAGE_LOW		0xF787
-#define	REG_BAT_TEMPERATURE_HIGH	0xF788
-#define	REG_BAT_TEMPERATURE_LOW		0xF789
-#define	REG_BAT_RELATIVE_CAP_HIGH	0xF492
-#define	REG_BAT_RELATIVE_CAP_LOW	0xF493
-#define	REG_BAT_VENDOR			0xF4C4
-#define	FLAG_BAT_VENDOR_SANYO		0x01
-#define	FLAG_BAT_VENDOR_SIMPLO		0x02
-#define	REG_BAT_CELL_COUNT		0xF4C6
-#define	FLAG_BAT_CELL_3S1P		0x03
-#define	FLAG_BAT_CELL_3S2P		0x06
-#define	REG_BAT_CHARGE			0xF4A2
-#define	FLAG_BAT_CHARGE_DISCHARGE	0x01
-#define	FLAG_BAT_CHARGE_CHARGE		0x02
-#define	FLAG_BAT_CHARGE_ACPOWER		0x00
-#define	REG_BAT_STATUS			0xF4B0
-#define	BIT_BAT_STATUS_LOW		(1 << 5)
-#define	BIT_BAT_STATUS_DESTROY		(1 << 2)
-#define	BIT_BAT_STATUS_FULL		(1 << 1)
-#define	BIT_BAT_STATUS_IN		(1 << 0)
-#define	REG_BAT_CHARGE_STATUS		0xF4B1
-#define	BIT_BAT_CHARGE_STATUS_OVERTEMP	(1 << 2)
-#define	BIT_BAT_CHARGE_STATUS_PRECHG	(1 << 1)
-#define	REG_BAT_STATE			0xF482
-#define	BIT_BAT_STATE_CHARGING		(1 << 1)
-#define	BIT_BAT_STATE_DISCHARGING	(1 << 0)
-#define	REG_BAT_POWER			0xF440
-#define	BIT_BAT_POWER_S3		(1 << 2)
-#define	BIT_BAT_POWER_ON		(1 << 1)
-#define	BIT_BAT_POWER_ACIN		(1 << 0)
-
-/* other registers */
-/* Audio: rd/wr */
-#define	REG_AUDIO_VOLUME	0xF46C
-#define	REG_AUDIO_MUTE		0xF4E7
-#define	REG_AUDIO_BEEP		0xF4D0
-/* USB port power or not: rd/wr */
-#define	REG_USB0_FLAG		0xF461
-#define	REG_USB1_FLAG		0xF462
-#define	REG_USB2_FLAG		0xF463
-#define	BIT_USB_FLAG_ON		1
-#define	BIT_USB_FLAG_OFF	0
-/* LID */
-#define	REG_LID_DETECT		0xF4BD
-#define	BIT_LID_DETECT_ON	1
-#define	BIT_LID_DETECT_OFF	0
-/* CRT */
-#define	REG_CRT_DETECT		0xF4AD
-#define	BIT_CRT_DETECT_PLUG	1
-#define	BIT_CRT_DETECT_UNPLUG	0
-/* LCD backlight brightness adjust: 9 levels */
-#define	REG_DISPLAY_BRIGHTNESS	0xF4F5
-/* Black screen Status */
-#define	BIT_DISPLAY_LCD_ON	1
-#define	BIT_DISPLAY_LCD_OFF	0
-/* LCD backlight control: off/restore */
-#define	REG_BACKLIGHT_CTRL	0xF7BD
-#define	BIT_BACKLIGHT_ON	1
-#define	BIT_BACKLIGHT_OFF	0
-/* Reset the machine auto-clear: rd/wr */
-#define	REG_RESET		0xF4EC
-#define	BIT_RESET_ON		1
-/* Light the led: rd/wr */
-#define	REG_LED			0xF4C8
-#define	BIT_LED_RED_POWER	(1 << 0)
-#define	BIT_LED_ORANGE_POWER	(1 << 1)
-#define	BIT_LED_GREEN_CHARGE	(1 << 2)
-#define	BIT_LED_RED_CHARGE	(1 << 3)
-#define	BIT_LED_NUMLOCK		(1 << 4)
-/* Test led mode, all led on/off */
-#define	REG_LED_TEST		0xF4C2
-#define	BIT_LED_TEST_IN		1
-#define	BIT_LED_TEST_OUT	0
-/* Camera on/off */
-#define	REG_CAMERA_STATUS	0xF46A
-#define	BIT_CAMERA_STATUS_ON	1
-#define	BIT_CAMERA_STATUS_OFF	0
-#define	REG_CAMERA_CONTROL	0xF7B7
-#define	BIT_CAMERA_CONTROL_OFF	0
-#define	BIT_CAMERA_CONTROL_ON	1
-/* Wlan Status */
-#define	REG_WLAN		0xF4FA
-#define	BIT_WLAN_ON		1
-#define	BIT_WLAN_OFF		0
-#define	REG_DISPLAY_LCD		0xF79F
-
-/* SCI Event Number from EC */
-enum {
-	EVENT_LID = 0x23,	/*  LID open/close */
-	EVENT_DISPLAY_TOGGLE,	/*  Fn+F3 for display switch */
-	EVENT_SLEEP,		/*  Fn+F1 for entering sleep mode */
-	EVENT_OVERTEMP,		/*  Over-temperature happened */
-	EVENT_CRT_DETECT,	/*  CRT is connected */
-	EVENT_CAMERA,		/*  Camera on/off */
-	EVENT_USB_OC2,		/*  USB2 Over Current occurred */
-	EVENT_USB_OC0,		/*  USB0 Over Current occurred */
-	EVENT_BLACK_SCREEN,	/*  Turn on/off backlight */
-	EVENT_AUDIO_MUTE,	/*  Mute on/off */
-	EVENT_DISPLAY_BRIGHTNESS,/* LCD backlight brightness adjust */
-	EVENT_AC_BAT,		/*  AC & Battery relative issue */
-	EVENT_AUDIO_VOLUME,	/*  Volume adjust */
-	EVENT_WLAN,		/*  Wlan on/off */
-	EVENT_END
-};
-
-#endif /* !_EC_KB3310B_H */
diff --git a/arch/mips/loongson/lemote-2f/pm.c b/arch/mips/loongson/lemote-2f/pm.c
index d7af2e6..a3947aa 100644
--- a/arch/mips/loongson/lemote-2f/pm.c
+++ b/arch/mips/loongson/lemote-2f/pm.c
@@ -23,7 +23,7 @@
 #include <loongson.h>
 
 #include <cs5536/cs5536_mfgpt.h>
-#include "ec_kb3310b.h"
+#include "yeeloong_laptop/ec_kb3310b.h"
 
 #define I8042_KBD_IRQ		1
 #define I8042_CTR_KBDINT	0x01
@@ -100,7 +100,7 @@ int wakeup_loongson(void)
 	if (irq < 0)
 		return 0;
 
-	printk(KERN_INFO "%s: irq = %d\n", __func__, irq);
+	pr_info("%s: irq = %d\n", __func__, irq);
 
 	if (irq == I8042_KBD_IRQ)
 		return 1;
diff --git a/arch/mips/loongson/lemote-2f/reset.c b/arch/mips/loongson/lemote-2f/reset.c
index 51d1a60..d996a55 100644
--- a/arch/mips/loongson/lemote-2f/reset.c
+++ b/arch/mips/loongson/lemote-2f/reset.c
@@ -20,7 +20,7 @@
 #include <loongson.h>
 
 #include <cs5536/cs5536.h>
-#include "ec_kb3310b.h"
+#include "yeeloong_laptop/ec_kb3310b.h"
 
 static void reset_cpu(void)
 {
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
new file mode 100644
index 0000000..d6df9b7
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -0,0 +1,15 @@
+menuconfig LEMOTE_YEELOONG2F
+	bool "Lemote YeeLoong Laptop"
+	depends on LEMOTE_MACH2F
+	default y
+	help
+	  YeeLoong netbook is a mini laptop made by Lemote, which is basically
+	  compatible to FuLoong2F mini PC, but it has an extra Embedded
+	  Controller(kb3310b) for battery, hotkey, backlight, temperature and
+	  fan management.
+
+if LEMOTE_YEELOONG2F
+
+
+
+endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
new file mode 100644
index 0000000..90c4ce5
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -0,0 +1,3 @@
+# YeeLoong Specific
+
+obj-y += ec_kb3310b.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c
new file mode 100644
index 0000000..cefcc72
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c
@@ -0,0 +1,126 @@
+/*
+ * Basic KB3310B Embedded Controller support for the YeeLoong 2F netbook
+ *
+ *  Copyright (C) 2008 Lemote Inc.
+ *  Author: liujl <liujl@lemote.com>, 2008-04-20
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+
+#include "ec_kb3310b.h"
+
+static DEFINE_SPINLOCK(index_access_lock);
+static DEFINE_SPINLOCK(port_access_lock);
+
+unsigned char ec_read(unsigned short addr)
+{
+	unsigned char value;
+	unsigned long flags;
+
+	spin_lock_irqsave(&index_access_lock, flags);
+	outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
+	outb((addr & 0x00ff), EC_IO_PORT_LOW);
+	value = inb(EC_IO_PORT_DATA);
+	spin_unlock_irqrestore(&index_access_lock, flags);
+
+	return value;
+}
+EXPORT_SYMBOL_GPL(ec_read);
+
+void ec_write(unsigned short addr, unsigned char val)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&index_access_lock, flags);
+	outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
+	outb((addr & 0x00ff), EC_IO_PORT_LOW);
+	outb(val, EC_IO_PORT_DATA);
+	/*  flush the write action */
+	inb(EC_IO_PORT_DATA);
+	spin_unlock_irqrestore(&index_access_lock, flags);
+
+	return;
+}
+EXPORT_SYMBOL_GPL(ec_write);
+
+/*
+ * This function is used for EC command writes and corresponding status queries.
+ */
+int ec_query_seq(unsigned char cmd)
+{
+	int timeout;
+	unsigned char status;
+	unsigned long flags;
+	int ret = 0;
+
+	spin_lock_irqsave(&port_access_lock, flags);
+
+	/* make chip goto reset mode */
+	udelay(EC_REG_DELAY);
+	outb(cmd, EC_CMD_PORT);
+	udelay(EC_REG_DELAY);
+
+	/* check if the command is received by ec */
+	timeout = EC_CMD_TIMEOUT;
+	status = inb(EC_STS_PORT);
+	while (timeout-- && (status & (1 << 1))) {
+		status = inb(EC_STS_PORT);
+		udelay(EC_REG_DELAY);
+	}
+
+	if (timeout <= 0) {
+		pr_err("%s: deadable error : timeout...\n", __func__);
+		ret = -EINVAL;
+	}
+
+	spin_unlock_irqrestore(&port_access_lock, flags);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(ec_query_seq);
+
+/*
+ * Send query command to EC to get the proper event number
+ */
+int ec_query_event_num(void)
+{
+	return ec_query_seq(CMD_GET_EVENT_NUM);
+}
+EXPORT_SYMBOL(ec_query_event_num);
+
+/*
+ * Get event number from EC
+ *
+ * NOTE: This routine must follow the query_event_num function in the
+ * interrupt.
+ */
+int ec_get_event_num(void)
+{
+	int timeout = 100;
+	unsigned char value;
+	unsigned char status;
+
+	udelay(EC_REG_DELAY);
+	status = inb(EC_STS_PORT);
+	udelay(EC_REG_DELAY);
+	while (timeout-- && !(status & (1 << 0))) {
+		status = inb(EC_STS_PORT);
+		udelay(EC_REG_DELAY);
+	}
+	if (timeout <= 0) {
+		pr_err("%s: get event number timeout.\n", __func__);
+		return -EINVAL;
+	}
+	value = inb(EC_DAT_PORT);
+	udelay(EC_REG_DELAY);
+
+	return value;
+}
+EXPORT_SYMBOL(ec_get_event_num);
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
new file mode 100644
index 0000000..762d888
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -0,0 +1,187 @@
+/*
+ * KB3310B Embedded Controller
+ *
+ *  Copyright (C) 2008 Lemote Inc.
+ *  Author: liujl <liujl@lemote.com>, 2008-03-14
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _EC_KB3310B_H
+#define _EC_KB3310B_H
+
+extern unsigned char ec_read(unsigned short addr);
+extern void ec_write(unsigned short addr, unsigned char val);
+extern int ec_query_seq(unsigned char cmd);
+extern int ec_query_event_num(void);
+extern int ec_get_event_num(void);
+
+typedef int (*sci_handler) (int status);
+extern sci_handler yeeloong_report_lid_status;
+
+#define SCI_IRQ_NUM 0x0A
+
+/*
+ * The following registers are determined by the EC index configuration.
+ * 1, fill the PORT_HIGH as EC register high part.
+ * 2, fill the PORT_LOW as EC register low part.
+ * 3, fill the PORT_DATA as EC register write data or get the data from it.
+ */
+#define	EC_IO_PORT_HIGH	0x0381
+#define	EC_IO_PORT_LOW	0x0382
+#define	EC_IO_PORT_DATA	0x0383
+
+/*
+ * EC delay time is 500us for register and status access
+ */
+#define	EC_REG_DELAY	500	/* unit : us */
+#define	EC_CMD_TIMEOUT	0x1000
+
+/*
+ * EC access port for SCI communication
+ */
+#define	EC_CMD_PORT		0x66
+#define	EC_STS_PORT		0x66
+#define	EC_DAT_PORT		0x62
+#define	CMD_INIT_IDLE_MODE	0xdd
+#define	CMD_EXIT_IDLE_MODE	0xdf
+#define	CMD_INIT_RESET_MODE	0xd8
+#define	CMD_REBOOT_SYSTEM	0x8c
+#define	CMD_GET_EVENT_NUM	0x84
+#define	CMD_PROGRAM_PIECE	0xda
+
+/* Temperature & Fan registers */
+#define	REG_TEMPERATURE_VALUE	0xF458
+#define	REG_FAN_AUTO_MAN_SWITCH 0xF459
+#define	BIT_FAN_AUTO		0
+#define	BIT_FAN_MANUAL		1
+#define	REG_FAN_CONTROL		0xF4D2
+#define	BIT_FAN_CONTROL_ON	(1 << 0)
+#define	BIT_FAN_CONTROL_OFF	(0 << 0)
+#define	REG_FAN_STATUS		0xF4DA
+#define	BIT_FAN_STATUS_ON	(1 << 0)
+#define	BIT_FAN_STATUS_OFF	(0 << 0)
+#define	REG_FAN_SPEED_HIGH	0xFE22
+#define	REG_FAN_SPEED_LOW	0xFE23
+#define	REG_FAN_SPEED_LEVEL	0xF4CC
+/* Fan speed divider */
+#define	FAN_SPEED_DIVIDER	480000	/* (60*1000*1000/62.5/2)*/
+
+/* Battery registers */
+#define	REG_BAT_DESIGN_CAP_HIGH		0xF77D
+#define	REG_BAT_DESIGN_CAP_LOW		0xF77E
+#define	REG_BAT_FULLCHG_CAP_HIGH	0xF780
+#define	REG_BAT_FULLCHG_CAP_LOW		0xF781
+#define	REG_BAT_DESIGN_VOL_HIGH		0xF782
+#define	REG_BAT_DESIGN_VOL_LOW		0xF783
+#define	REG_BAT_CURRENT_HIGH		0xF784
+#define	REG_BAT_CURRENT_LOW		0xF785
+#define	REG_BAT_VOLTAGE_HIGH		0xF786
+#define	REG_BAT_VOLTAGE_LOW		0xF787
+#define	REG_BAT_TEMPERATURE_HIGH	0xF788
+#define	REG_BAT_TEMPERATURE_LOW		0xF789
+#define	REG_BAT_RELATIVE_CAP_HIGH	0xF492
+#define	REG_BAT_RELATIVE_CAP_LOW	0xF493
+#define	REG_BAT_VENDOR			0xF4C4
+#define	FLAG_BAT_VENDOR_SANYO		0x01
+#define	FLAG_BAT_VENDOR_SIMPLO		0x02
+#define	REG_BAT_CELL_COUNT		0xF4C6
+#define	FLAG_BAT_CELL_3S1P		0x03
+#define	FLAG_BAT_CELL_3S2P		0x06
+#define	REG_BAT_CHARGE			0xF4A2
+#define	FLAG_BAT_CHARGE_DISCHARGE	0x01
+#define	FLAG_BAT_CHARGE_CHARGE		0x02
+#define	FLAG_BAT_CHARGE_ACPOWER		0x00
+#define	REG_BAT_STATUS			0xF4B0
+#define	BIT_BAT_STATUS_LOW		(1 << 5)
+#define	BIT_BAT_STATUS_DESTROY		(1 << 2)
+#define	BIT_BAT_STATUS_FULL		(1 << 1)
+#define	BIT_BAT_STATUS_IN		(1 << 0)
+#define	REG_BAT_CHARGE_STATUS		0xF4B1
+#define	BIT_BAT_CHARGE_STATUS_OVERTEMP	(1 << 2)
+#define	BIT_BAT_CHARGE_STATUS_PRECHG	(1 << 1)
+#define	REG_BAT_STATE			0xF482
+#define	BIT_BAT_STATE_CHARGING		(1 << 1)
+#define	BIT_BAT_STATE_DISCHARGING	(1 << 0)
+#define	REG_BAT_POWER			0xF440
+#define	BIT_BAT_POWER_S3		(1 << 2)
+#define	BIT_BAT_POWER_ON		(1 << 1)
+#define	BIT_BAT_POWER_ACIN		(1 << 0)
+
+/* Audio: rd/wr */
+#define	REG_AUDIO_VOLUME	0xF46C
+#define	REG_AUDIO_MUTE		0xF4E7
+#define	REG_AUDIO_BEEP		0xF4D0
+/* USB port power or not: rd/wr */
+#define	REG_USB0_FLAG		0xF461
+#define	REG_USB1_FLAG		0xF462
+#define	REG_USB2_FLAG		0xF463
+#define	BIT_USB_FLAG_ON		1
+#define	BIT_USB_FLAG_OFF	0
+/* LID */
+#define	REG_LID_DETECT		0xF4BD
+#define	BIT_LID_DETECT_ON	1
+#define	BIT_LID_DETECT_OFF	0
+/* CRT */
+#define	REG_CRT_DETECT		0xF4AD
+#define	BIT_CRT_DETECT_PLUG	1
+#define	BIT_CRT_DETECT_UNPLUG	0
+/* LCD backlight brightness adjust: 9 levels */
+#define	REG_DISPLAY_BRIGHTNESS	0xF4F5
+/* Black screen Status */
+#define	BIT_DISPLAY_LCD_ON	1
+#define	BIT_DISPLAY_LCD_OFF	0
+/* LCD backlight control: off/restore */
+#define	REG_BACKLIGHT_CTRL	0xF7BD
+#define	BIT_BACKLIGHT_ON	1
+#define	BIT_BACKLIGHT_OFF	0
+/* Reset the machine auto-clear: rd/wr */
+#define	REG_RESET		0xF4EC
+#define	BIT_RESET_ON		1
+/* Light the led: rd/wr */
+#define	REG_LED			0xF4C8
+#define	BIT_LED_RED_POWER	(1 << 0)
+#define	BIT_LED_ORANGE_POWER	(1 << 1)
+#define	BIT_LED_GREEN_CHARGE	(1 << 2)
+#define	BIT_LED_RED_CHARGE	(1 << 3)
+#define	BIT_LED_NUMLOCK		(1 << 4)
+/* Test led mode, all led on/off */
+#define	REG_LED_TEST		0xF4C2
+#define	BIT_LED_TEST_IN		1
+#define	BIT_LED_TEST_OUT	0
+/* Camera on/off */
+#define	REG_CAMERA_STATUS	0xF46A
+#define	BIT_CAMERA_STATUS_ON	1
+#define	BIT_CAMERA_STATUS_OFF	0
+#define	REG_CAMERA_CONTROL	0xF7B7
+#define	BIT_CAMERA_CONTROL_OFF	0
+#define	BIT_CAMERA_CONTROL_ON	1
+/* Wlan Status */
+#define	REG_WLAN		0xF4FA
+#define	BIT_WLAN_ON		1
+#define	BIT_WLAN_OFF		0
+#define	REG_DISPLAY_LCD		0xF79F
+
+/* SCI Event Number from EC */
+enum {
+	EVENT_LID = 0x23,	/*  Turn on/off LID */
+	EVENT_DISPLAY_TOGGLE,	/*  Fn+F3 for display switch */
+	EVENT_SLEEP,		/*  Fn+F1 for entering sleep mode */
+	EVENT_OVERTEMP,		/*  Over-temperature happened */
+	EVENT_CRT_DETECT,	/*  CRT is connected */
+	EVENT_CAMERA,		/*  Camera on/off */
+	EVENT_USB_OC2,		/*  USB2 Over Current occurred */
+	EVENT_USB_OC0,		/*  USB0 Over Current occurred */
+	EVENT_BLACK_SCREEN,	/*  Turn on/off backlight */
+	EVENT_AUDIO_MUTE,	/*  Mute on/off */
+	EVENT_DISPLAY_BRIGHTNESS,/* LCD backlight brightness adjust */
+	EVENT_AC_BAT,		/*  AC & Battery relative issue */
+	EVENT_AUDIO_VOLUME,	/*  Volume adjust */
+	EVENT_WLAN,		/*  Wlan on/off */
+	EVENT_END
+};
+
+#endif /* !_EC_KB3310B_H */
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
  2009-11-28 13:31 ` [PATCH v5 1/8] Loongson: Lemote-2F: add platform specific submenu Wu Zhangjin
  2009-11-28 13:34 ` [PATCH v5 2/8] Loongson: YeeLoong: add platform specific option Wu Zhangjin
@ 2009-11-28 13:36 ` Wu Zhangjin
  2009-11-30  5:22   ` Wu Zhangjin
  2009-11-28 13:37 ` [PATCH v5 4/8] Loongson: YeeLoong: add battery driver Wu Zhangjin
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:36 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Richard Purdie,
	Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds YeeLoong Backlight Driver, which provides standard
interface for user-space applications to control the brightness of the
backlight.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++-
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    2 +
 .../loongson/lemote-2f/yeeloong_laptop/backlight.c |   93 ++++++++++++++++++++
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    1 +
 4 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index d6df9b7..02d36d8 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -10,6 +10,13 @@ menuconfig LEMOTE_YEELOONG2F
 
 if LEMOTE_YEELOONG2F
 
-
+config YEELOONG_BACKLIGHT
+	tristate "Backlight Driver"
+	select BACKLIGHT_CLASS_DEVICE
+	default y
+	help
+	  This option adds YeeLoong Backlight Driver, which provides standard
+	  interface for user-space applications to control the brightness of
+	  the backlight.
 
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 90c4ce5..8ad1e9d 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -1,3 +1,5 @@
 # YeeLoong Specific
 
 obj-y += ec_kb3310b.o
+
+obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c
new file mode 100644
index 0000000..481d2ca
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c
@@ -0,0 +1,93 @@
+/*
+ * YeeLoong Backlight Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop backlight driver");
+MODULE_LICENSE("GPL");
+
+static int yeeloong_set_brightness(struct backlight_device *bd)
+{
+	unsigned int level, current_level;
+	static unsigned int old_level;
+
+	level = (bd->props.fb_blank == FB_BLANK_UNBLANK &&
+		 bd->props.power == FB_BLANK_UNBLANK) ?
+	    bd->props.brightness : 0;
+
+	if (level > MAX_BRIGHTNESS)
+		level = MAX_BRIGHTNESS;
+	else if (level < 0)
+		level = 0;
+
+	/* Avoid to modify the brightness when EC is tuning it */
+	current_level = ec_read(REG_DISPLAY_BRIGHTNESS);
+	if ((old_level == current_level) && (old_level != level))
+		ec_write(REG_DISPLAY_BRIGHTNESS, level);
+	old_level = level;
+
+	return 0;
+}
+
+static int yeeloong_get_brightness(struct backlight_device *bd)
+{
+	return (int)ec_read(REG_DISPLAY_BRIGHTNESS);
+}
+
+static struct backlight_ops backlight_ops = {
+	.get_brightness = yeeloong_get_brightness,
+	.update_status = yeeloong_set_brightness,
+};
+
+static struct backlight_device *yeeloong_backlight_dev;
+
+static int __init yeeloong_backlight_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	yeeloong_backlight_dev = backlight_device_register("backlight0", NULL,
+			NULL, &backlight_ops);
+
+	if (IS_ERR(yeeloong_backlight_dev)) {
+		ret = PTR_ERR(yeeloong_backlight_dev);
+		yeeloong_backlight_dev = NULL;
+		return ret;
+	}
+
+	yeeloong_backlight_dev->props.max_brightness = MAX_BRIGHTNESS;
+	yeeloong_backlight_dev->props.brightness =
+		yeeloong_get_brightness(yeeloong_backlight_dev);
+	backlight_update_status(yeeloong_backlight_dev);
+
+	return 0;
+}
+
+static void __exit yeeloong_backlight_exit(void)
+{
+	if (yeeloong_backlight_dev) {
+		backlight_device_unregister(yeeloong_backlight_dev);
+		yeeloong_backlight_dev = NULL;
+	}
+}
+
+module_init(yeeloong_backlight_init);
+module_exit(yeeloong_backlight_exit);
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
index 762d888..0e3b5ad 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -23,6 +23,7 @@ typedef int (*sci_handler) (int status);
 extern sci_handler yeeloong_report_lid_status;
 
 #define SCI_IRQ_NUM 0x0A
+#define MAX_BRIGHTNESS 8
 
 /*
  * The following registers are determined by the EC index configuration.
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 4/8] Loongson: YeeLoong: add battery driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
                   ` (2 preceding siblings ...)
  2009-11-28 13:36 ` [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangjin
@ 2009-11-28 13:37 ` Wu Zhangjin
  2009-11-30  5:22   ` Wu Zhangjin
  2009-11-28 13:38   ` [lm-sensors] " Wu Zhangjin
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:37 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Jamey Hicks,
	Stephen Rothwell, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds APM_EMULATION based Battery Driver, which provides
standard interface for user-space applications to manage the battery.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../loongson/lemote-2f/yeeloong_laptop/battery.c   |  127 ++++++++++++++++++++
 3 files changed, 137 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index 02d36d8..e284c91 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -19,4 +19,13 @@ config YEELOONG_BACKLIGHT
 	  interface for user-space applications to control the brightness of
 	  the backlight.
 
+config YEELOONG_BATTERY
+	tristate "Battery Driver"
+	select SYS_SUPPORTS_APM_EMULATION
+	select APM_EMULATION
+	default y
+	help
+	  This option adds APM emulated Battery Driver, which provides standard
+	  interface for user-space applications to manage the battery.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 8ad1e9d..20fe0c6 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -3,3 +3,4 @@
 obj-y += ec_kb3310b.o
 
 obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
+obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c
new file mode 100644
index 0000000..2a94292
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c
@@ -0,0 +1,127 @@
+/*
+ * YeeLoong Battery Driver: APM emulated support
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Liu Junliang <liujl@lemote.com>
+ *          Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/apm-emulation.h>
+#include <linux/err.h>
+#include <linux/module.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Liu Junliang <liujl@lemote.com>; Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop battery driver");
+MODULE_LICENSE("GPL");
+
+static void get_fixed_battery_info(void)
+{
+	int design_cap, full_charged_cap, design_vol, vendor, cell_count;
+
+	design_cap = (ec_read(REG_BAT_DESIGN_CAP_HIGH) << 8)
+	    | ec_read(REG_BAT_DESIGN_CAP_LOW);
+	full_charged_cap = (ec_read(REG_BAT_FULLCHG_CAP_HIGH) << 8)
+	    | ec_read(REG_BAT_FULLCHG_CAP_LOW);
+	design_vol = (ec_read(REG_BAT_DESIGN_VOL_HIGH) << 8)
+	    | ec_read(REG_BAT_DESIGN_VOL_LOW);
+	vendor = ec_read(REG_BAT_VENDOR);
+	cell_count = ec_read(REG_BAT_CELL_COUNT);
+
+	if (vendor != 0) {
+		pr_info("battery vendor(%s), cells count(%d), "
+		       "with designed capacity(%d),designed voltage(%d),"
+		       " full charged capacity(%d)\n",
+		       (vendor ==
+			FLAG_BAT_VENDOR_SANYO) ? "SANYO" : "SIMPLO",
+		       (cell_count == FLAG_BAT_CELL_3S1P) ? 3 : 6,
+		       design_cap, design_vol,
+		       full_charged_cap);
+	}
+}
+
+#define APM_CRITICAL		5
+
+static void get_power_status(struct apm_power_info *info)
+{
+	unsigned char bat_status;
+
+	info->battery_status = APM_BATTERY_STATUS_UNKNOWN;
+	info->battery_flag = APM_BATTERY_FLAG_UNKNOWN;
+	info->units = APM_UNITS_MINS;
+
+	info->battery_life = (ec_read(REG_BAT_RELATIVE_CAP_HIGH) << 8) |
+		(ec_read(REG_BAT_RELATIVE_CAP_LOW));
+
+	info->ac_line_status = (ec_read(REG_BAT_POWER) & BIT_BAT_POWER_ACIN) ?
+		APM_AC_ONLINE : APM_AC_OFFLINE;
+
+	bat_status = ec_read(REG_BAT_STATUS);
+
+	if (!(bat_status & BIT_BAT_STATUS_IN)) {
+		/* no battery inserted */
+		info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
+		info->battery_flag = APM_BATTERY_FLAG_NOT_PRESENT;
+		info->time = 0x00;
+		return;
+	}
+
+	/* adapter inserted */
+	if (info->ac_line_status == APM_AC_ONLINE) {
+		if (!(bat_status & BIT_BAT_STATUS_FULL)) {
+			/* battery is not fully charged */
+			info->battery_status = APM_BATTERY_STATUS_CHARGING;
+			info->battery_flag = APM_BATTERY_FLAG_CHARGING;
+		} else {
+			/* battery is fully charged */
+			info->battery_status = APM_BATTERY_STATUS_HIGH;
+			info->battery_flag = APM_BATTERY_FLAG_HIGH;
+			info->battery_life = 100;
+		}
+	} else {
+		/* battery is too low */
+		if (bat_status & BIT_BAT_STATUS_LOW) {
+			info->battery_status = APM_BATTERY_STATUS_LOW;
+			info->battery_flag = APM_BATTERY_FLAG_LOW;
+			if (info->battery_life <= APM_CRITICAL) {
+				/* we should power off the system now */
+				info->battery_status =
+					APM_BATTERY_STATUS_CRITICAL;
+				info->battery_flag = APM_BATTERY_FLAG_CRITICAL;
+			}
+		} else {
+			/* assume the battery is high enough. */
+			info->battery_status = APM_BATTERY_STATUS_HIGH;
+			info->battery_flag = APM_BATTERY_FLAG_HIGH;
+		}
+	}
+	info->time = ((info->battery_life - 3) * 54 + 142) / 60;
+}
+
+static int __init yeeloong_battery_init(void)
+{
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	get_fixed_battery_info();
+
+	apm_get_power_status = get_power_status;
+
+	return 0;
+}
+
+static void __exit yeeloong_battery_exit(void)
+{
+}
+
+module_init(yeeloong_battery_init);
+module_exit(yeeloong_battery_exit);
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
@ 2009-11-28 13:38   ` Wu Zhangjin
  2009-11-28 13:34 ` [PATCH v5 2/8] Loongson: YeeLoong: add platform specific option Wu Zhangjin
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:38 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors,
	Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds hwmon driver for managing the temperature of battery,
cpu and controlling the fan.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
 .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
 4 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index e284c91..56cb584 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -28,4 +28,13 @@ config YEELOONG_BATTERY
 	  This option adds APM emulated Battery Driver, which provides standard
 	  interface for user-space applications to manage the battery.
 
+config YEELOONG_HWMON
+	tristate "Hardware Monitor Driver"
+	select HWMON
+	default y
+	help
+	  This option adds hardware monitor driver, which provides standard
+	  interface for lm-sensors to monitor the temperatures of CPU and
+	  battery, the PWM of fan, the current, voltage of battery.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 20fe0c6..73277a8 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -4,3 +4,4 @@ obj-y += ec_kb3310b.o
 
 obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
 obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
+obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
index 0e3b5ad..674a543 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -22,6 +22,9 @@ extern int ec_get_event_num(void);
 typedef int (*sci_handler) (int status);
 extern sci_handler yeeloong_report_lid_status;
 
+extern void set_fan_pwm(int value);
+extern void set_fan_pwm_enable(int manual);
+
 #define SCI_IRQ_NUM 0x0A
 #define MAX_BRIGHTNESS 8
 
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
new file mode 100644
index 0000000..22c5f1d
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
@@ -0,0 +1,241 @@
+/*
+ * YeeLoong Hwmon Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop hwmon driver");
+MODULE_LICENSE("GPL");
+
+/* pwm(auto/manual) enable or not */
+static int get_fan_pwm_enable(void)
+{
+	return ec_read(REG_FAN_AUTO_MAN_SWITCH);
+}
+
+void set_fan_pwm_enable(int manual)
+{
+	ec_write(REG_FAN_AUTO_MAN_SWITCH, !!manual);
+}
+EXPORT_SYMBOL(set_fan_pwm_enable);
+
+static int get_fan_pwm(void)
+{
+	return ec_read(REG_FAN_SPEED_LEVEL);
+}
+
+void set_fan_pwm(int value)
+{
+	int status;
+
+	value = SENSORS_LIMIT(value, 0, 3);
+
+	/* If value is not ZERO, We should ensure it is on */
+	if (value != 0) {
+		status = ec_read(REG_FAN_STATUS);
+		if (status == 0)
+			ec_write(REG_FAN_CONTROL, BIT_FAN_CONTROL_ON);
+	}
+	ec_write(REG_FAN_SPEED_LEVEL, value);
+}
+EXPORT_SYMBOL(set_fan_pwm);
+
+static int get_fan_rpm(void)
+{
+	int value = 0;
+
+	value = FAN_SPEED_DIVIDER /
+	    (((ec_read(REG_FAN_SPEED_HIGH) & 0x0f) << 8) |
+	     ec_read(REG_FAN_SPEED_LOW));
+
+	return value;
+}
+
+static int get_cpu_temp(void)
+{
+	int value;
+
+	value = ec_read(REG_TEMPERATURE_VALUE);
+
+	if (value & (1 << 7))
+		value = (value & 0x7f) - 128;
+	else
+		value = value & 0xff;
+
+	return value * 1000;
+}
+
+static int get_battery_temp(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_TEMPERATURE_HIGH) << 8) |
+		(ec_read(REG_BAT_TEMPERATURE_LOW));
+
+	return value * 1000;
+}
+
+static int get_battery_temp_alarm(void)
+{
+	int status;
+
+	status = (ec_read(REG_BAT_CHARGE_STATUS) &
+			BIT_BAT_CHARGE_STATUS_OVERTEMP);
+
+	return !!status;
+}
+
+static int get_battery_current(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_CURRENT_HIGH) << 8) |
+		(ec_read(REG_BAT_CURRENT_LOW));
+
+	if (value & 0x8000)
+		value = 0xffff - value;
+
+	return value;
+}
+
+static int get_battery_voltage(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_VOLTAGE_HIGH) << 8) |
+		(ec_read(REG_BAT_VOLTAGE_LOW));
+
+	return value;
+}
+
+
+static int parse_arg(const char *buf, unsigned long count, int *val)
+{
+	if (!count)
+		return 0;
+	if (sscanf(buf, "%i", val) != 1)
+		return -EINVAL;
+	return count;
+}
+
+static ssize_t store_sys_hwmon(void (*set) (int), const char *buf, size_t count)
+{
+	int rv, value;
+
+	rv = parse_arg(buf, count, &value);
+	if (rv > 0)
+		set(value);
+	return rv;
+}
+
+static ssize_t show_sys_hwmon(int (*get) (void), char *buf)
+{
+	return sprintf(buf, "%d\n", get());
+}
+
+#define CREATE_SENSOR_ATTR(_name, _mode, _set, _get)		\
+	static ssize_t show_##_name(struct device *dev,			\
+				    struct device_attribute *attr,	\
+				    char *buf)				\
+	{								\
+		return show_sys_hwmon(_set, buf);			\
+	}								\
+	static ssize_t store_##_name(struct device *dev,		\
+				     struct device_attribute *attr,	\
+				     const char *buf, size_t count)	\
+	{								\
+		return store_sys_hwmon(_get, buf, count);		\
+	}								\
+	static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);
+
+CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, get_fan_rpm, NULL);
+CREATE_SENSOR_ATTR(pwm1, S_IRUGO | S_IWUSR, get_fan_pwm, set_fan_pwm);
+CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, get_fan_pwm_enable,
+		set_fan_pwm_enable);
+CREATE_SENSOR_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL);
+CREATE_SENSOR_ATTR(temp2_input, S_IRUGO, get_battery_temp, NULL);
+CREATE_SENSOR_ATTR(temp2_max_alarm, S_IRUGO, get_battery_temp_alarm, NULL);
+CREATE_SENSOR_ATTR(curr1_input, S_IRUGO, get_battery_current, NULL);
+CREATE_SENSOR_ATTR(in1_input, S_IRUGO, get_battery_voltage, NULL);
+
+static ssize_t
+show_name(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "yeeloong\n");
+}
+
+static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
+
+static struct attribute *hwmon_attributes[] = {
+	&sensor_dev_attr_pwm1.dev_attr.attr,
+	&sensor_dev_attr_pwm1_enable.dev_attr.attr,
+	&sensor_dev_attr_fan1_input.dev_attr.attr,
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	&sensor_dev_attr_temp2_input.dev_attr.attr,
+	&sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
+	&sensor_dev_attr_curr1_input.dev_attr.attr,
+	&sensor_dev_attr_in1_input.dev_attr.attr,
+	&sensor_dev_attr_name.dev_attr.attr,
+	NULL
+};
+
+static struct attribute_group hwmon_attribute_group = {
+	.attrs = hwmon_attributes
+};
+
+struct device *yeeloong_hwmon_dev;
+
+static int __init yeeloong_hwmon_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	yeeloong_hwmon_dev = hwmon_device_register(NULL);
+	if (IS_ERR(yeeloong_hwmon_dev)) {
+		pr_err("Fail to register yeeloong hwmon device\n");
+		yeeloong_hwmon_dev = NULL;
+		return PTR_ERR(yeeloong_hwmon_dev);
+	}
+	ret = sysfs_create_group(&yeeloong_hwmon_dev->kobj,
+				 &hwmon_attribute_group);
+	if (ret) {
+		sysfs_remove_group(&yeeloong_hwmon_dev->kobj,
+				   &hwmon_attribute_group);
+		hwmon_device_unregister(yeeloong_hwmon_dev);
+		yeeloong_hwmon_dev = NULL;
+	}
+	/* ensure fan is set to auto mode */
+	set_fan_pwm_enable(BIT_FAN_AUTO);
+
+	return 0;
+}
+
+static void __exit yeeloong_hwmon_exit(void)
+{
+	if (yeeloong_hwmon_dev) {
+		sysfs_remove_group(&yeeloong_hwmon_dev->kobj,
+				   &hwmon_attribute_group);
+		hwmon_device_unregister(yeeloong_hwmon_dev);
+		yeeloong_hwmon_dev = NULL;
+	}
+}
+
+module_init(yeeloong_hwmon_init);
+module_exit(yeeloong_hwmon_exit);
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [lm-sensors] [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
@ 2009-11-28 13:38   ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:38 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors,
	Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds hwmon driver for managing the temperature of battery,
cpu and controlling the fan.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
 .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
 4 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index e284c91..56cb584 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -28,4 +28,13 @@ config YEELOONG_BATTERY
 	  This option adds APM emulated Battery Driver, which provides standard
 	  interface for user-space applications to manage the battery.
 
+config YEELOONG_HWMON
+	tristate "Hardware Monitor Driver"
+	select HWMON
+	default y
+	help
+	  This option adds hardware monitor driver, which provides standard
+	  interface for lm-sensors to monitor the temperatures of CPU and
+	  battery, the PWM of fan, the current, voltage of battery.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 20fe0c6..73277a8 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -4,3 +4,4 @@ obj-y += ec_kb3310b.o
 
 obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
 obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
+obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
index 0e3b5ad..674a543 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -22,6 +22,9 @@ extern int ec_get_event_num(void);
 typedef int (*sci_handler) (int status);
 extern sci_handler yeeloong_report_lid_status;
 
+extern void set_fan_pwm(int value);
+extern void set_fan_pwm_enable(int manual);
+
 #define SCI_IRQ_NUM 0x0A
 #define MAX_BRIGHTNESS 8
 
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
new file mode 100644
index 0000000..22c5f1d
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
@@ -0,0 +1,241 @@
+/*
+ * YeeLoong Hwmon Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop hwmon driver");
+MODULE_LICENSE("GPL");
+
+/* pwm(auto/manual) enable or not */
+static int get_fan_pwm_enable(void)
+{
+	return ec_read(REG_FAN_AUTO_MAN_SWITCH);
+}
+
+void set_fan_pwm_enable(int manual)
+{
+	ec_write(REG_FAN_AUTO_MAN_SWITCH, !!manual);
+}
+EXPORT_SYMBOL(set_fan_pwm_enable);
+
+static int get_fan_pwm(void)
+{
+	return ec_read(REG_FAN_SPEED_LEVEL);
+}
+
+void set_fan_pwm(int value)
+{
+	int status;
+
+	value = SENSORS_LIMIT(value, 0, 3);
+
+	/* If value is not ZERO, We should ensure it is on */
+	if (value != 0) {
+		status = ec_read(REG_FAN_STATUS);
+		if (status = 0)
+			ec_write(REG_FAN_CONTROL, BIT_FAN_CONTROL_ON);
+	}
+	ec_write(REG_FAN_SPEED_LEVEL, value);
+}
+EXPORT_SYMBOL(set_fan_pwm);
+
+static int get_fan_rpm(void)
+{
+	int value = 0;
+
+	value = FAN_SPEED_DIVIDER /
+	    (((ec_read(REG_FAN_SPEED_HIGH) & 0x0f) << 8) |
+	     ec_read(REG_FAN_SPEED_LOW));
+
+	return value;
+}
+
+static int get_cpu_temp(void)
+{
+	int value;
+
+	value = ec_read(REG_TEMPERATURE_VALUE);
+
+	if (value & (1 << 7))
+		value = (value & 0x7f) - 128;
+	else
+		value = value & 0xff;
+
+	return value * 1000;
+}
+
+static int get_battery_temp(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_TEMPERATURE_HIGH) << 8) |
+		(ec_read(REG_BAT_TEMPERATURE_LOW));
+
+	return value * 1000;
+}
+
+static int get_battery_temp_alarm(void)
+{
+	int status;
+
+	status = (ec_read(REG_BAT_CHARGE_STATUS) &
+			BIT_BAT_CHARGE_STATUS_OVERTEMP);
+
+	return !!status;
+}
+
+static int get_battery_current(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_CURRENT_HIGH) << 8) |
+		(ec_read(REG_BAT_CURRENT_LOW));
+
+	if (value & 0x8000)
+		value = 0xffff - value;
+
+	return value;
+}
+
+static int get_battery_voltage(void)
+{
+	int value;
+
+	value = (ec_read(REG_BAT_VOLTAGE_HIGH) << 8) |
+		(ec_read(REG_BAT_VOLTAGE_LOW));
+
+	return value;
+}
+
+
+static int parse_arg(const char *buf, unsigned long count, int *val)
+{
+	if (!count)
+		return 0;
+	if (sscanf(buf, "%i", val) != 1)
+		return -EINVAL;
+	return count;
+}
+
+static ssize_t store_sys_hwmon(void (*set) (int), const char *buf, size_t count)
+{
+	int rv, value;
+
+	rv = parse_arg(buf, count, &value);
+	if (rv > 0)
+		set(value);
+	return rv;
+}
+
+static ssize_t show_sys_hwmon(int (*get) (void), char *buf)
+{
+	return sprintf(buf, "%d\n", get());
+}
+
+#define CREATE_SENSOR_ATTR(_name, _mode, _set, _get)		\
+	static ssize_t show_##_name(struct device *dev,			\
+				    struct device_attribute *attr,	\
+				    char *buf)				\
+	{								\
+		return show_sys_hwmon(_set, buf);			\
+	}								\
+	static ssize_t store_##_name(struct device *dev,		\
+				     struct device_attribute *attr,	\
+				     const char *buf, size_t count)	\
+	{								\
+		return store_sys_hwmon(_get, buf, count);		\
+	}								\
+	static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);
+
+CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, get_fan_rpm, NULL);
+CREATE_SENSOR_ATTR(pwm1, S_IRUGO | S_IWUSR, get_fan_pwm, set_fan_pwm);
+CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, get_fan_pwm_enable,
+		set_fan_pwm_enable);
+CREATE_SENSOR_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL);
+CREATE_SENSOR_ATTR(temp2_input, S_IRUGO, get_battery_temp, NULL);
+CREATE_SENSOR_ATTR(temp2_max_alarm, S_IRUGO, get_battery_temp_alarm, NULL);
+CREATE_SENSOR_ATTR(curr1_input, S_IRUGO, get_battery_current, NULL);
+CREATE_SENSOR_ATTR(in1_input, S_IRUGO, get_battery_voltage, NULL);
+
+static ssize_t
+show_name(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "yeeloong\n");
+}
+
+static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
+
+static struct attribute *hwmon_attributes[] = {
+	&sensor_dev_attr_pwm1.dev_attr.attr,
+	&sensor_dev_attr_pwm1_enable.dev_attr.attr,
+	&sensor_dev_attr_fan1_input.dev_attr.attr,
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	&sensor_dev_attr_temp2_input.dev_attr.attr,
+	&sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
+	&sensor_dev_attr_curr1_input.dev_attr.attr,
+	&sensor_dev_attr_in1_input.dev_attr.attr,
+	&sensor_dev_attr_name.dev_attr.attr,
+	NULL
+};
+
+static struct attribute_group hwmon_attribute_group = {
+	.attrs = hwmon_attributes
+};
+
+struct device *yeeloong_hwmon_dev;
+
+static int __init yeeloong_hwmon_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	yeeloong_hwmon_dev = hwmon_device_register(NULL);
+	if (IS_ERR(yeeloong_hwmon_dev)) {
+		pr_err("Fail to register yeeloong hwmon device\n");
+		yeeloong_hwmon_dev = NULL;
+		return PTR_ERR(yeeloong_hwmon_dev);
+	}
+	ret = sysfs_create_group(&yeeloong_hwmon_dev->kobj,
+				 &hwmon_attribute_group);
+	if (ret) {
+		sysfs_remove_group(&yeeloong_hwmon_dev->kobj,
+				   &hwmon_attribute_group);
+		hwmon_device_unregister(yeeloong_hwmon_dev);
+		yeeloong_hwmon_dev = NULL;
+	}
+	/* ensure fan is set to auto mode */
+	set_fan_pwm_enable(BIT_FAN_AUTO);
+
+	return 0;
+}
+
+static void __exit yeeloong_hwmon_exit(void)
+{
+	if (yeeloong_hwmon_dev) {
+		sysfs_remove_group(&yeeloong_hwmon_dev->kobj,
+				   &hwmon_attribute_group);
+		hwmon_device_unregister(yeeloong_hwmon_dev);
+		yeeloong_hwmon_dev = NULL;
+	}
+}
+
+module_init(yeeloong_hwmon_init);
+module_exit(yeeloong_hwmon_exit);
-- 
1.6.2.1


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 6/8] Loongson: YeeLoong: add video output driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
                   ` (4 preceding siblings ...)
  2009-11-28 13:38   ` [lm-sensors] " Wu Zhangjin
@ 2009-11-28 13:41 ` Wu Zhangjin
  2009-11-30  5:19   ` Wu Zhangjin
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:41 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, luming.yu, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds Video Output Driver, which provides standard interface
to turn on/off the video output of LCD, CRT.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    8 +
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
 .../lemote-2f/yeeloong_laptop/video_output.c       |  164 ++++++++++++++++++++
 4 files changed, 176 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index 56cb584..c4398ff 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -37,4 +37,12 @@ config YEELOONG_HWMON
 	  interface for lm-sensors to monitor the temperatures of CPU and
 	  battery, the PWM of fan, the current, voltage of battery.
 
+config YEELOONG_VO
+	tristate "Video Output Driver"
+	select VIDEO_OUTPUT_CONTROL
+	default y
+	help
+	  This option adds Video Output Driver, which provides standard
+	  interface to turn on/off the video output of LCD, CRT.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 73277a8..104670f 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -5,3 +5,4 @@ obj-y += ec_kb3310b.o
 obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
 obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
 obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
+obj-$(CONFIG_YEELOONG_VO) += video_output.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
index 674a543..3d08792 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -25,6 +25,9 @@ extern sci_handler yeeloong_report_lid_status;
 extern void set_fan_pwm(int value);
 extern void set_fan_pwm_enable(int manual);
 
+extern void lcd_vo_set(int status);
+extern void crt_vo_set(int status);
+
 #define SCI_IRQ_NUM 0x0A
 #define MAX_BRIGHTNESS 8
 
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c
new file mode 100644
index 0000000..e8b2f9a
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c
@@ -0,0 +1,164 @@
+/*
+ * YeeLoong Video Output Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/video_output.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop video output driver");
+MODULE_LICENSE("GPL");
+
+static int lcd_video_output_get(struct output_device *od)
+{
+	return ec_read(REG_DISPLAY_LCD);
+}
+
+static int lcd_video_output_set(struct output_device *od)
+{
+	unsigned long status = od->request_state;
+	int value;
+
+	if (status == BIT_DISPLAY_LCD_ON) {
+		/* Turn on LCD */
+		outb(0x31, 0x3c4);
+		value = inb(0x3c5);
+		value = (value & 0xf8) | 0x03;
+		outb(0x31, 0x3c4);
+		outb(value, 0x3c5);
+		/* Turn on backlight */
+		ec_write(REG_BACKLIGHT_CTRL, BIT_BACKLIGHT_ON);
+	} else {
+		/* Turn off backlight */
+		ec_write(REG_BACKLIGHT_CTRL, BIT_BACKLIGHT_OFF);
+		/* Turn off LCD */
+		outb(0x31, 0x3c4);
+		value = inb(0x3c5);
+		value = (value & 0xf8) | 0x02;
+		outb(0x31, 0x3c4);
+		outb(value, 0x3c5);
+	}
+
+	return 0;
+}
+
+static struct output_properties lcd_output_properties = {
+	.set_state = lcd_video_output_set,
+	.get_status = lcd_video_output_get,
+};
+
+static int crt_video_output_get(struct output_device *od)
+{
+	return ec_read(REG_CRT_DETECT);
+}
+
+static int crt_video_output_set(struct output_device *od)
+{
+	unsigned long status = od->request_state;
+	int value;
+
+	if (status == BIT_CRT_DETECT_PLUG) {
+		if (ec_read(REG_CRT_DETECT) == BIT_CRT_DETECT_PLUG) {
+			/* Turn on CRT */
+			outb(0x21, 0x3c4);
+			value = inb(0x3c5);
+			value &= ~(1 << 7);
+			outb(0x21, 0x3c4);
+			outb(value, 0x3c5);
+		}
+	} else {
+		/* Turn off CRT */
+		outb(0x21, 0x3c4);
+		value = inb(0x3c5);
+		value |= (1 << 7);
+		outb(0x21, 0x3c4);
+		outb(value, 0x3c5);
+	}
+
+	return 0;
+}
+
+static struct output_properties crt_output_properties = {
+	.set_state = crt_video_output_set,
+	.get_status = crt_video_output_get,
+};
+
+struct output_device *lcd_output_dev, *crt_output_dev;
+
+void lcd_vo_set(int status)
+{
+	lcd_output_dev->request_state = status;
+	lcd_video_output_set(lcd_output_dev);
+}
+EXPORT_SYMBOL(lcd_vo_set);
+
+void crt_vo_set(int status)
+{
+	crt_output_dev->request_state = status;
+	crt_video_output_set(crt_output_dev);
+}
+EXPORT_SYMBOL(crt_vo_set);
+
+static int __init yeeloong_vo_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+
+	/* Register video output device: lcd, crt */
+	lcd_output_dev = video_output_register("LCD", NULL, NULL,
+			&lcd_output_properties);
+
+	if (IS_ERR(lcd_output_dev)) {
+		ret = PTR_ERR(lcd_output_dev);
+		lcd_output_dev = NULL;
+		return ret;
+	}
+	/* Ensure LCD is on by default */
+	lcd_vo_set(BIT_DISPLAY_LCD_ON);
+
+	crt_output_dev = video_output_register("CRT", NULL, NULL,
+			&crt_output_properties);
+
+	if (IS_ERR(crt_output_dev)) {
+		ret = PTR_ERR(crt_output_dev);
+		crt_output_dev = NULL;
+		return ret;
+	}
+
+	/* Turn off CRT by default, and will be enabled when the CRT
+	 * connectting event reported by SCI */
+	crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+
+	return 0;
+}
+
+static void __exit yeeloong_vo_exit(void)
+{
+	if (lcd_output_dev) {
+		video_output_unregister(lcd_output_dev);
+		lcd_output_dev = NULL;
+	}
+	if (crt_output_dev) {
+		video_output_unregister(crt_output_dev);
+		crt_output_dev = NULL;
+	}
+}
+
+module_init(yeeloong_vo_init);
+module_exit(yeeloong_vo_exit);
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
                   ` (6 preceding siblings ...)
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
@ 2009-11-28 13:42 ` Wu Zhangjin
  2009-11-28 13:44 ` [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangjin
  8 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:42 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, yanh, Dmitry Torokhov, zhangfx, linux-pm

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds Suspend Driver, which will suspend the YeeLoong Platform
specific devices.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index c4398ff..49d63c5 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -45,4 +45,13 @@ config YEELOONG_VO
 	  This option adds Video Output Driver, which provides standard
 	  interface to turn on/off the video output of LCD, CRT.
 
+config YEELOONG_SUSPEND
+	tristate "Suspend Driver"
+	depends on YEELOONG_HWMON && YEELOONG_VO
+	select SUSPEND
+	default y
+	help
+	  This option adds Suspend Driver, which will suspend the YeeLoong
+	  Platform specific devices.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 104670f..cfe736f 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
 obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
 obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
 obj-$(CONFIG_YEELOONG_VO) += video_output.o
+obj-$(CONFIG_YEELOONG_SUSPEND) += suspend.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
new file mode 100644
index 0000000..8202971
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
@@ -0,0 +1,141 @@
+/*
+ * YeeLoong Platform Specific Suspend Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/platform_device.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop suspend driver");
+MODULE_LICENSE("GPL");
+
+static struct platform_device *yeeloong_pdev;
+
+static void usb_ports_set(int status)
+{
+	status = !!status;
+
+	ec_write(REG_USB0_FLAG, status);
+	ec_write(REG_USB1_FLAG, status);
+	ec_write(REG_USB2_FLAG, status);
+}
+
+static int yeeloong_suspend(struct platform_device *pdev,
+		pm_message_t state)
+{
+	pr_info("yeeloong specific suspend\n");
+
+	/* Turn off LCD */
+	lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+	/* Turn off CRT */
+	crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+	/* Poweroff three usb ports */
+	usb_ports_set(BIT_USB_FLAG_OFF);
+	/* Minimize the speed of FAN */
+	set_fan_pwm_enable(BIT_FAN_MANUAL);
+	set_fan_pwm(1);
+
+	return 0;
+}
+
+static int yeeloong_resume(struct platform_device *pdev)
+{
+	pr_info("yeeloong specific resume\n");
+
+	/* Resume the status of lcd & crt */
+	lcd_vo_set(BIT_DISPLAY_LCD_ON);
+	crt_vo_set(BIT_CRT_DETECT_PLUG);
+
+	/* Poweron three usb ports */
+	usb_ports_set(BIT_USB_FLAG_ON);
+
+	/* Resume fan to auto mode */
+	set_fan_pwm_enable(BIT_FAN_AUTO);
+
+	return 0;
+}
+
+static struct platform_driver platform_driver = {
+	.driver = {
+		   .name = "yeeloong-laptop",
+		   .owner = THIS_MODULE,
+		   },
+	.suspend = yeeloong_suspend,
+	.resume = yeeloong_resume,
+};
+
+static ssize_t yeeloong_pdev_name_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "yeeloong laptop\n");
+}
+
+static struct device_attribute dev_attr_yeeloong_pdev_name =
+__ATTR(name, S_IRUGO, yeeloong_pdev_name_show, NULL);
+
+static int __init yeeloong_suspend_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	/* Register platform stuff */
+	ret = platform_driver_register(&platform_driver);
+	if (ret)
+		return ret;
+
+	yeeloong_pdev = platform_device_alloc("yeeloong-laptop", -1);
+	if (!yeeloong_pdev) {
+		ret = -ENOMEM;
+		platform_driver_unregister(&platform_driver);
+		return ret;
+	}
+
+	ret = platform_device_add(yeeloong_pdev);
+	if (ret) {
+		platform_device_put(yeeloong_pdev);
+		return ret;
+	}
+
+	if (IS_ERR(yeeloong_pdev)) {
+		ret = PTR_ERR(yeeloong_pdev);
+		yeeloong_pdev = NULL;
+		pr_err("Fail to register platform device\n");
+		return ret;
+	}
+
+	ret = device_create_file(&yeeloong_pdev->dev,
+				 &dev_attr_yeeloong_pdev_name);
+	if (ret) {
+		pr_err("Fail to create sysfs device attributes\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static void __exit yeeloong_suspend_exit(void)
+{
+	if (yeeloong_pdev) {
+		platform_device_unregister(yeeloong_pdev);
+		yeeloong_pdev = NULL;
+		platform_driver_unregister(&platform_driver);
+	}
+}
+
+module_init(yeeloong_suspend_init);
+module_exit(yeeloong_suspend_exit);
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
                   ` (5 preceding siblings ...)
  2009-11-28 13:41 ` [PATCH v5 6/8] Loongson: YeeLoong: add video output driver Wu Zhangjin
@ 2009-11-28 13:42 ` Wu Zhangjin
  2009-11-29  9:19   ` Pavel Machek
                     ` (3 more replies)
  2009-11-28 13:42 ` Wu Zhangjin
  2009-11-28 13:44 ` [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangjin
  8 siblings, 4 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:42 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Pavel Machek,
	linux-pm, Rafael J. Wysocki, Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds Suspend Driver, which will suspend the YeeLoong Platform
specific devices.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c

diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index c4398ff..49d63c5 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -45,4 +45,13 @@ config YEELOONG_VO
 	  This option adds Video Output Driver, which provides standard
 	  interface to turn on/off the video output of LCD, CRT.
 
+config YEELOONG_SUSPEND
+	tristate "Suspend Driver"
+	depends on YEELOONG_HWMON && YEELOONG_VO
+	select SUSPEND
+	default y
+	help
+	  This option adds Suspend Driver, which will suspend the YeeLoong
+	  Platform specific devices.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index 104670f..cfe736f 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += backlight.o
 obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
 obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
 obj-$(CONFIG_YEELOONG_VO) += video_output.o
+obj-$(CONFIG_YEELOONG_SUSPEND) += suspend.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
new file mode 100644
index 0000000..8202971
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
@@ -0,0 +1,141 @@
+/*
+ * YeeLoong Platform Specific Suspend Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/platform_device.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop suspend driver");
+MODULE_LICENSE("GPL");
+
+static struct platform_device *yeeloong_pdev;
+
+static void usb_ports_set(int status)
+{
+	status = !!status;
+
+	ec_write(REG_USB0_FLAG, status);
+	ec_write(REG_USB1_FLAG, status);
+	ec_write(REG_USB2_FLAG, status);
+}
+
+static int yeeloong_suspend(struct platform_device *pdev,
+		pm_message_t state)
+{
+	pr_info("yeeloong specific suspend\n");
+
+	/* Turn off LCD */
+	lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+	/* Turn off CRT */
+	crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+	/* Poweroff three usb ports */
+	usb_ports_set(BIT_USB_FLAG_OFF);
+	/* Minimize the speed of FAN */
+	set_fan_pwm_enable(BIT_FAN_MANUAL);
+	set_fan_pwm(1);
+
+	return 0;
+}
+
+static int yeeloong_resume(struct platform_device *pdev)
+{
+	pr_info("yeeloong specific resume\n");
+
+	/* Resume the status of lcd & crt */
+	lcd_vo_set(BIT_DISPLAY_LCD_ON);
+	crt_vo_set(BIT_CRT_DETECT_PLUG);
+
+	/* Poweron three usb ports */
+	usb_ports_set(BIT_USB_FLAG_ON);
+
+	/* Resume fan to auto mode */
+	set_fan_pwm_enable(BIT_FAN_AUTO);
+
+	return 0;
+}
+
+static struct platform_driver platform_driver = {
+	.driver = {
+		   .name = "yeeloong-laptop",
+		   .owner = THIS_MODULE,
+		   },
+	.suspend = yeeloong_suspend,
+	.resume = yeeloong_resume,
+};
+
+static ssize_t yeeloong_pdev_name_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "yeeloong laptop\n");
+}
+
+static struct device_attribute dev_attr_yeeloong_pdev_name =
+__ATTR(name, S_IRUGO, yeeloong_pdev_name_show, NULL);
+
+static int __init yeeloong_suspend_init(void)
+{
+	int ret;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	/* Register platform stuff */
+	ret = platform_driver_register(&platform_driver);
+	if (ret)
+		return ret;
+
+	yeeloong_pdev = platform_device_alloc("yeeloong-laptop", -1);
+	if (!yeeloong_pdev) {
+		ret = -ENOMEM;
+		platform_driver_unregister(&platform_driver);
+		return ret;
+	}
+
+	ret = platform_device_add(yeeloong_pdev);
+	if (ret) {
+		platform_device_put(yeeloong_pdev);
+		return ret;
+	}
+
+	if (IS_ERR(yeeloong_pdev)) {
+		ret = PTR_ERR(yeeloong_pdev);
+		yeeloong_pdev = NULL;
+		pr_err("Fail to register platform device\n");
+		return ret;
+	}
+
+	ret = device_create_file(&yeeloong_pdev->dev,
+				 &dev_attr_yeeloong_pdev_name);
+	if (ret) {
+		pr_err("Fail to create sysfs device attributes\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static void __exit yeeloong_suspend_exit(void)
+{
+	if (yeeloong_pdev) {
+		platform_device_unregister(yeeloong_pdev);
+		yeeloong_pdev = NULL;
+		platform_driver_unregister(&platform_driver);
+	}
+}
+
+module_init(yeeloong_suspend_init);
+module_exit(yeeloong_suspend_exit);
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
                   ` (7 preceding siblings ...)
  2009-11-28 13:42 ` Wu Zhangjin
@ 2009-11-28 13:44 ` Wu Zhangjin
  2009-11-29  5:35   ` Dmitry Torokhov
  2009-11-30  5:18   ` Wu Zhangjin
  8 siblings, 2 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-28 13:44 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, linux-input,
	Wu Zhangjin

From: Wu Zhangjin <wuzhangjin@gmail.com>

This patch adds Hotkey Driver, which will do relative actions for The
hotkey event and report the corresponding input keys to the user-space
applications.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/kernel/setup.c                           |    1 +
 .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |   12 +
 .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
 .../loongson/lemote-2f/yeeloong_laptop/hotkey.c    |  468 ++++++++++++++++++++
 4 files changed, 482 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hotkey.c

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index bd55f71..b1e1272 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -60,6 +60,7 @@ struct boot_mem_map boot_mem_map;
 
 static char command_line[COMMAND_LINE_SIZE];
        char arcs_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
+EXPORT_SYMBOL(arcs_cmdline);
 
 /*
  * mips_io_port_base is the begin of the address space to which x86 style
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index 49d63c5..ec3b28b 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -54,4 +54,16 @@ config YEELOONG_SUSPEND
 	  This option adds Suspend Driver, which will suspend the YeeLoong
 	  Platform specific devices.
 
+config YEELOONG_HOTKEY
+	tristate "Hotkey Driver"
+	depends on YEELOONG_VO
+	select INPUT
+	select INPUT_EVDEV
+	select SUSPEND
+	default y
+	help
+	  This option adds Hotkey Driver, which will do relative actions for
+	  The hotkey event and report the corresponding input keys to the
+	  user-space applications.
+
 endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index cfe736f..6aad103 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_YEELOONG_BATTERY) += battery.o
 obj-$(CONFIG_YEELOONG_HWMON) += hwmon.o
 obj-$(CONFIG_YEELOONG_VO) += video_output.o
 obj-$(CONFIG_YEELOONG_SUSPEND) += suspend.o
+obj-$(CONFIG_YEELOONG_HOTKEY) += hotkey.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/hotkey.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hotkey.c
new file mode 100644
index 0000000..8e30e58
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/hotkey.c
@@ -0,0 +1,468 @@
+/*
+ * YeeLoong Hotkey Driver
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *          Liu Junliang <liujl@lemote.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+
+#include <asm/bootinfo.h>	/* for arcs_cmdline */
+
+#include <cs5536/cs5536.h>
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>; Liu Junliang <liujl@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop hotkey driver");
+MODULE_LICENSE("GPL");
+
+static struct input_dev *yeeloong_hotkey_dev;
+static int event, status;
+
+struct key_entry {
+	char type;		/* See KE_* below */
+	int event;		/* event from SCI */
+	u16 keycode;		/* KEY_* or SW_* */
+};
+
+enum { KE_KEY, KE_SW, KE_END };
+
+static struct key_entry yeeloong_keymap[] = {
+	{KE_SW, EVENT_LID, SW_LID},
+	{KE_KEY, EVENT_CAMERA, KEY_CAMERA},	/* Fn + ESC */
+	{KE_KEY, EVENT_SLEEP, KEY_SLEEP},	/* Fn + F1 */
+	{KE_KEY, EVENT_DISPLAY_TOGGLE, KEY_SWITCHVIDEOMODE},	/* Fn + F3 */
+	{KE_KEY, EVENT_AUDIO_MUTE, KEY_MUTE},	/* Fn + F4 */
+	{KE_KEY, EVENT_WLAN, KEY_WLAN},	/* Fn + F5 */
+	{KE_KEY, EVENT_DISPLAY_BRIGHTNESS, KEY_BRIGHTNESSUP},	/* Fn + up */
+	{KE_KEY, EVENT_DISPLAY_BRIGHTNESS, KEY_BRIGHTNESSDOWN},	/* Fn + down */
+	{KE_KEY, EVENT_AUDIO_VOLUME, KEY_VOLUMEUP},	/* Fn + right */
+	{KE_KEY, EVENT_AUDIO_VOLUME, KEY_VOLUMEDOWN},	/* Fn + left */
+	{KE_END, 0}
+};
+
+static int get_event_keycode(void)
+{
+	struct key_entry *key;
+
+	for (key = yeeloong_keymap; key->type != KE_END; key++) {
+		if (key->event != event)
+			continue;
+		else {
+			if (EVENT_DISPLAY_BRIGHTNESS == event) {
+				static int old_brightness_status = -1;
+				/* current status > old one, means up */
+				if ((status < old_brightness_status)
+				    || (0 == status))
+					key++;
+				old_brightness_status = status;
+			} else if (EVENT_AUDIO_VOLUME == event) {
+				static int old_volume_status = -1;
+				if ((status < old_volume_status)
+				    || (0 == status))
+					key++;
+				old_volume_status = status;
+			}
+			break;
+		}
+	}
+	return key->keycode;
+}
+
+static int report_lid_switch(int status)
+{
+	input_report_switch(yeeloong_hotkey_dev, SW_LID, !status);
+	input_sync(yeeloong_hotkey_dev);
+
+	return status;
+}
+
+void report_key(void)
+{
+	int keycode;
+
+	keycode = get_event_keycode();
+
+	if (keycode == SW_LID)
+		report_lid_switch(status);
+	else {
+		input_report_key(yeeloong_hotkey_dev, keycode, 1);
+		input_sync(yeeloong_hotkey_dev);
+		input_report_key(yeeloong_hotkey_dev, keycode, 0);
+		input_sync(yeeloong_hotkey_dev);
+	}
+}
+
+enum { NO_REG, MUL_REG, REG_END };
+
+static int event_reg[15] = {
+	REG_LID_DETECT,		/*  LID open/close */
+	NO_REG,			/*  Fn+F3 for display switch */
+	NO_REG,			/*  Fn+F1 for entering sleep mode */
+	MUL_REG,		/*  Over-temperature happened */
+	REG_CRT_DETECT,		/*  CRT is connected */
+	REG_CAMERA_STATUS,	/*  Camera on/off */
+	REG_USB2_FLAG,		/*  USB2 Over Current occurred */
+	REG_USB0_FLAG,		/*  USB0 Over Current occurred */
+	REG_DISPLAY_LCD,	/*  Black screen on/off */
+	REG_AUDIO_MUTE,		/*  Mute on/off */
+	REG_DISPLAY_BRIGHTNESS,	/*  LCD backlight brightness adjust */
+	NO_REG,			/*  AC & Battery relative issue */
+	REG_AUDIO_VOLUME,	/*  Volume adjust */
+	REG_WLAN,		/*  Wlan on/off */
+	REG_END
+};
+
+static int ec_get_event_status(void)
+{
+	int reg;
+
+	reg = event_reg[event - EVENT_LID];
+
+	if (reg == NO_REG || reg == MUL_REG)
+		return 1;
+	else if (reg != REG_END)
+		return ec_read(reg);
+
+	return -1;
+}
+
+static int crt_detect_handler(int status)
+{
+	if (status == BIT_CRT_DETECT_PLUG) {
+		crt_vo_set(BIT_CRT_DETECT_PLUG);
+		lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+	} else {
+		lcd_vo_set(BIT_DISPLAY_LCD_ON);
+		crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+	}
+	return status;
+}
+
+#define EC_VER_LEN 64
+
+static int black_screen_handler(int status)
+{
+	char *p, ec_ver[EC_VER_LEN];
+
+	p = strstr(arcs_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';
+	}
+
+	/* Seems EC(>=PQ1D26) does this job for us, we can not do it again,
+	 * otherwise, the brightness will not resume to the normal level! */
+	if (strncasecmp(ec_ver, "EC_VER=PQ1D26", 64) < 0)
+		lcd_vo_set(status);
+
+	return status;
+}
+
+static int display_toggle_handler(int status)
+{
+	static int video_output_status;
+
+	/* Only enable switch video output button
+	 * when CRT is connected */
+	if (ec_read(REG_CRT_DETECT) == BIT_CRT_DETECT_UNPLUG)
+		return 0;
+	/* 0. no CRT connected: LCD on, CRT off
+	 * 1. BOTH on
+	 * 2. LCD off, CRT on
+	 * 3. BOTH off
+	 * 4. LCD on, CRT off
+	 */
+	video_output_status++;
+	if (video_output_status > 4)
+		video_output_status = 1;
+
+	switch (video_output_status) {
+	case 1:
+		lcd_vo_set(BIT_DISPLAY_LCD_ON);
+		crt_vo_set(BIT_CRT_DETECT_PLUG);
+		break;
+	case 2:
+		lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+		crt_vo_set(BIT_CRT_DETECT_PLUG);
+		break;
+	case 3:
+		lcd_vo_set(BIT_DISPLAY_LCD_OFF);
+		crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+		break;
+	case 4:
+		lcd_vo_set(BIT_DISPLAY_LCD_ON);
+		crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+		break;
+	default:
+		/* Ensure LCD is on */
+		lcd_vo_set(BIT_DISPLAY_LCD_ON);
+		break;
+	}
+	return video_output_status;
+}
+
+static int camera_handler(int status)
+{
+	int value;
+	static int camera_status;
+
+	status = !!status;
+	camera_status = ec_read(REG_CAMERA_STATUS);
+	if (status != camera_status) {
+		value = ec_read(REG_CAMERA_CONTROL);
+		ec_write(REG_CAMERA_CONTROL, value | (1 << 1));
+	}
+	return ec_read(REG_CAMERA_STATUS);
+}
+
+static int usb2_handler(int status)
+{
+	pr_emerg("USB2 Over Current occurred\n");
+
+	return status;
+}
+
+static int usb0_handler(int status)
+{
+	pr_emerg("USB0 Over Current occurred\n");
+
+	return status;
+}
+
+/* yeeloong_wifi_handler may be implemented in the wifi driver */
+sci_handler yeeloong_wifi_handler;
+EXPORT_SYMBOL(yeeloong_wifi_handler);
+
+static void do_event_action(void)
+{
+	sci_handler handler;
+
+	handler = NULL;
+
+	switch (event) {
+	case EVENT_DISPLAY_TOGGLE:
+		handler = display_toggle_handler;
+		break;
+	case EVENT_CRT_DETECT:
+		handler = crt_detect_handler;
+		break;
+	case EVENT_CAMERA:
+		handler = camera_handler;
+		break;
+	case EVENT_USB_OC2:
+		handler = usb2_handler;
+		break;
+	case EVENT_USB_OC0:
+		handler = usb0_handler;
+		break;
+	case EVENT_BLACK_SCREEN:
+		handler = black_screen_handler;
+		break;
+	case EVENT_WLAN:
+		/*
+		 * Use the key as a switch button, not care about the real
+		 * status
+		 */
+		status = 2;
+		handler = yeeloong_wifi_handler;
+		break;
+	default:
+		break;
+	}
+
+	if (handler)
+		status = handler(status);
+}
+
+/*
+ * SCI(system control interrupt) main interrupt routine
+ *
+ * We will do the query and get event number together so the interrupt routine
+ * should be longer than 120us now at least 3ms elpase for it.
+ */
+static irqreturn_t sci_irq_handler(int irq, void *dev_id)
+{
+	int ret;
+
+	if (SCI_IRQ_NUM != irq)
+		return IRQ_NONE;
+
+	/* Query the event number */
+	ret = ec_query_event_num();
+	if (ret < 0)
+		return IRQ_NONE;
+
+	event = ec_get_event_num();
+	if (event < 0)
+		return IRQ_NONE;
+
+	if ((event != 0x00) && (event != 0xff)) {
+		/* Get status of current event */
+		status = ec_get_event_status();
+		pr_info("%s: event: %d, status: %d\n", __func__, event, status);
+		if (status == -1)
+			return IRQ_NONE;
+		/* Execute corresponding actions */
+		do_event_action();
+		/* Report current key */
+		report_key();
+	}
+	return IRQ_HANDLED;
+}
+
+/*
+ * Config and init some msr and gpio register properly.
+ */
+static int sci_irq_init(void)
+{
+	u32 hi, lo;
+	u32 gpio_base;
+	unsigned long flags;
+	int ret;
+
+	/* Get gpio base */
+	_rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO), &hi, &lo);
+	gpio_base = lo & 0xff00;
+
+	/* Filter the former kb3310 interrupt for security */
+	ret = ec_query_event_num();
+	if (ret)
+		return ret;
+
+	/* For filtering next number interrupt */
+	udelay(10000);
+
+	/* Set gpio native registers and msrs for GPIO27 SCI EVENT PIN
+	 * gpio :
+	 *      input, pull-up, no-invert, event-count and value 0,
+	 *      no-filter, no edge mode
+	 *      gpio27 map to Virtual gpio0
+	 * msr :
+	 *      no primary and lpc
+	 *      Unrestricted Z input to IG10 from Virtual gpio 0.
+	 */
+	local_irq_save(flags);
+	_rdmsr(0x80000024, &hi, &lo);
+	lo &= ~(1 << 10);
+	_wrmsr(0x80000024, hi, lo);
+	_rdmsr(0x80000025, &hi, &lo);
+	lo &= ~(1 << 10);
+	_wrmsr(0x80000025, hi, lo);
+	_rdmsr(0x80000023, &hi, &lo);
+	lo |= (0x0a << 0);
+	_wrmsr(0x80000023, hi, lo);
+	local_irq_restore(flags);
+
+	/* Set gpio27 as sci interrupt
+	 *
+	 * input, pull-up, no-fliter, no-negedge, invert
+	 * the sci event is just about 120us
+	 */
+	asm(".set noreorder\n");
+	/*  input enable */
+	outl(0x00000800, (gpio_base | 0xA0));
+	/*  revert the input */
+	outl(0x00000800, (gpio_base | 0xA4));
+	/*  event-int enable */
+	outl(0x00000800, (gpio_base | 0xB8));
+	asm(".set reorder\n");
+
+	return 0;
+}
+
+static struct irqaction sci_irqaction = {
+	.handler = sci_irq_handler,
+	.name = "sci",
+	.flags = IRQF_SHARED,
+};
+
+static int __init yeeloong_hotkey_init(void)
+{
+	int ret;
+	struct key_entry *key;
+
+	if (mips_machtype != MACH_LEMOTE_YL2F89) {
+		pr_err("This Driver is only for YeeLoong laptop\n");
+		return -EFAULT;
+	}
+
+	ret = sci_irq_init();
+	if (ret)
+		return -EFAULT;
+
+	ret = setup_irq(SCI_IRQ_NUM, &sci_irqaction);
+	if (ret)
+		return -EFAULT;
+
+	yeeloong_hotkey_dev = input_allocate_device();
+
+	if (!yeeloong_hotkey_dev) {
+		remove_irq(SCI_IRQ_NUM, &sci_irqaction);
+		return -ENOMEM;
+	}
+
+	yeeloong_hotkey_dev->name = "HotKeys";
+	yeeloong_hotkey_dev->phys = "button/input0";
+	yeeloong_hotkey_dev->id.bustype = BUS_HOST;
+	yeeloong_hotkey_dev->dev.parent = NULL;
+
+	for (key = yeeloong_keymap; key->type != KE_END; key++) {
+		switch (key->type) {
+		case KE_KEY:
+			set_bit(EV_KEY, yeeloong_hotkey_dev->evbit);
+			set_bit(key->keycode, yeeloong_hotkey_dev->keybit);
+			break;
+		case KE_SW:
+			set_bit(EV_SW, yeeloong_hotkey_dev->evbit);
+			set_bit(key->keycode, yeeloong_hotkey_dev->swbit);
+			break;
+		}
+	}
+
+	ret = input_register_device(yeeloong_hotkey_dev);
+	if (ret) {
+		input_free_device(yeeloong_hotkey_dev);
+		return ret;
+	}
+
+	if (ret) {
+		input_unregister_device(yeeloong_hotkey_dev);
+		yeeloong_hotkey_dev = NULL;
+	}
+	/* Update the current status of LID */
+	report_lid_switch(BIT_LID_DETECT_ON);
+
+	/* Install the real yeeloong_report_lid_status for pm.c */
+	yeeloong_report_lid_status = report_lid_switch;
+
+	return 0;
+}
+
+static void __exit yeeloong_hotkey_exit(void)
+{
+	/* Free irq */
+	remove_irq(SCI_IRQ_NUM, &sci_irqaction);
+
+	/* Uninstall yeeloong_report_lid_status for pm.c */
+	yeeloong_report_lid_status = NULL;
+
+	if (yeeloong_hotkey_dev) {
+		input_unregister_device(yeeloong_hotkey_dev);
+		yeeloong_hotkey_dev = NULL;
+	}
+}
+
+module_init(yeeloong_hotkey_init);
+module_exit(yeeloong_hotkey_exit);
-- 
1.6.2.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-28 13:44 ` [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangjin
@ 2009-11-29  5:35   ` Dmitry Torokhov
  2009-11-29  5:50     ` Wu Zhangjin
  2009-11-30  5:18   ` Wu Zhangjin
  1 sibling, 1 reply; 34+ messages in thread
From: Dmitry Torokhov @ 2009-11-29  5:35 UTC (permalink / raw)
  To: Wu Zhangjin; +Cc: Ralf Baechle, linux-mips, zhangfx, yanh, huhb, linux-input

On Sat, Nov 28, 2009 at 09:44:41PM +0800, Wu Zhangjin wrote:
>  
> +config YEELOONG_HOTKEY
> +	tristate "Hotkey Driver"
> +	depends on YEELOONG_VO
> +	select INPUT

I think this should be depend, not select. 

> +	select INPUT_EVDEV
> +	select SUSPEND

Does it break without SUSPEND? I am pretty sure that it will work fine
without EVDEV (however unlikely it is not present).

-- 
Dmitry

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-29  5:35   ` Dmitry Torokhov
@ 2009-11-29  5:50     ` Wu Zhangjin
  2009-11-29  7:29       ` Ralf Baechle
  0 siblings, 1 reply; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-29  5:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Ralf Baechle, linux-mips, zhangfx, yanh, huhb, linux-input

On Sat, 2009-11-28 at 21:35 -0800, Dmitry Torokhov wrote:
> On Sat, Nov 28, 2009 at 09:44:41PM +0800, Wu Zhangjin wrote:
> >  
> > +config YEELOONG_HOTKEY
> > +	tristate "Hotkey Driver"
> > +	depends on YEELOONG_VO
> > +	select INPUT
> 
> I think this should be depend, not select. 

Hmm, okay, will replace it by depend later ;)

> 
> > +	select INPUT_EVDEV
> > +	select SUSPEND
> 
> Does it break without SUSPEND?

not break, but I just want to select something for users, so, they will
have no need to care about which extra option is needed.

anyway, I will use #ifdef ... #endif instead later.

>  I am pretty sure that it will work fine
> without EVDEV (however unlikely it is not present).

Yes, without EVDEV, it can be compiled, but without the EVDEV module, no
event will be sent to the user-space, as a result, we just get a broken
input support. so, let the users make their decision?

Regards,
	Wu Zhangjin


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-29  5:50     ` Wu Zhangjin
@ 2009-11-29  7:29       ` Ralf Baechle
  2009-11-29  7:40         ` Wu Zhangjin
  0 siblings, 1 reply; 34+ messages in thread
From: Ralf Baechle @ 2009-11-29  7:29 UTC (permalink / raw)
  To: Wu Zhangjin; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, linux-input

On Sun, Nov 29, 2009 at 01:50:02PM +0800, Wu Zhangjin wrote:

> On Sat, 2009-11-28 at 21:35 -0800, Dmitry Torokhov wrote:
> > On Sat, Nov 28, 2009 at 09:44:41PM +0800, Wu Zhangjin wrote:
> > >  
> > > +config YEELOONG_HOTKEY
> > > +	tristate "Hotkey Driver"
> > > +	depends on YEELOONG_VO
> > > +	select INPUT
> > 
> > I think this should be depend, not select. 
> 
> Hmm, okay, will replace it by depend later ;)
> 
> > 
> > > +	select INPUT_EVDEV
> > > +	select SUSPEND
> > 
> > Does it break without SUSPEND?
> 
> not break, but I just want to select something for users, so, they will
> have no need to care about which extra option is needed.

We use  select extensively on MIPS but select is dangerous and you stepped
into its trap.  When SUSPEND is enabled by a user in
kernel/power/Kconfig it can only be choosen if PM is enabled.  By
"select SUSPEND" this dependency so now it is possible to have a kernel
where SUSPEND is enabled without PM which won't work.

  Ralf

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-29  7:29       ` Ralf Baechle
@ 2009-11-29  7:40         ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-29  7:40 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, linux-input

On Sun, 2009-11-29 at 07:29 +0000, Ralf Baechle wrote:
> On Sun, Nov 29, 2009 at 01:50:02PM +0800, Wu Zhangjin wrote:
> 
> > On Sat, 2009-11-28 at 21:35 -0800, Dmitry Torokhov wrote:
> > > On Sat, Nov 28, 2009 at 09:44:41PM +0800, Wu Zhangjin wrote:
> > > >  
> > > > +config YEELOONG_HOTKEY
> > > > +	tristate "Hotkey Driver"
> > > > +	depends on YEELOONG_VO
> > > > +	select INPUT
> > > 
> > > I think this should be depend, not select. 
> > 
> > Hmm, okay, will replace it by depend later ;)
> > 
> > > 
> > > > +	select INPUT_EVDEV
> > > > +	select SUSPEND
> > > 
> > > Does it break without SUSPEND?
> > 
> > not break, but I just want to select something for users, so, they will
> > have no need to care about which extra option is needed.
> 
> We use  select extensively on MIPS but select is dangerous and you stepped
> into its trap.  When SUSPEND is enabled by a user in
> kernel/power/Kconfig it can only be choosen if PM is enabled.  By
> "select SUSPEND" this dependency so now it is possible to have a kernel
> where SUSPEND is enabled without PM which won't work.
> 

Get it, thanks for your clarification ;)

Regards,
	Wu Zhangjin


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
  2009-11-29  9:19   ` Pavel Machek
@ 2009-11-29  9:19   ` Pavel Machek
  2009-11-29 22:35   ` Rafael J. Wysocki
  2009-11-29 22:35   ` Rafael J. Wysocki
  3 siblings, 0 replies; 34+ messages in thread
From: Pavel Machek @ 2009-11-29  9:19 UTC (permalink / raw)
  To: Wu Zhangjin
  Cc: linux-mips, yanh, Dmitry Torokhov, Ralf Baechle, zhangfx, linux-pm

On Sat 2009-11-28 21:42:39, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> specific devices.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>

ACK.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
@ 2009-11-29  9:19   ` Pavel Machek
  2009-11-29  9:19   ` Pavel Machek
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Pavel Machek @ 2009-11-29  9:19 UTC (permalink / raw)
  To: Wu Zhangjin
  Cc: Ralf Baechle, Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb,
	linux-pm, Rafael J. Wysocki

On Sat 2009-11-28 21:42:39, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> specific devices.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>

ACK.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
                     ` (2 preceding siblings ...)
  2009-11-29 22:35   ` Rafael J. Wysocki
@ 2009-11-29 22:35   ` Rafael J. Wysocki
  3 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2009-11-29 22:35 UTC (permalink / raw)
  To: Wu Zhangjin
  Cc: linux-mips, yanh, Dmitry Torokhov, Ralf Baechle, zhangfx, linux-pm

On Saturday 28 November 2009, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> specific devices.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
>  3 files changed, 151 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index c4398ff..49d63c5 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -45,4 +45,13 @@ config YEELOONG_VO
>  	  This option adds Video Output Driver, which provides standard
>  	  interface to turn on/off the video output of LCD, CRT.
>  
> +config YEELOONG_SUSPEND
> +	tristate "Suspend Driver"

Why tristate?

> +	depends on YEELOONG_HWMON && YEELOONG_VO
> +	select SUSPEND

I'm not sure if that's going to work.  Please make it depend on SUSPEND rather
than select it.

> +	default y
> +	help
> +	  This option adds Suspend Driver, which will suspend the YeeLoong
> +	  Platform specific devices.
> +
>  endif

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
  2009-11-29  9:19   ` Pavel Machek
  2009-11-29  9:19   ` Pavel Machek
@ 2009-11-29 22:35   ` Rafael J. Wysocki
  2009-11-30  0:59     ` Wu Zhangjin
  2009-11-30  0:59     ` Wu Zhangjin
  2009-11-29 22:35   ` Rafael J. Wysocki
  3 siblings, 2 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2009-11-29 22:35 UTC (permalink / raw)
  To: Wu Zhangjin
  Cc: Ralf Baechle, Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb,
	Pavel Machek, linux-pm

On Saturday 28 November 2009, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> specific devices.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
>  3 files changed, 151 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index c4398ff..49d63c5 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -45,4 +45,13 @@ config YEELOONG_VO
>  	  This option adds Video Output Driver, which provides standard
>  	  interface to turn on/off the video output of LCD, CRT.
>  
> +config YEELOONG_SUSPEND
> +	tristate "Suspend Driver"

Why tristate?

> +	depends on YEELOONG_HWMON && YEELOONG_VO
> +	select SUSPEND

I'm not sure if that's going to work.  Please make it depend on SUSPEND rather
than select it.

> +	default y
> +	help
> +	  This option adds Suspend Driver, which will suspend the YeeLoong
> +	  Platform specific devices.
> +
>  endif

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-29 22:35   ` Rafael J. Wysocki
@ 2009-11-30  0:59     ` Wu Zhangjin
  2009-11-30  0:59     ` Wu Zhangjin
  1 sibling, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  0:59 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-mips, yanh, Dmitry Torokhov, Ralf Baechle, zhangfx, linux-pm

On Sun, 2009-11-29 at 23:35 +0100, Rafael J. Wysocki wrote:
> On Saturday 28 November 2009, Wu Zhangjin wrote:
> > From: Wu Zhangjin <wuzhangjin@gmail.com>
> > 
> > This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> > specific devices.
> > 
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> > ---
> >  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
> >  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
> >  .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
> >  3 files changed, 151 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
> > 
> > diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > index c4398ff..49d63c5 100644
> > --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > @@ -45,4 +45,13 @@ config YEELOONG_VO
> >  	  This option adds Video Output Driver, which provides standard
> >  	  interface to turn on/off the video output of LCD, CRT.
> >  
> > +config YEELOONG_SUSPEND
> > +	tristate "Suspend Driver"
> 
> Why tristate?

Allow it to be available as a module.

There are lots of platform specific drivers for Lemote-2F family
machines, benefit from tristate, the distribution developers can compile
them as modules, and then the users can load what they want for their
own machines.

> 
> > +	depends on YEELOONG_HWMON && YEELOONG_VO
> > +	select SUSPEND
> 
> I'm not sure if that's going to work.  Please make it depend on SUSPEND rather
> than select it.

Yes, Have replaced "select" by "depend on", thanks!

> 
> > +	default y
> > +	help
> > +	  This option adds Suspend Driver, which will suspend the YeeLoong
> > +	  Platform specific devices.
> > +
> >  endif
> 
> Thanks,
> Rafael

Thanks & Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver
  2009-11-29 22:35   ` Rafael J. Wysocki
  2009-11-30  0:59     ` Wu Zhangjin
@ 2009-11-30  0:59     ` Wu Zhangjin
  1 sibling, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  0:59 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Ralf Baechle, Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb,
	Pavel Machek, linux-pm

On Sun, 2009-11-29 at 23:35 +0100, Rafael J. Wysocki wrote:
> On Saturday 28 November 2009, Wu Zhangjin wrote:
> > From: Wu Zhangjin <wuzhangjin@gmail.com>
> > 
> > This patch adds Suspend Driver, which will suspend the YeeLoong Platform
> > specific devices.
> > 
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> > ---
> >  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
> >  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
> >  .../loongson/lemote-2f/yeeloong_laptop/suspend.c   |  141 ++++++++++++++++++++
> >  3 files changed, 151 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/suspend.c
> > 
> > diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > index c4398ff..49d63c5 100644
> > --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > @@ -45,4 +45,13 @@ config YEELOONG_VO
> >  	  This option adds Video Output Driver, which provides standard
> >  	  interface to turn on/off the video output of LCD, CRT.
> >  
> > +config YEELOONG_SUSPEND
> > +	tristate "Suspend Driver"
> 
> Why tristate?

Allow it to be available as a module.

There are lots of platform specific drivers for Lemote-2F family
machines, benefit from tristate, the distribution developers can compile
them as modules, and then the users can load what they want for their
own machines.

> 
> > +	depends on YEELOONG_HWMON && YEELOONG_VO
> > +	select SUSPEND
> 
> I'm not sure if that's going to work.  Please make it depend on SUSPEND rather
> than select it.

Yes, Have replaced "select" by "depend on", thanks!

> 
> > +	default y
> > +	help
> > +	  This option adds Suspend Driver, which will suspend the YeeLoong
> > +	  Platform specific devices.
> > +
> >  endif
> 
> Thanks,
> Rafael

Thanks & Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
  2009-11-28 13:44 ` [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangjin
  2009-11-29  5:35   ` Dmitry Torokhov
@ 2009-11-30  5:18   ` Wu Zhangjin
  1 sibling, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:18 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, linux-input

On Sat, 2009-11-28 at 21:44 +0800, Wu Zhangjin wrote:
[...]
> +
> +static int camera_handler(int status)
> +{
> +	int value;
> +	static int camera_status;
> +
> +	status = !!status;
> +	camera_status = ec_read(REG_CAMERA_STATUS);
> +	if (status != camera_status) {
> +		value = ec_read(REG_CAMERA_CONTROL);
> +		ec_write(REG_CAMERA_CONTROL, value | (1 << 1));
> +	}
> +	return ec_read(REG_CAMERA_STATUS);
> +}

The above stuff is very awful, the camera event work as a switch, so
this is enough:

static int camera_handler(int status)
{
	int value;

	value = ec_read(REG_CAMERA_CONTROL);
	ec_write(REG_CAMERA_CONTROL, value | (1 << 1));

	return status;
}

[...]
> +/*
> + * SCI(system control interrupt) main interrupt routine
> + *
> + * We will do the query and get event number together so the interrupt routine
> + * should be longer than 120us now at least 3ms elpase for it.
> + */
> +static irqreturn_t sci_irq_handler(int irq, void *dev_id)
> +{
> +	int ret;
> +
> +	if (SCI_IRQ_NUM != irq)
> +		return IRQ_NONE;
> +
> +	/* Query the event number */
> +	ret = ec_query_event_num();
> +	if (ret < 0)
> +		return IRQ_NONE;
> +
> +	event = ec_get_event_num();
> +	if (event < 0)
> +		return IRQ_NONE;
> +
> +	if ((event != 0x00) && (event != 0xff)) {

It's better to use somethig else:

if (event >= EVENT_START && event <= EVENT_END) {
....

Best Regards,
	Wu Zhangjin


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 6/8] Loongson: YeeLoong: add video output driver
  2009-11-28 13:41 ` [PATCH v5 6/8] Loongson: YeeLoong: add video output driver Wu Zhangjin
@ 2009-11-30  5:19   ` Wu Zhangjin
  2009-11-30  6:43     ` Wu Zhangjin
  0 siblings, 1 reply; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:19 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, luming.yu

On Sat, 2009-11-28 at 21:41 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds Video Output Driver, which provides standard interface
> to turn on/off the video output of LCD, CRT.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    8 +
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
>  .../lemote-2f/yeeloong_laptop/video_output.c       |  164 ++++++++++++++++++++
>  4 files changed, 176 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index 56cb584..c4398ff 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -37,4 +37,12 @@ config YEELOONG_HWMON
>  	  interface for lm-sensors to monitor the temperatures of CPU and
>  	  battery, the PWM of fan, the current, voltage of battery.
>  
> +config YEELOONG_VO
> +	tristate "Video Output Driver"
> +	select VIDEO_OUTPUT_CONTROL

Will use "depend" instead in the next version.

Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
  2009-11-28 13:38   ` [lm-sensors] " Wu Zhangjin
@ 2009-11-30  5:20     ` Wu Zhangjin
  -1 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:20 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Sat, 2009-11-28 at 21:38 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds hwmon driver for managing the temperature of battery,
> cpu and controlling the fan.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
>  .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
>  4 files changed, 254 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index e284c91..56cb584 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -28,4 +28,13 @@ config YEELOONG_BATTERY
>  	  This option adds APM emulated Battery Driver, which provides standard
>  	  interface for user-space applications to manage the battery.
>  
> +config YEELOONG_HWMON
> +	tristate "Hardware Monitor Driver"
> +	select HWMON

Will use depend in the next version.

Best Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [lm-sensors] [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
@ 2009-11-30  5:20     ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:20 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Sat, 2009-11-28 at 21:38 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds hwmon driver for managing the temperature of battery,
> cpu and controlling the fan.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
>  .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
>  4 files changed, 254 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index e284c91..56cb584 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -28,4 +28,13 @@ config YEELOONG_BATTERY
>  	  This option adds APM emulated Battery Driver, which provides standard
>  	  interface for user-space applications to manage the battery.
>  
> +config YEELOONG_HWMON
> +	tristate "Hardware Monitor Driver"
> +	select HWMON

Will use depend in the next version.

Best Regards,
	Wu Zhangjin


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 4/8] Loongson: YeeLoong: add battery driver
  2009-11-28 13:37 ` [PATCH v5 4/8] Loongson: YeeLoong: add battery driver Wu Zhangjin
@ 2009-11-30  5:22   ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:22 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Jamey Hicks,
	Stephen Rothwell

On Sat, 2009-11-28 at 21:37 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds APM_EMULATION based Battery Driver, which provides
> standard interface for user-space applications to manage the battery.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
>  .../loongson/lemote-2f/yeeloong_laptop/battery.c   |  127 ++++++++++++++++++++
>  3 files changed, 137 insertions(+), 0 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/battery.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index 02d36d8..e284c91 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -19,4 +19,13 @@ config YEELOONG_BACKLIGHT
>  	  interface for user-space applications to control the brightness of
>  	  the backlight.
>  
> +config YEELOONG_BATTERY
> +	tristate "Battery Driver"
> +	select SYS_SUPPORTS_APM_EMULATION
> +	select APM_EMULATION

Will use "depend" on APM_EMULATION instead in the next version, and put
this line "select SYS_SUPPORTS_APM_EMULATION" under the
LEMOTE_YEELOONG2F.

Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver
  2009-11-28 13:36 ` [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangjin
@ 2009-11-30  5:22   ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  5:22 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, Richard Purdie

On Sat, 2009-11-28 at 21:36 +0800, Wu Zhangjin wrote:
> From: Wu Zhangjin <wuzhangjin@gmail.com>
> 
> This patch adds YeeLoong Backlight Driver, which provides standard
> interface for user-space applications to control the brightness of the
> backlight.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 ++-
>  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    2 +
>  .../loongson/lemote-2f/yeeloong_laptop/backlight.c |   93 ++++++++++++++++++++
>  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    1 +
>  4 files changed, 104 insertions(+), 1 deletions(-)
>  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/backlight.c
> 
> diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> index d6df9b7..02d36d8 100644
> --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> @@ -10,6 +10,13 @@ menuconfig LEMOTE_YEELOONG2F
>  
>  if LEMOTE_YEELOONG2F
>  
> -
> +config YEELOONG_BACKLIGHT
> +	tristate "Backlight Driver"
> +	select BACKLIGHT_CLASS_DEVICE

Will use "depend" instead in the next version.

Best Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
  2009-11-30  5:20     ` [lm-sensors] " Wu Zhangjin
@ 2009-11-30  6:24       ` Wu Zhangjin
  -1 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  6:24 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Mon, 2009-11-30 at 13:20 +0800, Wu Zhangjin wrote:
> On Sat, 2009-11-28 at 21:38 +0800, Wu Zhangjin wrote:
> > From: Wu Zhangjin <wuzhangjin@gmail.com>
> > 
> > This patch adds hwmon driver for managing the temperature of battery,
> > cpu and controlling the fan.
> > 
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> > ---
> >  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
> >  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
> >  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
> >  .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
> >  4 files changed, 254 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
> > 
> > diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > index e284c91..56cb584 100644
> > --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > @@ -28,4 +28,13 @@ config YEELOONG_BATTERY
> >  	  This option adds APM emulated Battery Driver, which provides standard
> >  	  interface for user-space applications to manage the battery.
> >  
> > +config YEELOONG_HWMON
> > +	tristate "Hardware Monitor Driver"
> > +	select HWMON
> 
> Will use depend in the next version.
> 

Sorry, This must be select, there is no other way to select this stuff.

> Best Regards,
> 	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [lm-sensors] [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
@ 2009-11-30  6:24       ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  6:24 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Mon, 2009-11-30 at 13:20 +0800, Wu Zhangjin wrote:
> On Sat, 2009-11-28 at 21:38 +0800, Wu Zhangjin wrote:
> > From: Wu Zhangjin <wuzhangjin@gmail.com>
> > 
> > This patch adds hwmon driver for managing the temperature of battery,
> > cpu and controlling the fan.
> > 
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> > ---
> >  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    9 +
> >  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
> >  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
> >  .../loongson/lemote-2f/yeeloong_laptop/hwmon.c     |  241 ++++++++++++++++++++
> >  4 files changed, 254 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/hwmon.c
> > 
> > diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > index e284c91..56cb584 100644
> > --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > @@ -28,4 +28,13 @@ config YEELOONG_BATTERY
> >  	  This option adds APM emulated Battery Driver, which provides standard
> >  	  interface for user-space applications to manage the battery.
> >  
> > +config YEELOONG_HWMON
> > +	tristate "Hardware Monitor Driver"
> > +	select HWMON
> 
> Will use depend in the next version.
> 

Sorry, This must be select, there is no other way to select this stuff.

> Best Regards,
> 	Wu Zhangjin



_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 6/8] Loongson: YeeLoong: add video output driver
  2009-11-30  5:19   ` Wu Zhangjin
@ 2009-11-30  6:43     ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-11-30  6:43 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, luming.yu

On Mon, 2009-11-30 at 13:19 +0800, Wu Zhangjin wrote:
> On Sat, 2009-11-28 at 21:41 +0800, Wu Zhangjin wrote:
> > From: Wu Zhangjin <wuzhangjin@gmail.com>
> > 
> > This patch adds Video Output Driver, which provides standard interface
> > to turn on/off the video output of LCD, CRT.
> > 
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> > ---
> >  .../loongson/lemote-2f/yeeloong_laptop/Kconfig     |    8 +
> >  .../loongson/lemote-2f/yeeloong_laptop/Makefile    |    1 +
> >  .../lemote-2f/yeeloong_laptop/ec_kb3310b.h         |    3 +
> >  .../lemote-2f/yeeloong_laptop/video_output.c       |  164 ++++++++++++++++++++
> >  4 files changed, 176 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/video_output.c
> > 
> > diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > index 56cb584..c4398ff 100644
> > --- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > +++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
> > @@ -37,4 +37,12 @@ config YEELOONG_HWMON
> >  	  interface for lm-sensors to monitor the temperatures of CPU and
> >  	  battery, the PWM of fan, the current, voltage of battery.
> >  
> > +config YEELOONG_VO
> > +	tristate "Video Output Driver"
> > +	select VIDEO_OUTPUT_CONTROL
> 
> Will use "depend" instead in the next version.
> 

Sorry to disturb you, this also must be "select", and the same to
BACKLIGHT_CLASS_DEVICE.

> Regards,
> 	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
  2009-11-30  6:24       ` [lm-sensors] " Wu Zhangjin
@ 2009-12-01  1:48         ` Ralf Baechle
  -1 siblings, 0 replies; 34+ messages in thread
From: Ralf Baechle @ 2009-12-01  1:48 UTC (permalink / raw)
  To: Wu Zhangjin; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Mon, Nov 30, 2009 at 02:24:54PM +0800, Wu Zhangjin wrote:

> > > +config YEELOONG_HWMON
> > > +	tristate "Hardware Monitor Driver"
> > > +	select HWMON
> > 
> > Will use depend in the next version.
> > 
> 
> Sorry, This must be select, there is no other way to select this stuff.

Why that?

  Ralf

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [lm-sensors] [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
@ 2009-12-01  1:48         ` Ralf Baechle
  0 siblings, 0 replies; 34+ messages in thread
From: Ralf Baechle @ 2009-12-01  1:48 UTC (permalink / raw)
  To: Wu Zhangjin; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Mon, Nov 30, 2009 at 02:24:54PM +0800, Wu Zhangjin wrote:

> > > +config YEELOONG_HWMON
> > > +	tristate "Hardware Monitor Driver"
> > > +	select HWMON
> > 
> > Will use depend in the next version.
> > 
> 
> Sorry, This must be select, there is no other way to select this stuff.

Why that?

  Ralf

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
  2009-12-01  1:48         ` [lm-sensors] " Ralf Baechle
@ 2009-12-01  2:06           ` Wu Zhangjin
  -1 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-12-01  2:06 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Tue, 2009-12-01 at 01:48 +0000, Ralf Baechle wrote:
> On Mon, Nov 30, 2009 at 02:24:54PM +0800, Wu Zhangjin wrote:
> 
> > > > +config YEELOONG_HWMON
> > > > +	tristate "Hardware Monitor Driver"
> > > > +	select HWMON
> > > 
> > > Will use depend in the next version.
> > > 
> > 
> > Sorry, This must be select, there is no other way to select this stuff.
> 
> Why that?

Hmm, sorry, my old explanation is totally Wrong, it's better to select
it for us, just as the x86 platform drivers did:

$ cat drivers/platform/x86/Kconfig | grep " HWMON"
	select HWMON
	select HWMON

Because the HWMON stuff is put in the device drivers as a menuconfig,
but our platform driver is put in its own directory. it will not be
convenient for the users to select it themselves, and also, this select
have no side effect.

Best Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [lm-sensors] [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver
@ 2009-12-01  2:06           ` Wu Zhangjin
  0 siblings, 0 replies; 34+ messages in thread
From: Wu Zhangjin @ 2009-12-01  2:06 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Dmitry Torokhov, linux-mips, zhangfx, yanh, huhb, lm-sensors

On Tue, 2009-12-01 at 01:48 +0000, Ralf Baechle wrote:
> On Mon, Nov 30, 2009 at 02:24:54PM +0800, Wu Zhangjin wrote:
> 
> > > > +config YEELOONG_HWMON
> > > > +	tristate "Hardware Monitor Driver"
> > > > +	select HWMON
> > > 
> > > Will use depend in the next version.
> > > 
> > 
> > Sorry, This must be select, there is no other way to select this stuff.
> 
> Why that?

Hmm, sorry, my old explanation is totally Wrong, it's better to select
it for us, just as the x86 platform drivers did:

$ cat drivers/platform/x86/Kconfig | grep " HWMON"
	select HWMON
	select HWMON

Because the HWMON stuff is put in the device drivers as a menuconfig,
but our platform driver is put in its own directory. it will not be
convenient for the users to select it themselves, and also, this select
have no side effect.

Best Regards,
	Wu Zhangjin


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2009-12-01  2:06 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-28 13:31 [PATCH v5 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangjin
2009-11-28 13:31 ` [PATCH v5 1/8] Loongson: Lemote-2F: add platform specific submenu Wu Zhangjin
2009-11-28 13:34 ` [PATCH v5 2/8] Loongson: YeeLoong: add platform specific option Wu Zhangjin
2009-11-28 13:36 ` [PATCH v5 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangjin
2009-11-30  5:22   ` Wu Zhangjin
2009-11-28 13:37 ` [PATCH v5 4/8] Loongson: YeeLoong: add battery driver Wu Zhangjin
2009-11-30  5:22   ` Wu Zhangjin
2009-11-28 13:38 ` [PATCH v5 5/8] Loongson: YeeLoong: add hwmon driver Wu Zhangjin
2009-11-28 13:38   ` [lm-sensors] " Wu Zhangjin
2009-11-30  5:20   ` Wu Zhangjin
2009-11-30  5:20     ` [lm-sensors] " Wu Zhangjin
2009-11-30  6:24     ` Wu Zhangjin
2009-11-30  6:24       ` [lm-sensors] " Wu Zhangjin
2009-12-01  1:48       ` Ralf Baechle
2009-12-01  1:48         ` [lm-sensors] " Ralf Baechle
2009-12-01  2:06         ` Wu Zhangjin
2009-12-01  2:06           ` [lm-sensors] " Wu Zhangjin
2009-11-28 13:41 ` [PATCH v5 6/8] Loongson: YeeLoong: add video output driver Wu Zhangjin
2009-11-30  5:19   ` Wu Zhangjin
2009-11-30  6:43     ` Wu Zhangjin
2009-11-28 13:42 ` [PATCH v5 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangjin
2009-11-29  9:19   ` Pavel Machek
2009-11-29  9:19   ` Pavel Machek
2009-11-29 22:35   ` Rafael J. Wysocki
2009-11-30  0:59     ` Wu Zhangjin
2009-11-30  0:59     ` Wu Zhangjin
2009-11-29 22:35   ` Rafael J. Wysocki
2009-11-28 13:42 ` Wu Zhangjin
2009-11-28 13:44 ` [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangjin
2009-11-29  5:35   ` Dmitry Torokhov
2009-11-29  5:50     ` Wu Zhangjin
2009-11-29  7:29       ` Ralf Baechle
2009-11-29  7:40         ` Wu Zhangjin
2009-11-30  5:18   ` Wu Zhangjin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.