Skip to contentSkip to conversation

input: pmic8xxx-keypad: Add row and column gpio configuration

PATCH In review Anirudh Ghayal 3 participants 7 messages May 13, 2011 – May 22, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 input: pmic8xxx-keypad: Add row and column gpio configuration

---
 drivers/input/keyboard/pmic8xxx-keypad.c |   58 ++++++++++++++++++++++++++++++
 include/linux/input/pmic8xxx-keypad.h    |    2 +
 2 files changed, 60 insertions(+), 0 deletions(-)
drivers/input/keyboard/pmic8xxx-keypad.c +58 -0
index 0229325..40b02ae 100644
@@ -21,6 +21,7 @@
 #include <linux/mutex.h>
 
 #include <linux/mfd/pm8xxx/core.h>
+#include <linux/mfd/pm8xxx/gpio.h>
 #include <linux/input/pmic8xxx-keypad.h>
 
 #define PM8XXX_MAX_ROWS		18
@@ -446,6 +447,27 @@ static int __devinit pmic8xxx_kpd_init(struct pmic8xxx_kp *kp)
 
 }
 
+static int  __devinit pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios,
+			struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config)
+{
+	int	rc, i;
+
+	if (gpio_start < 0 || num_gpios < 0)
+		return -EINVAL;
+
+	for (i = 0; i < num_gpios; i++) {
+		rc = pm8xxx_gpio_config(gpio_start + i, gpio_config);
+		if (rc) {
+			dev_err(kp->dev, "%s: FAIL pm8xxx_gpio_config():"
+					"for PM GPIO [%d] rc=%d.\n",
+					__func__, gpio_start + i, rc);
+			return rc;
+		}
+	 }
+
+	return 0;
+}
+
 static int pmic8xxx_kp_enable(struct pmic8xxx_kp *kp)
 {
 	int rc;
@@ -504,6 +526,27 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
 	int rc;
 	u8 ctrl_val;
 
+	struct pm_gpio kypd_drv = {
+		.direction	= PM_GPIO_DIR_OUT,
+		.output_buffer	= PM_GPIO_OUT_BUF_OPEN_DRAIN,
+		.output_value	= 0,
+		.pull		= PM_GPIO_PULL_NO,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_LOW,
+		.function	= PM_GPIO_FUNC_1,
+		.inv_int_pol	= 1,
+	};
+
+	struct pm_gpio kypd_sns = {
+		.direction	= PM_GPIO_DIR_IN,
+		.pull		= PM_GPIO_PULL_UP_31P5,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_NO,
+		.function	= PM_GPIO_FUNC_NORMAL,
+		.inv_int_pol	= 1,
+	};
+
+
 	if (!pdata || !pdata->num_cols || !pdata->num_rows ||
 		pdata->num_cols > PM8XXX_MAX_COLS ||
 		pdata->num_rows > PM8XXX_MAX_ROWS ||
@@ -609,6 +652,20 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
 		goto err_get_irq;
 	}
 
+	rc = pmic8xxx_kp_config_gpio(pdata->cols_gpio_start,
+					pdata->num_cols, kp, &kypd_sns);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "unable to configure keypad sense lines\n");
+		goto err_gpio_config;
+	}
+
+	rc = pmic8xxx_kp_config_gpio(pdata->rows_gpio_start,
+					pdata->num_rows, kp, &kypd_drv);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "unable to configure keypad drive lines\n");
+		goto err_gpio_config;
+	}
+
 	rc = request_any_context_irq(kp->key_sense_irq, pmic8xxx_kp_irq,
 				 IRQF_TRIGGER_RISING, "pmic-keypad", kp);
 	if (rc < 0) {
@@ -645,6 +702,7 @@ err_pmic_reg_read:
 	free_irq(kp->key_stuck_irq, NULL);
 err_req_stuck_irq:
 	free_irq(kp->key_sense_irq, NULL);
+err_gpio_config:
 err_get_irq:
 	input_free_device(kp->input);
 err_alloc_device:
include/linux/input/pmic8xxx-keypad.h +2 -0
index fc2ac4c..5f1e2f9 100644
@@ -38,6 +38,8 @@ struct pm8xxx_keypad_platform_data {
 
 	unsigned int num_cols;
 	unsigned int num_rows;
+	unsigned int rows_gpio_start;
+	unsigned int cols_gpio_start;
 
 	unsigned int debounce_ms;
 	unsigned int scan_delay_ms;
Signature · 1 line
Sent by a consultant of the Qualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw

PATCH v3 2/2 input: pmic8xxx_pwrkey: Add support for power key

From: Trilok Soni <[email protected]>

Add support for PMIC8XXX power key driven over dedicated KYPD_PWR_N pin.

---
 drivers/input/misc/Kconfig            |   11 ++
 drivers/input/misc/Makefile           |    1 +
 drivers/input/misc/pmic8xxx-pwrkey.c  |  231 +++++++++++++++++++++++++++++++++
 include/linux/input/pmic8xxx-pwrkey.h |   31 +++++
 4 files changed, 274 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/pmic8xxx-pwrkey.c
 create mode 100644 include/linux/input/pmic8xxx-pwrkey.h
drivers/input/misc/Kconfig +11 -0
index f9cf088..45dc6aa 100644
@@ -330,6 +330,17 @@ config INPUT_PWM_BEEPER
 	  To compile this driver as a module, choose M here: the module will be
 	  called pwm-beeper.
 
+config INPUT_PMIC8XXX_PWRKEY
+	tristate "PMIC8XXX power key support"
+	depends on MFD_PM8XXX
+	help
+	  Say Y here if you want support for the PMIC8XXX power key.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called pmic8xxx-pwrkey.
+
 config INPUT_GPIO_ROTARY_ENCODER
 	tristate "Rotary encoders connected to GPIO pins"
 	depends on GPIOLIB && GENERIC_GPIO
drivers/input/misc/Makefile +1 -0
index e3f7984..38efb2c 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_INPUT_PCF8574)		+= pcf8574_keypad.o
 obj-$(CONFIG_INPUT_PCSPKR)		+= pcspkr.o
 obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
+obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)	+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
drivers/input/misc/pmic8xxx-pwrkey.c new file +231 -0

