s3c24xx_ts.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Jiri Svoboda
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00037 #ifndef S3C24XX_TS_H_
00038 #define S3C24XX_TS_H_
00039 
00040 #include <sys/types.h>
00041 
00043 typedef struct {
00044         uint32_t con;
00045         uint32_t tsc;
00046         uint32_t dly;
00047         uint32_t dat0;
00048         uint32_t dat1;
00049         uint32_t updn;
00050 } s3c24xx_adc_io_t;
00051 
00052 /* Fields in ADCCON register */
00053 #define ADCCON_ECFLG            0x8000
00054 #define ADCCON_PRSCEN           0x4000
00055 
00056 #define ADCCON_PRSCVL(val)      (((val) & 0xff) << 6)
00057 
00058 #define ADCCON_SEL_MUX(smux)    (((smux) & 7) << 3)
00059 
00060 #define ADCCON_STDBM            0x0004
00061 #define ADCCON_READ_START       0x0002
00062 #define ADCCON_ENABLE_START     0x0001
00063 
00064 /* Values for ADCCON_SEL_MUX */
00065 #define SMUX_AIN0               0
00066 #define SMUX_AIN1               1
00067 #define SMUX_AIN2               2
00068 #define SMUX_AIN3               3
00069 #define SMUX_YM                 4
00070 #define SMUX_YP                 5
00071 #define SMUX_XM                 6
00072 #define SMUX_XP                 7
00073 
00074 
00075 /* Fields in ADCTSC register */
00076 #define ADCTSC_DSUD_UP          0x0100
00077 #define ADCTSC_YM_ENABLE        0x0080
00078 #define ADCTSC_YP_DISABLE       0x0040
00079 #define ADCTSC_XM_ENABLE        0x0020
00080 #define ADCTSC_XP_DISABLE       0x0010
00081 #define ADCTSC_PULLUP_DISABLE   0x0008
00082 #define ADCTSC_AUTO_PST         0x0004
00083 
00084 #define ADCTSC_XY_PST_NOOP      0x0000
00085 #define ADCTSC_XY_PST_X         0x0001
00086 #define ADCTSC_XY_PST_Y         0x0002
00087 #define ADCTSC_XY_PST_WAITINT   0x0003
00088 #define ADCTSC_XY_PST_MASK      0x0003
00089 
00090 /* Fields in ADCDAT0, ADCDAT1 registers */
00091 #define ADCDAT_UPDOWN           0x8000
00092 #define ADCDAT_AUTO_PST         0x4000
00093 
00094 /* Fields in ADCUPDN register */
00095 #define ADCUPDN_TSC_UP          0x0002
00096 #define ADCUPDN_TSC_DN          0x0001
00097 
00099 #define S3C24XX_TS_INR          31
00100 
00102 #define S3C24XX_TS_ADDR         0x58000000
00103 
00104 typedef enum {
00105         ts_wait_pendown,
00106         ts_sample_pos,
00107         ts_wait_penup
00108 } ts_state_t;
00109 
00110 typedef enum {
00111         updn_up,
00112         updn_down
00113 } ts_updn_t;
00114 
00116 typedef struct {
00118         uintptr_t paddr;
00119 
00121         s3c24xx_adc_io_t *io;
00122 
00124         int client_phone;
00125 
00127         devmap_handle_t devmap_handle;
00128 
00130         ts_state_t state;
00131 
00133         int last_x;
00134         int last_y;
00135 } s3c24xx_ts_t;
00136 
00137 #endif
00138 

Generated on Thu Jun 2 07:45:50 2011 for HelenOS/USB by  doxygen 1.4.7