Re: [PATCH v2] gpio: palmas: add in GPIO support for palmas charger

2013-03-04 Thread Samuel Ortiz
Hi Ian,

On Mon, Mar 04, 2013 at 10:20:58AM +, Ian Lartey wrote:
> On 02/03/13 19:35, Grant Likely wrote:
> >On Sat, 2 Mar 2013 13:09:47 +0530, Laxman Dewangan  
> >wrote:
> >>On Friday 01 March 2013 10:36 PM, Ian Lartey wrote:
> >>>Palmas charger has 16 GPIOs
> >>>add palmas_gpio_[read|write|update] api to take account
> >>>second bank of GPIOs
> >>>
> >>>Signed-off-by: Ian Lartey 
> >>>Signed-off-by: Graeme Gregory 
> >>>---
> >>
> >>Looks good.
> >>Acked-by: Laxman Dewangan
> >>
> >
> >Applied for v3.10, thanks.
> >
> >g.
> >
> >--
> >To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> >the body of a message to majord...@vger.kernel.org
> >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >Please read the FAQ at  http://www.tux.org/lkml/
> >
> Hello Grant,
> 
> For this [v2] patch I missed out that this patch depends on
> "[PATCH v2] mfd: palmas: is_palmas_charger needed by multiple drivers."
> I did have this noted in the first version of this patch - sorry.
> 
> kbuild rightly complained about the patch
> 
> Do you want to revert this patch until the
> "mfd: palmas: is_palmas_charger needed by multiple drivers"
> is also accepted ?
You should send your patches as independent patchsets, to be applied in the
right order. I'll ack the MFD patches and Grant could take both.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] gpio: palmas: add in GPIO support for palmas charger

2013-03-04 Thread Ian Lartey

On 02/03/13 19:35, Grant Likely wrote:

On Sat, 2 Mar 2013 13:09:47 +0530, Laxman Dewangan  wrote:

On Friday 01 March 2013 10:36 PM, Ian Lartey wrote:

Palmas charger has 16 GPIOs
add palmas_gpio_[read|write|update] api to take account
second bank of GPIOs

Signed-off-by: Ian Lartey 
Signed-off-by: Graeme Gregory 
---


Looks good.
Acked-by: Laxman Dewangan



Applied for v3.10, thanks.

g.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Hello Grant,

For this [v2] patch I missed out that this patch depends on
"[PATCH v2] mfd: palmas: is_palmas_charger needed by multiple drivers."
I did have this noted in the first version of this patch - sorry.

kbuild rightly complained about the patch

Do you want to revert this patch until the
"mfd: palmas: is_palmas_charger needed by multiple drivers"
is also accepted ?




Ian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] gpio: palmas: add in GPIO support for palmas charger

2013-03-03 Thread Grant Likely
On Sat, 2 Mar 2013 13:09:47 +0530, Laxman Dewangan  wrote:
> On Friday 01 March 2013 10:36 PM, Ian Lartey wrote:
> > Palmas charger has 16 GPIOs
> > add palmas_gpio_[read|write|update] api to take account
> > second bank of GPIOs
> >
> > Signed-off-by: Ian Lartey 
> > Signed-off-by: Graeme Gregory 
> > ---
> 
> Looks good.
> Acked-by: Laxman Dewangan
> 

Applied for v3.10, thanks.

g.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] gpio: palmas: add in GPIO support for palmas charger

2013-03-01 Thread Laxman Dewangan

On Friday 01 March 2013 10:36 PM, Ian Lartey wrote:

Palmas charger has 16 GPIOs
add palmas_gpio_[read|write|update] api to take account
second bank of GPIOs

Signed-off-by: Ian Lartey 
Signed-off-by: Graeme Gregory 
---


Looks good.
Acked-by: Laxman Dewangan


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] gpio: palmas: add in GPIO support for palmas charger

2013-03-01 Thread Ian Lartey
Palmas charger has 16 GPIOs
add palmas_gpio_[read|write|update] api to take account
second bank of GPIOs

Signed-off-by: Ian Lartey 
Signed-off-by: Graeme Gregory 
---
 drivers/gpio/gpio-palmas.c |   75 ---
 include/linux/mfd/palmas.h |   12 ++-
 2 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
index e3a4e56..443802a 100644
--- a/drivers/gpio/gpio-palmas.c
+++ b/drivers/gpio/gpio-palmas.c
@@ -1,5 +1,5 @@
 /*
- * TI Palma series PMIC's GPIO driver.
+ * TI Palmas series PMIC's GPIO driver.
  *
  * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  *
@@ -31,6 +31,36 @@ struct palmas_gpio {
struct palmas *palmas;
 };
 
+static int palmas_gpio_read(struct palmas *palmas, unsigned int reg,
+   int gpio, unsigned int *dest)
+{
+   /* registers for second bank are identical and offset by 0x9 */
+   if (gpio > 7)
+   reg += PALMAS_GPIO_DATA_IN2;
+
+   return palmas_read(palmas, PALMAS_GPIO_BASE, reg, dest);
+}
+
+static int palmas_gpio_write(struct palmas *palmas, unsigned int reg,
+   int gpio, unsigned int data)
+{
+   /* registers for second bank are identical and offset by 0x9 */
+   if (gpio > 7)
+   reg += PALMAS_GPIO_DATA_IN2;
+
+   return palmas_write(palmas, PALMAS_GPIO_BASE, reg, data);
+}
+
+static int palmas_gpio_update_bits(struct palmas *palmas, unsigned int reg,
+   int gpio, unsigned int mask, unsigned int data)
+{
+   /* registers for second bank are identical and offset by 0x9 */
+   if (gpio > 7)
+   reg += PALMAS_GPIO_DATA_IN2;
+
+   return palmas_update_bits(palmas, PALMAS_GPIO_BASE, reg, mask, data);
+}
+
 static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip)
 {
return container_of(chip, struct palmas_gpio, gpio_chip);
@@ -43,12 +73,12 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned 
offset)
unsigned int val;
int ret;
 
-   ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val);
+   ret = palmas_gpio_read(palmas, PALMAS_GPIO_DATA_IN, offset, &val);
if (ret < 0) {
dev_err(gc->dev, "GPIO_DATA_IN read failed, err = %d\n", ret);
return ret;
}
-   return !!(val & BIT(offset));
+   return !!(val & BIT(offset % 8));
 }
 
 static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset,
@@ -59,11 +89,11 @@ static void palmas_gpio_set(struct gpio_chip *gc, unsigned 
offset,
int ret;
 
if (value)
-   ret = palmas_write(palmas, PALMAS_GPIO_BASE,
-   PALMAS_GPIO_SET_DATA_OUT, BIT(offset));
+   ret = palmas_gpio_write(palmas, PALMAS_GPIO_SET_DATA_OUT,
+   offset, BIT(offset % 8));
else
-   ret = palmas_write(palmas, PALMAS_GPIO_BASE,
-   PALMAS_GPIO_CLEAR_DATA_OUT, BIT(offset));
+   ret = palmas_gpio_write(palmas, PALMAS_GPIO_CLEAR_DATA_OUT,
+   offset, BIT(offset % 8));
if (ret < 0)
dev_err(gc->dev, "%s write failed, err = %d\n",
(value) ? "GPIO_SET_DATA_OUT" : "GPIO_CLEAR_DATA_OUT",
@@ -80,8 +110,8 @@ static int palmas_gpio_output(struct gpio_chip *gc, unsigned 
offset,
/* Set the initial value */
palmas_gpio_set(gc, offset, value);
 
-   ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE,
-   PALMAS_GPIO_DATA_DIR, BIT(offset), BIT(offset));
+   ret = palmas_gpio_update_bits(palmas, PALMAS_GPIO_DATA_DIR,
+   offset, 1 << (offset % 8), 1 << (offset % 8));
if (ret < 0)
dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret);
return ret;
@@ -93,8 +123,8 @@ static int palmas_gpio_input(struct gpio_chip *gc, unsigned 
offset)
struct palmas *palmas = pg->palmas;
int ret;
 
-   ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE,
-   PALMAS_GPIO_DATA_DIR, BIT(offset), 0);
+   ret =  palmas_gpio_update_bits(palmas, PALMAS_GPIO_DATA_DIR,
+   offset, 1 << (offset % 8), 0);
if (ret < 0)
dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret);
return ret;
@@ -108,7 +138,21 @@ static int palmas_gpio_to_irq(struct gpio_chip *gc, 
unsigned offset)
return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset);
 }
 
-static int palmas_gpio_probe(struct platform_device *pdev)
+static int palmas_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
+   unsigned debounce)
+{
+   struct palmas_gpio *palmas_gpio = to_palmas_gpio(gc);
+   struct palmas *palmas = palmas_gpio->palmas;
+   unsigned int data = 0;
+
+   if (debounce)
+   data = 0xff;
+
+   retu