11/*
22 * AD714X CapTouch Programmable Controller driver supporting AD7142/3/7/8/7A
33 *
4- * Copyright 2009 Analog Devices Inc.
4+ * Copyright 2009-2011 Analog Devices Inc.
55 *
66 * Licensed under the GPL-2 or later.
77 */
@@ -123,6 +123,7 @@ struct ad714x_driver_data {
123123 * information to integrate all things which will be private data
124124 * of spi/i2c device
125125 */
126+
126127static void ad714x_use_com_int (struct ad714x_chip * ad714x ,
127128 int start_stage , int end_stage )
128129{
@@ -131,11 +132,11 @@ static void ad714x_use_com_int(struct ad714x_chip *ad714x,
131132
132133 mask = ((1 << (end_stage + 1 )) - 1 ) - ((1 << start_stage ) - 1 );
133134
134- ad714x -> read (ad714x , STG_COM_INT_EN_REG , & data );
135+ ad714x -> read (ad714x , STG_COM_INT_EN_REG , & data , 1 );
135136 data |= 1 << end_stage ;
136137 ad714x -> write (ad714x , STG_COM_INT_EN_REG , data );
137138
138- ad714x -> read (ad714x , STG_HIGH_INT_EN_REG , & data );
139+ ad714x -> read (ad714x , STG_HIGH_INT_EN_REG , & data , 1 );
139140 data &= ~mask ;
140141 ad714x -> write (ad714x , STG_HIGH_INT_EN_REG , data );
141142}
@@ -148,11 +149,11 @@ static void ad714x_use_thr_int(struct ad714x_chip *ad714x,
148149
149150 mask = ((1 << (end_stage + 1 )) - 1 ) - ((1 << start_stage ) - 1 );
150151
151- ad714x -> read (ad714x , STG_COM_INT_EN_REG , & data );
152+ ad714x -> read (ad714x , STG_COM_INT_EN_REG , & data , 1 );
152153 data &= ~(1 << end_stage );
153154 ad714x -> write (ad714x , STG_COM_INT_EN_REG , data );
154155
155- ad714x -> read (ad714x , STG_HIGH_INT_EN_REG , & data );
156+ ad714x -> read (ad714x , STG_HIGH_INT_EN_REG , & data , 1 );
156157 data |= mask ;
157158 ad714x -> write (ad714x , STG_HIGH_INT_EN_REG , data );
158159}
@@ -250,13 +251,16 @@ static void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
250251 struct ad714x_slider_plat * hw = & ad714x -> hw -> slider [idx ];
251252 int i ;
252253
254+ ad714x -> read (ad714x , CDC_RESULT_S0 + hw -> start_stage ,
255+ & ad714x -> adc_reg [hw -> start_stage ],
256+ hw -> end_stage - hw -> start_stage + 1 );
257+
253258 for (i = hw -> start_stage ; i <= hw -> end_stage ; i ++ ) {
254- ad714x -> read (ad714x , CDC_RESULT_S0 + i , & ad714x -> adc_reg [i ]);
255259 ad714x -> read (ad714x , STAGE0_AMBIENT + i * PER_STAGE_REG_NUM ,
256- & ad714x -> amb_reg [i ]);
260+ & ad714x -> amb_reg [i ], 1 );
257261
258- ad714x -> sensor_val [i ] = abs ( ad714x -> adc_reg [ i ] -
259- ad714x -> amb_reg [i ]);
262+ ad714x -> sensor_val [i ] =
263+ abs ( ad714x -> adc_reg [ i ] - ad714x -> amb_reg [i ]);
260264 }
261265}
262266
@@ -419,13 +423,16 @@ static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
419423 struct ad714x_wheel_plat * hw = & ad714x -> hw -> wheel [idx ];
420424 int i ;
421425
426+ ad714x -> read (ad714x , CDC_RESULT_S0 + hw -> start_stage ,
427+ & ad714x -> adc_reg [hw -> start_stage ],
428+ hw -> end_stage - hw -> start_stage + 1 );
429+
422430 for (i = hw -> start_stage ; i <= hw -> end_stage ; i ++ ) {
423- ad714x -> read (ad714x , CDC_RESULT_S0 + i , & ad714x -> adc_reg [i ]);
424431 ad714x -> read (ad714x , STAGE0_AMBIENT + i * PER_STAGE_REG_NUM ,
425- & ad714x -> amb_reg [i ]);
432+ & ad714x -> amb_reg [i ], 1 );
426433 if (ad714x -> adc_reg [i ] > ad714x -> amb_reg [i ])
427- ad714x -> sensor_val [i ] = ad714x -> adc_reg [ i ] -
428- ad714x -> amb_reg [i ];
434+ ad714x -> sensor_val [i ] =
435+ ad714x -> adc_reg [ i ] - ad714x -> amb_reg [i ];
429436 else
430437 ad714x -> sensor_val [i ] = 0 ;
431438 }
@@ -570,13 +577,16 @@ static void touchpad_cal_sensor_val(struct ad714x_chip *ad714x, int idx)
570577 struct ad714x_touchpad_plat * hw = & ad714x -> hw -> touchpad [idx ];
571578 int i ;
572579
580+ ad714x -> read (ad714x , CDC_RESULT_S0 + hw -> x_start_stage ,
581+ & ad714x -> adc_reg [hw -> x_start_stage ],
582+ hw -> x_end_stage - hw -> x_start_stage + 1 );
583+
573584 for (i = hw -> x_start_stage ; i <= hw -> x_end_stage ; i ++ ) {
574- ad714x -> read (ad714x , CDC_RESULT_S0 + i , & ad714x -> adc_reg [i ]);
575585 ad714x -> read (ad714x , STAGE0_AMBIENT + i * PER_STAGE_REG_NUM ,
576- & ad714x -> amb_reg [i ]);
586+ & ad714x -> amb_reg [i ], 1 );
577587 if (ad714x -> adc_reg [i ] > ad714x -> amb_reg [i ])
578- ad714x -> sensor_val [i ] = ad714x -> adc_reg [ i ] -
579- ad714x -> amb_reg [i ];
588+ ad714x -> sensor_val [i ] =
589+ ad714x -> adc_reg [ i ] - ad714x -> amb_reg [i ];
580590 else
581591 ad714x -> sensor_val [i ] = 0 ;
582592 }
@@ -862,7 +872,7 @@ static int ad714x_hw_detect(struct ad714x_chip *ad714x)
862872{
863873 unsigned short data ;
864874
865- ad714x -> read (ad714x , AD714X_PARTID_REG , & data );
875+ ad714x -> read (ad714x , AD714X_PARTID_REG , & data , 1 );
866876 switch (data & 0xFFF0 ) {
867877 case AD7142_PARTID :
868878 ad714x -> product = 0x7142 ;
@@ -919,14 +929,12 @@ static void ad714x_hw_init(struct ad714x_chip *ad714x)
919929 ad714x -> write (ad714x , AD714X_SYSCFG_REG + i ,
920930 ad714x -> hw -> sys_cfg_reg [i ]);
921931 for (i = 0 ; i < SYS_CFGREG_NUM ; i ++ )
922- ad714x -> read (ad714x , AD714X_SYSCFG_REG + i , & data );
932+ ad714x -> read (ad714x , AD714X_SYSCFG_REG + i , & data , 1 );
923933
924934 ad714x -> write (ad714x , AD714X_STG_CAL_EN_REG , 0xFFF );
925935
926936 /* clear all interrupts */
927- ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & data );
928- ad714x -> read (ad714x , STG_HIGH_INT_STA_REG , & data );
929- ad714x -> read (ad714x , STG_COM_INT_STA_REG , & data );
937+ ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & ad714x -> l_state , 3 );
930938}
931939
932940static irqreturn_t ad714x_interrupt_thread (int irq , void * data )
@@ -936,9 +944,7 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
936944
937945 mutex_lock (& ad714x -> mutex );
938946
939- ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & ad714x -> l_state );
940- ad714x -> read (ad714x , STG_HIGH_INT_STA_REG , & ad714x -> h_state );
941- ad714x -> read (ad714x , STG_COM_INT_STA_REG , & ad714x -> c_state );
947+ ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & ad714x -> l_state , 3 );
942948
943949 for (i = 0 ; i < ad714x -> hw -> button_num ; i ++ )
944950 ad714x_button_state_machine (ad714x , i );
@@ -1225,8 +1231,6 @@ EXPORT_SYMBOL(ad714x_disable);
12251231
12261232int ad714x_enable (struct ad714x_chip * ad714x )
12271233{
1228- unsigned short data ;
1229-
12301234 dev_dbg (ad714x -> dev , "%s enter\n" , __func__ );
12311235
12321236 mutex_lock (& ad714x -> mutex );
@@ -1240,9 +1244,7 @@ int ad714x_enable(struct ad714x_chip *ad714x)
12401244 * otherwise we will get no chance to enter falling-edge irq again
12411245 */
12421246
1243- ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & data );
1244- ad714x -> read (ad714x , STG_HIGH_INT_STA_REG , & data );
1245- ad714x -> read (ad714x , STG_COM_INT_STA_REG , & data );
1247+ ad714x -> read (ad714x , STG_LOW_INT_STA_REG , & ad714x -> l_state , 3 );
12461248
12471249 mutex_unlock (& ad714x -> mutex );
12481250
0 commit comments