summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.1
diff options
context:
space:
mode:
authorJoel A Fernandes <joelagnel@ti.com>2011-11-29 11:00:28 -0600
committerKoen Kooi <koen@dominion.thruhere.net>2011-11-30 08:47:30 +0100
commit9a9069a5960455ed6e67379dd836fab6a45d5def (patch)
tree12612eab5b43b9994b74a8a7ffc99d2a6ee9f693 /recipes-kernel/linux/linux-ti33x-psp-3.1
parentcb28528824be948644873e474288b06b1a904882 (diff)
downloadmeta-ti-9a9069a5960455ed6e67379dd836fab6a45d5def.tar.gz
linux-ti33x-psp 3.1: ADC support for beaglebone
First 3 patches are cherry picks from PSP. Next 7 add support for gen purpose adc, MFD support, sysfs triggering etc. Currently: cat /sys/bus/platform/tsc/ain* will trigger sampling Output of the 12-bit ADC will be in decimal 0-4095 TODO: 1. IIO driver support 2. Other ADC features Signed-off-by: Joel A Fernandes <joelagnel@ti.com> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.1')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch219
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch122
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch219
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch463
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch86
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch26
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch46
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch151
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch34
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch54
10 files changed, 1420 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch
new file mode 100644
index 00000000..b4b14b87
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch
@@ -0,0 +1,219 @@
1From 3c22386bee665fb13aeb1f28016a9e77fc6c2dc2 Mon Sep 17 00:00:00 2001
2From: Patil, Rachna <rachna@ti.com>
3Date: Fri, 11 Nov 2011 18:03:27 +0530
4Subject: [PATCH 1/9] AM335x: Add support for TSC on Beta GP EVM.
5
6AN1 and AN2(analog inputs to analog front end) were swapped
7on alpha EVM's. This change is IP dependent, hence changes are
8made in the driver to support the beta EVM.
9
10Signed-off-by: Patil, Rachna <rachna@ti.com>
11---
12 arch/arm/mach-omap2/board-am335xevm.c | 8 +++
13 drivers/input/touchscreen/ti_tscadc.c | 83 ++++++++++++++++++++++-----------
14 include/linux/input/ti_tscadc.h | 10 ++++
15 3 files changed, 73 insertions(+), 28 deletions(-)
16
17diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
18index 590c4ca..9ec56c6 100644
19--- a/arch/arm/mach-omap2/board-am335xevm.c
20+++ b/arch/arm/mach-omap2/board-am335xevm.c
21@@ -912,6 +912,14 @@ static void dvi_init(int evm_id, int profile)
22 static void tsc_init(int evm_id, int profile)
23 {
24 int err;
25+
26+ if (gp_evm_revision == GP_EVM_REV_IS_1_1A) {
27+ am335x_touchscreen_data.analog_input = 1;
28+ pr_info("TSC connected to beta GP EVM\n");
29+ } else {
30+ am335x_touchscreen_data.analog_input = 0;
31+ pr_info("TSC connected to alpha GP EVM\n");
32+ }
33 setup_pin_mux(tsc_pin_mux);
34 err = platform_device_register(&tsc_device);
35 if (err)
36diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
37index 1f4db8d..021db7f 100644
38--- a/drivers/input/touchscreen/ti_tscadc.c
39+++ b/drivers/input/touchscreen/ti_tscadc.c
40@@ -65,13 +65,16 @@
41 #define TSCADC_STEPCONFIG_RFP (1 << 12)
42 #define TSCADC_STEPCONFIG_INM (1 << 18)
43 #define TSCADC_STEPCONFIG_INP_4 (1 << 19)
44+#define TSCADC_STEPCONFIG_INP (1 << 20)
45 #define TSCADC_STEPCONFIG_INP_5 (1 << 21)
46 #define TSCADC_STEPCONFIG_FIFO1 (1 << 26)
47 #define TSCADC_STEPCONFIG_IDLE_INP (1 << 22)
48 #define TSCADC_STEPCONFIG_OPENDLY 0x018
49 #define TSCADC_STEPCONFIG_SAMPLEDLY 0x88
50-#define TSCADC_STEPCHARGE_INM BIT(16)
51-#define TSCADC_STEPCHARGE_INP BIT(20)
52+#define TSCADC_STEPCHARGE_INM_SWAP BIT(16)
53+#define TSCADC_STEPCHARGE_INM BIT(15)
54+#define TSCADC_STEPCHARGE_INP_SWAP BIT(20)
55+#define TSCADC_STEPCHARGE_INP BIT(19)
56 #define TSCADC_STEPCHARGE_RFM (1 << 23)
57 #define TSCADC_STEPCHARGE_DELAY 0x1
58 #define TSCADC_CNTRLREG_TSCSSENB BIT(0)
59@@ -94,6 +97,7 @@ unsigned int bckup_x = 0, bckup_y = 0;
60 struct tscadc {
61 struct input_dev *input;
62 int wires;
63+ int analog_input;
64 struct clk *clk;
65 int irq;
66 void __iomem *tsc_base;
67@@ -121,21 +125,37 @@ static void tsc_step_config(struct tscadc *ts_dev)
68 delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
69
70 stepconfigx = TSCADC_STEPCONFIG_MODE_HWSYNC |
71- TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP |
72- TSCADC_STEPCONFIG_YPN;
73+ TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP;
74+
75 switch (ts_dev->wires) {
76 case 4:
77- stepconfigx |= TSCADC_STEPCONFIG_INP_4;
78+ if (ts_dev->analog_input == 0)
79+ stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
80+ TSCADC_STEPCONFIG_YPN;
81+ else
82+ stepconfigx |= TSCADC_STEPCONFIG_INP |
83+ TSCADC_STEPCONFIG_XNN;
84 break;
85 case 5:
86- stepconfigx |= TSCADC_STEPCONFIG_YPP |
87- TSCADC_STEPCONFIG_YNN |
88+ stepconfigx |= TSCADC_STEPCONFIG_YNN |
89 TSCADC_STEPCONFIG_INP_5;
90+ if (ts_dev->analog_input == 0)
91+ stepconfigx |= TSCADC_STEPCONFIG_XNP |
92+ TSCADC_STEPCONFIG_YPN;
93+ else
94+ stepconfigx |= TSCADC_STEPCONFIG_XNN |
95+ TSCADC_STEPCONFIG_YPP;
96 break;
97 case 8:
98- stepconfigx |= TSCADC_STEPCONFIG_INP_4;
99+ if (ts_dev->analog_input == 0)
100+ stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
101+ TSCADC_STEPCONFIG_YPN;
102+ else
103+ stepconfigx |= TSCADC_STEPCONFIG_INP |
104+ TSCADC_STEPCONFIG_XNN;
105 break;
106 }
107+
108 for (i = 1; i < 7; i++) {
109 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigx);
110 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
111@@ -146,18 +166,28 @@ static void tsc_step_config(struct tscadc *ts_dev)
112 TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_FIFO1;
113 switch (ts_dev->wires) {
114 case 4:
115- stepconfigy |= TSCADC_STEPCONFIG_XNP;
116+ if (ts_dev->analog_input == 0)
117+ stepconfigy |= TSCADC_STEPCONFIG_XNP;
118+ else
119+ stepconfigy |= TSCADC_STEPCONFIG_YPP;
120 break;
121 case 5:
122- stepconfigy |= TSCADC_STEPCONFIG_XPP |
123- TSCADC_STEPCONFIG_XNP |
124- TSCADC_STEPCONFIG_YPN |
125- TSCADC_STEPCONFIG_INP_5;
126+ stepconfigy |= TSCADC_STEPCONFIG_XPP | TSCADC_STEPCONFIG_INP_5;
127+ if (ts_dev->analog_input == 0)
128+ stepconfigy |= TSCADC_STEPCONFIG_XNN |
129+ TSCADC_STEPCONFIG_YPP;
130+ else
131+ stepconfigy |= TSCADC_STEPCONFIG_XNP |
132+ TSCADC_STEPCONFIG_YPN;
133 break;
134 case 8:
135- stepconfigy |= TSCADC_STEPCONFIG_XNP;
136+ if (ts_dev->analog_input == 0)
137+ stepconfigy |= TSCADC_STEPCONFIG_XNP;
138+ else
139+ stepconfigy |= TSCADC_STEPCONFIG_YPP;
140 break;
141 }
142+
143 for (i = 7; i < 13; i++) {
144 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigy);
145 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
146@@ -166,8 +196,12 @@ static void tsc_step_config(struct tscadc *ts_dev)
147 chargeconfig = TSCADC_STEPCONFIG_XPP |
148 TSCADC_STEPCONFIG_YNN |
149 TSCADC_STEPCONFIG_RFP |
150- TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP |
151 TSCADC_STEPCHARGE_RFM;
152+ if (ts_dev->analog_input == 0)
153+ chargeconfig |= TSCADC_STEPCHARGE_INM_SWAP |
154+ TSCADC_STEPCHARGE_INP_SWAP;
155+ else
156+ chargeconfig |= TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP;
157 tscadc_writel(ts_dev, TSCADC_REG_CHARGECONFIG, chargeconfig);
158 tscadc_writel(ts_dev, TSCADC_REG_CHARGEDELAY, TSCADC_STEPCHARGE_DELAY);
159
160@@ -180,20 +214,12 @@ static void tsc_idle_config(struct tscadc *ts_config)
161 unsigned int idleconfig;
162
163 idleconfig = TSCADC_STEPCONFIG_YNN |
164- TSCADC_STEPCONFIG_XNN |
165- TSCADC_STEPCONFIG_INM;
166+ TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_IDLE_INP;
167+ if (ts_config->analog_input == 0)
168+ idleconfig |= TSCADC_STEPCONFIG_XNN;
169+ else
170+ idleconfig |= TSCADC_STEPCONFIG_YPN;
171
172- switch (ts_config->wires) {
173- case 4:
174- idleconfig |= TSCADC_STEPCONFIG_IDLE_INP;
175- break;
176- case 5:
177- idleconfig |= TSCADC_STEPCONFIG_INP_5;
178- break;
179- case 8:
180- idleconfig |= TSCADC_STEPCONFIG_INP_4;
181- break;
182- }
183 tscadc_writel(ts_config, TSCADC_REG_IDLECONFIG, idleconfig);
184 }
185
186@@ -376,6 +402,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
187 tscadc_writel(ts_dev, TSCADC_REG_IRQWAKEUP, TSCADC_IRQWKUP_ENB);
188
189 ts_dev->wires = pdata->wires;
190+ ts_dev->analog_input = pdata->analog_input;
191
192 /* Set the control register bits */
193 ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT |
194diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
195index 29f87db..b9d9a46 100644
196--- a/include/linux/input/ti_tscadc.h
197+++ b/include/linux/input/ti_tscadc.h
198@@ -3,8 +3,18 @@
199 * @wires: Wires refer to application modes
200 * i.e. 4/5/8 wire touchscreen support
201 * on the platform
202+ * @analog_input: Analog inputs refer to the order in which the
203+ * connections are made to the AFE. If the connections
204+ * are as : XPUL = AN0,XNUR = AN1,YPLL = AN2,
205+ * YNLR = AN3, then this variable is set to 1.
206+ * Else if the connections are as :
207+ * XPUL = AN0,YPLL = AN1,XNUR = AN2,
208+ * YNLR = AN3, then set this variable to
209+ * 0.
210 */
211
212 struct tsc_data {
213 int wires;
214+ int analog_input;
215+
216 };
217--
2181.7.4.1
219
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch
new file mode 100644
index 00000000..c7e4b786
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0002-ARM-OMAP-AM335x-Add-support-for-Beta-GP-EVM.patch
@@ -0,0 +1,122 @@
1From 98d0446f94a6f89016f5ed73cb6bc304075cceb6 Mon Sep 17 00:00:00 2001
2From: Patil, Rachna <rachna@ti.com>
3Date: Fri, 11 Nov 2011 13:09:51 +0530
4Subject: [PATCH 2/9] ARM: OMAP: AM335x: Add support for Beta GP EVM.
5
6This patch adds support for BETA EVM.
7BETA EVM is set as the default configuration.
8Since the peripherals were supported only in profile 0 for
9alpha EVM, It makes use of the exisiting GP EVM structure.
10
11Changes have been made to MMC and audio.
12
13Flag gp_evm_revision can be used to differentiate between the
14revisions of the GP EVM.
15
16Signed-off-by: Patil, Rachna <rachna@ti.com>
17---
18 arch/arm/mach-omap2/board-am335xevm.c | 57 ++++++++++++---------------------
19 1 files changed, 21 insertions(+), 36 deletions(-)
20
21diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
22index 9ec56c6..d6bf7b1 100644
23--- a/arch/arm/mach-omap2/board-am335xevm.c
24+++ b/arch/arm/mach-omap2/board-am335xevm.c
25@@ -329,6 +329,11 @@ struct am335x_evm_eeprom_config {
26 static struct am335x_evm_eeprom_config config;
27 static bool daughter_brd_detected;
28
29+#define GP_EVM_REV_IS_1_0A 0x1
30+#define GP_EVM_REV_IS_1_1A 0x2
31+#define GP_EVM_REV_IS_UNKNOWN 0xFF
32+static unsigned int gp_evm_revision = GP_EVM_REV_IS_UNKNOWN;
33+
34 #define EEPROM_MAC_ADDRESS_OFFSET 60 /* 4+8+4+12+32 */
35 #define EEPROM_NO_OF_MAC_ADDR 3
36 static char am335x_mac_addr[EEPROM_NO_OF_MAC_ADDR][ETH_ALEN];
37@@ -629,25 +634,8 @@ static struct pinmux_config mmc1_pin_mux[] = {
38 {"gpmc_ad0.mmc1_dat0", OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLUP},
39 {"gpmc_csn1.mmc1_clk", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
40 {"gpmc_csn2.mmc1_cmd", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
41- {"uart1_rxd.mmc1_sdwp", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
42- {"mcasp0_fsx.mmc1_sdcd", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
43- {NULL, 0},
44-};
45-
46-/* Module pin mux for mmc2 */
47-static struct pinmux_config mmc2_pin_mux[] = {
48- {"gpmc_ad11.mmc2_dat7", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
49- {"gpmc_ad10.mmc2_dat6", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
50- {"gpmc_ad9.mmc2_dat5", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
51- {"gpmc_ad8.mmc2_dat4", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
52- {"gpmc_ad15.mmc2_dat3", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
53- {"gpmc_ad14.mmc2_dat2", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
54- {"gpmc_ad13.mmc2_dat1", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
55- {"gpmc_ad12.mmc2_dat0", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
56- {"gpmc_clk.mmc2_clk", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
57- {"gpmc_csn3.mmc2_cmd", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
58- {"spi0_cs0.mmc2_sdwp", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
59- {"mcasp0_axr0.mmc2_sdcd", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
60+ {"gpmc_csn0.mmc1_sdwp", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
61+ {"gpmc_advn_ale.mmc1_sdcd", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
62 {NULL, 0},
63 };
64
65@@ -1138,20 +1126,6 @@ static void mmc1_init(int evm_id, int profile)
66 return;
67 }
68
69-static void mmc2_init(int evm_id, int profile)
70-{
71- setup_pin_mux(mmc2_pin_mux);
72-
73- am335x_mmc[1].mmc = 3;
74- am335x_mmc[1].caps = MMC_CAP_4_BIT_DATA;
75- am335x_mmc[1].gpio_cd = GPIO_TO_PIN(3, 16);
76- am335x_mmc[1].gpio_wp = GPIO_TO_PIN(0, 5);
77- am335x_mmc[1].ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34; /* 3V3 */
78-
79- /* mmc will be initialized when mmc0_init is called */
80- return;
81-}
82-
83 static void mmc2_wl12xx_init(int evm_id, int profile)
84 {
85 setup_pin_mux(mmc2_wl12xx_pin_mux);
86@@ -1488,9 +1462,8 @@ static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
87 {evm_nand_init, DEV_ON_DGHTR_BRD,
88 (PROFILE_ALL & ~PROFILE_2 & ~PROFILE_3)},
89 {i2c1_init, DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_3 | PROFILE_7)},
90- {mcasp1_init, DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_3) },
91+ {mcasp1_init, DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_3 | PROFILE_7) },
92 {mmc1_init, DEV_ON_DGHTR_BRD, PROFILE_2},
93- {mmc2_init, DEV_ON_DGHTR_BRD, PROFILE_4},
94 {mmc2_wl12xx_init, DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 |
95 PROFILE_5)},
96 {mmc0_init, DEV_ON_BASEBOARD, (PROFILE_ALL & ~PROFILE_5)},
97@@ -1563,9 +1536,21 @@ static void setup_low_cost_evm(void)
98 static void setup_general_purpose_evm(void)
99 {
100 u32 prof_sel = am335x_get_profile_selection();
101-
102 pr_info("The board is general purpose EVM in profile %d\n", prof_sel);
103
104+ if (!strncmp("1.1A", config.version, 4)) {
105+ pr_info("EVM version is %s\n", config.version);
106+ gp_evm_revision = GP_EVM_REV_IS_1_1A;
107+ }
108+ else if (!strncmp("1.0A", config.version, 4)) {
109+ pr_info("EVM version is %s\n", config.version);
110+ gp_evm_revision = GP_EVM_REV_IS_1_0A;
111+ }
112+ else {
113+ pr_err("EVM version read fail, falling back to Rev1.1A");
114+ gp_evm_revision = GP_EVM_REV_IS_1_1A;
115+ }
116+
117 _configure_device(GEN_PURP_EVM, gen_purp_evm_dev_cfg, (1L << prof_sel));
118 }
119
120--
1211.7.4.1
122
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch
new file mode 100644
index 00000000..9e733162
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0003-AM335x-Add-support-for-pressure-measurement-on-TSC.patch
@@ -0,0 +1,219 @@
1From b086fa2754f2c5f4f05a9690f170e2ef86207b4e Mon Sep 17 00:00:00 2001
2From: Patil, Rachna <rachna@ti.com>
3Date: Fri, 11 Nov 2011 18:28:54 +0530
4Subject: [PATCH 3/9] AM335x: Add support for pressure measurement on TSC.
5
6This patch adds support for pressure measurement configurations
7on TSC. Along with X and Y co-ordinates pressure is also reported to
8the sub-system.
9
10Signed-off-by: Patil, Rachna <rachna@ti.com>
11---
12 arch/arm/mach-omap2/board-am335xevm.c | 1 +
13 drivers/input/touchscreen/ti_tscadc.c | 77 +++++++++++++++++++++++++++------
14 include/linux/input/ti_tscadc.h | 3 +-
15 3 files changed, 66 insertions(+), 15 deletions(-)
16
17diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
18index d6bf7b1..46fce3e 100644
19--- a/arch/arm/mach-omap2/board-am335xevm.c
20+++ b/arch/arm/mach-omap2/board-am335xevm.c
21@@ -194,6 +194,7 @@ static struct resource tsc_resources[] = {
22
23 static struct tsc_data am335x_touchscreen_data = {
24 .wires = 4,
25+ .x_plate_resistance = 200,
26 };
27
28 static struct platform_device tsc_device = {
29diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
30index 021db7f..9783435 100644
31--- a/drivers/input/touchscreen/ti_tscadc.c
32+++ b/drivers/input/touchscreen/ti_tscadc.c
33@@ -41,6 +41,10 @@
34 #define TSCADC_REG_CHARGEDELAY 0x060
35 #define TSCADC_REG_STEPCONFIG(n) (0x64 + ((n-1) * 8))
36 #define TSCADC_REG_STEPDELAY(n) (0x68 + ((n-1) * 8))
37+#define TSCADC_REG_STEPCONFIG13 0x0C4
38+#define TSCADC_REG_STEPDELAY13 0x0C8
39+#define TSCADC_REG_STEPCONFIG14 0x0CC
40+#define TSCADC_REG_STEPDELAY14 0x0D0
41 #define TSCADC_REG_FIFO0CNT 0xE4
42 #define TSCADC_REG_FIFO0THR 0xE8
43 #define TSCADC_REG_FIFO1CNT 0xF0
44@@ -50,7 +54,7 @@
45
46 /* Register Bitfields */
47 #define TSCADC_IRQWKUP_ENB BIT(0)
48-#define TSCADC_STPENB_STEPENB 0x1fFF
49+#define TSCADC_STPENB_STEPENB 0x7FFF
50 #define TSCADC_IRQENB_FIFO0THRES BIT(2)
51 #define TSCADC_IRQENB_FIFO1THRES BIT(5)
52 #define TSCADC_IRQENB_PENUP BIT(9)
53@@ -71,10 +75,11 @@
54 #define TSCADC_STEPCONFIG_IDLE_INP (1 << 22)
55 #define TSCADC_STEPCONFIG_OPENDLY 0x018
56 #define TSCADC_STEPCONFIG_SAMPLEDLY 0x88
57-#define TSCADC_STEPCHARGE_INM_SWAP BIT(16)
58-#define TSCADC_STEPCHARGE_INM BIT(15)
59-#define TSCADC_STEPCHARGE_INP_SWAP BIT(20)
60-#define TSCADC_STEPCHARGE_INP BIT(19)
61+#define TSCADC_STEPCONFIG_Z1 (3 << 19)
62+#define TSCADC_STEPCHARGE_INM_SWAP BIT(16)
63+#define TSCADC_STEPCHARGE_INM BIT(15)
64+#define TSCADC_STEPCHARGE_INP_SWAP BIT(20)
65+#define TSCADC_STEPCHARGE_INP BIT(19)
66 #define TSCADC_STEPCHARGE_RFM (1 << 23)
67 #define TSCADC_STEPCHARGE_DELAY 0x1
68 #define TSCADC_CNTRLREG_TSCSSENB BIT(0)
69@@ -98,6 +103,7 @@ struct tscadc {
70 struct input_dev *input;
71 int wires;
72 int analog_input;
73+ int x_plate_resistance;
74 struct clk *clk;
75 int irq;
76 void __iomem *tsc_base;
77@@ -118,6 +124,7 @@ static void tsc_step_config(struct tscadc *ts_dev)
78 {
79 unsigned int stepconfigx = 0, stepconfigy = 0;
80 unsigned int delay, chargeconfig = 0;
81+ unsigned int stepconfigz1 = 0, stepconfigz2 = 0;
82 int i;
83
84 /* Configure the Step registers */
85@@ -205,6 +212,18 @@ static void tsc_step_config(struct tscadc *ts_dev)
86 tscadc_writel(ts_dev, TSCADC_REG_CHARGECONFIG, chargeconfig);
87 tscadc_writel(ts_dev, TSCADC_REG_CHARGEDELAY, TSCADC_STEPCHARGE_DELAY);
88
89+ /* Configure to calculate pressure */
90+ stepconfigz1 = TSCADC_STEPCONFIG_MODE_HWSYNC |
91+ TSCADC_STEPCONFIG_2SAMPLES_AVG |
92+ TSCADC_STEPCONFIG_XNP |
93+ TSCADC_STEPCONFIG_YPN | TSCADC_STEPCONFIG_INM;
94+ stepconfigz2 = stepconfigz1 | TSCADC_STEPCONFIG_Z1 |
95+ TSCADC_STEPCONFIG_FIFO1;
96+ tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG13, stepconfigz1);
97+ tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY13, delay);
98+ tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG14, stepconfigz2);
99+ tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY14, delay);
100+
101 tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB);
102 }
103
104@@ -235,14 +254,14 @@ static irqreturn_t tscadc_interrupt(int irq, void *dev)
105 unsigned int prev_diff_x = ~0, prev_diff_y = ~0;
106 unsigned int cur_diff_x = 0, cur_diff_y = 0;
107 unsigned int val_x = 0, val_y = 0, diffx = 0, diffy = 0;
108+ unsigned int z1 = 0, z2 = 0, z = 0;
109
110 status = tscadc_readl(ts_dev, TSCADC_REG_IRQSTATUS);
111
112 if (status & TSCADC_IRQENB_FIFO1THRES) {
113 fifo0count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
114 fifo1count = tscadc_readl(ts_dev, TSCADC_REG_FIFO1CNT);
115-
116- for (i = 0; i < fifo0count; i++) {
117+ for (i = 0; i < (fifo0count-1); i++) {
118 readx1 = tscadc_readl(ts_dev, TSCADC_REG_FIFO0);
119 readx1 = readx1 & 0xfff;
120 if (readx1 > prev_val_x)
121@@ -281,12 +300,39 @@ static irqreturn_t tscadc_interrupt(int irq, void *dev)
122 bckup_x = val_x;
123 bckup_y = val_y;
124
125- if (pen == 0) {
126- if ((diffx < 15) && (diffy < 15)) {
127- input_report_abs(input_dev, ABS_X, val_x);
128- input_report_abs(input_dev, ABS_Y, val_y);
129- input_report_key(input_dev, BTN_TOUCH, 1);
130- input_sync(input_dev);
131+ z1 = ((tscadc_readl(ts_dev, TSCADC_REG_FIFO0)) & 0xfff);
132+ z2 = ((tscadc_readl(ts_dev, TSCADC_REG_FIFO1)) & 0xfff);
133+
134+ if ((z1 != 0) && (z2 != 0)) {
135+ /*
136+ * cal pressure using formula
137+ * Resistance(touch) = x plate resistance *
138+ * x postion/4096 * ((z2 / z1) - 1)
139+ */
140+ z = z2 - z1;
141+ z *= val_x;
142+ z *= ts_dev->x_plate_resistance;
143+ z /= z1;
144+ z = (z + 2047) >> 12;
145+
146+ /*
147+ * Sample found inconsistent by debouncing
148+ * or pressure is beyond the maximum.
149+ * Don't report it to user space.
150+ */
151+ if (pen == 0) {
152+ if ((diffx < 15) && (diffy < 15)
153+ && (z <= MAX_12BIT)) {
154+ input_report_abs(input_dev, ABS_X,
155+ val_x);
156+ input_report_abs(input_dev, ABS_Y,
157+ val_y);
158+ input_report_abs(input_dev, ABS_PRESSURE,
159+ z);
160+ input_report_key(input_dev, BTN_TOUCH,
161+ 1);
162+ input_sync(input_dev);
163+ }
164 }
165 }
166 irqclr |= TSCADC_IRQENB_FIFO1THRES;
167@@ -303,6 +349,7 @@ static irqreturn_t tscadc_interrupt(int irq, void *dev)
168 bckup_x = 0;
169 bckup_y = 0;
170 input_report_key(input_dev, BTN_TOUCH, 0);
171+ input_report_abs(input_dev, ABS_PRESSURE, 0);
172 input_sync(input_dev);
173 } else {
174 pen = 0;
175@@ -403,6 +450,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
176
177 ts_dev->wires = pdata->wires;
178 ts_dev->analog_input = pdata->analog_input;
179+ ts_dev->x_plate_resistance = pdata->x_plate_resistance;
180
181 /* Set the control register bits */
182 ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT |
183@@ -430,7 +478,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
184
185 tsc_step_config(ts_dev);
186
187- tscadc_writel(ts_dev, TSCADC_REG_FIFO1THR, 5);
188+ tscadc_writel(ts_dev, TSCADC_REG_FIFO1THR, 6);
189
190 ctrl |= TSCADC_CNTRLREG_TSCSSENB;
191 tscadc_writel(ts_dev, TSCADC_REG_CTRL, ctrl);
192@@ -443,6 +491,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
193
194 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
195 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
196+ input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0);
197
198 /* register to the input system */
199 err = input_register_device(input_dev);
200diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
201index b9d9a46..2c547bb 100644
202--- a/include/linux/input/ti_tscadc.h
203+++ b/include/linux/input/ti_tscadc.h
204@@ -11,10 +11,11 @@
205 * XPUL = AN0,YPLL = AN1,XNUR = AN2,
206 * YNLR = AN3, then set this variable to
207 * 0.
208+ * @x_plate_resistance: X plate resistance.
209 */
210
211 struct tsc_data {
212 int wires;
213 int analog_input;
214-
215+ int x_plate_resistance;
216 };
217--
2181.7.4.1
219
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch
new file mode 100644
index 00000000..adbe1a5a
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0004-tscadc-Add-general-purpose-mode-untested-with-touchs.patch
@@ -0,0 +1,463 @@
1From 2b44ca7878e41f25b91486ebcb8db2c3be1f61eb Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Sat, 29 Oct 2011 01:17:43 -0500
4Subject: [PATCH 4/9] tscadc: Add general purpose mode, untested with touchscreen functionality
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 adc-notes.txt | 33 +++++
9 arch/arm/mach-omap2/board-am335xevm.c | 6 +
10 arch/arm/mach-omap2/mux33xx.c | 12 ++
11 arch/arm/mach-omap2/mux33xx.h | 4 +
12 drivers/input/touchscreen/ti_tscadc.c | 209 +++++++++++++++++++++++++--------
13 include/linux/input/ti_tscadc.h | 4 +
14 6 files changed, 216 insertions(+), 52 deletions(-)
15 create mode 100755 adc-notes.txt
16
17diff --git a/adc-notes.txt b/adc-notes.txt
18new file mode 100755
19index 0000000..178e262
20--- /dev/null
21+++ b/adc-notes.txt
22@@ -0,0 +1,33 @@
23+Features
24+ - software register bit for SOC (Start of conversion) and EOC
25+ - single conversion (one-shot) - software enabled
26+ - Data stored in either of 2 fifo groups- can be read through dma or cpu
27+
28+
29+Events
30+ - Status bit to indicate if ADC is busy converting (can use polling to check if conversion is finished)
31+ - Interrupts on FIFO threhold levels reached
32+ - In on one-shot mode, Step-enable bit is turned off automatically after conversion - can be used to check if conversion is finished.
33+ - END_OF_SEQUENCE interrupt can be configured when the FSM is done with the last enabled step (but should not be used to check if data is in the FIFO)
34+ - For availability of data, the FIFO interrupts and word count reg should be used.
35+
36+Clocks-
37+ - ADC uses adc_clk
38+ - Sequencers, FIFO etc use ocp_clk
39+
40+One shot mode
41+ - Step-enable bit is turned off automatically after conversion - can be used to check if conversion is finished.
42+
43+ADC Controller
44+==============
45+*** config steps
46+1. configure a STEPCONFIG register
47+ For ADC we would like to configure the steps as general-purpose (non-touch screen)
48+2. Enable TSC_ADC_SS
49+3. Set STEPENABLE bit of any step for the sequencer to go to that step, perform conversion and store the data in FIFO
50+
51+*** reading data:
52+1. Check word count reg in FIFO register
53+2. If non 0, read word
54+3. Step enable bit can be polled to check if conversion is over or not.
55+
56diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
57index 46fce3e..c8da580 100644
58--- a/arch/arm/mach-omap2/board-am335xevm.c
59+++ b/arch/arm/mach-omap2/board-am335xevm.c
60@@ -456,6 +456,10 @@ static struct pinmux_config tsc_pin_mux[] = {
61 {"ain1.ain1", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
62 {"ain2.ain2", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
63 {"ain3.ain3", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
64+ {"ain4.ain4", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
65+ {"ain5.ain5", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
66+ {"ain6.ain6", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
67+ {"ain7.ain7", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
68 {"vrefp.vrefp", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
69 {"vrefn.vrefn", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
70 {NULL, 0},
71@@ -1513,6 +1517,7 @@ static struct evm_dev_cfg beaglebone_old_dev_cfg[] = {
72 {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
73 {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
74 {boneleds_init, DEV_ON_BASEBOARD, PROFILE_ALL},
75+ {tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
76 {NULL, 0, 0},
77 };
78
79@@ -1524,6 +1529,7 @@ static struct evm_dev_cfg beaglebone_dev_cfg[] = {
80 {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
81 {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
82 {boneleds_init, DEV_ON_BASEBOARD, PROFILE_ALL},
83+ {tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
84 {NULL, 0, 0},
85 };
86
87diff --git a/arch/arm/mach-omap2/mux33xx.c b/arch/arm/mach-omap2/mux33xx.c
88index 4399003..832a50b 100644
89--- a/arch/arm/mach-omap2/mux33xx.c
90+++ b/arch/arm/mach-omap2/mux33xx.c
91@@ -587,6 +587,18 @@ static struct omap_mux __initdata am33xx_muxmodes[] = {
92 _AM33XX_MUXENTRY(AIN3, 0,
93 "ain3", NULL, NULL, NULL,
94 NULL, NULL, NULL, NULL),
95+ _AM33XX_MUXENTRY(AIN4, 0,
96+ "ain4", NULL, NULL, NULL,
97+ NULL, NULL, NULL, NULL),
98+ _AM33XX_MUXENTRY(AIN5, 0,
99+ "ain5", NULL, NULL, NULL,
100+ NULL, NULL, NULL, NULL),
101+ _AM33XX_MUXENTRY(AIN6, 0,
102+ "ain6", NULL, NULL, NULL,
103+ NULL, NULL, NULL, NULL),
104+ _AM33XX_MUXENTRY(AIN7, 0,
105+ "ain7", NULL, NULL, NULL,
106+ NULL, NULL, NULL, NULL),
107 _AM33XX_MUXENTRY(VREFP, 0,
108 "vrefp", NULL, NULL, NULL,
109 NULL, NULL, NULL, NULL),
110diff --git a/arch/arm/mach-omap2/mux33xx.h b/arch/arm/mach-omap2/mux33xx.h
111index 70a3012..348c8e5 100644
112--- a/arch/arm/mach-omap2/mux33xx.h
113+++ b/arch/arm/mach-omap2/mux33xx.h
114@@ -228,6 +228,10 @@
115 #define AM33XX_CONTROL_PADCONF_DDR_DQSN1_OFFSET 0x0AFC
116 #define AM33XX_CONTROL_PADCONF_DDR_VREF_OFFSET 0x0B00
117 #define AM33XX_CONTROL_PADCONF_DDR_VTP_OFFSET 0x0B04
118+#define AM33XX_CONTROL_PADCONF_AIN7_OFFSET 0x0B10
119+#define AM33XX_CONTROL_PADCONF_AIN6_OFFSET 0x0B14
120+#define AM33XX_CONTROL_PADCONF_AIN5_OFFSET 0x0B18
121+#define AM33XX_CONTROL_PADCONF_AIN4_OFFSET 0x0B1C
122 #define AM33XX_CONTROL_PADCONF_AIN3_OFFSET 0x0B20
123 #define AM33XX_CONTROL_PADCONF_AIN2_OFFSET 0x0B24
124 #define AM33XX_CONTROL_PADCONF_AIN1_OFFSET 0x0B28
125diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
126index 9783435..76fc7b6 100644
127--- a/drivers/input/touchscreen/ti_tscadc.c
128+++ b/drivers/input/touchscreen/ti_tscadc.c
129@@ -27,6 +27,8 @@
130 #include <linux/input/ti_tscadc.h>
131 #include <linux/delay.h>
132
133+/* Memory mapped registers here have incorrect offsets!
134+ * Correct after referring TRM */
135 #define TSCADC_REG_IRQEOI 0x020
136 #define TSCADC_REG_RAWIRQSTATUS 0x024
137 #define TSCADC_REG_IRQSTATUS 0x028
138@@ -54,12 +56,18 @@
139
140 /* Register Bitfields */
141 #define TSCADC_IRQWKUP_ENB BIT(0)
142-#define TSCADC_STPENB_STEPENB 0x7FFF
143+#define TSCADC_STPENB_STEPENB_TOUCHSCREEN 0x7FFF
144+#define TSCADC_STPENB_STEPENB_GENERAL 0x0400
145 #define TSCADC_IRQENB_FIFO0THRES BIT(2)
146+#define TSCADC_IRQENB_FIFO0OVERRUN BIT(3)
147 #define TSCADC_IRQENB_FIFO1THRES BIT(5)
148+#define TSCADC_IRQENB_EOS BIT(1)
149 #define TSCADC_IRQENB_PENUP BIT(9)
150-#define TSCADC_STEPCONFIG_MODE_HWSYNC 0x2
151+#define TSCADC_STEPCONFIG_MODE_HWSYNC 0x2
152+#define TSCADC_STEPCONFIG_MODE_SWCONT 0x1
153+#define TSCADC_STEPCONFIG_MODE_SWONESHOT 0x0
154 #define TSCADC_STEPCONFIG_2SAMPLES_AVG (1 << 4)
155+#define TSCADC_STEPCONFIG_NO_AVG 0
156 #define TSCADC_STEPCONFIG_XPP BIT(5)
157 #define TSCADC_STEPCONFIG_XNN BIT(6)
158 #define TSCADC_STEPCONFIG_YPP BIT(7)
159@@ -72,7 +80,7 @@
160 #define TSCADC_STEPCONFIG_INP (1 << 20)
161 #define TSCADC_STEPCONFIG_INP_5 (1 << 21)
162 #define TSCADC_STEPCONFIG_FIFO1 (1 << 26)
163-#define TSCADC_STEPCONFIG_IDLE_INP (1 << 22)
164+#define TSCADC_STEPCONFIG_IDLE_INP 0x0000
165 #define TSCADC_STEPCONFIG_OPENDLY 0x018
166 #define TSCADC_STEPCONFIG_SAMPLEDLY 0x88
167 #define TSCADC_STEPCONFIG_Z1 (3 << 19)
168@@ -104,6 +112,7 @@ struct tscadc {
169 int wires;
170 int analog_input;
171 int x_plate_resistance;
172+ int mode;
173 struct clk *clk;
174 int irq;
175 void __iomem *tsc_base;
176@@ -120,6 +129,86 @@ static void tscadc_writel(struct tscadc *tsc, unsigned int reg,
177 writel(val, tsc->tsc_base + reg);
178 }
179
180+static void tsc_adc_step_config(struct tscadc *ts_dev)
181+{
182+ unsigned int stepconfig = 0, delay = 0, chargeconfig = 0;
183+
184+ /*
185+ * Step Configuration
186+ * software-enabled continous mode
187+ * 2 sample averaging
188+ * sample channel 1 (SEL_INP mux bits = 0)
189+ */
190+ stepconfig = TSCADC_STEPCONFIG_MODE_SWONESHOT |
191+ TSCADC_STEPCONFIG_2SAMPLES_AVG |
192+ (0x7 << 19);
193+
194+ delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
195+
196+ tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(10), stepconfig);
197+ tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(10), delay);
198+
199+ /* Get the ball rolling, this will trigger the FSM to step through
200+ * as soon as TSC_ADC_SS is turned on */
201+ tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
202+}
203+
204+static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
205+{
206+ struct tscadc *ts_dev = (struct tscadc *)dev;
207+ struct input_dev *input_dev = ts_dev->input;
208+ unsigned int status, irqclr = 0;
209+ int i;
210+ int fsm = 0, fifo0count = 0, fifo1count = 0;
211+ unsigned int read_sample = 0, ready1 = 0;
212+ unsigned int prev_val_x = ~0, prev_val_y = ~0;
213+ unsigned int prev_diff_x = ~0, prev_diff_y = ~0;
214+ unsigned int cur_diff_x = 0, cur_diff_y = 0;
215+ unsigned int val_x = 0, val_y = 0, diffx = 0, diffy = 0;
216+
217+ status = tscadc_readl(ts_dev, TSCADC_REG_IRQSTATUS);
218+
219+ printk("interrupt! status=%x\n", status);
220+ // if (status & TSCADC_IRQENB_EOS) {
221+ // irqclr |= TSCADC_IRQENB_EOS;
222+ // }
223+
224+ if (status & TSCADC_IRQENB_FIFO0THRES) {
225+ fifo1count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
226+ printk("fifo 0 count = %d\n", fifo1count);
227+
228+ for (i = 0; i < fifo1count; i++) {
229+ read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0);
230+ printk("sample: %d: %x\n", i, read_sample);
231+ }
232+ irqclr |= TSCADC_IRQENB_FIFO0THRES;
233+ }
234+
235+
236+ if (status & TSCADC_IRQENB_FIFO1THRES) {
237+ fifo1count = tscadc_readl(ts_dev, TSCADC_REG_FIFO1CNT);
238+
239+ for (i = 0; i < fifo1count; i++) {
240+ read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO1);
241+ // read_sample = read_sample & 0xfff;
242+ printk("sample: %d: %d\n", i, read_sample);
243+ panic("sample read from fifo1!");
244+ }
245+ irqclr |= TSCADC_IRQENB_FIFO1THRES;
246+ }
247+
248+ mdelay(500);
249+
250+ tscadc_writel(ts_dev, TSCADC_REG_IRQSTATUS, irqclr);
251+
252+ /* check pending interrupts */
253+ tscadc_writel(ts_dev, TSCADC_REG_IRQEOI, 0x0);
254+
255+ /* Turn on Step 1 again */
256+ tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
257+ return IRQ_HANDLED;
258+}
259+
260 static void tsc_step_config(struct tscadc *ts_dev)
261 {
262 unsigned int stepconfigx = 0, stepconfigy = 0;
263@@ -224,7 +313,7 @@ static void tsc_step_config(struct tscadc *ts_dev)
264 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG14, stepconfigz2);
265 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY14, delay);
266
267- tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB);
268+ tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_TOUCHSCREEN);
269 }
270
271 static void tsc_idle_config(struct tscadc *ts_config)
272@@ -242,7 +331,7 @@ static void tsc_idle_config(struct tscadc *ts_config)
273 tscadc_writel(ts_config, TSCADC_REG_IDLECONFIG, idleconfig);
274 }
275
276-static irqreturn_t tscadc_interrupt(int irq, void *dev)
277+static irqreturn_t tsc_interrupt(int irq, void *dev)
278 {
279 struct tscadc *ts_dev = (struct tscadc *)dev;
280 struct input_dev *input_dev = ts_dev->input;
281@@ -362,7 +451,7 @@ static irqreturn_t tscadc_interrupt(int irq, void *dev)
282 /* check pending interrupts */
283 tscadc_writel(ts_dev, TSCADC_REG_IRQEOI, 0x0);
284
285- tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB);
286+ tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_TOUCHSCREEN);
287 return IRQ_HANDLED;
288 }
289
290@@ -400,13 +489,15 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
291 return -ENODEV;
292 }
293
294- input_dev = input_allocate_device();
295- if (!input_dev) {
296- dev_err(&pdev->dev, "failed to allocate input device.\n");
297- err = -ENOMEM;
298- goto err_free_mem;
299+ if(pdata->mode == TI_TSCADC_TSCMODE) {
300+ input_dev = input_allocate_device();
301+ if (!input_dev) {
302+ dev_err(&pdev->dev, "failed to allocate input device.\n");
303+ err = -ENOMEM;
304+ goto err_free_mem;
305+ }
306+ ts_dev->input = input_dev;
307 }
308- ts_dev->input = input_dev;
309
310 ts_dev->tsc_base = ioremap(res->start, resource_size(res));
311 if (!ts_dev->tsc_base) {
312@@ -415,8 +506,15 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
313 goto err_release_mem;
314 }
315
316- err = request_irq(ts_dev->irq, tscadc_interrupt, IRQF_DISABLED,
317- pdev->dev.driver->name, ts_dev);
318+ if(pdata->mode == TI_TSCADC_TSCMODE) {
319+ err = request_irq(ts_dev->irq, tsc_interrupt, IRQF_DISABLED,
320+ pdev->dev.driver->name, ts_dev);
321+ }
322+ else {
323+ err = request_irq(ts_dev->irq, tsc_adc_interrupt, IRQF_DISABLED,
324+ pdev->dev.driver->name, ts_dev);
325+ }
326+
327 if (err) {
328 dev_err(&pdev->dev, "failed to allocate irq.\n");
329 goto err_unmap_regs;
330@@ -436,11 +534,15 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
331 goto err_free_irq;
332 }
333 clock_rate = clk_get_rate(ts_dev->clk);
334+
335+ /* clk_value of atleast 21MHz required
336+ * Clock verified on BeagleBone to be 24MHz */
337 clk_value = clock_rate / ADC_CLK;
338 if (clk_value < 7) {
339 dev_err(&pdev->dev, "clock input less than min clock requirement\n");
340 goto err_fail;
341 }
342+
343 /* TSCADC_CLKDIV needs to be configured to the value minus 1 */
344 clk_value = clk_value - 1;
345 tscadc_writel(ts_dev, TSCADC_REG_CLKDIV, clk_value);
346@@ -451,56 +553,59 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
347 ts_dev->wires = pdata->wires;
348 ts_dev->analog_input = pdata->analog_input;
349 ts_dev->x_plate_resistance = pdata->x_plate_resistance;
350+ ts_dev->mode = pdata->mode;
351
352- /* Set the control register bits */
353+ /* Set the control register bits - 12.5.44 TRM */
354 ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT |
355- TSCADC_CNTRLREG_TSCENB |
356- TSCADC_CNTRLREG_STEPID;
357- switch (ts_dev->wires) {
358- case 4:
359- ctrl |= TSCADC_CNTRLREG_4WIRE;
360- break;
361- case 5:
362- ctrl |= TSCADC_CNTRLREG_5WIRE;
363- break;
364- case 8:
365- ctrl |= TSCADC_CNTRLREG_8WIRE;
366- break;
367+ TSCADC_CNTRLREG_STEPID;
368+ if(pdata->mode == TI_TSCADC_TSCMODE) {
369+ ctrl |= TSCADC_CNTRLREG_TSCENB;
370+ switch (ts_dev->wires) {
371+ case 4:
372+ ctrl |= TSCADC_CNTRLREG_4WIRE;
373+ break;
374+ case 5:
375+ ctrl |= TSCADC_CNTRLREG_5WIRE;
376+ break;
377+ case 8:
378+ ctrl |= TSCADC_CNTRLREG_8WIRE;
379+ break;
380+ }
381 }
382 tscadc_writel(ts_dev, TSCADC_REG_CTRL, ctrl);
383
384- /* Set register bits for Idel Config Mode */
385- tsc_idle_config(ts_dev);
386-
387- /* IRQ Enable */
388- irqenable = TSCADC_IRQENB_FIFO1THRES;
389+ /* Touch screen / ADC configuration */
390+ if(pdata->mode == TI_TSCADC_TSCMODE) {
391+ tsc_idle_config(ts_dev);
392+ tsc_step_config(ts_dev);
393+ tscadc_writel(ts_dev, TSCADC_REG_FIFO1THR, 6);
394+ irqenable = TSCADC_IRQENB_FIFO1THRES;
395+ /* Touch screen also needs an input_dev */
396+ input_dev->name = "ti-tsc-adcc";
397+ input_dev->dev.parent = &pdev->dev;
398+ input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
399+ input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
400+ input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
401+ input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
402+ /* register to the input system */
403+ err = input_register_device(input_dev);
404+ if (err)
405+ goto err_fail;
406+ }
407+ else {
408+ tsc_adc_step_config(ts_dev);
409+ tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
410+ irqenable = TSCADC_IRQENB_FIFO0THRES;
411+ }
412 tscadc_writel(ts_dev, TSCADC_REG_IRQENABLE, irqenable);
413
414- tsc_step_config(ts_dev);
415-
416- tscadc_writel(ts_dev, TSCADC_REG_FIFO1THR, 6);
417-
418 ctrl |= TSCADC_CNTRLREG_TSCSSENB;
419- tscadc_writel(ts_dev, TSCADC_REG_CTRL, ctrl);
420-
421- input_dev->name = "ti-tsc-adcc";
422- input_dev->dev.parent = &pdev->dev;
423-
424- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
425- input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
426-
427- input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
428- input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
429- input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0);
430-
431- /* register to the input system */
432- err = input_register_device(input_dev);
433- if (err)
434- goto err_fail;
435+ tscadc_writel(ts_dev, TSCADC_REG_CTRL, ctrl); /* Turn on TSC_ADC */
436
437 return 0;
438
439 err_fail:
440+ printk(KERN_ERR "Fatal error, shutting down TSC_ADC\n");
441 clk_disable(ts_dev->clk);
442 clk_put(ts_dev->clk);
443 err_free_irq:
444diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
445index 2c547bb..850cd4b 100644
446--- a/include/linux/input/ti_tscadc.h
447+++ b/include/linux/input/ti_tscadc.h
448@@ -14,8 +14,12 @@
449 * @x_plate_resistance: X plate resistance.
450 */
451
452+#define TI_TSCADC_TSCMODE 0
453+#define TI_TSCADC_GENMODE 1
454+
455 struct tsc_data {
456 int wires;
457 int analog_input;
458 int x_plate_resistance;
459+ int mode;
460 };
461--
4621.7.4.1
463
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch
new file mode 100644
index 00000000..745855f8
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0005-tscadc-Add-board-file-mfd-support-fix-warning.patch
@@ -0,0 +1,86 @@
1From 800fc5594ec8922ef06e4063497d858cfd92c655 Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Wed, 23 Nov 2011 17:52:57 -0600
4Subject: [PATCH 5/9] tscadc: Add board file mfd support, fix warning
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 arch/arm/mach-omap2/board-am335xevm.c | 27 ++++++++++++++++++++++++++-
9 drivers/input/touchscreen/ti_tscadc.c | 2 +-
10 2 files changed, 27 insertions(+), 2 deletions(-)
11
12diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
13index c8da580..563770e 100644
14--- a/arch/arm/mach-omap2/board-am335xevm.c
15+++ b/arch/arm/mach-omap2/board-am335xevm.c
16@@ -195,6 +195,11 @@ static struct resource tsc_resources[] = {
17 static struct tsc_data am335x_touchscreen_data = {
18 .wires = 4,
19 .x_plate_resistance = 200,
20+ .mode = TI_TSCADC_TSCMODE,
21+};
22+
23+static struct tsc_data bone_touchscreen_data = {
24+ .mode = TI_TSCADC_GENMODE,
25 };
26
27 static struct platform_device tsc_device = {
28@@ -207,6 +212,16 @@ static struct platform_device tsc_device = {
29 .resource = tsc_resources,
30 };
31
32+static struct platform_device bone_tsc_device = {
33+ .name = "tsc",
34+ .id = -1,
35+ .dev = {
36+ .platform_data = &bone_touchscreen_data,
37+ },
38+ .num_resources = ARRAY_SIZE(tsc_resources),
39+ .resource = tsc_resources,
40+};
41+
42 static u8 am335x_iis_serializer_direction1[] = {
43 INACTIVE_MODE, INACTIVE_MODE, TX_MODE, RX_MODE,
44 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
45@@ -919,6 +934,16 @@ static void tsc_init(int evm_id, int profile)
46 pr_err("failed to register touchscreen device\n");
47 }
48
49+static void bone_tsc_init(int evm_id, int profile)
50+{
51+ int err;
52+ setup_pin_mux(tsc_pin_mux);
53+ err = platform_device_register(&bone_tsc_device);
54+ if (err)
55+ pr_err("failed to register touchscreen device\n");
56+}
57+
58+
59 static void boneleds_init(int evm_id, int profile )
60 {
61 int err;
62@@ -1517,7 +1542,7 @@ static struct evm_dev_cfg beaglebone_old_dev_cfg[] = {
63 {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
64 {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
65 {boneleds_init, DEV_ON_BASEBOARD, PROFILE_ALL},
66- {tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
67+ {bone_tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
68 {NULL, 0, 0},
69 };
70
71diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
72index 76fc7b6..49a5a70 100644
73--- a/drivers/input/touchscreen/ti_tscadc.c
74+++ b/drivers/input/touchscreen/ti_tscadc.c
75@@ -462,7 +462,7 @@ static irqreturn_t tsc_interrupt(int irq, void *dev)
76 static int __devinit tscadc_probe(struct platform_device *pdev)
77 {
78 struct tscadc *ts_dev;
79- struct input_dev *input_dev;
80+ struct input_dev *input_dev = NULL;
81 int err;
82 int clk_value;
83 int clock_rate, irqenable, ctrl;
84--
851.7.4.1
86
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch
new file mode 100644
index 00000000..85f200d9
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0006-AM335X-init-tsc-bone-style-for-new-boards.patch
@@ -0,0 +1,26 @@
1From be48948e9fe62f75cb221309aec0990f9ecd5e01 Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Mon, 28 Nov 2011 18:01:07 -0600
4Subject: [PATCH 6/9] AM335X: init tsc bone style for new boards
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 arch/arm/mach-omap2/board-am335xevm.c | 2 +-
9 1 files changed, 1 insertions(+), 1 deletions(-)
10
11diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
12index 563770e..20b4e29 100644
13--- a/arch/arm/mach-omap2/board-am335xevm.c
14+++ b/arch/arm/mach-omap2/board-am335xevm.c
15@@ -1554,7 +1554,7 @@ static struct evm_dev_cfg beaglebone_dev_cfg[] = {
16 {usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
17 {mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
18 {boneleds_init, DEV_ON_BASEBOARD, PROFILE_ALL},
19- {tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
20+ {bone_tsc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
21 {NULL, 0, 0},
22 };
23
24--
251.7.4.1
26
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch
new file mode 100644
index 00000000..487c5568
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0007-tscadc-make-stepconfig-channel-configurable.patch
@@ -0,0 +1,46 @@
1From 012ea9d8c2e7e522b1bd614ba5df814224663140 Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Mon, 28 Nov 2011 18:18:04 -0600
4Subject: [PATCH 7/9] tscadc: make stepconfig channel-configurable
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 drivers/input/touchscreen/ti_tscadc.c | 8 +++++---
9 1 files changed, 5 insertions(+), 3 deletions(-)
10
11diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
12index 49a5a70..638feb9 100644
13--- a/drivers/input/touchscreen/ti_tscadc.c
14+++ b/drivers/input/touchscreen/ti_tscadc.c
15@@ -129,7 +129,9 @@ static void tscadc_writel(struct tscadc *tsc, unsigned int reg,
16 writel(val, tsc->tsc_base + reg);
17 }
18
19-static void tsc_adc_step_config(struct tscadc *ts_dev)
20+/* Configure ADC to sample on channel (1-8) */
21+
22+static void tsc_adc_step_config(struct tscadc *ts_dev, int channel)
23 {
24 unsigned int stepconfig = 0, delay = 0, chargeconfig = 0;
25
26@@ -141,7 +143,7 @@ static void tsc_adc_step_config(struct tscadc *ts_dev)
27 */
28 stepconfig = TSCADC_STEPCONFIG_MODE_SWONESHOT |
29 TSCADC_STEPCONFIG_2SAMPLES_AVG |
30- (0x7 << 19);
31+ ((channel-1) << 19);
32
33 delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
34
35@@ -593,7 +595,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
36 goto err_fail;
37 }
38 else {
39- tsc_adc_step_config(ts_dev);
40+ tsc_adc_step_config(ts_dev, 8);
41 tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
42 irqenable = TSCADC_IRQENB_FIFO0THRES;
43 }
44--
451.7.4.1
46
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch
new file mode 100644
index 00000000..378e8ccb
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0008-tscadc-Trigger-through-sysfs.patch
@@ -0,0 +1,151 @@
1From 01b25097f2ad4ca1e9f35547b1a040c5f06a5dfd Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Mon, 28 Nov 2011 20:55:25 -0600
4Subject: [PATCH 8/9] tscadc: Trigger through sysfs
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 drivers/input/touchscreen/ti_tscadc.c | 61 ++++++++++++++++++++++++++++++---
9 include/linux/input/ti_tscadc.h | 1 +
10 2 files changed, 57 insertions(+), 5 deletions(-)
11
12diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
13index 638feb9..0126219 100644
14--- a/drivers/input/touchscreen/ti_tscadc.c
15+++ b/drivers/input/touchscreen/ti_tscadc.c
16@@ -26,6 +26,17 @@
17 #include <linux/io.h>
18 #include <linux/input/ti_tscadc.h>
19 #include <linux/delay.h>
20+#include <linux/device.h>
21+
22+size_t do_adc_sample(struct kobject *, struct attribute *, char *);
23+static DEVICE_ATTR(ain1, S_IRUGO, do_adc_sample, NULL);
24+static DEVICE_ATTR(ain2, S_IRUGO, do_adc_sample, NULL);
25+static DEVICE_ATTR(ain3, S_IRUGO, do_adc_sample, NULL);
26+static DEVICE_ATTR(ain4, S_IRUGO, do_adc_sample, NULL);
27+static DEVICE_ATTR(ain5, S_IRUGO, do_adc_sample, NULL);
28+static DEVICE_ATTR(ain6, S_IRUGO, do_adc_sample, NULL);
29+static DEVICE_ATTR(ain7, S_IRUGO, do_adc_sample, NULL);
30+static DEVICE_ATTR(ain8, S_IRUGO, do_adc_sample, NULL);
31
32 /* Memory mapped registers here have incorrect offsets!
33 * Correct after referring TRM */
34@@ -144,12 +155,12 @@ static void tsc_adc_step_config(struct tscadc *ts_dev, int channel)
35 stepconfig = TSCADC_STEPCONFIG_MODE_SWONESHOT |
36 TSCADC_STEPCONFIG_2SAMPLES_AVG |
37 ((channel-1) << 19);
38-
39+
40 delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
41
42 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(10), stepconfig);
43 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(10), delay);
44-
45+
46 /* Get the ball rolling, this will trigger the FSM to step through
47 * as soon as TSC_ADC_SS is turned on */
48 tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
49@@ -199,7 +210,7 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
50 irqclr |= TSCADC_IRQENB_FIFO1THRES;
51 }
52
53- mdelay(500);
54+ // mdelay(500);
55
56 tscadc_writel(ts_dev, TSCADC_REG_IRQSTATUS, irqclr);
57
58@@ -207,7 +218,7 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
59 tscadc_writel(ts_dev, TSCADC_REG_IRQEOI, 0x0);
60
61 /* Turn on Step 1 again */
62- tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
63+ // tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_GENERAL);
64 return IRQ_HANDLED;
65 }
66
67@@ -461,6 +472,34 @@ static irqreturn_t tsc_interrupt(int irq, void *dev)
68 * The functions for inserting/removing driver as a module.
69 */
70
71+size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
72+ struct platform_device *pdev;
73+ struct device *dev;
74+ struct tscadc *ts_dev;
75+ int channel_num;
76+
77+ pdev = (struct platform_device *)container_of(kobj, struct device, kobj);
78+ dev = &pdev->dev;
79+
80+ ts_dev = dev_get_drvdata(dev);
81+
82+ if(strncmp(attr->name, "ain", 3)) {
83+ printk("Invalid ain num\n");
84+ return -EINVAL;
85+ }
86+
87+ channel_num = attr->name[3] - 0x30;
88+ if(channel_num > 8 || channel_num < 1) {
89+ printk("Invalid channel_num=%d\n", channel_num);
90+ return -EINVAL;
91+ }
92+
93+ tsc_adc_step_config(ts_dev, channel_num);
94+
95+ memcpy(buf, attr->name, strlen(attr->name)+1);
96+ return strlen(attr->name);
97+}
98+
99 static int __devinit tscadc_probe(struct platform_device *pdev)
100 {
101 struct tscadc *ts_dev;
102@@ -472,6 +511,18 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
103 struct resource *res;
104 struct clk *tsc_ick;
105
106+ printk("dev addr = %p\n", &pdev->dev);
107+ printk("pdev addr = %p\n", pdev);
108+
109+ device_create_file(&pdev->dev, &dev_attr_ain1);
110+ device_create_file(&pdev->dev, &dev_attr_ain2);
111+ device_create_file(&pdev->dev, &dev_attr_ain3);
112+ device_create_file(&pdev->dev, &dev_attr_ain4);
113+ device_create_file(&pdev->dev, &dev_attr_ain5);
114+ device_create_file(&pdev->dev, &dev_attr_ain6);
115+ device_create_file(&pdev->dev, &dev_attr_ain7);
116+ device_create_file(&pdev->dev, &dev_attr_ain8);
117+
118 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
119 if (!res) {
120 dev_err(&pdev->dev, "no memory resource defined.\n");
121@@ -595,7 +646,6 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
122 goto err_fail;
123 }
124 else {
125- tsc_adc_step_config(ts_dev, 8);
126 tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
127 irqenable = TSCADC_IRQENB_FIFO0THRES;
128 }
129@@ -604,6 +654,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
130 ctrl |= TSCADC_CNTRLREG_TSCSSENB;
131 tscadc_writel(ts_dev, TSCADC_REG_CTRL, ctrl); /* Turn on TSC_ADC */
132
133+ dev_set_drvdata(&pdev->dev, ts_dev);
134 return 0;
135
136 err_fail:
137diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
138index 850cd4b..fc239c6 100644
139--- a/include/linux/input/ti_tscadc.h
140+++ b/include/linux/input/ti_tscadc.h
141@@ -13,6 +13,7 @@
142 * 0.
143 * @x_plate_resistance: X plate resistance.
144 */
145+#include <linux/device.h>
146
147 #define TI_TSCADC_TSCMODE 0
148 #define TI_TSCADC_GENMODE 1
149--
1501.7.4.1
151
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch
new file mode 100644
index 00000000..2c305701
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0009-meta-ti-Remove-debug-messages-for-meta-ti.patch
@@ -0,0 +1,34 @@
1From ddb162b6ced5d47caa3a62ab5e95b659287a32d1 Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Mon, 28 Nov 2011 20:56:48 -0600
4Subject: [PATCH 9/9] meta-ti: Remove debug messages for meta-ti
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 drivers/input/touchscreen/ti_tscadc.c | 4 ++--
9 1 files changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
12index 0126219..182428b 100644
13--- a/drivers/input/touchscreen/ti_tscadc.c
14+++ b/drivers/input/touchscreen/ti_tscadc.c
15@@ -181,14 +181,14 @@ static irqreturn_t tsc_adc_interrupt(int irq, void *dev)
16
17 status = tscadc_readl(ts_dev, TSCADC_REG_IRQSTATUS);
18
19- printk("interrupt! status=%x\n", status);
20+ // printk("interrupt! status=%x\n", status);
21 // if (status & TSCADC_IRQENB_EOS) {
22 // irqclr |= TSCADC_IRQENB_EOS;
23 // }
24
25 if (status & TSCADC_IRQENB_FIFO0THRES) {
26 fifo1count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
27- printk("fifo 0 count = %d\n", fifo1count);
28+ // printk("fifo 0 count = %d\n", fifo1count);
29
30 for (i = 0; i < fifo1count; i++) {
31 read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0);
32--
331.7.4.1
34
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch
new file mode 100644
index 00000000..23435252
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0010-tscadc-switch-to-polling-instead-of-interrupts.patch
@@ -0,0 +1,54 @@
1From d0852fc8d96eedb709b964dacfa8ea71746f1872 Mon Sep 17 00:00:00 2001
2From: Joel A Fernandes <joelagnel@ti.com>
3Date: Tue, 29 Nov 2011 09:44:22 -0600
4Subject: [PATCH 10/10] tscadc: switch to polling instead of interrupts
5
6Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
7---
8 drivers/input/touchscreen/ti_tscadc.c | 16 ++++++++++++++--
9 1 files changed, 14 insertions(+), 2 deletions(-)
10
11diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
12index 182428b..90cb5ed 100644
13--- a/drivers/input/touchscreen/ti_tscadc.c
14+++ b/drivers/input/touchscreen/ti_tscadc.c
15@@ -477,6 +477,8 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
16 struct device *dev;
17 struct tscadc *ts_dev;
18 int channel_num;
19+ int fifo0count = 0;
20+ int read_sample = 0;
21
22 pdev = (struct platform_device *)container_of(kobj, struct device, kobj);
23 dev = &pdev->dev;
24@@ -496,7 +498,17 @@ size_t do_adc_sample(struct kobject *kobj, struct attribute *attr, char *buf) {
25
26 tsc_adc_step_config(ts_dev, channel_num);
27
28- memcpy(buf, attr->name, strlen(attr->name)+1);
29+ do {
30+ fifo0count = tscadc_readl(ts_dev, TSCADC_REG_FIFO0CNT);
31+ }
32+ while (!fifo0count);
33+
34+ while (fifo0count--) {
35+ read_sample = tscadc_readl(ts_dev, TSCADC_REG_FIFO0) & 0xfff;
36+ // printk("polling sample: %d: %x\n", fifo0count, read_sample);
37+ }
38+ sprintf(buf, "%d", read_sample);
39+
40 return strlen(attr->name);
41 }
42
43@@ -647,7 +659,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
44 }
45 else {
46 tscadc_writel(ts_dev, TSCADC_REG_FIFO0THR, 0);
47- irqenable = TSCADC_IRQENB_FIFO0THRES;
48+ irqenable = 0; // TSCADC_IRQENB_FIFO0THRES;
49 }
50 tscadc_writel(ts_dev, TSCADC_REG_IRQENABLE, irqenable);
51
52--
531.7.4.1
54