Loongson: YeeLoong: add platform specific driver
v12 cover Loongson: YeeLoong: add platform specific driver
This patchset adds the platform specific driver for the YeeLoong netbook made by Lemote.
Changes from v11:
o Fixup of the brightness driver (from Zhou Yajin) use the right arguments for the backlight_device_register()
Wu Zhangjin (9):
MIPS: add subdirectory for platform extension drivers
Loongson: YeeLoong: add platform driver
Loongson: YeeLoong: add backlight driver
Loongson: YeeLoong: add hardware monitoring driver
Loongson: YeeLoong: add video output driver
Loongson: YeeLoong: add suspend support
Loongson: YeeLoong: add input/hotkey driver
Loongson: YeeLoong: add power_supply based battery driver
Loongson: YeeLoong: Co-operate with the revisions of EC
arch/mips/include/asm/mach-loongson/ec_kb3310b.h | 190 ++++ arch/mips/include/asm/mach-loongson/loongson.h | 6 + arch/mips/loongson/common/cmdline.c | 8 + arch/mips/loongson/lemote-2f/Makefile | 2 +- arch/mips/loongson/lemote-2f/ec_kb3310b.c | 12 +- arch/mips/loongson/lemote-2f/ec_kb3310b.h | 188 ---- arch/mips/loongson/lemote-2f/platform.c | 39 + arch/mips/loongson/lemote-2f/pm.c | 4 +- arch/mips/loongson/lemote-2f/reset.c | 2 +- drivers/platform/Kconfig | 4 + drivers/platform/Makefile | 1 + drivers/platform/mips/Kconfig | 32 + drivers/platform/mips/Makefile | 5 + drivers/platform/mips/yeeloong_laptop.c | 1200 ++++++++++++++++++++++ 14 files changed, 1493 insertions(+), 200 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/ec_kb3310b.h delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.h create mode 100644 arch/mips/loongson/lemote-2f/platform.c create mode 100644 drivers/platform/mips/Kconfig create mode 100644 drivers/platform/mips/Makefile create mode 100644 drivers/platform/mips/yeeloong_laptop.c
PATCH v12 1/9 MIPS: add subdirectory for platform extension drivers
It is really hard to split the platform specific subdrivers into different subsystems, which will generate lots of duplicated source code, break the whole support into several pieces and also will make the users be difficult to choose the suitable subdrivers in different places.
So, I did like the forks have done under drivers/platform/x86, created the drivers/platform/mips/ for putting the future MIPS netbook/laptop/pc extension drivers in.
--- drivers/platform/Kconfig | 4 ++++ drivers/platform/mips/Kconfig | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 drivers/platform/mips/Kconfig
drivers/platform/Kconfig +4 -0
@@ -1,3 +1,7 @@ if X86 source "drivers/platform/x86/Kconfig" endif + +if MIPS +source "drivers/platform/mips/Kconfig" +endif
drivers/platform/mips/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# +# MIPS Platform Specific Drivers +# + +menuconfig MIPS_PLATFORM_DEVICES + bool "MIPS Platform Specific Device Drivers" + default y + help + Say Y here to get to see options for device drivers of various + MIPS platforms, including vendor-specific netbook/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 MIPS_PLATFORM_DEVICES + + +endif # MIPS_PLATFORM_DEVICES
Signature · 1 line
1.7.0.4
PATCH v12 2/9 Loongson: YeeLoong: add platform driver
In reply to Wu ZhangjinThis patch adds platform driver for YeeLoong, Currently, This driver is "empty", the subdrivers will be added in the coming patches.
--- arch/mips/include/asm/mach-loongson/ec_kb3310b.h | 190 ++++++++++++++++++++++ arch/mips/loongson/lemote-2f/Makefile | 2 +- arch/mips/loongson/lemote-2f/ec_kb3310b.c | 12 +- arch/mips/loongson/lemote-2f/ec_kb3310b.h | 188 --------------------- arch/mips/loongson/lemote-2f/platform.c | 39 +++++ arch/mips/loongson/lemote-2f/pm.c | 4 +- arch/mips/loongson/lemote-2f/reset.c | 2 +- drivers/platform/Makefile | 1 + drivers/platform/mips/Kconfig | 8 + drivers/platform/mips/Makefile | 5 + drivers/platform/mips/yeeloong_laptop.c | 59 +++++++ 11 files changed, 310 insertions(+), 200 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/ec_kb3310b.h delete mode 100644 arch/mips/loongson/lemote-2f/ec_kb3310b.h create mode 100644 arch/mips/loongson/lemote-2f/platform.c create mode 100644 drivers/platform/mips/Makefile create mode 100644 drivers/platform/mips/yeeloong_laptop.c
arch/mips/include/asm/mach-loongson/ec_kb3310b.h new file +190 -0
@@ -0,0 +1,190 @@ +/* +* KB3310B Embedded Controller +* +* Copyright (C) 2008 Lemote Inc. +* Author: liujl <[email protected]>, 2008-03-14 +* Copyright (C) 2009, 2010 Wu Zhangjin <[email protected]> +* +* 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_SWITCHVIDEOMODE ,/* 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_DISPLAYTOGGLE ,/* Fn+F2, Turn on/off backlight */ +EVENT_AUDIO_MUTE ,/* Fn+F4, Mute on/off */ +EVENT_DISPLAY_BRIGHTNESS ,/* Fn+^/V, LCD backlight brightness adjust */ +EVENT_AC_BAT ,/* AC & Battery relative issue */ +EVENT_AUDIO_VOLUME ,/* Fn+<|>, Volume adjust */ +EVENT_WLAN ,/* Wlan on/off */ +}; + +#define EVENT_START EVENT_LID +#define EVENT_END EVENT_WLAN + +#endif /* !_EC_KB3310B_H */
arch/mips/loongson/lemote-2f/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile for lemote loongson2f family machines # -obj-y += machtype.o irq.o reset.o ec_kb3310b.o +obj-y += machtype.o irq.o reset.o ec_kb3310b.o platform.o # # Suspend Support
arch/mips/loongson/lemote-2f/ec_kb3310b.c +4 -8
@@ -14,7 +14,7 @@#include <linux/spinlock.h> #include <linux/delay.h> -#include "ec_kb3310b.h" +#include <ec_kb3310b.h> static DEFINE_SPINLOCK (index_access_lock);static DEFINE_SPINLOCK (port_access_lock);
@@ -78,12 +78,9 @@ int ec_query_seq(unsigned char cmd)spin_unlock_irqrestore (&port_access_lock, flags);if (timeout <=0 ) { -printk (KERN_ERR "%s: deadable error : timeout...\n" , __func__); +pr_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); + }return ret; }
@@ -118,8 +115,7 @@ int ec_get_event_num(void)udelay (EC_REG_DELAY ); }if (timeout <=0 ) { -pr_info ("%s: get event number timeout.\n" , __func__); - +pr_err ("%s: get event number timeout.\n" , __func__);return -EINVAL ; } value =inb (EC_DAT_PORT );
arch/mips/loongson/lemote-2f/ec_kb3310b.h deleted +0 -188
188 lines not on this page · raw message
arch/mips/loongson/lemote-2f/platform.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (C) 2009, 2010 Wu Zhangjin <[email protected]> +* +* 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/err.h> +#include <linux/platform_device.h> + +#include <asm/bootinfo.h> + +static struct platform_device yeeloong_pdev = { + .name ="yeeloong_laptop" , + .id =-1 , +}; + +static int __init lemote2f_platform_init (void ) +{ +struct platform_device *pdev =NULL ; + +switch (mips_machtype) { +case MACH_LEMOTE_YL2F89 : + pdev = &yeeloong_pdev; +break ; +default : +break ; + + } + +if (pdev !=NULL ) +return platform_device_register (pdev); + +return -ENODEV ; +} + +device_initcall (lemote2f_platform_init);
arch/mips/loongson/lemote-2f/pm.c +2 -2
@@ -23,7 +23,7 @@#include <loongson.h> #include <cs5536/cs5536_mfgpt.h> -#include "ec_kb3310b.h" +#include <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 ;
arch/mips/loongson/lemote-2f/reset.c +1 -1
@@ -20,7 +20,7 @@#include <loongson.h> #include <cs5536/cs5536.h> -#include "ec_kb3310b.h" +#include <ec_kb3310b.h> static void reset_cpu (void ) {
drivers/platform/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_MIPS) += mips/
drivers/platform/mips/Kconfig +8 -0
@@ -14,5 +14,13 @@ menuconfig MIPS_PLATFORM_DEVICES if MIPS_PLATFORM_DEVICES +config LEMOTE_YEELOONG2F + tristate "Lemote YeeLoong Laptop" + depends on LEMOTE_MACH2F + 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. endif # MIPS_PLATFORM_DEVICES
drivers/platform/mips/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for MIPS Platform-Specific Drivers +# + +obj-$(CONFIG_LEMOTE_YEELOONG2F) += yeeloong_laptop.o
drivers/platform/mips/yeeloong_laptop.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 3/9 Loongson: YeeLoong: add backlight driver
In reply to Wu ZhangjinThis patch adds YeeLoong Backlight Driver, it provides standard interface(/sys/class/backlight/) for user-space applications(e.g. kpowersave, gnome-power-manager) to control the brightness of the backlight.
--- drivers/platform/mips/Kconfig | 1 + drivers/platform/mips/yeeloong_laptop.c | 83 +++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 0 deletions(-)
drivers/platform/mips/Kconfig +1 -0
@@ -17,6 +17,7 @@ if MIPS_PLATFORM_DEVICES config LEMOTE_YEELOONG2F tristate "Lemote YeeLoong Laptop" depends on LEMOTE_MACH2F + select BACKLIGHT_CLASS_DEVICE help YeeLoong netbook is a mini laptop made by Lemote, which is basically compatible to FuLoong2F mini PC, but it has an extra Embedded
drivers/platform/mips/yeeloong_laptop.c +83 -0
100 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 4/9 Loongson: YeeLoong: add hardware monitoring driver
In reply to Wu ZhangjinChanges from v11 5/8:
o add a get_bat_info() macro to cleanup the battery related operation.
Changes from v10 5/8:
o ensure the whole fan related source code follow the hwmon interfaces.
Changes from v9 5/8:
o ensure the fan controlling interface is compatible with the one described in Documentation/hwmon/sysfs-interface
----------------
This patch adds hardware monitoring driver, it provides standard interface(/sys/class/hwmon/) for lm-sensors/sensors-applet to monitor the temperatures of CPU and battery, the PWM of fan, the current, voltage of battery.
Please refer to Documentation/hwmon/userspace-tools and Documentation/hwmon/sysfs-interface to get more information about the hwmon.
--- drivers/platform/mips/Kconfig | 1 + drivers/platform/mips/yeeloong_laptop.c | 253 ++++++++++++++++++++++++++++++- 2 files changed, 250 insertions(+), 4 deletions(-)
drivers/platform/mips/Kconfig +1 -0
@@ -18,6 +18,7 @@ config LEMOTE_YEELOONG2F tristate "Lemote YeeLoong Laptop" depends on LEMOTE_MACH2F select BACKLIGHT_CLASS_DEVICE + select HWMON help YeeLoong netbook is a mini laptop made by Lemote, which is basically compatible to FuLoong2F mini PC, but it has an extra Embedded
drivers/platform/mips/yeeloong_laptop.c +249 -4
282 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 5/9 Loongson: YeeLoong: add video output driver
In reply to Wu ZhangjinThis patch adds Video Output Driver, it provides standard interface(/sys/class/video_output) to turn on/off the video output of LCD, CRT.
--- drivers/platform/mips/Kconfig | 1 + drivers/platform/mips/yeeloong_laptop.c | 139 +++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 0 deletions(-)
drivers/platform/mips/Kconfig +1 -0
@@ -19,6 +19,7 @@ config LEMOTE_YEELOONG2F depends on LEMOTE_MACH2F select BACKLIGHT_CLASS_DEVICE select HWMON + select VIDEO_OUTPUT_CONTROL help YeeLoong netbook is a mini laptop made by Lemote, which is basically compatible to FuLoong2F mini PC, but it has an extra Embedded
drivers/platform/mips/yeeloong_laptop.c +139 -0
162 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 6/9 Loongson: YeeLoong: add suspend support
In reply to Wu ZhangjinThis patch add support to suspend the yeeloong platform specific devices(LCD, CRT, USB...).
--- drivers/platform/mips/yeeloong_laptop.c | 41 ++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 3 deletions(-)
drivers/platform/mips/yeeloong_laptop.c +38 -3
@@ -454,6 +454,38 @@ static void yeeloong_vo_exit(void) } } +#ifdef CONFIG_PM +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 device *dev) +{ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG ); +usb_ports_set (BIT_USB_FLAG_OFF ); + +return 0 ; +} + +static int yeeloong_resume (struct device *dev) +{ +usb_ports_set (BIT_USB_FLAG_ON ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); + +return 0 ; +} + +static const SIMPLE_DEV_PM_OPS(yeeloong_pm_ops, yeeloong_suspend, + yeeloong_resume); +#endif +static struct platform_device_id platform_device_ids[] = { { .name ="yeeloong_laptop" ,
@@ -465,9 +497,12 @@ MODULE_DEVICE_TABLE(platform, platform_device_ids);static struct platform_driver platform_driver = { .driver = { - .name ="yeeloong_laptop" , - .owner =THIS_MODULE , - }, + .name ="yeeloong_laptop" , + .owner =THIS_MODULE , +#ifdef CONFIG_PM + .pm = &yeeloong_pm_ops, +#endif + }, .id_table = platform_device_ids, };
Signature · 1 line
1.7.0.4
PATCH v12 7/9 Loongson: YeeLoong: add input/hotkey driver
In reply to Wu ZhangjinChanges from v10 8/8:
o Split the EC related code out into the next patch.
Changes from v9 8/8:
o Remove the wifi related actions
With the standard rfkill support(/sys/class/rfkill/) in the wifi driver, there is no need to handle the wifi related actions except reporting the KEY_WLAN event to user-space. the related applications will response this event and do corresponding actions(access the rfkill interfaces).
------------------
This patch adds Hotkey Driver, which will do related actions for The hotkey event(/sys/class/input) and report the corresponding input keys to the user-space applications.
(This patch is based on the sparse keymap library in:
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input next
of Dmitry Torokhov. that sparse keymap support is also queued for 2.6.33. Before the above branch is pulled by linus, this patch is not appliable.)
--- drivers/platform/mips/Kconfig | 2 + drivers/platform/mips/yeeloong_laptop.c | 385 +++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+), 0 deletions(-)
drivers/platform/mips/Kconfig +2 -0
@@ -20,6 +20,8 @@ config LEMOTE_YEELOONG2F select BACKLIGHT_CLASS_DEVICE select HWMON select VIDEO_OUTPUT_CONTROL + select INPUT_SPARSEKMAP + depends on INPUT help YeeLoong netbook is a mini laptop made by Lemote, which is basically compatible to FuLoong2F mini PC, but it has an extra Embedded
drivers/platform/mips/yeeloong_laptop.c +385 -0
408 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 8/9 Loongson: YeeLoong: add power_supply based battery driver
In reply to Wu ZhangjinChanges from old revision:
o Fixes the bugs
In the old driver, it didn't show the current charging status and reported the wrong full charge and voltage value.
Capacity = Charge_full_last (Dynamic) / Charge_full_design (Fixed) Percentage Charge = Charge_now (Dyn-Dynamic) / Charge_full_last (Dynamic)
Based on the old emulated APM battery driver and the power_supply class, this patch adds a new battery driver.
References:
1. Documentation/power/power_supply_class.txt
2. drivers/power/
--- drivers/platform/mips/Kconfig | 1 + drivers/platform/mips/yeeloong_laptop.c | 228 +++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+), 0 deletions(-)
drivers/platform/mips/Kconfig +1 -0
@@ -21,6 +21,7 @@ config LEMOTE_YEELOONG2F select HWMON select VIDEO_OUTPUT_CONTROL select INPUT_SPARSEKMAP + select POWER_SUPPLY depends on INPUT help YeeLoong netbook is a mini laptop made by Lemote, which is basically
drivers/platform/mips/yeeloong_laptop.c +228 -0
264 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v12 9/9 Loongson: YeeLoong: Co-operate with the revisions of EC
In reply to Wu ZhangjinThis patch makes the platform drivers work with the revisions of EC.
O When EC >= PQ1D26, EC will response the key of Fn+F2 and turn off the video output of LCD, we can no do it again in kernel.
O When EC >= PQ1D27, EC will response the LID key and turn off the video output of LCD, we can not do it again in kernel.
--- arch/mips/include/asm/mach-loongson/loongson.h | 6 ++++ arch/mips/loongson/common/cmdline.c | 8 ++++++ drivers/platform/mips/yeeloong_laptop.c | 32 +++++++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-)
arch/mips/include/asm/mach-loongson/loongson.h +6 -0
@@ -42,6 +42,12 @@ static inline void prom_init_uart_base(void)#endif } +/* +* Copy kernel command line from arcs_cmdline +*/ +#include <asm/setup.h> +extern char loongson_cmdline[COMMAND_LINE_SIZE ]; +/* irq operation functions */ extern void bonito_irqdispatch (void );extern void __init bonito_irq_init (void );
arch/mips/loongson/common/cmdline.c +8 -0
@@ -17,10 +17,15 @@* Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ +#include <linux/module.h> #include <asm/bootinfo.h> #include <loongson.h> +/* the kernel command line copied from arcs_cmdline */ +char loongson_cmdline[COMMAND_LINE_SIZE ]; +EXPORT_SYMBOL (loongson_cmdline); +void __init prom_init_cmdline (void ) {int prom_argc;
@@ -50,4 +55,7 @@ void __init prom_init_cmdline(void)strcat (arcs_cmdline," root=/dev/hda1" );prom_init_machtype (); + +/* copy arcs_cmdline into loongson_cmdline */ +strncpy (loongson_cmdline, arcs_cmdline,COMMAND_LINE_SIZE ); }
drivers/platform/mips/yeeloong_laptop.c +29 -3
@@ -23,8 +23,29 @@#include <cs5536/cs5536.h> +#include <loongson.h> /* for loongson_cmdline */ #include <ec_kb3310b.h> +/* common function */ +#define EC_VER_LEN 64 + +static int ec_version_before (char *version) +{ +char *p, ec_ver[EC_VER_LEN ]; + + p =strstr (loongson_cmdline,"EC_VER=" ); +if (!p) +memset (ec_ver,0 ,EC_VER_LEN ); +else { +strncpy (ec_ver, p,EC_VER_LEN ); + p =strstr (ec_ver," " ); +if (p) + *p ='\0' ; + } + +return (strncasecmp (ec_ver, version,64 ) <0 ); +} +/* backlight subdriver */ #define MAX_BRIGHTNESS 8
@@ -738,7 +759,10 @@ static int crt_detect_handler(int status)static int displaytoggle_handler (int status) { -yeeloong_lcd_vo_set (status); +/* EC(>=PQ1D26) does this job for us, we can not do it again, +* otherwise, the brightness will not resume to the normal level! */ +if (ec_version_before ("EC_VER=PQ1D26" )) +yeeloong_lcd_vo_set (status);return status; }
@@ -1063,7 +1087,8 @@ static void usb_ports_set(int status)static int yeeloong_suspend (struct device *dev) { -yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +if (ec_version_before ("EC_VER=PQ1D27" )) +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF );yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG );usb_ports_set (BIT_USB_FLAG_OFF );
@@ -1074,7 +1099,8 @@ static int yeeloong_resume(struct device *dev) {usb_ports_set (BIT_USB_FLAG_ON );yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); -yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); +if (ec_version_before ("EC_VER=PQ1D27" )) +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON );return 0 ; }
Signature · 1 line
1.7.0.4