linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpiolib: introduce gpio_set_pullup
@ 2011-11-25 14:08 Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:08 ` [PATCH 2/2] gpiolib: introduce gpio_set_deglitch Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-25 14:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jean-Christophe PLAGNIOL-VILLARD, Nicolas Ferre, Grant Likely

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/asm-generic/gpio.h |    4 ++++
 include/linux/gpio.h       |    5 +++++
 3 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a971e3d..b7e5e75 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1519,6 +1519,50 @@ fail:
 }
 EXPORT_SYMBOL_GPL(gpio_set_debounce);
 
+/**
+ * gpio_set_pullup - sets @pullup for a @gpio
+ * @gpio: the gpio to set pullup
+ * @pullup: pullup level
+ */
+int gpio_set_pullup(unsigned gpio, unsigned pullup)
+{
+	unsigned long		flags;
+	struct gpio_chip	*chip;
+	struct gpio_desc	*desc = &gpio_desc[gpio];
+	int			status = -EINVAL;
+
+	spin_lock_irqsave(&gpio_lock, flags);
+
+	if (!gpio_is_valid(gpio))
+		goto fail;
+	chip = desc->chip;
+	if (!chip || !chip->set_pullup)
+		goto fail;
+	gpio -= chip->base;
+	if (gpio >= chip->ngpio)
+		goto fail;
+	status = gpio_ensure_requested(desc, gpio);
+	if (status < 0)
+		goto fail;
+
+	/* now we know the gpio is valid and chip won't vanish */
+
+	spin_unlock_irqrestore(&gpio_lock, flags);
+
+	might_sleep_if(chip->can_sleep);
+
+	return chip->set_pullup(chip, gpio, pullup);
+
+fail:
+	spin_unlock_irqrestore(&gpio_lock, flags);
+	if (status)
+		pr_debug("%s: gpio-%d status %d\n",
+			__func__, gpio, status);
+
+	return status;
+}
+EXPORT_SYMBOL_GPL(gpio_set_pullup);
+
 /* I/O calls are only valid after configuration completed; the relevant
  * "is this a valid GPIO" error checks should already have been done.
  *
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 8c86210..085ef16 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -107,6 +107,9 @@ struct gpio_chip {
 	int			(*set_debounce)(struct gpio_chip *chip,
 						unsigned offset, unsigned debounce);
 
+	int			(*set_pullup)(struct gpio_chip *chip,
+						unsigned offset, unsigned pullup);
+
 	void			(*set)(struct gpio_chip *chip,
 						unsigned offset, int value);
 
@@ -155,6 +158,7 @@ extern int gpio_direction_input(unsigned gpio);
 extern int gpio_direction_output(unsigned gpio, int value);
 
 extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
+extern int gpio_set_pullup(unsigned gpio, unsigned pullup);
 
 extern int gpio_get_value_cansleep(unsigned gpio);
 extern void gpio_set_value_cansleep(unsigned gpio, int value);
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 38ac48b..5c786e7 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -90,6 +90,11 @@ static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
 	return -ENOSYS;
 }
 
+static inline int gpio_set_pullup(unsigned gpio, unsigned pullup)
+{
+	return -ENOSYS;
+}
+
 static inline int gpio_get_value(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as {in,out}put */
-- 
1.7.7


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

* [PATCH 2/2] gpiolib: introduce gpio_set_deglitch
  2011-11-25 14:08 [PATCH 1/2] gpiolib: introduce gpio_set_pullup Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-25 14:08 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:14   ` Felipe Balbi
  2011-11-25 14:16 ` [PATCH 1/2] gpiolib: introduce gpio_set_pullup Felipe Balbi
  2011-11-25 15:34 ` Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-25 14:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jean-Christophe PLAGNIOL-VILLARD, Nicolas Ferre, Grant Likely

this will allow to manage the Glitch Input Filter
as present on AT91 as example

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/asm-generic/gpio.h |    4 ++++
 include/linux/gpio.h       |    5 +++++
 3 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b7e5e75..d2b1833 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1563,6 +1563,50 @@ fail:
 }
 EXPORT_SYMBOL_GPL(gpio_set_pullup);
 
