From patchwork Tue Nov 16 19:39:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 329061 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAGJglSP030355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Nov 2010 19:43:07 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id oAGJevNI010183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 16 Nov 2010 13:40:57 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id oAGJevqb013729; Tue, 16 Nov 2010 13:40:57 -0600 (CST) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 2130780628; Tue, 16 Nov 2010 13:40:20 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id AC76480626 for ; Tue, 16 Nov 2010 13:39:43 -0600 (CST) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id oAGJdhje020669 for ; Tue, 16 Nov 2010 13:39:43 -0600 (CST) Received: from psmtp.com (na3sys009amx164.postini.com [74.125.149.90]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id oAGJdgSI021310 for ; Tue, 16 Nov 2010 13:39:42 -0600 Received: from source ([74.125.149.197]) by na3sys009amx164.postini.com ([74.125.148.10]) with SMTP; Tue, 16 Nov 2010 14:39:43 EST Received: from source ([209.85.212.52]) by na3sys009aob107.postini.com ([74.125.148.12]) with SMTP ID DSNKTOLd/gsifCpMMOF0lm4NZAF1oXY72JP9@postini.com; Tue, 16 Nov 2010 11:39:42 PST Received: by mail-vw0-f52.google.com with SMTP id 3so545158vws.11 for ; Tue, 16 Nov 2010 11:39:42 -0800 (PST) Received: by 10.220.177.137 with SMTP id bi9mr1812809vcb.220.1289936381630; Tue, 16 Nov 2010 11:39:41 -0800 (PST) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id j13sm457716vcr.41.2010.11.16.11.39.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 16 Nov 2010 11:39:41 -0800 (PST) From: Ben Gardiner To: Kevin Hilman , davinci-linux-open-source@linux.davincidsp.com, linux-input@vger.kernel.org, Dmitry Torokhov Subject: [PATCH v2 2/4] da850-evm: add UI Expander pushbuttons Date: Tue, 16 Nov 2010 14:39:35 -0500 Message-Id: <95f48a32a0256ecdb7148aa08d16f64928a7e5d8.1289935504.git.bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:91.67317/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: "Govindarajan, Sriramakrishnan" , Paul Mundt , linux-kernel@vger.kernel.org, Alexander Clouter , Chris Cordahi X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Nov 2010 19:43:08 +0000 (UTC) diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index b77b860..5163a1c 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -178,6 +178,9 @@ config DA850_UI_RMII endchoice +config INPUT_POLLDEV + default MACH_DAVINCI_DA850_EVM + config MACH_TNETV107X bool "TI TNETV107X Reference Platform" default ARCH_DAVINCI_TNETV107X diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index c6e11c6..ff71ffd 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -17,8 +17,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -272,6 +274,63 @@ static inline void da850_evm_setup_emac_rmii(int rmii_sel) static inline void da850_evm_setup_emac_rmii(int rmii_sel) { } #endif + +#define DA850_PB_DEBOUNCE_MS 10 +/* + * At 200ms polling interval it is possible to miss an + * event by tapping very lightly on the push button but most + * pushes do result in an event; longer intervals require the + * user to hold the button whereas shorter intervals require + * more CPU time for polling. + */ +#define DA850_PB_POLL_MS 200 +/* No need to poll switches anywhere near as fast */ +#define DA850_SW_POLL_MS 700 + +static const char const *ui_expander_names[] = { + "dgnd", "dgnd", "dgnd", "dgnd", "nc", "sel_c", "sel_b", "sel_a", "pb8", + "pb7", "pb6", "pb5", "pb4", "pb3", "pb2", "pb1" +}; + +#define DA850_UI_PB8_OFFSET 8 +#define DA850_N_UI_PB 8 + +static struct gpio_keys_button user_ui_pbs_gpio_keys[DA850_N_UI_PB]; + +static struct gpio_keys_platform_data user_ui_pbs_gpio_key_platform_data = { + .buttons = user_ui_pbs_gpio_keys, + .nbuttons = ARRAY_SIZE(user_ui_pbs_gpio_keys), + .rep = 0, /* disable auto-repeat */ + .poll_interval = DA850_PB_POLL_MS, +}; + +static struct platform_device user_ui_pb_gpio_key_device = { + .name = "gpio-keys", + .id = 0, + .dev = { + .platform_data = &user_ui_pbs_gpio_key_platform_data + } +}; + +static void da850_ui_pushbuttons_init(unsigned gpio) +{ + int i; + struct gpio_keys_button *button; + + for (i = 0; i < DA850_N_UI_PB; i++) { + button = &user_ui_pbs_gpio_keys[i]; + + button->code = KEY_F8 - i; + button->type = EV_KEY; + button->active_low = 1; + button->wakeup = 0; + button->debounce_interval = DA850_PB_DEBOUNCE_MS; + button->desc = (char *) + ui_expander_names[DA850_UI_PB8_OFFSET + i]; + button->gpio = gpio + DA850_UI_PB8_OFFSET + i; + } +} + static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, unsigned ngpio, void *c) { @@ -304,6 +363,14 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, gpio_direction_output(sel_b, 1); gpio_direction_output(sel_c, 1); + da850_ui_pushbuttons_init(gpio); + ret = platform_device_register(&user_ui_pb_gpio_key_device); + if (ret) { + pr_warning("Could not register UI GPIO expander push-buttons" + " device\n"); + goto exp_setup_keys_fail; + } + ui_card_detected = 1; pr_info("DA850/OMAP-L138 EVM UI card detected\n"); @@ -313,6 +380,8 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, return 0; +exp_setup_keys_fail: + gpio_free(sel_c); exp_setup_selc_fail: gpio_free(sel_b); exp_setup_selb_fail: @@ -324,6 +393,8 @@ exp_setup_sela_fail: static int da850_evm_ui_expander_teardown(struct i2c_client *client, unsigned gpio, unsigned ngpio, void *c) { + platform_device_unregister(&user_ui_pb_gpio_key_device); + /* deselect all functionalities */ gpio_set_value(gpio + 5, 1); gpio_set_value(gpio + 6, 1); @@ -340,6 +411,7 @@ static struct pca953x_platform_data da850_evm_ui_expander_info = { .gpio_base = DAVINCI_N_GPIO, .setup = da850_evm_ui_expander_setup, .teardown = da850_evm_ui_expander_teardown, + .names = ui_expander_names, }; static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { @@ -349,6 +421,10 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { { I2C_BOARD_INFO("tca6416", 0x20), .platform_data = &da850_evm_ui_expander_info, + /* + * TODO : populate at runtime using + * .irq = gpio_to_irq(GPIO_TO_PIN(2,7)), + */ }, };