Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
ad7877.c File Reference
#include <linux/device.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/spi/ad7877.h>
#include <linux/module.h>
#include <asm/irq.h>

Go to the source code of this file.

Data Structures

struct  ser_req
 
struct  ad7877
 

Macros

#define TS_PEN_UP_TIMEOUT   msecs_to_jiffies(100)
 
#define MAX_SPI_FREQ_HZ   20000000
 
#define MAX_12BIT   ((1<<12)-1)
 
#define AD7877_REG_ZEROS   0
 
#define AD7877_REG_CTRL1   1
 
#define AD7877_REG_CTRL2   2
 
#define AD7877_REG_ALERT   3
 
#define AD7877_REG_AUX1HIGH   4
 
#define AD7877_REG_AUX1LOW   5
 
#define AD7877_REG_BAT1HIGH   6
 
#define AD7877_REG_BAT1LOW   7
 
#define AD7877_REG_BAT2HIGH   8
 
#define AD7877_REG_BAT2LOW   9
 
#define AD7877_REG_TEMP1HIGH   10
 
#define AD7877_REG_TEMP1LOW   11
 
#define AD7877_REG_SEQ0   12
 
#define AD7877_REG_SEQ1   13
 
#define AD7877_REG_DAC   14
 
#define AD7877_REG_NONE1   15
 
#define AD7877_REG_EXTWRITE   15
 
#define AD7877_REG_XPLUS   16
 
#define AD7877_REG_YPLUS   17
 
#define AD7877_REG_Z2   18
 
#define AD7877_REG_aux1   19
 
#define AD7877_REG_aux2   20
 
#define AD7877_REG_aux3   21
 
#define AD7877_REG_bat1   22
 
#define AD7877_REG_bat2   23
 
#define AD7877_REG_temp1   24
 
#define AD7877_REG_temp2   25
 
#define AD7877_REG_Z1   26
 
#define AD7877_REG_GPIOCTRL1   27
 
#define AD7877_REG_GPIOCTRL2   28
 
#define AD7877_REG_GPIODATA   29
 
#define AD7877_REG_NONE2   30
 
#define AD7877_REG_NONE3   31
 
#define AD7877_SEQ_YPLUS_BIT   (1<<11)
 
#define AD7877_SEQ_XPLUS_BIT   (1<<10)
 
#define AD7877_SEQ_Z2_BIT   (1<<9)
 
#define AD7877_SEQ_AUX1_BIT   (1<<8)
 
#define AD7877_SEQ_AUX2_BIT   (1<<7)
 
#define AD7877_SEQ_AUX3_BIT   (1<<6)
 
#define AD7877_SEQ_BAT1_BIT   (1<<5)
 
#define AD7877_SEQ_BAT2_BIT   (1<<4)
 
#define AD7877_SEQ_TEMP1_BIT   (1<<3)
 
#define AD7877_SEQ_TEMP2_BIT   (1<<2)
 
#define AD7877_SEQ_Z1_BIT   (1<<1)
 
#define AD7877_DAC_CONF   0x1
 
#define AD7877_EXTW_GPIO_3_CONF   0x1C4
 
#define AD7877_EXTW_GPIO_DATA   0x200
 
#define AD7877_TMR(x)   ((x & 0x3) << 0)
 
#define AD7877_REF(x)   ((x & 0x1) << 2)
 
#define AD7877_POL(x)   ((x & 0x1) << 3)
 
#define AD7877_FCD(x)   ((x & 0x3) << 4)
 
#define AD7877_PM(x)   ((x & 0x3) << 6)
 
#define AD7877_ACQ(x)   ((x & 0x3) << 8)
 
#define AD7877_AVG(x)   ((x & 0x3) << 10)
 
#define AD7877_SER   (1 << 11) /* non-differential */
 
#define AD7877_DFR   (0 << 11) /* differential */
 
#define AD7877_MODE_NOC   (0) /* Do not convert */
 
#define AD7877_MODE_SCC   (1) /* Single channel conversion */
 
#define AD7877_MODE_SEQ0   (2) /* Sequence 0 in Slave Mode */
 
#define AD7877_MODE_SEQ1   (3) /* Sequence 1 in Master Mode */
 
#define AD7877_CHANADD(x)   ((x&0xF)<<7)
 
#define AD7877_READADD(x)   ((x)<<2)
 
#define AD7877_WRITEADD(x)   ((x)<<12)
 
#define AD7877_READ_CHAN(x)
 
#define AD7877_MM_SEQUENCE
 
#define SHOW(name)
 

Enumerations

