Lines Matching refs:port

177 static inline int sync_data_avail(struct sync_port *port);
202 static void start_dma_out(struct sync_port *port, const char *data, int count);
203 static void start_dma_in(struct sync_port *port);
208 static void send_word(struct sync_port *port);
311 static void sync_serial_start_port(struct sync_port *port) in sync_serial_start_port() argument
313 reg_sser_rw_cfg cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_start_port()
315 REG_RD(sser, port->regi_sser, rw_tr_cfg); in sync_serial_start_port()
317 REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_start_port()
321 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in sync_serial_start_port()
322 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in sync_serial_start_port()
323 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_start_port()
324 port->started = 1; in sync_serial_start_port()
329 struct sync_port *port = &ports[portnbr]; in initialize_port() local
337 port->port_nbr = portnbr; in initialize_port()
338 port->init_irqs = no_irq_setup; in initialize_port()
340 port->out_rd_ptr = port->out_buffer; in initialize_port()
341 port->out_buf_count = 0; in initialize_port()
343 port->output = 1; in initialize_port()
344 port->input = 0; in initialize_port()
346 port->readp = port->flip; in initialize_port()
347 port->writep = port->flip; in initialize_port()
348 port->in_buffer_size = IN_BUFFER_SIZE; in initialize_port()
349 port->in_buffer_len = 0; in initialize_port()
350 port->inbufchunk = IN_DESCR_SIZE; in initialize_port()
352 port->read_ts_idx = 0; in initialize_port()
353 port->write_ts_idx = 0; in initialize_port()
355 init_waitqueue_head(&port->out_wait_q); in initialize_port()
356 init_waitqueue_head(&port->in_wait_q); in initialize_port()
358 spin_lock_init(&port->lock); in initialize_port()
367 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in initialize_port()
377 REG_WR(sser, port->regi_sser, rw_frm_cfg, frm_cfg); in initialize_port()
382 tr_cfg.use_dma = port->use_dma ? regk_sser_yes : regk_sser_no; in initialize_port()
391 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in initialize_port()
395 rec_cfg.use_dma = port->use_dma ? regk_sser_yes : regk_sser_no; in initialize_port()
397 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in initialize_port()
404 dma_descr_data *descr = &port->out_descr[i]; in initialize_port()
415 port->out_descr[NBR_OUT_DESCR-1].next = in initialize_port()
416 (dma_descr_data *)virt_to_phys(&port->out_descr[0]); in initialize_port()
419 port->active_tr_descr = &port->out_descr[0]; in initialize_port()
420 port->prev_tr_descr = &port->out_descr[NBR_OUT_DESCR-1]; in initialize_port()
421 port->catch_tr_descr = &port->out_descr[0]; in initialize_port()
425 static inline int sync_data_avail(struct sync_port *port) in sync_data_avail() argument
427 return port->in_buffer_len; in sync_data_avail()
434 struct sync_port *port; in sync_serial_open() local
446 port = &ports[dev]; in sync_serial_open()
448 if (port->busy == 2) { in sync_serial_open()
456 port->readp = port->writep = port->flip; in sync_serial_open()
457 port->in_buffer_len = 0; in sync_serial_open()
458 port->read_ts_idx = 0; in sync_serial_open()
459 port->write_ts_idx = 0; in sync_serial_open()
461 if (port->init_irqs != no_irq_setup) { in sync_serial_open()
463 port->busy++; in sync_serial_open()
467 if (port->use_dma) { in sync_serial_open()
473 if (request_irq(port->dma_out_intr_vect, tr_interrupt, 0, in sync_serial_open()
474 tmp, port)) { in sync_serial_open()
479 if (artpec_request_dma(port->dma_out_nbr, tmp, in sync_serial_open()
480 DMA_VERBOSE_ON_ERROR, 0, port->req_dma)) { in sync_serial_open()
481 free_irq(port->dma_out_intr_vect, port); in sync_serial_open()
487 if (request_irq(port->dma_in_intr_vect, rx_interrupt, 0, in sync_serial_open()
488 tmp, port)) { in sync_serial_open()
489 artpec_free_dma(port->dma_out_nbr); in sync_serial_open()
490 free_irq(port->dma_out_intr_vect, port); in sync_serial_open()
495 if (artpec_request_dma(port->dma_in_nbr, tmp, in sync_serial_open()
496 DMA_VERBOSE_ON_ERROR, 0, port->req_dma)) { in sync_serial_open()
497 artpec_free_dma(port->dma_out_nbr); in sync_serial_open()
498 free_irq(port->dma_out_intr_vect, port); in sync_serial_open()
499 free_irq(port->dma_in_intr_vect, port); in sync_serial_open()
505 REG_WR(dma, port->regi_dmain, rw_cfg, cfg); in sync_serial_open()
506 REG_WR(dma, port->regi_dmaout, rw_cfg, cfg); in sync_serial_open()
508 REG_WR(dma, port->regi_dmain, rw_intr_mask, intr_mask); in sync_serial_open()
509 REG_WR(dma, port->regi_dmaout, rw_intr_mask, intr_mask); in sync_serial_open()
511 DMA_WR_CMD(port->regi_dmain, regk_dma_set_w_size1); in sync_serial_open()
512 DMA_WR_CMD(port->regi_dmaout, regk_dma_set_w_size1); in sync_serial_open()
514 start_dma_in(port); in sync_serial_open()
515 port->init_irqs = dma_irq_setup; in sync_serial_open()
521 if (request_irq(port->syncser_intr_vect, manual_interrupt, in sync_serial_open()
522 0, tmp, port)) { in sync_serial_open()
528 port->init_irqs = manual_irq_setup; in sync_serial_open()
533 port->busy++; in sync_serial_open()
544 struct sync_port *port; in sync_serial_release() local
550 port = &ports[dev]; in sync_serial_release()
551 if (port->busy) in sync_serial_release()
552 port->busy--; in sync_serial_release()
553 if (!port->busy) in sync_serial_release()
562 struct sync_port *port; in sync_serial_poll() local
567 port = &ports[dev]; in sync_serial_poll()
569 if (!port->started) in sync_serial_poll()
570 sync_serial_start_port(port); in sync_serial_poll()
572 poll_wait(file, &port->out_wait_q, wait); in sync_serial_poll()
573 poll_wait(file, &port->in_wait_q, wait); in sync_serial_poll()
576 if (port->output && !port->tr_running) in sync_serial_poll()
580 if (port->output && in sync_serial_poll()
581 port->active_tr_descr != port->catch_tr_descr && in sync_serial_poll()
582 port->out_buf_count < OUT_BUFFER_SIZE) in sync_serial_poll()
586 if (port->input && sync_data_avail(port) >= port->inbufchunk) in sync_serial_poll()
609 struct sync_port *port; in __sync_serial_read() local
617 port = &ports[dev]; in __sync_serial_read()
619 if (!port->started) in __sync_serial_read()
620 sync_serial_start_port(port); in __sync_serial_read()
624 spin_lock_irqsave(&port->lock, flags); in __sync_serial_read()
625 start = port->readp; in __sync_serial_read()
626 end = port->writep; in __sync_serial_read()
627 spin_unlock_irqrestore(&port->lock, flags); in __sync_serial_read()
629 while ((start == end) && !port->in_buffer_len) { in __sync_serial_read()
633 wait_event_interruptible(port->in_wait_q, in __sync_serial_read()
634 !(start == end && !port->full)); in __sync_serial_read()
639 spin_lock_irqsave(&port->lock, flags); in __sync_serial_read()
640 start = port->readp; in __sync_serial_read()
641 end = port->writep; in __sync_serial_read()
642 spin_unlock_irqrestore(&port->lock, flags); in __sync_serial_read()
647 start - port->flip, end - port->flip, in __sync_serial_read()
648 port->in_buffer_size)); in __sync_serial_read()
654 avail = port->flip + port->in_buffer_size - start; in __sync_serial_read()
667 int idx = port->read_ts_idx; in __sync_serial_read()
668 memcpy(ts, &port->timestamp[idx], sizeof(struct timespec)); in __sync_serial_read()
669 port->read_ts_idx += count / IN_DESCR_SIZE; in __sync_serial_read()
670 if (port->read_ts_idx >= NBR_IN_DESCR) in __sync_serial_read()
671 port->read_ts_idx = 0; in __sync_serial_read()
674 spin_lock_irqsave(&port->lock, flags); in __sync_serial_read()
675 port->readp += count; in __sync_serial_read()
677 if (port->readp >= port->flip + port->in_buffer_size) in __sync_serial_read()
678 port->readp = port->flip; in __sync_serial_read()
679 port->in_buffer_len -= count; in __sync_serial_read()
680 port->full = 0; in __sync_serial_read()
681 spin_unlock_irqrestore(&port->lock, flags); in __sync_serial_read()
742 struct sync_port *port; in sync_serial_ioctl_unlocked() local
757 port = &ports[dev]; in sync_serial_ioctl_unlocked()
758 spin_lock_irq(&port->lock); in sync_serial_ioctl_unlocked()
760 tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in sync_serial_ioctl_unlocked()
761 rec_cfg = REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_ioctl_unlocked()
762 frm_cfg = REG_RD(sser, port->regi_sser, rw_frm_cfg); in sync_serial_ioctl_unlocked()
763 gen_cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_ioctl_unlocked()
764 intr_mask = REG_RD(sser, port->regi_sser, rw_intr_mask); in sync_serial_ioctl_unlocked()
802 spin_unlock_irq(&port->lock); in sync_serial_ioctl_unlocked()
863 port->output = 1; in sync_serial_ioctl_unlocked()
864 port->input = 0; in sync_serial_ioctl_unlocked()
870 port->output = 1; in sync_serial_ioctl_unlocked()
871 port->input = 0; in sync_serial_ioctl_unlocked()
876 port->output = 0; in sync_serial_ioctl_unlocked()
877 port->input = 1; in sync_serial_ioctl_unlocked()
883 port->output = 0; in sync_serial_ioctl_unlocked()
884 port->input = 1; in sync_serial_ioctl_unlocked()
889 port->output = 1; in sync_serial_ioctl_unlocked()
890 port->input = 1; in sync_serial_ioctl_unlocked()
896 port->output = 1; in sync_serial_ioctl_unlocked()
897 port->input = 1; in sync_serial_ioctl_unlocked()
902 spin_unlock_irq(&port->lock); in sync_serial_ioctl_unlocked()
905 if (!port->use_dma || arg == MASTER_OUTPUT || in sync_serial_ioctl_unlocked()
1013 port->input = 1; in sync_serial_ioctl_unlocked()
1014 port->output = 0; in sync_serial_ioctl_unlocked()
1017 port->input = 0; in sync_serial_ioctl_unlocked()
1018 port->output = 1; in sync_serial_ioctl_unlocked()
1029 if (port->started) { in sync_serial_ioctl_unlocked()
1030 rec_cfg.rec_en = port->input; in sync_serial_ioctl_unlocked()
1031 gen_cfg.en = (port->output | port->input); in sync_serial_ioctl_unlocked()
1034 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in sync_serial_ioctl_unlocked()
1035 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_ioctl_unlocked()
1036 REG_WR(sser, port->regi_sser, rw_frm_cfg, frm_cfg); in sync_serial_ioctl_unlocked()
1037 REG_WR(sser, port->regi_sser, rw_intr_mask, intr_mask); in sync_serial_ioctl_unlocked()
1038 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl_unlocked()
1045 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl_unlocked()
1047 DMA_WR_CMD(port->regi_dmain, dma_w_size); in sync_serial_ioctl_unlocked()
1048 DMA_WR_CMD(port->regi_dmaout, dma_w_size); in sync_serial_ioctl_unlocked()
1050 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl_unlocked()
1053 spin_unlock_irq(&port->lock); in sync_serial_ioctl_unlocked()
1075 struct sync_port *port; in sync_serial_write() local
1089 port = &ports[dev]; in sync_serial_write()
1100 port->port_nbr, count, port->active_tr_descr, in sync_serial_write()
1101 port->catch_tr_descr)); in sync_serial_write()
1104 spin_lock_irqsave(&port->lock, flags); in sync_serial_write()
1105 rd_ptr = port->out_rd_ptr; in sync_serial_write()
1106 out_buf_count = port->out_buf_count; in sync_serial_write()
1107 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_write()
1110 if (port->tr_running && in sync_serial_write()
1111 ((port->use_dma && port->active_tr_descr == port->catch_tr_descr) || in sync_serial_write()
1117 buf_stop_ptr = port->out_buffer + OUT_BUFFER_SIZE; in sync_serial_write()
1138 port->out_buf_count, port->out_buffer, in sync_serial_write()
1142 if (!port->started) { in sync_serial_write()
1143 reg_sser_rw_cfg cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_write()
1145 REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_write()
1147 rec_cfg.rec_en = port->input; in sync_serial_write()
1148 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in sync_serial_write()
1149 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_write()
1150 port->started = 1; in sync_serial_write()
1155 add_wait_queue(&port->out_wait_q, &wait); in sync_serial_write()
1159 spin_lock_irqsave(&port->lock, flags); in sync_serial_write()
1160 port->out_buf_count += trunc_count; in sync_serial_write()
1161 if (port->use_dma) { in sync_serial_write()
1163 start_dma_out(port, wr_ptr, trunc_count); in sync_serial_write()
1165 } else if (!port->tr_running) { in sync_serial_write()
1168 intr_mask = REG_RD(sser, port->regi_sser, rw_intr_mask); in sync_serial_write()
1170 send_word(port); in sync_serial_write()
1173 REG_WR(sser, port->regi_sser, rw_intr_mask, intr_mask); in sync_serial_write()
1176 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_write()
1181 port->port_nbr, trunc_count, in sync_serial_write()
1182 REG_RD_INT(dma, port->regi_dmaout, r_intr))); in sync_serial_write()
1187 remove_wait_queue(&port->out_wait_q, &wait); in sync_serial_write()
1192 DEBUGWRITE(pr_info("w d%d c %u\n", port->port_nbr, trunc_count)); in sync_serial_write()
1203 static void send_word(struct sync_port *port) in send_word() argument
1205 reg_sser_rw_tr_cfg tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in send_word()
1210 port->out_buf_count--; in send_word()
1211 tr_data.data = *port->out_rd_ptr++; in send_word()
1212 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1213 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1214 port->out_rd_ptr = port->out_buffer; in send_word()
1218 int data = (*port->out_rd_ptr++) << 8; in send_word()
1219 data |= *port->out_rd_ptr++; in send_word()
1220 port->out_buf_count -= 2; in send_word()
1222 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1223 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1224 port->out_rd_ptr = port->out_buffer; in send_word()
1228 port->out_buf_count -= 2; in send_word()
1229 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1230 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1231 port->out_rd_ptr += 2; in send_word()
1232 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1233 port->out_rd_ptr = port->out_buffer; in send_word()
1236 port->out_buf_count -= 3; in send_word()
1237 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1238 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1239 port->out_rd_ptr += 2; in send_word()
1240 tr_data.data = *port->out_rd_ptr++; in send_word()
1241 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1242 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1243 port->out_rd_ptr = port->out_buffer; in send_word()
1246 port->out_buf_count -= 4; in send_word()
1247 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1248 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1249 port->out_rd_ptr += 2; in send_word()
1250 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1251 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1252 port->out_rd_ptr += 2; in send_word()
1253 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1254 port->out_rd_ptr = port->out_buffer; in send_word()
1261 static void start_dma_out(struct sync_port *port, const char *data, int count) in start_dma_out() argument
1263 port->active_tr_descr->buf = (char *)virt_to_phys((char *)data); in start_dma_out()
1264 port->active_tr_descr->after = port->active_tr_descr->buf + count; in start_dma_out()
1265 port->active_tr_descr->intr = 1; in start_dma_out()
1267 port->active_tr_descr->eol = 1; in start_dma_out()
1268 port->prev_tr_descr->eol = 0; in start_dma_out()
1271 port->prev_tr_descr, port->active_tr_descr)); in start_dma_out()
1272 port->prev_tr_descr = port->active_tr_descr; in start_dma_out()
1273 port->active_tr_descr = phys_to_virt((int)port->active_tr_descr->next); in start_dma_out()
1275 if (!port->tr_running) { in start_dma_out()
1276 reg_sser_rw_tr_cfg tr_cfg = REG_RD(sser, port->regi_sser, in start_dma_out()
1279 port->out_context.next = NULL; in start_dma_out()
1280 port->out_context.saved_data = in start_dma_out()
1281 (dma_descr_data *)virt_to_phys(port->prev_tr_descr); in start_dma_out()
1282 port->out_context.saved_data_buf = port->prev_tr_descr->buf; in start_dma_out()
1284 DMA_START_CONTEXT(port->regi_dmaout, in start_dma_out()
1285 virt_to_phys((char *)&port->out_context)); in start_dma_out()
1288 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in start_dma_out()
1291 DMA_CONTINUE_DATA(port->regi_dmaout); in start_dma_out()
1295 port->tr_running = 1; in start_dma_out()
1298 static void start_dma_in(struct sync_port *port) in start_dma_in() argument
1303 spin_lock_irqsave(&port->lock, flags); in start_dma_in()
1304 port->writep = port->flip; in start_dma_in()
1305 spin_unlock_irqrestore(&port->lock, flags); in start_dma_in()
1307 buf = (char *)virt_to_phys(port->in_buffer); in start_dma_in()
1309 port->in_descr[i].buf = buf; in start_dma_in()
1310 port->in_descr[i].after = buf + port->inbufchunk; in start_dma_in()
1311 port->in_descr[i].intr = 1; in start_dma_in()
1312 port->in_descr[i].next = in start_dma_in()
1313 (dma_descr_data *)virt_to_phys(&port->in_descr[i+1]); in start_dma_in()
1314 port->in_descr[i].buf = buf; in start_dma_in()
1315 buf += port->inbufchunk; in start_dma_in()
1318 port->in_descr[i-1].next = in start_dma_in()
1319 (dma_descr_data *)virt_to_phys(&port->in_descr[0]); in start_dma_in()
1320 port->in_descr[i-1].eol = regk_sser_yes; in start_dma_in()
1321 port->next_rx_desc = &port->in_descr[0]; in start_dma_in()
1322 port->prev_rx_desc = &port->in_descr[NBR_IN_DESCR - 1]; in start_dma_in()
1323 port->in_context.saved_data = in start_dma_in()
1324 (dma_descr_data *)virt_to_phys(&port->in_descr[0]); in start_dma_in()
1325 port->in_context.saved_data_buf = port->in_descr[0].buf; in start_dma_in()
1326 DMA_START_CONTEXT(port->regi_dmain, virt_to_phys(&port->in_context)); in start_dma_in()
1339 struct sync_port *port = &ports[i]; in tr_interrupt() local
1340 if (!port->enabled || !port->use_dma) in tr_interrupt()
1344 masked = REG_RD(dma, port->regi_dmaout, r_masked_intr); in tr_interrupt()
1351 stat = REG_RD(dma, port->regi_dmaout, rw_stat); in tr_interrupt()
1356 REG_WR(dma, port->regi_dmaout, rw_ack_intr, ack_intr); in tr_interrupt()
1363 sent = port->catch_tr_descr->after - in tr_interrupt()
1364 port->catch_tr_descr->buf; in tr_interrupt()
1367 port->out_buf_count, sent, in tr_interrupt()
1368 port->out_buf_count - sent, in tr_interrupt()
1369 port->catch_tr_descr, in tr_interrupt()
1370 port->active_tr_descr);); in tr_interrupt()
1371 port->out_buf_count -= sent; in tr_interrupt()
1372 port->catch_tr_descr = in tr_interrupt()
1373 phys_to_virt((int) port->catch_tr_descr->next); in tr_interrupt()
1374 port->out_rd_ptr = in tr_interrupt()
1375 phys_to_virt((int) port->catch_tr_descr->buf); in tr_interrupt()
1387 while (!port->catch_tr_descr->eol) { in tr_interrupt()
1388 sent = port->catch_tr_descr->after - in tr_interrupt()
1389 port->catch_tr_descr->buf; in tr_interrupt()
1392 port->catch_tr_descr, in tr_interrupt()
1394 port->out_buf_count)); in tr_interrupt()
1395 port->out_buf_count -= sent; in tr_interrupt()
1396 port->catch_tr_descr = phys_to_virt( in tr_interrupt()
1397 (int)port->catch_tr_descr->next); in tr_interrupt()
1404 sent = port->catch_tr_descr->after - in tr_interrupt()
1405 port->catch_tr_descr->buf; in tr_interrupt()
1407 port->catch_tr_descr, in tr_interrupt()
1409 port->out_buf_count)); in tr_interrupt()
1411 port->out_buf_count -= sent; in tr_interrupt()
1415 port->out_rd_ptr = in tr_interrupt()
1416 phys_to_virt((int) port->catch_tr_descr->after); in tr_interrupt()
1417 if (port->out_rd_ptr > port->out_buffer + in tr_interrupt()
1419 port->out_rd_ptr = port->out_buffer; in tr_interrupt()
1421 tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in tr_interrupt()
1424 port->out_buf_count, in tr_interrupt()
1425 port->active_tr_descr)); in tr_interrupt()
1426 if (port->out_buf_count != 0) in tr_interrupt()
1428 port->catch_tr_descr = port->active_tr_descr; in tr_interrupt()
1429 port->tr_running = 0; in tr_interrupt()
1431 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in tr_interrupt()
1434 wake_up_interruptible(&port->out_wait_q); in tr_interrupt()
1440 static inline void handle_rx_packet(struct sync_port *port) in handle_rx_packet() argument
1447 spin_lock_irqsave(&port->lock, flags); in handle_rx_packet()
1453 if ((port->writep + port->inbufchunk <= in handle_rx_packet()
1454 port->flip + port->in_buffer_size) && in handle_rx_packet()
1455 (port->in_buffer_len + port->inbufchunk < IN_BUFFER_SIZE)) { in handle_rx_packet()
1456 memcpy(port->writep, in handle_rx_packet()
1457 phys_to_virt((unsigned)port->next_rx_desc->buf), in handle_rx_packet()
1458 port->inbufchunk); in handle_rx_packet()
1459 port->writep += port->inbufchunk; in handle_rx_packet()
1460 if (port->writep >= port->flip + port->in_buffer_size) in handle_rx_packet()
1461 port->writep = port->flip; in handle_rx_packet()
1464 if (port->write_ts_idx == NBR_IN_DESCR) in handle_rx_packet()
1465 port->write_ts_idx = 0; in handle_rx_packet()
1466 idx = port->write_ts_idx++; in handle_rx_packet()
1467 do_posix_clock_monotonic_gettime(&port->timestamp[idx]); in handle_rx_packet()
1468 port->in_buffer_len += port->inbufchunk; in handle_rx_packet()
1470 spin_unlock_irqrestore(&port->lock, flags); in handle_rx_packet()
1472 port->next_rx_desc->eol = 1; in handle_rx_packet()
1473 port->prev_rx_desc->eol = 0; in handle_rx_packet()
1475 flush_dma_descr(port->prev_rx_desc, 0); in handle_rx_packet()
1476 port->prev_rx_desc = port->next_rx_desc; in handle_rx_packet()
1477 port->next_rx_desc = phys_to_virt((unsigned)port->next_rx_desc->next); in handle_rx_packet()
1479 flush_dma_descr(port->prev_rx_desc, 1); in handle_rx_packet()
1481 wake_up_interruptible(&port->in_wait_q); in handle_rx_packet()
1482 DMA_CONTINUE(port->regi_dmain); in handle_rx_packet()
1483 REG_WR(dma, port->regi_dmain, rw_ack_intr, ack_intr); in handle_rx_packet()
1497 struct sync_port *port = &ports[i]; in rx_interrupt() local
1499 if (!port->enabled || !port->use_dma) in rx_interrupt()
1502 masked = REG_RD(dma, port->regi_dmain, r_masked_intr); in rx_interrupt()
1509 while (REG_RD(dma, port->regi_dmain, rw_data) != in rx_interrupt()
1510 virt_to_phys(port->next_rx_desc)) in rx_interrupt()
1511 handle_rx_packet(port); in rx_interrupt()
1526 struct sync_port *port = &ports[i]; in manual_interrupt() local
1528 if (!port->enabled || port->use_dma) in manual_interrupt()
1531 masked = REG_RD(sser, port->regi_sser, r_masked_intr); in manual_interrupt()
1535 REG_RD(sser, port->regi_sser, rw_rec_cfg); in manual_interrupt()
1537 port->regi_sser, r_rec_data); in manual_interrupt()
1540 spin_lock_irqsave(&port->lock, flags); in manual_interrupt()
1543 *port->writep++ = data.data & 0xff; in manual_interrupt()
1546 *port->writep = (data.data & 0x0ff0) >> 4; in manual_interrupt()
1547 *(port->writep + 1) = data.data & 0x0f; in manual_interrupt()
1548 port->writep += 2; in manual_interrupt()
1551 *(unsigned short *)port->writep = data.data; in manual_interrupt()
1552 port->writep += 2; in manual_interrupt()
1555 *(unsigned int *)port->writep = data.data; in manual_interrupt()
1556 port->writep += 3; in manual_interrupt()
1559 *(unsigned int *)port->writep = data.data; in manual_interrupt()
1560 port->writep += 4; in manual_interrupt()
1565 if (port->writep >= port->flip + port->in_buffer_size) in manual_interrupt()
1566 port->writep = port->flip; in manual_interrupt()
1567 if (port->writep == port->readp) { in manual_interrupt()
1569 port->readp++; in manual_interrupt()
1571 if (port->readp >= port->flip + in manual_interrupt()
1572 port->in_buffer_size) in manual_interrupt()
1573 port->readp = port->flip; in manual_interrupt()
1575 spin_unlock_irqrestore(&port->lock, flags); in manual_interrupt()
1576 if (sync_data_avail(port) >= port->inbufchunk) in manual_interrupt()
1578 wake_up_interruptible(&port->in_wait_q); in manual_interrupt()
1585 if (port->out_buf_count > 0) in manual_interrupt()
1586 send_word(port); in manual_interrupt()
1590 intr_mask = REG_RD(sser, port->regi_sser, in manual_interrupt()
1593 REG_WR(sser, port->regi_sser, in manual_interrupt()
1596 wake_up_interruptible(&port->out_wait_q); in manual_interrupt()
1687 struct sync_port *port = &ports[i]; in etrax_sync_serial_exit() local
1688 if (port->init_irqs == dma_irq_setup) { in etrax_sync_serial_exit()
1691 artpec_free_dma(port->dma_in_nbr); in etrax_sync_serial_exit()
1692 artpec_free_dma(port->dma_out_nbr); in etrax_sync_serial_exit()
1693 free_irq(port->dma_out_intr_vect, port); in etrax_sync_serial_exit()
1694 free_irq(port->dma_in_intr_vect, port); in etrax_sync_serial_exit()
1696 } else if (port->init_irqs == manual_irq_setup) { in etrax_sync_serial_exit()
1698 free_irq(port->syncser_intr_vect, port); in etrax_sync_serial_exit()