231 lines not on this page · raw message

include/linux/input/pmic8xxx-pwrkey.h new file +31 -0
new file mode 100644
index 0000000..6d2974e
@@ -0,0 +1,31 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __PMIC8XXX_PWRKEY_H__
+#define __PMIC8XXX_PWRKEY_H__
+
+#define PM8XXX_PWRKEY_DEV_NAME "pm8xxx-pwrkey"
+
+/**
+ * struct pm8xxx_pwrkey_platform_data - platform data for pwrkey driver
+ * @pull up:  power on register control for pull up/down configuration
+ * @kpd_trigger_delay_us: time delay for power key state change interrupt
+ *                  trigger.
+ * @wakeup: configure power key as wakeup source
+ */
+struct pm8xxx_pwrkey_platform_data  {
+	bool pull_up;
+	u32  kpd_trigger_delay_us;
+	u32  wakeup;
+};
+
+#endif /* __PMIC8XXX_PWRKEY_H__ */
Signature · 1 line
Sent by a consultant of the Qualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
maintainer Acked-by on v3 2/2
#2 lore raw

Re: [PATCH V3 2/2] input: pmic8xxx_pwrkey: Add support for power key

Quoted 8 lines · Anirudh Ghayal

From: Trilok Soni <[email protected]>

Add support for PMIC8XXX power key driven over dedicated KYPD_PWR_N pin.

Anirudh,

Looks great, thank you for making changes. Please feel free to merge with the rest of the pmic8xxx MFD patches. I assume they will go through MFD tree, right?

Thanks.

Signature · 1 line
Dmitry
maintainer Acked-by on v3 1/2
#5 lore raw
In reply to Anirudh Ghayal
Quoted 2 lines · Anirudh Ghayal
Quoted 118 lines
---
 drivers/input/keyboard/pmic8xxx-keypad.c |   58 ++++++++++++++++++++++++++++++
 include/linux/input/pmic8xxx-keypad.h    |    2 +
 2 files changed, 60 insertions(+), 0 deletions(-)
drivers/input/keyboard/pmic8xxx-keypad.c +58 -0
index 0229325..40b02ae 100644
@@ -21,6 +21,7 @@
 #include <linux/mutex.h>
 
 #include <linux/mfd/pm8xxx/core.h>
+#include <linux/mfd/pm8xxx/gpio.h>
 #include <linux/input/pmic8xxx-keypad.h>
 
 #define PM8XXX_MAX_ROWS		18
@@ -446,6 +447,27 @@ static int __devinit pmic8xxx_kpd_init(struct pmic8xxx_kp *kp)
 
 }
 
