sync hh.org
[hh.org.git] / include / linux / soc / tsc2200.h
blob95a23a717d86a832759df80feacdee400f7ac4e1
1 /*
2 * TI TSC2101 Structure Definitions
4 * Copyright 2005 Openedhand Ltd.
6 * Author: Richard Purdie <richard@o-hand.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
15 * see http://focus.ti.com/docs/prod/folders/print/tsc2200.html
16 * it's a texas instruments TSC 2200 A-D converter with interrupts
17 * and keypad interrupts and everything.
20 #define TSC2200_REG_READ (1<<15) // read register
21 #define TSC2200_PAGEMASK (0xf<<11) // page of device's memory to be addressed
22 // see table II
23 #define TSC2200_PAGE(x) ((x<<11) & TSC2200_PAGEMASK)
25 #define TSC2200_REG_ADDRMASK (0x1f<<5) // memory address mask
26 #define TSC2200_REG_ADDR(x) ((x<<5) & TSC2200_REG_ADDRMASK)
28 #define TSC2200_DATAREG_PAGEADDR (0) // datareg page address
29 #define TSC2200_CTRLREG_PAGEADDR (1) // control reg page address
31 #define TSC2200_DATAREG(x) (TSC2200_PAGE(TSC2200_DATAREG_PAGEADDR) | TSC2200_REG_ADDR(x))
33 // these are data registers, in page 0, so they are addressed
34 // using e.g. TSC2200_REG_ADDR(TSC2200_DATAREG_PAGEADDR)
36 #define TSC2200_DATAREG_X TSC2200_DATAREG(0)
37 #define TSC2200_DATAREG_Y TSC2200_DATAREG(1)
38 #define TSC2200_DATAREG_Z1 TSC2200_DATAREG(2)
39 #define TSC2200_DATAREG_Z2 TSC2200_DATAREG(3)
40 #define TSC2200_DATAREG_KPDATA TSC2200_DATAREG(4)
41 #define TSC2200_DATAREG_BAT1 TSC2200_DATAREG(5)
42 #define TSC2200_DATAREG_BAT2 TSC2200_DATAREG(6)
43 #define TSC2200_DATAREG_AUX1 TSC2200_DATAREG(7)
44 #define TSC2200_DATAREG_AUX2 TSC2200_DATAREG(8)
45 #define TSC2200_DATAREG_TEMP1 TSC2200_DATAREG(9)
46 #define TSC2200_DATAREG_TEMP2 TSC2200_DATAREG(0xa)
47 #define TSC2200_DATAREG_DAC TSC2200_DATAREG(0xb)
48 #define TSC2200_DATAREG_ZERO TSC2200_DATAREG(0x10)
50 // these are control registers, in page 1, address using
51 // using e.g. TSC2200_REG_ADDR(TSC2200_CTRLREG_PAGEADDR)
53 #define TSC2200_CTRLREG(x) (TSC2200_PAGE(TSC2200_CTRLREG_PAGEADDR) | TSC2200_REG_ADDR(x))
55 #define TSC2200_CTRLREG_ADC TSC2200_CTRLREG(0)
56 #define TSC2200_CTRLREG_KEY TSC2200_CTRLREG(1)
57 #define TSC2200_CTRLREG_DACCTL TSC2200_CTRLREG(2)
58 #define TSC2200_CTRLREG_REF TSC2200_CTRLREG(3)
59 #define TSC2200_CTRLREG_RESET TSC2200_CTRLREG(4)
60 #define TSC2200_CTRLREG_CONFIG TSC2200_CTRLREG(5)
61 #define TSC2200_CTRLREG_KPMASK TSC2200_CTRLREG(0x10)
63 // these are relevant for when you access page1's adc register
64 #define TSC2200_CTRLREG_ADC_PSM_TSC2200 (1<<15) // pen status mode on ctrlreg adc
65 #define TSC2200_CTRLREG_ADC_STS (1<<14) // stop continuous scanning.
66 #define TSC2200_CTRLREG_ADC_AD3 (1<<13) //
67 #define TSC2200_CTRLREG_ADC_AD2 (1<<12) //
68 #define TSC2200_CTRLREG_ADC_AD1 (1<<11) //
69 #define TSC2200_CTRLREG_ADC_AD0 (1<<10) //
70 #define TSC2200_CTRLREG_ADC_RES(x) ((x<<8) & TSC2200_CTRLREG_ADC_RES_MASK )
71 #define TSC2200_CTRLREG_ADC_RES_MASK (0x3<<8)
72 #define TSC2200_CTRLREG_ADC_RES_12BITP (0) // 12-bit ADC resolution (default)
73 #define TSC2200_CTRLREG_ADC_RES_8BIT (1) // 8-bit ADC resolution
74 #define TSC2200_CTRLREG_ADC_RES_10BIT (2) // 10-bit ADC resolution
75 #define TSC2200_CTRLREG_ADC_RES_12BIT (3) // 12-bit ADC resolution
77 #define TSC2200_CTRLREG_ADC_AVG(x) ((x<<6) & TSC2200_CTRLREG_ADC_AVG_MASK )
78 #define TSC2200_CTRLREG_ADC_AVG_MASK (0x3<<6)
79 #define TSC2200_CTRLREG_ADC_NOAVG (0) // a-d does no averaging
80 #define TSC2200_CTRLREG_ADC_4AVG (1) // a-d does averaging of 4 samples
81 #define TSC2200_CTRLREG_ADC_8AVG (2) // a-d does averaging of 8 samples
82 #define TSC2200_CTRLREG_ADC_16AVG (3) // a-d does averaging of 16 samples
84 #define TSC2200_CTRLREG_ADC_CL(x) ((x<<4) & TSC2200_CTRLREG_ADC_CL_MASK )
85 #define TSC2200_CTRLREG_ADC_CL_MASK (0x3<<4)
86 #define TSC2200_CTRLREG_ADC_CL_8MHZ_8BIT (0)
87 #define TSC2200_CTRLREG_ADC_CL_4MHZ_10BIT (1)
88 #define TSC2200_CTRLREG_ADC_CL_2MHZ_12BIT (2)
89 #define TSC2200_CTRLREG_ADC_CL_1MHZ_12BIT (3)
90 #define TSC2200_CTRLREG_ADC_CL0 (1<< 4) //
92 #define TSC2200_CTRLREG_ADC_PV(x) ((x<<1) & TSC2200_CTRLREG_ADC_PV_MASK )
93 #define TSC2200_CTRLREG_ADC_PV_MASK (0x7<<1)
94 #define TSC2200_CTRLREG_ADC_PV_100mS (0x7) // 100ms panel voltage stabilisation
95 // ....
96 #define TSC2200_CTRLREG_ADC_PV_5mS (0x4) // 5ms panel voltage stabilisation
97 #define TSC2200_CTRLREG_ADC_PV_1mS (0x3) // 1ms panel voltage stabilisation
98 #define TSC2200_CTRLREG_ADC_PV_500uS (0x2) // 500us panel voltage stabilisation
99 #define TSC2200_CTRLREG_ADC_PV_100uS (0x1) // 100us panel voltage stabilisation
100 #define TSC2200_CTRLREG_ADC_PV_0S (0x0) // zero seconds stabilisation
102 #define TSC2200_CTRLREG_ADC_x (1<< 0) // don't care
104 #define TSC2200_CTRLREG_CONFIG_DAV (1<<6)
106 #define TSC2200_CTRLREG_KEY_STC (1<<15) // keypad status
107 #define TSC2200_CTRLREG_KEY_SCS (1<<14) // keypad scan status
110 * public interface.
112 * the tsc2200 driver is timer-interrupt-driven and pen-irq driven.
114 * it only needs to know how to read and write to the NSSP, via
115 * the send_cmd and recv_cmd functions in the nssp_tsc2200_struct.
119 //extern struct device_driver tsc2200_device_driver;
120 //extern struct semaphore tsc2200_sem;
121 //void tsc2200_reset(void);
122 //int tsc2200_dev (void);
123 //unsigned short tsc2200_read(unsigned short reg);
124 //void tsc2200_write(unsigned short reg, unsigned short val);
125 //int tsc2200_dav(void);
129 #include <linux/input.h>
131 struct tsc2200_ts_event {
132 short p;
133 short x;
134 short y;
137 //struct tsc2200_misc_data {
138 // short bat;
139 // short aux1;
140 // short aux2;
141 // short temp1;
142 // short temp2;
143 //};
146 * Keyboard definitions
150 struct tsc2200_key {
151 char *name;
152 int key_index;
153 int keycode;
156 struct tsc2200_buttons_platform_info {
157 struct tsc2200_key *keys;
158 int num_keys;
159 int irq;
162 struct tsc2200_buttons_data {
163 struct tsc2200_buttons_platform_info *platform_info;
164 struct device *tsc2200_dev;
166 struct timer_list timer;
167 struct input_dev *input_dev;
168 int keydata;
173 * Touch screen definitions
176 struct tsc2200_ts_platform_info {
177 int irq;
180 struct tsc2200_ts_data {
181 struct tsc2200_ts_platform_info *platform_info;
182 struct device *tsc2200_dev;
184 struct timer_list timer;
185 struct input_dev *input_dev;
189 struct tsc2200_data {
190 spinlock_t lock;
191 struct tsc2200_platform_info *platform;
192 struct platform_device *buttons_dev;
193 struct platform_device *ts_dev;
196 struct tsc2200_platform_info {
197 unsigned short (*send)(unsigned short reg, unsigned short value);
198 void (*init)(void);
199 // int (*suspend) (void);
200 // int (*resume) (void);
201 void (*exit)(void);
203 struct tsc2200_buttons_platform_info *buttons_info;
204 struct tsc2200_ts_platform_info *touchscreen_info;
208 extern void tsc2200_write(struct device *dev, unsigned short regnum, unsigned short value);
209 extern unsigned short tsc2200_read(struct device *dev, unsigned short reg);
210 extern unsigned short tsc2200_dav(struct device *dev);
212 extern void tsc2200_stop(struct device *dev);
213 extern void tsc2200_lock(struct device *dev);
214 extern void tsc2200_unlock(struct device *dev);