From: Gordan Markus <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Gordan Markuš"
<gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH v2 1/2] input: keyboard: Add devicetree support for lm8333
Date: Wed, 2 Nov 2016 22:43:48 +0100 [thread overview]
Message-ID: <1478123029-18291-1-git-send-email-gordan.markus@gmail.com> (raw)
This adds LM8333 devicetree parsing for the keypad part.
Optional properties to specify the keypad driver active
time and debounce time.
Signed-off-by: Gordan Markuš <gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/input/keyboard/lm8333.c | 54 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index c717e8f..f1508c5 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -128,6 +128,51 @@ static irqreturn_t lm8333_irq_thread(int irq, void *data)
return IRQ_HANDLED;
}
+static struct lm8333_platform_data *lm8333_parse_dt(struct i2c_client *client)
+{
+ struct device_node *np = client->dev.of_node;
+ struct lm8333_platform_data *pdata;
+ struct matrix_keymap_data *matrix_data;
+ u32 *keymap;
+ u32 prop;
+ int len;
+
+ pdata = devm_kzalloc(&client->dev, sizeof(pdata),
+ GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ if (!of_property_read_u32(np, "ti,active-time-ms", &prop))
+ pdata->active_time = prop;
+
+ if (!of_property_read_u32(np, "debounce-delay-ms", &prop))
+ pdata->debounce_time = prop;
+ else
+ pdata->debounce_time = 10;
+
+ if (!of_get_property(np, "linux,keymap", &prop))
+ len = prop / sizeof(u32);
+ else {
+ dev_err(&client->dev, "no keymap data defined\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ keymap = devm_kzalloc(&client->dev, sizeof(len) * len, GFP_KERNEL);
+ matrix_data = devm_kzalloc(&client->dev, sizeof(matrix_data),
+ GFP_KERNEL);
+ if (!matrix_data || !keymap)
+ return ERR_PTR(-ENOMEM);
+
+ if (!of_property_read_u32_array(np, "linux,keymap", keymap, len)) {
+ matrix_data->keymap_size = len;
+ matrix_data->keymap = keymap;
+
+ pdata->matrix_data = matrix_data;
+ }
+
+ return pdata;
+}
+
static int lm8333_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -137,6 +182,15 @@ static int lm8333_probe(struct i2c_client *client,
struct input_dev *input;
int err, active_time;
+ if (!pdata && client->dev.of_node) {
+ pdata = lm8333_parse_dt(client);
+ if (IS_ERR(pdata)) {
+ dev_err(&client->dev,
+ "could not parse configuration\n");
+ return IS_ERR(pdata);
+ }
+ }
+
if (!pdata)
return -EINVAL;
--
1.9.1
--
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
next reply other threads:[~2016-11-02 21:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 21:43 Gordan Markus [this message]
[not found] ` <1478123029-18291-1-git-send-email-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-02 21:43 ` [PATCH v2 2/2] input: keyboard: Add lm8333 devicetree bindings Gordan Markus
[not found] ` <1478123029-18291-2-git-send-email-gordan.markus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-10 0:53 ` Rob Herring
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=1478123029-18291-1-git-send-email-gordan.markus@gmail.com \
--to=gordan.markus-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh-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 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).