Skip to contentSkip to conversation

basic_mmio_gpio: Add hook for simple debounce register

PATCH H Hartley Sweeten 2 participants 3 messages Nov 16, 2011

lore
Share & tools
lore
#0 lore raw

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);
}
Cc Grant Likely <[email protected]>
Cc Jamie Iles <[email protected]>
Cc Anton Vorontsov <[email protected]>
Cc Andrew Morton <[email protected]>
CC Russell King <[email protected]>

---

include/linux/basic_mmio_gpio.h +1 -0
index feb91219..9bec937 100644
@@ -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;
#1 lore raw

Hello,

Quoted 7 lines · H Hartley Sweeten

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,

Signature · 2 lines
Anton Vorontsov
Email: [email protected]
#2 lore raw
Quoted 9 lines · Anton Vorontsov

Hello,

Quoted 5 lines · H Hartley Sweeten

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.

Quoted 7 lines
Quoted 2 lines

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.

Quoted 21 lines

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);
}
Quoted 2 lines

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�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