enum  {
  AD7877_SEQ_YPOS = 0, AD7877_SEQ_XPOS = 1, AD7877_SEQ_Z2 = 2, AD7877_SEQ_AUX1 = 3,
  AD7877_SEQ_AUX2 = 4, AD7877_SEQ_AUX3 = 5, AD7877_SEQ_BAT1 = 6, AD7877_SEQ_BAT2 = 7,
  AD7877_SEQ_TEMP1 = 8, AD7877_SEQ_TEMP2 = 9, AD7877_SEQ_Z1 = 10, AD7877_NR_SENSE = 11
}
 

Functions

 module_param (gpio3, bool, 0)
 
 MODULE_PARM_DESC (gpio3,"If gpio3 is set to 1 AUX3 acts as GPIO3")
 
 module_spi_driver (ad7877_driver)
 
 MODULE_AUTHOR ("Michael Hennerich <[email protected]>")
 
 MODULE_DESCRIPTION ("AD7877 touchscreen Driver")
 
 MODULE_LICENSE ("GPL")
 
 MODULE_ALIAS ("spi:ad7877")
 

Macro Definition Documentation

#define AD7877_ACQ (   x)    ((x & 0x3) << 8)

Definition at line 130 of file ad7877.c.

#define AD7877_AVG (   x)    ((x & 0x3) << 10)

Definition at line 131 of file ad7877.c.

#define AD7877_CHANADD (   x)    ((x&0xF)<<7)

Definition at line 142 of file ad7877.c.

#define AD7877_DAC_CONF   0x1

Definition at line 118 of file ad7877.c.

#define AD7877_DFR   (0 << 11) /* differential */

Definition at line 135 of file ad7877.c.

#define AD7877_EXTW_GPIO_3_CONF   0x1C4

Definition at line 121 of file ad7877.c.

#define AD7877_EXTW_GPIO_DATA   0x200

Definition at line 122 of file ad7877.c.

#define AD7877_FCD (   x)    ((x & 0x3) << 4)

Definition at line 128 of file ad7877.c.

#define AD7877_MM_SEQUENCE
Value:

Definition at line 150 of file ad7877.c.

#define AD7877_MODE_NOC   (0) /* Do not convert */

Definition at line 137 of file ad7877.c.

#define AD7877_MODE_SCC   (1) /* Single channel conversion */

Definition at line 138 of file ad7877.c.

#define AD7877_MODE_SEQ0   (2) /* Sequence 0 in Slave Mode */

Definition at line 139 of file ad7877.c.

#define AD7877_MODE_SEQ1   (3) /* Sequence 1 in Master Mode */

Definition at line 140 of file ad7877.c.

#define AD7877_PM (   x)    ((x & 0x3) << 6)

Definition at line 129 of file ad7877.c.

#define AD7877_POL (   x)    ((x & 0x1) << 3)

Definition at line 127 of file ad7877.c.

