diff mbox

[1/1] Input: samsung-keypad: Add support for pinctrl

Message ID 1354789126-28304-1-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Kamat Dec. 6, 2012, 10:18 a.m. UTC
Added support for pin configuration using pinctrl subsystem
to the Samsung keypad driver.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 .../devicetree/bindings/input/samsung-keypad.txt   |   12 ++++++++++++
 drivers/input/keyboard/samsung-keypad.c            |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

Comments

Linus Walleij Dec. 6, 2012, 7:29 p.m. UTC | #1
On Thu, Dec 6, 2012 at 11:18 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:

> Added support for pin configuration using pinctrl subsystem
> to the Samsung keypad driver.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

So we've tried to add some pinctrl default fetchers into the input drivers
and Dmitry don't like sprinking calls like that all over the drivers so
we're trying to come up with some other scheme.

I sent one patch that tried to pick the pinctrl handles by using
notifiers but it doesn't work basically due to probe deferral.

So next approach will be to try and modify the device core to
fetch default pinctrl states.

You might try to lobby Dmitry to accepting this in the meantime,
as a stepping stone. (I'm OK with it, Acked-by).

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sachin Kamat Dec. 31, 2012, 3:45 a.m. UTC | #2
Hi Dmitry,

On 7 December 2012 00:59, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Dec 6, 2012 at 11:18 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>
>> Added support for pin configuration using pinctrl subsystem
>> to the Samsung keypad driver.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>
> So we've tried to add some pinctrl default fetchers into the input drivers
> and Dmitry don't like sprinking calls like that all over the drivers so
> we're trying to come up with some other scheme.
>
> I sent one patch that tried to pick the pinctrl handles by using
> notifiers but it doesn't work basically due to probe deferral.
>
> So next approach will be to try and modify the device core to
> fetch default pinctrl states.
>
> You might try to lobby Dmitry to accepting this in the meantime,
> as a stepping stone. (I'm OK with it, Acked-by).

What is your opinion about this patch? Can you please accept this
until we have some common scheme to handle this.

>
> Yours,
> Linus Walleij
Dmitry Torokhov Dec. 31, 2012, 8:20 p.m. UTC | #3
Hi Sachin,

On Mon, Dec 31, 2012 at 09:15:38AM +0530, Sachin Kamat wrote:
> Hi Dmitry,
> 
> On 7 December 2012 00:59, Linus Walleij <linus.walleij@linaro.org> wrote:
> > On Thu, Dec 6, 2012 at 11:18 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> >
> >> Added support for pin configuration using pinctrl subsystem
> >> to the Samsung keypad driver.
> >>
> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> >
> > So we've tried to add some pinctrl default fetchers into the input drivers
> > and Dmitry don't like sprinking calls like that all over the drivers so
> > we're trying to come up with some other scheme.
> >
> > I sent one patch that tried to pick the pinctrl handles by using
> > notifiers but it doesn't work basically due to probe deferral.
> >
> > So next approach will be to try and modify the device core to
> > fetch default pinctrl states.
> >
> > You might try to lobby Dmitry to accepting this in the meantime,
> > as a stepping stone. (I'm OK with it, Acked-by).
> 
> What is your opinion about this patch? Can you please accept this
> until we have some common scheme to handle this.

I'd rather we wait for the device core patch to get in (I believe Greg
KH was basically OK with it so 3.9 is the current target) and you
carried this patch locally for now.

Thanks.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/input/samsung-keypad.txt b/Documentation/devicetree/bindings/input/samsung-keypad.txt
index ce3e394..616cfeb 100644
--- a/Documentation/devicetree/bindings/input/samsung-keypad.txt
+++ b/Documentation/devicetree/bindings/input/samsung-keypad.txt
@@ -25,6 +25,7 @@  Required Board Specific Properties:
 - samsung,keypad-num-columns: Number of column lines connected to the
   keypad controller.
 
+- Samsung GPIO variant (deprecated):
 - row-gpios: List of gpios used as row lines. The gpio specifier for
   this property depends on the gpio controller to which these row lines
   are connected.
@@ -33,6 +34,10 @@  Required Board Specific Properties:
   this property depends on the gpio controller to which these column
   lines are connected.
 
+- Pinctrl variant (preferred, if available):
+  - pinctrl-0: Pin control group to be used for this controller.
+  - pinctrl-names: Should contain only one value - "default".
+
 - Keys represented as child nodes: Each key connected to the keypad
   controller is represented as a child node to the keypad controller
   device node and should include the following properties.
@@ -56,6 +61,7 @@  Example:
 		linux,input-no-autorepeat;
 		linux,input-wakeup;
 
+		/* Samsung GPIO variant begins here */
 		row-gpios = <&gpx2 0 3 3 0
 			     &gpx2 1 3 3 0>;
 
@@ -67,6 +73,12 @@  Example:
 			     &gpx1 5 3 0 0
 			     &gpx1 6 3 0 0
 			     &gpx1 7 3 0 0>;
+		/* Samsung GPIO variant ends here */
+
+		/* Pinctrl variant begins here */
+		pinctrl-0 = <&keypad_row0 &keypad_col0>;
+		pinctrl-names = "default";
+		/* Pinctrl variant ends here */
 
 		key_1 {
 			keypad,row = <0>;
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 22e357b..18770e4 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -27,6 +27,7 @@ 
 #include <linux/of_gpio.h>
 #include <linux/sched.h>
 #include <linux/input/samsung-keypad.h>
+#include <linux/pinctrl/consumer.h>
 
 #define SAMSUNG_KEYIFCON			0x00
 #define SAMSUNG_KEYIFSTSCLR			0x04
@@ -79,6 +80,7 @@  struct samsung_keypad {
 	unsigned int rows;
 	unsigned int cols;
 	unsigned int row_state[SAMSUNG_MAX_COLS];
+	struct pinctrl *pctrl;
 #ifdef CONFIG_OF
 	int row_gpios[SAMSUNG_MAX_ROWS];
 	int col_gpios[SAMSUNG_MAX_COLS];
@@ -424,9 +426,12 @@  static int samsung_keypad_probe(struct platform_device *pdev)
 	keypad->stopped = true;
 	init_waitqueue_head(&keypad->wait);
 
+	keypad->pctrl = devm_pinctrl_get_select_default(&pdev->dev);
+
 	if (pdev->dev.of_node) {
 #ifdef CONFIG_OF
-		samsung_keypad_parse_dt_gpio(&pdev->dev, keypad);
+		if (IS_ERR(keypad->pctrl))
+			samsung_keypad_parse_dt_gpio(&pdev->dev, keypad);
 		keypad->type = of_device_is_compatible(pdev->dev.of_node,
 					"samsung,s5pv210-keypad");
 #endif