+static int  __devinit pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios,
+			struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config)
+{
+	int	rc, i;
+
+	if (gpio_start < 0 || num_gpios < 0)
+		return -EINVAL;
+
+	for (i = 0; i < num_gpios; i++) {
+		rc = pm8xxx_gpio_config(gpio_start + i, gpio_config);
+		if (rc) {
+			dev_err(kp->dev, "%s: FAIL pm8xxx_gpio_config():"
+					"for PM GPIO [%d] rc=%d.\n",
+					__func__, gpio_start + i, rc);
+			return rc;
+		}
+	 }
+
+	return 0;
+}
+
 static int pmic8xxx_kp_enable(struct pmic8xxx_kp *kp)
 {
 	int rc;
@@ -504,6 +526,27 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
 	int rc;
 	u8 ctrl_val;
 
+	struct pm_gpio kypd_drv = {
+		.direction	= PM_GPIO_DIR_OUT,
+		.output_buffer	= PM_GPIO_OUT_BUF_OPEN_DRAIN,
+		.output_value	= 0,
+		.pull		= PM_GPIO_PULL_NO,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_LOW,
+		.function	= PM_GPIO_FUNC_1,
+		.inv_int_pol	= 1,
+	};
+
+	struct pm_gpio kypd_sns = {
+		.direction	= PM_GPIO_DIR_IN,
+		.pull		= PM_GPIO_PULL_UP_31P5,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_NO,
+		.function	= PM_GPIO_FUNC_NORMAL,
+		.inv_int_pol	= 1,
+	};
+
+
 	if (!pdata || !pdata->num_cols || !pdata->num_rows ||
 		pdata->num_cols > PM8XXX_MAX_COLS ||
 		pdata->num_rows > PM8XXX_MAX_ROWS ||
@@ -609,6 +652,20 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
 		goto err_get_irq;
 	}
 
+	rc = pmic8xxx_kp_config_gpio(pdata->cols_gpio_start,
+					pdata->num_cols, kp, &kypd_sns);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "unable to configure keypad sense lines\n");
+		goto err_gpio_config;
+	}
+
+	rc = pmic8xxx_kp_config_gpio(pdata->rows_gpio_start,
+					pdata->num_rows, kp, &kypd_drv);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "unable to configure keypad drive lines\n");
+		goto err_gpio_config;
+	}
+
 	rc = request_any_context_irq(kp->key_sense_irq, pmic8xxx_kp_irq,
 				 IRQF_TRIGGER_RISING, "pmic-keypad", kp);
 	if (rc < 0) {
@@ -645,6 +702,7 @@ err_pmic_reg_read:
 	free_irq(kp->key_stuck_irq, NULL);
 err_req_stuck_irq:
 	free_irq(kp->key_sense_irq, NULL);
+err_gpio_config:
 err_get_irq:
 	input_free_device(kp->input);
 err_alloc_device:
include/linux/input/pmic8xxx-keypad.h +2 -0
index fc2ac4c..5f1e2f9 100644
@@ -38,6 +38,8 @@ struct pm8xxx_keypad_platform_data {
 
 	unsigned int num_cols;
 	unsigned int num_rows;
+	unsigned int rows_gpio_start;
+	unsigned int cols_gpio_start;
 
 	unsigned int debounce_ms;
 	unsigned int scan_delay_ms;
Signature · 1 line
Sent by a consultant of the Qualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Signature · 1 line
Dmitry
#6 lore raw

Hi Dmitry,

Thank you for reviewing this.

I was planning to fold this patch into the pm8xxx-keypad driver and then send it across to the MFD tree with your Ack. Does this sound ok?

Thank you,
~Anirudh

Quoted 125 lines · Dmitry Torokhov
Quoted 2 lines · Anirudh Ghayal
Quoted 118 lines
---
  drivers/input/keyboard/pmic8xxx-keypad.c |   58 ++++++++++++++++++++++++++++++
  include/linux/input/pmic8xxx-keypad.h    |    2 +
  2 files changed, 60 insertions(+), 0 deletions(-)
drivers/input/keyboard/pmic8xxx-keypad.c +58 -0
index 0229325..40b02ae 100644
@@ -21,6 +21,7 @@
  #include<linux/mutex.h>
 
  #include<linux/mfd/pm8xxx/core.h>
+#include<linux/mfd/pm8xxx/gpio.h>
  #include<linux/input/pmic8xxx-keypad.h>
 
  #define PM8XXX_MAX_ROWS		18
@@ -446,6 +447,27 @@ static int __devinit pmic8xxx_kpd_init(struct pmic8xxx_kp *kp)
 
  }
 
+static int  __devinit pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios,
+			struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config)
+{
+	int	rc, i;
+
+	if (gpio_start<  0 || num_gpios<  0)
+		return -EINVAL;
+
+	for (i = 0; i<  num_gpios; i++) {
+		rc = pm8xxx_gpio_config(gpio_start + i, gpio_config);
+		if (rc) {
+			dev_err(kp->dev, "%s: FAIL pm8xxx_gpio_config():"
+					"for PM GPIO [%d] rc=%d.\n",
+					__func__, gpio_start + i, rc);
+			return rc;
+		}
+	 }
+
+	return 0;
+}
+
  static int pmic8xxx_kp_enable(struct pmic8xxx_kp *kp)
  {
  	int rc;
@@ -504,6 +526,27 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
  	int rc;
  	u8 ctrl_val;
 
+	struct pm_gpio kypd_drv = {
+		.direction	= PM_GPIO_DIR_OUT,
+		.output_buffer	= PM_GPIO_OUT_BUF_OPEN_DRAIN,
+		.output_value	= 0,
+		.pull		= PM_GPIO_PULL_NO,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_LOW,
+		.function	= PM_GPIO_FUNC_1,
+		.inv_int_pol	= 1,
+	};
+
+	struct pm_gpio kypd_sns = {
+		.direction	= PM_GPIO_DIR_IN,
+		.pull		= PM_GPIO_PULL_UP_31P5,
+		.vin_sel	= PM_GPIO_VIN_S3,
+		.out_strength	= PM_GPIO_STRENGTH_NO,
+		.function	= PM_GPIO_FUNC_NORMAL,
+		.inv_int_pol	= 1,
+	};
+
+
  	if (!pdata || !pdata->num_cols || !pdata->num_rows ||
  		pdata->num_cols>  PM8XXX_MAX_COLS ||
  		pdata->num_rows>  PM8XXX_MAX_ROWS ||
@@ -609,6 +652,20 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
  		goto err_get_irq;
  	}
 
+	rc = pmic8xxx_kp_config_gpio(pdata->cols_gpio_start,
+					pdata->num_cols, kp,&kypd_sns);
+	if (rc<  0) {
+		dev_err(&pdev->dev, "unable to configure keypad sense lines\n");
+		goto err_gpio_config;
+	}
+
+	rc = pmic8xxx_kp_config_gpio(pdata->rows_gpio_start,
+					pdata->num_rows, kp,&kypd_drv);
+	if (rc<  0) {
+		dev_err(&pdev->dev, "unable to configure keypad drive lines\n");
+		goto err_gpio_config;
+	}
+
  	rc = request_any_context_irq(kp->key_sense_irq, pmic8xxx_kp_irq,
  				 IRQF_TRIGGER_RISING, "pmic-keypad", kp);
  	if (rc<  0) {
@@ -645,6 +702,7 @@ err_pmic_reg_read:
  	free_irq(kp->key_stuck_irq, NULL);
  err_req_stuck_irq:
  	free_irq(kp->key_sense_irq, NULL);
+err_gpio_config:
  err_get_irq:
  	input_free_device(kp->input);
  err_alloc_device:
include/linux/input/pmic8xxx-keypad.h +2 -1
index fc2ac4c..5f1e2f9 100644
@@ -38,6 +38,8 @@ struct pm8xxx_keypad_platform_data {
 
  	unsigned int num_cols;
  	unsigned int num_rows;
+	unsigned int rows_gpio_start;
+	unsigned int cols_gpio_start;
 
  	unsigned int debounce_ms;
  	unsigned int scan_delay_ms;
--

Sent by a consultant of the Qualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

#3 lore raw

Re: [PATCH V3 2/2] input: pmic8xxx_pwrkey: Add support for power key

In reply to Dmitry Torokhov

Hi Samuel,

Can you please pull this patch in your MFD tree. https://patchwork.kernel.org/patch/782212/.
This patch depends on the pm8xxx MFD core.

Thank you,
~Anirudh

Quoted 20 lines · Dmitry Torokhov
Quoted 8 lines · Anirudh Ghayal

From: Trilok Soni<[email protected]>

Add support for PMIC8XXX power key driven over dedicated KYPD_PWR_N pin.

Anirudh,

Looks great, thank you for making changes. Please feel free to merge with the rest of the pmic8xxx MFD patches. I assume they will go through MFD tree, right?

Thanks.

#4 lore raw

Re: [PATCH V3 2/2] input: pmic8xxx_pwrkey: Add support for power key

In reply to Anirudh Ghayal

Hi Anirudh,

Quoted 4 lines · Anirudh Ghayal

From: Trilok Soni <[email protected]>

Add support for PMIC8XXX power key driven over dedicated KYPD_PWR_N pin.

Patch applied. Thanks for the patch, and thanks Dmitry for the review.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/