Lines Matching full:port
2 * Simple synchronous serial port driver for ETRAX FS and Artpec-3.
39 /* responsible for port->bufchunk of a common buffer. */
93 char started; /* 1 if port has been started */
94 char port_nbr; /* Port 0 or 1 */
95 char busy; /* 1 if port is busy */
97 char enabled; /* 1 if port is enabled */
98 char use_dma; /* 1 if port uses dma */
151 static inline int sync_data_avail(struct sync_port *port);
171 static void send_word(sync_port* port);
172 static void start_dma_out(struct sync_port *port, const char *data, int count);
173 static void start_dma_in(sync_port* port);
264 "Unable to get major for synchronous serial port\n"); in etrax_sync_serial_init()
272 "Unable to alloc pins for synchronous serial port 0\n"); in etrax_sync_serial_init()
282 "Unable to alloc pins for synchronous serial port 0\n"); in etrax_sync_serial_init()
290 printk(KERN_INFO "ETRAX FS synchronous serial port driver\n"); in etrax_sync_serial_init()
292 printk(KERN_INFO "Artpec-3 synchronous serial port driver\n"); in etrax_sync_serial_init()
300 struct sync_port *port = &ports[portnbr]; in initialize_port() local
306 DEBUG(printk(KERN_DEBUG "Init sync serial port %d\n", portnbr)); in initialize_port()
308 port->port_nbr = portnbr; in initialize_port()
309 port->init_irqs = 1; in initialize_port()
311 port->out_rd_ptr = port->out_buffer; in initialize_port()
312 port->out_buf_count = 0; in initialize_port()
314 port->output = 1; in initialize_port()
315 port->input = 0; in initialize_port()
317 port->readp = port->flip; in initialize_port()
318 port->writep = port->flip; in initialize_port()
319 port->in_buffer_size = IN_BUFFER_SIZE; in initialize_port()
320 port->inbufchunk = IN_DESCR_SIZE; in initialize_port()
321 port->next_rx_desc = &port->in_descr[0]; in initialize_port()
322 port->prev_rx_desc = &port->in_descr[NBR_IN_DESCR-1]; in initialize_port()
323 port->prev_rx_desc->eol = 1; in initialize_port()
325 init_waitqueue_head(&port->out_wait_q); in initialize_port()
326 init_waitqueue_head(&port->in_wait_q); in initialize_port()
328 spin_lock_init(&port->lock); in initialize_port()
337 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in initialize_port()
347 REG_WR(sser, port->regi_sser, rw_frm_cfg, frm_cfg); in initialize_port()
352 tr_cfg.use_dma = port->use_dma ? regk_sser_yes : regk_sser_no; in initialize_port()
361 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in initialize_port()
365 rec_cfg.use_dma = port->use_dma ? regk_sser_yes : regk_sser_no; in initialize_port()
367 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in initialize_port()
372 port->out_descr[i].wait = 0; in initialize_port()
373 port->out_descr[i].intr = 1; in initialize_port()
374 port->out_descr[i].eol = 0; in initialize_port()
375 port->out_descr[i].out_eop = 0; in initialize_port()
376 port->out_descr[i].next = in initialize_port()
377 (dma_descr_data *)virt_to_phys(&port->out_descr[i+1]); in initialize_port()
381 port->out_descr[NBR_OUT_DESCR-1].next = in initialize_port()
382 (dma_descr_data *)virt_to_phys(&port->out_descr[0]); in initialize_port()
385 port->active_tr_descr = &port->out_descr[0]; in initialize_port()
386 port->prev_tr_descr = &port->out_descr[NBR_OUT_DESCR-1]; in initialize_port()
387 port->catch_tr_descr = &port->out_descr[0]; in initialize_port()
391 static inline int sync_data_avail(struct sync_port *port) in sync_data_avail() argument
397 start = (unsigned char*)port->readp; /* cast away volatile */ in sync_data_avail()
398 end = (unsigned char*)port->writep; /* cast away volatile */ in sync_data_avail()
407 avail = port->in_buffer_size - (start - end); in sync_data_avail()
411 static inline int sync_data_avail_to_end(struct sync_port *port) in sync_data_avail_to_end() argument
417 start = (unsigned char*)port->readp; /* cast away volatile */ in sync_data_avail_to_end()
418 end = (unsigned char*)port->writep; /* cast away volatile */ in sync_data_avail_to_end()
427 avail = port->flip + port->in_buffer_size - start; in sync_data_avail_to_end()
435 sync_port *port; in sync_serial_open() local
440 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); in sync_serial_open()
448 port = &ports[dev]; in sync_serial_open()
450 if (port->busy == 2) in sync_serial_open()
457 if (port->init_irqs) { in sync_serial_open()
458 if (port->use_dma) { in sync_serial_open()
459 if (port == &ports[0]) { in sync_serial_open()
466 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); in sync_serial_open()
473 free_irq(DMA_OUT_INTR_VECT, &port[0]); in sync_serial_open()
474 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); in sync_serial_open()
481 free_irq(DMA_OUT_INTR_VECT, &port[0]); in sync_serial_open()
482 free_irq(DMA_IN_INTR_VECT, &port[0]); in sync_serial_open()
483 printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel"); in sync_serial_open()
491 free_irq(DMA_OUT_INTR_VECT, &port[0]); in sync_serial_open()
492 free_irq(DMA_IN_INTR_VECT, &port[0]); in sync_serial_open()
493 printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel"); in sync_serial_open()
499 else if (port == &ports[1]) { in sync_serial_open()
506 printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ"); in sync_serial_open()
514 printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ"); in sync_serial_open()
524 printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel"); in sync_serial_open()
535 printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel"); in sync_serial_open()
542 REG_WR(dma, port->regi_dmain, rw_cfg, cfg); in sync_serial_open()
543 REG_WR(dma, port->regi_dmaout, rw_cfg, cfg); in sync_serial_open()
545 REG_WR(dma, port->regi_dmain, rw_intr_mask, intr_mask); in sync_serial_open()
546 REG_WR(dma, port->regi_dmaout, rw_intr_mask, intr_mask); in sync_serial_open()
548 DMA_WR_CMD (port->regi_dmain, regk_dma_set_w_size1); in sync_serial_open()
549 DMA_WR_CMD (port->regi_dmaout, regk_dma_set_w_size1); in sync_serial_open()
551 start_dma_in(port); in sync_serial_open()
552 port->init_irqs = 0; in sync_serial_open()
553 } else { /* !port->use_dma */ in sync_serial_open()
555 if (port == &ports[0]) { in sync_serial_open()
566 else if (port == &ports[1]) { in sync_serial_open()
577 port->init_irqs = 0; in sync_serial_open()
583 } /* port->init_irqs */ in sync_serial_open()
585 port->busy++; in sync_serial_open()
595 sync_port *port; in sync_serial_release() local
602 port = &ports[dev]; in sync_serial_release()
603 if (port->busy) in sync_serial_release()
604 port->busy--; in sync_serial_release()
605 if (!port->busy) in sync_serial_release()
614 sync_port *port; in sync_serial_poll() local
617 port = &ports[dev]; in sync_serial_poll()
619 if (!port->started) { in sync_serial_poll()
620 reg_sser_rw_cfg cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_poll()
622 REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_poll()
624 rec_cfg.rec_en = port->input; in sync_serial_poll()
625 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in sync_serial_poll()
626 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_poll()
627 port->started = 1; in sync_serial_poll()
630 poll_wait(file, &port->out_wait_q, wait); in sync_serial_poll()
631 poll_wait(file, &port->in_wait_q, wait); in sync_serial_poll()
634 if (port->output && !port->tr_running) in sync_serial_poll()
638 if (port->output && in sync_serial_poll()
639 port->active_tr_descr != port->catch_tr_descr && in sync_serial_poll()
640 port->out_buf_count < OUT_BUFFER_SIZE) in sync_serial_poll()
644 if (port->input && sync_data_avail(port) >= port->inbufchunk) in sync_serial_poll()
661 sync_port *port; in sync_serial_ioctl() local
673 port = &ports[dev]; in sync_serial_ioctl()
674 spin_lock_irq(&port->lock); in sync_serial_ioctl()
676 tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in sync_serial_ioctl()
677 rec_cfg = REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_ioctl()
678 frm_cfg = REG_RD(sser, port->regi_sser, rw_frm_cfg); in sync_serial_ioctl()
679 gen_cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_ioctl()
680 intr_mask = REG_RD(sser, port->regi_sser, rw_intr_mask); in sync_serial_ioctl()
772 port->output = 1; in sync_serial_ioctl()
773 port->input = 0; in sync_serial_ioctl()
779 port->output = 1; in sync_serial_ioctl()
780 port->input = 0; in sync_serial_ioctl()
785 port->output = 0; in sync_serial_ioctl()
786 port->input = 1; in sync_serial_ioctl()
792 port->output = 0; in sync_serial_ioctl()
793 port->input = 1; in sync_serial_ioctl()
798 port->output = 1; in sync_serial_ioctl()
799 port->input = 1; in sync_serial_ioctl()
805 port->output = 1; in sync_serial_ioctl()
806 port->input = 1; in sync_serial_ioctl()
811 spin_unlock_irq(&port->lock); in sync_serial_ioctl()
814 if (!port->use_dma || (arg == MASTER_OUTPUT || arg == SLAVE_OUTPUT)) in sync_serial_ioctl()
920 port->input = 1; in sync_serial_ioctl()
921 port->output = 0; in sync_serial_ioctl()
926 port->input = 0; in sync_serial_ioctl()
927 port->output = 1; in sync_serial_ioctl()
938 if (port->started) { in sync_serial_ioctl()
939 rec_cfg.rec_en = port->input; in sync_serial_ioctl()
940 gen_cfg.en = (port->output | port->input); in sync_serial_ioctl()
943 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in sync_serial_ioctl()
944 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_ioctl()
945 REG_WR(sser, port->regi_sser, rw_frm_cfg, frm_cfg); in sync_serial_ioctl()
946 REG_WR(sser, port->regi_sser, rw_intr_mask, intr_mask); in sync_serial_ioctl()
947 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl()
954 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl()
956 DMA_WR_CMD(port->regi_dmain, dma_w_size); in sync_serial_ioctl()
957 DMA_WR_CMD(port->regi_dmaout, dma_w_size); in sync_serial_ioctl()
959 REG_WR(sser, port->regi_sser, rw_cfg, gen_cfg); in sync_serial_ioctl()
962 spin_unlock_irq(&port->lock); in sync_serial_ioctl()
984 struct sync_port *port; in sync_serial_write() local
998 port = &ports[dev]; in sync_serial_write()
1009 port->port_nbr, count, port->active_tr_descr, in sync_serial_write()
1010 port->catch_tr_descr)); in sync_serial_write()
1013 spin_lock_irqsave(&port->lock, flags); in sync_serial_write()
1014 rd_ptr = port->out_rd_ptr; in sync_serial_write()
1015 out_buf_count = port->out_buf_count; in sync_serial_write()
1016 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_write()
1019 if (port->tr_running && in sync_serial_write()
1020 ((port->use_dma && port->active_tr_descr == port->catch_tr_descr) || in sync_serial_write()
1026 buf_stop_ptr = port->out_buffer + OUT_BUFFER_SIZE; in sync_serial_write()
1047 port->out_buf_count, port->out_buffer, in sync_serial_write()
1051 if (!port->started) { in sync_serial_write()
1052 reg_sser_rw_cfg cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_write()
1053 reg_sser_rw_rec_cfg rec_cfg = REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_write()
1055 rec_cfg.rec_en = port->input; in sync_serial_write()
1056 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in sync_serial_write()
1057 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_write()
1058 port->started = 1; in sync_serial_write()
1063 add_wait_queue(&port->out_wait_q, &wait); in sync_serial_write()
1067 spin_lock_irqsave(&port->lock, flags); in sync_serial_write()
1068 port->out_buf_count += trunc_count; in sync_serial_write()
1069 if (port->use_dma) { in sync_serial_write()
1070 start_dma_out(port, wr_ptr, trunc_count); in sync_serial_write()
1071 } else if (!port->tr_running) { in sync_serial_write()
1073 intr_mask = REG_RD(sser, port->regi_sser, rw_intr_mask); in sync_serial_write()
1075 send_word(port); in sync_serial_write()
1078 REG_WR(sser, port->regi_sser, rw_intr_mask, intr_mask); in sync_serial_write()
1080 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_write()
1085 port->port_nbr, trunc_count, in sync_serial_write()
1086 REG_RD_INT(dma, port->regi_dmaout, r_intr))); in sync_serial_write()
1092 remove_wait_queue(&port->out_wait_q, &wait); in sync_serial_write()
1098 port->port_nbr, trunc_count)); in sync_serial_write()
1107 sync_port *port; in sync_serial_read() local
1117 port = &ports[dev]; in sync_serial_read()
1119 …tk("R%d c %d ri %lu wi %lu /%lu\n", dev, count, port->readp - port->flip, port->writep - port->fli… in sync_serial_read()
1121 if (!port->started) in sync_serial_read()
1123 reg_sser_rw_cfg cfg = REG_RD(sser, port->regi_sser, rw_cfg); in sync_serial_read()
1124 reg_sser_rw_tr_cfg tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in sync_serial_read()
1125 reg_sser_rw_rec_cfg rec_cfg = REG_RD(sser, port->regi_sser, rw_rec_cfg); in sync_serial_read()
1129 REG_WR(sser, port->regi_sser, rw_cfg, cfg); in sync_serial_read()
1130 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in sync_serial_read()
1131 REG_WR(sser, port->regi_sser, rw_rec_cfg, rec_cfg); in sync_serial_read()
1132 port->started = 1; in sync_serial_read()
1137 spin_lock_irqsave(&port->lock, flags); in sync_serial_read()
1138 start = (unsigned char*)port->readp; /* cast away volatile */ in sync_serial_read()
1139 end = (unsigned char*)port->writep; /* cast away volatile */ in sync_serial_read()
1140 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_read()
1141 while ((start == end) && !port->full) /* No data */ in sync_serial_read()
1147 interruptible_sleep_on(&port->in_wait_q); in sync_serial_read()
1151 spin_lock_irqsave(&port->lock, flags); in sync_serial_read()
1152 start = (unsigned char*)port->readp; /* cast away volatile */ in sync_serial_read()
1153 end = (unsigned char*)port->writep; /* cast away volatile */ in sync_serial_read()
1154 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_read()
1158 if (port->full) in sync_serial_read()
1159 avail = port->in_buffer_size; in sync_serial_read()
1163 avail = port->flip + port->in_buffer_size - start; in sync_serial_read()
1169 spin_lock_irqsave(&port->lock, flags); in sync_serial_read()
1170 port->readp += count; in sync_serial_read()
1171 if (port->readp >= port->flip + port->in_buffer_size) /* Wrap? */ in sync_serial_read()
1172 port->readp = port->flip; in sync_serial_read()
1173 port->full = 0; in sync_serial_read()
1174 spin_unlock_irqrestore(&port->lock, flags); in sync_serial_read()
1179 static void send_word(sync_port* port) in send_word() argument
1181 reg_sser_rw_tr_cfg tr_cfg = REG_RD(sser, port->regi_sser, rw_tr_cfg); in send_word()
1187 port->out_buf_count--; in send_word()
1188 tr_data.data = *port->out_rd_ptr++; in send_word()
1189 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1190 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1191 port->out_rd_ptr = port->out_buffer; in send_word()
1195 int data = (*port->out_rd_ptr++) << 8; in send_word()
1196 data |= *port->out_rd_ptr++; in send_word()
1197 port->out_buf_count -= 2; in send_word()
1199 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1200 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1201 port->out_rd_ptr = port->out_buffer; in send_word()
1205 port->out_buf_count -= 2; in send_word()
1206 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1207 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1208 port->out_rd_ptr += 2; in send_word()
1209 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1210 port->out_rd_ptr = port->out_buffer; in send_word()
1213 port->out_buf_count -= 3; in send_word()
1214 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1215 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1216 port->out_rd_ptr += 2; in send_word()
1217 tr_data.data = *port->out_rd_ptr++; in send_word()
1218 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1219 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1220 port->out_rd_ptr = port->out_buffer; in send_word()
1223 port->out_buf_count -= 4; in send_word()
1224 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1225 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1226 port->out_rd_ptr += 2; in send_word()
1227 tr_data.data = *(unsigned short *)port->out_rd_ptr; in send_word()
1228 REG_WR(sser, port->regi_sser, rw_tr_data, tr_data); in send_word()
1229 port->out_rd_ptr += 2; in send_word()
1230 if (port->out_rd_ptr >= port->out_buffer + OUT_BUFFER_SIZE) in send_word()
1231 port->out_rd_ptr = port->out_buffer; in send_word()
1236 static void start_dma_out(struct sync_port *port, in start_dma_out() argument
1239 port->active_tr_descr->buf = (char *) virt_to_phys((char *) data); in start_dma_out()
1240 port->active_tr_descr->after = port->active_tr_descr->buf + count; in start_dma_out()
1241 port->active_tr_descr->intr = 1; in start_dma_out()
1243 port->active_tr_descr->eol = 1; in start_dma_out()
1244 port->prev_tr_descr->eol = 0; in start_dma_out()
1247 port->prev_tr_descr, port->active_tr_descr)); in start_dma_out()
1248 port->prev_tr_descr = port->active_tr_descr; in start_dma_out()
1249 port->active_tr_descr = phys_to_virt((int) port->active_tr_descr->next); in start_dma_out()
1251 if (!port->tr_running) { in start_dma_out()
1252 reg_sser_rw_tr_cfg tr_cfg = REG_RD(sser, port->regi_sser, in start_dma_out()
1255 port->out_context.next = 0; in start_dma_out()
1256 port->out_context.saved_data = in start_dma_out()
1257 (dma_descr_data *)virt_to_phys(port->prev_tr_descr); in start_dma_out()
1258 port->out_context.saved_data_buf = port->prev_tr_descr->buf; in start_dma_out()
1260 DMA_START_CONTEXT(port->regi_dmaout, in start_dma_out()
1261 virt_to_phys((char *)&port->out_context)); in start_dma_out()
1264 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in start_dma_out()
1267 DMA_CONTINUE_DATA(port->regi_dmaout); in start_dma_out()
1271 port->tr_running = 1; in start_dma_out()
1274 static void start_dma_in(sync_port *port) in start_dma_in() argument
1278 port->writep = port->flip; in start_dma_in()
1280 if (port->writep > port->flip + port->in_buffer_size) { in start_dma_in()
1284 buf = (char*)virt_to_phys(port->in_buffer); in start_dma_in()
1286 port->in_descr[i].buf = buf; in start_dma_in()
1287 port->in_descr[i].after = buf + port->inbufchunk; in start_dma_in()
1288 port->in_descr[i].intr = 1; in start_dma_in()
1289 port->in_descr[i].next = (dma_descr_data*)virt_to_phys(&port->in_descr[i+1]); in start_dma_in()
1290 port->in_descr[i].buf = buf; in start_dma_in()
1291 buf += port->inbufchunk; in start_dma_in()
1294 port->in_descr[i-1].next = (dma_descr_data*)virt_to_phys(&port->in_descr[0]); in start_dma_in()
1295 port->in_descr[i-1].eol = regk_sser_yes; in start_dma_in()
1296 port->next_rx_desc = &port->in_descr[0]; in start_dma_in()
1297 port->prev_rx_desc = &port->in_descr[NBR_IN_DESCR - 1]; in start_dma_in()
1298 port->in_context.saved_data = (dma_descr_data*)virt_to_phys(&port->in_descr[0]); in start_dma_in()
1299 port->in_context.saved_data_buf = port->in_descr[0].buf; in start_dma_in()
1300 DMA_START_CONTEXT(port->regi_dmain, virt_to_phys(&port->in_context)); in start_dma_in()
1314 sync_port *port = &ports[i]; in tr_interrupt() local
1315 if (!port->enabled || !port->use_dma) in tr_interrupt()
1318 /* IRQ active for the port? */ in tr_interrupt()
1319 masked = REG_RD(dma, port->regi_dmaout, r_masked_intr); in tr_interrupt()
1326 stat = REG_RD(dma, port->regi_dmaout, rw_stat); in tr_interrupt()
1331 REG_WR(dma, port->regi_dmaout, rw_ack_intr, ack_intr); in tr_interrupt()
1338 sent = port->catch_tr_descr->after - in tr_interrupt()
1339 port->catch_tr_descr->buf; in tr_interrupt()
1342 port->out_buf_count, sent, in tr_interrupt()
1343 port->out_buf_count - sent, in tr_interrupt()
1344 port->catch_tr_descr, in tr_interrupt()
1345 port->active_tr_descr);); in tr_interrupt()
1346 port->out_buf_count -= sent; in tr_interrupt()
1347 port->catch_tr_descr = in tr_interrupt()
1348 phys_to_virt((int) port->catch_tr_descr->next); in tr_interrupt()
1349 port->out_rd_ptr = in tr_interrupt()
1350 phys_to_virt((int) port->catch_tr_descr->buf); in tr_interrupt()
1361 while (!port->catch_tr_descr->eol) { in tr_interrupt()
1362 sent = port->catch_tr_descr->after - in tr_interrupt()
1363 port->catch_tr_descr->buf; in tr_interrupt()
1366 port->catch_tr_descr, in tr_interrupt()
1368 port->out_buf_count)); in tr_interrupt()
1369 port->out_buf_count -= sent; in tr_interrupt()
1370 port->catch_tr_descr = phys_to_virt( in tr_interrupt()
1371 (int)port->catch_tr_descr->next); in tr_interrupt()
1378 sent = port->catch_tr_descr->after - in tr_interrupt()
1379 port->catch_tr_descr->buf; in tr_interrupt()
1382 port->catch_tr_descr, in tr_interrupt()
1384 port->out_buf_count)); in tr_interrupt()
1386 port->out_buf_count -= sent; in tr_interrupt()
1390 port->out_rd_ptr = in tr_interrupt()
1391 phys_to_virt((int) port->catch_tr_descr->after); in tr_interrupt()
1392 if (port->out_rd_ptr > port->out_buffer + in tr_interrupt()
1394 port->out_rd_ptr = port->out_buffer; in tr_interrupt()
1397 REG_RD(sser, port->regi_sser, rw_tr_cfg); in tr_interrupt()
1400 port->out_buf_count, in tr_interrupt()
1401 port->active_tr_descr)); in tr_interrupt()
1402 if (port->out_buf_count != 0) in tr_interrupt()
1405 port->catch_tr_descr = port->active_tr_descr; in tr_interrupt()
1406 port->tr_running = 0; in tr_interrupt()
1408 REG_WR(sser, port->regi_sser, rw_tr_cfg, tr_cfg); in tr_interrupt()
1411 wake_up_interruptible(&port->out_wait_q); in tr_interrupt()
1426 sync_port *port = &ports[i]; in rx_interrupt() local
1428 if (!port->enabled || !port->use_dma ) in rx_interrupt()
1431 masked = REG_RD(dma, port->regi_dmain, r_masked_intr); in rx_interrupt()
1436 while (REG_RD(dma, port->regi_dmain, rw_data) != in rx_interrupt()
1437 virt_to_phys(port->next_rx_desc)) { in rx_interrupt()
1439 if (port->writep + port->inbufchunk > port->flip + port->in_buffer_size) { in rx_interrupt()
1440 int first_size = port->flip + port->in_buffer_size - port->writep; in rx_interrupt()
1441 memcpy((char*)port->writep, phys_to_virt((unsigned)port->next_rx_desc->buf), first_size); in rx_interrupt()
1442 …memcpy(port->flip, phys_to_virt((unsigned)port->next_rx_desc->buf+first_size), port->inbufchunk - … in rx_interrupt()
1443 port->writep = port->flip + port->inbufchunk - first_size; in rx_interrupt()
1445 memcpy((char*)port->writep, in rx_interrupt()
1446 phys_to_virt((unsigned)port->next_rx_desc->buf), in rx_interrupt()
1447 port->inbufchunk); in rx_interrupt()
1448 port->writep += port->inbufchunk; in rx_interrupt()
1449 if (port->writep >= port->flip + port->in_buffer_size) in rx_interrupt()
1450 port->writep = port->flip; in rx_interrupt()
1452 if (port->writep == port->readp) in rx_interrupt()
1454 port->full = 1; in rx_interrupt()
1457 port->next_rx_desc->eol = 1; in rx_interrupt()
1458 port->prev_rx_desc->eol = 0; in rx_interrupt()
1460 flush_dma_descr(port->prev_rx_desc, 0); in rx_interrupt()
1461 port->prev_rx_desc = port->next_rx_desc; in rx_interrupt()
1462 port->next_rx_desc = phys_to_virt((unsigned)port->next_rx_desc->next); in rx_interrupt()
1464 flush_dma_descr(port->prev_rx_desc, 1); in rx_interrupt()
1466 wake_up_interruptible(&port->in_wait_q); in rx_interrupt()
1467 DMA_CONTINUE(port->regi_dmain); in rx_interrupt()
1468 REG_WR(dma, port->regi_dmain, rw_ack_intr, ack_intr); in rx_interrupt()
1486 sync_port *port = &ports[i]; in manual_interrupt() local
1488 if (!port->enabled || port->use_dma) in manual_interrupt()
1493 masked = REG_RD(sser, port->regi_sser, r_masked_intr); in manual_interrupt()
1496 reg_sser_rw_rec_cfg rec_cfg = REG_RD(sser, port->regi_sser, rw_rec_cfg); in manual_interrupt()
1497 reg_sser_r_rec_data data = REG_RD(sser, port->regi_sser, r_rec_data); in manual_interrupt()
1503 *port->writep++ = data.data & 0xff; in manual_interrupt()
1506 *port->writep = (data.data & 0x0ff0) >> 4; in manual_interrupt()
1507 *(port->writep + 1) = data.data & 0x0f; in manual_interrupt()
1508 port->writep+=2; in manual_interrupt()
1511 *(unsigned short*)port->writep = data.data; in manual_interrupt()
1512 port->writep+=2; in manual_interrupt()
1515 *(unsigned int*)port->writep = data.data; in manual_interrupt()
1516 port->writep+=3; in manual_interrupt()
1519 *(unsigned int*)port->writep = data.data; in manual_interrupt()
1520 port->writep+=4; in manual_interrupt()
1524 if (port->writep >= port->flip + port->in_buffer_size) /* Wrap? */ in manual_interrupt()
1525 port->writep = port->flip; in manual_interrupt()
1526 if (port->writep == port->readp) { in manual_interrupt()
1529 port->readp++; in manual_interrupt()
1530 if (port->readp >= port->flip + port->in_buffer_size) /* Wrap? */ in manual_interrupt()
1531 port->readp = port->flip; in manual_interrupt()
1533 if (sync_data_avail(port) >= port->inbufchunk) in manual_interrupt()
1534 wake_up_interruptible(&port->in_wait_q); /* Wake up application */ in manual_interrupt()
1540 if (port->out_buf_count > 0) /* More data to send */ in manual_interrupt()
1541 send_word(port); in manual_interrupt()
1545 intr_mask = REG_RD(sser, port->regi_sser, rw_intr_mask); in manual_interrupt()
1547 REG_WR(sser, port->regi_sser, rw_intr_mask, intr_mask); in manual_interrupt()
1548 wake_up_interruptible(&port->out_wait_q); /* Wake up application */ in manual_interrupt()