Lines Matching full: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
98 /* Data in 2's complement, convert to mg */ in decode_mg()
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 guard(mutex)(&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()
232 struct cma3000_accl_data *data = input_get_drvdata(input_dev); in cma3000_close() local
234 guard(mutex)(&data->mutex); in cma3000_close()
236 if (!data->suspended) in cma3000_close()
237 cma3000_poweroff(data); in cma3000_close()
239 data->opened = false; in cma3000_close()
242 void cma3000_suspend(struct cma3000_accl_data *data) in cma3000_suspend() argument
244 guard(mutex)(&data->mutex); in cma3000_suspend()
246 if (!data->suspended && data->opened) in cma3000_suspend()
247 cma3000_poweroff(data); in cma3000_suspend()
249 data->suspended = true; in cma3000_suspend()
254 void cma3000_resume(struct cma3000_accl_data *data) in cma3000_resume() argument
256 guard(mutex)(&data->mutex); in cma3000_resume()
258 if (data->suspended && data->opened) in cma3000_resume()
259 cma3000_poweron(data); in cma3000_resume()
261 data->suspended = false; in cma3000_resume()
269 struct cma3000_accl_data *data; in cma3000_init() local
275 dev_err(dev, "platform data not found\n"); in cma3000_init()
287 data = kzalloc(sizeof(*data), GFP_KERNEL); in cma3000_init()
289 if (!data || !input_dev) { in cma3000_init()
294 data->dev = dev; in cma3000_init()
295 data->input_dev = input_dev; in cma3000_init()
296 data->bus_ops = bops; in cma3000_init()
297 data->pdata = pdata; in cma3000_init()
298 data->irq = irq; in cma3000_init()
299 mutex_init(&data->mutex); in cma3000_init()
301 data->mode = pdata->mode; in cma3000_init()
302 if (data->mode > CMAMODE_POFF) { in cma3000_init()
303 data->mode = CMAMODE_MOTDET; in cma3000_init()
308 data->g_range = pdata->g_range; in cma3000_init()
309 if (data->g_range != CMARANGE_2G && data->g_range != CMARANGE_8G) { in cma3000_init()
312 data->g_range = CMARANGE_8G; in cma3000_init()
321 -data->g_range, data->g_range, pdata->fuzz_x, 0); in cma3000_init()
323 -data->g_range, data->g_range, pdata->fuzz_y, 0); in cma3000_init()
325 -data->g_range, data->g_range, pdata->fuzz_z, 0); in cma3000_init()
328 input_set_drvdata(input_dev, data); in cma3000_init()
330 error = cma3000_reset(data); in cma3000_init()
334 rev = CMA3000_READ(data, CMA3000_REVID, "Revid"); in cma3000_init()
344 "cma3000_d0x", data); in cma3000_init()
350 error = input_register_device(data->input_dev); in cma3000_init()
356 return data; in cma3000_init()
359 free_irq(irq, data); in cma3000_init()
362 kfree(data); in cma3000_init()
368 void cma3000_exit(struct cma3000_accl_data *data) in cma3000_exit() argument
370 free_irq(data->irq, data); in cma3000_exit()
371 input_unregister_device(data->input_dev); in cma3000_exit()
372 kfree(data); in cma3000_exit()