Lines Matching refs:ucb
34 static void ucb1400_ts_mode_int(struct ucb1400_ts *ucb) in ucb1400_ts_mode_int() argument
36 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_mode_int()
46 static unsigned int ucb1400_ts_read_pressure(struct ucb1400_ts *ucb) in ucb1400_ts_read_pressure() argument
48 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_pressure()
55 return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPY, adcsync); in ucb1400_ts_read_pressure()
64 static unsigned int ucb1400_ts_read_xpos(struct ucb1400_ts *ucb) in ucb1400_ts_read_xpos() argument
66 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_xpos()
69 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_xpos()
72 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_xpos()
78 return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPY, adcsync); in ucb1400_ts_read_xpos()
87 static int ucb1400_ts_read_ypos(struct ucb1400_ts *ucb) in ucb1400_ts_read_ypos() argument
89 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_ypos()
92 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_ypos()
95 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_ypos()
101 return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPX, adcsync); in ucb1400_ts_read_ypos()
108 static unsigned int ucb1400_ts_read_xres(struct ucb1400_ts *ucb) in ucb1400_ts_read_xres() argument
110 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_xres()
113 return ucb1400_adc_read(ucb->ac97, 0, adcsync); in ucb1400_ts_read_xres()
120 static unsigned int ucb1400_ts_read_yres(struct ucb1400_ts *ucb) in ucb1400_ts_read_yres() argument
122 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, in ucb1400_ts_read_yres()
125 return ucb1400_adc_read(ucb->ac97, 0, adcsync); in ucb1400_ts_read_yres()
128 static int ucb1400_ts_pen_up(struct ucb1400_ts *ucb) in ucb1400_ts_pen_up() argument
130 unsigned short val = ucb1400_reg_read(ucb->ac97, UCB_TS_CR); in ucb1400_ts_pen_up()
135 static void ucb1400_ts_irq_enable(struct ucb1400_ts *ucb) in ucb1400_ts_irq_enable() argument
137 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, UCB_IE_TSPX); in ucb1400_ts_irq_enable()
138 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_ts_irq_enable()
139 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_TSPX); in ucb1400_ts_irq_enable()
142 static void ucb1400_ts_irq_disable(struct ucb1400_ts *ucb) in ucb1400_ts_irq_disable() argument
144 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); in ucb1400_ts_irq_disable()
163 static void ucb1400_clear_pending_irq(struct ucb1400_ts *ucb) in ucb1400_clear_pending_irq() argument
167 isr = ucb1400_reg_read(ucb->ac97, UCB_IE_STATUS); in ucb1400_clear_pending_irq()
168 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, isr); in ucb1400_clear_pending_irq()
169 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_clear_pending_irq()
172 ucb1400_ts_irq_disable(ucb); in ucb1400_clear_pending_irq()
174 dev_dbg(&ucb->ts_idev->dev, in ucb1400_clear_pending_irq()
187 struct ucb1400_ts *ucb = devid; in ucb1400_irq() local
190 if (unlikely(irqnr != ucb->irq)) in ucb1400_irq()
193 ucb1400_clear_pending_irq(ucb); in ucb1400_irq()
198 while (!ucb->stopped && !ucb1400_ts_pen_up(ucb)) { in ucb1400_irq()
199 ucb1400_adc_enable(ucb->ac97); in ucb1400_irq()
200 x = ucb1400_ts_read_xpos(ucb); in ucb1400_irq()
201 y = ucb1400_ts_read_ypos(ucb); in ucb1400_irq()
202 p = ucb1400_ts_read_pressure(ucb); in ucb1400_irq()
203 ucb1400_adc_disable(ucb->ac97); in ucb1400_irq()
205 ucb1400_ts_report_event(ucb->ts_idev, p, x, y); in ucb1400_irq()
207 wait_event_timeout(ucb->ts_wait, ucb->stopped, in ucb1400_irq()
211 ucb1400_ts_event_release(ucb->ts_idev); in ucb1400_irq()
213 if (!ucb->stopped) { in ucb1400_irq()
215 ucb1400_ts_mode_int(ucb); in ucb1400_irq()
216 ucb1400_ts_irq_enable(ucb); in ucb1400_irq()
222 static void ucb1400_ts_stop(struct ucb1400_ts *ucb) in ucb1400_ts_stop() argument
225 ucb->stopped = true; in ucb1400_ts_stop()
227 wake_up(&ucb->ts_wait); in ucb1400_ts_stop()
228 disable_irq(ucb->irq); in ucb1400_ts_stop()
230 ucb1400_ts_irq_disable(ucb); in ucb1400_ts_stop()
231 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); in ucb1400_ts_stop()
235 static void ucb1400_ts_start(struct ucb1400_ts *ucb) in ucb1400_ts_start() argument
238 ucb->stopped = false; in ucb1400_ts_start()
241 ucb1400_ts_mode_int(ucb); in ucb1400_ts_start()
242 ucb1400_ts_irq_enable(ucb); in ucb1400_ts_start()
244 enable_irq(ucb->irq); in ucb1400_ts_start()
249 struct ucb1400_ts *ucb = input_get_drvdata(idev); in ucb1400_ts_open() local
251 ucb1400_ts_start(ucb); in ucb1400_ts_open()
258 struct ucb1400_ts *ucb = input_get_drvdata(idev); in ucb1400_ts_close() local
260 ucb1400_ts_stop(ucb); in ucb1400_ts_close()
271 static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb, in ucb1400_ts_detect_irq() argument
279 ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, UCB_IE_ADC); in ucb1400_ts_detect_irq()
280 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_ADC); in ucb1400_ts_detect_irq()
281 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); in ucb1400_ts_detect_irq()
282 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_ts_detect_irq()
285 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA); in ucb1400_ts_detect_irq()
286 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); in ucb1400_ts_detect_irq()
290 while (!(ucb1400_reg_read(ucb->ac97, UCB_ADC_DATA) & in ucb1400_ts_detect_irq()
299 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, 0); in ucb1400_ts_detect_irq()
302 ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, 0); in ucb1400_ts_detect_irq()
303 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); in ucb1400_ts_detect_irq()
304 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); in ucb1400_ts_detect_irq()
305 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_ts_detect_irq()
308 ucb->irq = probe_irq_off(mask); in ucb1400_ts_detect_irq()
309 if (ucb->irq < 0 || ucb->irq == NO_IRQ) in ucb1400_ts_detect_irq()
317 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev); in ucb1400_ts_probe() local
321 ucb->ts_idev = input_allocate_device(); in ucb1400_ts_probe()
322 if (!ucb->ts_idev) { in ucb1400_ts_probe()
328 if (ucb->irq < 0) { in ucb1400_ts_probe()
329 error = ucb1400_ts_detect_irq(ucb, pdev); in ucb1400_ts_probe()
335 dev_dbg(&pdev->dev, "found IRQ %d\n", ucb->irq); in ucb1400_ts_probe()
337 init_waitqueue_head(&ucb->ts_wait); in ucb1400_ts_probe()
339 input_set_drvdata(ucb->ts_idev, ucb); in ucb1400_ts_probe()
341 ucb->ts_idev->dev.parent = &pdev->dev; in ucb1400_ts_probe()
342 ucb->ts_idev->name = "UCB1400 touchscreen interface"; in ucb1400_ts_probe()
343 ucb->ts_idev->id.vendor = ucb1400_reg_read(ucb->ac97, in ucb1400_ts_probe()
345 ucb->ts_idev->id.product = ucb->id; in ucb1400_ts_probe()
346 ucb->ts_idev->open = ucb1400_ts_open; in ucb1400_ts_probe()
347 ucb->ts_idev->close = ucb1400_ts_close; in ucb1400_ts_probe()
348 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); in ucb1400_ts_probe()
349 ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in ucb1400_ts_probe()
356 fcsr = ucb1400_reg_read(ucb->ac97, UCB_FCSR); in ucb1400_ts_probe()
357 ucb1400_reg_write(ucb->ac97, UCB_FCSR, fcsr | UCB_FCSR_AVE); in ucb1400_ts_probe()
359 ucb1400_adc_enable(ucb->ac97); in ucb1400_ts_probe()
360 x_res = ucb1400_ts_read_xres(ucb); in ucb1400_ts_probe()
361 y_res = ucb1400_ts_read_yres(ucb); in ucb1400_ts_probe()
362 ucb1400_adc_disable(ucb->ac97); in ucb1400_ts_probe()
365 input_set_abs_params(ucb->ts_idev, ABS_X, 0, x_res, 0, 0); in ucb1400_ts_probe()
366 input_set_abs_params(ucb->ts_idev, ABS_Y, 0, y_res, 0, 0); in ucb1400_ts_probe()
367 input_set_abs_params(ucb->ts_idev, ABS_PRESSURE, 0, 0, 0, 0); in ucb1400_ts_probe()
369 ucb1400_ts_stop(ucb); in ucb1400_ts_probe()
371 error = request_threaded_irq(ucb->irq, NULL, ucb1400_irq, in ucb1400_ts_probe()
373 "UCB1400", ucb); in ucb1400_ts_probe()
376 "unable to grab irq%d: %d\n", ucb->irq, error); in ucb1400_ts_probe()
380 error = input_register_device(ucb->ts_idev); in ucb1400_ts_probe()
387 free_irq(ucb->irq, ucb); in ucb1400_ts_probe()
389 input_free_device(ucb->ts_idev); in ucb1400_ts_probe()
396 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev); in ucb1400_ts_remove() local
398 free_irq(ucb->irq, ucb); in ucb1400_ts_remove()
399 input_unregister_device(ucb->ts_idev); in ucb1400_ts_remove()
406 struct ucb1400_ts *ucb = dev_get_platdata(dev); in ucb1400_ts_suspend() local
407 struct input_dev *idev = ucb->ts_idev; in ucb1400_ts_suspend()
412 ucb1400_ts_stop(ucb); in ucb1400_ts_suspend()
420 struct ucb1400_ts *ucb = dev_get_platdata(dev); in ucb1400_ts_resume() local
421 struct input_dev *idev = ucb->ts_idev; in ucb1400_ts_resume()
426 ucb1400_ts_start(ucb); in ucb1400_ts_resume()