1 | /*
|
---|
2 | * Copyright (c) 2010 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup genarch
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /**
|
---|
33 | * @file
|
---|
34 | * @brief Samsung S3C24xx on-chip ADC and touch-screen interface driver.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef S3C24XX_TS_H_
|
---|
38 | #define S3C24XX_TS_H_
|
---|
39 |
|
---|
40 | #include <sys/types.h>
|
---|
41 |
|
---|
42 | /** S3C24xx ADC and touch-screen I/O */
|
---|
43 | typedef struct {
|
---|
44 | uint32_t con;
|
---|
45 | uint32_t tsc;
|
---|
46 | uint32_t dly;
|
---|
47 | uint32_t dat0;
|
---|
48 | uint32_t dat1;
|
---|
49 | uint32_t updn;
|
---|
50 | } s3c24xx_adc_io_t;
|
---|
51 |
|
---|
52 | /* Fields in ADCCON register */
|
---|
53 | #define ADCCON_ECFLG 0x8000
|
---|
54 | #define ADCCON_PRSCEN 0x4000
|
---|
55 |
|
---|
56 | #define ADCCON_PRSCVL(val) (((val) & 0xff) << 6)
|
---|
57 |
|
---|
58 | #define ADCCON_SEL_MUX(smux) (((smux) & 7) << 3)
|
---|
59 |
|
---|
60 | #define ADCCON_STDBM 0x0004
|
---|
61 | #define ADCCON_READ_START 0x0002
|
---|
62 | #define ADCCON_ENABLE_START 0x0001
|
---|
63 |
|
---|
64 | /* Values for ADCCON_SEL_MUX */
|
---|
65 | #define SMUX_AIN0 0
|
---|
66 | #define SMUX_AIN1 1
|
---|
67 | #define SMUX_AIN2 2
|
---|
68 | #define SMUX_AIN3 3
|
---|
69 | #define SMUX_YM 4
|
---|
70 | #define SMUX_YP 5
|
---|
71 | #define SMUX_XM 6
|
---|
72 | #define SMUX_XP 7
|
---|
73 |
|
---|
74 |
|
---|
75 | /* Fields in ADCTSC register */
|
---|
76 | #define ADCTSC_DSUD_UP 0x0100
|
---|
77 | #define ADCTSC_YM_ENABLE 0x0080
|
---|
78 | #define ADCTSC_YP_DISABLE 0x0040
|
---|
79 | #define ADCTSC_XM_ENABLE 0x0020
|
---|
80 | #define ADCTSC_XP_DISABLE 0x0010
|
---|
81 | #define ADCTSC_PULLUP_DISABLE 0x0008
|
---|
82 | #define ADCTSC_AUTO_PST 0x0004
|
---|
83 |
|
---|
84 | #define ADCTSC_XY_PST_NOOP 0x0000
|
---|
85 | #define ADCTSC_XY_PST_X 0x0001
|
---|
86 | #define ADCTSC_XY_PST_Y 0x0002
|
---|
87 | #define ADCTSC_XY_PST_WAITINT 0x0003
|
---|
88 | #define ADCTSC_XY_PST_MASK 0x0003
|
---|
89 |
|
---|
90 | /* Fields in ADCDAT0, ADCDAT1 registers */
|
---|
91 | #define ADCDAT_UPDOWN 0x8000
|
---|
92 | #define ADCDAT_AUTO_PST 0x4000
|
---|
93 |
|
---|
94 | /* Fields in ADCUPDN register */
|
---|
95 | #define ADCUPDN_TSC_UP 0x0002
|
---|
96 | #define ADCUPDN_TSC_DN 0x0001
|
---|
97 |
|
---|
98 | /** Touchscreen interrupt number */
|
---|
99 | #define S3C24XX_TS_INR 31
|
---|
100 |
|
---|
101 | /** Touchscreen I/O address */
|
---|
102 | #define S3C24XX_TS_ADDR 0x58000000
|
---|
103 |
|
---|
104 | typedef enum {
|
---|
105 | ts_wait_pendown,
|
---|
106 | ts_sample_pos,
|
---|
107 | ts_wait_penup
|
---|
108 | } ts_state_t;
|
---|
109 |
|
---|
110 | typedef enum {
|
---|
111 | updn_up,
|
---|
112 | updn_down
|
---|
113 | } ts_updn_t;
|
---|
114 |
|
---|
115 | /** S3C24xx touchscreen driver instance */
|
---|
116 | typedef struct {
|
---|
117 | /** Physical device address */
|
---|
118 | uintptr_t paddr;
|
---|
119 |
|
---|
120 | /** Device I/O structure */
|
---|
121 | s3c24xx_adc_io_t *io;
|
---|
122 |
|
---|
123 | /** Callback phone to the client */
|
---|
124 | int client_phone;
|
---|
125 |
|
---|
126 | /** Device handle */
|
---|
127 | dev_handle_t dev_handle;
|
---|
128 |
|
---|
129 | /** Device/driver state */
|
---|
130 | ts_state_t state;
|
---|
131 |
|
---|
132 | /** Previous position reported to client. */
|
---|
133 | int last_x;
|
---|
134 | int last_y;
|
---|
135 | } s3c24xx_ts_t;
|
---|
136 |
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | /** @}
|
---|
140 | */
|
---|