From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Viresh Kumar <viresh.kumar@st.com>
Cc: swarren@nvidia.com, spear-devel@list.st.com,
viresh.linux@gmail.com, devicetree-discuss@lists.ozlabs.org,
olof@lixom.net, linux-input@vger.kernel.org, sr@denx.de
Subject: Re: [PATCH V3 2/2] Input: spear-keyboard: add device tree bindings
Date: Tue, 8 May 2012 22:28:28 -0700 [thread overview]
Message-ID: <20120509052828.GD10514@core.coreip.homeip.net> (raw)
In-Reply-To: <eebfde0a1511204cab203fa18efe6264abe00486.1333009670.git.viresh.kumar@st.com>
Hi Viresh,
On Thu, Mar 29, 2012 at 02:03:27PM +0530, Viresh Kumar wrote:
>
> - matrix_keypad_build_keymap(keymap, ROW_SHIFT,
> - input_dev->keycode, input_dev->keybit);
> + if (np) {
> + error = matrix_keypad_of_build_keymap(input_dev, ROW_SHIFT,
> + "linux,keymap");
> + if (error) {
> + dev_err(&pdev->dev, "OF: failed to build keymap\n");
> + goto err_put_clk;
> + }
> + } else {
> + matrix_keypad_build_keymap(pdata->keymap, ROW_SHIFT,
> + input_dev->keycode, input_dev->keybit);
> + }
Now that I got matrix_keypad_build_keymap() also handle DT case, how
about the patch below?
Thanks.
--
Dmitry
Input: spear-keyboard - add device tree bindings
From: Viresh Kumar <viresh.kumar@st.com>
This adds simple DT bindings for spear-keyboard controller.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/keyboard/spear-keyboard.c | 71 ++++++++++++++++++++++++-------
1 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index e83cab2..6f287f7 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -19,6 +19,7 @@
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeup.h>
#include <linux/slab.h>
@@ -63,6 +64,7 @@ struct spear_kbd {
unsigned int mode;
unsigned short last_key;
unsigned short keycodes[NUM_ROWS * NUM_COLS];
+ bool rep;
};
static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id)
@@ -138,27 +140,49 @@ static void spear_kbd_close(struct input_dev *dev)
kbd->last_key = KEY_RESERVED;
}
-static int __devinit spear_kbd_probe(struct platform_device *pdev)
+#ifdef CONFIG_OF
+static int __devinit spear_kbd_parse_dt(struct platform_device *pdev,
+ struct spear_kbd *kbd)
{
- const struct kbd_platform_data *pdata = pdev->dev.platform_data;
- const struct matrix_keymap_data *keymap;
- struct spear_kbd *kbd;
- struct input_dev *input_dev;
- struct resource *res;
- int irq;
+ struct device_node *np = pdev->dev.of_node;
int error;
+ u32 val;
- if (!pdata) {
- dev_err(&pdev->dev, "Invalid platform data\n");
+ if (!np) {
+ dev_err(&pdev->dev, "Missing DT data\n");
return -EINVAL;
}
- keymap = pdata->keymap;
- if (!keymap) {
- dev_err(&pdev->dev, "no keymap defined\n");
- return -EINVAL;
+ if (of_property_read_bool(np, "autorepeat"))
+ kbd->rep = true;
+
+ error = of_property_read_u32(np, "st,mode", &val);
+ if (error) {
+ dev_err(&pdev->dev, "DT: Invalid or missing mode\n");
+ return error;
}
+ kbd->mode = val;
+ return 0;
+}
+#else
+static inline int spear_kbd_parse_dt(struct platform_device *pdev,
+ struct spear_kbd *kbd)
+{
+ return -ENOSYS;
+}
+#endif
+
+static int __devinit spear_kbd_probe(struct platform_device *pdev)
+{
+ struct kbd_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ const struct matrix_keymap_data *keymap = pdata ? pdata->keymap : NULL;
+ struct spear_kbd *kbd;
+ struct input_dev *input_dev;
+ struct resource *res;
+ int irq;
+ int error;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "no keyboard resource defined\n");
@@ -181,7 +205,15 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
kbd->input = input_dev;
kbd->irq = irq;
- kbd->mode = pdata->mode;
+
+ if (!pdata) {
+ error = spear_kbd_parse_dt(pdev, kbd);
+ if (error)
+ goto err_free_mem;
+ } else {
+ kbd->mode = pdata->mode;
+ kbd->rep = pdata->rep;
+ }
kbd->res = request_mem_region(res->start, resource_size(res),
pdev->name);
@@ -221,7 +253,7 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
goto err_put_clk;
}
- if (pdata->rep)
+ if (kbd->rep)
__set_bit(EV_REP, input_dev->evbit);
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
@@ -318,6 +350,14 @@ static int spear_kbd_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume);
+#ifdef CONFIG_OF
+static const struct of_device_id spear_kbd_id_table[] = {
+ { .compatible = "st,spear300-kbd" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, spear_kbd_id_table);
+#endif
+
static struct platform_driver spear_kbd_driver = {
.probe = spear_kbd_probe,
.remove = __devexit_p(spear_kbd_remove),
@@ -325,6 +365,7 @@ static struct platform_driver spear_kbd_driver = {
.name = "keyboard",
.owner = THIS_MODULE,
.pm = &spear_kbd_pm_ops,
+ .of_match_table = of_match_ptr(spear_kbd_id_table),
},
};
module_platform_driver(spear_kbd_driver);
next prev parent reply other threads:[~2012-05-09 5:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 8:33 [PATCH V3 0/2] Input: Add matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-29 8:33 ` [PATCH V3 1/2] Input: of_keymap: Introduce matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-29 15:44 ` Stephen Warren
2012-03-29 16:31 ` viresh kumar
2012-03-30 3:38 ` Viresh Kumar
2012-03-29 8:33 ` [PATCH V3 2/2] Input: spear-keyboard: add device tree bindings Viresh Kumar
2012-05-09 5:28 ` Dmitry Torokhov [this message]
2012-05-09 6:53 ` Viresh Kumar
2012-05-15 6:54 ` viresh kumar
2012-05-17 21:31 ` Dmitry Torokhov
2012-03-30 3:33 ` [PATCH v4 1/2] Input: of_keymap: Introduce matrix_keypad_of_build_keymap() Viresh Kumar
2012-03-30 3:55 ` Viresh Kumar
2012-03-30 3:40 ` [PATCH V4 Resend " Viresh Kumar
2012-03-30 18:45 ` Stephen Warren
2012-04-02 3:33 ` Viresh Kumar
2012-04-02 4:01 ` [PATCH] fixup! " Viresh Kumar
2012-04-05 0:45 ` Dmitry Torokhov
2012-04-05 3:52 ` Viresh Kumar
2012-04-17 11:32 ` Viresh Kumar
-- strict thread matches above, loose matches on Subject: below --
2012-03-27 5:38 [PATCH V2 1/2] " Viresh Kumar
[not found] ` <4aba6f2cd9f050f419660555bdb661915c1be9b1.1332826100.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-03-28 9:54 ` [PATCH V3 2/2] Input: spear-keyboard: add device tree bindings Viresh Kumar
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=20120509052828.GD10514@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-input@vger.kernel.org \
--cc=olof@lixom.net \
--cc=spear-devel@list.st.com \
--cc=sr@denx.de \
--cc=swarren@nvidia.com \
--cc=viresh.kumar@st.com \
--cc=viresh.linux@gmail.com \
/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).