linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support.
@ 2010-05-12  8:52 Datta, Shubhrajyoti
  2010-05-12 13:22 ` Nishanth Menon
  0 siblings, 1 reply; 2+ messages in thread
From: Datta, Shubhrajyoti @ 2010-05-12  8:52 UTC (permalink / raw)
  To: linux-input@vger.kernel.org, linux-omap@vger.kernel.org
  Cc: Datta, Shubhrajyoti


Adding board support for the proximity sensor.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 arch/arm/mach-omap2/board-4430sdp.c |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

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 <linux/io.h>
 #include <linux/gpio.h>
 #include <linux/usb/otg.h>
+#include <linux/input/sfh7741.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -31,7 +32,25 @@
 #include <plat/usb.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
+#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)
-- 
1.5.4.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support.
  2010-05-12  8:52 [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support Datta, Shubhrajyoti
@ 2010-05-12 13:22 ` Nishanth Menon
  0 siblings, 0 replies; 2+ messages in thread
From: Nishanth Menon @ 2010-05-12 13:22 UTC (permalink / raw)
  To: Datta, Shubhrajyoti
  Cc: linux-input@vger.kernel.org, linux-omap@vger.kernel.org

Datta, Shubhrajyoti had written, on 05/12/2010 03:52 AM, the following:
> Adding board support for the proximity sensor.
> 
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> ---
>  arch/arm/mach-omap2/board-4430sdp.c |   71 +++++++++++++++++++++++++++++++++++
>  1 files changed, 71 insertions(+), 0 deletions(-)
> 
> 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 <linux/io.h>
>  #include <linux/gpio.h>
>  #include <linux/usb/otg.h>
> +#include <linux/input/sfh7741.h>
>  
>  #include <mach/hardware.h>
>  #include <asm/mach-types.h>
> @@ -31,7 +32,25 @@
>  #include <plat/usb.h>
>  #include <asm/hardware/gic.h>
>  #include <asm/hardware/cache-l2x0.h>
> +#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);
> +}

a) mux handling?
b) if init failed, still register the prox device? it wont function right?

>  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)


-- 
Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-12 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12  8:52 [RFC] [PATCHv2 2/2] SFH7741: Proximity sensor board support Datta, Shubhrajyoti
2010-05-12 13:22 ` Nishanth Menon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).