Skip to contentSkip to conversation

leds-alix2: add support for button connected to J15

PATCH In review Daniel Mack 5 participants 15 messages Oct 16, 2009 – Oct 22, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds-alix2: add support for button connected to J15

Hi,

for a project I was working on, we used the J15 connector of the ALIX.2D board (which is connected to a GPIO of the CS5536 Geode companion chip) for an external button switch.

I thought it might be worth sharing this piece of code, so others can do the same.

There is, however, a small hardware modification is necessary as the pin is also shared as buzzer output. I noted that in the Kconfig entry.

The patch should go thru Richard's led-2.6.git as it depends on another one that has been queued there already.

Thanks,
Daniel

Quoted 1 line

From fd5915cf86c659eac67a8c0ea4379a78efbe2231 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 13 Oct 2009 12:42:52 +0800
Subject: [PATCH] leds-alix2: add support for button connected to J15

The ALIX2 boards have one GPIO pin which is reachable at connector J15. One possible application for this feature is to connect a button which closes the two pins.

This patch adds support to query these button and export its state via an input device.

Cc Dmitry Torokhov <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Constantin Baranov <[email protected]>
---
 drivers/leds/Kconfig      |   14 ++++++++++++
 drivers/leds/leds-alix2.c |   50 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 0 deletions(-)
drivers/leds/Kconfig +14 -0
index e4f599f..7e57bba 100644
@@ -77,6 +77,20 @@ config LEDS_ALIX2
 	  This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
 	  You have to set leds-alix2.force=1 for boards with Award BIOS.
 
+config LEDS_ALIX2_BUTTON
+	bool "Input device support for button on ALIX boards"
+	depends on LEDS_ALIX2 && INPUT
+	select INPUT_POLLDEV
+	help
+	  This option enables support for a button connected to J15 of ALIX
+	  boards.
+	  
+	  Note that for this feature to work, there is need for a minor
+	  modification to the hardware. R1 needs to be removed, and R4 needs
+	  to be places as 100KOhms pull-up.
+	  
+	  Only select that option if you modified your ALIX board like this.
+
 config LEDS_H1940
 	tristate "LED Support for iPAQ H1940 device"
 	depends on LEDS_CLASS && ARCH_H1940
drivers/leds/leds-alix2.c +50 -0

74 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#1 lore raw

Hi Daniel,

drivers/leds/leds-alix2.c static struct alix_led alix_leds[] = { · line 94

Quoted 8 lines · Daniel Mack
drivers/leds/leds-alix2.c +7 -0
+#ifdef CONFIG_LEDS_ALIX2_BUTTON
+static void alix_button_poll(struct input_polled_dev *ipdev)
+{
+	unsigned int val = !(inl(gpio_base + 0x30) & (1 << 1));
+
+	if (val == alix_button_last)
+		return;

You can probably let input core filter out duplicate events...

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	input_report_key(ipdev->input, BTN_MISC, val);

BTN_MISC is expected to be used by joysticks or poniting devices, I'd recomment KEY_PROG1 for a key.

Quoted 30 lines
drivers/leds/leds-alix2.c +23 -0
+	input_sync(ipdev->input);
+	alix_button_last = val;
+}
+#endif
+
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
@@ -89,6 +110,35 @@ static int __init alix_led_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto fail;
 	}
+
+#ifdef CONFIG_LEDS_ALIX2_BUTTON
+	/* enable button input */
+	outl(1 << 1, gpio_base + 0x20);
+
+	/* enable pullup on input pin */
+	outl(1 << 1, gpio_base + 0x18);
+
+	alix_button_last = 0;
+	ipdev = input_allocate_polled_device();
+	if (!ipdev)
+		goto fail;
+
+	ipdev->poll = alix_button_poll;
+	ipdev->poll_interval = POLL_INTERVAL_DEFAULT;
+	ipdev->input->name = "ALIX2 button";
+	ipdev->input->phys = "alix2/input0";
+	ipdev->input->id.bustype = BUS_HOST;

drivers/leds/leds-alix2.c static int __init alix_led_probe(struct platform_device *pdev) · line 140

Quoted 10 lines
drivers/leds/leds-alix2.c +10 -0
+
+	set_bit(EV_KEY, ipdev->input->evbit);
+        ipdev->input->keybit[BIT_WORD(BTN_MISC)] = BIT_MASK(BTN_MISC);
+
+	ret = input_register_polled_device(ipdev);
+	if (ret) {
+		input_free_polled_device(ipdev);
+		goto fail;
+	}
+#endif

