linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* ARM: gta02: Add Button, LED and Vibrator support
@ 2009-11-28  3:05 Lars-Peter Clausen
  2009-11-28  3:05 ` [PATCH] ARM: gta02: Add button support Lars-Peter Clausen
  0 siblings, 1 reply; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-28  3:05 UTC (permalink / raw)
  To: linux-arm-kernel


This patch series adds button, LED and vibrator support for the GTA02 Openmoko
Freerunner smartphone.

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

* [PATCH] ARM: gta02: Add button support
  2009-11-28  3:05 ARM: gta02: Add Button, LED and Vibrator support Lars-Peter Clausen
@ 2009-11-28  3:05 ` Lars-Peter Clausen
  2009-11-28  3:05   ` [PATCH] ARM: gta02: Add LED support Lars-Peter Clausen
  2009-11-29  8:31   ` [PATCH] ARM: gta02: Add button support Pavel Machek
  0 siblings, 2 replies; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-28  3:05 UTC (permalink / raw)
  To: linux-arm-kernel

The gta02 has two buttons which are connected to gpio pins and thus can get
supported by using the generic gpio-keys driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>
---
 arch/arm/mach-s3c2442/mach-gta02.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index 0fb385b..0f0c619 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -58,6 +58,8 @@
 #include <linux/mfd/pcf50633/gpio.h>
 #include <linux/mfd/pcf50633/pmic.h>
 
+#include <linux/gpio_keys.h>
+
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
@@ -550,6 +552,36 @@ static struct s3c2410_hcd_info gta02_usb_info = {
 	},
 };
 
