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()
197 for (irq = pcap->irq_base; service; service >>= 1, irq++) { in pcap_isr_work()
201 ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); in pcap_isr_work()
207 struct pcap_chip *pcap = irq_desc_get_handler_data(desc); in pcap_irq_handler() local
210 queue_work(pcap->workqueue, &pcap->isr_work); in pcap_irq_handler()
214 void pcap_set_ts_bits(struct pcap_chip *pcap, u32 bits) in pcap_set_ts_bits() argument
219 spin_lock_irqsave(&pcap->adc_lock, flags); in pcap_set_ts_bits()
220 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_set_ts_bits()
223 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_set_ts_bits()
224 spin_unlock_irqrestore(&pcap->adc_lock, flags); in pcap_set_ts_bits()
228 static void pcap_disable_adc(struct pcap_chip *pcap) in pcap_disable_adc() argument
232 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_disable_adc()
234 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_disable_adc()
237 static void pcap_adc_trigger(struct pcap_chip *pcap) in pcap_adc_trigger() argument
243 spin_lock_irqsave(&pcap->adc_lock, flags); in pcap_adc_trigger()
244 head = pcap->adc_head; in pcap_adc_trigger()
245 if (!pcap->adc_queue[head]) { in pcap_adc_trigger()
247 pcap_disable_adc(pcap); in pcap_adc_trigger()
248 spin_unlock_irqrestore(&pcap->adc_lock, flags); in pcap_adc_trigger()
252 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_adc_trigger()
254 tmp |= pcap->adc_queue[head]->flags | PCAP_ADC_ADEN; in pcap_adc_trigger()
256 if (pcap->adc_queue[head]->bank == PCAP_ADC_BANK_1) in pcap_adc_trigger()
259 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_adc_trigger()
260 spin_unlock_irqrestore(&pcap->adc_lock, flags); in pcap_adc_trigger()
261 ezx_pcap_write(pcap, PCAP_REG_ADR, PCAP_ADR_ASC); in pcap_adc_trigger()
266 struct pcap_chip *pcap = _pcap; in pcap_adc_irq() local
271 spin_lock(&pcap->adc_lock); in pcap_adc_irq()
272 req = pcap->adc_queue[pcap->adc_head]; in pcap_adc_irq()
275 spin_unlock(&pcap->adc_lock); in pcap_adc_irq()
280 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); in pcap_adc_irq()
284 ezx_pcap_write(pcap, PCAP_REG_ADC, tmp); in pcap_adc_irq()
285 ezx_pcap_read(pcap, PCAP_REG_ADR, &tmp); in pcap_adc_irq()
289 pcap->adc_queue[pcap->adc_head] = NULL; in pcap_adc_irq()
290 pcap->adc_head = (pcap->adc_head + 1) & (PCAP_ADC_MAXQ - 1); in pcap_adc_irq()
291 spin_unlock(&pcap->adc_lock); in pcap_adc_irq()
298 pcap_adc_trigger(pcap); in pcap_adc_irq()
303 int pcap_adc_async(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[], in pcap_adc_async() argument
321 spin_lock_irqsave(&pcap->adc_lock, irq_flags); in pcap_adc_async()
322 if (pcap->adc_queue[pcap->adc_tail]) { in pcap_adc_async()
323 spin_unlock_irqrestore(&pcap->adc_lock, irq_flags); in pcap_adc_async()
327 pcap->adc_queue[pcap->adc_tail] = req; in pcap_adc_async()
328 pcap->adc_tail = (pcap->adc_tail + 1) & (PCAP_ADC_MAXQ - 1); in pcap_adc_async()
329 spin_unlock_irqrestore(&pcap->adc_lock, irq_flags); in pcap_adc_async()
332 pcap_adc_trigger(pcap); in pcap_adc_async()
347 int pcap_adc_sync(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[], in pcap_adc_sync() argument
354 ret = pcap_adc_async(pcap, bank, flags, ch, pcap_adc_sync_cb, in pcap_adc_sync()
373 static int pcap_add_subdev(struct pcap_chip *pcap, in pcap_add_subdev() argument
383 pdev->dev.parent = &pcap->spi->dev; in pcap_add_subdev()
395 struct pcap_chip *pcap = spi_get_drvdata(spi); in ezx_pcap_remove() local
403 spin_lock_irqsave(&pcap->adc_lock, flags); in ezx_pcap_remove()
405 kfree(pcap->adc_queue[i]); in ezx_pcap_remove()
406 spin_unlock_irqrestore(&pcap->adc_lock, flags); in ezx_pcap_remove()
409 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_remove()
412 destroy_workqueue(pcap->workqueue); in ezx_pcap_remove()
418 struct pcap_chip *pcap; in ezx_pcap_probe() local
426 pcap = devm_kzalloc(&spi->dev, sizeof(*pcap), GFP_KERNEL); in ezx_pcap_probe()
427 if (!pcap) { in ezx_pcap_probe()
432 spin_lock_init(&pcap->io_lock); in ezx_pcap_probe()
433 spin_lock_init(&pcap->adc_lock); in ezx_pcap_probe()
434 INIT_WORK(&pcap->isr_work, pcap_isr_work); in ezx_pcap_probe()
435 INIT_WORK(&pcap->msr_work, pcap_msr_work); in ezx_pcap_probe()
436 spi_set_drvdata(spi, pcap); in ezx_pcap_probe()
445 pcap->spi = spi; in ezx_pcap_probe()
448 pcap->irq_base = pdata->irq_base; in ezx_pcap_probe()
449 pcap->workqueue = create_singlethread_workqueue("pcapd"); in ezx_pcap_probe()
450 if (!pcap->workqueue) { in ezx_pcap_probe()
458 ezx_pcap_write(pcap, PCAP_REG_INT_SEL, in ezx_pcap_probe()
462 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) { in ezx_pcap_probe()
464 irq_set_chip_data(i, pcap); in ezx_pcap_probe()
469 ezx_pcap_write(pcap, PCAP_REG_MSR, PCAP_MASK_ALL_INTERRUPT); in ezx_pcap_probe()
470 ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER); in ezx_pcap_probe()
471 pcap->msr = PCAP_MASK_ALL_INTERRUPT; in ezx_pcap_probe()
474 irq_set_chained_handler_and_data(spi->irq, pcap_irq_handler, pcap); in ezx_pcap_probe()
478 adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? in ezx_pcap_probe()
482 pcap); in ezx_pcap_probe()
488 ret = pcap_add_subdev(pcap, &pdata->subdevs[i]); in ezx_pcap_probe()
495 pdata->init(pcap); in ezx_pcap_probe()
502 for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) in ezx_pcap_probe()
505 destroy_workqueue(pcap->workqueue); in ezx_pcap_probe()