Fells like you want to make it a function (and a stub if not configured)...

Signature · 1 line
Dmitry
#2 lore raw
Quoted 52 lines · Dmitry Torokhov

Review

Quoted 8 lines · Daniel Mack
(quoted diff) +7 -0
+#ifdef CONFIG_LEDS_ALIX2_BUTTON
+static void alix_button_poll(struct input_polled_dev *ipdev)
+{
+	unsigned int val = !(inl(gpio_base + 0x30) & (1 << 1));
+
+	if (val == alix_button_last)
+		return;

You can probably let input core filter out duplicate events...

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	input_report_key(ipdev->input, BTN_MISC, val);

BTN_MISC is expected to be used by joysticks or poniting devices, I'd recomment KEY_PROG1 for a key.

Quoted 35 lines
(quoted diff) +28 -0
+	input_sync(ipdev->input);
+	alix_button_last = val;
+}
+#endif
+
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
@@ -89,6 +110,35 @@ static int __init alix_led_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto fail;
 	}
+
+#ifdef CONFIG_LEDS_ALIX2_BUTTON
+	/* enable button input */
+	outl(1 << 1, gpio_base + 0x20);
+
+	/* enable pullup on input pin */
+	outl(1 << 1, gpio_base + 0x18);
+
+	alix_button_last = 0;
+	ipdev = input_allocate_polled_device();
+	if (!ipdev)
+		goto fail;
+
+	ipdev->poll = alix_button_poll;
+	ipdev->poll_interval = POLL_INTERVAL_DEFAULT;
+	ipdev->input->name = "ALIX2 button";
+	ipdev->input->phys = "alix2/input0";
+	ipdev->input->id.bustype = BUS_HOST;
+
+	set_bit(EV_KEY, ipdev->input->evbit);
+        ipdev->input->keybit[BIT_WORD(BTN_MISC)] = BIT_MASK(BTN_MISC);
+
+	ret = input_register_polled_device(ipdev);
Quoted 8 lines

Review static int __init alix_led_probe(struct platform_device *pdev) · line 140

Quoted 5 lines
(quoted diff) +5 -0
+	if (ret) {
+		input_free_polled_device(ipdev);
+		goto fail;
+	}
+#endif

Fells like you want to make it a function (and a stub if not configured)...

Agreed in all points - new version below.

Thanks,
Daniel

Quoted 1 line

From 3095491476facc28f4cc639e7e44227c38ec0f8f Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 13 Oct 2009 12:42:52 +0800
Subject: [PATCH] leds-alix2: add support for button connected to J15

The ALIX2 boards have one GPIO pin which is reachable at connector J15. One possible application for this feature is to connect a button which closes the two pins.

This patch adds support to query these button and export its state via an input device.

Cc Dmitry Torokhov <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Constantin Baranov <[email protected]>
---
 drivers/leds/Kconfig      |   14 ++++++++++
 drivers/leds/leds-alix2.c |   59 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)
drivers/leds/Kconfig +14 -0
index e4f599f..2faba0a 100644
@@ -77,6 +77,20 @@ config LEDS_ALIX2
 	  This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
 	  You have to set leds-alix2.force=1 for boards with Award BIOS.
 
+config LEDS_ALIX2_BUTTON
+	bool "Input device support for button on ALIX boards"
+	depends on LEDS_ALIX2 && INPUT
+	select INPUT_POLLDEV
+	help
+	  This option enables support for a button connected to J15 of ALIX
+	  boards.
+	  
+	  Note that for this feature to work, there is need for a minor
+	  modification to the hardware: R1 needs to be removed, and R4 needs
+	  to be placed as 100 KOhms pull-up.
+	  
+	  Only select that option if you modified your ALIX board like this.
+
 config LEDS_H1940
 	tristate "LED Support for iPAQ H1940 device"
 	depends on LEDS_CLASS && ARCH_H1940
drivers/leds/leds-alix2.c +59 -0

83 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#3 lore raw

Hi Daniel,

Quoted 20 lines · Daniel Mack
drivers/leds/leds-alix2.c +9 -0
+#else
+#define alix_button_register() (0)
+#endif
+
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
@@ -89,6 +139,11 @@ static int __init alix_led_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto fail;
 	}
