Lines Matching refs:data
73 #define CMA3000_READ(data, reg, msg) \ argument
74 (data->bus_ops->read(data->dev, reg, msg))
75 #define CMA3000_SET(data, reg, val, msg) \ argument
76 ((data)->bus_ops->write(data->dev, reg, val, msg))
95 static void decode_mg(struct cma3000_accl_data *data, int *datax, in decode_mg() argument
99 *datax = ((s8)*datax) * data->bit_to_mg; in decode_mg()
100 *datay = ((s8)*datay) * data->bit_to_mg; in decode_mg()
101 *dataz = ((s8)*dataz) * data->bit_to_mg; in decode_mg()
106 struct cma3000_accl_data *data = dev_id; in cma3000_thread_irq() local
110 intr_status = CMA3000_READ(data, CMA3000_INTSTATUS, "interrupt status"); in cma3000_thread_irq()
116 input_report_abs(data->input_dev, ABS_MISC, 1); in cma3000_thread_irq()
117 input_sync(data->input_dev); in cma3000_thread_irq()
119 input_report_abs(data->input_dev, ABS_MISC, 0); in cma3000_thread_irq()
122 datax = CMA3000_READ(data, CMA3000_DOUTX, "X"); in cma3000_thread_irq()
123 datay = CMA3000_READ(data, CMA3000_DOUTY, "Y"); in cma3000_thread_irq()
124 dataz = CMA3000_READ(data, CMA3000_DOUTZ, "Z"); in cma3000_thread_irq()
126 ctrl = CMA3000_READ(data, CMA3000_CTRL, "ctrl"); in cma3000_thread_irq()
130 data->bit_to_mg = mode_to_mg[mode][range]; in cma3000_thread_irq()
133 if (data->bit_to_mg == 0) in cma3000_thread_irq()
137 decode_mg(data, &datax, &datay, &dataz); in cma3000_thread_irq()
139 input_report_abs(data->input_dev, ABS_X, datax); in cma3000_thread_irq()
140 input_report_abs(data->input_dev, ABS_Y, datay); in cma3000_thread_irq()
141 input_report_abs(data->input_dev, ABS_Z, dataz); in cma3000_thread_irq()
142 input_sync(data->input_dev); in cma3000_thread_irq()
147 static int cma3000_reset(struct cma3000_accl_data *data) in cma3000_reset() argument
152 CMA3000_SET(data, CMA3000_RSTR, 0x02, "Reset"); in cma3000_reset()
153 CMA3000_SET(data, CMA3000_RSTR, 0x0A, "Reset"); in cma3000_reset()
154 CMA3000_SET(data, CMA3000_RSTR, 0x04, "Reset"); in cma3000_reset()
159 val = CMA3000_READ(data, CMA3000_STATUS, "Status"); in cma3000_reset()
161 dev_err(data->dev, "Reset failed\n"); in cma3000_reset()
166 dev_err(data->dev, "Parity Error\n"); in cma3000_reset()
173 static int cma3000_poweron(struct cma3000_accl_data *data) in cma3000_poweron() argument
175 const struct cma3000_platform_data *pdata = data->pdata; in cma3000_poweron()
179 if (data->g_range == CMARANGE_2G) { in cma3000_poweron()
180 ctrl = (data->mode << 1) | CMA3000_RANGE2G; in cma3000_poweron()
181 } else if (data->g_range == CMARANGE_8G) { in cma3000_poweron()
182 ctrl = (data->mode << 1) | CMA3000_RANGE8G; in cma3000_poweron()
184 dev_info(data->dev, in cma3000_poweron()
186 ctrl = (data->mode << 1) | CMA3000_RANGE8G; in cma3000_poweron()
189 ctrl |= data->bus_ops->ctrl_mod; in cma3000_poweron()
191 CMA3000_SET(data, CMA3000_MDTHR, pdata->mdthr, in cma3000_poweron()
193 CMA3000_SET(data, CMA3000_MDFFTMR, pdata->mdfftmr, in cma3000_poweron()
195 CMA3000_SET(data, CMA3000_FFTHR, pdata->ffthr, in cma3000_poweron()
197 ret = CMA3000_SET(data, CMA3000_CTRL, ctrl, "Mode setting"); in cma3000_poweron()
206 static int cma3000_poweroff(struct cma3000_accl_data *data) in cma3000_poweroff() argument
210 ret = CMA3000_SET(data, CMA3000_CTRL, CMAMODE_POFF, "Mode setting"); in cma3000_poweroff()
218 struct cma3000_accl_data *data = input_get_drvdata(input_dev); in cma3000_open() local
220 mutex_lock(&data->mutex); in cma3000_open()
222 if (!data->suspended) in cma3000_open()
223 cma3000_poweron(data); in cma3000_open()
225 data->opened = true; in cma3000_open()
227 mutex_unlock(&data->mutex); in cma3000_open()
234 struct cma3000_accl_data *data = input_get_drvdata(input_dev); in cma3000_close() local
236 mutex_lock(&data->mutex); in cma3000_close()
238 if (!data->suspended) in cma3000_close()
239 cma3000_poweroff(data); in cma3000_close()
241 data->opened = false; in cma3000_close()
243 mutex_unlock(&data->mutex); in cma3000_close()
246 void cma3000_suspend(struct cma3000_accl_data *data) in cma3000_suspend() argument
248 mutex_lock(&data->mutex); in cma3000_suspend()
250 if (!data->suspended && data->opened) in cma3000_suspend()
251 cma3000_poweroff(data); in cma3000_suspend()
253 data->suspended = true; in cma3000_suspend()
255 mutex_unlock(&data->mutex); in cma3000_suspend()
260 void cma3000_resume(struct cma3000_accl_data *data) in cma3000_resume() argument
262 mutex_lock(&data->mutex); in cma3000_resume()
264 if (data->suspended && data->opened) in cma3000_resume()
265 cma3000_poweron(data); in cma3000_resume()
267 data->suspended = false; in cma3000_resume()
269 mutex_unlock(&data->mutex); in cma3000_resume()
277 struct cma3000_accl_data *data; in cma3000_init() local
295 data = kzalloc(sizeof(struct cma3000_accl_data), GFP_KERNEL); in cma3000_init()
297 if (!data || !input_dev) { in cma3000_init()
302 data->dev = dev; in cma3000_init()
303 data->input_dev = input_dev; in cma3000_init()
304 data->bus_ops = bops; in cma3000_init()
305 data->pdata = pdata; in cma3000_init()
306 data->irq = irq; in cma3000_init()
307 mutex_init(&data->mutex); in cma3000_init()
309 data->mode = pdata->mode; in cma3000_init()
310 if (data->mode > CMAMODE_POFF) { in cma3000_init()
311 data->mode = CMAMODE_MOTDET; in cma3000_init()
316 data->g_range = pdata->g_range; in cma3000_init()
317 if (data->g_range != CMARANGE_2G && data->g_range != CMARANGE_8G) { in cma3000_init()
320 data->g_range = CMARANGE_8G; in cma3000_init()
329 -data->g_range, data->g_range, pdata->fuzz_x, 0); in cma3000_init()
331 -data->g_range, data->g_range, pdata->fuzz_y, 0); in cma3000_init()
333 -data->g_range, data->g_range, pdata->fuzz_z, 0); in cma3000_init()
336 input_set_drvdata(input_dev, data); in cma3000_init()
338 error = cma3000_reset(data); in cma3000_init()
342 rev = CMA3000_READ(data, CMA3000_REVID, "Revid"); in cma3000_init()
352 "cma3000_d0x", data); in cma3000_init()
358 error = input_register_device(data->input_dev); in cma3000_init()
364 return data; in cma3000_init()
367 free_irq(irq, data); in cma3000_init()
370 kfree(data); in cma3000_init()
376 void cma3000_exit(struct cma3000_accl_data *data) in cma3000_exit() argument
378 free_irq(data->irq, data); in cma3000_exit()
379 input_unregister_device(data->input_dev); in cma3000_exit()
380 kfree(data); in cma3000_exit()