From patchwork Fri May 13 09:47:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anirudh Ghayal X-Patchwork-Id: 782222 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4D9mQRv001299 for ; Fri, 13 May 2011 09:48:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759078Ab1EMJsN (ORCPT ); Fri, 13 May 2011 05:48:13 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:45499 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758552Ab1EMJsL (ORCPT ); Fri, 13 May 2011 05:48:11 -0400 X-IronPort-AV: E=McAfee;i="5400,1158,6344"; a="91183161" Received: from pdmz-ns-mip.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.114.10]) by wolverine01.qualcomm.com with ESMTP/TLS/ADH-AES256-SHA; 13 May 2011 02:48:11 -0700 Received: from codeaurora.org (pdmz-snip-v218.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 9C3E710004D5; Fri, 13 May 2011 02:47:50 -0700 (PDT) From: Anirudh Ghayal To: linux-input@vger.kernel.org, Dmitry Torokhov Cc: linux-arm-msm@vger.kernel.org, Trilok Soni , Samuel Ortiz , Anirudh Ghayal Subject: [PATCH V3 1/2] input: pmic8xxx-keypad: Add row and column gpio configuration Date: Fri, 13 May 2011 15:17:50 +0530 Message-Id: <1305280071-1652-1-git-send-email-aghayal@codeaurora.org> X-Mailer: git-send-email 1.7.3.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 13 May 2011 09:48:27 +0000 (UTC) Cc: Dmitry Torokhov Signed-off-by: Anirudh Ghayal Acked-by: Dmitry Torokhov --- drivers/input/keyboard/pmic8xxx-keypad.c | 58 ++++++++++++++++++++++++++++++ include/linux/input/pmic8xxx-keypad.h | 2 + 2 files changed, 60 insertions(+), 0 deletions(-) diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c index 0229325..40b02ae 100644 --- a/drivers/input/keyboard/pmic8xxx-keypad.c +++ b/drivers/input/keyboard/pmic8xxx-keypad.c @@ -21,6 +21,7 @@ #include #include +#include #include #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: diff --git a/include/linux/input/pmic8xxx-keypad.h b/include/linux/input/pmic8xxx-keypad.h index fc2ac4c..5f1e2f9 100644 --- a/include/linux/input/pmic8xxx-keypad.h +++ b/include/linux/input/pmic8xxx-keypad.h @@ -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;