Lines Matching refs:channel
48 struct ipoctal_channel channel[NR_CHANNELS];
57 return container_of(chan, struct ipoctal, channel[index]);
60 static void ipoctal_reset_channel(struct ipoctal_channel *channel)
62 iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
63 channel->rx_enable = 0;
64 iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
65 iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
66 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
67 iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
72 struct ipoctal_channel *channel;
74 channel = dev_get_drvdata(tty->dev);
80 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
81 channel->rx_enable = 1;
87 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
88 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
98 tty->driver_data = channel;
110 struct ipoctal_channel *channel = tty->driver_data;
112 return tty_port_open(&channel->tty_port, tty, file);
125 static void ipoctal_free_channel(struct ipoctal_channel *channel)
127 ipoctal_reset_stats(&channel->stats);
128 channel->pointer_read = 0;
129 channel->pointer_write = 0;
130 channel->nb_bytes = 0;
135 struct ipoctal_channel *channel = tty->driver_data;
137 tty_port_close(&channel->tty_port, tty, filp);
138 ipoctal_free_channel(channel);
144 struct ipoctal_channel *channel = tty->driver_data;
150 icount->rx = channel->stats.rx;
151 icount->tx = channel->stats.tx;
152 icount->frame = channel->stats.framing_err;
153 icount->parity = channel->stats.parity_err;
154 icount->brk = channel->stats.rcv_break;
158 static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr)
160 struct tty_port *port = &channel->tty_port;
166 value = ioread8(&channel->regs->r.rhr);
170 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
173 channel->stats.overrun_err++;
178 channel->stats.parity_err++;
182 channel->stats.framing_err++;
186 channel->stats.rcv_break++;
193 * If there are more, the isr register for this channel
196 isr = ioread8(&channel->block_regs->r.isr);
197 sr = ioread8(&channel->regs->r.sr);
198 } while (isr & channel->isr_rx_rdy_mask);
203 static void ipoctal_irq_tx(struct ipoctal_channel *channel)
206 unsigned int *pointer_write = &channel->pointer_write;
208 if (channel->nb_bytes == 0)
211 spin_lock(&channel->lock);
212 value = channel->tty_port.xmit_buf[*pointer_write];
213 iowrite8(value, &channel->regs->w.thr);
214 channel->stats.tx++;
217 channel->nb_bytes--;
218 spin_unlock(&channel->lock);
221 static void ipoctal_irq_channel(struct ipoctal_channel *channel)
227 isr = ioread8(&channel->block_regs->r.isr);
228 sr = ioread8(&channel->regs->r.sr);
231 iowrite8(CR_CMD_RESET_BREAK_CHANGE, &channel->regs->w.cr);
233 if ((sr & SR_TX_EMPTY) && (channel->nb_bytes == 0)) {
234 iowrite8(CR_DISABLE_TX, &channel->regs->w.cr);
237 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
238 iowrite8(CR_CMD_NEGATE_RTSN, &channel->regs->w.cr);
239 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
240 channel->rx_enable = 1;
245 if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY))
246 ipoctal_irq_rx(channel, sr);
249 if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY))
250 ipoctal_irq_tx(channel);
264 ipoctal_irq_channel(&ipoctal->channel[i]);
280 struct ipoctal_channel *channel;
328 struct ipoctal_channel *channel = &ipoctal->channel[i];
329 channel->regs = chan_regs + i;
330 channel->block_regs = block_regs + (i >> 1);
331 channel->board_id = ipoctal->board_id;
333 channel->isr_tx_rdy_mask = ISR_TxRDY_B;
334 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_B;
336 channel->isr_tx_rdy_mask = ISR_TxRDY_A;
337 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
340 ipoctal_reset_channel(channel);
342 &channel->regs->w.mr); /* mr1 */
343 iowrite8(0, &channel->regs->w.mr); /* mr2 */
344 iowrite8(TX_CLK_9600 | RX_CLK_9600, &channel->regs->w.csr);
361 /* Each IP-OCTAL channel is a TTY port */
398 channel = &ipoctal->channel[i];
399 tty_port_init(&channel->tty_port);
400 res = tty_port_alloc_xmit_buf(&channel->tty_port);
403 channel->tty_port.ops = &ipoctal_tty_port_ops;
405 ipoctal_reset_stats(&channel->stats);
406 channel->nb_bytes = 0;
407 spin_lock_init(&channel->lock);
408 channel->pointer_read = 0;
409 channel->pointer_write = 0;
410 tty_dev = tty_port_register_device_attr(&channel->tty_port, drv,
411 i, NULL, channel, NULL);
414 tty_port_free_xmit_buf(&channel->tty_port);
415 tty_port_destroy(&channel->tty_port);
418 channel->tty_registered = true;
439 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
444 unsigned int *pointer_read = &channel->pointer_read;
448 if (i <= (PAGE_SIZE - channel->nb_bytes)) {
449 spin_lock_irqsave(&channel->lock, flags);
450 channel->tty_port.xmit_buf[*pointer_read] = buf[i];
452 channel->nb_bytes++;
453 spin_unlock_irqrestore(&channel->lock, flags);
464 struct ipoctal_channel *channel = tty->driver_data;
467 char_copied = ipoctal_copy_write_buffer(channel, buf, count);
470 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
471 iowrite8(CR_DISABLE_RX, &channel->regs->w.cr);
472 channel->rx_enable = 0;
473 iowrite8(CR_CMD_ASSERT_RTSN, &channel->regs->w.cr);
480 iowrite8(CR_ENABLE_TX, &channel->regs->w.cr);
486 struct ipoctal_channel *channel = tty->driver_data;
488 return PAGE_SIZE - channel->nb_bytes;
493 struct ipoctal_channel *channel = tty->driver_data;
495 return channel->nb_bytes;
505 struct ipoctal_channel *channel = tty->driver_data;
511 ipoctal_reset_channel(channel);
548 switch (channel->board_id) {
623 iowrite8(mr1, &channel->regs->w.mr);
624 iowrite8(mr2, &channel->regs->w.mr);
625 iowrite8(csr, &channel->regs->w.csr);
628 if (channel->rx_enable)
629 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
635 struct ipoctal_channel *channel = tty->driver_data;
637 if (channel == NULL)
640 spin_lock_irqsave(&channel->lock, flags);
641 channel->nb_bytes = 0;
642 channel->pointer_read = 0;
643 channel->pointer_write = 0;
644 spin_unlock_irqrestore(&channel->lock, flags);
646 tty_port_hangup(&channel->tty_port);
648 ipoctal_reset_channel(channel);
649 tty_port_set_initialized(&channel->tty_port, false);
650 wake_up_interruptible(&channel->tty_port.open_wait);
655 struct ipoctal_channel *channel = tty->driver_data;
657 if (channel == NULL)
660 ipoctal_reset_channel(channel);
661 tty_port_set_initialized(&channel->tty_port, false);
666 struct ipoctal_channel *channel = tty->driver_data;
667 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
717 struct ipoctal_channel *channel = &ipoctal->channel[i];
719 if (!channel->tty_registered)
723 tty_port_free_xmit_buf(&channel->tty_port);
724 tty_port_destroy(&channel->tty_port);