+/**
+ * gpio_set_deglitch - sets @deglitch for a @gpio
+ * @gpio: the gpio to set deglitch
+ * @deglitch: deglitch level
+ */
+int gpio_set_deglitch(unsigned gpio, unsigned deglitch)
+{
+	unsigned long		flags;
+	struct gpio_chip	*chip;
+	struct gpio_desc	*desc = &gpio_desc[gpio];
+	int			status = -EINVAL;
+
+	spin_lock_irqsave(&gpio_lock, flags);
+
+	if (!gpio_is_valid(gpio))
+		goto fail;
+	chip = desc->chip;
+	if (!chip || !chip->set_deglitch)
+		goto fail;
+	gpio -= chip->base;
+	if (gpio >= chip->ngpio)
+		goto fail;
+	status = gpio_ensure_requested(desc, gpio);
+	if (status < 0)
+		goto fail;
+
+	/* now we know the gpio is valid and chip won't vanish */
+
+	spin_unlock_irqrestore(&gpio_lock, flags);
+
+	might_sleep_if(chip->can_sleep);
+
+	return chip->set_deglitch(chip, gpio, deglitch);
+
+fail:
+	spin_unlock_irqrestore(&gpio_lock, flags);
+	if (status)
+		pr_debug("%s: gpio-%d status %d\n",
+			__func__, gpio, status);
+
+	return status;
+}
+EXPORT_SYMBOL_GPL(gpio_set_deglitch);
+
 /* I/O calls are only valid after configuration completed; the relevant
  * "is this a valid GPIO" error checks should already have been done.
  *
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 085ef16..20a9786 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -110,6 +110,9 @@ struct gpio_chip {
 	int			(*set_pullup)(struct gpio_chip *chip,
 						unsigned offset, unsigned pullup);
 
+	int			(*set_deglitch)(struct gpio_chip *chip,
+						unsigned offset, unsigned deglitch);
+
 	void			(*set)(struct gpio_chip *chip,
 						unsigned offset, int value);
 
@@ -159,6 +162,7 @@ extern int gpio_direction_output(unsigned gpio, int value);
 
 extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
 extern int gpio_set_pullup(unsigned gpio, unsigned pullup);
+extern int gpio_set_deglitch(unsigned gpio, unsigned deglitch);
 
 extern int gpio_get_value_cansleep(unsigned gpio);
 extern void gpio_set_value_cansleep(unsigned gpio, int value);
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 5c786e7..bfbc3d7 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -95,6 +95,11 @@ static inline int gpio_set_pullup(unsigned gpio, unsigned pullup)
 	return -ENOSYS;
 }
 
+static inline int gpio_set_deglitch(unsigned gpio, unsigned deglitch)
+{
+	return -ENOSYS;
+}
+
 static inline int gpio_get_value(unsigned gpio)
 {
 	/* GPIO can never have been requested or set as {in,out}put */
-- 
1.7.7


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

* Re: [PATCH 2/2] gpiolib: introduce gpio_set_deglitch
  2011-11-25 14:08 ` [PATCH 2/2] gpiolib: introduce gpio_set_deglitch Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-25 14:14   ` Felipe Balbi
  2011-11-25 15:00     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 13+ messages in thread
From: Felipe Balbi @ 2011-11-25 14:14 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: linux-kernel, Nicolas Ferre, Grant Likely

[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]

Hi,

On Fri, Nov 25, 2011 at 03:08:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> this will allow to manage the Glitch Input Filter
> as present on AT91 as example
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> ---
>  drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  include/asm-generic/gpio.h |    4 ++++
>  include/linux/gpio.h       |    5 +++++
>  3 files changed, 53 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index b7e5e75..d2b1833 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1563,6 +1563,50 @@ fail:
>  }
>  EXPORT_SYMBOL_GPL(gpio_set_pullup);
>  
> +/**
> + * gpio_set_deglitch - sets @deglitch for a @gpio
> + * @gpio: the gpio to set deglitch
> + * @deglitch: deglitch level
> + */
> +int gpio_set_deglitch(unsigned gpio, unsigned deglitch)

