Lines Matching full:dc
331 struct nozomi *dc; member
479 static void nozomi_setup_memory(struct nozomi *dc) in nozomi_setup_memory() argument
481 void __iomem *offset = dc->base_addr + dc->config_table.dl_start; in nozomi_setup_memory()
488 dc->port[PORT_MDM].dl_addr[CH_A] = offset; in nozomi_setup_memory()
489 dc->port[PORT_MDM].dl_addr[CH_B] = in nozomi_setup_memory()
490 (offset += dc->config_table.dl_mdm_len1); in nozomi_setup_memory()
491 dc->port[PORT_MDM].dl_size[CH_A] = in nozomi_setup_memory()
492 dc->config_table.dl_mdm_len1 - buff_offset; in nozomi_setup_memory()
493 dc->port[PORT_MDM].dl_size[CH_B] = in nozomi_setup_memory()
494 dc->config_table.dl_mdm_len2 - buff_offset; in nozomi_setup_memory()
497 dc->port[PORT_DIAG].dl_addr[CH_A] = in nozomi_setup_memory()
498 (offset += dc->config_table.dl_mdm_len2); in nozomi_setup_memory()
499 dc->port[PORT_DIAG].dl_size[CH_A] = in nozomi_setup_memory()
500 dc->config_table.dl_diag_len1 - buff_offset; in nozomi_setup_memory()
501 dc->port[PORT_DIAG].dl_addr[CH_B] = in nozomi_setup_memory()
502 (offset += dc->config_table.dl_diag_len1); in nozomi_setup_memory()
503 dc->port[PORT_DIAG].dl_size[CH_B] = in nozomi_setup_memory()
504 dc->config_table.dl_diag_len2 - buff_offset; in nozomi_setup_memory()
507 dc->port[PORT_APP1].dl_addr[CH_A] = in nozomi_setup_memory()
508 (offset += dc->config_table.dl_diag_len2); in nozomi_setup_memory()
509 dc->port[PORT_APP1].dl_size[CH_A] = in nozomi_setup_memory()
510 dc->config_table.dl_app1_len - buff_offset; in nozomi_setup_memory()
513 dc->port[PORT_APP2].dl_addr[CH_A] = in nozomi_setup_memory()
514 (offset += dc->config_table.dl_app1_len); in nozomi_setup_memory()
515 dc->port[PORT_APP2].dl_size[CH_A] = in nozomi_setup_memory()
516 dc->config_table.dl_app2_len - buff_offset; in nozomi_setup_memory()
519 dc->port[PORT_CTRL].dl_addr[CH_A] = in nozomi_setup_memory()
520 (offset += dc->config_table.dl_app2_len); in nozomi_setup_memory()
521 dc->port[PORT_CTRL].dl_size[CH_A] = in nozomi_setup_memory()
522 dc->config_table.dl_ctrl_len - buff_offset; in nozomi_setup_memory()
524 offset = dc->base_addr + dc->config_table.ul_start; in nozomi_setup_memory()
527 dc->port[PORT_MDM].ul_addr[CH_A] = offset; in nozomi_setup_memory()
528 dc->port[PORT_MDM].ul_size[CH_A] = in nozomi_setup_memory()
529 dc->config_table.ul_mdm_len1 - buff_offset; in nozomi_setup_memory()
530 dc->port[PORT_MDM].ul_addr[CH_B] = in nozomi_setup_memory()
531 (offset += dc->config_table.ul_mdm_len1); in nozomi_setup_memory()
532 dc->port[PORT_MDM].ul_size[CH_B] = in nozomi_setup_memory()
533 dc->config_table.ul_mdm_len2 - buff_offset; in nozomi_setup_memory()
536 dc->port[PORT_DIAG].ul_addr[CH_A] = in nozomi_setup_memory()
537 (offset += dc->config_table.ul_mdm_len2); in nozomi_setup_memory()
538 dc->port[PORT_DIAG].ul_size[CH_A] = in nozomi_setup_memory()
539 dc->config_table.ul_diag_len - buff_offset; in nozomi_setup_memory()
542 dc->port[PORT_APP1].ul_addr[CH_A] = in nozomi_setup_memory()
543 (offset += dc->config_table.ul_diag_len); in nozomi_setup_memory()
544 dc->port[PORT_APP1].ul_size[CH_A] = in nozomi_setup_memory()
545 dc->config_table.ul_app1_len - buff_offset; in nozomi_setup_memory()
548 dc->port[PORT_APP2].ul_addr[CH_A] = in nozomi_setup_memory()
549 (offset += dc->config_table.ul_app1_len); in nozomi_setup_memory()
550 dc->port[PORT_APP2].ul_size[CH_A] = in nozomi_setup_memory()
551 dc->config_table.ul_app2_len - buff_offset; in nozomi_setup_memory()
554 dc->port[PORT_CTRL].ul_addr[CH_A] = in nozomi_setup_memory()
555 (offset += dc->config_table.ul_app2_len); in nozomi_setup_memory()
556 dc->port[PORT_CTRL].ul_size[CH_A] = in nozomi_setup_memory()
557 dc->config_table.ul_ctrl_len - buff_offset; in nozomi_setup_memory()
562 static void dump_table(const struct nozomi *dc) in dump_table() argument
564 DBG3("signature: 0x%08X", dc->config_table.signature); in dump_table()
565 DBG3("version: 0x%04X", dc->config_table.version); in dump_table()
567 dc->config_table.product_information); in dump_table()
568 DBG3("toggle enabled: %d", dc->config_table.toggle.enabled); in dump_table()
569 DBG3("toggle up_mdm: %d", dc->config_table.toggle.mdm_ul); in dump_table()
570 DBG3("toggle dl_mdm: %d", dc->config_table.toggle.mdm_dl); in dump_table()
571 DBG3("toggle dl_dbg: %d", dc->config_table.toggle.diag_dl); in dump_table()
573 DBG3("dl_start: 0x%04X", dc->config_table.dl_start); in dump_table()
574 DBG3("dl_mdm_len0: 0x%04X, %d", dc->config_table.dl_mdm_len1, in dump_table()
575 dc->config_table.dl_mdm_len1); in dump_table()
576 DBG3("dl_mdm_len1: 0x%04X, %d", dc->config_table.dl_mdm_len2, in dump_table()
577 dc->config_table.dl_mdm_len2); in dump_table()
578 DBG3("dl_diag_len0: 0x%04X, %d", dc->config_table.dl_diag_len1, in dump_table()
579 dc->config_table.dl_diag_len1); in dump_table()
580 DBG3("dl_diag_len1: 0x%04X, %d", dc->config_table.dl_diag_len2, in dump_table()
581 dc->config_table.dl_diag_len2); in dump_table()
582 DBG3("dl_app1_len: 0x%04X, %d", dc->config_table.dl_app1_len, in dump_table()
583 dc->config_table.dl_app1_len); in dump_table()
584 DBG3("dl_app2_len: 0x%04X, %d", dc->config_table.dl_app2_len, in dump_table()
585 dc->config_table.dl_app2_len); in dump_table()
586 DBG3("dl_ctrl_len: 0x%04X, %d", dc->config_table.dl_ctrl_len, in dump_table()
587 dc->config_table.dl_ctrl_len); in dump_table()
588 DBG3("ul_start: 0x%04X, %d", dc->config_table.ul_start, in dump_table()
589 dc->config_table.ul_start); in dump_table()
590 DBG3("ul_mdm_len[0]: 0x%04X, %d", dc->config_table.ul_mdm_len1, in dump_table()
591 dc->config_table.ul_mdm_len1); in dump_table()
592 DBG3("ul_mdm_len[1]: 0x%04X, %d", dc->config_table.ul_mdm_len2, in dump_table()
593 dc->config_table.ul_mdm_len2); in dump_table()
594 DBG3("ul_diag_len: 0x%04X, %d", dc->config_table.ul_diag_len, in dump_table()
595 dc->config_table.ul_diag_len); in dump_table()
596 DBG3("ul_app1_len: 0x%04X, %d", dc->config_table.ul_app1_len, in dump_table()
597 dc->config_table.ul_app1_len); in dump_table()
598 DBG3("ul_app2_len: 0x%04X, %d", dc->config_table.ul_app2_len, in dump_table()
599 dc->config_table.ul_app2_len); in dump_table()
600 DBG3("ul_ctrl_len: 0x%04X, %d", dc->config_table.ul_ctrl_len, in dump_table()
601 dc->config_table.ul_ctrl_len); in dump_table()
604 static inline void dump_table(const struct nozomi *dc) { } in dump_table() argument
611 static int nozomi_read_config_table(struct nozomi *dc) in nozomi_read_config_table() argument
613 read_mem32((u32 *) &dc->config_table, dc->base_addr + 0, in nozomi_read_config_table()
616 if (dc->config_table.signature != NOZOMI_CONFIG_MAGIC) { in nozomi_read_config_table()
617 dev_err(&dc->pdev->dev, "ConfigTable Bad! 0x%08X != 0x%08X\n", in nozomi_read_config_table()
618 dc->config_table.signature, NOZOMI_CONFIG_MAGIC); in nozomi_read_config_table()
622 if ((dc->config_table.version == 0) in nozomi_read_config_table()
623 || (dc->config_table.toggle.enabled == TOGGLE_VALID)) { in nozomi_read_config_table()
627 nozomi_setup_memory(dc); in nozomi_read_config_table()
629 dc->port[PORT_MDM].toggle_ul = dc->config_table.toggle.mdm_ul; in nozomi_read_config_table()
630 dc->port[PORT_MDM].toggle_dl = dc->config_table.toggle.mdm_dl; in nozomi_read_config_table()
631 dc->port[PORT_DIAG].toggle_dl = dc->config_table.toggle.diag_dl; in nozomi_read_config_table()
633 dc->port[PORT_MDM].toggle_ul, in nozomi_read_config_table()
634 dc->port[PORT_MDM].toggle_dl, dc->port[PORT_DIAG].toggle_dl); in nozomi_read_config_table()
636 dump_table(dc); in nozomi_read_config_table()
639 memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl)); in nozomi_read_config_table()
640 memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul)); in nozomi_read_config_table()
644 dc->last_ier = dc->last_ier | CTRL_DL; in nozomi_read_config_table()
645 writew(dc->last_ier, dc->reg_ier); in nozomi_read_config_table()
647 dc->state = NOZOMI_STATE_ALLOCATED; in nozomi_read_config_table()
648 dev_info(&dc->pdev->dev, "Initialization OK!\n"); in nozomi_read_config_table()
652 if ((dc->config_table.version > 0) in nozomi_read_config_table()
653 && (dc->config_table.toggle.enabled != TOGGLE_VALID)) { in nozomi_read_config_table()
657 dev_info(&dc->pdev->dev, "Version of card: %d\n", in nozomi_read_config_table()
658 dc->config_table.version); in nozomi_read_config_table()
661 nozomi_setup_memory(dc); in nozomi_read_config_table()
669 write_mem32(dc->port[PORT_MDM].ul_addr[CH_A], in nozomi_read_config_table()
671 write_mem32(dc->port[PORT_MDM].ul_addr[CH_B], in nozomi_read_config_table()
674 writew(MDM_UL | DIAG_DL | MDM_DL, dc->reg_fcr); in nozomi_read_config_table()
683 static void enable_transmit_ul(enum port_type port, struct nozomi *dc) in enable_transmit_ul() argument
688 dc->last_ier |= mask[port]; in enable_transmit_ul()
689 writew(dc->last_ier, dc->reg_ier); in enable_transmit_ul()
691 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in enable_transmit_ul()
696 static void disable_transmit_ul(enum port_type port, struct nozomi *dc) in disable_transmit_ul() argument
702 dc->last_ier &= mask[port]; in disable_transmit_ul()
703 writew(dc->last_ier, dc->reg_ier); in disable_transmit_ul()
705 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in disable_transmit_ul()
710 static void enable_transmit_dl(enum port_type port, struct nozomi *dc) in enable_transmit_dl() argument
715 dc->last_ier |= mask[port]; in enable_transmit_dl()
716 writew(dc->last_ier, dc->reg_ier); in enable_transmit_dl()
718 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in enable_transmit_dl()
723 static void disable_transmit_dl(enum port_type port, struct nozomi *dc) in disable_transmit_dl() argument
729 dc->last_ier &= mask[port]; in disable_transmit_dl()
730 writew(dc->last_ier, dc->reg_ier); in disable_transmit_dl()
732 dev_err(&dc->pdev->dev, "Called with wrong port?\n"); in disable_transmit_dl()
740 static int send_data(enum port_type index, struct nozomi *dc) in send_data() argument
743 struct port *port = &dc->port[index]; in send_data()
749 size = kfifo_out(&port->fifo_ul, dc->send_buf, in send_data()
761 write_mem32(addr + 4, (u32 *) dc->send_buf, size); in send_data()
769 static int receive_data(enum port_type index, struct nozomi *dc) in receive_data() argument
774 struct port *port = &dc->port[index]; in receive_data()
786 disable_transmit_dl(index, dc); in receive_data()
792 dev_err(&dc->pdev->dev, "size == 0?\n"); in receive_data()
814 set_bit(index, &dc->flip); in receive_data()
870 static int receive_flow_control(struct nozomi *dc) in receive_flow_control() argument
877 read_mem32((u32 *) &ctrl_dl, dc->port[PORT_CTRL].dl_addr[CH_A], 2); in receive_flow_control()
900 if (dc->state == NOZOMI_STATE_ALLOCATED) { in receive_flow_control()
905 dc->state = NOZOMI_STATE_READY; in receive_flow_control()
906 dev_info(&dc->pdev->dev, "Device READY!\n"); in receive_flow_control()
910 dev_err(&dc->pdev->dev, in receive_flow_control()
915 DBG1("0x%04X->0x%04X", *((u16 *)&dc->port[port].ctrl_dl), in receive_flow_control()
918 old_ctrl = dc->port[port].ctrl_dl; in receive_flow_control()
919 dc->port[port].ctrl_dl = ctrl_dl; in receive_flow_control()
924 disable_transmit_ul(port, dc); in receive_flow_control()
928 if (kfifo_len(&dc->port[port].fifo_ul)) { in receive_flow_control()
932 kfifo_len(&dc->port[port].fifo_ul)); in receive_flow_control()
933 enable_transmit_ul(port, dc); in receive_flow_control()
945 dc->port[port].tty_icount.cts++; in receive_flow_control()
947 dc->port[port].tty_icount.dsr++; in receive_flow_control()
949 dc->port[port].tty_icount.rng++; in receive_flow_control()
951 dc->port[port].tty_icount.dcd++; in receive_flow_control()
953 wake_up_interruptible(&dc->port[port].tty_wait); in receive_flow_control()
957 dc->port[port].tty_icount.dcd, dc->port[port].tty_icount.cts, in receive_flow_control()
958 dc->port[port].tty_icount.rng, dc->port[port].tty_icount.dsr); in receive_flow_control()
964 const struct nozomi *dc) in port2ctrl() argument
976 dev_err(&dc->pdev->dev, in port2ctrl()
988 static int send_flow_control(struct nozomi *dc) in send_flow_control() argument
994 if (dc->port[i].update_flow_control) { in send_flow_control()
999 dc->port[i].ctrl_ul.port = port2ctrl(i, dc); in send_flow_control()
1000 ctrl = (u16 *)&dc->port[i].ctrl_ul; in send_flow_control()
1001 write_mem32(dc->port[PORT_CTRL].ul_addr[0], \ in send_flow_control()
1003 dc->port[i].update_flow_control = 0; in send_flow_control()
1015 static int handle_data_dl(struct nozomi *dc, enum port_type port, u8 *toggle, in handle_data_dl() argument
1019 if (receive_data(port, dc)) { in handle_data_dl()
1020 writew(mask1, dc->reg_fcr); in handle_data_dl()
1025 if (receive_data(port, dc)) { in handle_data_dl()
1026 writew(mask2, dc->reg_fcr); in handle_data_dl()
1031 if (receive_data(port, dc)) { in handle_data_dl()
1032 writew(mask2, dc->reg_fcr); in handle_data_dl()
1037 if (receive_data(port, dc)) { in handle_data_dl()
1038 writew(mask1, dc->reg_fcr); in handle_data_dl()
1043 dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n", in handle_data_dl()
1055 static int handle_data_ul(struct nozomi *dc, enum port_type port, u16 read_iir) in handle_data_ul() argument
1057 u8 *toggle = &(dc->port[port].toggle_ul); in handle_data_ul()
1060 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1061 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1062 if (send_data(port, dc)) { in handle_data_ul()
1063 writew(MDM_UL1, dc->reg_fcr); in handle_data_ul()
1064 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1065 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1070 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1071 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1072 if (send_data(port, dc)) { in handle_data_ul()
1073 writew(MDM_UL2, dc->reg_fcr); in handle_data_ul()
1074 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1075 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1081 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1082 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1083 if (send_data(port, dc)) { in handle_data_ul()
1084 writew(MDM_UL2, dc->reg_fcr); in handle_data_ul()
1085 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1086 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1091 dc->last_ier &= ~MDM_UL; in handle_data_ul()
1092 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1093 if (send_data(port, dc)) { in handle_data_ul()
1094 writew(MDM_UL1, dc->reg_fcr); in handle_data_ul()
1095 dc->last_ier = dc->last_ier | MDM_UL; in handle_data_ul()
1096 writew(dc->last_ier, dc->reg_ier); in handle_data_ul()
1101 writew(read_iir & MDM_UL, dc->reg_fcr); in handle_data_ul()
1102 dev_err(&dc->pdev->dev, "port out of sync!\n"); in handle_data_ul()
1110 struct nozomi *dc = dev_id; in interrupt_handler() local
1114 if (!dc) in interrupt_handler()
1117 spin_lock(&dc->spin_mutex); in interrupt_handler()
1118 read_iir = readw(dc->reg_iir); in interrupt_handler()
1125 * (by masking with dc->last_ier) in interrupt_handler()
1127 read_iir &= dc->last_ier; in interrupt_handler()
1134 dc->last_ier); in interrupt_handler()
1137 if (unlikely(!nozomi_read_config_table(dc))) { in interrupt_handler()
1138 dc->last_ier = 0x0; in interrupt_handler()
1139 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1140 dev_err(&dc->pdev->dev, "Could not read status from " in interrupt_handler()
1143 writew(RESET, dc->reg_fcr); in interrupt_handler()
1150 dc->last_ier &= ~CTRL_UL; in interrupt_handler()
1151 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1152 if (send_flow_control(dc)) { in interrupt_handler()
1153 writew(CTRL_UL, dc->reg_fcr); in interrupt_handler()
1154 dc->last_ier = dc->last_ier | CTRL_UL; in interrupt_handler()
1155 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1159 receive_flow_control(dc); in interrupt_handler()
1160 writew(CTRL_DL, dc->reg_fcr); in interrupt_handler()
1163 if (!handle_data_dl(dc, PORT_MDM, in interrupt_handler()
1164 &(dc->port[PORT_MDM].toggle_dl), read_iir, in interrupt_handler()
1166 dev_err(&dc->pdev->dev, "MDM_DL out of sync!\n"); in interrupt_handler()
1171 if (!handle_data_ul(dc, PORT_MDM, read_iir)) { in interrupt_handler()
1172 dev_err(&dc->pdev->dev, "MDM_UL out of sync!\n"); in interrupt_handler()
1177 if (!handle_data_dl(dc, PORT_DIAG, in interrupt_handler()
1178 &(dc->port[PORT_DIAG].toggle_dl), read_iir, in interrupt_handler()
1180 dev_err(&dc->pdev->dev, "DIAG_DL out of sync!\n"); in interrupt_handler()
1185 dc->last_ier &= ~DIAG_UL; in interrupt_handler()
1186 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1187 if (send_data(PORT_DIAG, dc)) { in interrupt_handler()
1188 writew(DIAG_UL, dc->reg_fcr); in interrupt_handler()
1189 dc->last_ier = dc->last_ier | DIAG_UL; in interrupt_handler()
1190 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1194 if (receive_data(PORT_APP1, dc)) in interrupt_handler()
1195 writew(APP1_DL, dc->reg_fcr); in interrupt_handler()
1198 dc->last_ier &= ~APP1_UL; in interrupt_handler()
1199 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1200 if (send_data(PORT_APP1, dc)) { in interrupt_handler()
1201 writew(APP1_UL, dc->reg_fcr); in interrupt_handler()
1202 dc->last_ier = dc->last_ier | APP1_UL; in interrupt_handler()
1203 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1207 if (receive_data(PORT_APP2, dc)) in interrupt_handler()
1208 writew(APP2_DL, dc->reg_fcr); in interrupt_handler()
1211 dc->last_ier &= ~APP2_UL; in interrupt_handler()
1212 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1213 if (send_data(PORT_APP2, dc)) { in interrupt_handler()
1214 writew(APP2_UL, dc->reg_fcr); in interrupt_handler()
1215 dc->last_ier = dc->last_ier | APP2_UL; in interrupt_handler()
1216 writew(dc->last_ier, dc->reg_ier); in interrupt_handler()
1221 spin_unlock(&dc->spin_mutex); in interrupt_handler()
1224 if (test_and_clear_bit(a, &dc->flip)) in interrupt_handler()
1225 tty_flip_buffer_push(&dc->port[a].port); in interrupt_handler()
1229 spin_unlock(&dc->spin_mutex); in interrupt_handler()
1233 static void nozomi_get_card_type(struct nozomi *dc) in nozomi_get_card_type() argument
1239 size += pci_resource_len(dc->pdev, i); in nozomi_get_card_type()
1242 dc->card_type = size == 2048 ? F32_2 : F32_8; in nozomi_get_card_type()
1244 dev_info(&dc->pdev->dev, "Card type is: %d\n", dc->card_type); in nozomi_get_card_type()
1247 static void nozomi_setup_private_data(struct nozomi *dc) in nozomi_setup_private_data() argument
1249 void __iomem *offset = dc->base_addr + dc->card_type / 2; in nozomi_setup_private_data()
1252 dc->reg_fcr = (void __iomem *)(offset + R_FCR); in nozomi_setup_private_data()
1253 dc->reg_iir = (void __iomem *)(offset + R_IIR); in nozomi_setup_private_data()
1254 dc->reg_ier = (void __iomem *)(offset + R_IER); in nozomi_setup_private_data()
1255 dc->last_ier = 0; in nozomi_setup_private_data()
1256 dc->flip = 0; in nozomi_setup_private_data()
1258 dc->port[PORT_MDM].token_dl = MDM_DL; in nozomi_setup_private_data()
1259 dc->port[PORT_DIAG].token_dl = DIAG_DL; in nozomi_setup_private_data()
1260 dc->port[PORT_APP1].token_dl = APP1_DL; in nozomi_setup_private_data()
1261 dc->port[PORT_APP2].token_dl = APP2_DL; in nozomi_setup_private_data()
1264 init_waitqueue_head(&dc->port[i].tty_wait); in nozomi_setup_private_data()
1270 const struct nozomi *dc = dev_get_drvdata(dev); in card_type_show() local
1272 return sprintf(buf, "%d\n", dc->card_type); in card_type_show()
1279 const struct nozomi *dc = dev_get_drvdata(dev); in open_ttys_show() local
1281 return sprintf(buf, "%u\n", dc->open_ttys); in open_ttys_show()
1285 static void make_sysfs_files(struct nozomi *dc) in make_sysfs_files() argument
1287 if (device_create_file(&dc->pdev->dev, &dev_attr_card_type)) in make_sysfs_files()
1288 dev_err(&dc->pdev->dev, in make_sysfs_files()
1290 if (device_create_file(&dc->pdev->dev, &dev_attr_open_ttys)) in make_sysfs_files()
1291 dev_err(&dc->pdev->dev, in make_sysfs_files()
1295 static void remove_sysfs_files(struct nozomi *dc) in remove_sysfs_files() argument
1297 device_remove_file(&dc->pdev->dev, &dev_attr_card_type); in remove_sysfs_files()
1298 device_remove_file(&dc->pdev->dev, &dev_attr_open_ttys); in remove_sysfs_files()
1306 struct nozomi *dc = NULL; in nozomi_card_init() local
1320 dc = kzalloc(sizeof(struct nozomi), GFP_KERNEL); in nozomi_card_init()
1321 if (unlikely(!dc)) { in nozomi_card_init()
1327 dc->pdev = pdev; in nozomi_card_init()
1329 ret = pci_enable_device(dc->pdev); in nozomi_card_init()
1335 ret = pci_request_regions(dc->pdev, NOZOMI_NAME); in nozomi_card_init()
1343 nozomi_get_card_type(dc); in nozomi_card_init()
1345 dc->base_addr = pci_iomap(dc->pdev, 0, dc->card_type); in nozomi_card_init()
1346 if (!dc->base_addr) { in nozomi_card_init()
1352 dc->send_buf = kmalloc(SEND_BUF_MAX, GFP_KERNEL); in nozomi_card_init()
1353 if (!dc->send_buf) { in nozomi_card_init()
1360 if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_UL, in nozomi_card_init()
1369 spin_lock_init(&dc->spin_mutex); in nozomi_card_init()
1371 nozomi_setup_private_data(dc); in nozomi_card_init()
1374 dc->last_ier = 0; in nozomi_card_init()
1375 writew(dc->last_ier, dc->reg_ier); in nozomi_card_init()
1378 NOZOMI_NAME, dc); in nozomi_card_init()
1384 DBG1("base_addr: %p", dc->base_addr); in nozomi_card_init()
1386 make_sysfs_files(dc); in nozomi_card_init()
1388 dc->index_start = ndev_idx * MAX_PORT; in nozomi_card_init()
1389 ndevs[ndev_idx] = dc; in nozomi_card_init()
1391 pci_set_drvdata(pdev, dc); in nozomi_card_init()
1394 dc->last_ier = RESET; in nozomi_card_init()
1395 iowrite16(dc->last_ier, dc->reg_ier); in nozomi_card_init()
1397 dc->state = NOZOMI_STATE_ENABLED; in nozomi_card_init()
1401 struct port *port = &dc->port[i]; in nozomi_card_init()
1402 port->dc = dc; in nozomi_card_init()
1406 dc->index_start + i, &pdev->dev); in nozomi_card_init()
1420 tty_unregister_device(ntty_driver, dc->index_start + i); in nozomi_card_init()
1421 tty_port_destroy(&dc->port[i].port); in nozomi_card_init()
1423 free_irq(pdev->irq, dc); in nozomi_card_init()
1428 kfifo_free(&dc->port[i].fifo_ul); in nozomi_card_init()
1430 kfree(dc->send_buf); in nozomi_card_init()
1431 iounmap(dc->base_addr); in nozomi_card_init()
1437 kfree(dc); in nozomi_card_init()
1442 static void tty_exit(struct nozomi *dc) in tty_exit() argument
1447 tty_port_tty_hangup(&dc->port[i].port, false); in tty_exit()
1451 while (dc->open_ttys) in tty_exit()
1454 tty_unregister_device(ntty_driver, dc->index_start + i); in tty_exit()
1455 tty_port_destroy(&dc->port[i].port); in tty_exit()
1464 struct nozomi *dc = pci_get_drvdata(pdev); in nozomi_card_exit() local
1467 dc->last_ier = 0; in nozomi_card_exit()
1468 writew(dc->last_ier, dc->reg_ier); in nozomi_card_exit()
1470 tty_exit(dc); in nozomi_card_exit()
1480 /* Setup dc->reg addresses to we can use defines here */ in nozomi_card_exit()
1481 write_mem32(dc->port[PORT_CTRL].ul_addr[0], (u32 *)&ctrl, 2); in nozomi_card_exit()
1482 writew(CTRL_UL, dc->reg_fcr); /* push the token to the card. */ in nozomi_card_exit()
1484 remove_sysfs_files(dc); in nozomi_card_exit()
1486 free_irq(pdev->irq, dc); in nozomi_card_exit()
1489 kfifo_free(&dc->port[i].fifo_ul); in nozomi_card_exit()
1491 kfree(dc->send_buf); in nozomi_card_exit()
1493 iounmap(dc->base_addr); in nozomi_card_exit()
1499 ndevs[dc->index_start / MAX_PORT] = NULL; in nozomi_card_exit()
1501 kfree(dc); in nozomi_card_exit()
1533 struct nozomi *dc = get_dc_by_tty(tty); in ntty_install() local
1535 if (!port || !dc || dc->state != NOZOMI_STATE_READY) in ntty_install()
1551 struct nozomi *dc = port->dc; in ntty_activate() local
1555 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_activate()
1556 dc->last_ier = dc->last_ier | port->token_dl; in ntty_activate()
1557 writew(dc->last_ier, dc->reg_ier); in ntty_activate()
1558 dc->open_ttys++; in ntty_activate()
1559 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_activate()
1573 struct nozomi *dc = port->dc; in ntty_shutdown() local
1577 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_shutdown()
1578 dc->last_ier &= ~(port->token_dl); in ntty_shutdown()
1579 writew(dc->last_ier, dc->reg_ier); in ntty_shutdown()
1580 dc->open_ttys--; in ntty_shutdown()
1581 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_shutdown()
1606 struct nozomi *dc = get_dc_by_tty(tty); in ntty_write() local
1610 if (!dc || !port) in ntty_write()
1615 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_write()
1617 if (port == &(dc->port[PORT_MDM])) { in ntty_write()
1620 enable_transmit_ul(tty->index % MAX_PORT, dc); in ntty_write()
1622 dev_err(&dc->pdev->dev, in ntty_write()
1626 enable_transmit_ul(tty->index % MAX_PORT, dc); in ntty_write()
1628 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_write()
1646 const struct nozomi *dc = get_dc_by_tty(tty); in ntty_write_room() local
1648 if (dc) in ntty_write_room()
1675 struct nozomi *dc = get_dc_by_tty(tty); in ntty_tiocmset() local
1678 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_tiocmset()
1688 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_tiocmset()
1757 struct nozomi *dc = get_dc_by_tty(tty); in ntty_unthrottle() local
1760 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_unthrottle()
1761 enable_transmit_dl(tty->index % MAX_PORT, dc); in ntty_unthrottle()
1764 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_unthrottle()
1773 struct nozomi *dc = get_dc_by_tty(tty); in ntty_throttle() local
1776 spin_lock_irqsave(&dc->spin_mutex, flags); in ntty_throttle()
1778 spin_unlock_irqrestore(&dc->spin_mutex, flags); in ntty_throttle()
1785 struct nozomi *dc = get_dc_by_tty(tty); in ntty_chars_in_buffer() local
1787 if (unlikely(!dc || !port)) in ntty_chars_in_buffer()