+/* Buttons */
+static struct gpio_keys_button gta02_buttons[] = {
+	{
+		.gpio = GTA02_GPIO_AUX_KEY,
+		.code = KEY_PHONE,
+		.desc = "Aux",
+		.type = EV_KEY,
+		.debounce_interval = 100,
+	},
+	{
+		.gpio = GTA02_GPIO_HOLD_KEY,
+		.code = KEY_PAUSE,
+		.desc = "Hold",
+		.type = EV_KEY,
+		.debounce_interval = 100,
+	},
+};
+
+static struct gpio_keys_platform_data gta02_buttons_pdata = {
+	.buttons = gta02_buttons,
+	.nbuttons = ARRAY_SIZE(gta02_buttons),
+};
+
+static struct platform_device gta02_buttons_device = {
+	.name = "gpio-keys",
+	.id = -1,
+	.dev = {
+		.platform_data = &gta02_buttons_pdata,
+	},
+};
 
 static void __init gta02_map_io(void)
 {
@@ -571,6 +603,7 @@ static struct platform_device *gta02_devices[] __initdata = {
 	&s3c24xx_pwm_device,
 	&s3c_device_iis,
 	&s3c_device_i2c0,
+	&gta02_buttons_device,
 };
 
 /* These guys DO need to be children of PMU. */
-- 
1.5.6.5

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

* [PATCH] ARM: gta02: Add LED support
  2009-11-28  3:05 ` [PATCH] ARM: gta02: Add button support Lars-Peter Clausen
@ 2009-11-28  3:05   ` Lars-Peter Clausen
  2009-11-28  3:05     ` [PATCH] ARM: gta02: Add vibrator support Lars-Peter Clausen
  2009-11-29  8:31   ` [PATCH] ARM: gta02: Add button support Pavel Machek
  1 sibling, 1 reply; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-28  3:05 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds support for the LEDs found on the gta02 smartphone.
There are three leds in total. Two of the are going to be controlled by leds-pwm
driver. One by the leds-gpio driver.
In theory all LEDs could be driven by the pwm driver, but one the pwm timers is
needed for other purposes, so we stick to a simple gpio driven led here.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>
---
 arch/arm/mach-s3c2442/mach-gta02.c |   70 ++++++++++++++++++++++++++++++++---
 1 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index 0f0c619..6f08dca 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -60,6 +60,9 @@
 
 #include <linux/gpio_keys.h>
 
+#include <linux/leds.h>
+#include <linux/leds_pwm.h>
+
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
@@ -409,11 +412,6 @@ static struct platform_device gta02_nor_flash = {
 };
 
 
-struct platform_device s3c24xx_pwm_device = {
-	.name		= "s3c24xx_pwm",
-	.num_resources	= 0,
-};
-
 static struct i2c_board_info gta02_i2c_devs[] __initdata = {
 	{
 		I2C_BOARD_INFO("pcf50633", 0x73),
@@ -583,6 +581,61 @@ static struct platform_device gta02_buttons_device = {
 	},
 };
 
+/* LEDs */
+static struct gpio_led gta02_gpio_leds[] = {
+	{
+		.name = "gta02:red:aux",
+		.gpio = GTA02_GPIO_AUX_LED,
+	},
+};
+
+static struct gpio_led_platform_data gta02_gpio_leds_pdata = {
+	.leds = gta02_gpio_leds,
+	.num_leds = ARRAY_SIZE(gta02_gpio_leds),
+};
+
+static struct platform_device gta02_leds_device = {
+	.name	= "leds-gpio",
+	.id	= -1,
+	.dev = {
+		.platform_data = &gta02_gpio_leds_pdata,
+	},
+};
+
+static struct led_pwm gta02_pwm_leds[] = {
+	{
+		.name = "gta02:orange:power",
+		.max_brightness = 0xff,
+		.pwm_period_ns = 1000000,
+		.pwm_id = 0,
+	},
+	{
+		.name = "gta02:blue:power",
+		.max_brightness = 0xff,
+		.pwm_period_ns = 1000000,
+		.pwm_id = 1,
+	},
+};
+
+static struct led_pwm_platform_data gta02_pwm_leds_pdata = {
+	.num_leds = ARRAY_SIZE(gta02_pwm_leds),
+	.leds = gta02_pwm_leds,
+};
+
+static struct platform_device gta02_pwm_leds_device = {
+	.name	= "leds_pwm",
+	.id	= -1,
+	.dev = {
+		.platform_data = &gta02_pwm_leds_pdata,
+	}
+};
+
+static void gta02_enable_pwm_pins(void)
+{
+	s3c2410_gpio_cfgpin(GTA02_GPIO_PWR_LED1, S3C2410_GPB0_TOUT0);
+	s3c2410_gpio_cfgpin(GTA02_GPIO_PWR_LED2, S3C2410_GPB1_TOUT1);
+}
+
 static void __init gta02_map_io(void)
 {
 	s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
@@ -600,10 +653,13 @@ static struct platform_device *gta02_devices[] __initdata = {
 	&s3c_device_usbgadget,
 	&s3c_device_nand,
 	&gta02_nor_flash,
-	&s3c24xx_pwm_device,
+	&s3c_device_timer[0],
+	&s3c_device_timer[1],
 	&s3c_device_iis,
 	&s3c_device_i2c0,
 	&gta02_buttons_device,
+	&gta02_leds_device,
+	&gta02_pwm_leds_device,
 };
 
 /* These guys DO need to be children of PMU. */
@@ -662,6 +718,8 @@ static void __init gta02_machine_init(void)
 	i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
 
 	platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
+	gta02_enable_pwm_pins();
+
 	pm_power_off = gta02_poweroff;
 }
 
-- 
1.5.6.5

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

* [PATCH] ARM: gta02: Add vibrator support
  2009-11-28  3:05   ` [PATCH] ARM: gta02: Add LED support Lars-Peter Clausen
@ 2009-11-28  3:05     ` Lars-Peter Clausen
  2009-11-28  3:05       ` [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier Lars-Peter Clausen
  2009-11-29  8:37       ` [PATCH] ARM: gta02: Add vibrator support Pavel Machek
  0 siblings, 2 replies; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-28  3:05 UTC (permalink / raw)
  To: linux-arm-kernel

The vibrator found on the gta02 is controlled by the s3c pwm controller.
Instead of writing a special vibrator driver/class the vibrator is represented
as a led device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>
---
 arch/arm/mach-s3c2442/mach-gta02.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index 6f08dca..13b14ab 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -615,6 +615,12 @@ static struct led_pwm gta02_pwm_leds[] = {
 		.pwm_period_ns = 1000000,
 		.pwm_id = 1,
 	},
+	{
+		.name = "gta02::vibrator",
+		.max_brightness = 0x3f,
+		.pwm_period_ns = 60000000,
+		.pwm_id = 3,
+	}
 };
 
 static struct led_pwm_platform_data gta02_pwm_leds_pdata = {
@@ -634,6 +640,7 @@ static void gta02_enable_pwm_pins(void)
 {
 	s3c2410_gpio_cfgpin(GTA02_GPIO_PWR_LED1, S3C2410_GPB0_TOUT0);
 	s3c2410_gpio_cfgpin(GTA02_GPIO_PWR_LED2, S3C2410_GPB1_TOUT1);
+	s3c2410_gpio_cfgpin(GTA02_GPIO_VIBRATOR_ON, S3C2410_GPB3_TOUT3);
 }
 
 static void __init gta02_map_io(void)
@@ -655,6 +662,7 @@ static struct platform_device *gta02_devices[] __initdata = {
 	&gta02_nor_flash,
 	&s3c_device_timer[0],
 	&s3c_device_timer[1],
+	&s3c_device_timer[3],
 	&s3c_device_iis,
 	&s3c_device_i2c0,
 	&gta02_buttons_device,
-- 
1.5.6.5

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-28  3:05     ` [PATCH] ARM: gta02: Add vibrator support Lars-Peter Clausen
@ 2009-11-28  3:05       ` Lars-Peter Clausen
  2009-11-29  8:34         ` Pavel Machek
  2009-12-01 18:27         ` Ben Dooks
  2009-11-29  8:37       ` [PATCH] ARM: gta02: Add vibrator support Pavel Machek
  1 sibling, 2 replies; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-28  3:05 UTC (permalink / raw)
  To: linux-arm-kernel

On gta02 hardware revision 5 and earlier the basis resistors for transistors of
the leds are missing and reading their gpio pin status will always return 0.
So we have to shadow the led states in software. This is done by "hijacking"
the gpio accessor functions for bank B.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>
---
 arch/arm/mach-s3c2442/mach-gta02.c |   54 ++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index 13b14ab..9298db4 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -90,6 +90,7 @@
 #include <plat/pm.h>
 #include <plat/udc.h>
 #include <plat/gpio-cfg.h>
+#include <plat/gpio-core.h>
 #include <plat/iic.h>
 
 static struct pcf50633 *gta02_pcf;
@@ -706,11 +707,64 @@ static void gta02_poweroff(void)
 	pcf50633_reg_set_bit_mask(gta02_pcf, PCF50633_REG_OOCSHDWN, 1, 1);
 }
 
+/* On hardware rev 5 and earlier the leds are missing a resistor and reading
+ * from their gpio pins will always return 0, so we have to shadow the
+ * led states software */
+static unsigned long gpb_shadow;
+extern struct s3c_gpio_chip s3c24xx_gpios[];
+
+static void gta02_gpb_set(struct gpio_chip *chip,
+				unsigned offset, int value)
+{
+	void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
+	unsigned long flags;
+	unsigned long dat;
+
+	local_irq_save(flags);
+
+	dat = __raw_readl(base + 0x04) | gpb_shadow;
+	dat &= ~(1 << offset);
+	gpb_shadow &= ~(1 << offset);
+	if (value) {
+		dat |= 1 << offset;
+		switch (offset) {
+		case 0 ... 2:
+			gpb_shadow |= 1 << offset;
+			break;
+		default:
+			break;
+		}
+	}
+	__raw_writel(dat, base + 0x04);
+
+	local_irq_restore(flags);
+}
+
+static int gta02_gpb_get(struct gpio_chip *chip, unsigned offset)
+{
+	void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
+	unsigned long val;
+
+	val = __raw_readl(base + 0x04) | gpb_shadow;
+	val >>= offset;
+	val &= 1;
+
+	return val;
+}
+
+static void gta02_hijack_gpb(void)
+{
+	s3c24xx_gpios[1].chip.set = gta02_gpb_set;
+	s3c24xx_gpios[1].chip.get = gta02_gpb_get;
+}
+
 static void __init gta02_machine_init(void)
 {
 	/* Set the panic callback to make AUX LED blink at ~5Hz. */
 	panic_blink = gta02_panic_blink;
 
+	gta02_hijack_gpb();
+
 	s3c_pm_init();
 
 #ifdef CONFIG_CHARGER_PCF50633
-- 
1.5.6.5

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

* [PATCH] ARM: gta02: Add button support
  2009-11-28  3:05 ` [PATCH] ARM: gta02: Add button support Lars-Peter Clausen
  2009-11-28  3:05   ` [PATCH] ARM: gta02: Add LED support Lars-Peter Clausen
@ 2009-11-29  8:31   ` Pavel Machek
  1 sibling, 0 replies; 13+ messages in thread
From: Pavel Machek @ 2009-11-29  8:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat 2009-11-28 04:05:29, Lars-Peter Clausen wrote:
> The gta02 has two buttons which are connected to gpio pins and thus can get
> supported by using the generic gpio-keys driver.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>

ACK.

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

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-28  3:05       ` [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier Lars-Peter Clausen
@ 2009-11-29  8:34         ` Pavel Machek
  2009-11-29 10:56           ` Lars-Peter Clausen
  2009-12-01 18:27         ` Ben Dooks
  1 sibling, 1 reply; 13+ messages in thread
From: Pavel Machek @ 2009-11-29  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi!

> On gta02 hardware revision 5 and earlier the basis resistors for transistors of
> the leds are missing and reading their gpio pin status will always return 0.
> So we have to shadow the led states in software. This is done by "hijacking"
> the gpio accessor functions for bank B.

Should that be done in LED driver, instead?
									Pavel

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

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

* [PATCH] ARM: gta02: Add vibrator support
  2009-11-28  3:05     ` [PATCH] ARM: gta02: Add vibrator support Lars-Peter Clausen
  2009-11-28  3:05       ` [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier Lars-Peter Clausen
@ 2009-11-29  8:37       ` Pavel Machek
  1 sibling, 0 replies; 13+ messages in thread
From: Pavel Machek @ 2009-11-29  8:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hi!

> The vibrator found on the gta02 is controlled by the s3c pwm controller.
> Instead of writing a special vibrator driver/class the vibrator is represented
> as a led device.

Maybe vibrator device will be needed after all?

1) it is getting very common

2) timed-gpio model makes more sense for vibrators -- send 200msec
pulse

3) normal triggers make little sense. 'vibrate when battery charges'
is cool hack, but

4) can vibrator motor survive running 24/7 ?

5) it is really force feedback; we have input handling for that. Is it
unusable?
								Pavel

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

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-29  8:34         ` Pavel Machek
@ 2009-11-29 10:56           ` Lars-Peter Clausen
  2009-11-30 12:31             ` Pavel Machek
  0 siblings, 1 reply; 13+ messages in thread
From: Lars-Peter Clausen @ 2009-11-29 10:56 UTC (permalink / raw)
  To: linux-arm-kernel

Pavel Machek wrote:
> Hi!
>
>> On gta02 hardware revision 5 and earlier the basis resistors for
>> transistors of the leds are missing and reading their gpio pin
>> status will always return 0. So we have to shadow the led states
>> in software. This is done by "hijacking" the gpio accessor
>> functions for bank B.
>
> Should that be done in LED driver, instead? Pave
Hi

Nope, that won't work. Every time a gpio on gpb is changed the leds
will turn off. So we would have to ship a special version of each
driver using a gpio pin form gpb. We certainly don't want to do that.

- Lars

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-29 10:56           ` Lars-Peter Clausen
@ 2009-11-30 12:31             ` Pavel Machek
  2009-11-30 18:56               ` Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Pavel Machek @ 2009-11-30 12:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun 2009-11-29 11:56:51, Lars-Peter Clausen wrote:
> Pavel Machek wrote:
> > Hi!
> >
> >> On gta02 hardware revision 5 and earlier the basis resistors for
> >> transistors of the leds are missing and reading their gpio pin
> >> status will always return 0. So we have to shadow the led states
> >> in software. This is done by "hijacking" the gpio accessor
> >> functions for bank B.
> >
> > Should that be done in LED driver, instead? Pave
> Hi
> 
> Nope, that won't work. Every time a gpio on gpb is changed the leds
> will turn off. So we would have to ship a special version of each
> driver using a gpio pin form gpb. We certainly don't want to do that.

_Any_ GPIO pin change will turn off the LED? Wow, the hardware is
severely misdesigned then, ok. That means you do need to modify GPIO
:-(. You probably should state it clearly in the comments.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-30 12:31             ` Pavel Machek
@ 2009-11-30 18:56               ` Jamie Lokier
  2009-12-01 12:32                 ` Pavel Machek
  0 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2009-11-30 18:56 UTC (permalink / raw)
  To: linux-arm-kernel

Pavel Machek wrote:
> On Sun 2009-11-29 11:56:51, Lars-Peter Clausen wrote:
> > Pavel Machek wrote:
> > > Hi!
> > >
> > >> On gta02 hardware revision 5 and earlier the basis resistors for
> > >> transistors of the leds are missing and reading their gpio pin
> > >> status will always return 0. So we have to shadow the led states
> > >> in software. This is done by "hijacking" the gpio accessor
> > >> functions for bank B.
> > >
> > > Should that be done in LED driver, instead? Pave
> > Hi
> > 
> > Nope, that won't work. Every time a gpio on gpb is changed the leds
> > will turn off. So we would have to ship a special version of each
> > driver using a gpio pin form gpb. We certainly don't want to do that.
> 
> _Any_ GPIO pin change will turn off the LED? Wow, the hardware is
> severely misdesigned then, ok. That means you do need to modify GPIO
> :-(. You probably should state it clearly in the comments.

I don't think it's necessarily a hardware misdesign if you can't read
back the value of output-only GPIOs, even though it's inconvenient.
But from the sound of that comment, I'd worry about the current consumed :-)

-- Jamie

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-30 18:56               ` Jamie Lokier
@ 2009-12-01 12:32                 ` Pavel Machek
  0 siblings, 0 replies; 13+ messages in thread
From: Pavel Machek @ 2009-12-01 12:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon 2009-11-30 18:56:13, Jamie Lokier wrote:
> Pavel Machek wrote:
> > On Sun 2009-11-29 11:56:51, Lars-Peter Clausen wrote:
> > > Pavel Machek wrote:
> > > > Hi!
> > > >
> > > >> On gta02 hardware revision 5 and earlier the basis resistors for
> > > >> transistors of the leds are missing and reading their gpio pin
> > > >> status will always return 0. So we have to shadow the led states
> > > >> in software. This is done by "hijacking" the gpio accessor
> > > >> functions for bank B.
> > > >
> > > > Should that be done in LED driver, instead? Pave
> > > Hi
> > > 
> > > Nope, that won't work. Every time a gpio on gpb is changed the leds
> > > will turn off. So we would have to ship a special version of each
> > > driver using a gpio pin form gpb. We certainly don't want to do that.
> > 
> > _Any_ GPIO pin change will turn off the LED? Wow, the hardware is
> > severely misdesigned then, ok. That means you do need to modify GPIO
> > :-(. You probably should state it clearly in the comments.
> 
> I don't think it's necessarily a hardware misdesign if you can't read
> back the value of output-only GPIOs, even though it's inconvenient.
> But from the sound of that comment, I'd worry about the current consumed :-)

Well, in such case... does it make sense to have flag such as
"GPIO_SHADOW", not special hacks? Or.... maybe we should be using
"shadow" state, always, as it should be faster, anyway?
									Pavel

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

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

* [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier
  2009-11-28  3:05       ` [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier Lars-Peter Clausen
  2009-11-29  8:34         ` Pavel Machek
@ 2009-12-01 18:27         ` Ben Dooks
  1 sibling, 0 replies; 13+ messages in thread
From: Ben Dooks @ 2009-12-01 18:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Nov 28, 2009 at 04:05:32AM +0100, Lars-Peter Clausen wrote:
> On gta02 hardware revision 5 and earlier the basis resistors for transistors of
> the leds are missing and reading their gpio pin status will always return 0.
> So we have to shadow the led states in software. This is done by "hijacking"
> the gpio accessor functions for bank B.

I think it would be worth investigating the idea of having GPxDAT cached
in our gpio chip structure for all banks, as it might even speed up changing
the gpios as instead of read-modify-write an uncached memory area, we would
change the read-cached,modify,write-cached,write-uncached.

I'll try this and see if there is any measurable GPIO performance increase
from doing this.
 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Acked-By: Nelson Castillo <arhuaco@freaks-unidos.net>
> ---
>  arch/arm/mach-s3c2442/mach-gta02.c |   54 ++++++++++++++++++++++++++++++++++++
>  1 files changed, 54 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
> index 13b14ab..9298db4 100644
> --- a/arch/arm/mach-s3c2442/mach-gta02.c
> +++ b/arch/arm/mach-s3c2442/mach-gta02.c
> @@ -90,6 +90,7 @@
>  #include <plat/pm.h>
>  #include <plat/udc.h>
>  #include <plat/gpio-cfg.h>
> +#include <plat/gpio-core.h>
>  #include <plat/iic.h>
>  
>  static struct pcf50633 *gta02_pcf;
> @@ -706,11 +707,64 @@ static void gta02_poweroff(void)
>  	pcf50633_reg_set_bit_mask(gta02_pcf, PCF50633_REG_OOCSHDWN, 1, 1);
>  }
>  
> +/* On hardware rev 5 and earlier the leds are missing a resistor and reading
> + * from their gpio pins will always return 0, so we have to shadow the
> + * led states software */
> +static unsigned long gpb_shadow;
> +extern struct s3c_gpio_chip s3c24xx_gpios[];
> +
> +static void gta02_gpb_set(struct gpio_chip *chip,
> +				unsigned offset, int value)
> +{
> +	void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
> +	unsigned long flags;
> +	unsigned long dat;
> +
> +	local_irq_save(flags);
> +
> +	dat = __raw_readl(base + 0x04) | gpb_shadow;
> +	dat &= ~(1 << offset);
> +	gpb_shadow &= ~(1 << offset);
> +	if (value) {
> +		dat |= 1 << offset;
> +		switch (offset) {
> +		case 0 ... 2:
> +			gpb_shadow |= 1 << offset;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +	__raw_writel(dat, base + 0x04);
> +
> +	local_irq_restore(flags);
> +}
> +
> +static int gta02_gpb_get(struct gpio_chip *chip, unsigned offset)
> +{
> +	void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
> +	unsigned long val;
> +
> +	val = __raw_readl(base + 0x04) | gpb_shadow;
> +	val >>= offset;
> +	val &= 1;
> +
> +	return val;
> +}
> +
> +static void gta02_hijack_gpb(void)
> +{
> +	s3c24xx_gpios[1].chip.set = gta02_gpb_set;
> +	s3c24xx_gpios[1].chip.get = gta02_gpb_get;
> +}
> +
>  static void __init gta02_machine_init(void)
>  {
>  	/* Set the panic callback to make AUX LED blink at ~5Hz. */
>  	panic_blink = gta02_panic_blink;
>  
> +	gta02_hijack_gpb();
> +
>  	s3c_pm_init();
>  
>  #ifdef CONFIG_CHARGER_PCF50633
> -- 
> 1.5.6.5
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

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

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

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-28  3:05 ARM: gta02: Add Button, LED and Vibrator support Lars-Peter Clausen
2009-11-28  3:05 ` [PATCH] ARM: gta02: Add button support Lars-Peter Clausen
2009-11-28  3:05   ` [PATCH] ARM: gta02: Add LED support Lars-Peter Clausen
2009-11-28  3:05     ` [PATCH] ARM: gta02: Add vibrator support Lars-Peter Clausen
2009-11-28  3:05       ` [PATCH] ARM: gta02: Add gpio bank B quirk for hardware revision 5 and earlier Lars-Peter Clausen
2009-11-29  8:34         ` Pavel Machek
2009-11-29 10:56           ` Lars-Peter Clausen
2009-11-30 12:31             ` Pavel Machek
2009-11-30 18:56               ` Jamie Lokier
2009-12-01 12:32                 ` Pavel Machek
2009-12-01 18:27         ` Ben Dooks
2009-11-29  8:37       ` [PATCH] ARM: gta02: Add vibrator support Pavel Machek
2009-11-29  8:31   ` [PATCH] ARM: gta02: Add button support Pavel Machek

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).