linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to make KEY_POWER work in terminal system
@ 2009-10-03 15:13 xiangfu liu
  2009-10-03 16:42 ` xiangfu liu
  0 siblings, 1 reply; 7+ messages in thread
From: xiangfu liu @ 2009-10-03 15:13 UTC (permalink / raw)
  To: linux-input; +Cc: xiangfu

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

sorry forget the subject. send again

On 10/3/09, xiangfu liu <xiangfu.z@gmail.com> wrote:
> Hi
>
> I try to write gpio-keys driver a POWER button. attach is the patch.
> but when I press or hold the button. the system not poweroff. do nothing.
>
> I have change the KEY_POWER to KEY_A. then I press the button again.
> the terminal ouptu 'a' , it works. but why KEY_POWER?
>
> give me some tips
>
> thanks for help
>
> Best Regards
> Xiangfu
>

[-- Attachment #2: power-button.patch --]
[-- Type: text/x-diff, Size: 2272 bytes --]

diff --git a/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h b/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
index 2c3260f..aa461bd 100644
--- a/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
+++ b/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
@@ -35,6 +35,7 @@
 #define GPIO_LCD_CS             JZ_GPIO_PORTC(21)
 #define GPIO_DISP_OFF_N         JZ_GPIO_PORTD(21)
 #define GPIO_PWM                JZ_GPIO_PORTD(27)
+#define GPIO_WAKEUP_N           JZ_GPIO_PORTD(29)
 
 #define GPIO_AMP_EN             JZ_GPIO_PORTD(4)
 
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 127fad8..c6ef60c 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -97,6 +97,7 @@ static void __init board_gpio_setup(void)
 
 	__gpio_as_input(GPIO_DC_DETE_N);
 	__gpio_as_input(GPIO_CHARG_STAT_N);
+	__gpio_as_input(GPIO_WAKEUP_N);
 }
 
 void __init jz_board_setup(void)
diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index dc7a832..16a0008 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -21,6 +21,8 @@
 #include <linux/spi/spi_gpio.h>
 #include <linux/power_supply.h>
 #include <linux/jz4740_batt.h>
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
 
 #include <asm/jzsoc.h>
 #include <asm/gpio.h>
@@ -492,6 +494,30 @@ static struct platform_device batt_gpio_device = {
 	},
 };
 
+/* GPIO Key: power */
+static const struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
+	[0] = {
+		.code		= KEY_POWER,
+		.gpio		= GPIO_WAKEUP_N,
+		.active_low	= 1,
+		.desc		= "power button",
+	},
+};
+
+static const struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
+	.nbuttons =	ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
+	.buttons =	qi_lb60_gpio_keys_buttons,
+};
+
+static struct platform_device qi_lb60_gpio_keys = {
+	.name =	"gpio-keys",
+	.id =		-1,
+	.dev = {
+		.platform_data = (void *) &qi_lb60_gpio_keys_data,
+	}
+};
+
+
 /* All */
 static struct platform_device *jz_platform_devices[] __initdata = {
 	&jz_usb_ohci_device,
@@ -506,6 +532,7 @@ static struct platform_device *jz_platform_devices[] __initdata = {
 	&jz_codec_device,
 	&jz_rtc_device,
 	&batt_gpio_device,
+	&qi_lb60_gpio_keys,
 };
 
 static int __init jz_platform_init(void)

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

* Re: how to make KEY_POWER work in terminal system
  2009-10-03 15:13 how to make KEY_POWER work in terminal system xiangfu liu
@ 2009-10-03 16:42 ` xiangfu liu
  2009-10-06  5:06   ` Dmitry Torokhov
  0 siblings, 1 reply; 7+ messages in thread
From: xiangfu liu @ 2009-10-03 16:42 UTC (permalink / raw)
  To: linux-input

kernel message:
[    1.240000] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    1.250000] input: matrix-keypad as /devices/platform/matrix-keypad/input/in1

no /dev/event/inputX device
but there is
/sys/devices/platform/gpio-keys/input/input0
the uevent is :
PRODUCT=19/1/1/100
NAME="gpio-keys"
PHYS="gpio-keys/input0"
EV==3
KEY==100000 0 0 0
MODALIAS=input:b0019v0001p0001e0100-e0,1,k74,ramlsfw

from /proc/interrupts
181:         87     GPIO Bank D  Power

when I press the button nothing happen. device not poweroff.

we have a metrix-keypad in out device. all keys work find.
so I try to map the "F1" to KEY_POWER. then I press the "F1" device not pwoeroff

On 10/3/09, xiangfu liu <xiangfu.z@gmail.com> wrote:
> sorry forget the subject. send again
>
> On 10/3/09, xiangfu liu <xiangfu.z@gmail.com> wrote:
>> Hi
>>
>> I try to write gpio-keys driver a POWER button. attach is the patch.
>> but when I press or hold the button. the system not poweroff. do nothing.
>>
>> I have change the KEY_POWER to KEY_A. then I press the button again.
>> the terminal ouptu 'a' , it works. but why KEY_POWER?
>>
>> give me some tips
>>
>> thanks for help
>>
>> Best Regards
>> Xiangfu
>>
>


-- 
Blog: http://www.openmobilefree.net

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

* Re: how to make KEY_POWER work in terminal system
  2009-10-03 16:42 ` xiangfu liu
@ 2009-10-06  5:06   ` Dmitry Torokhov
       [not found]     ` <bc65a8d50910062032u1ab5d215xb37737b197bb7d46@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Torokhov @ 2009-10-06  5:06 UTC (permalink / raw)
  To: xiangfu liu; +Cc: linux-input

