public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* basic_mmio_gpio: Add hook for simple debounce register
@ 2011-11-16 19:02 H Hartley Sweeten
  2011-11-16 21:40 ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: H Hartley Sweeten @ 2011-11-16 19:02 UTC (permalink / raw)
  To: Linux Kernel; +Cc: grant.likely, jamie, cbouatmailru, akpm, rmk+kernel

Some platforms using the basic memory-mapped GPIO library have
simple input debounce support that is enabled/disabled, per-input,
by setting/clearing bits in a control register. Add a hook in the
bgpio_chip structure to hold the void __iomem * for this register.

This register, and the gc.set_debounce callback should set by the
platform after calling bgpio_init() and before calling gpiochip_add().

	...
	err = bgpio_chip(bgc, ...);
	if (err)
		return err;

	bgc->reg_db = platform_debounce_reg;
	bgc->gc.set_debounce = platform_set_debounce_func;

	return gpiochip_add(&bgc->gc);
}

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jamie Iles <jamie@jamieiles.com>
Cc: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
CC: Russell King <rmk+kernel@arm.linux.org.uk>

---

diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h
index feb91219..9bec937 100644
--- a/include/linux/basic_mmio_gpio.h
+++ b/include/linux/basic_mmio_gpio.h
@@ -35,6 +35,7 @@ struct bgpio_chip {
 	void __iomem *reg_set;
 	void __iomem *reg_clr;
 	void __iomem *reg_dir;
+	void __iomem *reg_db;
 
 	/* Number of bits (GPIOs): <register width> * 8. */
 	int bits;

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

* Re: basic_mmio_gpio: Add hook for simple debounce register
  2011-11-16 19:02 basic_mmio_gpio: Add hook for simple debounce register H Hartley Sweeten
@ 2011-11-16 21:40 ` Anton Vorontsov
  2011-11-16 22:41   ` H Hartley Sweeten
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Vorontsov @ 2011-11-16 21:40 UTC (permalink / raw)
  To: H Hartley Sweeten; +Cc: Linux Kernel, grant.likely, jamie, akpm, rmk+kernel

Hello,

On Wed, Nov 16, 2011 at 12:02:15PM -0700, H Hartley Sweeten wrote:
> Some platforms using the basic memory-mapped GPIO library have
> simple input debounce support that is enabled/disabled, per-input,
> by setting/clearing bits in a control register. Add a hook in the
> bgpio_chip structure to hold the void __iomem * for this register.
> 
> This register, and the gc.set_debounce callback should set by the
> platform after calling bgpio_init() and before calling gpiochip_add().

I think it is possible to add 'reg_db' into the device-specific
(private) structure, so no need to add it into the generic one
(the fact that the generic gpio code does not use it at all, is a
sign that you should place it into a private struct).

I.e. something like this:

struct foo_chip {
	struct bgpio_chip bgc;
	void __iomem *reg_db;
};

static struct foo_chip *to_foo_chip(struct bgpio_chip *bgc)
{
	return container_of(bgc, struct foo_chip, bgc);
}

static void foo_gpio_set_debounce(struct gpio_chip *gc, ...)
{
	struct bgpio_chip *bgc = to_bgpio_chip(gc);
	struct foo_chip *fgc = to_foo_chip(bgc);

	writel(..., fgc->reg_db);
}


Or, if the generic code will use that register, then please introduce
the code at the same time you introduce reg_db.

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* RE: basic_mmio_gpio: Add hook for simple debounce register
  2011-11-16 21:40 ` Anton Vorontsov
@ 2011-11-16 22:41   ` H Hartley Sweeten
  0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2011-11-16 22:41 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Linux Kernel, grant.likely@secretlab.ca, jamie@jamieiles.com,
	akpm@linux-foundation.org, rmk+kernel@arm.linux.org.uk

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1924 bytes --]

On Wednesday, November 16, 2011 2:40 PM, Anton Vorontsov wrote:
> 
> Hello,
> 
> On Wed, Nov 16, 2011 at 12:02:15PM -0700, H Hartley Sweeten wrote:
>> Some platforms using the basic memory-mapped GPIO library have
>> simple input debounce support that is enabled/disabled, per-input,
>> by setting/clearing bits in a control register. Add a hook in the
>> bgpio_chip structure to hold the void __iomem * for this register.
>> 
>> This register, and the gc.set_debounce callback should set by the
>> platform after calling bgpio_init() and before calling gpiochip_add().
>
> I think it is possible to add 'reg_db' into the device-specific
> (private) structure, so no need to add it into the generic one
> (the fact that the generic gpio code does not use it at all, is a
> sign that you should place it into a private struct).

Good point.

I'm working on converting the gpio-ep93xx driver's interrupt support
over to genirq.  The debounce register was the only thing hanging this
up.

> I.e. something like this:
> 
> struct foo_chip {
> 	struct bgpio_chip bgc;
> 	void __iomem *reg_db;
> };
> 
> static struct foo_chip *to_foo_chip(struct bgpio_chip *bgc)
> {
> 	return container_of(bgc, struct foo_chip, bgc);
> }
> 
> static void foo_gpio_set_debounce(struct gpio_chip *gc, ...)
> {
> 	struct bgpio_chip *bgc = to_bgpio_chip(gc);
> 	struct foo_chip *fgc = to_foo_chip(bgc);
> 
> 	writel(..., fgc->reg_db);
> }
> 
> 
> Or, if the generic code will use that register, then please introduce
> the code at the same time you introduce reg_db.

Currently the reg_db usage is outside the generic code.

I'll modify the gpio-ep93xx driver using something like you have shown
above.  If it looks reasonable to add to gpio-generic we can move it later.

Thanks,
Hartley
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

end of thread, other threads:[~2011-11-16 22:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-16 19:02 basic_mmio_gpio: Add hook for simple debounce register H Hartley Sweeten
2011-11-16 21:40 ` Anton Vorontsov
2011-11-16 22:41   ` H Hartley Sweeten

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox