All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Guido Martínez" <guido-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
To: Dmitry Torokhov
	<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Ezequiel García"
	<ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [RFC/PATCH 1/3] drivers: input: keyboard: adp5589: add DT support
Date: Mon, 2 Jun 2014 12:36:45 -0300	[thread overview]
Message-ID: <20140602153645.GA26073@fox> (raw)
In-Reply-To: <20140518204009.GB13276-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

Hi Dmitry, sorry for the terribly late reply.

On Sun, May 18, 2014 at 01:40:09PM -0700, Dmitry Torokhov wrote:
> Hi Guido,
> 
> On Wed, May 07, 2014 at 10:00:42AM -0300, Guido Martínez wrote:
> > Add DT support for the Analog ADP5589 matrix keypad decoding functions.
> > 
> > Signed-off-by: Guido Martínez <guido-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
> > ---
> >  drivers/input/keyboard/adp5589-keys.c | 207 +++++++++++++++++++++++++++++++++-
> >  1 file changed, 206 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
> > index 6329549..2b232c0 100644
> > --- a/drivers/input/keyboard/adp5589-keys.c
> > +++ b/drivers/input/keyboard/adp5589-keys.c
> > @@ -18,7 +18,10 @@
> >  #include <linux/i2c.h>
> >  #include <linux/gpio.h>
> >  #include <linux/slab.h>
> > +#include <linux/of.h>
> > +#include <linux/err.h>
> >  
> > +#include <linux/input/matrix_keypad.h>
> >  #include <linux/input/adp5589.h>
> >  
> >  /* ADP5589/ADP5585 Common Registers */
> > @@ -246,6 +249,14 @@ struct adp5589_kpad {
> >  #endif
> >  };
> >  
> > +static struct of_device_id adp5589_of_match[] = {
> > +	{
> > +		.compatible = "adi,adp5589",
> > +		.data = (void *)ADP5589
> > +	},
> > +	{ },
> > +};
> > +
> >  /*
> >   *  ADP5589 / ADP5585 derivative / variant handling
> >   */
> > @@ -858,6 +869,188 @@ static void adp5589_report_switch_state(struct adp5589_kpad *kpad)
> >  	input_sync(kpad->input);
> >  }
> >  
> > +#ifdef CONFIG_OF
> > +static int adp5589_key(int row, int col)
> > +{
> > +	return col + row * 11;
> > +}
> > +
> > +static int adp5589_dt_read_keymap(struct device *dev,
> > +				  struct adp5589_kpad_platform_data *pdata,
> > +				  const struct device_node *node)
> > +{
> > +	int i;
> > +	const u32 *dt_keymap;
> > +	unsigned short *keymap;
> > +	int keymap_len;
> > +
> > +	dt_keymap = of_get_property(node, "linux,keymap", &keymap_len);
> > +	if (!dt_keymap) {
> > +		dev_err(dev, "missing dt keymap\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	if (keymap_len % sizeof(u32)) {
> > +		dev_err(dev, "malformed keymap (len=%i)\n", keymap_len);
> > +		return -EINVAL;
> > +	}
> > +
> > +	keymap_len /= sizeof(u32);
> > +
> > +	keymap = devm_kzalloc(dev, ADP5589_KEYMAPSIZE * sizeof(u32),
> > +			      GFP_KERNEL);
> > +	if (!keymap)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < keymap_len; i++) {
> > +		u32 val;
> > +		u16 key;
> > +		u8 row, col;
> > +
> > +		val = be32_to_cpup(&dt_keymap[i]);
> > +
> > +		row = KEY_ROW(val);
> > +		col = KEY_COL(val);
> > +		key = KEY_VAL(val);
> > +
> > +		if (row > ADP5589_MAX_ROW_NUM) {
> > +			dev_err(dev, "invalid row number (%i)\n", row);
> > +			return -EINVAL;
> > +		}
> > +
> > +		if (col > ADP5589_MAX_COL_NUM) {
> > +			dev_err(dev, "invalid column number (%i)\n", col);
> > +			return -EINVAL;
> > +		}
> > +
> > +		pdata->keypad_en_mask |= ADP_ROW(row);
> > +		pdata->keypad_en_mask |= ADP_COL(col);
> > +
> > +		keymap[adp5589_key(row, col)] = key;
> > +	}
> > +
> > +	pdata->keymap = keymap;
> > +	pdata->keymapsize = ADP5589_KEYMAPSIZE;
> 
> I was wondering if we could also move non-DT variant to matrix-keypad
> infrastructure and use matrix_keypad_build_keymap and friends to handle
> this uniformly.

Seems like a good idea, I'll look into it.

Thanks for reviewing this!

-- 
Guido Martínez, VanguardiaSur
www.vanguardiasur.com.ar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "Guido Martínez" <guido@vanguardiasur.com.ar>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: robh+dt@kernel.org, devicetree@vger.kernel.org,
	"Ezequiel García" <ezequiel@vanguardiasur.com.ar>,
	linux-input@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC/PATCH 1/3] drivers: input: keyboard: adp5589: add DT support
Date: Mon, 2 Jun 2014 12:36:45 -0300	[thread overview]
Message-ID: <20140602153645.GA26073@fox> (raw)
In-Reply-To: <20140518204009.GB13276@core.coreip.homeip.net>

