Lines Matching full: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
191 if (unlikely(irqnr != ucb->irq)) in ucb1400_irq()
194 ucb1400_clear_pending_irq(ucb); in ucb1400_irq()
199 while (!ucb->stopped && !(penup = ucb1400_ts_pen_up(ucb))) { in ucb1400_irq()
201 ucb1400_adc_enable(ucb->ac97); in ucb1400_irq()
202 x = ucb1400_ts_read_xpos(ucb); in ucb1400_irq()
203 y = ucb1400_ts_read_ypos(ucb); in ucb1400_irq()
204 p = ucb1400_ts_read_pressure(ucb); in ucb1400_irq()
205 ucb1400_adc_disable(ucb->ac97); in ucb1400_irq()
207 ucb1400_ts_report_event(ucb->ts_idev, p, x, y); in ucb1400_irq()
209 wait_event_timeout(ucb->ts_wait, ucb->stopped, in ucb1400_irq()
213 ucb1400_ts_event_release(ucb->ts_idev); in ucb1400_irq()
215 if (!ucb->stopped) { in ucb1400_irq()
217 ucb1400_ts_mode_int(ucb); in ucb1400_irq()
218 ucb1400_ts_irq_enable(ucb); in ucb1400_irq()
224 static void ucb1400_ts_stop(struct ucb1400_ts *ucb) in ucb1400_ts_stop() argument
227 ucb->stopped = true; in ucb1400_ts_stop()
229 wake_up(&ucb->ts_wait); in ucb1400_ts_stop()
230 disable_irq(ucb->irq); in ucb1400_ts_stop()
232 ucb1400_ts_irq_disable(ucb); in ucb1400_ts_stop()
233 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); in ucb1400_ts_stop()
237 static void ucb1400_ts_start(struct ucb1400_ts *ucb) in ucb1400_ts_start() argument
240 ucb->stopped = false; in ucb1400_ts_start()
243 ucb1400_ts_mode_int(ucb); in ucb1400_ts_start()
244 ucb1400_ts_irq_enable(ucb); in ucb1400_ts_start()
246 enable_irq(ucb->irq); in ucb1400_ts_start()
251 struct ucb1400_ts *ucb = input_get_drvdata(idev); in ucb1400_ts_open() local
253 ucb1400_ts_start(ucb); in ucb1400_ts_open()
260 struct ucb1400_ts *ucb = input_get_drvdata(idev); in ucb1400_ts_close() local
262 ucb1400_ts_stop(ucb); in ucb1400_ts_close()
273 static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb, in ucb1400_ts_detect_irq() argument
281 ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, UCB_IE_ADC); in ucb1400_ts_detect_irq()
282 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_ADC); in ucb1400_ts_detect_irq()
283 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); in ucb1400_ts_detect_irq()
284 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_ts_detect_irq()
287 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA); in ucb1400_ts_detect_irq()
288 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); in ucb1400_ts_detect_irq()
292 while (!(ucb1400_reg_read(ucb->ac97, UCB_ADC_DATA) & in ucb1400_ts_detect_irq()
301 ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, 0); in ucb1400_ts_detect_irq()
304 ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, 0); in ucb1400_ts_detect_irq()
305 ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); in ucb1400_ts_detect_irq()
306 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); in ucb1400_ts_detect_irq()
307 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); in ucb1400_ts_detect_irq()
310 ucb->irq = probe_irq_off(mask); in ucb1400_ts_detect_irq()
311 if (ucb->irq < 0 || ucb->irq == NO_IRQ) in ucb1400_ts_detect_irq()
319 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev); in ucb1400_ts_probe() local
323 ucb->ts_idev = input_allocate_device(); in ucb1400_ts_probe()
324 if (!ucb->ts_idev) { in ucb1400_ts_probe()
330 if (ucb->irq < 0) { in ucb1400_ts_probe()
331 error = ucb1400_ts_detect_irq(ucb, pdev); in ucb1400_ts_probe()
337 dev_dbg(&pdev->dev, "found IRQ %d\n", ucb->irq); in ucb1400_ts_probe()
339 init_waitqueue_head(&ucb->ts_wait); in ucb1400_ts_probe()
341 input_set_drvdata(ucb->ts_idev, ucb); in ucb1400_ts_probe()
343 ucb->ts_idev->dev.parent = &pdev->dev; in ucb1400_ts_probe()
344 ucb->ts_idev->name = "UCB1400 touchscreen interface"; in ucb1400_ts_probe()
345 ucb->ts_idev->id.vendor = ucb1400_reg_read(ucb->ac97, in ucb1400_ts_probe()
347 ucb->ts_idev->id.product = ucb->id; in ucb1400_ts_probe()
348 ucb->ts_idev->open = ucb1400_ts_open; in ucb1400_ts_probe()
349 ucb->ts_idev->close = ucb1400_ts_close; in ucb1400_ts_probe()
350 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); in ucb1400_ts_probe()
351 ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in ucb1400_ts_probe()
358 fcsr = ucb1400_reg_read(ucb->ac97, UCB_FCSR); in ucb1400_ts_probe()
359 ucb1400_reg_write(ucb->ac97, UCB_FCSR, fcsr | UCB_FCSR_AVE); in ucb1400_ts_probe()
361 ucb1400_adc_enable(ucb->ac97); in ucb1400_ts_probe()
362 x_res = ucb1400_ts_read_xres(ucb); in ucb1400_ts_probe()
363 y_res = ucb1400_ts_read_yres(ucb); in ucb1400_ts_probe()
364 ucb1400_adc_disable(ucb->ac97); in ucb1400_ts_probe()
367 input_set_abs_params(ucb->ts_idev, ABS_X, 0, x_res, 0, 0); in ucb1400_ts_probe()
368 input_set_abs_params(ucb->ts_idev, ABS_Y, 0, y_res, 0, 0); in ucb1400_ts_probe()
369 input_set_abs_params(ucb->ts_idev, ABS_PRESSURE, 0, 0, 0, 0); in ucb1400_ts_probe()
371 ucb1400_ts_stop(ucb); in ucb1400_ts_probe()
373 error = request_threaded_irq(ucb->irq, NULL, ucb1400_irq, in ucb1400_ts_probe()
375 "UCB1400", ucb); in ucb1400_ts_probe()
378 "unable to grab irq%d: %d\n", ucb->irq, error); in ucb1400_ts_probe()
382 error = input_register_device(ucb->ts_idev); in ucb1400_ts_probe()
389 free_irq(ucb->irq, ucb); in ucb1400_ts_probe()
391 input_free_device(ucb->ts_idev); in ucb1400_ts_probe()
398 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev); in ucb1400_ts_remove() local
400 free_irq(ucb->irq, ucb); in ucb1400_ts_remove()
401 input_unregister_device(ucb->ts_idev); in ucb1400_ts_remove()
408 struct ucb1400_ts *ucb = dev_get_platdata(dev); in ucb1400_ts_suspend() local
409 struct input_dev *idev = ucb->ts_idev; in ucb1400_ts_suspend()
414 ucb1400_ts_stop(ucb); in ucb1400_ts_suspend()
422 struct ucb1400_ts *ucb = dev_get_platdata(dev); in ucb1400_ts_resume() local
423 struct input_dev *idev = ucb->ts_idev; in ucb1400_ts_resume()
428 ucb1400_ts_start(ucb); in ucb1400_ts_resume()