Lines Matching refs:channel
50 struct ipoctal_channel channel[NR_CHANNELS];
59 return container_of(chan, struct ipoctal, channel[index]);
62 static void ipoctal_reset_channel(struct ipoctal_channel *channel)
64 iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
65 channel->rx_enable = 0;
66 iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
67 iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
68 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
69 iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
74 struct ipoctal_channel *channel;
76 channel = dev_get_drvdata(tty->dev);
82 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
83 channel->rx_enable = 1;
89 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
90 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
100 tty->driver_data = channel;
112 struct ipoctal_channel *channel = tty->driver_data;
114 return tty_port_open(&channel->tty_port, tty, file);
127 static void ipoctal_free_channel(struct ipoctal_channel *channel)
129 ipoctal_reset_stats(&channel->stats);
130 channel->pointer_read = 0;
131 channel->pointer_write = 0;
132 channel->nb_bytes = 0;
137 struct ipoctal_channel *channel = tty->driver_data;
139 tty_port_close(&channel->tty_port, tty, filp);
140 ipoctal_free_channel(channel);
146 struct ipoctal_channel *channel = tty->driver_data;
152 icount->rx = channel->stats.rx;
153 icount->tx = channel->stats.tx;
154 icount->frame = channel->stats.framing_err;
155 icount->parity = channel->stats.parity_err;
156 icount->brk = channel->stats.rcv_break;
160 static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr)
162 struct tty_port *port = &channel->tty_port;
168 value = ioread8(&channel->regs->r.rhr);
172 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
175 channel->stats.overrun_err++;
180 channel->stats.parity_err++;
184 channel->stats.framing_err++;
188 channel->stats.rcv_break++;
195 * If there are more, the isr register for this channel
198 isr = ioread8(&channel->block_regs->r.isr);
199 sr = ioread8(&channel->regs->r.sr);
200 } while (isr & channel->isr_rx_rdy_mask);
205 static void ipoctal_irq_tx(struct ipoctal_channel *channel)
208 unsigned int *pointer_write = &channel->pointer_write;
210 if (channel->nb_bytes == 0)
213 spin_lock(&channel->lock);
214 value = channel->tty_port.xmit_buf[*pointer_write];
215 iowrite8(value, &channel->regs->w.thr);
216 channel->stats.tx++;
219 channel->nb_bytes--;
220 spin_unlock(&channel->lock);
223 static void ipoctal_irq_channel(struct ipoctal_channel *channel)
229 isr = ioread8(&channel->block_regs->r.isr);
230 sr = ioread8(&channel->regs->r.sr);
233 iowrite8(CR_CMD_RESET_BREAK_CHANGE, &channel->regs->w.cr);
235 if ((sr & SR_TX_EMPTY) && (channel->nb_bytes == 0)) {
236 iowrite8(CR_DISABLE_TX, &channel->regs->w.cr);
239 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
240 iowrite8(CR_CMD_NEGATE_RTSN, &channel->regs->w.cr);
241 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
242 channel->rx_enable = 1;
247 if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY))
248 ipoctal_irq_rx(channel, sr);
251 if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY))
252 ipoctal_irq_tx(channel);
266 ipoctal_irq_channel(&ipoctal->channel[i]);
282 struct ipoctal_channel *channel;
330 struct ipoctal_channel *channel = &ipoctal->channel[i];
331 channel->regs = chan_regs + i;
332 channel->block_regs = block_regs + (i >> 1);
333 channel->board_id = ipoctal->board_id;
335 channel->isr_tx_rdy_mask = ISR_TxRDY_B;
336 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_B;
338 channel->isr_tx_rdy_mask = ISR_TxRDY_A;
339 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
342 ipoctal_reset_channel(channel);
344 &channel->regs->w.mr); /* mr1 */
345 iowrite8(0, &channel->regs->w.mr); /* mr2 */
346 iowrite8(TX_CLK_9600 | RX_CLK_9600, &channel->regs->w.csr);
363 /* Each IP-OCTAL channel is a TTY port */
401 channel = &ipoctal->channel[i];
402 tty_port_init(&channel->tty_port);
403 res = tty_port_alloc_xmit_buf(&channel->tty_port);
406 channel->tty_port.ops = &ipoctal_tty_port_ops;
408 ipoctal_reset_stats(&channel->stats);
409 channel->nb_bytes = 0;
410 spin_lock_init(&channel->lock);
411 channel->pointer_read = 0;
412 channel->pointer_write = 0;
413 tty_dev = tty_port_register_device_attr(&channel->tty_port, tty,
414 i, NULL, channel, NULL);
417 tty_port_free_xmit_buf(&channel->tty_port);
418 tty_port_destroy(&channel->tty_port);
421 channel->tty_registered = true;
442 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
448 unsigned int *pointer_read = &channel->pointer_read;
452 if (i <= (PAGE_SIZE - channel->nb_bytes)) {
453 spin_lock_irqsave(&channel->lock, flags);
454 channel->tty_port.xmit_buf[*pointer_read] = buf[i];
456 channel->nb_bytes++;
457 spin_unlock_irqrestore(&channel->lock, flags);
468 struct ipoctal_channel *channel = tty->driver_data;
471 char_copied = ipoctal_copy_write_buffer(channel, buf, count);
474 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
475 iowrite8(CR_DISABLE_RX, &channel->regs->w.cr);
476 channel->rx_enable = 0;
477 iowrite8(CR_CMD_ASSERT_RTSN, &channel->regs->w.cr);
484 iowrite8(CR_ENABLE_TX, &channel->regs->w.cr);
490 struct ipoctal_channel *channel = tty->driver_data;
492 return PAGE_SIZE - channel->nb_bytes;
497 struct ipoctal_channel *channel = tty->driver_data;
499 return channel->nb_bytes;
509 struct ipoctal_channel *channel = tty->driver_data;
515 ipoctal_reset_channel(channel);
552 switch (channel->board_id) {
628 iowrite8(mr1, &channel->regs->w.mr);
629 iowrite8(mr2, &channel->regs->w.mr);
630 iowrite8(csr, &channel->regs->w.csr);
633 if (channel->rx_enable)
634 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
640 struct ipoctal_channel *channel = tty->driver_data;
642 if (channel == NULL)
645 spin_lock_irqsave(&channel->lock, flags);
646 channel->nb_bytes = 0;
647 channel->pointer_read = 0;
648 channel->pointer_write = 0;
649 spin_unlock_irqrestore(&channel->lock, flags);
651 tty_port_hangup(&channel->tty_port);
653 ipoctal_reset_channel(channel);
654 tty_port_set_initialized(&channel->tty_port, 0);
655 wake_up_interruptible(&channel->tty_port.open_wait);
660 struct ipoctal_channel *channel = tty->driver_data;
662 if (channel == NULL)
665 ipoctal_reset_channel(channel);
666 tty_port_set_initialized(&channel->tty_port, 0);
671 struct ipoctal_channel *channel = tty->driver_data;
672 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
722 struct ipoctal_channel *channel = &ipoctal->channel[i];
724 if (!channel->tty_registered)
728 tty_port_free_xmit_buf(&channel->tty_port);
729 tty_port_destroy(&channel->tty_port);