Loongson: YeeLoong: add platform specific drivers
v6 cover Loongson: YeeLoong: add platform specific drivers
From: Wu Zhangjin <[email protected]>
This patchset adds platform specific drivers for YeeLoong netbook. including the backlight, battery, hwmon, video output, suspend and hotkey(input) drivers. These drivers provide standard interfaces to the user-space applications to manage the relative devices:
Modules Tools
- backlight
/sys/class/backlight/ kpowersave, gnome-power-manager
- battery
/proc/apm kpowersave, gnome-power-manager
- hwmon
/sys/class/hwmon/ lm-sensors, sensors-applet...
- video output
/sys/class/video_output ?
- suspend
/sys/power/state kpowersave, gnome-power-manager
- hotkey
/sys/class/input/ gnome-settings-daemon ?
To utilize the above interfaces, you are recommended to install the latest hal, dbus.
This v6 revision incorporates with the feedbacks from Ralf, Pavel Machek, Rafael J. Wysocki and Dmitry Torokhov.
Changes from the old v5 revision:
- Cleanup the "select" and "depend" of the options Replace some "select"s by "depend"s to avoid potential compiling errors.
- Cleanup the hotkey(input) driver
Merge several functions, Cleanup the comments, Use Switch...Case instead of the array.
- Fixup of the video output driver
Seems the video output subsystem doesn't handle the input value, we handle it outselves via !!od->request_state.
- Append the yl_ prefix to the file names
yl_ prefix is needed to distinguish it with the next patchset for lynloong pc platform drivers.
All changes have been tested again.
Best Regards,
Wu Zhangjin
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 | 65 +++ .../loongson/lemote-2f/yeeloong_laptop/Makefile | 10 + .../lemote-2f/yeeloong_laptop/ec_kb3310b.c | 126 ++++++ .../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 193 +++++++++ .../lemote-2f/yeeloong_laptop/yl_backlight.c | 93 ++++ .../lemote-2f/yeeloong_laptop/yl_battery.c | 127 ++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c | 452 ++++++++++++++++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c | 239 +++++++++++ .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_vo.c | 164 +++++++ 17 files changed, 1635 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 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_backlight.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_battery.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c
PATCH v6 1/8 Loongson: Lemote-2F: add platform specific submenu
From: Wu Zhangjin <[email protected]>
--- arch/mips/loongson/Kconfig | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
arch/mips/loongson/Kconfig +20 -0
@@ -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
Signature · 1 line
1.6.2.1
Re: [PATCH v6 1/8] Loongson: Lemote-2F: add platform specific submenu
Quoted 18 lines · Wu Zhangin
arch/mips/loongson/Kconfig | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)arch/mips/loongson/Kconfig +7
-0@@ -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"
arch/mips/loongson/Kconfig config LOONGSON_UART_BASE · line 102
Quoted 10 lines
arch/mips/loongson/Kconfig +10
-0+ 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
Useless comment. LOONGSON_PLATFORM_DEVICES already says exactly that.
arch/mips/loongson/Kconfig config LOONGSON_UART_BASE · line 105
Quoted 3 lines
arch/mips/loongson/Kconfig +3
-0+ + +endif # LOONGSON_PLATFORM_DEVICES
Ralf
Re: [PATCH v6 1/8] Loongson: Lemote-2F: add platform specific submenu
Quoted 24 lines · Ralf Baechle
Quoted 22 lines · Wu Zhangin
arch/mips/loongson/Kconfig | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)arch/mips/loongson/Kconfig +11
-0@@ -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
Quoted 9 lines
arch/mips/loongson/Kconfig config LOONGSON_UART_BASE · line 102
Quoted 6 lines
arch/mips/loongson/Kconfig +6
-0+ 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 hereUseless comment.
LOONGSON_PLATFORM_DEVICESalready says exactly that.
Yep, Need to remove it ;)
Thanks!
Wu Zhangjin
PATCH v6 2/8 Loongson: YeeLoong: add platform specific option
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
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.
--- 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
arch/mips/loongson/Kconfig +1 -0
@@ -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
arch/mips/loongson/lemote-2f/Makefile +6 -1
@@ -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/
arch/mips/loongson/lemote-2f/ec_kb3310b.c deleted +0 -130
130 lines not on this page · raw message
arch/mips/loongson/lemote-2f/ec_kb3310b.h deleted +0 -188
188 lines not on this page · raw message
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 "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 ;
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 "yeeloong_laptop/ec_kb3310b.h" static void reset_cpu (void ) {
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig new file +15 -0
@@ -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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# YeeLoong Specific + +obj-y += ec_kb3310b.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.c new file +126 -0
126 lines not on this page · raw message
arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option
Quoted 5 lines · Wu Zhangin
This patch add a new
LEMOTE_YEELOONG2Foption, a yeeloong_laptop/ directory for the coming yeeloong specific support, and for theec_kb3310bbelongs to yeeloong, so, move it to yeeloong_laptop/ too.Signed-off-by Wu Zhangjin <[email protected]>
I suggest you fold this patch into patch 2/8.
Ralf
Re: [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option
Quoted 9 lines · Ralf Baechle
Quoted 5 lines · Wu Zhangin
This patch add a new
LEMOTE_YEELOONG2Foption, a yeeloong_laptop/ directory for the coming yeeloong specific support, and for theec_kb3310bbelongs to yeeloong, so, move it to yeeloong_laptop/ too.Signed-off-by Wu Zhangjin <[email protected]>I suggest you fold this patch into patch 2/8.
Sorry, do you mean merging the following two? for this patch itself is 2/8?
[PATCH v6 1/8] Loongson: Lemote-2F: add platform specific submenu [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option
Regards,
Wu Zhangjin
Re: [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option
Quoted 9 lines · Wu Zhangjin
Quoted 8 lines · Ralf Baechle
Quoted 5 lines · Wu Zhangin
This patch add a new
LEMOTE_YEELOONG2Foption, a yeeloong_laptop/ directory for the coming yeeloong specific support, and for theec_kb3310bbelongs to yeeloong, so, move it to yeeloong_laptop/ too.Signed-off-by Wu Zhangjin <[email protected]>
Quoted 7 lines
Quoted 1 line
I suggest you fold this patch into patch 2/8.
Sorry, do you mean merging the following two? for this patch itself is 2/8?
[PATCH v6 1/8] Loongson: Lemote-2F: add platform specific submenu [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option
Yes.
Ralf
PATCH v6 3/8 Loongson: YeeLoong: add backlight driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds YeeLoong Backlight Driver, which provides standard interface for user-space applications to control the brightness of the backlight.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 9 ++- .../loongson/lemote-2f/yeeloong_laptop/Makefile | 2 + .../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 1 + .../lemote-2f/yeeloong_laptop/yl_backlight.c | 93 ++++++++++++++++++++ 4 files changed, 104 insertions(+), 1 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_backlight.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8 -1
@@ -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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +2 -0
@@ -1,3 +1,5 @@ # YeeLoong Specific obj-y += ec_kb3310b.o + +obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h +1 -0
@@ -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.
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_backlight.c new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
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 <[email protected]>
You split old, big driver into several individual drivers - good.
Now we can actually move things to their rightf place and for a backlight drivers that should be drivers/video/backlight/. Convert it to a platform driver.
Ralf
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 8 lines · Ralf Baechle
Quoted 6 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds YeeLoong Backlight Driver, which provides standard interface for user-space applications to control the brightness of the backlight.
Quoted 7 lines
Quoted 1 line
Signed-off-by Wu Zhangjin <[email protected]>You split old, big driver into several individual drivers - good.
Now we can actually move things to their rightf place and for a backlight drivers that should be
drivers/video/backlight/. Convert it to a platform driver.
Okay, but for these drivers need the ec_kb3310b.h, so, we also need to move it from arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h to arch/mips/include/asm/mach-loongson/ec_kb3310b.h.
and seems some subsystem have no maintainer, such as the hwmon driver:
HARDWARE MONITORING
L: [email protected] W: http://www.lm-sensors.org/ S: Orphan F: drivers/hwmon/
So, who should I send this patch to?
Best Regards,
Wu Zhangjin
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 17 lines · Wu Zhangjin
Quoted 8 lines · Ralf Baechle
Quoted 6 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds YeeLoong Backlight Driver, which provides standard interface for user-space applications to control the brightness of the backlight.
Quoted 7 lines
Quoted 1 line
Signed-off-by Wu Zhangjin <[email protected]>You split old, big driver into several individual drivers - good.
Now we can actually move things to their rightf place and for a backlight drivers that should be
drivers/video/backlight/. Convert it to a platform driver.
Quoted 5 lines
Okay, but for these drivers need the
ec_kb3310b.h, so, we also need to move it fromarch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.htoarch/mips/include/asm/mach-loongson/ec_kb3310b.h.and seems some subsystem have no maintainer, such as the hwmon driver:
Which is true and sometimes a bit of a nuisance but one we can live with.
Quoted 7 lines
HARDWARE MONITORING
L: [email protected] W: http://www.lm-sensors.org/ S: Orphan F: drivers/hwmon/So, who should I send this patch to?
I suggest you add Andrew Morton <[email protected]> and linux-kernel to the To: list.
Ralf
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 19 lines · Ralf Baechle
Quoted 17 lines · Wu Zhangjin
Quoted 15 lines · Ralf Baechle
Quoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
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 <[email protected]>You split old, big driver into several individual drivers - good.
Now we can actually move things to their rightf place and for a backlight drivers that should be
drivers/video/backlight/. Convert it to a platform driver.
Quoted 8 lines
Quoted 5 lines
Okay, but for these drivers need the
ec_kb3310b.h, so, we also need to move it fromarch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.htoarch/mips/include/asm/mach-loongson/ec_kb3310b.h.and seems some subsystem have no maintainer, such as the hwmon driver:
Which is true and sometimes a bit of a nuisance but one we can live with.
This time, I like the folks did under drivers/platform/x86/ ;) which will be better to maintain. for all of these drivers are really only YeeLoong platform specific ;)
Quoted 11 lines
Quoted 7 lines
HARDWARE MONITORING
L: [email protected] W: http://www.lm-sensors.org/ S: Orphan F: drivers/hwmon/So, who should I send this patch to?
I suggest you add Andrew Morton <[email protected]> and linux-kernel to the To: list.
Okay, later, thanks!
Regards,
Wu Zhangjin
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 3 lines · Wu Zhangjin
This time, I like the folks did under
drivers/platform/x86/;) which will be better to maintain. for all of these drivers are really only YeeLoong platform specific ;)
Experience has shown that drivers for a particular subsystem are best combined in a single menu, in a single directory. Otherwise any changes to subsystem's internal APIs will become a major pain. Which in the end means arch/ is usually the place for drivers that don't fit into any established cathegory.
Ralf
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver
Quoted 5 lines · Wu Zhangjin
Quoted 1 line
any established cathegory.
Get it, thanks ;)
I will do it tomorrow, Good night!
I thought you never sleep :-)
Ralf
PATCH v6 4/8 Loongson: YeeLoong: add battery driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds APM_EMULATION based Battery Driver, which provides standard interface for user-space applications to manage the battery.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 9 ++ .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_battery.c | 127 ++++++++++++++++++++ 3 files changed, 137 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_battery.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +9 -0
@@ -1,6 +1,7 @@ menuconfig LEMOTE_YEELOONG2F bool "Lemote YeeLoong Laptop" depends on LEMOTE_MACH2F + select SYS_SUPPORTS_APM_EMULATION default y help YeeLoong netbook is a mini laptop made by Lemote, which is basically
@@ -19,4 +20,12 @@ config YEELOONG_BACKLIGHT interface for user-space applications to control the brightness of the backlight. +config YEELOONG_BATTERY + tristate "Battery Driver" + depends on 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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-y += ec_kb3310b.o obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o +obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_battery.c new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 4/8] Loongson: YeeLoong: add battery driver
Quoted 4 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds
APM_EMULATIONbased Battery Driver, which provides standard interface for user-space applications to manage the battery.
This one as well is a candidate to become a platform driver.
Ralf
PATCH v6 5/8 Loongson: YeeLoong: add hwmon driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds hwmon driver for managing the temperature of battery, cpu and controlling the fan.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 9 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c | 239 ++++++++++++++++++++ 3 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +9 -0
@@ -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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += ec_kb3310b.o obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o +obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c new file +239 -0
239 lines not on this page · raw message
Signature · 7 lines
1.6.2.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [PATCH v6 5/8] Loongson: YeeLoong: add hwmon driver
Quoted 4 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds hwmon driver for managing the temperature of battery, cpu and controlling the fan.
And this one should now go to drivers/hwmon and become a platform driver as well.
Ralf
PATCH v6 6/8 Loongson: YeeLoong: add video output driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds Video Output Driver, which provides standard interface to turn on/off the video output of LCD, CRT.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 3 + .../loongson/lemote-2f/yeeloong_laptop/yl_vo.c | 168 ++++++++++++++++++++ 4 files changed, 180 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8 -0
@@ -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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += ec_kb3310b.o obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o +obj-$(CONFIG_YEELOONG_VO) += yl_vo.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h +3 -0
@@ -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 yeeloong_lcd_vo_set (int status); +extern void yeeloong_crt_vo_set (int status); +#define SCI_IRQ_NUM 0x0A#define MAX_BRIGHTNESS 8
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c new file +168 -0
168 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 6/8] Loongson: YeeLoong: add video output driver
Quoted 4 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds Video Output Driver, which provides standard interface to turn on/off the video output of LCD, CRT.
This one also should become a platform driver.
Ralf
PATCH v6 7/8 Loongson: YeeLoong: add suspend driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8 -0
@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endif
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.6.2.1
PATCH v6 7/8 Loongson: YeeLoong: add suspend driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8 -0
@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endif
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
Quoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>
I'm still not sure how useful it is to build it as a module, but otherwise
Quoted 175 lines
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.carch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8
-0@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endifarch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1
-0@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.oarch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +135
-0@@ -0,0 +1,135 @@ +/* +* YeeLoong Platform Specific Suspend Driver +* +* Copyright (C) 2009 Lemote Inc. +* Author: 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 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 <[email protected]>" ); +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 */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +/* Turn off CRT */ +yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG ); +/* Poweroff three usb ports */ +usb_ports_set (BIT_USB_FLAG_OFF ); + +return 0 ; +} + +static int yeeloong_resume (struct platform_device *pdev) +{ +pr_info ("yeeloong specific resume\n" ); + +/* Resume the status of lcd & crt */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); + +/* Poweron three usb ports */ +usb_ports_set (BIT_USB_FLAG_ON ); + +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);
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>I'm still not sure how useful it is to build it as a module, but otherwise
I think I agree with that. Maybe even one step further and just build this code depending on CONFIG_PM or similar?
Ralf
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
In reply to Rafael J. WysockiQuoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>I'm still not sure how useful it is to build it as a module, but otherwise
I think I agree with that. Maybe even one step further and just build this code depending on CONFIG_PM or similar?
Ralf
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
In reply to Wu ZhanginQuoted 7 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>
I'm still not sure how useful it is to build it as a module, but otherwise
Quoted 175 lines
--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.carch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8
-0@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endifarch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1
-0@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.oarch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +135
-0@@ -0,0 +1,135 @@ +/* +* YeeLoong Platform Specific Suspend Driver +* +* Copyright (C) 2009 Lemote Inc. +* Author: 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 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 <[email protected]>" ); +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 */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +/* Turn off CRT */ +yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG ); +/* Poweroff three usb ports */ +usb_ports_set (BIT_USB_FLAG_OFF ); + +return 0 ; +} + +static int yeeloong_resume (struct platform_device *pdev) +{ +pr_info ("yeeloong specific resume\n" ); + +/* Resume the status of lcd & crt */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); + +/* Poweron three usb ports */ +usb_ports_set (BIT_USB_FLAG_ON ); + +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);
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
In reply to Wu ZhanginQuoted 133 lines · Wu Zhangin
From: Wu Zhangin <[email protected]>
Date: Tue, 1 Dec 2009 19:11:55 +0800
To: Ralf Baechle <[email protected]>
Cc: [email protected], [email protected],
Pavel Machek <[email protected]>, "Rafael J. Wysocki" <[email protected]>, [email protected],
Wu Zhangjin <[email protected]>
Subject: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driverFrom: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.carch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8
-0@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endifarch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1
-0@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.oarch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +78
-0@@ -0,0 +1,135 @@ +/* +* YeeLoong Platform Specific Suspend Driver +* +* Copyright (C) 2009 Lemote Inc. +* Author: 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 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 <[email protected]>" ); +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 */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +/* Turn off CRT */ +yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG ); +/* Poweroff three usb ports */ +usb_ports_set (BIT_USB_FLAG_OFF ); + +return 0 ; +} + +static int yeeloong_resume (struct platform_device *pdev) +{ +pr_info ("yeeloong specific resume\n" ); + +/* Resume the status of lcd & crt */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); + +/* Poweron three usb ports */ +usb_ports_set (BIT_USB_FLAG_ON ); + +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 =
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c line 88
Quoted 10 lines
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +10
-0+__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 ; + }
No need to signal an error here. A platform device should only be registered on a platform that actually has the device. If you handle all that registration business in a central platform.c file which always is compiled into the YeeLoong kernel, this check can go away and you at the same time assure the actual driver module can only be loaded into the right kernel.
Quoted 49 lines
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +47
-0+ +/* 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);Signature · 1 line
1.6.2.1
Ralf
Re: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver
In reply to Wu ZhanginQuoted 133 lines · Wu Zhangin
From: Wu Zhangin <[email protected]>
Date: Tue, 1 Dec 2009 19:11:55 +0800
To: Ralf Baechle <[email protected]>
Cc: [email protected], [email protected],
Pavel Machek <[email protected]>, "Rafael J. Wysocki" <[email protected]>, [email protected],
Wu Zhangjin <[email protected]>
Subject: [PATCH v6 7/8] Loongson: YeeLoong: add suspend driverFrom: Wu Zhangjin <[email protected]>
This patch adds Suspend Driver, which will suspend the YeeLoong Platform specific devices.
Acked-by Pavel Machek <[email protected]>Signed-off-by Wu Zhangjin <[email protected]>--- .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.carch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +8
-0@@ -45,4 +45,12 @@ 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_VO && LOONGSON_SUSPEND + default y + help + This option adds Suspend Driver, which will suspend the YeeLoong + Platform specific devices. + endifarch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1
-0@@ -6,3 +6,4 @@ obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o +obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.oarch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +78
-0@@ -0,0 +1,135 @@ +/* +* YeeLoong Platform Specific Suspend Driver +* +* Copyright (C) 2009 Lemote Inc. +* Author: 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 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 <[email protected]>" ); +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 */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_OFF ); +/* Turn off CRT */ +yeeloong_crt_vo_set (BIT_CRT_DETECT_UNPLUG ); +/* Poweroff three usb ports */ +usb_ports_set (BIT_USB_FLAG_OFF ); + +return 0 ; +} + +static int yeeloong_resume (struct platform_device *pdev) +{ +pr_info ("yeeloong specific resume\n" ); + +/* Resume the status of lcd & crt */ +yeeloong_lcd_vo_set (BIT_DISPLAY_LCD_ON ); +yeeloong_crt_vo_set (BIT_CRT_DETECT_PLUG ); + +/* Poweron three usb ports */ +usb_ports_set (BIT_USB_FLAG_ON ); + +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 =
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c line 88
Quoted 10 lines
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +10
-0+__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 ; + }
No need to signal an error here. A platform device should only be registered on a platform that actually has the device. If you handle all that registration business in a central platform.c file which always is compiled into the YeeLoong kernel, this check can go away and you at the same time assure the actual driver module can only be loaded into the right kernel.
Quoted 49 lines
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c new file +47
-0+ +/* 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);Signature · 1 line
1.6.2.1
Ralf
PATCH v6 8/8 Loongson: YeeLoong: add hotkey driver
In reply to Wu ZhanginFrom: Wu Zhangjin <[email protected]>
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.
--- arch/mips/kernel/setup.c | 1 + .../loongson/lemote-2f/yeeloong_laptop/Kconfig | 9 + .../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 + .../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 4 +- .../loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c | 448 ++++++++++++++++++++ 5 files changed, 462 insertions(+), 1 deletions(-) create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c
arch/mips/kernel/setup.c +1 -0
@@ -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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig +9 -0
@@ -53,4 +53,13 @@ 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 && INPUT + 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
arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o obj-$(CONFIG_YEELOONG_VO) += yl_vo.o obj-$(CONFIG_YEELOONG_SUSPEND) += yl_suspend.o +obj-$(CONFIG_YEELOONG_HOTKEY) += yl_hotkey.o
arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h +3 -1
@@ -185,7 +185,9 @@ enum {EVENT_AC_BAT ,/* AC & Battery relative issue */ EVENT_AUDIO_VOLUME ,/* Volume adjust */ EVENT_WLAN, /* Wlan on/off */ -EVENT_END }; +#define EVENT_START EVENT_LID +#define EVENT_END EVENT_WLAN +#endif /* !_EC_KB3310B_H */
arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c new file +448 -0
448 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [PATCH v6 8/8] Loongson: YeeLoong: add hotkey driver
Quoted 5 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
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.
This one also should become a platform driver. And is probably a candidate for drivers/input/keyboard.
Ralf
Re: [PATCH v6 8/8] Loongson: YeeLoong: add hotkey driver
Quoted 11 lines · Ralf Baechle
Quoted 5 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
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.
This one also should become a platform driver. And is probably a candidate for
drivers/input/keyboard.
Umm, it still mixes up bunch of stuff not directly related to input. I'd vote for drivers/platform/mips (since we have a few of kitchen-sink style drivers for x86-based laptops in drivers/platform/x86).
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH v6 8/8] Loongson: YeeLoong: add hotkey driver
Quoted 9 lines · Dmitry Torokhov
Quoted 8 lines · Ralf Baechle
Quoted 5 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
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.
Quoted 8 lines
Quoted 3 lines
This one also should become a platform driver. And is probably a candidate for
drivers/input/keyboard.Umm, it still mixes up bunch of stuff not directly related to input. I'd vote for
drivers/platform/mips(since we have a few of kitchen-sink style drivers for x86-based laptops indrivers/platform/x86).
Hello,
Do you mean we go back to drivers/platform/mips/yeeloong_laptop.c? (or split the input stuff into yeeloong_input.c)
For considering the next platform support of LynLoong PC and the future other MIPS netbooks/PC(e.g. gdium), perhaps drivers/platform/mips is really the good place to put them in. and benefit from it, we maybe easier to share the functions, variables. of course, the problem about the API modification will also be there:
"Experience has shown that drivers for a particular subsystem are best combined in a single menu, in a single directory. Otherwise any changes to subsystem's internal APIs will become a major pain. Which in the end means arch/ is usually the place for drivers that don't fit into any established cathegory." -- Ralf
Best Regards,
Wu Zhangjin
Sorry, I have sent this stuff 8 times, forgive me ;(
Quoted 92 lines · Wu Zhangin
From: Wu Zhangjin <[email protected]>
This patchset adds platform specific drivers for YeeLoong netbook. including the backlight, battery, hwmon, video output, suspend and hotkey(input) drivers. These drivers provide standard interfaces to the user-space applications to manage the relative devices:
Modules Tools
- backlight
/sys/class/backlight/kpowersave, gnome-power-manager
- battery
/proc/apmkpowersave, gnome-power-manager
- hwmon
/sys/class/hwmon/lm-sensors, sensors-applet...
- video output
/sys/class/video_output?
- suspend
/sys/power/statekpowersave, gnome-power-manager
- hotkey
/sys/class/input/gnome-settings-daemon ?To utilize the above interfaces, you are recommended to install the latest hal, dbus.
This v6 revision incorporates with the feedbacks from Ralf, Pavel Machek, Rafael J. Wysocki and Dmitry Torokhov.
Changes from the old v5 revision:
- Cleanup the "select" and "depend" of the options Replace some "select"s by "depend"s to avoid potential compiling errors.
- Cleanup the hotkey(input) driver
Merge several functions, Cleanup the comments, Use Switch...Case instead of the array.- Fixup of the video output driver
Seems the video output subsystem doesn't handle the input value, we handle it outselves via !!od->request_state.- Append the
yl_prefix to the file names
yl_prefix is needed to distinguish it with the next patchset for lynloong pc platform drivers.All changes have been tested again.
Best Regards,
Wu ZhangjinWu 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 driverarch/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 | 65 +++ .../loongson/lemote-2f/yeeloong_laptop/Makefile | 10 + .../lemote-2f/yeeloong_laptop/ec_kb3310b.c | 126 ++++++ .../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 193 +++++++++ .../lemote-2f/yeeloong_laptop/yl_backlight.c | 93 ++++ .../lemote-2f/yeeloong_laptop/yl_battery.c | 127 ++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c | 452 ++++++++++++++++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c | 239 +++++++++++ .../lemote-2f/yeeloong_laptop/yl_suspend.c | 135 ++++++ .../loongson/lemote-2f/yeeloong_laptop/yl_vo.c | 164 +++++++ 17 files changed, 1635 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 create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_backlight.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_battery.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hotkey.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_hwmon.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_suspend.c create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c