From patchwork Thu Oct 1 21:54:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: miguel.aguilar@ridgerun.com X-Patchwork-Id: 51029 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n91Lsb69009618 for ; Thu, 1 Oct 2009 21:54:37 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n91Lsbod012929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Oct 2009 16:54:37 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id n91Lsahr028191 for ; Thu, 1 Oct 2009 16:54:36 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D9AB380648 for ; Thu, 1 Oct 2009 16:54:34 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 3E21480626 for ; Thu, 1 Oct 2009 16:54:30 -0500 (CDT) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n91LsUs4010951 for ; Thu, 1 Oct 2009 16:54:30 -0500 (CDT) Received: from mail165-tx2-R.bigfish.com (mail-tx2.bigfish.com [65.55.88.114]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id n91LsTR0031408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 1 Oct 2009 16:54:29 -0500 Received: from mail165-tx2 (localhost.localdomain [127.0.0.1]) by mail165-tx2-R.bigfish.com (Postfix) with ESMTP id 8CBAB560216 for ; Thu, 1 Oct 2009 21:54:29 +0000 (UTC) X-SpamScore: 7 X-BigFish: vps7(zza4b1ozz1202hzzz2fh6bh66h) X-Spam-TCS-SCL: 5:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 74.208.67.6; Service: EHS Received: by mail165-tx2 (MessageSwitch) id 1254434063661830_12122; Thu, 1 Oct 2009 21:54:23 +0000 (UCT) Received: from TX2EHSMHS012.bigfish.com (unknown [10.9.14.237]) by mail165-tx2.bigfish.com (Postfix) with ESMTP id 46EC8F8066; Thu, 1 Oct 2009 21:54:23 +0000 (UTC) Received: from mail.navvo.net (74.208.67.6) by TX2EHSMHS012.bigfish.com (10.9.99.112) with Microsoft SMTP Server (TLS) id 14.0.482.32; Thu, 1 Oct 2009 21:54:22 +0000 Received: from [201.198.127.70] (helo=localhost.localdomain) by mail.navvo.net with esmtpa (Exim 4.63) (envelope-from ) id 1MtTbO-0007HU-Oe; Thu, 01 Oct 2009 16:54:20 -0500 From: To: davinci-linux-open-source@linux.davincidsp.com, nsnehaprabha@ti.com, linux-input-owner@vger.kernel.org Date: Thu, 1 Oct 2009 15:54:11 -0600 Message-ID: <1254434051-28772-1-git-send-email-miguel.aguilar@ridgerun.com> X-Mailer: git-send-email 1.6.0.4 X-SA-Exim-Connect-IP: 201.198.127.70 X-SA-Exim-Mail-From: miguel.aguilar@ridgerun.com X-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on mail.navvo.net X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, NO_REAL_NAME autolearn=ham version=3.1.7-deb X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000) X-SA-Exim-Scanned: Yes (on mail.navvo.net) MIME-Version: 1.0 X-Reverse-DNS: mail.navvo.net Cc: santiago.nunez@ridgerun.com, todd.fischer@ridgerun.com, clark.becker@ridgerun.com, Miguel Aguilar Subject: [PATCH v2 1/2] Input: DaVinci Key Scan Driver X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com From: Miguel Aguilar Adds the driver for enabling key scan support for DaVinci platforms. DM365 is the only platform that uses this driver at the moment. Signed-off-by: Miguel Aguilar --- arch/arm/mach-davinci/include/mach/keyscan.h | 12 ++++- drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/davinci_keyscan.c | 52 +++++++++++++++++-------- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-davinci/include/mach/keyscan.h b/arch/arm/mach-davinci/include/mach/keyscan.h index 6d64198..d82ae17 100644 --- a/arch/arm/mach-davinci/include/mach/keyscan.h +++ b/arch/arm/mach-davinci/include/mach/keyscan.h @@ -23,12 +23,18 @@ #include +/* Base of key scan register bank */ +#define DM365_KEYSCAN_BASE (0x01C69400) + struct davinci_ks_platform_data { unsigned short *keymap; u32 keymapsize; - u32 rep:1; - u32 strobe; - u32 interval; + u8 rows; + u8 cols; + u8 rep:1; + u8 strobe; + u8 interval; + }; #endif diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 72e560e..eca9e14 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -366,7 +366,7 @@ config KEYBOARD_DAVINCI depends on ARCH_DAVINCI_DM365 help Say Y to enable keypad module support for the TI DaVinci - platforms (DM365) + platforms (DM365). To compile this driver as a module, choose M here: the module will be called davinci_keyscan. diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c index 074cf81..9b153a9 100644 --- a/drivers/input/keyboard/davinci_keyscan.c +++ b/drivers/input/keyboard/davinci_keyscan.c @@ -57,7 +57,6 @@ #define DAVINCI_KEYSCAN_AUTODET 0x00000008 #define DAVINCI_KEYSCAN_SCANMODE 0x00000010 #define DAVINCI_KEYSCAN_OUTTYPE 0x00000020 -#define DAVINCI_KEYSCAN_4X4 0x00000040 /* Masks for the interrupts */ #define DAVINCI_KEYSCAN_INT_CONT 0x00000008 @@ -91,10 +90,14 @@ static u32 davinci_ks_read(struct davinci_ks *davinci_ks, u32 addr) } /* Initializing the kp Module */ -static void davinci_ks_initialize(struct davinci_ks *davinci_ks) +static int davinci_ks_initialize(struct davinci_ks *davinci_ks) { - u32 strobe = davinci_ks->pdata->strobe; - u32 interval = davinci_ks->pdata->interval; + struct device *dev = &davinci_ks->input->dev; + u8 strobe = davinci_ks->pdata->strobe; + u8 interval = davinci_ks->pdata->interval; + u8 rows = davinci_ks->pdata->rows; + u8 cols = davinci_ks->pdata->cols; + u8 matrix_type = 0; /* Enable all interrupts */ davinci_ks_write(davinci_ks, DAVINCI_KEYSCAN_INT_ALL, DAVINCI_KEYSCAN_INTENA); @@ -107,9 +110,21 @@ static void davinci_ks_initialize(struct davinci_ks *davinci_ks) davinci_ks_write(davinci_ks, interval, DAVINCI_KEYSCAN_INTERVAL); davinci_ks_write(davinci_ks, 0x01, DAVINCI_KEYSCAN_CONTTIME); - /* Enable Keyscan module and enable */ - davinci_ks_write(davinci_ks, DAVINCI_KEYSCAN_AUTODET | DAVINCI_KEYSCAN_KEYEN, - DAVINCI_KEYSCAN_KEYCTRL); + /* Define matrix type */ + if ((rows == 4) && (cols == 4)) + matrix_type = 0; + else if ((rows == 3) && (cols == 5)) + matrix_type = 1; + else { + dev_err(dev, "davinci_scan: wrong matrix dimension\n"); + return -EINVAL; + } + + /* Enable key scan module and set matrix type */ + davinci_ks_write(davinci_ks, DAVINCI_KEYSCAN_AUTODET | DAVINCI_KEYSCAN_KEYEN + | (matrix_type << 6), DAVINCI_KEYSCAN_KEYCTRL); + + return 0; } static irqreturn_t davinci_ks_interrupt(int irq, void *dev_id) @@ -141,7 +156,7 @@ static irqreturn_t davinci_ks_interrupt(int irq, void *dev_id) if((changed>>i) & 0x1) { keycode = keymap[i]; release = (new_status >> i) & 0x1; - dev_info(dev, "davinci_keyscan: key %d %s\n", + dev_dbg(dev, "davinci_keyscan: key %d %s\n", keycode, release ? "released" : "pressed"); input_report_key(davinci_ks->input, keycode, !release); @@ -168,7 +183,10 @@ static int __init davinci_ks_probe(struct platform_device *pdev) struct davinci_ks_platform_data *pdata = pdev->dev.platform_data; int ret, i; - dev_info(dev, "DaVinci Key Scan Driver\n"); + if (!pdata->keymap) { + dev_dbg(dev, "no keymap from pdata\n"); + return -EINVAL; + } davinci_ks = kzalloc(sizeof(struct davinci_ks) + sizeof(unsigned short) * pdata->keymapsize, GFP_KERNEL); @@ -177,11 +195,6 @@ static int __init davinci_ks_probe(struct platform_device *pdev) return -ENOMEM; } - if (!pdata->keymap) { - dev_dbg(dev, "no keymap from pdata\n"); - return -EINVAL; - } - memcpy(davinci_ks->keymap, pdata->keymap, sizeof(unsigned short) * pdata->keymapsize); @@ -254,20 +267,25 @@ static int __init davinci_ks_probe(struct platform_device *pdev) ret = input_register_device(davinci_ks->input); if (ret < 0) { - dev_err(dev, "unable to register DaVinci keyscan device\n"); + dev_err(dev, "unable to register davinci key scan device\n"); goto fail4; } ret = request_irq(davinci_ks->irq, davinci_ks_interrupt, IRQF_DISABLED, "davinci_keyscan", davinci_ks); if (ret < 0) { - dev_err(dev, "unable to register DaVinci keyscan Interrupt\n"); + dev_err(dev, "unable to register davinci key scan interrupt\n"); goto fail5; } - davinci_ks_initialize(davinci_ks); + ret = davinci_ks_initialize(davinci_ks); + if (ret < 0) { + dev_err(dev, "unable to initialize davinci key scan device\n"); + goto fail5; + } return 0; + fail5: input_unregister_device(davinci_ks->input); key_dev = NULL;