Lines Matching refs:icom_port

67 #define ICOM_PORT ((struct icom_port *)port)
140 static inline void trace(struct icom_port *icom_port, char *trace_pt, in trace() argument
143 dev_info(&icom_port->adapter->pci_dev->dev, ":%d:%s - %lx\n", in trace()
144 icom_port->port, trace_pt, trace_data); in trace()
147 static inline void trace(struct icom_port *icom_port, char *trace_pt, unsigned long trace_data) {}; in trace() argument
151 static void free_port_memory(struct icom_port *icom_port) in free_port_memory() argument
153 struct pci_dev *dev = icom_port->adapter->pci_dev; in free_port_memory()
155 trace(icom_port, "RET_PORT_MEM", 0); in free_port_memory()
156 if (icom_port->recv_buf) { in free_port_memory()
157 pci_free_consistent(dev, 4096, icom_port->recv_buf, in free_port_memory()
158 icom_port->recv_buf_pci); in free_port_memory()
159 icom_port->recv_buf = NULL; in free_port_memory()
161 if (icom_port->xmit_buf) { in free_port_memory()
162 pci_free_consistent(dev, 4096, icom_port->xmit_buf, in free_port_memory()
163 icom_port->xmit_buf_pci); in free_port_memory()
164 icom_port->xmit_buf = NULL; in free_port_memory()
166 if (icom_port->statStg) { in free_port_memory()
167 pci_free_consistent(dev, 4096, icom_port->statStg, in free_port_memory()
168 icom_port->statStg_pci); in free_port_memory()
169 icom_port->statStg = NULL; in free_port_memory()
172 if (icom_port->xmitRestart) { in free_port_memory()
173 pci_free_consistent(dev, 4096, icom_port->xmitRestart, in free_port_memory()
174 icom_port->xmitRestart_pci); in free_port_memory()
175 icom_port->xmitRestart = NULL; in free_port_memory()
179 static int __devinit get_port_memory(struct icom_port *icom_port) in get_port_memory() argument
185 struct pci_dev *dev = icom_port->adapter->pci_dev; in get_port_memory()
187 icom_port->xmit_buf = in get_port_memory()
188 pci_alloc_consistent(dev, 4096, &icom_port->xmit_buf_pci); in get_port_memory()
189 if (!icom_port->xmit_buf) { in get_port_memory()
194 trace(icom_port, "GET_PORT_MEM", in get_port_memory()
195 (unsigned long) icom_port->xmit_buf); in get_port_memory()
197 icom_port->recv_buf = in get_port_memory()
198 pci_alloc_consistent(dev, 4096, &icom_port->recv_buf_pci); in get_port_memory()
199 if (!icom_port->recv_buf) { in get_port_memory()
201 free_port_memory(icom_port); in get_port_memory()
204 trace(icom_port, "GET_PORT_MEM", in get_port_memory()
205 (unsigned long) icom_port->recv_buf); in get_port_memory()
207 icom_port->statStg = in get_port_memory()
208 pci_alloc_consistent(dev, 4096, &icom_port->statStg_pci); in get_port_memory()
209 if (!icom_port->statStg) { in get_port_memory()
211 free_port_memory(icom_port); in get_port_memory()
214 trace(icom_port, "GET_PORT_MEM", in get_port_memory()
215 (unsigned long) icom_port->statStg); in get_port_memory()
217 icom_port->xmitRestart = in get_port_memory()
218 pci_alloc_consistent(dev, 4096, &icom_port->xmitRestart_pci); in get_port_memory()
219 if (!icom_port->xmitRestart) { in get_port_memory()
222 free_port_memory(icom_port); in get_port_memory()
226 memset(icom_port->statStg, 0, 4096); in get_port_memory()
232 stgAddr = (unsigned long) icom_port->statStg; in get_port_memory()
234 trace(icom_port, "FOD_ADDR", stgAddr); in get_port_memory()
235 stgAddr = stgAddr + sizeof(icom_port->statStg->xmit[0]); in get_port_memory()
237 memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area)); in get_port_memory()
238 icom_port->statStg->xmit[index].leLengthASD = in get_port_memory()
240 trace(icom_port, "FOD_ADDR", stgAddr); in get_port_memory()
241 trace(icom_port, "FOD_XBUFF", in get_port_memory()
242 (unsigned long) icom_port->xmit_buf); in get_port_memory()
243 icom_port->statStg->xmit[index].leBuffer = in get_port_memory()
244 cpu_to_le32(icom_port->xmit_buf_pci); in get_port_memory()
246 memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area)); in get_port_memory()
247 icom_port->statStg->xmit[index].leLengthASD = in get_port_memory()
249 trace(icom_port, "FOD_XBUFF", in get_port_memory()
250 (unsigned long) icom_port->xmit_buf); in get_port_memory()
251 icom_port->statStg->xmit[index].leBuffer = in get_port_memory()
252 cpu_to_le32(icom_port->xmit_buf_pci); in get_port_memory()
254 memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area)); in get_port_memory()
262 trace(icom_port, "FID_ADDR", stgAddr); in get_port_memory()
263 stgAddr = stgAddr + sizeof(icom_port->statStg->rcv[0]); in get_port_memory()
264 icom_port->statStg->rcv[index].leLength = 0; in get_port_memory()
265 icom_port->statStg->rcv[index].WorkingLength = in get_port_memory()
268 offset = stgAddr - (unsigned long) icom_port->statStg; in get_port_memory()
269 icom_port->statStg->rcv[index].leNext = in get_port_memory()
270 cpu_to_le32(icom_port-> statStg_pci + offset); in get_port_memory()
271 trace(icom_port, "FID_RBUFF", in get_port_memory()
272 (unsigned long) icom_port->recv_buf); in get_port_memory()
273 icom_port->statStg->rcv[index].leBuffer = in get_port_memory()
274 cpu_to_le32(icom_port->recv_buf_pci); in get_port_memory()
276 offset = startStgAddr - (unsigned long) icom_port->statStg; in get_port_memory()
277 icom_port->statStg->rcv[index].leNext = in get_port_memory()
278 cpu_to_le32(icom_port-> statStg_pci + offset); in get_port_memory()
279 trace(icom_port, "FID_RBUFF", in get_port_memory()
280 (unsigned long) icom_port->recv_buf + 2048); in get_port_memory()
281 icom_port->statStg->rcv[index].leBuffer = in get_port_memory()
282 cpu_to_le32(icom_port->recv_buf_pci + 2048); in get_port_memory()
284 icom_port->statStg->rcv[index].leNext = 0; in get_port_memory()
285 icom_port->statStg->rcv[index].leBuffer = 0; in get_port_memory()
292 static void stop_processor(struct icom_port *icom_port) in stop_processor() argument
300 port = icom_port->port; in stop_processor()
302 stop_proc[port].global_control_reg = &icom_port->global_reg->control; in stop_processor()
304 stop_proc[port].global_control_reg = &icom_port->global_reg->control_2; in stop_processor()
316 dev_err(&icom_port->adapter->pci_dev->dev, in stop_processor()
323 static void start_processor(struct icom_port *icom_port) in start_processor() argument
331 port = icom_port->port; in start_processor()
333 start_proc[port].global_control_reg = &icom_port->global_reg->control; in start_processor()
335 start_proc[port].global_control_reg = &icom_port->global_reg->control_2; in start_processor()
345 dev_err(&icom_port->adapter->pci_dev->dev, in start_processor()
352 static void load_code(struct icom_port *icom_port) in load_code() argument
358 void __iomem *dram_ptr = icom_port->dram; in load_code()
362 struct pci_dev *dev = icom_port->adapter->pci_dev; in load_code()
365 writew(0x3FFF, icom_port->int_reg); in load_code()
367 trace(icom_port, "CLEAR_INTERRUPTS", 0); in load_code()
370 stop_processor(icom_port); in load_code()
389 iram_ptr = (char __iomem *)icom_port->dram + ICOM_IRAM_OFFSET; in load_code()
409 iram_ptr = (char __iomem *) icom_port->dram + ICOM_IRAM_OFFSET; in load_code()
416 if (icom_port->adapter->version == ADAPTER_V2) in load_code()
417 writeb(V2_HARDWARE, &(icom_port->dram->misc_flags)); in load_code()
420 start_processor(icom_port); in load_code()
423 &(icom_port->dram->HDLCConfigReg)); in load_code()
424 writeb(0x04, &(icom_port->dram->FlagFillIdleTimer)); /* 0.5 seconds */ in load_code()
425 writeb(0x00, &(icom_port->dram->CmdReg)); in load_code()
426 writeb(0x10, &(icom_port->dram->async_config3)); in load_code()
428 ICOM_ACFG_1STOP_BIT), &(icom_port->dram->async_config2)); in load_code()
459 writeb((char) ((fw->size + 16)/16), &icom_port->dram->mac_length); in load_code()
460 writel(temp_pci, &icom_port->dram->mac_load_addr); in load_code()
471 writeb(START_DOWNLOAD, &icom_port->dram->sync); in load_code()
476 if (readb(&icom_port->dram->misc_flags) & ICOM_HDW_ACTIVE) in load_code()
486 cable_id = readb(&icom_port->dram->cable_id); in load_code()
491 icom_port->cable_id = cable_id; in load_code()
494 icom_port->cable_id = NO_CABLE; in load_code()
501 writew(0x3FFF, icom_port->int_reg); in load_code()
504 writeb(ICOM_DISABLE, &(icom_port->dram->disable)); in load_code()
507 stop_processor(icom_port); in load_code()
509 dev_err(&icom_port->adapter->pci_dev->dev,"Port not opertional\n"); in load_code()
516 static int startup(struct icom_port *icom_port) in startup() argument
523 trace(icom_port, "STARTUP", 0); in startup()
525 if (!icom_port->dram) { in startup()
527 dev_err(&icom_port->adapter->pci_dev->dev, in startup()
535 raw_cable_id = readb(&icom_port->dram->cable_id); in startup()
536 trace(icom_port, "CABLE_ID", raw_cable_id); in startup()
543 (cable_id != icom_port->cable_id)) { in startup()
546 load_code(icom_port); in startup()
549 raw_cable_id = readb(&icom_port->dram->cable_id); in startup()
552 (icom_port->cable_id == NO_CABLE)) in startup()
560 port = icom_port->port; in startup()
562 int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask; in startup()
564 int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask_2; in startup()
567 writew(0x00FF, icom_port->int_reg); in startup()
569 writew(0x3F00, icom_port->int_reg); in startup()
577 dev_err(&icom_port->adapter->pci_dev->dev, in startup()
585 static void shutdown(struct icom_port *icom_port) in shutdown() argument
593 trace(icom_port, "SHUTDOWN", 0); in shutdown()
598 port = icom_port->port; in shutdown()
600 int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask; in shutdown()
602 int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask_2; in shutdown()
611 dev_err(&icom_port->adapter->pci_dev->dev, in shutdown()
619 cmdReg = readb(&icom_port->dram->CmdReg); in shutdown()
621 writeb(cmdReg & ~CMD_SND_BREAK, &icom_port->dram->CmdReg); in shutdown()
673 static inline void check_modem_status(struct icom_port *icom_port) in check_modem_status() argument
679 spin_lock(&icom_port->uart_port.lock); in check_modem_status()
682 status = readb(&icom_port->dram->isr); in check_modem_status()
683 trace(icom_port, "CHECK_MODEM", status); in check_modem_status()
687 icom_port->uart_port.icount.rng++; in check_modem_status()
689 icom_port->uart_port.icount.dsr++; in check_modem_status()
691 uart_handle_dcd_change(&icom_port->uart_port, in check_modem_status()
694 uart_handle_cts_change(&icom_port->uart_port, in check_modem_status()
697 wake_up_interruptible(&icom_port->uart_port.state-> in check_modem_status()
701 spin_unlock(&icom_port->uart_port.lock); in check_modem_status()
704 static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port) in xmit_interrupt() argument
710 trace(icom_port, "XMIT_COMPLETE", 0); in xmit_interrupt()
713 icom_port->statStg->xmit[0].flags &= in xmit_interrupt()
717 cpu_to_le16(icom_port->statStg->xmit[0].leLength); in xmit_interrupt()
718 icom_port->uart_port.icount.tx += count; in xmit_interrupt()
721 !uart_circ_empty(&icom_port->uart_port.state->xmit); i++) { in xmit_interrupt()
723 icom_port->uart_port.state->xmit.tail++; in xmit_interrupt()
724 icom_port->uart_port.state->xmit.tail &= in xmit_interrupt()
728 if (!icom_write(&icom_port->uart_port)) in xmit_interrupt()
730 uart_write_wakeup(&icom_port->uart_port); in xmit_interrupt()
732 trace(icom_port, "XMIT_DISABLED", 0); in xmit_interrupt()
735 static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) in recv_interrupt() argument
738 struct tty_struct *tty = icom_port->uart_port.state->port.tty; in recv_interrupt()
744 trace(icom_port, "RCV_COMPLETE", 0); in recv_interrupt()
745 rcv_buff = icom_port->next_rcv; in recv_interrupt()
747 status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); in recv_interrupt()
751 trace(icom_port, "FID_STATUS", status); in recv_interrupt()
752 count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); in recv_interrupt()
754 trace(icom_port, "RCV_COUNT", count); in recv_interrupt()
756 trace(icom_port, "REAL_COUNT", count); in recv_interrupt()
759 cpu_to_le32(icom_port->statStg->rcv[rcv_buff].leBuffer) - in recv_interrupt()
760 icom_port->recv_buf_pci; in recv_interrupt()
764 first = icom_port->recv_buf[offset]; in recv_interrupt()
765 tty_insert_flip_string(tty, icom_port->recv_buf + offset, count - 1); in recv_interrupt()
768 icount = &icom_port->uart_port.icount; in recv_interrupt()
776 trace(icom_port, "BREAK_DET", 0); in recv_interrupt()
799 if (status & icom_port->ignore_status_mask) { in recv_interrupt()
800 trace(icom_port, "IGNORE_CHAR", 0); in recv_interrupt()
804 status &= icom_port->read_status_mask; in recv_interrupt()
809 trace(icom_port, "PARITY_ERROR", 0); in recv_interrupt()
816 tty_insert_flip_char(tty, *(icom_port->recv_buf + offset + count - 1), flag); in recv_interrupt()
826 icom_port->statStg->rcv[rcv_buff].flags = 0; in recv_interrupt()
827 icom_port->statStg->rcv[rcv_buff].leLength = 0; in recv_interrupt()
828 icom_port->statStg->rcv[rcv_buff].WorkingLength = in recv_interrupt()
835 status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); in recv_interrupt()
837 icom_port->next_rcv = rcv_buff; in recv_interrupt()
842 struct icom_port *icom_port) in process_interrupt() argument
845 spin_lock(&icom_port->uart_port.lock); in process_interrupt()
846 trace(icom_port, "INTERRUPT", port_int_reg); in process_interrupt()
849 xmit_interrupt(port_int_reg, icom_port); in process_interrupt()
852 recv_interrupt(port_int_reg, icom_port); in process_interrupt()
854 spin_unlock(&icom_port->uart_port.lock); in process_interrupt()
863 struct icom_port *icom_port; in icom_interrupt() local
875 icom_port = &icom_adapter->port_info[2]; in icom_interrupt()
877 process_interrupt(port_int_reg, icom_port); in icom_interrupt()
878 check_modem_status(icom_port); in icom_interrupt()
882 icom_port = &icom_adapter->port_info[3]; in icom_interrupt()
883 if (icom_port->status == ICOM_PORT_ACTIVE) { in icom_interrupt()
886 process_interrupt(port_int_reg, icom_port); in icom_interrupt()
887 check_modem_status(icom_port); in icom_interrupt()
903 icom_port = &icom_adapter->port_info[0]; in icom_interrupt()
905 process_interrupt(port_int_reg, icom_port); in icom_interrupt()
906 check_modem_status(icom_port); in icom_interrupt()
910 icom_port = &icom_adapter->port_info[1]; in icom_interrupt()
911 if (icom_port->status == ICOM_PORT_ACTIVE) { in icom_interrupt()
913 process_interrupt(port_int_reg, icom_port); in icom_interrupt()
914 check_modem_status(icom_port); in icom_interrupt()
1322 struct icom_port *icom_port; in icom_init_ports() local
1328 icom_port = &icom_adapter->port_info[i]; in icom_init_ports()
1329 icom_port->port = i; in icom_init_ports()
1330 icom_port->status = ICOM_PORT_ACTIVE; in icom_init_ports()
1331 icom_port->imbed_modem = ICOM_UNKNOWN; in icom_init_ports()
1338 icom_port = &icom_adapter->port_info[i]; in icom_init_ports()
1340 icom_port->port = i; in icom_init_ports()
1341 icom_port->status = ICOM_PORT_ACTIVE; in icom_init_ports()
1342 icom_port->imbed_modem = ICOM_IMBED_MODEM; in icom_init_ports()
1369 static void icom_port_active(struct icom_port *icom_port, struct icom_adapter *icom_adapter, int po… in icom_port_active() argument
1372 icom_port->global_reg = icom_adapter->base_addr + 0x4000; in icom_port_active()
1373 icom_port->int_reg = icom_adapter->base_addr + in icom_port_active()
1376 icom_port->global_reg = icom_adapter->base_addr + 0x8000; in icom_port_active()
1377 if (icom_port->port < 2) in icom_port_active()
1378 icom_port->int_reg = icom_adapter->base_addr + in icom_port_active()
1379 0x8004 + 2 - 2 * icom_port->port; in icom_port_active()
1381 icom_port->int_reg = icom_adapter->base_addr + in icom_port_active()
1382 0x8024 + 2 - 2 * (icom_port->port - 2); in icom_port_active()
1387 struct icom_port *icom_port; in icom_load_ports() local
1392 icom_port = &icom_adapter->port_info[port_num]; in icom_load_ports()
1394 if (icom_port->status == ICOM_PORT_ACTIVE) { in icom_load_ports()
1395 icom_port_active(icom_port, icom_adapter, port_num); in icom_load_ports()
1396 icom_port->dram = icom_adapter->base_addr + in icom_load_ports()
1397 0x2000 * icom_port->port; in icom_load_ports()
1399 icom_port->adapter = icom_adapter; in icom_load_ports()
1402 if (get_port_memory(icom_port) != 0) { in icom_load_ports()
1403 dev_err(&icom_port->adapter->pci_dev->dev, in icom_load_ports()
1451 struct icom_port *icom_port; in icom_remove_adapter() local
1455 icom_port = &icom_adapter->port_info[index]; in icom_remove_adapter()
1457 if (icom_port->status == ICOM_PORT_ACTIVE) { in icom_remove_adapter()
1462 &icom_port->uart_port); in icom_remove_adapter()
1465 writeb(0x00, &icom_port->dram->osr); in icom_remove_adapter()
1471 stop_processor(icom_port); in icom_remove_adapter()
1473 free_port_memory(icom_port); in icom_remove_adapter()
1498 struct icom_port *icom_port; in icom_probe() local
1565 icom_port = &icom_adapter->port_info[index]; in icom_probe()
1567 if (icom_port->status == ICOM_PORT_ACTIVE) { in icom_probe()
1568 icom_port->uart_port.irq = icom_port->adapter->pci_dev->irq; in icom_probe()
1569 icom_port->uart_port.type = PORT_ICOM; in icom_probe()
1570 icom_port->uart_port.iotype = UPIO_MEM; in icom_probe()
1571 icom_port->uart_port.membase = in icom_probe()
1573 icom_port->uart_port.fifosize = 16; in icom_probe()
1574 icom_port->uart_port.ops = &icom_ops; in icom_probe()
1575 icom_port->uart_port.line = in icom_probe()
1576 icom_port->port + icom_adapter->index * 4; in icom_probe()
1577 if (uart_add_one_port (&icom_uart_driver, &icom_port->uart_port)) { in icom_probe()
1578 icom_port->status = ICOM_PORT_OFF; in icom_probe()