sounds a lot like debounce, what's the difference ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-25 14:08 [PATCH 1/2] gpiolib: introduce gpio_set_pullup Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:08 ` [PATCH 2/2] gpiolib: introduce gpio_set_deglitch Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-25 14:16 ` Felipe Balbi
  2011-11-25 14:23   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 15:34 ` Mark Brown
  2 siblings, 1 reply; 13+ messages in thread
From: Felipe Balbi @ 2011-11-25 14:16 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: linux-kernel, Nicolas Ferre, Grant Likely

[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]

Hi,

On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> ---
>  drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  include/asm-generic/gpio.h |    4 ++++
>  include/linux/gpio.h       |    5 +++++
>  3 files changed, 53 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index a971e3d..b7e5e75 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1519,6 +1519,50 @@ fail:
>  }
>  EXPORT_SYMBOL_GPL(gpio_set_debounce);
>  
> +/**
> + * gpio_set_pullup - sets @pullup for a @gpio
> + * @gpio: the gpio to set pullup
> + * @pullup: pullup level
> + */
> +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> +{
> +	unsigned long		flags;
> +	struct gpio_chip	*chip;
> +	struct gpio_desc	*desc = &gpio_desc[gpio];
> +	int			status = -EINVAL;
> +
> +	spin_lock_irqsave(&gpio_lock, flags);
> +
> +	if (!gpio_is_valid(gpio))
> +		goto fail;
> +	chip = desc->chip;
> +	if (!chip || !chip->set_pullup)
> +		goto fail;
> +	gpio -= chip->base;
> +	if (gpio >= chip->ngpio)
> +		goto fail;
> +	status = gpio_ensure_requested(desc, gpio);
> +	if (status < 0)
> +		goto fail;
> +
> +	/* now we know the gpio is valid and chip won't vanish */
> +
> +	spin_unlock_irqrestore(&gpio_lock, flags);
> +
> +	might_sleep_if(chip->can_sleep);
> +
> +	return chip->set_pullup(chip, gpio, pullup);
> +
> +fail:
> +	spin_unlock_irqrestore(&gpio_lock, flags);
> +	if (status)
> +		pr_debug("%s: gpio-%d status %d\n",
> +			__func__, gpio, status);
> +
> +	return status;
> +}
> +EXPORT_SYMBOL_GPL(gpio_set_pullup);

Maybe I'm missing something, but isn't it essentially what
gpio_set_value() does ? I mean, you set a pullup and you get '1' value
and set a pulldown and you get a '0' value ??

Without a proper description of the necessity for this change, I can't
easily tell them apart :-(

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-25 14:16 ` [PATCH 1/2] gpiolib: introduce gpio_set_pullup Felipe Balbi
@ 2011-11-25 14:23   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:59     ` Felipe Balbi
  0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-25 14:23 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-kernel, Nicolas Ferre, Grant Likely

On 16:16 Fri 25 Nov     , Felipe Balbi wrote:
> Hi,
> 
> On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > ---
> >  drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
> >  include/asm-generic/gpio.h |    4 ++++
> >  include/linux/gpio.h       |    5 +++++
> >  3 files changed, 53 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index a971e3d..b7e5e75 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -1519,6 +1519,50 @@ fail:
> >  }
> >  EXPORT_SYMBOL_GPL(gpio_set_debounce);
> >  
> > +/**
> > + * gpio_set_pullup - sets @pullup for a @gpio
> > + * @gpio: the gpio to set pullup
> > + * @pullup: pullup level
> > + */
> > +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> > +{
> > +	unsigned long		flags;
> > +	struct gpio_chip	*chip;
> > +	struct gpio_desc	*desc = &gpio_desc[gpio];
> > +	int			status = -EINVAL;
> > +
> > +	spin_lock_irqsave(&gpio_lock, flags);
> > +
> > +	if (!gpio_is_valid(gpio))
> > +		goto fail;
> > +	chip = desc->chip;
> > +	if (!chip || !chip->set_pullup)
> > +		goto fail;
> > +	gpio -= chip->base;
> > +	if (gpio >= chip->ngpio)
> > +		goto fail;
> > +	status = gpio_ensure_requested(desc, gpio);
> > +	if (status < 0)
> > +		goto fail;
> > +
> > +	/* now we know the gpio is valid and chip won't vanish */
> > +
> > +	spin_unlock_irqrestore(&gpio_lock, flags);
> > +
> > +	might_sleep_if(chip->can_sleep);
> > +
> > +	return chip->set_pullup(chip, gpio, pullup);
> > +
> > +fail:
> > +	spin_unlock_irqrestore(&gpio_lock, flags);
> > +	if (status)
> > +		pr_debug("%s: gpio-%d status %d\n",
> > +			__func__, gpio, status);
> > +
> > +	return status;
> > +}
> > +EXPORT_SYMBOL_GPL(gpio_set_pullup);
> 
> Maybe I'm missing something, but isn't it essentially what
> gpio_set_value() does ? I mean, you set a pullup and you get '1' value
> and set a pulldown and you get a '0' value ??
> 
> Without a proper description of the necessity for this change, I can't
> easily tell them apart :-(
set_value is for output set_pullup is for input mode

some IP allow you when you configure an gpio as input to enable the internal pullup
so no need on the board to add an external pull up

Best Regards,
J.

> 
> -- 
> balbi



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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-25 14:23   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-25 14:59     ` Felipe Balbi
  0 siblings, 0 replies; 13+ messages in thread
