source: mainline/uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h@ 747a1e71

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 747a1e71 was 5da7199, checked in by Martin Decky <martin@…>, 14 years ago

remove the obsolete async API

  • Property mode set to 100644
File size: 3.6 KB
Line 
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#include <async.h>
42
43/** S3C24xx ADC and touch-screen I/O */
44typedef struct {
45 uint32_t con;
46 uint32_t tsc;
47 uint32_t dly;
48 uint32_t dat0;
49 uint32_t dat1;
50 uint32_t updn;
51} s3c24xx_adc_io_t;
52
53/* Fields in ADCCON register */
54#define ADCCON_ECFLG 0x8000
55#define ADCCON_PRSCEN 0x4000
56
57#define ADCCON_PRSCVL(val) (((val) & 0xff) << 6)
58
59#define ADCCON_SEL_MUX(smux) (((smux) & 7) << 3)
60
61#define ADCCON_STDBM 0x0004
62#define ADCCON_READ_START 0x0002
63#define ADCCON_ENABLE_START 0x0001
64
65/* Values for ADCCON_SEL_MUX */
66#define SMUX_AIN0 0
67#define SMUX_AIN1 1
68#define SMUX_AIN2 2
69#define SMUX_AIN3 3
70#define SMUX_YM 4
71#define SMUX_YP 5
72#define SMUX_XM 6
73#define SMUX_XP 7
74
75
76/* Fields in ADCTSC register */
77#define ADCTSC_DSUD_UP 0x0100
78#define ADCTSC_YM_ENABLE 0x0080
79#define ADCTSC_YP_DISABLE 0x0040
80#define ADCTSC_XM_ENABLE 0x0020
81#define ADCTSC_XP_DISABLE 0x0010
82#define ADCTSC_PULLUP_DISABLE 0x0008
83#define ADCTSC_AUTO_PST 0x0004
84
85#define ADCTSC_XY_PST_NOOP 0x0000
86#define ADCTSC_XY_PST_X 0x0001
87#define ADCTSC_XY_PST_Y 0x0002
88#define ADCTSC_XY_PST_WAITINT 0x0003
89#define ADCTSC_XY_PST_MASK 0x0003
90
91/* Fields in ADCDAT0, ADCDAT1 registers */
92#define ADCDAT_UPDOWN 0x8000
93#define ADCDAT_AUTO_PST 0x4000
94
95/* Fields in ADCUPDN register */
96#define ADCUPDN_TSC_UP 0x0002
97#define ADCUPDN_TSC_DN 0x0001
98
99/** Touchscreen interrupt number */
100#define S3C24XX_TS_INR 31
101
102/** Touchscreen I/O address */
103#define S3C24XX_TS_ADDR 0x58000000
104
105typedef enum {
106 ts_wait_pendown,
107 ts_sample_pos,
108 ts_wait_penup
109} ts_state_t;
110
111typedef enum {
112 updn_up,
113 updn_down
114} ts_updn_t;
115
116/** S3C24xx touchscreen driver instance */
117typedef struct {
118 /** Physical device address */
119 uintptr_t paddr;
120
121 /** Device I/O structure */
122 s3c24xx_adc_io_t *io;
123
124 /** Callback session to the client */
125 async_sess_t *client_sess;
126
127 /** Service ID */
128 service_id_t service_id;
129
130 /** Device/driver state */
131 ts_state_t state;
132
133 /** Previous position reported to client. */
134 int last_x;
135 int last_y;
136} s3c24xx_ts_t;
137
138#endif
139
140/** @}
141 */
Note: See TracBrowser for help on using the repository browser.