#define AD7877_READ_CHAN (   x)
Value:
AD7877_MODE_SCC | AD7877_CHANADD(AD7877_REG_ ## x) | \
AD7877_READADD(AD7877_REG_ ## x))

Definition at line 146 of file ad7877.c.

#define AD7877_READADD (   x)    ((x)<<2)

Definition at line 143 of file ad7877.c.

#define AD7877_REF (   x)    ((x & 0x1) << 2)

Definition at line 126 of file ad7877.c.

#define AD7877_REG_ALERT   3

Definition at line 59 of file ad7877.c.

#define AD7877_REG_aux1   19

Definition at line 76 of file ad7877.c.

#define AD7877_REG_AUX1HIGH   4

Definition at line 60 of file ad7877.c.

#define AD7877_REG_AUX1LOW   5

Definition at line 61 of file ad7877.c.

#define AD7877_REG_aux2   20

Definition at line 77 of file ad7877.c.

#define AD7877_REG_aux3   21

Definition at line 78 of file ad7877.c.

#define AD7877_REG_bat1   22

Definition at line 79 of file ad7877.c.

#define AD7877_REG_BAT1HIGH   6

Definition at line 62 of file ad7877.c.

#define AD7877_REG_BAT1LOW   7

Definition at line 63 of file ad7877.c.

#define AD7877_REG_bat2   23

Definition at line 80 of file ad7877.c.

#define AD7877_REG_BAT2HIGH   8

Definition at line 64 of file ad7877.c.

#define AD7877_REG_BAT2LOW   9

Definition at line 65 of file ad7877.c.

#define AD7877_REG_CTRL1   1

Definition at line 57 of file ad7877.c.

#define AD7877_REG_CTRL2   2

Definition at line 58 of file ad7877.c.

#define AD7877_REG_DAC   14

Definition at line 70 of file ad7877.c.

#define AD7877_REG_EXTWRITE   15

Definition at line 72 of file ad7877.c.

#define AD7877_REG_GPIOCTRL1   27

Definition at line 84 of file ad7877.c.

#define AD7877_REG_GPIOCTRL2   28

Definition at line 85 of file ad7877.c.

#define AD7877_REG_GPIODATA   29

Definition at line 86 of file ad7877.c.

#define AD7877_REG_NONE1   15

Definition at line 71 of file ad7877.c.

#define AD7877_REG_NONE2   30

Definition at line 87 of file ad7877.c.

#define AD7877_REG_NONE3   31

Definition at line 88 of file ad7877.c.

#define AD7877_REG_SEQ0   12

Definition at line 68 of file ad7877.c.

#define AD7877_REG_SEQ1   13

Definition at line 69 of file ad7877.c.

#define AD7877_REG_temp1   24

Definition at line 81 of file ad7877.c.

#define AD7877_REG_TEMP1HIGH   10

Definition at line 66 of file ad7877.c.

#define AD7877_REG_TEMP1LOW   11

Definition at line 67 of file ad7877.c.

#define AD7877_REG_temp2   25

Definition at line 82 of file ad7877.c.

#define AD7877_REG_XPLUS   16

Definition at line 73 of file ad7877.c.

#define AD7877_REG_YPLUS   17

Definition at line 74 of file ad7877.c.

#define AD7877_REG_Z1   26

Definition at line 83 of file ad7877.c.

#define AD7877_REG_Z2   18

Definition at line 75 of file ad7877.c.

#define AD7877_REG_ZEROS   0

Definition at line 56 of file ad7877.c.

#define AD7877_SEQ_AUX1_BIT   (1<<8)

Definition at line 93 of file ad7877.c.

#define AD7877_SEQ_AUX2_BIT   (1<<7)

Definition at line 94 of file ad7877.c.

#define AD7877_SEQ_AUX3_BIT   (1<<6)

Definition at line 95 of file ad7877.c.

#define AD7877_SEQ_BAT1_BIT   (1<<5)

Definition at line 96 of file ad7877.c.

#define AD7877_SEQ_BAT2_BIT   (1<<4)

Definition at line 97 of file ad7877.c.

#define AD7877_SEQ_TEMP1_BIT   (1<<3)

Definition at line 98 of file ad7877.c.

#define AD7877_SEQ_TEMP2_BIT   (1<<2)

Definition at line 99 of file ad7877.c.

#define AD7877_SEQ_XPLUS_BIT   (1<<10)

Definition at line 91 of file ad7877.c.

#define AD7877_SEQ_YPLUS_BIT   (1<<11)

Definition at line 90 of file ad7877.c.

#define AD7877_SEQ_Z1_BIT   (1<<1)

Definition at line 100 of file ad7877.c.

#define AD7877_SEQ_Z2_BIT   (1<<9)

Definition at line 92 of file ad7877.c.

#define AD7877_SER   (1 << 11) /* non-differential */

Definition at line 134 of file ad7877.c.

#define AD7877_TMR (   x)    ((x & 0x3) << 0)

Definition at line 125 of file ad7877.c.

#define AD7877_WRITEADD (   x)    ((x)<<12)

Definition at line 144 of file ad7877.c.

#define MAX_12BIT   ((1<<12)-1)

Definition at line 54 of file ad7877.c.

#define MAX_SPI_FREQ_HZ   20000000

Definition at line 53 of file ad7877.c.

#define SHOW (   name)
Value:
static ssize_t \
name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
ssize_t v = ad7877_read_adc(ts->spi, \
if (v < 0) \
return v; \
return sprintf(buf, "%u\n", (unsigned) v); \
} \
static DEVICE_ATTR(name, S_IRUGO, name ## _show, NULL);

Definition at line 458 of file ad7877.c.

#define TS_PEN_UP_TIMEOUT   msecs_to_jiffies(100)

Definition at line 51 of file ad7877.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
AD7877_SEQ_YPOS 
AD7877_SEQ_XPOS 
AD7877_SEQ_Z2 
AD7877_SEQ_AUX1 
AD7877_SEQ_AUX2 
AD7877_SEQ_AUX3 
AD7877_SEQ_BAT1 
AD7877_SEQ_BAT2 
AD7877_SEQ_TEMP1 
AD7877_SEQ_TEMP2 
AD7877_SEQ_Z1 
AD7877_NR_SENSE 

Definition at line 102 of file ad7877.c.

Function Documentation

MODULE_ALIAS ( "spi:ad7877"  )
MODULE_AUTHOR ( "Michael Hennerich <[email protected]>"  )
MODULE_DESCRIPTION ( "AD7877 touchscreen Driver"  )
MODULE_LICENSE ( "GPL"  )
module_param ( gpio3  ,
bool  ,
 
)
MODULE_PARM_DESC ( gpio3  ,
"If gpio3 is set to 1 AUX3 acts as GPIO3  
)
module_spi_driver ( ad7877_driver  )