+
+	ret = alix_button_register();
+	if (ret) 
+		goto fail;
+
 	return 0;
 
 fail:

drivers/leds/leds-alix2.c static int alix_led_remove(struct platform_device *pdev) · line 164

Quoted 7 lines
drivers/leds/leds-alix2.c +4 -0
@@ -103,6 +158,10 @@ static int alix_led_remove(struct platform_device *pdev)
 
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_unregister(&alix_leds[i].cdev);
+	
+	if (ipdev)
+		input_unregister_polled_device(ipdev);
+	

I think it will bomb on !CONFIG_LEDS_ALIX2_BUTTON... You need alix_button_register() and a dummy wrapper for it as well.

Signature · 1 line
Dmitry
#4 lore raw

Hi Dmitry,

Quoted 22 lines · Dmitry Torokhov
Quoted 21 lines · Daniel Mack
(quoted diff) +9 -0
+#else
+#define alix_button_register() (0)
+#endif
+
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
@@ -89,6 +139,11 @@ static int __init alix_led_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto fail;
 	}
+
+	ret = alix_button_register();
+	if (ret) 
+		goto fail;
+
 	return 0;
 
 fail:
@@ -103,6 +158,10 @@ static int alix_led_remove(struct platform_device *pdev)
 
Quoted 10 lines

Review static int alix_led_remove(struct platform_device *pdev) · line 164

Quoted 6 lines
(quoted diff) +4 -0
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_unregister(&alix_leds[i].cdev);
+	
+	if (ipdev)
+		input_unregister_polled_device(ipdev);
+	

I think it will bomb on !CONFIG_LEDS_ALIX2_BUTTON... You need alix_button_register() and a dummy wrapper for it as well.

There is one actually - lazyly implemented as #define in this case. But you're right, it does bomb, but due to an undefined reference to ipdev in alix_led_remove(). Below is a new patch the finally works fine for both configs.

Daniel

Quoted 1 line

From f3ed2eb2a123a2d2ff1fd587d1ff1076893ae148 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 13 Oct 2009 12:42:52 +0800
Subject: [PATCH] leds-alix2: add support for button connected to J15

The ALIX2 boards have one GPIO pin which is reachable at connector J15. One possible application for this feature is to connect a button which closes the two pins.

This patch adds support to query these button and export its state via an input device.

Cc Dmitry Torokhov <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Constantin Baranov <[email protected]>
---
 drivers/leds/Kconfig      |   14 ++++++++++
 drivers/leds/leds-alix2.c |   61 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
drivers/leds/Kconfig +14 -0
index e4f599f..2faba0a 100644
@@ -77,6 +77,20 @@ config LEDS_ALIX2
 	  This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
 	  You have to set leds-alix2.force=1 for boards with Award BIOS.
 
+config LEDS_ALIX2_BUTTON
+	bool "Input device support for button on ALIX boards"
+	depends on LEDS_ALIX2 && INPUT
+	select INPUT_POLLDEV
+	help
+	  This option enables support for a button connected to J15 of ALIX
+	  boards.
+	  
+	  Note that for this feature to work, there is need for a minor
+	  modification to the hardware: R1 needs to be removed, and R4 needs
+	  to be placed as 100 KOhms pull-up.
+	  
+	  Only select that option if you modified your ALIX board like this.
+
 config LEDS_H1940
 	tristate "LED Support for iPAQ H1940 device"
 	depends on LEDS_CLASS && ARCH_H1940
drivers/leds/leds-alix2.c +61 -0

85 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#5 lore raw

Hi Daniel,

drivers/leds/leds-alix2.c static struct alix_led alix_leds[] = { · line 126

Quoted 10 lines · Daniel Mack
drivers/leds/leds-alix2.c +10 -0
+
+	ret = input_register_polled_device(ipdev);
+	
+	if (ret) {
+		input_free_polled_device(ipdev);
+		ipdev = NULL;
+	}
+
+	return ret;
+}

Ah, don't be lazy ;)

static void alix_button_unregister(void)

{
	if (ipdev) {
		input_unregister_polled_device(ipdev);
		/* Yes, polled devices need to be freed */
		input_free_polled_device(ipdev);
		ipdev = NULL;
	}
}