From: Felipe Balbi @ 2011-11-25 14:59 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Felipe Balbi, linux-kernel, Nicolas Ferre, Grant Likely

[-- Attachment #1: Type: text/plain, Size: 2813 bytes --]

On Fri, Nov 25, 2011 at 03:23:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 16:16 Fri 25 Nov     , Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > > Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> > > Cc: Grant Likely <grant.likely@secretlab.ca>
> > > ---
> > >  drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
> > >  include/asm-generic/gpio.h |    4 ++++
> > >  include/linux/gpio.h       |    5 +++++
> > >  3 files changed, 53 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > > index a971e3d..b7e5e75 100644
> > > --- a/drivers/gpio/gpiolib.c
> > > +++ b/drivers/gpio/gpiolib.c
> > > @@ -1519,6 +1519,50 @@ fail:
> > >  }
> > >  EXPORT_SYMBOL_GPL(gpio_set_debounce);
> > >  
> > > +/**
> > > + * gpio_set_pullup - sets @pullup for a @gpio
> > > + * @gpio: the gpio to set pullup
> > > + * @pullup: pullup level
> > > + */
> > > +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> > > +{
> > > +	unsigned long		flags;
> > > +	struct gpio_chip	*chip;
> > > +	struct gpio_desc	*desc = &gpio_desc[gpio];
> > > +	int			status = -EINVAL;
> > > +
> > > +	spin_lock_irqsave(&gpio_lock, flags);
> > > +
> > > +	if (!gpio_is_valid(gpio))
> > > +		goto fail;
> > > +	chip = desc->chip;
> > > +	if (!chip || !chip->set_pullup)
> > > +		goto fail;
> > > +	gpio -= chip->base;
> > > +	if (gpio >= chip->ngpio)
> > > +		goto fail;
> > > +	status = gpio_ensure_requested(desc, gpio);
> > > +	if (status < 0)
> > > +		goto fail;
> > > +
> > > +	/* now we know the gpio is valid and chip won't vanish */
> > > +
> > > +	spin_unlock_irqrestore(&gpio_lock, flags);
> > > +
> > > +	might_sleep_if(chip->can_sleep);
> > > +
> > > +	return chip->set_pullup(chip, gpio, pullup);
> > > +
> > > +fail:
> > > +	spin_unlock_irqrestore(&gpio_lock, flags);
> > > +	if (status)
> > > +		pr_debug("%s: gpio-%d status %d\n",
> > > +			__func__, gpio, status);
> > > +
> > > +	return status;
> > > +}
> > > +EXPORT_SYMBOL_GPL(gpio_set_pullup);
> > 
> > Maybe I'm missing something, but isn't it essentially what
> > gpio_set_value() does ? I mean, you set a pullup and you get '1' value
> > and set a pulldown and you get a '0' value ??
> > 
> > Without a proper description of the necessity for this change, I can't
> > easily tell them apart :-(
> set_value is for output set_pullup is for input mode
> 
> some IP allow you when you configure an gpio as input to enable the
> internal pullup so no need on the board to add an external pull up

I see, that would fit nicely on the changelog :-)

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 2/2] gpiolib: introduce gpio_set_deglitch
  2011-11-25 14:14   ` Felipe Balbi
@ 2011-11-25 15:00     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-25 15:00 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: linux-kernel, Nicolas Ferre, Grant Likely

On 16:14 Fri 25 Nov     , Felipe Balbi wrote:
> Hi,
> 
> On Fri, Nov 25, 2011 at 03:08:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > this will allow to manage the Glitch Input Filter
> > as present on AT91 as example
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > ---
> >  drivers/gpio/gpiolib.c     |   44 ++++++++++++++++++++++++++++++++++++++++++++
> >  include/asm-generic/gpio.h |    4 ++++
> >  include/linux/gpio.h       |    5 +++++
> >  3 files changed, 53 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > index b7e5e75..d2b1833 100644
> > --- a/drivers/gpio/gpiolib.c
> > +++ b/drivers/gpio/gpiolib.c
> > @@ -1563,6 +1563,50 @@ fail:
> >  }
> >  EXPORT_SYMBOL_GPL(gpio_set_pullup);
> >  
> > +/**
> > + * gpio_set_deglitch - sets @deglitch for a @gpio
> > + * @gpio: the gpio to set deglitch
> > + * @deglitch: deglitch level
> > + */
> > +int gpio_set_deglitch(unsigned gpio, unsigned deglitch)
> 
> sounds a lot like debounce, what's the difference ?
deglitch allow you to filter the fact that the line take time to be stable
go to 1 and 0

debounce will set 2 different threshold for changing the state from 0 to 1 and
invertly

Best Regards,
J.

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-25 14:08 [PATCH 1/2] gpiolib: introduce gpio_set_pullup Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:08 ` [PATCH 2/2] gpiolib: introduce gpio_set_deglitch Jean-Christophe PLAGNIOL-VILLARD
  2011-11-25 14:16 ` [PATCH 1/2] gpiolib: introduce gpio_set_pullup Felipe Balbi
@ 2011-11-25 15:34 ` Mark Brown
  2011-11-27  9:35   ` Igor Grinberg
  2 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2011-11-25 15:34 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: linux-kernel, Nicolas Ferre, Grant Likely

On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:

> +/**
> + * gpio_set_pullup - sets @pullup for a @gpio
> + * @gpio: the gpio to set pullup
> + * @pullup: pullup level
> + */
> +int gpio_set_pullup(unsigned gpio, unsigned pullup)

This has some overlap with the pinmux subsystem.  We also need
documentation of what the pullup values mean.

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-25 15:34 ` Mark Brown
@ 2011-11-27  9:35   ` Igor Grinberg
  2011-11-29  2:37     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 13+ messages in thread
From: Igor Grinberg @ 2011-11-27  9:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: Jean-Christophe PLAGNIOL-VILLARD, linux-kernel, Nicolas Ferre,
	Grant Likely

On 11/25/11 17:34, Mark Brown wrote:
> On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 
>> +/**
>> + * gpio_set_pullup - sets @pullup for a @gpio
>> + * @gpio: the gpio to set pullup
>> + * @pullup: pullup level
>> + */
>> +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> 
> This has some overlap with the pinmux subsystem.  We also need
> documentation of what the pullup values mean.

+1

AFAIK, 3 values are there: up, down and highz
Also, IMO, this should have no effect if the GPIO is configured for output.


-- 
Regards,
Igor.

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-27  9:35   ` Igor Grinberg
@ 2011-11-29  2:37     ` Jean-Christophe PLAGNIOL-VILLARD
  2011-11-29 16:51       ` Stephen Warren
  0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-29  2:37 UTC (permalink / raw)
  To: Igor Grinberg; +Cc: Mark Brown, linux-kernel, Nicolas Ferre, Grant Likely

