From patchwork Sat Jul 10 15:57:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 111233 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6AFvihv019879 for ; Sat, 10 Jul 2010 15:57:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755939Ab0GJP52 (ORCPT ); Sat, 10 Jul 2010 11:57:28 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:35010 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755717Ab0GJP5L convert rfc822-to-8bit (ORCPT ); Sat, 10 Jul 2010 11:57:11 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o6AFv8xi007681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 10 Jul 2010 10:57:10 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id o6AFv77x000805; Sat, 10 Jul 2010 21:27:07 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Sat, 10 Jul 2010 21:27:07 +0530 From: "Datta, Shubhrajyoti" To: "linux-omap@vger.kernel.org" CC: "linux-input@vger.kernel.org" Date: Sat, 10 Jul 2010 21:27:05 +0530 Subject: [RFC][PATCH] Add the proximity sensor support for 4430sdp Thread-Topic: [RFC][PATCH] Add the proximity sensor support for 4430sdp Thread-Index: AcsgSBhwpFL4UIQKR+WPOYmSc3gBCQAAEDCA Message-ID: <0680EC522D0CC943BC586913CF3768C003B36AAFAF@dbde02.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 10 Jul 2010 15:57:45 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index 9447644..91eba3f 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,8 @@ #define ETH_KS8851_IRQ 34 #define ETH_KS8851_POWER_ON 48 #define ETH_KS8851_QUART 138 +#define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184 +#define OMAP4_SFH7741_ENABLE_GPIO 188 static struct gpio_led sdp4430_gpio_leds[] = { { @@ -76,11 +79,31 @@ static struct gpio_led sdp4430_gpio_leds[] = { }, }; +static struct gpio_keys_button sdp4430_gpio_keys[] = { + { + .desc = "Proximity Sensor", + .type = EV_SW, + .code = SW_FRONT_PROXIMITY, + .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO, + .active_low = 0, + } +}; static struct gpio_led_platform_data sdp4430_led_data = { .leds = sdp4430_gpio_leds, .num_leds = ARRAY_SIZE(sdp4430_gpio_leds), }; +static struct gpio_keys_platform_data sdp4430_gpio_keys_data = { + .buttons = sdp4430_gpio_keys, + .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys), +}; +static struct platform_device sdp4430_gpio_keys_device = { + .name = "gpio-keys", + .id = -1, + .dev = { + .platform_data = &sdp4430_gpio_keys_data, + }, +}; static struct platform_device sdp4430_leds_gpio = { .name = "leds-gpio", @@ -161,6 +184,7 @@ static struct platform_device sdp4430_lcd_device = { static struct platform_device *sdp4430_devices[] __initdata = { &sdp4430_lcd_device, + &sdp4430_gpio_keys_device, &sdp4430_leds_gpio, }; @@ -426,6 +450,24 @@ static int __init omap4_i2c_init(void) omap_register_i2c_bus(4, 400, NULL, 0); return 0; } +static void omap_sfh7741prox_init(void) +{ + int error; + + error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741"); + if (error < 0) { + pr_err("failed to request GPIO %d, error %d\n", + OMAP4_SFH7741_ENABLE_GPIO, error); + return; + } + + error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 1); + if (error < 0) { + pr_err("%s: GPIO configuration failed: GPIO %d,\ + error %d\n",__func__, OMAP4_SFH7741_ENABLE_GPIO, error); + gpio_free(OMAP4_SFH7741_ENABLE_GPIO); + } +} static void __init omap_4430sdp_init(void) { int status; @@ -448,6 +490,7 @@ static void __init omap_4430sdp_init(void) spi_register_board_info(sdp4430_spi_board_info, ARRAY_SIZE(sdp4430_spi_board_info)); } + omap_sfh7741prox_init(); } static void __init omap_4430sdp_map_io(void)