drivers/leds/leds-alix2.c static struct alix_led alix_leds[] = { · line 128

Quoted 2 lines
drivers/leds/leds-alix2.c +2 -0
+#else
+#define alix_button_register() (0)

static inline int alix_button_register(void) { return 0; } static inline void alix_button_unregister(void) { }

So you get typechecking (if any).

Quoted 18 lines
drivers/leds/leds-alix2.c +7 -0
+#endif
+
 static int __init alix_led_probe(struct platform_device *pdev)
 {
 	int i;
@@ -89,6 +139,11 @@ static int __init alix_led_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto fail;
 	}
+
+	ret = alix_button_register();
+	if (ret) 
+		goto fail;
+
 	return 0;
 
 fail:

drivers/leds/leds-alix2.c static int alix_led_remove(struct platform_device *pdev) · line 165

Quoted 8 lines
drivers/leds/leds-alix2.c +5 -0
@@ -103,6 +158,12 @@ static int alix_led_remove(struct platform_device *pdev)
 
 	for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
 		led_classdev_unregister(&alix_leds[i].cdev);
+
+#ifdef CONFIG_LEDS_ALIX2_BUTTON
+	if (ipdev)
+		input_unregister_polled_device(ipdev);
+#endif
	alix_button_unregister();
Quoted 4 lines
drivers/leds/leds-alix2.c +1 -0
+
 	return 0;
 }
 
Signature · 1 line
Dmitry
#6 lore raw

Hi Dmitry,

Quoted 13 lines · Dmitry Torokhov

Review

Quoted 10 lines · Daniel Mack
(quoted diff) +10 -0
+
+	ret = input_register_polled_device(ipdev);
+	
+	if (ret) {
+		input_free_polled_device(ipdev);
+		ipdev = NULL;
+	}
+
+	return ret;
+}

Ah, don't be lazy ;)

Ok ok, you're right, let's do it the clean way. Agreed :)

See the one below.

Thanks!

Daniel

Quoted 1 line

From 66953e5dda7bbbc22b92541ed3a6020773c62140 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Tue, 13 Oct 2009 12:42:52 +0800
Subject: [PATCH] leds-alix2: add support for button connected to J15

The ALIX2 boards have one GPIO pin which is reachable at connector J15. One possible application for this feature is to connect a button which closes the two pins.

This patch adds support to query these button and export its state via an input device.

Cc Dmitry Torokhov <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Constantin Baranov <[email protected]>
---
 drivers/leds/Kconfig      |   14 +++++++++
 drivers/leds/leds-alix2.c |   71 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)
drivers/leds/Kconfig +14 -0
index e4f599f..2faba0a 100644
@@ -77,6 +77,20 @@ config LEDS_ALIX2
 	  This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
 	  You have to set leds-alix2.force=1 for boards with Award BIOS.
 
+config LEDS_ALIX2_BUTTON
+	bool "Input device support for button on ALIX boards"
+	depends on LEDS_ALIX2 && INPUT
+	select INPUT_POLLDEV
+	help
+	  This option enables support for a button connected to J15 of ALIX
+	  boards.
+	  
+	  Note that for this feature to work, there is need for a minor
+	  modification to the hardware: R1 needs to be removed, and R4 needs
+	  to be placed as 100 KOhms pull-up.
+	  
+	  Only select that option if you modified your ALIX board like this.
+
 config LEDS_H1940
 	tristate "LED Support for iPAQ H1940 device"
 	depends on LEDS_CLASS && ARCH_H1940
drivers/leds/leds-alix2.c +71 -0

95 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#7 lore raw

Hi, Daniel!

I wonder why do you integrate the input driver into the leds driver. They should be separated. Or at least the complex driver should be moved to the "X86 Platform Specific Device Drivers" and renamed to some like "PC Engines ALIX Extras". I personally would prefer the separation way.

Also ALIX.2 documentation describes the "Mode switch" driven by GPIO which is a small button on front side of a board. I guessed your driver is not for this button. If so, would it be better to provide the mode switch as KEY_PROG1 and the J15 connected button as KEY_PROG2 at once?

Cheers,
Constantin

Quoted 17 lines

From 66953e5dda7bbbc22b92541ed3a6020773c62140 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Tue, 13 Oct 2009 12:42:52 +0800
Subject: [PATCH] leds-alix2: add support for button connected to J15

