From patchwork Wed May 12 08:52:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 98963 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4C8qM9h004349 for ; Wed, 12 May 2010 08:52:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755215Ab0ELIwV (ORCPT ); Wed, 12 May 2010 04:52:21 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:50829 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755120Ab0ELIwU convert rfc822-to-8bit (ORCPT ); Wed, 12 May 2010 04:52:20 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o4C8qHJo016920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 May 2010 03:52:19 -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 o4C8qGIu002343; Wed, 12 May 2010 14:22:16 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Wed, 12 May 2010 14:22:17 +0530 From: "Datta, Shubhrajyoti" To: "linux-input@vger.kernel.org" , "linux-omap@vger.kernel.org" CC: "Datta, Shubhrajyoti" Date: Wed, 12 May 2010 14:22:16 +0530 Subject: [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support. Thread-Topic: [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support. Thread-Index: AcrxroM3vKuO38JdTRms37fzf+GpSgAAT2gQ Message-ID: <0680EC522D0CC943BC586913CF3768C003B3209EF5@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-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.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 08:52:22 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index b88f28c..beb3059 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,25 @@ #include #include #include +#define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184 +#define OMAP4_SFH7741_ENABLE_GPIO 188 +static void omap_prox_activate(int state); +static int omap_prox_read(void); + +static struct sfh7741_platform_data omap_sfh7741_data = { + .irq = OMAP_GPIO_IRQ(OMAP4_SFH7741_SENSOR_OUTPUT_GPIO), + .prox_enable = 1, + .activate_func = omap_prox_activate, + .read_prox = omap_prox_read, +}; +static struct platform_device sdp4430_proximity_device = { + .name = "sfh7741", + .id = 1, + .dev = { + .platform_data = &omap_sfh7741_data, + }, +}; static struct platform_device sdp4430_lcd_device = { .name = "sdp4430_lcd", .id = -1, @@ -39,6 +58,7 @@ static struct platform_device sdp4430_lcd_device = { static struct platform_device *sdp4430_devices[] __initdata = { &sdp4430_lcd_device, + &sdp4430_proximity_device, }; static struct omap_lcd_config sdp4430_lcd_config __initdata = { @@ -111,6 +131,56 @@ static struct omap_musb_board_data musb_board_data = { .power = 100, }; +static void omap_prox_activate(int state) +{ + gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , state); +} + +static int omap_prox_read(void) +{ + int proximity; + proximity = gpio_get_value(OMAP4_SFH7741_SENSOR_OUTPUT_GPIO); + return proximity; +} + +static void omap_sfh7741prox_init(void) +{ + char *desc = "sfh7741"; + int error; + + error = gpio_request(OMAP4_SFH7741_SENSOR_OUTPUT_GPIO, "sfh7741"); + if (error < 0) { + pr_err("%s: GPIO configuration failed: GPIO %d, error %d\n" + , __func__, OMAP4_SFH7741_SENSOR_OUTPUT_GPIO, error); + return ; + } + + error = gpio_direction_input(OMAP4_SFH7741_SENSOR_OUTPUT_GPIO); + if (error < 0) { + pr_err("Proximity GPIO input configuration failed\n"); + goto fail1; + } + + 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); + goto fail1; + } + + 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); + goto fail3; + } + return; + +fail3: + gpio_free(OMAP4_SFH7741_ENABLE_GPIO); +fail1: + gpio_free(OMAP4_SFH7741_SENSOR_OUTPUT_GPIO); +} static void __init omap_4430sdp_init(void) { platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices)); @@ -120,6 +190,7 @@ static void __init omap_4430sdp_init(void) /* FIXME: allow multi-omap to boot until musb is updated for omap4 */ if (!cpu_is_omap44xx()) usb_musb_init(&musb_board_data); + omap_sfh7741prox_init(); } static void __init omap_4430sdp_map_io(void)