diff options
author | Shubhrajyoti Datta <shubhrajyoti@ti.com> | 2010-09-23 21:22:49 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-09-24 20:37:35 -0400 |
commit | 94ce7a6628ccaa71f0a5f26f6ff7dc7b0f0f65b7 (patch) | |
tree | 505439beb5f5435b9c007c4901f968162e9bc865 /arch/arm/mach-omap2 | |
parent | e3333f48dd5cb21b8d43d6d3a434055815084f1e (diff) |
omap: 4430sdp board support for proximity sensor
omap 4430sdp board support for the proximity sensor via GPIO keys.
The proximity sensor is connected to GPIO and is registered as a
GPIO key.
- Making the default state of the sensor off at bootup
- The init is called before platform_add_devices
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/board-4430sdp.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index 5b6a48dad86f..d2b917382b42 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/usb/otg.h> | 20 | #include <linux/usb/otg.h> |
21 | #include <linux/spi/spi.h> | 21 | #include <linux/spi/spi.h> |
22 | #include <linux/i2c/twl.h> | 22 | #include <linux/i2c/twl.h> |
23 | #include <linux/gpio_keys.h> | ||
23 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
24 | #include <linux/leds.h> | 25 | #include <linux/leds.h> |
25 | 26 | ||
@@ -40,6 +41,8 @@ | |||
40 | #define ETH_KS8851_IRQ 34 | 41 | #define ETH_KS8851_IRQ 34 |
41 | #define ETH_KS8851_POWER_ON 48 | 42 | #define ETH_KS8851_POWER_ON 48 |
42 | #define ETH_KS8851_QUART 138 | 43 | #define ETH_KS8851_QUART 138 |
44 | #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184 | ||
45 | #define OMAP4_SFH7741_ENABLE_GPIO 188 | ||
43 | 46 | ||
44 | static struct gpio_led sdp4430_gpio_leds[] = { | 47 | static struct gpio_led sdp4430_gpio_leds[] = { |
45 | { | 48 | { |
@@ -77,11 +80,47 @@ static struct gpio_led sdp4430_gpio_leds[] = { | |||
77 | 80 | ||
78 | }; | 81 | }; |
79 | 82 | ||
83 | static struct gpio_keys_button sdp4430_gpio_keys[] = { | ||
84 | { | ||
85 | .desc = "Proximity Sensor", | ||
86 | .type = EV_SW, | ||
87 | .code = SW_FRONT_PROXIMITY, | ||
88 | .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO, | ||
89 | .active_low = 0, | ||
90 | } | ||
91 | }; | ||
92 | |||
80 | static struct gpio_led_platform_data sdp4430_led_data = { | 93 | static struct gpio_led_platform_data sdp4430_led_data = { |
81 | .leds = sdp4430_gpio_leds, | 94 | .leds = sdp4430_gpio_leds, |
82 | .num_leds = ARRAY_SIZE(sdp4430_gpio_leds), | 95 | .num_leds = ARRAY_SIZE(sdp4430_gpio_leds), |
83 | }; | 96 | }; |
84 | 97 | ||
98 | static int omap_prox_activate(struct device *dev) | ||
99 | { | ||
100 | gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1); | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static void omap_prox_deactivate(struct device *dev) | ||
105 | { | ||
106 | gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0); | ||
107 | } | ||
108 | |||
109 | static struct gpio_keys_platform_data sdp4430_gpio_keys_data = { | ||
110 | .buttons = sdp4430_gpio_keys, | ||
111 | .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys), | ||
112 | .enable = omap_prox_activate, | ||
113 | .disable = omap_prox_deactivate, | ||
114 | }; | ||
115 | |||
116 | static struct platform_device sdp4430_gpio_keys_device = { | ||
117 | .name = "gpio-keys", | ||
118 | .id = -1, | ||
119 | .dev = { | ||
120 | .platform_data = &sdp4430_gpio_keys_data, | ||
121 | }, | ||
122 | }; | ||
123 | |||
85 | static struct platform_device sdp4430_leds_gpio = { | 124 | static struct platform_device sdp4430_leds_gpio = { |
86 | .name = "leds-gpio", | 125 | .name = "leds-gpio", |
87 | .id = -1, | 126 | .id = -1, |
@@ -161,6 +200,7 @@ static struct platform_device sdp4430_lcd_device = { | |||
161 | 200 | ||
162 | static struct platform_device *sdp4430_devices[] __initdata = { | 201 | static struct platform_device *sdp4430_devices[] __initdata = { |
163 | &sdp4430_lcd_device, | 202 | &sdp4430_lcd_device, |
203 | &sdp4430_gpio_keys_device, | ||
164 | &sdp4430_leds_gpio, | 204 | &sdp4430_leds_gpio, |
165 | }; | 205 | }; |
166 | 206 | ||
@@ -432,11 +472,32 @@ static int __init omap4_i2c_init(void) | |||
432 | ARRAY_SIZE(sdp4430_i2c_4_boardinfo)); | 472 | ARRAY_SIZE(sdp4430_i2c_4_boardinfo)); |
433 | return 0; | 473 | return 0; |
434 | } | 474 | } |
475 | |||
476 | static void __init omap_sfh7741prox_init(void) | ||
477 | { | ||
478 | int error; | ||
479 | |||
480 | error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741"); | ||
481 | if (error < 0) { | ||
482 | pr_err("%s:failed to request GPIO %d, error %d\n", | ||
483 | __func__, OMAP4_SFH7741_ENABLE_GPIO, error); | ||
484 | return; | ||
485 | } | ||
486 | |||
487 | error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0); | ||
488 | if (error < 0) { | ||
489 | pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n", | ||
490 | __func__, OMAP4_SFH7741_ENABLE_GPIO, error); | ||
491 | gpio_free(OMAP4_SFH7741_ENABLE_GPIO); | ||
492 | } | ||
493 | } | ||
494 | |||
435 | static void __init omap_4430sdp_init(void) | 495 | static void __init omap_4430sdp_init(void) |
436 | { | 496 | { |
437 | int status; | 497 | int status; |
438 | 498 | ||
439 | omap4_i2c_init(); | 499 | omap4_i2c_init(); |
500 | omap_sfh7741prox_init(); | ||
440 | platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices)); | 501 | platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices)); |
441 | omap_serial_init(); | 502 | omap_serial_init(); |
442 | omap4_twl6030_hsmmc_init(mmc); | 503 | omap4_twl6030_hsmmc_init(mmc); |