Hi Dmitry, sorry for the terribly late reply.

On Sun, May 18, 2014 at 01:40:09PM -0700, Dmitry Torokhov wrote:
> Hi Guido,
> 
> On Wed, May 07, 2014 at 10:00:42AM -0300, Guido Martínez wrote:
> > Add DT support for the Analog ADP5589 matrix keypad decoding functions.
> > 
> > Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>
> > ---
> >  drivers/input/keyboard/adp5589-keys.c | 207 +++++++++++++++++++++++++++++++++-
> >  1 file changed, 206 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
> > index 6329549..2b232c0 100644
> > --- a/drivers/input/keyboard/adp5589-keys.c
> > +++ b/drivers/input/keyboard/adp5589-keys.c
> > @@ -18,7 +18,10 @@
> >  #include <linux/i2c.h>
> >  #include <linux/gpio.h>
> >  #include <linux/slab.h>
> > +#include <linux/of.h>
> > +#include <linux/err.h>
> >  
> > +#include <linux/input/matrix_keypad.h>
> >  #include <linux/input/adp5589.h>
> >  
> >  /* ADP5589/ADP5585 Common Registers */
> > @@ -246,6 +249,14 @@ struct adp5589_kpad {
> >  #endif
> >  };
> >  
> > +static struct of_device_id adp5589_of_match[] = {
> > +	{
> > +		.compatible = "adi,adp5589",
> > +		.data = (void *)ADP5589
> > +	},
> > +	{ },
> > +};
> > +
> >  /*
> >   *  ADP5589 / ADP5585 derivative / variant handling
> >   */
> > @@ -858,6 +869,188 @@ static void adp5589_report_switch_state(struct adp5589_kpad *kpad)
> >  	input_sync(kpad->input);
> >  }
> >  
> > +#ifdef CONFIG_OF
> > +static int adp5589_key(int row, int col)
> > +{
> > +	return col + row * 11;
> > +}
> > +
> > +static int adp5589_dt_read_keymap(struct device *dev,
> > +				  struct adp5589_kpad_platform_data *pdata,
> > +				  const struct device_node *node)
> > +{
> > +	int i;
> > +	const u32 *dt_keymap;
> > +	unsigned short *keymap;
> > +	int keymap_len;
> > +
> > +	dt_keymap = of_get_property(node, "linux,keymap", &keymap_len);
> > +	if (!dt_keymap) {
> > +		dev_err(dev, "missing dt keymap\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	if (keymap_len % sizeof(u32)) {
> > +		dev_err(dev, "malformed keymap (len=%i)\n", keymap_len);
> > +		return -EINVAL;
> > +	}
> > +
> > +	keymap_len /= sizeof(u32);
> > +
> > +	keymap = devm_kzalloc(dev, ADP5589_KEYMAPSIZE * sizeof(u32),
> > +			      GFP_KERNEL);
> > +	if (!keymap)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < keymap_len; i++) {
> > +		u32 val;
> > +		u16 key;
> > +		u8 row, col;
> > +
> > +		val = be32_to_cpup(&dt_keymap[i]);
> > +
> > +		row = KEY_ROW(val);
> > +		col = KEY_COL(val);
> > +		key = KEY_VAL(val);
> > +
> > +		if (row > ADP5589_MAX_ROW_NUM) {
> > +			dev_err(dev, "invalid row number (%i)\n", row);
> > +			return -EINVAL;
> > +		}
> > +
> > +		if (col > ADP5589_MAX_COL_NUM) {
> > +			dev_err(dev, "invalid column number (%i)\n", col);
> > +			return -EINVAL;
> > +		}
> > +
> > +		pdata->keypad_en_mask |= ADP_ROW(row);
> > +		pdata->keypad_en_mask |= ADP_COL(col);
> > +
> > +		keymap[adp5589_key(row, col)] = key;
> > +	}
> > +
> > +	pdata->keymap = keymap;
> > +	pdata->keymapsize = ADP5589_KEYMAPSIZE;
> 
> I was wondering if we could also move non-DT variant to matrix-keypad
> infrastructure and use matrix_keypad_build_keymap and friends to handle
> this uniformly.

Seems like a good idea, I'll look into it.

Thanks for reviewing this!

-- 
Guido Martínez, VanguardiaSur
www.vanguardiasur.com.ar

  parent reply	other threads:[~2014-06-02 15:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 13:00 [RFC/PATCH 0/3] add adp5589 dt support Guido Martínez
2014-05-07 13:00 ` [RFC/PATCH 1/3] drivers: input: keyboard: adp5589: add DT support Guido Martínez
2014-05-18 20:40   ` Dmitry Torokhov
2014-05-18 20:40     ` Dmitry Torokhov
     [not found]     ` <20140518204009.GB13276-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2014-06-02 15:36       ` Guido Martínez [this message]
2014-06-02 15:36         ` Guido Martínez
2014-05-07 13:00 ` [RFC/PATCH 2/3] DT: input: adp5589: add adp5589 include file Guido Martínez
2014-05-07 13:00 ` [RFC/PATCH 3/3] DT: input: adp5589: add binding documentation Guido Martínez
2014-05-07 13:00   ` Guido Martínez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140602153645.GA26073@fox \
    --to=guido-30ulvvutt6g51wmpkgsgjgyuob5fgqpz@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.