• Home
  • Raw
  • Download

Lines Matching refs:pcap

59 static int ezx_pcap_putget(struct pcap_chip *pcap, u32 *data)  in ezx_pcap_putget()  argument
70 pcap->buf = *data; in ezx_pcap_putget()
71 t.tx_buf = (u8 *) &pcap->buf; in ezx_pcap_putget()
72 t.rx_buf = (u8 *) &pcap->buf; in ezx_pcap_putget()
73 status = spi_sync(pcap->spi, &m); in ezx_pcap_putget()
76 *data = pcap->buf; in ezx_pcap_putget()
81 int ezx_pcap_write(struct pcap_chip *pcap, u8 reg_num, u32 value) in ezx_pcap_write() argument
85 mutex_lock(&pcap->io_mutex); in ezx_pcap_write()
89 ret = ezx_pcap_putget(pcap, &value); in ezx_pcap_write()
90 mutex_unlock(&pcap->io_mutex); in ezx_pcap_write()
96 int ezx_pcap_read(struct pcap_chip *pcap, u8 reg_num, u32 *value) in ezx_pcap_read() argument
100 mutex_lock(&pcap->io_mutex); in ezx_pcap_read()
104 ret = ezx_pcap_putget(pcap, value); in ezx_pcap_read()
105 mutex_unlock(&pcap->io_mutex); in ezx_pcap_read()
111 int ezx_pcap_set_bits(struct pcap_chip *pcap, u8 reg_num, u32 mask, u32 val) in ezx_pcap_set_bits() argument
117 mutex_lock(&pcap->io_mutex); in ezx_pcap_set_bits()
118 ret = ezx_pcap_putget(pcap, &tmp); in ezx_pcap_set_bits()
126 ret = ezx_pcap_putget(pcap, &tmp); in ezx_pcap_set_bits()
128 mutex_unlock(&pcap->io_mutex); in ezx_pcap_set_bits()
135 int irq_to_pcap(struct pcap_chip *pcap, int irq) in irq_to_pcap() argument
137 return irq - pcap->irq_base; in irq_to_pcap()
141 int pcap_to_irq(struct pcap_chip *pcap, int irq) in pcap_to_irq() argument
143 return pcap->irq_base + irq; in pcap_to_irq()
149 struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); in pcap_mask_irq() local
151 pcap->msr |= 1 << irq_to_pcap(pcap, d->irq); in pcap_mask_irq()
152 queue_work(pcap->workqueue, &pcap->msr_work); in pcap_mask_irq()
157 struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); in pcap_unmask_irq() local
159 pcap->msr &= ~(1 << irq_to_pcap(pcap, d->irq)); in pcap_unmask_irq()
160 queue_work(pcap->workqueue, &pcap->msr_work); in pcap_unmask_irq()
172 struct pcap_chip *pcap = container_of(work, struct pcap_chip, msr_work); in pcap_msr_work() local
174 ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); in pcap_msr_work()
179 struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work); in pcap_isr_work() local
180 struct pcap_platform_data *pdata = pcap->spi->dev.platform_data; in pcap_isr_work()
185 ezx_pcap_read(pcap, PCAP_REG_MSR, &msr); in pcap_isr_work()
186 ezx_pcap_read(pcap, PCAP_REG_ISR, &isr); in pcap_isr_work()
190 ezx_pcap_read(pcap, PCAP_REG_INT_SEL, &int_sel); in pcap_isr_work()
194 ezx_pcap_write(pcap, PCAP_REG_MSR, isr | msr); in pcap_isr_work()
195 ezx_pcap_write(pcap, PCAP_REG_ISR, isr); in pcap_isr_work()
199 for (irq = pcap->irq_base; service; service >>= 1, irq++) { in pcap_isr_work()
204 ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); in pcap_isr_work()
210 struct pcap_chip *pcap = irq_get_handler_data(irq); in pcap_irq_handler() local
213 queue_work(pcap->workqueue, &pcap->isr_work); in pcap_irq_handler()
218 void pcap_set_ts_bits(struct pcap_chip *pcap, u32 bits) in pcap_set_ts_bits() argument
222 mutex_lock(&pcap->adc_mutex); in pcap_set_ts_bits()
223 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_set_ts_bits()
226 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_set_ts_bits()
227 mutex_unlock(&pcap->adc_mutex); in pcap_set_ts_bits()
231 static void pcap_disable_adc(struct pcap_chip *pcap) in pcap_disable_adc() argument
235 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_disable_adc()
237 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_disable_adc()
240 static void pcap_adc_trigger(struct pcap_chip *pcap) in pcap_adc_trigger() argument
245 mutex_lock(&pcap->adc_mutex); in pcap_adc_trigger()
246 head = pcap->adc_head; in pcap_adc_trigger()
247 if (!pcap->adc_queue[head]) { in pcap_adc_trigger()
249 pcap_disable_adc(pcap); in pcap_adc_trigger()
250 mutex_unlock(&pcap->adc_mutex); in pcap_adc_trigger()
254 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_adc_trigger()
256 tmp |= pcap->adc_queue[head]->flags | PCAP_ADC_ADEN; in pcap_adc_trigger()
258 if (pcap->adc_queue[head]->bank == PCAP_ADC_BANK_1) in pcap_adc_trigger()
261 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_adc_trigger()
262 mutex_unlock(&pcap->adc_mutex); in pcap_adc_trigger()
263 ezx_pcap_write(pcap, PCAP_REG_ADR, PCAP_ADR_ASC); in pcap_adc_trigger()
268 struct pcap_chip *pcap = _pcap; in pcap_adc_irq() local
273 mutex_lock(&pcap->adc_mutex); in pcap_adc_irq()
274 req = pcap->adc_queue[pcap->adc_head]; in pcap_adc_irq()
277 mutex_unlock(&pcap->adc_mutex); in pcap_adc_irq()
282 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_adc_irq()
286 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_adc_irq()
287 ezx_pcap_read(pcap, PCAP_REG_ADR, &tmp); in pcap_adc_irq()
291 pcap->adc_queue[pcap->adc_head] = NULL; in pcap_adc_irq()
292 pcap->adc_head = (pcap->adc_head + 1) & (PCAP_ADC_MAXQ - 1); in pcap_adc_irq()
293 mutex_unlock(&pcap->adc_mutex); in pcap_adc_irq()
300 pcap_adc_trigger(pcap); in pcap_adc_irq()
305 int pcap_adc_async(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[], in pcap_adc_async() argument
322 mutex_lock(&pcap->adc_mutex); in pcap_adc_async()
323 if (pcap->adc_queue[pcap->adc_tail]) { in pcap_adc_async()
324 mutex_unlock(&pcap->adc_mutex); in pcap_adc_async()
328 pcap->adc_queue[pcap->adc_tail] = req; in pcap_adc_async()
329 pcap->adc_tail = (pcap->adc_tail + 1) & (PCAP_ADC_MAXQ - 1); in pcap_adc_async()
330 mutex_unlock(&pcap->adc_mutex); in pcap_adc_async()
333 pcap_adc_trigger(pcap); in pcap_adc_async()
348 int pcap_adc_sync(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[], in pcap_adc_sync() argument
355 ret = pcap_adc_async(pcap, bank, flags, ch, pcap_adc_sync_cb, in pcap_adc_sync()
374 static int pcap_add_subdev(struct pcap_chip *pcap, in pcap_add_subdev() argument
384 pdev->dev.parent = &pcap->spi->dev; in pcap_add_subdev()
396 struct pcap_chip *pcap = spi_get_drvdata(spi); in ezx_pcap_remove() local
404 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? in ezx_pcap_remove()
406 devm_free_irq(&spi->dev, adc_irq, pcap); in ezx_pcap_remove()
407 mutex_lock(&pcap->adc_mutex); in ezx_pcap_remove()
409 kfree(pcap->adc_queue[i]); in ezx_pcap_remove()
410 mutex_unlock(&pcap->adc_mutex); in ezx_pcap_remove()
413 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_remove()
416 destroy_workqueue(pcap->workqueue); in ezx_pcap_remove()
424 struct pcap_chip *pcap; in ezx_pcap_probe() local
432 pcap = devm_kzalloc(&spi->dev, sizeof(*pcap), GFP_KERNEL); in ezx_pcap_probe()
433 if (!pcap) { in ezx_pcap_probe()
438 mutex_init(&pcap->io_mutex); in ezx_pcap_probe()
439 mutex_init(&pcap->adc_mutex); in ezx_pcap_probe()
440 INIT_WORK(&pcap->isr_work, pcap_isr_work); in ezx_pcap_probe()
441 INIT_WORK(&pcap->msr_work, pcap_msr_work); in ezx_pcap_probe()
442 spi_set_drvdata(spi, pcap); in ezx_pcap_probe()
451 pcap->spi = spi; in ezx_pcap_probe()
454 pcap->irq_base = pdata->irq_base; in ezx_pcap_probe()
455 pcap->workqueue = create_singlethread_workqueue("pcapd"); in ezx_pcap_probe()
456 if (!pcap->workqueue) { in ezx_pcap_probe()
464 ezx_pcap_write(pcap, PCAP_REG_INT_SEL, in ezx_pcap_probe()
468 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) { in ezx_pcap_probe()
470 irq_set_chip_data(i, pcap); in ezx_pcap_probe()
479 ezx_pcap_write(pcap, PCAP_REG_MSR, PCAP_MASK_ALL_INTERRUPT); in ezx_pcap_probe()
480 ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER); in ezx_pcap_probe()
481 pcap->msr = PCAP_MASK_ALL_INTERRUPT; in ezx_pcap_probe()
484 irq_set_handler_data(spi->irq, pcap); in ezx_pcap_probe()
489 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? in ezx_pcap_probe()
493 pcap); in ezx_pcap_probe()
499 ret = pcap_add_subdev(pcap, &pdata->subdevs[i]); in ezx_pcap_probe()
506 pdata->init(pcap); in ezx_pcap_probe()
513 devm_free_irq(&spi->dev, adc_irq, pcap); in ezx_pcap_probe()
515 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_probe()
518 destroy_workqueue(pcap->workqueue); in ezx_pcap_probe()