The ALIX2 boards have one GPIO pin which is reachable at connector J15. One possible application for this feature is to connect a button which closes the two pins.

This patch adds support to query these button and export its state via an input device.

Cc Dmitry Torokhov <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Constantin Baranov <[email protected]>
#8 lore raw
Quoted 4 lines · Constantin Baranov

I wonder why do you integrate the input driver into the leds driver. They should be separated. Or at least the complex driver should be moved to the "X86 Platform Specific Device Drivers" and renamed to some like "PC Engines ALIX Extras". I personally would prefer the separation way.

I would as well, yes. And I was of course considerating this when I hacked these lines. However, the major part of the LED driver and what it currently shares with the button implementation is the BIOS detection code which is so ugly that I didn't want to duplicate it ;) That would, however, be the only option if you wanted to split the drivers up. Or do you have any better idea?

Quoted 4 lines

Also ALIX.2 documentation describes the "Mode switch" driven by GPIO which is a small button on front side of a board. I guessed your driver is not for this button. If so, would it be better to provide the mode switch as KEY_PROG1 and the J15 connected button as KEY_PROG2 at once?

Correct, the button this code is for is not the one on the 'front' side of the PCB. The other one I didn't try yet, but according the the CS5536A datasheet, the alternate function for that pin is WORK_AUX which can be used for power switching purposes. So that might need some extra care probably.

However, if you can make any suggestion of how to split the code without copying more than half of the lines for that, I'd be happy with that as well, of course :)

Daniel

#9 lore raw
Quoted 6 lines · On Wed, 21 Oct 2009 22:41:58 +0200 Daniel Mack <[email protected]> wrote:
Quoted 4 lines · Constantin Baranov

I wonder why do you integrate the input driver into the leds driver. They should be separated. Or at least the complex driver should be moved to the "X86 Platform Specific Device Drivers" and renamed to some like "PC Engines ALIX Extras". I personally would prefer the separation way.

Quoted 6 lines

I would as well, yes. And I was of course considerating this when I hacked these lines. However, the major part of the LED driver and what it currently shares with the button implementation is the BIOS detection code which is so ugly that I didn't want to duplicate it ;) That would, however, be the only option if you wanted to split the drivers up. Or do you have any better idea?

We may introduce new ALIX2 extended platform (module in arch/x86/kernel). In the init function it shall perform detection. The module shall export the is_alix2() function which shall be called from init functions of drivers. Also the cs5535_gpio driver could be reused for gpio access (the previous patch for leds-alix2 is copy&paste from cs5535_gpio).

Quoted 10 lines
Quoted 4 lines

Also ALIX.2 documentation describes the "Mode switch" driven by GPIO which is a small button on front side of a board. I guessed your driver is not for this button. If so, would it be better to provide the mode switch as KEY_PROG1 and the J15 connected button as KEY_PROG2 at once?

Correct, the button this code is for is not the one on the 'front' side of the PCB. The other one I didn't try yet, but according the the CS5536A datasheet, the alternate function for that pin is WORK_AUX which can be used for power switching purposes. So that might need some extra care probably.

Is there an ALIX board which uses that pin for something but button? The driver ensures that it works with ALIX, not any CS5536.

Constantin

#10 lore raw
Quoted 14 lines · On Thu, 22 Oct 2009 02:39:28 +0500 Constantin Baranov <[email protected]> wrote:
Quoted 6 lines · On Wed, 21 Oct 2009 22:41:58 +0200 Daniel Mack <[email protected]> wrote:
Quoted 4 lines · Constantin Baranov

I wonder why do you integrate the input driver into the leds driver. They should be separated. Or at least the complex driver should be moved to the "X86 Platform Specific Device Drivers" and renamed to some like "PC Engines ALIX Extras". I personally would prefer the separation way.

Quoted 6 lines

I would as well, yes. And I was of course considerating this when I hacked these lines. However, the major part of the LED driver and what it currently shares with the button implementation is the BIOS detection code which is so ugly that I didn't want to duplicate it ;) That would, however, be the only option if you wanted to split the drivers up. Or do you have any better idea?

Quoted 5 lines

We may introduce new ALIX2 extended platform (module in arch/x86/kernel). In the init function it shall perform detection. The module shall export the is_alix2() function which shall be called from init functions of drivers. Also the cs5535_gpio driver could be reused for gpio access (the previous patch for leds-alix2 is copy&paste from cs5535_gpio).