On 11:35 Sun 27 Nov     , Igor Grinberg wrote:
> On 11/25/11 17:34, Mark Brown wrote:
> > On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > 
> >> +/**
> >> + * gpio_set_pullup - sets @pullup for a @gpio
> >> + * @gpio: the gpio to set pullup
> >> + * @pullup: pullup level
> >> + */
> >> +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> > 
> > This has some overlap with the pinmux subsystem.  We also need
> > documentation of what the pullup values mean.
yes and no

as some gpio IP (only gpio i2c extender as example ) have it too
so you can not use the pinmux for this
> 
> +1
> 
> AFAIK, 3 values are there: up, down and highz
> Also, IMO, this should have no effect if the GPIO is configured for output.
I see some pio IP have 2 highz

but yes 3 value normaly

Best Regards,
J.

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

* RE: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-29  2:37     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-29 16:51       ` Stephen Warren
  2011-12-05 15:40         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Warren @ 2011-11-29 16:51 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD, Igor Grinberg
  Cc: Mark Brown, linux-kernel, Nicolas Ferre, Grant Likely

Jean-Christophe PLAGNIOL-VILLARD wrote at Monday, November 28, 2011 7:37 PM:
> On 11:35 Sun 27 Nov     , Igor Grinberg wrote:
> > On 11/25/11 17:34, Mark Brown wrote:
> > > On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > >
> > >> +/**
> > >> + * gpio_set_pullup - sets @pullup for a @gpio
> > >> + * @gpio: the gpio to set pullup
> > >> + * @pullup: pullup level
> > >> + */
> > >> +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> > >
> > > This has some overlap with the pinmux subsystem.  We also need
> > > documentation of what the pullup values mean.
> yes and no
> 
> as some gpio IP (only gpio i2c extender as example ) have it too
> so you can not use the pinmux for this

Why not?

I believe the pinctrl subsystem should be applicable to any chip, be it
the main SoC/CPU in the system, or any other chip. We don't currently
have any non-SoC drivers, but that's just because nobody has written them
yet; there's no technical reason they couldn't exist.

-- 
nvpublic


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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-11-29 16:51       ` Stephen Warren
@ 2011-12-05 15:40         ` Jean-Christophe PLAGNIOL-VILLARD
  2011-12-05 15:56           ` Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-12-05 15:40 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Igor Grinberg, Mark Brown, linux-kernel, Nicolas Ferre, Grant Likely

