• Home
  • Raw
  • Download

Lines Matching refs:dc

527 static void setup_memory(struct nozomi *dc)  in setup_memory()  argument
529 void __iomem *offset = dc->base_addr + dc->config_table.dl_start; in setup_memory()
536 dc->port[PORT_MDM].dl_addr[CH_A] = offset; in setup_memory()
537 dc->port[PORT_MDM].dl_addr[CH_B] = in setup_memory()
538 (offset += dc->config_table.dl_mdm_len1); in setup_memory()
539 dc->port[PORT_MDM].dl_size[CH_A] = in setup_memory()
540 dc->config_table.dl_mdm_len1 - buff_offset; in setup_memory()
541 dc->port[PORT_MDM].dl_size[CH_B] = in setup_memory()
542 dc->config_table.dl_mdm_len2 - buff_offset; in setup_memory()
545 dc->port[PORT_DIAG].dl_addr[CH_A] = in setup_memory()
546 (offset += dc->config_table.dl_mdm_len2); in setup_memory()
547 dc->port[PORT_DIAG].dl_size[CH_A] = in setup_memory()
548 dc->config_table.dl_diag_len1 - buff_offset; in setup_memory()
549 dc->port[PORT_DIAG].dl_addr[CH_B] = in setup_memory()
550 (offset += dc->config_table.dl_diag_len1); in setup_memory()
551 dc->port[PORT_DIAG].dl_size[CH_B] = in setup_memory()
552 dc->config_table.dl_diag_len2 - buff_offset; in setup_memory()
555 dc->port[PORT_APP1].dl_addr[CH_A] = in setup_memory()
556 (offset += dc->config_table.dl_diag_len2); in setup_memory()
557 dc->port[PORT_APP1].dl_size[CH_A] = in setup_memory()
558 dc->config_table.dl_app1_len - buff_offset; in setup_memory()
561 dc->port[PORT_APP2].dl_addr[CH_A] = in setup_memory()
562 (offset += dc->config_table.dl_app1_len); in setup_memory()
563 dc->port[PORT_APP2].dl_size[CH_A] = in setup_memory()
564 dc->config_table.dl_app2_len - buff_offset; in setup_memory()
567 dc->port[PORT_CTRL].dl_addr[CH_A] = in setup_memory()
568 (offset += dc->config_table.dl_app2_len); in setup_memory()
569 dc->port[PORT_CTRL].dl_size[CH_A] = in setup_memory()
570 dc->config_table.dl_ctrl_len - buff_offset; in setup_memory()
572 offset = dc->base_addr + dc->config_table.ul_start; in setup_memory()
575 dc->port[PORT_MDM].ul_addr[CH_A] = offset; in setup_memory()
576 dc->port[PORT_MDM].ul_size[CH_A] = in setup_memory()
577 dc->config_table.ul_mdm_len1 - buff_offset; in setup_memory()
578 dc->port[PORT_MDM].ul_addr[CH_B] = in setup_memory()
579 (offset += dc->config_table.ul_mdm_len1); in setup_memory()
580 dc->port[PORT_MDM].ul_size[CH_B] = in setup_memory()
581 dc->config_table.ul_mdm_len2 - buff_offset; in setup_memory()
584 dc->port[PORT_DIAG].ul_addr[CH_A] = in setup_memory()
585 (offset += dc->config_table.ul_mdm_len2); in setup_memory()
586 dc->port[PORT_DIAG].ul_size[CH_A] = in setup_memory()
587 dc->config_table.ul_diag_len - buff_offset; in setup_memory()
590 dc->port[PORT_APP1].ul_addr[CH_A] = in setup_memory()
591 (offset += dc->config_table.ul_diag_len); in setup_memory()
592 dc->port[PORT_APP1].ul_size[CH_A] = in setup_memory()
593 dc->config_table.ul_app1_len - buff_offset; in setup_memory()
596 dc->port[PORT_APP2].ul_addr[CH_A] = in setup_memory()
597 (offset += dc->config_table.ul_app1_len); in setup_memory()
598 dc->port[PORT_APP2].ul_size[CH_A] = in setup_memory()
599 dc->config_table.ul_app2_len - buff_offset; in setup_memory()
602 dc->port[PORT_CTRL].ul_addr[CH_A] = in setup_memory()
603 (offset += dc->config_table.ul_app2_len); in setup_memory()
604 dc->port[PORT_CTRL].ul_size[CH_A] = in setup_memory()
605 dc->config_table.ul_ctrl_len - buff_offset; in setup_memory()
610 static void dump_table(const struct nozomi *dc) in dump_table() argument
612 DBG3("signature: 0x%08X", dc->config_table.signature); in dump_table()
613 DBG3("version: 0x%04X", dc->config_table.version); in dump_table()
615 dc->config_table.product_information); in dump_table()
616 DBG3("toggle enabled: %d", dc->config_table.toggle.enabled); in dump_table()
617 DBG3("toggle up_mdm: %d", dc->config_table.toggle.mdm_ul); in dump_table()
618 DBG3("toggle dl_mdm: %d", dc->config_table.toggle.mdm_dl); in dump_table()
619 DBG3("toggle dl_dbg: %d", dc->config_table.toggle.diag_dl); in dump_table()
621 DBG3("dl_start: 0x%04X", dc->config_table.dl_start); in dump_table()
622 DBG3("dl_mdm_len0: 0x%04X, %d", dc->config_table.dl_mdm_len1, in dump_table()
623 dc->config_table.dl_mdm_len1); in dump_table()
624 DBG3("dl_mdm_len1: 0x%04X, %d", dc->config_table.dl_mdm_len2, in dump_table()
625 dc->config_table.dl_mdm_len2); in dump_table()
626 DBG3("dl_diag_len0: 0x%04X, %d", dc->config_table.dl_diag_len1, in dump_table()
627 dc->config_table.dl_diag_len1); in dump_table()
628 DBG3("dl_diag_len1: 0x%04X, %d", dc->config_table.dl_diag_len2, in dump_table()
629 dc->config_table.dl_diag_len2); in dump_table()
630 DBG3("dl_app1_len: 0x%04X, %d", dc->config_table.dl_app1_len, in dump_table()
631 dc->config_table.dl_app1_len); in dump_table()
632 DBG3("dl_app2_len: 0x%04X, %d", dc->config_table.dl_app2_len, in dump_table()
633 dc->config_table.dl_app2_len); in dump_table()
634 DBG3("dl_ctrl_len: 0x%04X, %d", dc->config_table.dl_ctrl_len, in dump_table()
635 dc->config_table.dl_ctrl_len); in dump_table()
636 DBG3("ul_start: 0x%04X, %d", dc->config_table.ul_start, in dump_table()
637 dc->config_table.ul_start); in dump_table()
638 DBG3("ul_mdm_len[0]: 0x%04X, %d", dc->config_table.ul_mdm_len1, in dump_table()
639 dc->config_table.ul_mdm_len1); in dump_table()
640 DBG3("ul_mdm_len[1]: 0x%04X, %d", dc->config_table.ul_mdm_len2, in dump_table()
641 dc->config_table.ul_mdm_len2); in dump_table()
642 DBG3("ul_diag_len: 0x%04X, %d", dc->config_table.ul_diag_len, in dump_table()
643 dc->config_table.ul_diag_len); in dump_table()
644 DBG3("ul_app1_len: 0x%04X, %d", dc->config_table.ul_app1_len, in dump_table()
645 dc->config_table.ul_app1_len); in dump_table()
646 DBG3("ul_app2_len: 0x%04X, %d", dc->config_table.ul_app2_len, in dump_table()
647 dc->config_table.ul_app2_len); in dump_table()
648 DBG3("ul_ctrl_len: 0x%04X, %d", dc->config_table.ul_ctrl_len, in dump_table()
649 dc->config_table.ul_ctrl_len); in dump_table()
652 static inline void dump_table(const struct nozomi *dc) { } in dump_table() argument
659 static int nozomi_read_config_table(struct nozomi *dc) in nozomi_read_config_table() argument
661 read_mem32((u32 *) &dc->config_table, dc->base_addr + 0, in nozomi_read_config_table()
664 if (dc->config_table.signature != CONFIG_MAGIC) { in nozomi_read_config_table()
665 dev_err(&dc->pdev->dev, "ConfigTable Bad! 0x%08X != 0x%08X\n", in nozomi_read_config_table()
666 dc->config_table.signature, CONFIG_MAGIC); in nozomi_read_config_table()
670 if ((dc->config_table.version == 0) in nozomi_read_config_table()
671 || (dc->config_table.toggle.enabled == TOGGLE_VALID)) { in nozomi_read_config_table()
675 setup_memory(dc); in nozomi_read_config_table()
677 dc->port[PORT_MDM].toggle_ul = dc->config_table.toggle.mdm_ul; in nozomi_read_config_table()
678 dc->port[PORT_MDM].toggle_dl = dc->config_table.toggle.mdm_dl; in nozomi_read_config_table()
679 dc->port[PORT_DIAG].toggle_dl = dc->config_table.toggle.diag_dl; in nozomi_read_config_table()
681 dc->port[PORT_MDM].toggle_ul, in nozomi_read_config_table()
682 dc->port[PORT_MDM].toggle_dl, dc->port[PORT_DIAG].toggle_dl); in nozomi_read_config_table()
684 dump_table(dc); in nozomi_read_config_table()
687 dc->port[i].fifo_ul = in nozomi_read_config_table()
689 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl)); in nozomi_read_config_table()
690 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul)); in nozomi_read_config_table()
694 dc->last_ier = dc->last_ier | CTRL_DL; in nozomi_read_config_table()
695 writew(dc->last_ier, dc->reg_ier); in nozomi_read_config_table()
697 dc->state = NOZOMI_STATE_ALLOCATED; in nozomi_read_config_table()
698 dev_info(&dc->pdev->dev, "Initialization OK!\n"); in nozomi_read_config_table()
702 if ((dc->config_table.version > 0) in nozomi_read_config_table()
703 && (dc->config_table.toggle.enabled != TOGGLE_VALID)) { in nozomi_read_config_table()
707 dev_info(&dc->pdev->dev, "Version of card: %d\n", in nozomi_read_config_table()
708 dc->config_table.version); in nozomi_read_config_table()
711 setup_memory(dc); in nozomi_read_config_table()
719 write_mem32(dc->port[PORT_MDM].ul_addr[CH_A], in nozomi_read_config_table()
721 write_mem32(dc->port[PORT_MDM].ul_addr[CH_B], in nozomi_read_config_table()
724 writew(MDM_UL | DIAG_DL | MDM_DL, dc->reg_fcr); in nozomi_read_config_table()
733 static void enable_transmit_ul(enum port_type port, struct nozomi *dc) in enable_transmit_ul() argument
738 dc->last_ier |= mask[port]; in enable_transmit_ul()
739 writew(dc->last_ier, dc->reg_ier); in enable_transmit_ul()
741 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in enable_transmit_ul()
746 static void disable_transmit_ul(enum port_type port, struct nozomi *dc) in disable_transmit_ul() argument
752 dc->last_ier &= mask[port]; in disable_transmit_ul()
753 writew(dc->last_ier, dc->reg_ier); in disable_transmit_ul()
755 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in disable_transmit_ul()
760 static void enable_transmit_dl(enum port_type port, struct nozomi *dc) in enable_transmit_dl() argument
765 dc->last_ier |= mask[port]; in enable_transmit_dl()
766 writew(dc->last_ier, dc->reg_ier); in enable_transmit_dl()
768 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in enable_transmit_dl()
773 static void disable_transmit_dl(enum port_type port, struct nozomi *dc) in disable_transmit_dl() argument
779 dc->last_ier &= mask[port]; in disable_transmit_dl()
780 writew(dc->last_ier, dc->reg_ier); in disable_transmit_dl()
782 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in disable_transmit_dl()
790 static int send_data(enum port_type index, struct nozomi *dc) in send_data() argument
793 struct port *port = &dc->port[index]; in send_data()
800 size = __kfifo_get(port->fifo_ul, dc->send_buf, in send_data()
813 write_mem32(addr + 4, (u32 *) dc->send_buf, size); in send_data()
823 static int receive_data(enum port_type index, struct nozomi *dc) in receive_data() argument
828 struct port *port = &dc->port[index]; in receive_data()
846 disable_transmit_dl(index, dc); in receive_data()
851 dev_err(&dc->pdev->dev, "size == 0?\n"); in receive_data()
873 set_bit(index, &dc->flip); in receive_data()
928 static int receive_flow_control(struct nozomi *dc) in receive_flow_control() argument
935 read_mem32((u32 *) &ctrl_dl, dc->port[PORT_CTRL].dl_addr[CH_A], 2); in receive_flow_control()
958 if (dc->state == NOZOMI_STATE_ALLOCATED) { in receive_flow_control()
963 dc->state = NOZOMI_STATE_READY; in receive_flow_control()
964 dev_info(&dc->pdev->dev, "Device READY!\n"); in receive_flow_control()
968 dev_err(&dc->pdev->dev, in receive_flow_control()
973 DBG1("0x%04X->0x%04X", *((u16 *)&dc->port[port].ctrl_dl), in receive_flow_control()
976 old_ctrl = dc->port[port].ctrl_dl; in receive_flow_control()
977 dc->port[port].ctrl_dl = ctrl_dl; in receive_flow_control()
982 disable_transmit_ul(port, dc); in receive_flow_control()
986 if (__kfifo_len(dc->port[port].fifo_ul)) { in receive_flow_control()
990 __kfifo_len(dc->port[port].fifo_ul)); in receive_flow_control()
991 enable_transmit_ul(port, dc); in receive_flow_control()
1003 dc->port[port].tty_icount.cts++; in receive_flow_control()
1005 dc->port[port].tty_icount.dsr++; in receive_flow_control()
1007 dc->port[port].tty_icount.rng++; in receive_flow_control()
1009 dc->port[port].tty_icount.dcd++; in receive_flow_control()
1011 wake_up_interruptible(&dc->port[port].tty_wait); in receive_flow_control()
1015 dc->port[port].tty_icount.dcd, dc->port[port].tty_icount.cts, in receive_flow_control()
1016 dc->port[port].tty_icount.rng, dc->port[port].tty_icount.dsr); in receive_flow_control()
1022 const struct nozomi *dc) in port2ctrl() argument
1034 dev_err(&dc->pdev->dev, in port2ctrl()
1046 static int send_flow_control(struct nozomi *dc) in send_flow_control() argument
1052 if (dc->port[i].update_flow_control) { in send_flow_control()
1057 dc->port[i].ctrl_ul.port = port2ctrl(i, dc); in send_flow_control()
1058 ctrl = (u16 *)&dc->port[i].ctrl_ul; in send_flow_control()
1059 write_mem32(dc->port[PORT_CTRL].ul_addr[0], \ in send_flow_control()
1061 dc->port[i].update_flow_control = 0; in send_flow_control()
1073 static int handle_data_dl(struct nozomi *dc, enum port_type port, u8 *toggle, in handle_data_dl() argument
1077 if (receive_data(port, dc)) { in handle_data_dl()
1078 writew(mask1, dc->reg_fcr); in handle_data_dl()
1083 if (receive_data(port, dc)) { in handle_data_dl()
1084 writew(mask2, dc->reg_fcr); in handle_data_dl()
1089 if (receive_data(port, dc)) { in handle_data_dl()
1090 writew(mask2, dc->reg_fcr); in handle_data_dl()
1095 if (receive_data(port, dc)) { in handle_data_dl()
1096 writew(mask1, dc->reg_fcr); in handle_data_dl()
1101 dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n", in handle_data_dl()
1113 static int handle_data_ul(struct nozomi *dc, enum port_type port, u16 read_iir) in handle_data_ul() argument
1115 u8 *toggle = &(dc->port[port].toggle_ul); in handle_data_ul()
1118 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1119 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1120 if (send_data(port, dc)) { in handle_data_ul()
1121 writew(MDM_UL1, dc->reg_fcr); in handle_data_ul()
1122 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1123 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1128 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1129 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1130 if (send_data(port, dc)) { in handle_data_ul()
1131 writew(MDM_UL2, dc->reg_fcr); in handle_data_ul()
1132 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1133 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1139 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1140 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1141 if (send_data(port, dc)) { in handle_data_ul()
1142 writew(MDM_UL2, dc->reg_fcr); in handle_data_ul()
1143 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1144 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1149 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1150 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1151 if (send_data(port, dc)) { in handle_data_ul()
1152 writew(MDM_UL1, dc->reg_fcr); in handle_data_ul()
1153 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1154 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1159 writew(read_iir & MDM_UL, dc->reg_fcr); in handle_data_ul()
1160 dev_err(&dc->pdev->dev, "port out of sync!\n"); in handle_data_ul()
1168 struct nozomi *dc = dev_id; in interrupt_handler() local
1172 if (!dc) in interrupt_handler()
1175 spin_lock(&dc->spin_mutex); in interrupt_handler()
1176 read_iir = readw(dc->reg_iir); in interrupt_handler()
1185 read_iir &= dc->last_ier; in interrupt_handler()
1192 dc->last_ier); in interrupt_handler()
1195 if (unlikely(!nozomi_read_config_table(dc))) { in interrupt_handler()
1196 dc->last_ier = 0x0; in interrupt_handler()
1197 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1198 dev_err(&dc->pdev->dev, "Could not read status from " in interrupt_handler()
1201 writew(RESET, dc->reg_fcr); in interrupt_handler()
1208 dc->last_ier &= ~CTRL_UL; in interrupt_handler()
1209 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1210 if (send_flow_control(dc)) { in interrupt_handler()
1211 writew(CTRL_UL, dc->reg_fcr); in interrupt_handler()
1212 dc->last_ier = dc->last_ier | CTRL_UL; in interrupt_handler()
1213 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1217 receive_flow_control(dc); in interrupt_handler()
1218 writew(CTRL_DL, dc->reg_fcr); in interrupt_handler()
1221 if (!handle_data_dl(dc, PORT_MDM, in interrupt_handler()
1222 &(dc->port[PORT_MDM].toggle_dl), read_iir, in interrupt_handler()
1224 dev_err(&dc->pdev->dev, "MDM_DL out of sync!\n"); in interrupt_handler()
1229 if (!handle_data_ul(dc, PORT_MDM, read_iir)) { in interrupt_handler()
1230 dev_err(&dc->pdev->dev, "MDM_UL out of sync!\n"); in interrupt_handler()
1235 if (!handle_data_dl(dc, PORT_DIAG, in interrupt_handler()
1236 &(dc->port[PORT_DIAG].toggle_dl), read_iir, in interrupt_handler()
1238 dev_err(&dc->pdev->dev, "DIAG_DL out of sync!\n"); in interrupt_handler()
1243 dc->last_ier &= ~DIAG_UL; in interrupt_handler()
1244 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1245 if (send_data(PORT_DIAG, dc)) { in interrupt_handler()
1246 writew(DIAG_UL, dc->reg_fcr); in interrupt_handler()
1247 dc->last_ier = dc->last_ier | DIAG_UL; in interrupt_handler()
1248 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1252 if (receive_data(PORT_APP1, dc)) in interrupt_handler()
1253 writew(APP1_DL, dc->reg_fcr); in interrupt_handler()
1256 dc->last_ier &= ~APP1_UL; in interrupt_handler()
1257 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1258 if (send_data(PORT_APP1, dc)) { in interrupt_handler()
1259 writew(APP1_UL, dc->reg_fcr); in interrupt_handler()
1260 dc->last_ier = dc->last_ier | APP1_UL; in interrupt_handler()
1261 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1265 if (receive_data(PORT_APP2, dc)) in interrupt_handler()
1266 writew(APP2_DL, dc->reg_fcr); in interrupt_handler()
1269 dc->last_ier &= ~APP2_UL; in interrupt_handler()
1270 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1271 if (send_data(PORT_APP2, dc)) { in interrupt_handler()
1272 writew(APP2_UL, dc->reg_fcr); in interrupt_handler()
1273 dc->last_ier = dc->last_ier | APP2_UL; in interrupt_handler()
1274 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1279 spin_unlock(&dc->spin_mutex); in interrupt_handler()
1282 if (test_and_clear_bit(a, &dc->flip)) { in interrupt_handler()
1283 tty = tty_port_tty_get(&dc->port[a].port); in interrupt_handler()
1291 spin_unlock(&dc->spin_mutex); in interrupt_handler()
1295 static void nozomi_get_card_type(struct nozomi *dc) in nozomi_get_card_type() argument
1301 size += pci_resource_len(dc->pdev, i); in nozomi_get_card_type()
1304 dc->card_type = size == 2048 ? F32_2 : F32_8; in nozomi_get_card_type()
1306 dev_info(&dc->pdev->dev, "Card type is: %d\n", dc->card_type); in nozomi_get_card_type()
1309 static void nozomi_setup_private_data(struct nozomi *dc) in nozomi_setup_private_data() argument
1311 void __iomem *offset = dc->base_addr + dc->card_type / 2; in nozomi_setup_private_data()
1314 dc->reg_fcr = (void __iomem *)(offset + R_FCR); in nozomi_setup_private_data()
1315 dc->reg_iir = (void __iomem *)(offset + R_IIR); in nozomi_setup_private_data()
1316 dc->reg_ier = (void __iomem *)(offset + R_IER); in nozomi_setup_private_data()
1317 dc->last_ier = 0; in nozomi_setup_private_data()
1318 dc->flip = 0; in nozomi_setup_private_data()
1320 dc->port[PORT_MDM].token_dl = MDM_DL; in nozomi_setup_private_data()
1321 dc->port[PORT_DIAG].token_dl = DIAG_DL; in nozomi_setup_private_data()
1322 dc->port[PORT_APP1].token_dl = APP1_DL; in nozomi_setup_private_data()
1323 dc->port[PORT_APP2].token_dl = APP2_DL; in nozomi_setup_private_data()
1326 init_waitqueue_head(&dc->port[i].tty_wait); in nozomi_setup_private_data()
1332 const struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev)); in card_type_show() local
1334 return sprintf(buf, "%d\n", dc->card_type); in card_type_show()
1341 const struct nozomi *dc = pci_get_drvdata(to_pci_dev(dev)); in open_ttys_show() local
1343 return sprintf(buf, "%u\n", dc->open_ttys); in open_ttys_show()
1347 static void make_sysfs_files(struct nozomi *dc) in make_sysfs_files() argument
1349 if (device_create_file(&dc->pdev->dev, &dev_attr_card_type)) in make_sysfs_files()
1350 dev_err(&dc->pdev->dev, in make_sysfs_files()
1352 if (device_create_file(&dc->pdev->dev, &dev_attr_open_ttys)) in make_sysfs_files()
1353 dev_err(&dc->pdev->dev, in make_sysfs_files()
1357 static void remove_sysfs_files(struct nozomi *dc) in remove_sysfs_files() argument
1359 device_remove_file(&dc->pdev->dev, &dev_attr_card_type); in remove_sysfs_files()
1360 device_remove_file(&dc->pdev->dev, &dev_attr_open_ttys); in remove_sysfs_files()
1369 struct nozomi *dc = NULL; in nozomi_card_init() local
1385 dc = kzalloc(sizeof(struct nozomi), GFP_KERNEL); in nozomi_card_init()
1386 if (unlikely(!dc)) { in nozomi_card_init()
1392 dc->pdev = pdev; in nozomi_card_init()
1394 ret = pci_enable_device(dc->pdev); in nozomi_card_init()
1400 ret = pci_request_regions(dc->pdev, NOZOMI_NAME); in nozomi_card_init()
1407 start = pci_resource_start(dc->pdev, 0); in nozomi_card_init()
1415 nozomi_get_card_type(dc); in nozomi_card_init()
1417 dc->base_addr = ioremap_nocache(start, dc->card_type); in nozomi_card_init()
1418 if (!dc->base_addr) { in nozomi_card_init()
1424 dc->send_buf = kmalloc(SEND_BUF_MAX, GFP_KERNEL); in nozomi_card_init()
1425 if (!dc->send_buf) { in nozomi_card_init()
1431 spin_lock_init(&dc->spin_mutex); in nozomi_card_init()
1433 nozomi_setup_private_data(dc); in nozomi_card_init()
1436 dc->last_ier = 0; in nozomi_card_init()
1437 writew(dc->last_ier, dc->reg_ier); in nozomi_card_init()
1440 NOZOMI_NAME, dc); in nozomi_card_init()
1446 DBG1("base_addr: %p", dc->base_addr); in nozomi_card_init()
1448 make_sysfs_files(dc); in nozomi_card_init()
1450 dc->index_start = ndev_idx * MAX_PORT; in nozomi_card_init()
1451 ndevs[ndev_idx] = dc; in nozomi_card_init()
1453 pci_set_drvdata(pdev, dc); in nozomi_card_init()
1456 dc->last_ier = RESET; in nozomi_card_init()
1457 iowrite16(dc->last_ier, dc->reg_ier); in nozomi_card_init()
1459 dc->state = NOZOMI_STATE_ENABLED; in nozomi_card_init()
1462 mutex_init(&dc->port[i].tty_sem); in nozomi_card_init()
1463 tty_port_init(&dc->port[i].port); in nozomi_card_init()
1464 tty_register_device(ntty_driver, dc->index_start + i, in nozomi_card_init()
1470 kfree(dc->send_buf); in nozomi_card_init()
1471 iounmap(dc->base_addr); in nozomi_card_init()
1477 kfree(dc); in nozomi_card_init()
1482 static void __devexit tty_exit(struct nozomi *dc) in tty_exit() argument
1491 struct tty_struct *tty = tty_port_tty_get(&dc->port[i].port); in tty_exit()
1498 while (dc->open_ttys) in tty_exit()
1500 for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) in tty_exit()
1509 struct nozomi *dc = pci_get_drvdata(pdev); in nozomi_card_exit() local
1512 dc->last_ier = 0; in nozomi_card_exit()
1513 writew(dc->last_ier, dc->reg_ier); in nozomi_card_exit()
1515 tty_exit(dc); in nozomi_card_exit()
1526 write_mem32(dc->port[PORT_CTRL].ul_addr[0], (u32 *)&ctrl, 2); in nozomi_card_exit()
1527 writew(CTRL_UL, dc->reg_fcr); /* push the token to the card. */ in nozomi_card_exit()
1529 remove_sysfs_files(dc); in nozomi_card_exit()
1531 free_irq(pdev->irq, dc); in nozomi_card_exit()
1534 if (dc->port[i].fifo_ul) in nozomi_card_exit()
1535 kfifo_free(dc->port[i].fifo_ul); in nozomi_card_exit()
1537 kfree(dc->send_buf); in nozomi_card_exit()
1539 iounmap(dc->base_addr); in nozomi_card_exit()
1545 ndevs[dc->index_start / MAX_PORT] = NULL; in nozomi_card_exit()
1547 kfree(dc); in nozomi_card_exit()
1580 struct nozomi *dc = get_dc_by_tty(tty); in ntty_open() local
1583 if (!port || !dc || dc->state != NOZOMI_STATE_READY) in ntty_open()
1590 dc->open_ttys++; in ntty_open()
1599 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_open()
1600 dc->last_ier = dc->last_ier | port->token_dl; in ntty_open()
1601 writew(dc->last_ier, dc->reg_ier); in ntty_open()
1602 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_open()
1614 struct nozomi *dc = get_dc_by_tty(tty); in ntty_close() local
1619 if (!dc || !nport) in ntty_close()
1627 dc->open_ttys--; in ntty_close()
1633 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_close()
1634 dc->last_ier &= ~(nport->token_dl); in ntty_close()
1635 writew(dc->last_ier, dc->reg_ier); in ntty_close()
1636 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_close()
1649 struct nozomi *dc = get_dc_by_tty(tty); in ntty_write() local
1655 if (!dc || !port) in ntty_write()
1663 dev_err(&dc->pdev->dev, "Would have deadlocked - " in ntty_write()
1676 if (unlikely(dc == NULL)) { in ntty_write()
1681 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_write()
1683 if (port == &(dc->port[PORT_MDM])) { in ntty_write()
1686 enable_transmit_ul(tty->index % MAX_PORT, dc); in ntty_write()
1688 dev_err(&dc->pdev->dev, in ntty_write()
1692 enable_transmit_ul(tty->index % MAX_PORT, dc); in ntty_write()
1694 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_write()
1711 const struct nozomi *dc = get_dc_by_tty(tty); in ntty_write_room() local
1713 if (!dc || !port) in ntty_write_room()
1749 struct nozomi *dc = get_dc_by_tty(tty); in ntty_tiocmset() local
1752 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_tiocmset()
1762 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_tiocmset()
1836 struct nozomi *dc = get_dc_by_tty(tty); in ntty_unthrottle() local
1840 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_unthrottle()
1841 enable_transmit_dl(tty->index % MAX_PORT, dc); in ntty_unthrottle()
1844 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_unthrottle()
1853 struct nozomi *dc = get_dc_by_tty(tty); in ntty_throttle() local
1857 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_throttle()
1859 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_throttle()
1866 struct nozomi *dc = get_dc_by_tty(tty); in ntty_chars_in_buffer() local
1869 if (unlikely(!dc || !port)) { in ntty_chars_in_buffer()
1875 dev_err(&dc->pdev->dev, "No tty open?\n"); in ntty_chars_in_buffer()