Moreover, the cs5535_gpio driver itself could be reworked and ported to the gpiolib. This goes far from initial task (button support) indeed :)

Constantin

#11 lore raw
Quoted 15 lines · Constantin Baranov
Quoted 14 lines · On Thu, 22 Oct 2009 02:39:28 +0500 Constantin Baranov <[email protected]> wrote:
Quoted 12 lines · On Wed, 21 Oct 2009 22:41:58 +0200 Daniel Mack <[email protected]> wrote:
Quoted 4 lines · Constantin Baranov

I wonder why do you integrate the input driver into the leds driver. They should be separated. Or at least the complex driver should be moved to the "X86 Platform Specific Device Drivers" and renamed to some like "PC Engines ALIX Extras". I personally would prefer the separation way.

I would as well, yes. And I was of course considerating this when I hacked these lines. However, the major part of the LED driver and what it currently shares with the button implementation is the BIOS detection code which is so ugly that I didn't want to duplicate it ;) That would, however, be the only option if you wanted to split the drivers up. Or do you have any better idea?

Quoted 8 lines
Quoted 5 lines

We may introduce new ALIX2 extended platform (module in arch/x86/kernel). In the init function it shall perform detection. The module shall export the is_alix2() function which shall be called from init functions of drivers. Also the cs5535_gpio driver could be reused for gpio access (the previous patch for leds-alix2 is copy&paste from cs5535_gpio).

Moreover, the cs5535_gpio driver itself could be reworked and ported to the gpiolib. This goes far from initial task (button support) indeed :)

Indeed, agreed to all points, that would be the sane way to do it. However, I won't have time to care for that soon. So the best thing to do for now is drop the patch and leave it in the mail archives. And wait untils eventually cares to do ir right :)

Daniel

#12 lore raw
In reply to Daniel Mack

Hi,

Quoted 4 lines · Daniel Mack

for a project I was working on, we used the J15 connector of the ALIX.2D board (which is connected to a GPIO of the CS5536 Geode companion chip) for an external button switch.

Quoted 8 lines

I thought it might be worth sharing this piece of code, so others can do the same.

There is, however, a small hardware modification is necessary as the pin is also shared as buzzer output. I noted that in the Kconfig entry.

The patch should go thru Richard's led-2.6.git as it depends on another one that has been queued there already.

How common is this modification? I'm just trying to get a feel for the number of users out there of this feature...

Cheers,

Richard

Signature · 2 lines
Richard Purdie
Intel Open Source Technology Centre
#13 lore raw
Quoted 8 lines · Richard Purdie
Quoted 7 lines · Daniel Mack

for a project I was working on, we used the J15 connector of the ALIX.2D board (which is connected to a GPIO of the CS5536 Geode companion chip) for an external button switch.

I thought it might be worth sharing this piece of code, so others can do the same.

Quoted 8 lines
Quoted 5 lines

There is, however, a small hardware modification is necessary as the pin is also shared as buzzer output. I noted that in the Kconfig entry.

The patch should go thru Richard's led-2.6.git as it depends on another one that has been queued there already.

How common is this modification? I'm just trying to get a feel for the number of users out there of this feature...

Hmm, hard to say. One can either use that IO as output to control a buzzer (which isn't placed on the board, but there are solder pads for it), as output for other purpose or as input.

Don't know what other people use it for, though, but we needed an external button in our case and use this IO pin for that purpose.

Anyway - I don't insist in that patch to be taken. The idea was more to share it so others won't have to hack the same thing.

I'll still submit a new version with Dmitry's suggestions addressed.

Thanks,
Daniel

#14 lore raw

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

for a project I was working on, we used the J15 connector of the ALIX.2D board (which is connected to a GPIO of the CS5536 Geode companion chip) for an external button switch.

...

Quoted 9 lines

Hmm, hard to say. One can either use that IO as output to control a buzzer (which isn't placed on the board, but there are solder pads for it), as output for other purpose or as input.

Don't know what other people use it for, though, but we needed an external button in our case and use this IO pin for that purpose.

Anyway - I don't insist in that patch to be taken. The idea was more to share it so others won't have to hack the same thing.

So its gpio pin... if you teach gpio framework about it, you should be able to just use gpio_button driver to handle it, no?

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