4 * driver for the GE IP-OCTAL boards
5 * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
6 * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
7 * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; version 2 of the License.
14 #include <linux/device.h>
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/sched.h>
18 #include <linux/tty.h>
19 #include <linux/serial.h>
20 #include <linux/tty_flip.h>
21 #include <linux/slab.h>
22 #include <linux/atomic.h>
28 #define IP_OCTAL_ID_SPACE_VECTOR 0x41
29 #define IP_OCTAL_NB_BLOCKS 4
31 static const struct tty_operations ipoctal_fops;
33 struct ipoctal_channel {
34 struct ipoctal_stats stats;
35 unsigned int nb_bytes;
36 unsigned int count_wr;
37 wait_queue_head_t queue;
39 unsigned int pointer_read;
40 unsigned int pointer_write;
42 struct tty_port tty_port;
43 union scc2698_channel __iomem *regs;
44 union scc2698_block __iomem *block_regs;
48 struct list_head list;
49 struct ipack_device *dev;
50 unsigned int board_id;
51 struct ipoctal_channel channel[NR_CHANNELS];
53 struct tty_driver *tty_drv;
56 /* Linked list to save the registered devices */
57 static LIST_HEAD(ipoctal_list);
59 static inline void ipoctal_write_io_reg(struct ipoctal *ipoctal,
63 iowrite8(value, dest);
66 static inline void ipoctal_write_cr_cmd(struct ipoctal *ipoctal,
70 ipoctal_write_io_reg(ipoctal, dest, value);
73 static inline unsigned char ipoctal_read_io_reg(struct ipoctal *ipoctal,
79 static struct ipoctal *ipoctal_find_board(struct tty_struct *tty)
83 list_for_each_entry(p, &ipoctal_list, list) {
84 if (tty->driver->major == p->tty_drv->major)
91 static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
93 struct ipoctal *ipoctal;
94 struct ipoctal_channel *channel;
96 ipoctal = ipoctal_find_board(tty);
98 if (ipoctal == NULL) {
99 dev_err(tty->dev, "Device not found. Major %d\n",
103 channel = &ipoctal->channel[tty->index];
105 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
110 static int ipoctal_open(struct tty_struct *tty, struct file *file)
113 struct ipoctal *ipoctal;
114 struct ipoctal_channel *channel;
116 ipoctal = ipoctal_find_board(tty);
118 if (ipoctal == NULL) {
119 dev_err(tty->dev, "Device not found. Major %d\n",
123 channel = &ipoctal->channel[tty->index];
125 if (atomic_read(&channel->open))
128 tty->driver_data = ipoctal;
130 res = tty_port_open(&channel->tty_port, tty, file);
134 atomic_inc(&channel->open);
138 static void ipoctal_reset_stats(struct ipoctal_stats *stats)
142 stats->rcv_break = 0;
143 stats->framing_err = 0;
144 stats->overrun_err = 0;
145 stats->parity_err = 0;
148 static void ipoctal_free_channel(struct tty_struct *tty)
150 struct ipoctal *ipoctal = tty->driver_data;
151 struct ipoctal_channel *channel;
155 channel = &ipoctal->channel[tty->index];
157 ipoctal_reset_stats(&channel->stats);
158 channel->pointer_read = 0;
159 channel->pointer_write = 0;
160 channel->nb_bytes = 0;
163 static void ipoctal_close(struct tty_struct *tty, struct file *filp)
165 struct ipoctal *ipoctal = tty->driver_data;
166 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
168 tty_port_close(&channel->tty_port, tty, filp);
170 if (atomic_dec_and_test(&channel->open))
171 ipoctal_free_channel(tty);
174 static int ipoctal_get_icount(struct tty_struct *tty,
175 struct serial_icounter_struct *icount)
177 struct ipoctal *ipoctal = tty->driver_data;
178 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
184 icount->rx = channel->stats.rx;
185 icount->tx = channel->stats.tx;
186 icount->frame = channel->stats.framing_err;
187 icount->parity = channel->stats.parity_err;
188 icount->brk = channel->stats.rcv_break;
192 static int ipoctal_irq_handler(void *arg)
194 unsigned int ichannel;
197 unsigned char isr_tx_rdy, isr_rx_rdy;
200 struct tty_struct *tty;
201 struct ipoctal *ipoctal = (struct ipoctal *) arg;
202 struct ipoctal_channel *channel;
204 /* Check all channels */
205 for (ichannel = 0; ichannel < NR_CHANNELS; ichannel++) {
206 channel = &ipoctal->channel[ichannel];
207 /* If there is no client, skip the check */
208 if (!atomic_read(&channel->open))
211 tty = tty_port_tty_get(&channel->tty_port);
216 * The HW is organized in pair of channels.
217 * See which register we need to read from
219 isr = ipoctal_read_io_reg(ipoctal,
220 &channel->block_regs->r.isr);
221 sr = ipoctal_read_io_reg(ipoctal,
222 &channel->regs->r.sr);
224 if ((ichannel % 2) == 1) {
225 isr_tx_rdy = isr & ISR_TxRDY_B;
226 isr_rx_rdy = isr & ISR_RxRDY_FFULL_B;
228 isr_tx_rdy = isr & ISR_TxRDY_A;
229 isr_rx_rdy = isr & ISR_RxRDY_FFULL_A;
232 /* In case of RS-485, change from TX to RX when finishing TX.
235 if ((ipoctal->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) &&
236 (sr & SR_TX_EMPTY) &&
237 (channel->nb_bytes == 0)) {
238 ipoctal_write_io_reg(ipoctal,
239 &channel->regs->w.cr,
241 ipoctal_write_cr_cmd(ipoctal,
242 &channel->regs->w.cr,
244 ipoctal_write_io_reg(ipoctal,
245 &channel->regs->w.cr,
248 wake_up_interruptible(&channel->queue);
252 if (isr_rx_rdy && (sr & SR_RX_READY)) {
253 value = ipoctal_read_io_reg(ipoctal,
254 &channel->regs->r.rhr);
257 /* Error: count statistics */
259 ipoctal_write_cr_cmd(ipoctal,
260 &channel->regs->w.cr,
261 CR_CMD_RESET_ERR_STATUS);
263 if (sr & SR_OVERRUN_ERROR) {
264 channel->stats.overrun_err++;
265 /* Overrun doesn't affect the current character*/
266 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
268 if (sr & SR_PARITY_ERROR) {
269 channel->stats.parity_err++;
272 if (sr & SR_FRAMING_ERROR) {
273 channel->stats.framing_err++;
276 if (sr & SR_RECEIVED_BREAK) {
277 channel->stats.rcv_break++;
282 tty_insert_flip_char(tty, value, flag);
285 /* TX of each character */
286 if (isr_tx_rdy && (sr & SR_TX_READY)) {
287 unsigned int *pointer_write = &channel->pointer_write;
289 if (channel->nb_bytes <= 0) {
290 channel->nb_bytes = 0;
294 value = channel->tty_port.xmit_buf[*pointer_write];
295 ipoctal_write_io_reg(ipoctal,
296 &channel->regs->w.thr,
301 *pointer_write = *pointer_write % PAGE_SIZE;
304 if ((channel->nb_bytes == 0) &&
305 (waitqueue_active(&channel->queue))) {
307 if (ipoctal->board_id != IPACK1_DEVICE_ID_SBS_OCTAL_485) {
309 wake_up_interruptible(&channel->queue);
314 tty_flip_buffer_push(tty);
320 static int ipoctal_check_model(struct ipack_device *dev, unsigned char *id)
322 unsigned char manufacturerID;
323 unsigned char board_id;
326 manufacturerID = ioread8(dev->id_space.address + IPACK_IDPROM_OFFSET_MANUFACTURER_ID);
327 if (manufacturerID != IPACK1_VENDOR_ID_SBS)
330 board_id = ioread8(dev->id_space.address + IPACK_IDPROM_OFFSET_MODEL);
332 case IPACK1_DEVICE_ID_SBS_OCTAL_232:
333 case IPACK1_DEVICE_ID_SBS_OCTAL_422:
334 case IPACK1_DEVICE_ID_SBS_OCTAL_485:
344 static const struct tty_port_operations ipoctal_tty_port_ops = {
346 .activate = ipoctal_port_activate,
349 static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
350 unsigned int slot, unsigned int vector)
354 struct tty_driver *tty;
356 unsigned char board_id;
357 struct ipoctal_channel *channel;
358 union scc2698_channel __iomem *chan_regs;
359 union scc2698_block __iomem *block_regs;
361 res = ipoctal->dev->bus->ops->map_space(ipoctal->dev, 0,
364 dev_err(&ipoctal->dev->dev,
365 "Unable to map slot [%d:%d] ID space!\n",
370 res = ipoctal_check_model(ipoctal->dev, &board_id);
372 ipoctal->dev->bus->ops->unmap_space(ipoctal->dev,
374 goto out_unregister_id_space;
376 ipoctal->board_id = board_id;
378 res = ipoctal->dev->bus->ops->map_space(ipoctal->dev, 0,
381 dev_err(&ipoctal->dev->dev,
382 "Unable to map slot [%d:%d] IO space!\n",
384 goto out_unregister_id_space;
387 res = ipoctal->dev->bus->ops->map_space(ipoctal->dev,
388 0x8000, IPACK_MEM_SPACE);
390 dev_err(&ipoctal->dev->dev,
391 "Unable to map slot [%d:%d] MEM space!\n",
393 goto out_unregister_io_space;
396 /* Save the virtual address to access the registers easily */
398 (union scc2698_channel __iomem *) ipoctal->dev->io_space.address;
400 (union scc2698_block __iomem *) ipoctal->dev->io_space.address;
402 /* Disable RX and TX before touching anything */
403 for (i = 0; i < NR_CHANNELS ; i++) {
404 struct ipoctal_channel *channel = &ipoctal->channel[i];
405 channel->regs = chan_regs + i;
406 channel->block_regs = block_regs + (i >> 1);
408 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
409 CR_DISABLE_RX | CR_DISABLE_TX);
410 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
412 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
414 ipoctal_write_io_reg(ipoctal,
415 &channel->regs->w.mr,
416 MR1_CHRL_8_BITS | MR1_ERROR_CHAR |
417 MR1_RxINT_RxRDY); /* mr1 */
418 ipoctal_write_io_reg(ipoctal,
419 &channel->regs->w.mr,
421 ipoctal_write_io_reg(ipoctal,
422 &channel->regs->w.csr,
423 TX_CLK_9600 | RX_CLK_9600);
426 for (i = 0; i < IP_OCTAL_NB_BLOCKS; i++) {
427 ipoctal_write_io_reg(ipoctal,
428 &block_regs[i].w.acr,
430 ipoctal_write_io_reg(ipoctal,
431 &block_regs[i].w.opcr,
432 OPCR_MPP_OUTPUT | OPCR_MPOa_RTSN |
434 ipoctal_write_io_reg(ipoctal,
435 &block_regs[i].w.imr,
436 IMR_TxRDY_A | IMR_RxRDY_FFULL_A |
437 IMR_DELTA_BREAK_A | IMR_TxRDY_B |
438 IMR_RxRDY_FFULL_B | IMR_DELTA_BREAK_B);
442 * IP-OCTAL has different addresses to copy its IRQ vector.
443 * Depending of the carrier these addresses are accesible or not.
444 * More info in the datasheet.
446 ipoctal->dev->bus->ops->request_irq(ipoctal->dev, vector,
447 ipoctal_irq_handler, ipoctal);
448 iowrite8(vector, ipoctal->dev->mem_space.address + 1);
450 /* Register the TTY device */
452 /* Each IP-OCTAL channel is a TTY port */
453 tty = alloc_tty_driver(NR_CHANNELS);
457 goto out_unregister_slot_unmap;
460 /* Fill struct tty_driver with ipoctal data */
461 tty->owner = THIS_MODULE;
462 tty->driver_name = "ipoctal";
463 sprintf(name, "ipoctal.%d.%d.", bus_nr, slot);
467 tty->minor_start = 0;
468 tty->type = TTY_DRIVER_TYPE_SERIAL;
469 tty->subtype = SERIAL_TYPE_NORMAL;
470 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
471 tty->init_termios = tty_std_termios;
472 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
473 tty->init_termios.c_ispeed = 9600;
474 tty->init_termios.c_ospeed = 9600;
476 tty_set_operations(tty, &ipoctal_fops);
477 res = tty_register_driver(tty);
479 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
481 goto out_unregister_slot_unmap;
484 /* Save struct tty_driver for use it when uninstalling the device */
485 ipoctal->tty_drv = tty;
487 for (i = 0; i < NR_CHANNELS; i++) {
488 channel = &ipoctal->channel[i];
489 tty_port_init(&channel->tty_port);
490 tty_port_alloc_xmit_buf(&channel->tty_port);
491 channel->tty_port.ops = &ipoctal_tty_port_ops;
493 ipoctal_reset_stats(&channel->stats);
494 channel->nb_bytes = 0;
495 init_waitqueue_head(&channel->queue);
497 spin_lock_init(&channel->lock);
498 channel->pointer_read = 0;
499 channel->pointer_write = 0;
500 channel->nb_bytes = 0;
501 tty_register_device(tty, i, NULL);
504 * Enable again the RX. TX will be enabled when
505 * there is something to send
507 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
513 out_unregister_slot_unmap:
514 ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_ID_SPACE);
515 out_unregister_io_space:
516 ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_IO_SPACE);
517 out_unregister_id_space:
518 ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_MEM_SPACE);
522 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
523 const unsigned char *buf,
528 unsigned int *pointer_read = &channel->pointer_read;
530 /* Copy the bytes from the user buffer to the internal one */
531 for (i = 0; i < count; i++) {
532 if (i <= (PAGE_SIZE - channel->nb_bytes)) {
533 spin_lock_irqsave(&channel->lock, flags);
534 channel->tty_port.xmit_buf[*pointer_read] = buf[i];
535 *pointer_read = (*pointer_read + 1) % PAGE_SIZE;
537 spin_unlock_irqrestore(&channel->lock, flags);
545 static int ipoctal_write(struct ipoctal *ipoctal, unsigned int ichannel,
546 const unsigned char *buf, int count)
548 struct ipoctal_channel *channel = &ipoctal->channel[ichannel];
549 channel->nb_bytes = 0;
550 channel->count_wr = 0;
552 ipoctal_copy_write_buffer(channel, buf, count);
554 /* As the IP-OCTAL 485 only supports half duplex, do it manually */
555 if (ipoctal->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
556 ipoctal_write_io_reg(ipoctal,
557 &channel->regs->w.cr,
559 ipoctal_write_cr_cmd(ipoctal,
560 &channel->regs->w.cr,
565 * Send a packet and then disable TX to avoid failure after several send
568 ipoctal_write_io_reg(ipoctal,
569 &channel->regs->w.cr,
571 wait_event_interruptible(channel->queue, ipoctal->write);
572 ipoctal_write_io_reg(ipoctal,
573 &channel->regs->w.cr,
577 return channel->count_wr;
580 static int ipoctal_write_tty(struct tty_struct *tty,
581 const unsigned char *buf, int count)
583 struct ipoctal *ipoctal = tty->driver_data;
585 return ipoctal_write(ipoctal, tty->index, buf, count);
588 static int ipoctal_write_room(struct tty_struct *tty)
590 struct ipoctal *ipoctal = tty->driver_data;
591 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
593 return PAGE_SIZE - channel->nb_bytes;
596 static int ipoctal_chars_in_buffer(struct tty_struct *tty)
598 struct ipoctal *ipoctal = tty->driver_data;
599 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
601 return channel->nb_bytes;
604 static void ipoctal_set_termios(struct tty_struct *tty,
605 struct ktermios *old_termios)
608 unsigned char mr1 = 0;
609 unsigned char mr2 = 0;
610 unsigned char csr = 0;
611 struct ipoctal *ipoctal = tty->driver_data;
612 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
615 cflag = tty->termios->c_cflag;
617 /* Disable and reset everything before change the setup */
618 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
619 CR_DISABLE_RX | CR_DISABLE_TX);
620 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
622 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
624 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
625 CR_CMD_RESET_ERR_STATUS);
626 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
629 /* Set Bits per chars */
630 switch (cflag & CSIZE) {
632 mr1 |= MR1_CHRL_6_BITS;
635 mr1 |= MR1_CHRL_7_BITS;
639 mr1 |= MR1_CHRL_8_BITS;
640 /* By default, select CS8 */
641 tty->termios->c_cflag = (cflag & ~CSIZE) | CS8;
648 mr1 |= MR1_PARITY_ON | MR1_PARITY_ODD;
650 mr1 |= MR1_PARITY_ON | MR1_PARITY_EVEN;
652 mr1 |= MR1_PARITY_OFF;
654 /* Mark or space parity is not supported */
655 tty->termios->c_cflag &= ~CMSPAR;
659 mr2 |= MR2_STOP_BITS_LENGTH_2;
661 mr2 |= MR2_STOP_BITS_LENGTH_1;
663 /* Set the flow control */
664 switch (ipoctal->board_id) {
665 case IPACK1_DEVICE_ID_SBS_OCTAL_232:
666 if (cflag & CRTSCTS) {
667 mr1 |= MR1_RxRTS_CONTROL_ON;
668 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_ON;
670 mr1 |= MR1_RxRTS_CONTROL_OFF;
671 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
674 case IPACK1_DEVICE_ID_SBS_OCTAL_422:
675 mr1 |= MR1_RxRTS_CONTROL_OFF;
676 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
678 case IPACK1_DEVICE_ID_SBS_OCTAL_485:
679 mr1 |= MR1_RxRTS_CONTROL_OFF;
680 mr2 |= MR2_TxRTS_CONTROL_ON | MR2_CTS_ENABLE_TX_OFF;
687 baud = tty_get_baud_rate(tty);
688 tty_termios_encode_baud_rate(tty->termios, baud, baud);
691 switch (tty->termios->c_ospeed) {
693 csr |= TX_CLK_75 | RX_CLK_75;
696 csr |= TX_CLK_110 | RX_CLK_110;
699 csr |= TX_CLK_150 | RX_CLK_150;
702 csr |= TX_CLK_300 | RX_CLK_300;
705 csr |= TX_CLK_600 | RX_CLK_600;
708 csr |= TX_CLK_1200 | RX_CLK_1200;
711 csr |= TX_CLK_1800 | RX_CLK_1800;
714 csr |= TX_CLK_2000 | RX_CLK_2000;
717 csr |= TX_CLK_2400 | RX_CLK_2400;
720 csr |= TX_CLK_4800 | RX_CLK_4800;
723 csr |= TX_CLK_9600 | RX_CLK_9600;
726 csr |= TX_CLK_19200 | RX_CLK_19200;
730 csr |= TX_CLK_38400 | RX_CLK_38400;
731 /* In case of default, we establish 38400 bps */
732 tty_termios_encode_baud_rate(tty->termios, 38400, 38400);
736 mr1 |= MR1_ERROR_CHAR;
737 mr1 |= MR1_RxINT_RxRDY;
739 /* Write the control registers */
740 ipoctal_write_io_reg(ipoctal, &channel->regs->w.mr, mr1);
741 ipoctal_write_io_reg(ipoctal, &channel->regs->w.mr, mr2);
742 ipoctal_write_io_reg(ipoctal, &channel->regs->w.csr, csr);
744 /* Enable again the RX */
745 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
749 static void ipoctal_hangup(struct tty_struct *tty)
752 struct ipoctal *ipoctal = tty->driver_data;
753 struct ipoctal_channel *channel = &ipoctal->channel[tty->index];
758 spin_lock_irqsave(&channel->lock, flags);
759 channel->nb_bytes = 0;
760 channel->pointer_read = 0;
761 channel->pointer_write = 0;
762 spin_unlock_irqrestore(&channel->lock, flags);
764 tty_port_hangup(&channel->tty_port);
766 ipoctal_write_io_reg(ipoctal, &channel->regs->w.cr,
767 CR_DISABLE_RX | CR_DISABLE_TX);
768 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
770 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
772 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
773 CR_CMD_RESET_ERR_STATUS);
774 ipoctal_write_cr_cmd(ipoctal, &channel->regs->w.cr,
777 clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
778 wake_up_interruptible(&channel->tty_port.open_wait);
781 static const struct tty_operations ipoctal_fops = {
783 .open = ipoctal_open,
784 .close = ipoctal_close,
785 .write = ipoctal_write_tty,
786 .set_termios = ipoctal_set_termios,
787 .write_room = ipoctal_write_room,
788 .chars_in_buffer = ipoctal_chars_in_buffer,
789 .get_icount = ipoctal_get_icount,
790 .hangup = ipoctal_hangup,
793 static int ipoctal_probe(struct ipack_device *dev)
796 struct ipoctal *ipoctal;
798 ipoctal = kzalloc(sizeof(struct ipoctal), GFP_KERNEL);
803 res = ipoctal_inst_slot(ipoctal, dev->bus_nr, dev->slot, dev->irq);
807 list_add_tail(&ipoctal->list, &ipoctal_list);
815 static void __ipoctal_remove(struct ipoctal *ipoctal)
819 ipoctal->dev->bus->ops->free_irq(ipoctal->dev);
821 for (i = 0; i < NR_CHANNELS; i++) {
822 struct ipoctal_channel *channel = &ipoctal->channel[i];
823 tty_unregister_device(ipoctal->tty_drv, i);
824 tty_port_free_xmit_buf(&channel->tty_port);
827 tty_unregister_driver(ipoctal->tty_drv);
828 put_tty_driver(ipoctal->tty_drv);
829 list_del(&ipoctal->list);
833 static void ipoctal_remove(struct ipack_device *device)
835 struct ipoctal *ipoctal, *next;
837 list_for_each_entry_safe(ipoctal, next, &ipoctal_list, list) {
838 if (ipoctal->dev == device)
839 __ipoctal_remove(ipoctal);
843 static DEFINE_IPACK_DEVICE_TABLE(ipoctal_ids) = {
844 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
845 IPACK1_DEVICE_ID_SBS_OCTAL_232) },
846 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
847 IPACK1_DEVICE_ID_SBS_OCTAL_422) },
848 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
849 IPACK1_DEVICE_ID_SBS_OCTAL_485) },
853 MODULE_DEVICE_TABLE(ipack, ipoctal_ids);
855 static const struct ipack_driver_ops ipoctal_drv_ops = {
856 .probe = ipoctal_probe,
857 .remove = ipoctal_remove,
860 static struct ipack_driver driver = {
861 .ops = &ipoctal_drv_ops,
862 .id_table = ipoctal_ids,
865 static int __init ipoctal_init(void)
867 return ipack_driver_register(&driver, THIS_MODULE, KBUILD_MODNAME);
870 static void __exit ipoctal_exit(void)
872 ipack_driver_unregister(&driver);
875 MODULE_DESCRIPTION("IP-Octal 232, 422 and 485 device driver");
876 MODULE_LICENSE("GPL");
878 module_init(ipoctal_init);
879 module_exit(ipoctal_exit);