RE: basic_mmio_gpio: Add hook for simple debounce register
From: H Hartley Sweeten
Date: Wed Nov 16 2011 - 17:41:25 EST
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Ç+·®+%Ëlzwm
ébëæìr¸zX§»®w¥{ayºÊÚë,j¢f£¢·hàz¹®w¥¢¸¢·¦j:+v¨wèjØm¶ÿ¾«êçzZ+ùÝj"ú!¶iOæ¬z·vØ^¶m§ÿðÃnÆàþY&