aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-05-08 03:36:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:23 -0400
commit0809e2671d804f6caa8b3bd5e4de4b52f649cf73 (patch)
treea5062f13bbfda8b708d8e9f837ddc0a9addca8df
parent58936d8d944e27b75c99b1c59cfeea3f253b03cb (diff)
Char: cyclades, move card entries init into function
Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/cyclades.c311
1 files changed, 156 insertions, 155 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index e5de0409b37c..85c734b7f548 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4503,6 +4503,159 @@ static void cy_hangup(struct tty_struct *tty)
4503 * --------------------------------------------------------------------- 4503 * ---------------------------------------------------------------------
4504 */ 4504 */
4505 4505
4506static void __devinit cy_init_card(struct cyclades_card *cinfo,
4507 const unsigned int board)
4508{
4509 struct cyclades_port *info;
4510 u32 mailbox;
4511 unsigned int nports;
4512 unsigned short chip_number;
4513 int index, port;
4514
4515 if (cinfo->num_chips == -1) { /* Cyclades-Z */
4516 mailbox = readl(&((struct RUNTIME_9060 __iomem *)
4517 cinfo->ctl_addr)->mail_box_0);
4518 nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
4519 cinfo->intr_enabled = 0;
4520 cinfo->nports = 0; /* Will be correctly set later, after
4521 Z FW is loaded */
4522 spin_lock_init(&cinfo->card_lock);
4523 for (port = cinfo->first_line;
4524 port < cinfo->first_line + nports; port++) {
4525 info = &cy_port[port];
4526 info->magic = CYCLADES_MAGIC;
4527 info->type = PORT_STARTECH;
4528 info->card = board;
4529 info->line = port;
4530 info->chip_rev = 0;
4531 info->flags = STD_COM_FLAGS;
4532 info->tty = NULL;
4533 if (mailbox == ZO_V1)
4534 info->xmit_fifo_size = CYZ_FIFO_SIZE;
4535 else
4536 info->xmit_fifo_size =
4537 4 * CYZ_FIFO_SIZE;
4538 info->cor1 = 0;
4539 info->cor2 = 0;
4540 info->cor3 = 0;
4541 info->cor4 = 0;
4542 info->cor5 = 0;
4543 info->tbpr = 0;
4544 info->tco = 0;
4545 info->rbpr = 0;
4546 info->rco = 0;
4547 info->custom_divisor = 0;
4548 info->close_delay = 5 * HZ / 10;
4549 info->closing_wait = CLOSING_WAIT_DELAY;
4550 info->icount.cts = info->icount.dsr =
4551 info->icount.rng = info->icount.dcd = 0;
4552 info->icount.rx = info->icount.tx = 0;
4553 info->icount.frame = info->icount.parity = 0;
4554 info->icount.overrun = info->icount.brk = 0;
4555 info->x_char = 0;
4556 info->event = 0;
4557 info->count = 0;
4558 info->blocked_open = 0;
4559 info->default_threshold = 0;
4560 info->default_timeout = 0;
4561 INIT_WORK(&info->tqueue, do_softint);
4562 init_waitqueue_head(&info->open_wait);
4563 init_waitqueue_head(&info->close_wait);
4564 init_waitqueue_head(&info->shutdown_wait);
4565 init_waitqueue_head(&info->delta_msr_wait);
4566 /* info->session */
4567 /* info->pgrp */
4568 info->read_status_mask = 0;
4569 /* info->timeout */
4570 /* Bentson's vars */
4571 info->jiffies[0] = 0;
4572 info->jiffies[1] = 0;
4573 info->jiffies[2] = 0;
4574 info->rflush_count = 0;
4575#ifdef CONFIG_CYZ_INTR
4576 init_timer(&cyz_rx_full_timer[port]);
4577 cyz_rx_full_timer[port].function = NULL;
4578#endif
4579 }
4580#ifndef CONFIG_CYZ_INTR
4581 if (!timer_pending(&cyz_timerlist)) {
4582 mod_timer(&cyz_timerlist, jiffies + 1);
4583#ifdef CY_PCI_DEBUG
4584 printk("Cyclades-Z polling initialized\n");
4585#endif
4586 }
4587#endif /* CONFIG_CYZ_INTR */
4588
4589 } else { /* Cyclom-Y of some kind */
4590 index = cinfo->bus_index;
4591 spin_lock_init(&cinfo->card_lock);
4592 cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
4593 for (port = cinfo->first_line;
4594 port < cinfo->first_line + cinfo->nports; port++) {
4595 info = &cy_port[port];
4596 info->magic = CYCLADES_MAGIC;
4597 info->type = PORT_CIRRUS;
4598 info->card = board;
4599 info->line = port;
4600 info->flags = STD_COM_FLAGS;
4601 info->tty = NULL;
4602 info->xmit_fifo_size = CyMAX_CHAR_FIFO;
4603 info->cor1 =
4604 CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
4605 info->cor2 = CyETC;
4606 info->cor3 = 0x08; /* _very_ small rcv threshold */
4607 info->cor4 = 0;
4608 info->cor5 = 0;
4609 info->custom_divisor = 0;
4610 info->close_delay = 5 * HZ / 10;
4611 info->closing_wait = CLOSING_WAIT_DELAY;
4612 info->icount.cts = info->icount.dsr =
4613 info->icount.rng = info->icount.dcd = 0;
4614 info->icount.rx = info->icount.tx = 0;
4615 info->icount.frame = info->icount.parity = 0;
4616 info->icount.overrun = info->icount.brk = 0;
4617 chip_number = (port - cinfo->first_line) / 4;
4618 if ((info->chip_rev =
4619 readb(cinfo->base_addr +
4620 (cy_chip_offset[chip_number] <<
4621 index) + (CyGFRCR << index))) >=
4622 CD1400_REV_J) {
4623 /* It is a CD1400 rev. J or later */
4624 info->tbpr = baud_bpr_60[13]; /* Tx BPR */
4625 info->tco = baud_co_60[13]; /* Tx CO */
4626 info->rbpr = baud_bpr_60[13]; /* Rx BPR */
4627 info->rco = baud_co_60[13]; /* Rx CO */
4628 info->rflow = 0;
4629 info->rtsdtr_inv = 1;
4630 } else {
4631 info->tbpr = baud_bpr_25[13]; /* Tx BPR */
4632 info->tco = baud_co_25[13]; /* Tx CO */
4633 info->rbpr = baud_bpr_25[13]; /* Rx BPR */
4634 info->rco = baud_co_25[13]; /* Rx CO */
4635 info->rflow = 0;
4636 info->rtsdtr_inv = 0;
4637 }
4638 info->x_char = 0;
4639 info->event = 0;
4640 info->count = 0;
4641 info->blocked_open = 0;
4642 info->default_threshold = 0;
4643 info->default_timeout = 0;
4644 INIT_WORK(&info->tqueue, do_softint);
4645 init_waitqueue_head(&info->open_wait);
4646 init_waitqueue_head(&info->close_wait);
4647 init_waitqueue_head(&info->shutdown_wait);
4648 init_waitqueue_head(&info->delta_msr_wait);
4649 /* info->session */
4650 /* info->pgrp */
4651 info->read_status_mask =
4652 CyTIMEOUT | CySPECHAR | CyBREAK
4653 | CyPARITY | CyFRAME | CyOVERRUN;
4654 /* info->timeout */
4655 }
4656 }
4657}
4658
4506/* initialize chips on Cyclom-Y card -- return number of valid 4659/* initialize chips on Cyclom-Y card -- return number of valid
4507 chips (which is number of ports/4) */ 4660 chips (which is number of ports/4) */
4508static unsigned short __init 4661static unsigned short __init
@@ -5300,13 +5453,7 @@ static const struct tty_operations cy_ops = {
5300 5453
5301static int __init cy_init(void) 5454static int __init cy_init(void)
5302{ 5455{
5303 struct cyclades_port *info; 5456 unsigned int i;
5304 struct cyclades_card *cinfo;
5305 int number_z_boards = 0;
5306 int board, port, i, index;
5307 unsigned long mailbox;
5308 unsigned short chip_number;
5309 int nports;
5310 5457
5311 cy_serial_driver = alloc_tty_driver(NR_PORTS); 5458 cy_serial_driver = alloc_tty_driver(NR_PORTS);
5312 if (!cy_serial_driver) 5459 if (!cy_serial_driver)
@@ -5369,154 +5516,8 @@ static int __init cy_init(void)
5369 } 5516 }
5370 5517
5371 /* initialize per-port data structures for each valid board found */ 5518 /* initialize per-port data structures for each valid board found */
5372 for (board = 0; board < cy_nboard; board++) { 5519 for (i = 0; i < cy_nboard; i++)
5373 cinfo = &cy_card[board]; 5520 cy_init_card(&cy_card[i], i);
5374 if (cinfo->num_chips == -1) { /* Cyclades-Z */
5375 number_z_boards++;
5376 mailbox = readl(&((struct RUNTIME_9060 __iomem *)
5377 cy_card[board].ctl_addr)->
5378 mail_box_0);
5379 nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
5380 cinfo->intr_enabled = 0;
5381 cinfo->nports = 0; /* Will be correctly set later, after
5382 Z FW is loaded */
5383 spin_lock_init(&cinfo->card_lock);
5384 for (port = cinfo->first_line;
5385 port < cinfo->first_line + nports; port++) {
5386 info = &cy_port[port];
5387 info->magic = CYCLADES_MAGIC;
5388 info->type = PORT_STARTECH;
5389 info->card = board;
5390 info->line = port;
5391 info->chip_rev = 0;
5392 info->flags = STD_COM_FLAGS;
5393 info->tty = NULL;
5394 if (mailbox == ZO_V1)
5395 info->xmit_fifo_size = CYZ_FIFO_SIZE;
5396 else
5397 info->xmit_fifo_size =
5398 4 * CYZ_FIFO_SIZE;
5399 info->cor1 = 0;
5400 info->cor2 = 0;
5401 info->cor3 = 0;
5402 info->cor4 = 0;
5403 info->cor5 = 0;
5404 info->tbpr = 0;
5405 info->tco = 0;
5406 info->rbpr = 0;
5407 info->rco = 0;
5408 info->custom_divisor = 0;
5409 info->close_delay = 5 * HZ / 10;
5410 info->closing_wait = CLOSING_WAIT_DELAY;
5411 info->icount.cts = info->icount.dsr =
5412 info->icount.rng = info->icount.dcd = 0;
5413 info->icount.rx = info->icount.tx = 0;
5414 info->icount.frame = info->icount.parity = 0;
5415 info->icount.overrun = info->icount.brk = 0;
5416 info->x_char = 0;
5417 info->event = 0;
5418 info->count = 0;
5419 info->blocked_open = 0;
5420 info->default_threshold = 0;
5421 info->default_timeout = 0;
5422 INIT_WORK(&info->tqueue, do_softint);
5423 init_waitqueue_head(&info->open_wait);
5424 init_waitqueue_head(&info->close_wait);
5425 init_waitqueue_head(&info->shutdown_wait);
5426 init_waitqueue_head(&info->delta_msr_wait);
5427 /* info->session */
5428 /* info->pgrp */
5429 info->read_status_mask = 0;
5430 /* info->timeout */
5431 /* Bentson's vars */
5432 info->jiffies[0] = 0;
5433 info->jiffies[1] = 0;
5434 info->jiffies[2] = 0;
5435 info->rflush_count = 0;
5436#ifdef CONFIG_CYZ_INTR
5437 init_timer(&cyz_rx_full_timer[port]);
5438 cyz_rx_full_timer[port].function = NULL;
5439#endif
5440 }
5441 continue;
5442 } else { /* Cyclom-Y of some kind */
5443 index = cinfo->bus_index;
5444 spin_lock_init(&cinfo->card_lock);
5445 cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
5446 for (port = cinfo->first_line;
5447 port < cinfo->first_line + cinfo->nports; port++) {
5448 info = &cy_port[port];
5449 info->magic = CYCLADES_MAGIC;
5450 info->type = PORT_CIRRUS;
5451 info->card = board;
5452 info->line = port;
5453 info->flags = STD_COM_FLAGS;
5454 info->tty = NULL;
5455 info->xmit_fifo_size = CyMAX_CHAR_FIFO;
5456 info->cor1 =
5457 CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
5458 info->cor2 = CyETC;
5459 info->cor3 = 0x08; /* _very_ small rcv threshold */
5460 info->cor4 = 0;
5461 info->cor5 = 0;
5462 info->custom_divisor = 0;
5463 info->close_delay = 5 * HZ / 10;
5464 info->closing_wait = CLOSING_WAIT_DELAY;
5465 info->icount.cts = info->icount.dsr =
5466 info->icount.rng = info->icount.dcd = 0;
5467 info->icount.rx = info->icount.tx = 0;
5468 info->icount.frame = info->icount.parity = 0;
5469 info->icount.overrun = info->icount.brk = 0;
5470 chip_number = (port - cinfo->first_line) / 4;
5471 if ((info->chip_rev =
5472 readb(cinfo->base_addr +
5473 (cy_chip_offset[chip_number] <<
5474 index) + (CyGFRCR << index))) >=
5475 CD1400_REV_J) {
5476 /* It is a CD1400 rev. J or later */
5477 info->tbpr = baud_bpr_60[13]; /* Tx BPR */
5478 info->tco = baud_co_60[13]; /* Tx CO */
5479 info->rbpr = baud_bpr_60[13]; /* Rx BPR */
5480 info->rco = baud_co_60[13]; /* Rx CO */
5481 info->rflow = 0;
5482 info->rtsdtr_inv = 1;
5483 } else {
5484 info->tbpr = baud_bpr_25[13]; /* Tx BPR */
5485 info->tco = baud_co_25[13]; /* Tx CO */
5486 info->rbpr = baud_bpr_25[13]; /* Rx BPR */
5487 info->rco = baud_co_25[13]; /* Rx CO */
5488 info->rflow = 0;
5489 info->rtsdtr_inv = 0;
5490 }
5491 info->x_char = 0;
5492 info->event = 0;
5493 info->count = 0;
5494 info->blocked_open = 0;
5495 info->default_threshold = 0;
5496 info->default_timeout = 0;
5497 INIT_WORK(&info->tqueue, do_softint);
5498 init_waitqueue_head(&info->open_wait);
5499 init_waitqueue_head(&info->close_wait);
5500 init_waitqueue_head(&info->shutdown_wait);
5501 init_waitqueue_head(&info->delta_msr_wait);
5502 /* info->session */
5503 /* info->pgrp */
5504 info->read_status_mask =
5505 CyTIMEOUT | CySPECHAR | CyBREAK
5506 | CyPARITY | CyFRAME | CyOVERRUN;
5507 /* info->timeout */
5508 }
5509 }
5510 }
5511
5512#ifndef CONFIG_CYZ_INTR
5513 if (number_z_boards) {
5514 mod_timer(&cyz_timerlist, jiffies + 1);
5515#ifdef CY_PCI_DEBUG
5516 printk("Cyclades-Z polling initialized\n");
5517#endif
5518 }
5519#endif /* CONFIG_CYZ_INTR */
5520 5521
5521 return 0; 5522 return 0;
5522 5523