On 08:51 Tue 29 Nov     , Stephen Warren wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote at Monday, November 28, 2011 7:37 PM:
> > On 11:35 Sun 27 Nov     , Igor Grinberg wrote:
> > > On 11/25/11 17:34, Mark Brown wrote:
> > > > On Fri, Nov 25, 2011 at 03:08:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >
> > > >> +/**
> > > >> + * gpio_set_pullup - sets @pullup for a @gpio
> > > >> + * @gpio: the gpio to set pullup
> > > >> + * @pullup: pullup level
> > > >> + */
> > > >> +int gpio_set_pullup(unsigned gpio, unsigned pullup)
> > > >
> > > > This has some overlap with the pinmux subsystem.  We also need
> > > > documentation of what the pullup values mean.
> > yes and no
> > 
> > as some gpio IP (only gpio i2c extender as example ) have it too
> > so you can not use the pinmux for this
> 
> Why not?
> 
> I believe the pinctrl subsystem should be applicable to any chip, be it
> the main SoC/CPU in the system, or any other chip. We don't currently
> have any non-SoC drivers, but that's just because nobody has written them
> yet; there's no technical reason they couldn't exist.
> 
sorry pinmux for gpio specific management i's overkill

Best Regards,
J.

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

* Re: [PATCH 1/2] gpiolib: introduce gpio_set_pullup
  2011-12-05 15:40         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-12-05 15:56           ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2011-12-05 15:56 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Stephen Warren, Igor Grinberg, linux-kernel, Nicolas Ferre, Grant Likely

On Mon, Dec 05, 2011 at 04:40:11PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:51 Tue 29 Nov     , Stephen Warren wrote:

> > I believe the pinctrl subsystem should be applicable to any chip, be it
> > the main SoC/CPU in the system, or any other chip. We don't currently
> > have any non-SoC drivers, but that's just because nobody has written them
> > yet; there's no technical reason they couldn't exist.

> sorry pinmux for gpio specific management i's overkill

If it's a GPIO-only device then probaby but lots of devices have a
fairly large range of signals that can be brought out on the pins (often
even more than a typical SoC actually).

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

end of thread, other threads:[~2011-12-05 21:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-25 14:08 [PATCH 1/2] gpiolib: introduce gpio_set_pullup Jean-Christophe PLAGNIOL-VILLARD
2011-11-25 14:08 ` [PATCH 2/2] gpiolib: introduce gpio_set_deglitch Jean-Christophe PLAGNIOL-VILLARD
2011-11-25 14:14   ` Felipe Balbi
2011-11-25 15:00     ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-25 14:16 ` [PATCH 1/2] gpiolib: introduce gpio_set_pullup Felipe Balbi
2011-11-25 14:23   ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-25 14:59     ` Felipe Balbi
2011-11-25 15:34 ` Mark Brown
2011-11-27  9:35   ` Igor Grinberg
2011-11-29  2:37     ` Jean-Christophe PLAGNIOL-VILLARD
2011-11-29 16:51       ` Stephen Warren
2011-12-05 15:40         ` Jean-Christophe PLAGNIOL-VILLARD
2011-12-05 15:56           ` Mark Brown

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