source: mainline/uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h

Last change on this file was 6404aca, checked in by Jakub Jermar <jakub@…>, 7 years ago

Disambiguate doxygroup genarch*

  • 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 uspace_srv_s3c24xx_ts
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 <stdint.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/* 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
104typedef enum {
105 ts_wait_pendown,
106 ts_sample_pos,
107 ts_wait_penup
108} ts_state_t;
109
110typedef enum {
111 updn_up,
112 updn_down
113} ts_updn_t;
114
115/** S3C24xx touchscreen driver instance */
116typedef struct {
117 /** Physical device address */
118 uintptr_t paddr;
119
120 /** Device I/O structure */
121 s3c24xx_adc_io_t *io;
122
123 /** Callback session to the client */
124 async_sess_t *client_sess;
125
126 /** Service ID */
127 service_id_t service_id;
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 */
Note: See TracBrowser for help on using the repository browser.