aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@no-log.org>2013-05-18 19:34:02 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@no-log.org>2013-05-18 23:21:36 +0200
commit6def4103ce10bf611247eb648bcdfe4f0db19cc5 (patch)
treeac5acd67d2d0b8b04de27ca792365d574dea0797
parentc04dbe9ea981d857ff255503e366bd7880096f36 (diff)
downloadkernel_goldelico_gta04-6def4103ce10bf611247eb648bcdfe4f0db19cc5.zip
kernel_goldelico_gta04-6def4103ce10bf611247eb648bcdfe4f0db19cc5.tar.gz
kernel_goldelico_gta04-6def4103ce10bf611247eb648bcdfe4f0db19cc5.tar.bz2
GTA04: Add Platform Android Jack driver
This driver is based on the tuna Platform SEC Jack driver. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
-rw-r--r--arch/arm/mach-omap2/Makefile1
-rw-r--r--arch/arm/mach-omap2/board-omap3gta04-jack.c111
-rw-r--r--arch/arm/mach-omap2/board-omap3gta04-jack.h6
-rw-r--r--arch/arm/mach-omap2/board-omap3gta04.c3
4 files changed, 121 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 759dfc9..430f2fd 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -181,6 +181,7 @@ obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \
hsmmc.o
obj-$(CONFIG_MACH_GTA04) += board-omap3gta04.o \
+ board-omap3gta04-jack.o \
hsmmc.o
obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \
hsmmc.o
diff --git a/arch/arm/mach-omap2/board-omap3gta04-jack.c b/arch/arm/mach-omap2/board-omap3gta04-jack.c
new file mode 100644
index 0000000..da27b5b
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3gta04-jack.c
@@ -0,0 +1,111 @@
+/* Board support file for Samsung Tuna Board.
+ *
+ * Copyright (C) 2011 Google, Inc.
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * Based on mach-omap2/board-omap4panda.c
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/i2c/twl4030-madc.h>
+#include <linux/sec_jack.h>
+
+#include "board-omap3gta04-jack.h"
+//#include "mux.h"
+
+#define ADC_CHANNEL_JACK 7
+
+static struct sec_jack_zone sec_jack_zones[] = {
+ {
+ /* adc < 100, unstable zone, default to 3pole if it stays
+ * in this range for a half second (20ms delays, 100 samples)
+ */
+ .adc_high = 100,
+ .delay_ms = 20,
+ .check_count = 100,
+ .jack_type = SEC_HEADSET_3POLE,
+ },
+ {
+ /* 100 < adc <= 820, unstable zone, default to 3pole if it stays
+ * in this range for a second (20ms delays, 100 samples)
+ */
+ .adc_high = 820,
+ .delay_ms = 20,
+ .check_count = 100,
+ .jack_type = SEC_HEADSET_3POLE,
+ },
+ {
+ /* adc >= 820, unstable zone, default to 4pole if it
+ * stays in this range for a second (10ms delays, 100 samples)
+ */
+ .adc_high = 0x7fffffff,
+ .delay_ms = 20,
+ .check_count = 100,
+ .jack_type = SEC_HEADSET_4POLE,
+ },
+};
+
+/* To support 3-buttons earjack */
+static struct sec_jack_buttons_zone sec_jack_buttons_zones[] = {
+ {
+ /* 0 <= adc <= 93, stable zone */
+ .code = KEY_MEDIA,
+ .adc_low = 0,
+ .adc_high = 93,
+ },
+ {
+ /* 94 <= adc <= 167, stable zone */
+ .code = KEY_PREVIOUSSONG,
+ .adc_low = 94,
+ .adc_high = 167,
+ },
+ {
+ /* 168 <= adc <= 370, stable zone */
+ .code = KEY_NEXTSONG,
+ .adc_low = 168,
+ .adc_high = 370,
+ },
+};
+
+static int sec_jack_get_adc_value(void)
+{
+ int value;
+
+ value = twl4030_get_madc_conversion(ADC_CHANNEL_JACK);
+// return (int)(1800*value) / 1024;
+ return value;
+}
+
+struct sec_jack_platform_data sec_jack_pdata = {
+ .get_adc_value = sec_jack_get_adc_value,
+ .zones = sec_jack_zones,
+ .num_zones = ARRAY_SIZE(sec_jack_zones),
+#if 0 /* TODO */
+ .buttons_zones = sec_jack_buttons_zones,
+ .num_buttons_zones = ARRAY_SIZE(sec_jack_buttons_zones),
+#endif
+};
+
+static struct platform_device sec_device_jack = {
+ .name = "sec_jack",
+ .id = 1, /* will be used also for gpio_event id */
+ .dev.platform_data = &sec_jack_pdata,
+};
+
+void __init omap3_gta04_jack_init(void)
+{
+ platform_device_register(&sec_device_jack);
+}
diff --git a/arch/arm/mach-omap2/board-omap3gta04-jack.h b/arch/arm/mach-omap2/board-omap3gta04-jack.h
new file mode 100644
index 0000000..397bd53
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3gta04-jack.h
@@ -0,0 +1,6 @@
+#ifndef BOARD_OMAP3_GTA04_JACK_H
+#define BOARD_OMAP3_GTA04_JACK_H
+
+void omap3_gta04_jack_init(void);
+
+#endif
diff --git a/arch/arm/mach-omap2/board-omap3gta04.c b/arch/arm/mach-omap2/board-omap3gta04.c
index aed67b3..fd6e88c 100644
--- a/arch/arm/mach-omap2/board-omap3gta04.c
+++ b/arch/arm/mach-omap2/board-omap3gta04.c
@@ -78,6 +78,7 @@
#include "pm.h"
#include "common-board-devices.h"
#include "control.h"
+#include "board-omap3gta04-jack.h"
#define GPMC_CS0_BASE 0x60
#define GPMC_CS_SIZE 0x30
@@ -1288,6 +1289,8 @@ static void __init gta04_init(void)
gta04_opp_init();
+ omap3_gta04_jack_init();
+
printk("gta04_init done...\n");
}