Hi Xiangfu,

On Sun, Oct 04, 2009 at 12:42:07AM +0800, xiangfu liu wrote:
> kernel message:
> [    1.240000] input: gpio-keys as /devices/platform/gpio-keys/input/input0
> [    1.250000] input: matrix-keypad as /devices/platform/matrix-keypad/input/in1
> 
> no /dev/event/inputX device
> but there is
> /sys/devices/platform/gpio-keys/input/input0
> the uevent is :
> PRODUCT=19/1/1/100
> NAME="gpio-keys"
> PHYS="gpio-keys/input0"
> EV==3
> KEY==100000 0 0 0
> MODALIAS=input:b0019v0001p0001e0100-e0,1,k74,ramlsfw
> 
> from /proc/interrupts
> 181:         87     GPIO Bank D  Power
> 
> when I press the button nothing happen. device not poweroff.
> 
> we have a metrix-keypad in out device. all keys work find.
> so I try to map the "F1" to KEY_POWER. then I press the "F1" device not pwoeroff
> 

Powering off in response to KEY_POWER is a policy decision and thus
belongs to userspace. Someone (a program, a userspace daemon) has to
listen to events coming from the input devices and shut down the system
when it sees EV_KEY/KEY_POWER event.

I think you also want KEY_SLEEP, not KEY_POWER for your device...

-- 
Dmitry

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

* Re: 回复: Re: how to make KEY_POWER work in terminal system
       [not found]       ` <bc65a8d50910062033j5c2f86c4s2a17cb21cf16a7f7@mail.gmail.com>
@ 2009-10-07  4:35         ` Dmitry Torokhov
  2009-10-08  3:46           ` xiangfu liu
  2009-10-13 13:08           ` ??: " Xiangfu Liu
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2009-10-07  4:35 UTC (permalink / raw)
  To: xiangfu liu; +Cc: linux-input

On Wed, Oct 07, 2009 at 11:33:47AM +0800, xiangfu liu wrote:
> thanks for reply
> so i must write userspace daemon. right?
> 

Yes.

-- 
Dmitry

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

* Re: 回复: Re: how to make KEY_POWER work in terminal system
  2009-10-07  4:35         ` 回复: " Dmitry Torokhov
@ 2009-10-08  3:46           ` xiangfu liu
  2009-10-13 13:08           ` ??: " Xiangfu Liu
  1 sibling, 0 replies; 7+ messages in thread
From: xiangfu liu @ 2009-10-08  3:46 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

thanks Dmitry
 I will try to write deamon.

On 10/7/09, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Wed, Oct 07, 2009 at 11:33:47AM +0800, xiangfu liu wrote:
>> thanks for reply
>> so i must write userspace daemon. right?
>>
>
> Yes.
>
> --
> Dmitry
>


-- 
Blog: http://www.openmobilefree.net

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

* Re: ??: Re: how to make KEY_POWER work in terminal system
  2009-10-07  4:35         ` 回复: " Dmitry Torokhov
  2009-10-08  3:46           ` xiangfu liu
@ 2009-10-13 13:08           ` Xiangfu Liu
  2009-10-14  6:12             ` Dmitry Torokhov
  1 sibling, 1 reply; 7+ messages in thread
From: Xiangfu Liu @ 2009-10-13 13:08 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Dmitry Torokhov wrote:
> On Wed, Oct 07, 2009 at 11:33:47AM +0800, xiangfu liu wrote:
>> thanks for reply
>> so i must write userspace daemon. right?
>>
> 
> Yes.
> 
Hi Dmitry.
can you give me some tips on write the daemon.
have no idea on it. 

thanks for help

-- 
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com

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

* Re: ??: Re: how to make KEY_POWER work in terminal system
  2009-10-13 13:08           ` ??: " Xiangfu Liu
@ 2009-10-14  6:12             ` Dmitry Torokhov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2009-10-14  6:12 UTC (permalink / raw)
  To: Xiangfu Liu; +Cc: linux-input

On Tue, Oct 13, 2009 at 09:08:18PM +0800, Xiangfu Liu wrote:
> Dmitry Torokhov wrote:
> > On Wed, Oct 07, 2009 at 11:33:47AM +0800, xiangfu liu wrote:
> >> thanks for reply
> >> so i must write userspace daemon. right?
> >>
> > 
> > Yes.
> > 
> Hi Dmitry.
> can you give me some tips on write the daemon.
> have no idea on it. 
> 

Xiangfu,

I don't think you want to write a demon from scratch really. I don't
know your platform/framework but I would expect you are using some
kind of HAL daemon/layer that handles power mamagement and other system
functions. That framework should handle powering off as well.

But this is somewhat off-topic for the linux-input mailing list which
deals with the _kernel_ issues.

-- 
Dmitry

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

end of thread, other threads:[~2009-10-14  6:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-03 15:13 how to make KEY_POWER work in terminal system xiangfu liu
2009-10-03 16:42 ` xiangfu liu
2009-10-06  5:06   ` Dmitry Torokhov
     [not found]     ` <bc65a8d50910062032u1ab5d215xb37737b197bb7d46@mail.gmail.com>
     [not found]       ` <bc65a8d50910062033j5c2f86c4s2a17cb21cf16a7f7@mail.gmail.com>
2009-10-07  4:35         ` 回复: " Dmitry Torokhov
2009-10-08  3:46           ` xiangfu liu
2009-10-13 13:08           ` ??: " Xiangfu Liu
2009-10-14  6:12             ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).