Lines Matching refs:pcap
55 static int ezx_pcap_putget(struct pcap_chip *pcap, u32 *data) in ezx_pcap_putget() argument
66 pcap->buf = *data; in ezx_pcap_putget()
67 t.tx_buf = (u8 *) &pcap->buf; in ezx_pcap_putget()
68 t.rx_buf = (u8 *) &pcap->buf; in ezx_pcap_putget()
69 status = spi_sync(pcap->spi, &m); in ezx_pcap_putget()
72 *data = pcap->buf; in ezx_pcap_putget()
77 int ezx_pcap_write(struct pcap_chip *pcap, u8 reg_num, u32 value) in ezx_pcap_write() argument
82 spin_lock_irqsave(&pcap->io_lock, flags); in ezx_pcap_write()
86 ret = ezx_pcap_putget(pcap, &value); in ezx_pcap_write()
87 spin_unlock_irqrestore(&pcap->io_lock, flags); in ezx_pcap_write()
93 int ezx_pcap_read(struct pcap_chip *pcap, u8 reg_num, u32 *value) in ezx_pcap_read() argument
98 spin_lock_irqsave(&pcap->io_lock, flags); in ezx_pcap_read()
102 ret = ezx_pcap_putget(pcap, value); in ezx_pcap_read()
103 spin_unlock_irqrestore(&pcap->io_lock, flags); in ezx_pcap_read()
109 int ezx_pcap_set_bits(struct pcap_chip *pcap, u8 reg_num, u32 mask, u32 val) in ezx_pcap_set_bits() argument
116 spin_lock_irqsave(&pcap->io_lock, flags); in ezx_pcap_set_bits()
117 ret = ezx_pcap_putget(pcap, &tmp); in ezx_pcap_set_bits()
125 ret = ezx_pcap_putget(pcap, &tmp); in ezx_pcap_set_bits()
127 spin_unlock_irqrestore(&pcap->io_lock, flags); in ezx_pcap_set_bits()
134 int irq_to_pcap(struct pcap_chip *pcap, int irq) in irq_to_pcap() argument
136 return irq - pcap->irq_base; in irq_to_pcap()
140 int pcap_to_irq(struct pcap_chip *pcap, int irq) in pcap_to_irq() argument
142 return pcap->irq_base + irq; in pcap_to_irq()
148 struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); in pcap_mask_irq() local
150 pcap->msr |= 1 << irq_to_pcap(pcap, d->irq); in pcap_mask_irq()
151 queue_work(pcap->workqueue, &pcap->msr_work); in pcap_mask_irq()
156 struct pcap_chip *pcap = irq_data_get_irq_chip_data(d); in pcap_unmask_irq() local
158 pcap->msr &= ~(1 << irq_to_pcap(pcap, d->irq)); in pcap_unmask_irq()
159 queue_work(pcap->workqueue, &pcap->msr_work); in pcap_unmask_irq()
171 struct pcap_chip *pcap = container_of(work, struct pcap_chip, msr_work); in pcap_msr_work() local
173 ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); in pcap_msr_work()
178 struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work); in pcap_isr_work() local
179 struct pcap_platform_data *pdata = dev_get_platdata(&pcap->spi->dev); in pcap_isr_work()
184 ezx_pcap_read(pcap, PCAP_REG_MSR, &msr); in pcap_isr_work()
185 ezx_pcap_read(pcap, PCAP_REG_ISR, &isr); in pcap_isr_work()
189 ezx_pcap_read(pcap, PCAP_REG_INT_SEL, &int_sel); in pcap_isr_work()
193 ezx_pcap_write(pcap, PCAP_REG_MSR, isr | msr); in pcap_isr_work()
194 ezx_pcap_write(pcap, PCAP_REG_ISR, isr); in pcap_isr_work()
198 for (irq = pcap->irq_base; service; service >>= 1, irq++) { in pcap_isr_work()
203 ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); in pcap_isr_work()
209 struct pcap_chip *pcap = irq_desc_get_handler_data(desc); in pcap_irq_handler() local
212 queue_work(pcap->workqueue, &pcap->isr_work); in pcap_irq_handler()
216 void pcap_set_ts_bits(struct pcap_chip *pcap, u32 bits) in pcap_set_ts_bits() argument
221 spin_lock_irqsave(&pcap->adc_lock, flags); in pcap_set_ts_bits()
222 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_set_ts_bits()
225 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_set_ts_bits()
226 spin_unlock_irqrestore(&pcap->adc_lock, flags); in pcap_set_ts_bits()
230 static void pcap_disable_adc(struct pcap_chip *pcap) in pcap_disable_adc() argument
234 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_disable_adc()
236 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_disable_adc()
239 static void pcap_adc_trigger(struct pcap_chip *pcap) in pcap_adc_trigger() argument
245 spin_lock_irqsave(&pcap->adc_lock, flags); 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 spin_unlock_irqrestore(&pcap->adc_lock, flags); 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 spin_unlock_irqrestore(&pcap->adc_lock, flags); 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 spin_lock(&pcap->adc_lock); in pcap_adc_irq()
274 req = pcap->adc_queue[pcap->adc_head]; in pcap_adc_irq()
277 spin_unlock(&pcap->adc_lock); 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 spin_unlock(&pcap->adc_lock); 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
323 spin_lock_irqsave(&pcap->adc_lock, irq_flags); in pcap_adc_async()
324 if (pcap->adc_queue[pcap->adc_tail]) { in pcap_adc_async()
325 spin_unlock_irqrestore(&pcap->adc_lock, irq_flags); in pcap_adc_async()
329 pcap->adc_queue[pcap->adc_tail] = req; in pcap_adc_async()
330 pcap->adc_tail = (pcap->adc_tail + 1) & (PCAP_ADC_MAXQ - 1); in pcap_adc_async()
331 spin_unlock_irqrestore(&pcap->adc_lock, irq_flags); in pcap_adc_async()
334 pcap_adc_trigger(pcap); in pcap_adc_async()
349 int pcap_adc_sync(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[], in pcap_adc_sync() argument
356 ret = pcap_adc_async(pcap, bank, flags, ch, pcap_adc_sync_cb, in pcap_adc_sync()
375 static int pcap_add_subdev(struct pcap_chip *pcap, in pcap_add_subdev() argument
385 pdev->dev.parent = &pcap->spi->dev; in pcap_add_subdev()
397 struct pcap_chip *pcap = spi_get_drvdata(spi); in ezx_pcap_remove() local
405 spin_lock_irqsave(&pcap->adc_lock, flags); in ezx_pcap_remove()
407 kfree(pcap->adc_queue[i]); in ezx_pcap_remove()
408 spin_unlock_irqrestore(&pcap->adc_lock, flags); in ezx_pcap_remove()
411 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_remove()
414 destroy_workqueue(pcap->workqueue); in ezx_pcap_remove()
422 struct pcap_chip *pcap; in ezx_pcap_probe() local
430 pcap = devm_kzalloc(&spi->dev, sizeof(*pcap), GFP_KERNEL); in ezx_pcap_probe()
431 if (!pcap) { in ezx_pcap_probe()
436 spin_lock_init(&pcap->io_lock); in ezx_pcap_probe()
437 spin_lock_init(&pcap->adc_lock); in ezx_pcap_probe()
438 INIT_WORK(&pcap->isr_work, pcap_isr_work); in ezx_pcap_probe()
439 INIT_WORK(&pcap->msr_work, pcap_msr_work); in ezx_pcap_probe()
440 spi_set_drvdata(spi, pcap); in ezx_pcap_probe()
449 pcap->spi = spi; in ezx_pcap_probe()
452 pcap->irq_base = pdata->irq_base; in ezx_pcap_probe()
453 pcap->workqueue = create_singlethread_workqueue("pcapd"); in ezx_pcap_probe()
454 if (!pcap->workqueue) { in ezx_pcap_probe()
462 ezx_pcap_write(pcap, PCAP_REG_INT_SEL, in ezx_pcap_probe()
466 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) { in ezx_pcap_probe()
468 irq_set_chip_data(i, pcap); in ezx_pcap_probe()
473 ezx_pcap_write(pcap, PCAP_REG_MSR, PCAP_MASK_ALL_INTERRUPT); in ezx_pcap_probe()
474 ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER); in ezx_pcap_probe()
475 pcap->msr = PCAP_MASK_ALL_INTERRUPT; in ezx_pcap_probe()
478 irq_set_chained_handler_and_data(spi->irq, pcap_irq_handler, pcap); in ezx_pcap_probe()
482 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? in ezx_pcap_probe()
486 pcap); in ezx_pcap_probe()
492 ret = pcap_add_subdev(pcap, &pdata->subdevs[i]); in ezx_pcap_probe()
499 pdata->init(pcap); in ezx_pcap_probe()
506 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_probe()
509 destroy_workqueue(pcap->workqueue); in ezx_pcap_probe()