* [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
@ 2008-11-07 19:59 David Brownell
2008-11-10 13:11 ` Felipe Balbi
0 siblings, 1 reply; 6+ messages in thread
From: David Brownell @ 2008-11-07 19:59 UTC (permalink / raw)
To: linux-omap
From: David Brownell <dbrownell@users.sourceforge.net>
Provide a static debounce configuration mechanism for twl4030 GPIOs,
replacing the previous dynamic one. The single user of that mechanism
was for MMC card detect debouncing.
Boards can provide a bitmask saying which GPIOs to debounce (30 msec).
It's always enabled for pins with the MMC card-detect/VMMCx link active,
so most boards won't need to set the debounce mask.
This is a net code shrink, including runtime footprint.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
I'll submit this to mainline as soon as I get appropriate
acks/signoffs here.
drivers/gpio/twl4030-gpio.c | 54 +++++++++++++++++-------------------------
include/linux/i2c/twl4030.h | 9 ++-----
2 files changed, 26 insertions(+), 37 deletions(-)
--- a/drivers/gpio/twl4030-gpio.c
+++ b/drivers/gpio/twl4030-gpio.c
@@ -202,37 +202,6 @@ static int twl4030_get_gpio_datain(int g
return ret;
}
-/*
- * Configure debounce timing value for a GPIO pin on TWL4030
- */
-int twl4030_set_gpio_debounce(int gpio, int enable)
-{
- u8 d_bnk = gpio >> 3;
- u8 d_msk = BIT(gpio & 0x7);
- u8 reg = 0;
- u8 base = 0;
- int ret = 0;
-
- if (unlikely((gpio >= TWL4030_GPIO_MAX)
- || !(gpio_usage_count & BIT(gpio))))
- return -EPERM;
-
- base = REG_GPIO_DEBEN1 + d_bnk;
- mutex_lock(&gpio_lock);
- ret = gpio_twl4030_read(base);
- if (ret >= 0) {
- if (enable)
- reg = ret | d_msk;
- else
- reg = ret & ~d_msk;
-
- ret = gpio_twl4030_write(base, reg);
- }
- mutex_unlock(&gpio_lock);
- return ret;
-}
-EXPORT_SYMBOL(twl4030_set_gpio_debounce);
-
/*----------------------------------------------------------------------*/
static int twl_request(struct gpio_chip *chip, unsigned offset)
@@ -405,6 +374,23 @@ static int __devinit gpio_twl4030_pulls(
REG_GPIOPUPDCTR1, 5);
}
+static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
+{
+ u8 message[4];
+
+ /* 30 msec of debouncing is always used for MMC card detect,
+ * and is optional for everything else.
+ */
+ message[1] = (debounce & 0xff) | (mmc_cd & 0x03);
+ debounce >>= 8;
+ message[2] = (debounce & 0xff);
+ debounce >>= 8;
+ message[3] = (debounce & 0x03);
+
+ return twl4030_i2c_write(TWL4030_MODULE_GPIO, message,
+ REG_GPIO_DEBEN1, 3);
+}
+
static int gpio_twl4030_remove(struct platform_device *pdev);
static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
@@ -439,6 +425,12 @@ no_irqs:
pdata->pullups, pdata->pulldowns,
ret);
+ ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
+ if (ret)
+ dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
+ pdata->debounce, pdata->mmc_cd,
+ ret);
+
twl_gpiochip.base = pdata->gpio_base;
twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
twl_gpiochip.dev = &pdev->dev;
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -234,6 +234,9 @@ struct twl4030_gpio_platform_data {
/* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */
u8 mmc_cd;
+ /* if BIT(N) is set, or VMMC(n+1) is linked, debounce GPIO-N */
+ u32 debounce;
+
/* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
* should be enabled. Else, if that bit is set in "pulldowns",
* that pulldown is enabled. Don't waste power by letting any
@@ -390,12 +393,6 @@ int twl4030_sih_setup(int module);
#define TWL4030_GPIO_IRQ_NO(n) (TWL4030_GPIO_IRQ_BASE + (n))
-/*
- * Exported TWL4030 GPIO APIs
- *
- * WARNING -- use standard GPIO and IRQ calls instead; these will vanish.
- */
-int twl4030_set_gpio_debounce(int gpio, int enable);
#if defined(CONFIG_TWL4030_BCI_BATTERY) || \
defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
2008-11-07 19:59 [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup David Brownell
@ 2008-11-10 13:11 ` Felipe Balbi
2008-11-10 14:28 ` David Brownell
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2008-11-10 13:11 UTC (permalink / raw)
To: ext David Brownell; +Cc: linux-omap
On Fri, Nov 07, 2008 at 11:59:49AM -0800, David Brownell wrote:
> From: David Brownell <dbrownell@users.sourceforge.net>
>
> Provide a static debounce configuration mechanism for twl4030 GPIOs,
> replacing the previous dynamic one. The single user of that mechanism
> was for MMC card detect debouncing.
>
> Boards can provide a bitmask saying which GPIOs to debounce (30 msec).
> It's always enabled for pins with the MMC card-detect/VMMCx link active,
> so most boards won't need to set the debounce mask.
>
> This is a net code shrink, including runtime footprint.
>
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> ---
> I'll submit this to mainline as soon as I get appropriate
> acks/signoffs here.
Shouldn't you update hsmmc.c as well ??
>
> drivers/gpio/twl4030-gpio.c | 54 +++++++++++++++++-------------------------
> include/linux/i2c/twl4030.h | 9 ++-----
> 2 files changed, 26 insertions(+), 37 deletions(-)
>
> --- a/drivers/gpio/twl4030-gpio.c
> +++ b/drivers/gpio/twl4030-gpio.c
> @@ -202,37 +202,6 @@ static int twl4030_get_gpio_datain(int g
> return ret;
> }
>
> -/*
> - * Configure debounce timing value for a GPIO pin on TWL4030
> - */
> -int twl4030_set_gpio_debounce(int gpio, int enable)
> -{
> - u8 d_bnk = gpio >> 3;
> - u8 d_msk = BIT(gpio & 0x7);
> - u8 reg = 0;
> - u8 base = 0;
> - int ret = 0;
> -
> - if (unlikely((gpio >= TWL4030_GPIO_MAX)
> - || !(gpio_usage_count & BIT(gpio))))
> - return -EPERM;
> -
> - base = REG_GPIO_DEBEN1 + d_bnk;
> - mutex_lock(&gpio_lock);
> - ret = gpio_twl4030_read(base);
> - if (ret >= 0) {
> - if (enable)
> - reg = ret | d_msk;
> - else
> - reg = ret & ~d_msk;
> -
> - ret = gpio_twl4030_write(base, reg);
> - }
> - mutex_unlock(&gpio_lock);
> - return ret;
> -}
> -EXPORT_SYMBOL(twl4030_set_gpio_debounce);
> -
> /*----------------------------------------------------------------------*/
>
> static int twl_request(struct gpio_chip *chip, unsigned offset)
> @@ -405,6 +374,23 @@ static int __devinit gpio_twl4030_pulls(
> REG_GPIOPUPDCTR1, 5);
> }
>
> +static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
> +{
> + u8 message[4];
> +
> + /* 30 msec of debouncing is always used for MMC card detect,
> + * and is optional for everything else.
> + */
> + message[1] = (debounce & 0xff) | (mmc_cd & 0x03);
> + debounce >>= 8;
> + message[2] = (debounce & 0xff);
> + debounce >>= 8;
> + message[3] = (debounce & 0x03);
> +
> + return twl4030_i2c_write(TWL4030_MODULE_GPIO, message,
> + REG_GPIO_DEBEN1, 3);
> +}
> +
> static int gpio_twl4030_remove(struct platform_device *pdev);
>
> static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> @@ -439,6 +425,12 @@ no_irqs:
> pdata->pullups, pdata->pulldowns,
> ret);
>
> + ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
> + if (ret)
> + dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
> + pdata->debounce, pdata->mmc_cd,
> + ret);
> +
> twl_gpiochip.base = pdata->gpio_base;
> twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
> twl_gpiochip.dev = &pdev->dev;
> --- a/include/linux/i2c/twl4030.h
> +++ b/include/linux/i2c/twl4030.h
> @@ -234,6 +234,9 @@ struct twl4030_gpio_platform_data {
> /* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */
> u8 mmc_cd;
>
> + /* if BIT(N) is set, or VMMC(n+1) is linked, debounce GPIO-N */
> + u32 debounce;
> +
> /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
> * should be enabled. Else, if that bit is set in "pulldowns",
> * that pulldown is enabled. Don't waste power by letting any
> @@ -390,12 +393,6 @@ int twl4030_sih_setup(int module);
>
> #define TWL4030_GPIO_IRQ_NO(n) (TWL4030_GPIO_IRQ_BASE + (n))
>
> -/*
> - * Exported TWL4030 GPIO APIs
> - *
> - * WARNING -- use standard GPIO and IRQ calls instead; these will vanish.
> - */
> -int twl4030_set_gpio_debounce(int gpio, int enable);
>
> #if defined(CONFIG_TWL4030_BCI_BATTERY) || \
> defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
balbi
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
2008-11-10 13:11 ` Felipe Balbi
@ 2008-11-10 14:28 ` David Brownell
2008-11-10 15:03 ` Felipe Balbi
0 siblings, 1 reply; 6+ messages in thread
From: David Brownell @ 2008-11-10 14:28 UTC (permalink / raw)
To: felipe.balbi; +Cc: linux-omap
On Monday 10 November 2008, Felipe Balbi wrote:
>
> > Provide a static debounce configuration mechanism for twl4030 GPIOs,
> > replacing the previous dynamic one. The single user of that mechanism
> > was for MMC card detect debouncing.
> >
> > Boards can provide a bitmask saying which GPIOs to debounce (30 msec).
> > It's always enabled for pins with the MMC card-detect/VMMCx link active,
> > so most boards won't need to set the debounce mask.
>
> Shouldn't you update hsmmc.c as well ??
In some way one of the other patches didn't??
... I don't understand what you're implying.
(Though the GPIO code might need to support the
other mode -- active high vs low -- for the card
detect-to-VMMCx linkage.)
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
2008-11-10 14:28 ` David Brownell
@ 2008-11-10 15:03 ` Felipe Balbi
2008-11-10 15:21 ` David Brownell
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2008-11-10 15:03 UTC (permalink / raw)
To: ext David Brownell; +Cc: felipe.balbi, linux-omap
On Mon, Nov 10, 2008 at 06:28:30AM -0800, David Brownell wrote:
> On Monday 10 November 2008, Felipe Balbi wrote:
> >
> > > Provide a static debounce configuration mechanism for twl4030 GPIOs,
> > > replacing the previous dynamic one. The single user of that mechanism
> > > was for MMC card detect debouncing.
> > >
> > > Boards can provide a bitmask saying which GPIOs to debounce (30 msec).
> > > It's always enabled for pins with the MMC card-detect/VMMCx link active,
> > > so most boards won't need to set the debounce mask.
> >
> > Shouldn't you update hsmmc.c as well ??
>
> In some way one of the other patches didn't??
> ... I don't understand what you're implying.
>
> (Though the GPIO code might need to support the
> other mode -- active high vs low -- for the card
> detect-to-VMMCx linkage.)
I got your patches and build tested them, hsmmc.c still had
twl4030_gpio_debounce call. Maybe I missed one of the patches then.
--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
2008-11-10 15:03 ` Felipe Balbi
@ 2008-11-10 15:21 ` David Brownell
2008-11-10 15:23 ` Felipe Balbi
0 siblings, 1 reply; 6+ messages in thread
From: David Brownell @ 2008-11-10 15:21 UTC (permalink / raw)
To: felipe.balbi; +Cc: linux-omap
On Monday 10 November 2008, Felipe Balbi wrote:
> I got your patches and build tested them, hsmmc.c still had
> twl4030_gpio_debounce call. Maybe I missed one of the patches then.
Grab current GIT.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup
2008-11-10 15:21 ` David Brownell
@ 2008-11-10 15:23 ` Felipe Balbi
0 siblings, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2008-11-10 15:23 UTC (permalink / raw)
To: ext David Brownell; +Cc: felipe.balbi, linux-omap
On Mon, Nov 10, 2008 at 07:21:30AM -0800, David Brownell wrote:
> On Monday 10 November 2008, Felipe Balbi wrote:
> > I got your patches and build tested them, hsmmc.c still had
> > twl4030_gpio_debounce call. Maybe I missed one of the patches then.
>
> Grab current GIT.
Ugh, missed that :-p
haha. Thanks
--
balbi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-11-10 15:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-07 19:59 [patch 2.6.28-rc3-omap git 2/2] twl4030-gpio debounce cleanup David Brownell
2008-11-10 13:11 ` Felipe Balbi
2008-11-10 14:28 ` David Brownell
2008-11-10 15:03 ` Felipe Balbi
2008-11-10 15:21 ` David Brownell
2008-11-10 15:23 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox