From patchwork Fri Oct 1 11:55:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh KUMAR X-Patchwork-Id: 66347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wy0-f184.google.com (mail-wy0-f184.google.com [74.125.82.184]) by ozlabs.org (Postfix) with ESMTP id B06C7B70F6 for ; Fri, 1 Oct 2010 21:58:06 +1000 (EST) Received: by mail-wy0-f184.google.com with SMTP id 11sf1396646wyi.11 for ; Fri, 01 Oct 2010 04:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:received:received :received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=1K89GIN82M+hqTuK0h6OinRTDd1+CC3vC39vuZCoKZ8=; b=kXgz7tW2IL9rIMEWzZzk+d5wb7YKh91nZe6S7r3ONctLBoT112q23w3sG7dizRioKy phB5+tuFsHC0QfOfSsoeZXng4iTZyB6PCrpLeq/lihevR62OSXeylBTXENlYd2KCVJk1 +mldBA/alA2jY7F7NYex1Lg9LuAU4fpE9T/O4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=AQmYwZQU8wm534sR8ijajg6qvxHRFpfbwNujwSVY0ip4WJsDFDk5UEC8VhJAd0FkRX IGbc1MopDVZs6gGVCHJAZiz5FfzAcrHS88BDLmNY/aUMN6r6S75LvPoHsjWYdaACT3Ea OAqSUTUvv6/useg4UMCXJjrOPlo2V/cmUUV18= Received: by 10.216.145.167 with SMTP id p39mr1122269wej.25.1285934285050; Fri, 01 Oct 2010 04:58:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.14.35.157 with SMTP id u29ls232953eea.6.p; Fri, 01 Oct 2010 04:58:04 -0700 (PDT) Received: by 10.14.29.75 with SMTP id h51mr503401eea.21.1285934284302; Fri, 01 Oct 2010 04:58:04 -0700 (PDT) Received: by 10.14.29.75 with SMTP id h51mr503400eea.21.1285934284282; Fri, 01 Oct 2010 04:58:04 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by gmr-mx.google.com with ESMTP id r57si1117383eeh.5.2010.10.01.04.57.49; Fri, 01 Oct 2010 04:58:04 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of viresh.kumar@st.com) client-ip=207.126.144.133; Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKTKXMve0YBWXm7dfGt7oS7094SmAlRpRU@postini.com; Fri, 01 Oct 2010 11:58:04 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C321BA7; Fri, 1 Oct 2010 11:57:43 +0000 (GMT) Received: from mail2.dlh.st.com (mail2.dlh.st.com [10.199.8.22]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 34DB52641; Fri, 1 Oct 2010 11:57:42 +0000 (GMT) Received: from localhost (dlhl0509.dlh.st.com [10.199.7.86]) by mail2.dlh.st.com (MOS 3.8.7a) with ESMTP id CUF00968 (AUTH viresh.kumar@st.com); Fri, 1 Oct 2010 17:27:41 +0530 (IST) From: Viresh KUMAR To: linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com, a.zummo@towertech.it, dbrownell@users.sourceforge.net, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com Cc: Rajeev Kumar , shiraz.hashim@st.com, vipin.kumar@st.com, deepak.sikri@st.com, armando.visconti@st.com, vipulkumar.samar@st.com, pratyush.anand@st.com, bhupesh.sharma@st.com Subject: [rtc-linux] [PATCH V2 22/69] ST SPEAr: Adding machine support for keyboard Date: Fri, 1 Oct 2010 17:25:42 +0530 Message-Id: <5eb8338cba759ba92beaeb5d1cca301ab0077582.1285933331.git.viresh.kumar@st.com> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: References: In-Reply-To: References: X-Original-Sender: viresh.kumar@st.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of viresh.kumar@st.com) smtp.mail=viresh.kumar@st.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Rajeev Kumar Signed-off-by: Rajeev Kumar --- arch/arm/mach-spear13xx/include/mach/generic.h | 1 + arch/arm/mach-spear13xx/spear1300_evb.c | 14 +++ arch/arm/mach-spear13xx/spear13xx.c | 19 +++ arch/arm/mach-spear3xx/include/mach/generic.h | 1 + arch/arm/mach-spear3xx/spear300.c | 19 +++ arch/arm/mach-spear3xx/spear300_evb.c | 14 +++ arch/arm/plat-spear/include/plat/keyboard.h | 144 ++++++++++++++++++++++++ 7 files changed, 212 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-spear/include/plat/keyboard.h diff --git a/arch/arm/mach-spear13xx/include/mach/generic.h b/arch/arm/mach-spear13xx/include/mach/generic.h index a75ed3a..fd9f9a6 100644 --- a/arch/arm/mach-spear13xx/include/mach/generic.h +++ b/arch/arm/mach-spear13xx/include/mach/generic.h @@ -33,6 +33,7 @@ extern struct amba_device spear13xx_uart_device; extern struct platform_device spear13xx_ehci0_device; extern struct platform_device spear13xx_ehci1_device; extern struct platform_device spear13xx_i2c_device; +extern struct platform_device spear13xx_kbd_device; extern struct platform_device spear13xx_ohci0_device; extern struct platform_device spear13xx_ohci1_device; extern struct platform_device spear13xx_rtc_device; diff --git a/arch/arm/mach-spear13xx/spear1300_evb.c b/arch/arm/mach-spear13xx/spear1300_evb.c index 9f53361..0c7c996 100644 --- a/arch/arm/mach-spear13xx/spear1300_evb.c +++ b/arch/arm/mach-spear13xx/spear1300_evb.c @@ -16,6 +16,7 @@ #include #include #include +#include static struct amba_device *amba_devs[] __initdata = { &spear13xx_uart_device, @@ -25,15 +26,28 @@ static struct platform_device *plat_devs[] __initdata = { &spear13xx_ehci0_device, &spear13xx_ehci1_device, &spear13xx_i2c_device, + &spear13xx_kbd_device, &spear13xx_ohci0_device, &spear13xx_ohci1_device, &spear13xx_rtc_device, }; +/* keyboard specific platform data */ +static DECLARE_KEYMAP(spear_keymap); + +static struct kbd_platform_data kbd_data = { + .keymap = spear_keymap, + .keymapsize = ARRAY_SIZE(spear_keymap), + .rep = 1, +}; + static void __init spear1300_evb_init(void) { unsigned int i; + /* set keyboard plat data */ + kbd_set_plat_data(&spear13xx_kbd_device, &kbd_data); + /* call spear1300 machine init function */ spear1300_init(); diff --git a/arch/arm/mach-spear13xx/spear13xx.c b/arch/arm/mach-spear13xx/spear13xx.c index c201e31..d19e325 100644 --- a/arch/arm/mach-spear13xx/spear13xx.c +++ b/arch/arm/mach-spear13xx/spear13xx.c @@ -166,6 +166,25 @@ struct platform_device spear13xx_ohci1_device = { .resource = ohci1_resources, }; +/* keyboard device registration */ +static struct resource kbd_resources[] = { + { + .start = SPEAR13XX_KBD_BASE, + .end = SPEAR13XX_KBD_BASE + SZ_1K - 1, + .flags = IORESOURCE_MEM, + }, { + .start = IRQ_KBD, + .flags = IORESOURCE_IRQ, + }, +}; + +struct platform_device spear13xx_kbd_device = { + .name = "keyboard", + .id = -1, + .num_resources = ARRAY_SIZE(kbd_resources), + .resource = kbd_resources, +}; + /* rtc device registration */ static struct resource rtc_resources[] = { { diff --git a/arch/arm/mach-spear3xx/include/mach/generic.h b/arch/arm/mach-spear3xx/include/mach/generic.h index 3eb2737..70f7ee2 100644 --- a/arch/arm/mach-spear3xx/include/mach/generic.h +++ b/arch/arm/mach-spear3xx/include/mach/generic.h @@ -108,6 +108,7 @@ extern struct pmx_driver pmx_driver; /* Add spear300 machine device structure declarations here */ extern struct amba_device clcd_device; extern struct amba_device gpio1_device; +extern struct platform_device kbd_device; /* pad mux modes */ extern struct pmx_mode nand_mode; diff --git a/arch/arm/mach-spear3xx/spear300.c b/arch/arm/mach-spear3xx/spear300.c index fb7d5f1..44ba52e 100644 --- a/arch/arm/mach-spear3xx/spear300.c +++ b/arch/arm/mach-spear3xx/spear300.c @@ -407,6 +407,25 @@ struct amba_device gpio1_device = { .irq = {VIRQ_GPIO1, NO_IRQ}, }; +/* keyboard device registration */ +static struct resource kbd_resources[] = { + { + .start = SPEAR300_KEYBOARD_BASE, + .end = SPEAR300_KEYBOARD_BASE + SZ_1K - 1, + .flags = IORESOURCE_MEM, + }, { + .start = VIRQ_KEYBOARD, + .flags = IORESOURCE_IRQ, + }, +}; + +struct platform_device kbd_device = { + .name = "keyboard", + .id = -1, + .num_resources = ARRAY_SIZE(kbd_resources), + .resource = kbd_resources, +}; + /* spear3xx shared irq */ struct shirq_dev_config shirq_ras1_config[] = { { diff --git a/arch/arm/mach-spear3xx/spear300_evb.c b/arch/arm/mach-spear3xx/spear300_evb.c index 3b3c6ce..afb773e 100644 --- a/arch/arm/mach-spear3xx/spear300_evb.c +++ b/arch/arm/mach-spear3xx/spear300_evb.c @@ -15,6 +15,7 @@ #include #include #include +#include /* padmux devices to enable */ static struct pmx_dev *pmx_devs[] = { @@ -51,6 +52,16 @@ static struct platform_device *plat_devs[] __initdata = { &rtc_device, /* spear300 specific devices */ + &kbd_device, +}; + +/* keyboard specific platform data */ +static DECLARE_KEYMAP(spear_keymap); + +static struct kbd_platform_data kbd_data = { + .keymap = spear_keymap, + .keymapsize = ARRAY_SIZE(spear_keymap), + .rep = 1, }; static void __init spear300_evb_init(void) @@ -62,6 +73,9 @@ static void __init spear300_evb_init(void) pmx_driver.devs = pmx_devs; pmx_driver.devs_count = ARRAY_SIZE(pmx_devs); + /* set keyboard plat data */ + kbd_set_plat_data(&kbd_device, &kbd_data); + /* call spear300 machine init function */ spear300_init(); diff --git a/arch/arm/plat-spear/include/plat/keyboard.h b/arch/arm/plat-spear/include/plat/keyboard.h new file mode 100644 index 0000000..29448bc --- /dev/null +++ b/arch/arm/plat-spear/include/plat/keyboard.h @@ -0,0 +1,144 @@ +/* + * arch/arm/plat-spear/include/plat/keyboard.h + * + * Copyright (C) 2010 ST Microelectronics + * Rajeev Kumar + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#ifndef __PLAT_KEYBOARD_H +#define __PLAT_KEYBOARD_H + +#include +#include +#include +#include + +#define DECLARE_KEYMAP(name) \ +int name[] = {\ + KEY(0, 0, KEY_ESC), \ + KEY(0, 1, KEY_1), \ + KEY(0, 2, KEY_2), \ + KEY(0, 3, KEY_3), \ + KEY(0, 4, KEY_4), \ + KEY(0, 5, KEY_5), \ + KEY(0, 6, KEY_6), \ + KEY(0, 7, KEY_7), \ + KEY(0, 8, KEY_8), \ + KEY(1, 0, KEY_9), \ + KEY(1, 1, KEY_MINUS), \ + KEY(1, 2, KEY_EQUAL), \ + KEY(1, 3, KEY_BACKSPACE), \ + KEY(1, 4, KEY_TAB), \ + KEY(1, 5, KEY_Q), \ + KEY(1, 6, KEY_W), \ + KEY(1, 7, KEY_E), \ + KEY(1, 8, KEY_R), \ + KEY(2, 0, KEY_T), \ + KEY(2, 1, KEY_Y), \ + KEY(2, 2, KEY_U), \ + KEY(2, 3, KEY_I), \ + KEY(2, 4, KEY_O), \ + KEY(2, 5, KEY_P), \ + KEY(2, 6, KEY_LEFTBRACE), \ + KEY(2, 7, KEY_RIGHTBRACE), \ + KEY(2, 8, KEY_ENTER), \ + KEY(3, 0, KEY_LEFTCTRL), \ + KEY(3, 1, KEY_A), \ + KEY(3, 2, KEY_S), \ + KEY(3, 3, KEY_D), \ + KEY(3, 4, KEY_F), \ + KEY(3, 5, KEY_G), \ + KEY(3, 6, KEY_H), \ + KEY(3, 7, KEY_J), \ + KEY(3, 8, KEY_K), \ + KEY(4, 0, KEY_L), \ + KEY(4, 1, KEY_SEMICOLON), \ + KEY(4, 2, KEY_APOSTROPHE), \ + KEY(4, 3, KEY_GRAVE), \ + KEY(4, 4, KEY_LEFTSHIFT), \ + KEY(4, 5, KEY_BACKSLASH), \ + KEY(4, 6, KEY_Z), \ + KEY(4, 7, KEY_X), \ + KEY(4, 8, KEY_C), \ + KEY(4, 0, KEY_L), \ + KEY(4, 1, KEY_SEMICOLON), \ + KEY(4, 2, KEY_APOSTROPHE), \ + KEY(4, 3, KEY_GRAVE), \ + KEY(4, 4, KEY_LEFTSHIFT), \ + KEY(4, 5, KEY_BACKSLASH), \ + KEY(4, 6, KEY_Z), \ + KEY(4, 7, KEY_X), \ + KEY(4, 8, KEY_C), \ + KEY(4, 0, KEY_L), \ + KEY(4, 1, KEY_SEMICOLON), \ + KEY(4, 2, KEY_APOSTROPHE), \ + KEY(4, 3, KEY_GRAVE), \ + KEY(4, 4, KEY_LEFTSHIFT), \ + KEY(4, 5, KEY_BACKSLASH), \ + KEY(4, 6, KEY_Z), \ + KEY(4, 7, KEY_X), \ + KEY(4, 8, KEY_C), \ + KEY(5, 0, KEY_V), \ + KEY(5, 1, KEY_B), \ + KEY(5, 2, KEY_N), \ + KEY(5, 3, KEY_M), \ + KEY(5, 4, KEY_COMMA), \ + KEY(5, 5, KEY_DOT), \ + KEY(5, 6, KEY_SLASH), \ + KEY(5, 7, KEY_RIGHTSHIFT), \ + KEY(5, 8, KEY_KPASTERISK), \ + KEY(6, 0, KEY_LEFTALT), \ + KEY(6, 1, KEY_SPACE), \ + KEY(6, 2, KEY_CAPSLOCK), \ + KEY(6, 3, KEY_F1), \ + KEY(6, 4, KEY_F2), \ + KEY(6, 5, KEY_F3), \ + KEY(6, 6, KEY_F4), \ + KEY(6, 7, KEY_F5), \ + KEY(6, 8, KEY_F6), \ + KEY(7, 0, KEY_F7), \ + KEY(7, 1, KEY_F8), \ + KEY(7, 2, KEY_F9), \ + KEY(7, 3, KEY_F10), \ + KEY(7, 4, KEY_NUMLOCK), \ + KEY(7, 5, KEY_SCROLLLOCK), \ + KEY(7, 6, KEY_KP7), \ + KEY(7, 7, KEY_KP8), \ + KEY(7, 8, KEY_KP9), \ + KEY(8, 0, KEY_KPMINUS), \ + KEY(8, 1, KEY_KP4), \ + KEY(8, 2, KEY_KP5), \ + KEY(8, 3, KEY_KP6), \ + KEY(8, 4, KEY_KPPLUS), \ + KEY(8, 5, KEY_KP1), \ + KEY(8, 6, KEY_KP2), \ + KEY(8, 7, KEY_KP3), \ + KEY(8, 8, KEY_KP0), \ +}; +/** + * struct kbd_platform_data - keymap for spear keyboards + * keymap: pointer to array of values encoded with KEY() macro representing + * keymap + * keymapsize: number of entries (initialized) in this keymap + * rep: current values for autorepeat parameters + * + * This structure is supposed to be used by platform code to supply + * keymaps to drivers that implement keyboards. + */ +struct kbd_platform_data { + int *keymap; + unsigned int keymapsize; + bool rep; +}; + +/* This function is used to set platform data field of pdev->dev */ +static inline void +kbd_set_plat_data(struct platform_device *pdev, struct kbd_platform_data *data) +{ + pdev->dev.platform_data = data; +} +#endif /* __PLAT_KEYBOARD_H */