Lines Matching +full:broken +full:- +full:save +full:- +full:restore +full:- +full:fw
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
49 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
165 struct TxFifo txfifo; /* transmit fifo -- size will be maxTxCredits */
310 struct device *dev = &edge_serial->serial->dev->dev; in update_edgeport_E2PROM()
318 const struct firmware *fw; in update_edgeport_E2PROM() local
322 switch (edge_serial->product_info.iDownloadFile) { in update_edgeport_E2PROM()
324 fw_name = "edgeport/boot.fw"; in update_edgeport_E2PROM()
327 fw_name = "edgeport/boot2.fw"; in update_edgeport_E2PROM()
333 response = request_ihex_firmware(&fw, fw_name, in update_edgeport_E2PROM()
334 &edge_serial->serial->dev->dev); in update_edgeport_E2PROM()
341 rec = (const struct ihex_binrec *)fw->data; in update_edgeport_E2PROM()
342 BootMajorVersion = rec->data[0]; in update_edgeport_E2PROM()
343 BootMinorVersion = rec->data[1]; in update_edgeport_E2PROM()
344 BootBuildNumber = (rec->data[2] << 8) | rec->data[3]; in update_edgeport_E2PROM()
347 BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) + in update_edgeport_E2PROM()
348 (edge_serial->boot_descriptor.MinorVersion << 16) + in update_edgeport_E2PROM()
349 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber); in update_edgeport_E2PROM()
356 edge_serial->boot_descriptor.MajorVersion, in update_edgeport_E2PROM()
357 edge_serial->boot_descriptor.MinorVersion, in update_edgeport_E2PROM()
358 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); in update_edgeport_E2PROM()
363 edge_serial->boot_descriptor.MajorVersion, in update_edgeport_E2PROM()
364 edge_serial->boot_descriptor.MinorVersion, in update_edgeport_E2PROM()
365 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber), in update_edgeport_E2PROM()
372 Bootaddr = be32_to_cpu(rec->addr); in update_edgeport_E2PROM()
373 response = rom_write(edge_serial->serial, in update_edgeport_E2PROM()
376 be16_to_cpu(rec->len), in update_edgeport_E2PROM()
377 &rec->data[0]); in update_edgeport_E2PROM()
379 dev_err(&edge_serial->serial->dev->dev, in update_edgeport_E2PROM()
382 be16_to_cpu(rec->len)); in update_edgeport_E2PROM()
387 dev_dbg(dev, "Boot Image -- already up to date\n"); in update_edgeport_E2PROM()
389 release_firmware(fw); in update_edgeport_E2PROM()
395 struct device *dev = &edge_serial->serial->dev->dev; in dump_product_info()
399 dev_dbg(dev, " ProductId %x\n", product_info->ProductId); in dump_product_info()
400 dev_dbg(dev, " NumPorts %d\n", product_info->NumPorts); in dump_product_info()
401 dev_dbg(dev, " ProdInfoVer %d\n", product_info->ProdInfoVer); in dump_product_info()
402 dev_dbg(dev, " IsServer %d\n", product_info->IsServer); in dump_product_info()
403 dev_dbg(dev, " IsRS232 %d\n", product_info->IsRS232); in dump_product_info()
404 dev_dbg(dev, " IsRS422 %d\n", product_info->IsRS422); in dump_product_info()
405 dev_dbg(dev, " IsRS485 %d\n", product_info->IsRS485); in dump_product_info()
406 dev_dbg(dev, " RomSize %d\n", product_info->RomSize); in dump_product_info()
407 dev_dbg(dev, " RamSize %d\n", product_info->RamSize); in dump_product_info()
408 dev_dbg(dev, " CpuRev %x\n", product_info->CpuRev); in dump_product_info()
409 dev_dbg(dev, " BoardRev %x\n", product_info->BoardRev); in dump_product_info()
411 product_info->BootMajorVersion, in dump_product_info()
412 product_info->BootMinorVersion, in dump_product_info()
413 le16_to_cpu(product_info->BootBuildNumber)); in dump_product_info()
415 product_info->FirmwareMajorVersion, in dump_product_info()
416 product_info->FirmwareMinorVersion, in dump_product_info()
417 le16_to_cpu(product_info->FirmwareBuildNumber)); in dump_product_info()
419 product_info->ManufactureDescDate[0], in dump_product_info()
420 product_info->ManufactureDescDate[1], in dump_product_info()
421 product_info->ManufactureDescDate[2]+1900); in dump_product_info()
423 product_info->iDownloadFile); in dump_product_info()
424 dev_dbg(dev, " EpicVer %d\n", product_info->EpicVer); in dump_product_info()
429 struct edgeport_product_info *product_info = &edge_serial->product_info; in get_product_info()
433 …product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~I… in get_product_info()
434 product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; in get_product_info()
435 product_info->ProdInfoVer = 0; in get_product_info()
437 product_info->RomSize = edge_serial->manuf_descriptor.RomSize; in get_product_info()
438 product_info->RamSize = edge_serial->manuf_descriptor.RamSize; in get_product_info()
439 product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev; in get_product_info()
440 product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev; in get_product_info()
442 product_info->BootMajorVersion = in get_product_info()
443 edge_serial->boot_descriptor.MajorVersion; in get_product_info()
444 product_info->BootMinorVersion = in get_product_info()
445 edge_serial->boot_descriptor.MinorVersion; in get_product_info()
446 product_info->BootBuildNumber = in get_product_info()
447 edge_serial->boot_descriptor.BuildNumber; in get_product_info()
449 memcpy(product_info->ManufactureDescDate, in get_product_info()
450 edge_serial->manuf_descriptor.DescDate, in get_product_info()
451 sizeof(edge_serial->manuf_descriptor.DescDate)); in get_product_info()
454 if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) in get_product_info()
456 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; in get_product_info()
458 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; in get_product_info()
461 switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) { in get_product_info()
473 product_info->IsRS232 = 1; in get_product_info()
477 product_info->IsRS422 = 1; in get_product_info()
478 product_info->IsRS485 = 1; in get_product_info()
483 product_info->IsRS422 = 1; in get_product_info()
493 struct usb_serial *serial = ep->serial; in get_epic_descriptor()
494 struct edgeport_product_info *product_info = &ep->product_info; in get_epic_descriptor()
497 struct device *dev = &serial->dev->dev; in get_epic_descriptor()
499 ep->is_epic = 0; in get_epic_descriptor()
503 return -ENOMEM; in get_epic_descriptor()
505 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), in get_epic_descriptor()
511 ep->is_epic = 1; in get_epic_descriptor()
512 memcpy(&ep->epic_descriptor, epic, sizeof(*epic)); in get_epic_descriptor()
515 product_info->NumPorts = epic->NumPorts; in get_epic_descriptor()
516 product_info->ProdInfoVer = 0; in get_epic_descriptor()
517 product_info->FirmwareMajorVersion = epic->MajorVersion; in get_epic_descriptor()
518 product_info->FirmwareMinorVersion = epic->MinorVersion; in get_epic_descriptor()
519 product_info->FirmwareBuildNumber = epic->BuildNumber; in get_epic_descriptor()
520 product_info->iDownloadFile = epic->iDownloadFile; in get_epic_descriptor()
521 product_info->EpicVer = epic->EpicVer; in get_epic_descriptor()
522 product_info->Epic = epic->Supports; in get_epic_descriptor()
523 product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; in get_epic_descriptor()
526 bits = &ep->epic_descriptor.Supports; in get_epic_descriptor()
528 dev_dbg(dev, " VendEnableSuspend: %s\n", bits->VendEnableSuspend ? "TRUE": "FALSE"); in get_epic_descriptor()
529 dev_dbg(dev, " IOSPOpen : %s\n", bits->IOSPOpen ? "TRUE": "FALSE"); in get_epic_descriptor()
530 dev_dbg(dev, " IOSPClose : %s\n", bits->IOSPClose ? "TRUE": "FALSE"); in get_epic_descriptor()
531 dev_dbg(dev, " IOSPChase : %s\n", bits->IOSPChase ? "TRUE": "FALSE"); in get_epic_descriptor()
532 dev_dbg(dev, " IOSPSetRxFlow : %s\n", bits->IOSPSetRxFlow ? "TRUE": "FALSE"); in get_epic_descriptor()
533 dev_dbg(dev, " IOSPSetTxFlow : %s\n", bits->IOSPSetTxFlow ? "TRUE": "FALSE"); in get_epic_descriptor()
534 dev_dbg(dev, " IOSPSetXChar : %s\n", bits->IOSPSetXChar ? "TRUE": "FALSE"); in get_epic_descriptor()
535 dev_dbg(dev, " IOSPRxCheck : %s\n", bits->IOSPRxCheck ? "TRUE": "FALSE"); in get_epic_descriptor()
536 dev_dbg(dev, " IOSPSetClrBreak : %s\n", bits->IOSPSetClrBreak ? "TRUE": "FALSE"); in get_epic_descriptor()
537 dev_dbg(dev, " IOSPWriteMCR : %s\n", bits->IOSPWriteMCR ? "TRUE": "FALSE"); in get_epic_descriptor()
538 dev_dbg(dev, " IOSPWriteLCR : %s\n", bits->IOSPWriteLCR ? "TRUE": "FALSE"); in get_epic_descriptor()
539 dev_dbg(dev, " IOSPSetBaudRate : %s\n", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); in get_epic_descriptor()
540 dev_dbg(dev, " TrueEdgeport : %s\n", bits->TrueEdgeport ? "TRUE": "FALSE"); in get_epic_descriptor()
544 dev_warn(&serial->interface->dev, "short epic descriptor received: %d\n", in get_epic_descriptor()
546 result = -EIO; in get_epic_descriptor()
569 struct edgeport_serial *edge_serial = urb->context; in edge_interrupt_callback()
573 unsigned char *data = urb->transfer_buffer; in edge_interrupt_callback()
574 int length = urb->actual_length; in edge_interrupt_callback()
581 int status = urb->status; in edge_interrupt_callback()
587 case -ECONNRESET: in edge_interrupt_callback()
588 case -ENOENT: in edge_interrupt_callback()
589 case -ESHUTDOWN: in edge_interrupt_callback()
591 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); in edge_interrupt_callback()
594 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status); in edge_interrupt_callback()
598 dev = &edge_serial->serial->dev->dev; in edge_interrupt_callback()
600 /* process this interrupt-read even if there are no ports open */ in edge_interrupt_callback()
607 spin_lock_irqsave(&edge_serial->es_lock, flags); in edge_interrupt_callback()
608 edge_serial->rxBytesAvail += bytes_avail; in edge_interrupt_callback()
610 "%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d\n", in edge_interrupt_callback()
612 edge_serial->rxBytesAvail, in edge_interrupt_callback()
613 edge_serial->read_in_progress); in edge_interrupt_callback()
615 if (edge_serial->rxBytesAvail > 0 && in edge_interrupt_callback()
616 !edge_serial->read_in_progress) { in edge_interrupt_callback()
617 dev_dbg(dev, "%s - posting a read\n", __func__); in edge_interrupt_callback()
618 edge_serial->read_in_progress = true; in edge_interrupt_callback()
622 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); in edge_interrupt_callback()
625 "%s - usb_submit_urb(read bulk) failed with result = %d\n", in edge_interrupt_callback()
627 edge_serial->read_in_progress = false; in edge_interrupt_callback()
630 spin_unlock_irqrestore(&edge_serial->es_lock, in edge_interrupt_callback()
637 while ((position < length - 1) && in edge_interrupt_callback()
638 (portNumber < edge_serial->serial->num_ports)) { in edge_interrupt_callback()
641 port = edge_serial->serial->port[portNumber]; in edge_interrupt_callback()
643 if (edge_port && edge_port->open) { in edge_interrupt_callback()
644 spin_lock_irqsave(&edge_port->ep_lock, in edge_interrupt_callback()
646 edge_port->txCredits += txCredits; in edge_interrupt_callback()
647 spin_unlock_irqrestore(&edge_port->ep_lock, in edge_interrupt_callback()
649 dev_dbg(dev, "%s - txcredits for port%d = %d\n", in edge_interrupt_callback()
651 edge_port->txCredits); in edge_interrupt_callback()
655 tty_port_tty_wakeup(&edge_port->port->port); in edge_interrupt_callback()
670 dev_err(&urb->dev->dev, in edge_interrupt_callback()
671 "%s - Error %d submitting control urb\n", in edge_interrupt_callback()
683 struct edgeport_serial *edge_serial = urb->context; in edge_bulk_in_callback()
685 unsigned char *data = urb->transfer_buffer; in edge_bulk_in_callback()
688 int status = urb->status; in edge_bulk_in_callback()
692 dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", in edge_bulk_in_callback()
694 edge_serial->read_in_progress = false; in edge_bulk_in_callback()
698 if (urb->actual_length == 0) { in edge_bulk_in_callback()
699 dev_dbg(&urb->dev->dev, "%s - read bulk callback with no data\n", __func__); in edge_bulk_in_callback()
700 edge_serial->read_in_progress = false; in edge_bulk_in_callback()
704 dev = &edge_serial->serial->dev->dev; in edge_bulk_in_callback()
705 raw_data_length = urb->actual_length; in edge_bulk_in_callback()
709 spin_lock_irqsave(&edge_serial->es_lock, flags); in edge_bulk_in_callback()
712 edge_serial->rxBytesAvail -= raw_data_length; in edge_bulk_in_callback()
714 dev_dbg(dev, "%s - Received = %d, rxBytesAvail %d\n", __func__, in edge_bulk_in_callback()
715 raw_data_length, edge_serial->rxBytesAvail); in edge_bulk_in_callback()
717 process_rcvd_data(edge_serial, data, urb->actual_length); in edge_bulk_in_callback()
720 if (edge_serial->rxBytesAvail > 0) { in edge_bulk_in_callback()
721 dev_dbg(dev, "%s - posting a read\n", __func__); in edge_bulk_in_callback()
722 retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); in edge_bulk_in_callback()
725 "%s - usb_submit_urb(read bulk) failed, retval = %d\n", in edge_bulk_in_callback()
727 edge_serial->read_in_progress = false; in edge_bulk_in_callback()
730 edge_serial->read_in_progress = false; in edge_bulk_in_callback()
733 spin_unlock_irqrestore(&edge_serial->es_lock, flags); in edge_bulk_in_callback()
744 struct edgeport_port *edge_port = urb->context; in edge_bulk_out_data_callback()
745 int status = urb->status; in edge_bulk_out_data_callback()
748 dev_dbg(&urb->dev->dev, in edge_bulk_out_data_callback()
749 "%s - nonzero write bulk status received: %d\n", in edge_bulk_out_data_callback()
753 if (edge_port->open) in edge_bulk_out_data_callback()
754 tty_port_tty_wakeup(&edge_port->port->port); in edge_bulk_out_data_callback()
757 edge_port->write_in_progress = false; in edge_bulk_out_data_callback()
761 (usb_get_serial_data(edge_port->port->serial)), edge_port); in edge_bulk_out_data_callback()
772 struct edgeport_port *edge_port = urb->context; in edge_bulk_out_cmd_callback()
773 struct device *dev = &urb->dev->dev; in edge_bulk_out_cmd_callback()
774 int status = urb->status; in edge_bulk_out_cmd_callback()
777 dev_dbg(dev, "%s - FREE URB %p (outstanding %d)\n", __func__, urb, in edge_bulk_out_cmd_callback()
782 kfree(urb->transfer_buffer); in edge_bulk_out_cmd_callback()
788 dev_dbg(dev, "%s - nonzero write bulk status received: %d\n", in edge_bulk_out_cmd_callback()
794 if (edge_port->open) in edge_bulk_out_cmd_callback()
795 tty_port_tty_wakeup(&edge_port->port->port); in edge_bulk_out_cmd_callback()
798 edge_port->commandPending = false; in edge_bulk_out_cmd_callback()
799 wake_up(&edge_port->wait_command); in edge_bulk_out_cmd_callback()
816 struct device *dev = &port->dev; in edge_open()
822 return -ENODEV; in edge_open()
826 serial = port->serial; in edge_open()
829 return -ENODEV; in edge_open()
830 if (edge_serial->interrupt_in_buffer == NULL) { in edge_open()
831 struct usb_serial_port *port0 = serial->port[0]; in edge_open()
834 edge_serial->interrupt_in_buffer = in edge_open()
835 port0->interrupt_in_buffer; in edge_open()
836 edge_serial->interrupt_in_endpoint = in edge_open()
837 port0->interrupt_in_endpointAddress; in edge_open()
838 edge_serial->interrupt_read_urb = port0->interrupt_in_urb; in edge_open()
839 edge_serial->bulk_in_buffer = port0->bulk_in_buffer; in edge_open()
840 edge_serial->bulk_in_endpoint = in edge_open()
841 port0->bulk_in_endpointAddress; in edge_open()
842 edge_serial->read_urb = port0->read_urb; in edge_open()
843 edge_serial->bulk_out_endpoint = in edge_open()
844 port0->bulk_out_endpointAddress; in edge_open()
847 usb_fill_int_urb(edge_serial->interrupt_read_urb, in edge_open()
848 serial->dev, in edge_open()
849 usb_rcvintpipe(serial->dev, in edge_open()
850 port0->interrupt_in_endpointAddress), in edge_open()
851 port0->interrupt_in_buffer, in edge_open()
852 edge_serial->interrupt_read_urb->transfer_buffer_length, in edge_open()
854 edge_serial->interrupt_read_urb->interval); in edge_open()
857 usb_fill_bulk_urb(edge_serial->read_urb, serial->dev, in edge_open()
858 usb_rcvbulkpipe(serial->dev, in edge_open()
859 port0->bulk_in_endpointAddress), in edge_open()
860 port0->bulk_in_buffer, in edge_open()
861 edge_serial->read_urb->transfer_buffer_length, in edge_open()
863 edge_serial->read_in_progress = false; in edge_open()
868 response = usb_submit_urb(edge_serial->interrupt_read_urb, in edge_open()
871 dev_err(dev, "%s - Error %d submitting control urb\n", in edge_open()
877 init_waitqueue_head(&edge_port->wait_open); in edge_open()
878 init_waitqueue_head(&edge_port->wait_chase); in edge_open()
879 init_waitqueue_head(&edge_port->wait_command); in edge_open()
882 edge_port->txCredits = 0; /* Can't send any data yet */ in edge_open()
884 edge_port->shadowMCR = MCR_MASTER_IE; in edge_open()
885 edge_port->chaseResponsePending = false; in edge_open()
888 edge_port->openPending = true; in edge_open()
889 edge_port->open = false; in edge_open()
893 dev_err(dev, "%s - error sending open port command\n", __func__); in edge_open()
894 edge_port->openPending = false; in edge_open()
895 return -ENODEV; in edge_open()
899 wait_event_timeout(edge_port->wait_open, !edge_port->openPending, in edge_open()
902 if (!edge_port->open) { in edge_open()
904 dev_dbg(dev, "%s - open timeout\n", __func__); in edge_open()
905 edge_port->openPending = false; in edge_open()
906 return -ENODEV; in edge_open()
910 edge_port->txfifo.head = 0; in edge_open()
911 edge_port->txfifo.tail = 0; in edge_open()
912 edge_port->txfifo.count = 0; in edge_open()
913 edge_port->txfifo.size = edge_port->maxTxCredits; in edge_open()
914 edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL); in edge_open()
916 if (!edge_port->txfifo.fifo) { in edge_open()
918 return -ENOMEM; in edge_open()
922 edge_port->write_urb = usb_alloc_urb(0, GFP_KERNEL); in edge_open()
923 edge_port->write_in_progress = false; in edge_open()
925 if (!edge_port->write_urb) { in edge_open()
927 return -ENOMEM; in edge_open()
930 dev_dbg(dev, "%s - Initialize TX fifo to %d bytes\n", in edge_open()
931 __func__, edge_port->maxTxCredits); in edge_open()
949 struct device *dev = &edge_port->port->dev; in block_until_chase_response()
956 /* Save Last credits */ in block_until_chase_response()
957 lastCredits = edge_port->txCredits; in block_until_chase_response()
960 if (!edge_port->chaseResponsePending) { in block_until_chase_response()
961 dev_dbg(dev, "%s - Got Chase Response\n", __func__); in block_until_chase_response()
964 if (edge_port->txCredits == edge_port->maxTxCredits) { in block_until_chase_response()
965 dev_dbg(dev, "%s - Got all credits\n", __func__); in block_until_chase_response()
971 prepare_to_wait(&edge_port->wait_chase, &wait, in block_until_chase_response()
974 finish_wait(&edge_port->wait_chase, &wait); in block_until_chase_response()
976 if (lastCredits == edge_port->txCredits) { in block_until_chase_response()
978 loop--; in block_until_chase_response()
980 edge_port->chaseResponsePending = false; in block_until_chase_response()
981 dev_dbg(dev, "%s - Chase TIMEOUT\n", __func__); in block_until_chase_response()
986 dev_dbg(dev, "%s - Last %d, Current %d\n", __func__, in block_until_chase_response()
987 lastCredits, edge_port->txCredits); in block_until_chase_response()
1006 struct device *dev = &edge_port->port->dev; in block_until_tx_empty()
1008 struct TxFifo *fifo = &edge_port->txfifo; in block_until_tx_empty()
1014 /* Save Last count */ in block_until_tx_empty()
1015 lastCount = fifo->count; in block_until_tx_empty()
1019 dev_dbg(dev, "%s - TX Buffer Empty\n", __func__); in block_until_tx_empty()
1024 prepare_to_wait(&edge_port->wait_chase, &wait, in block_until_tx_empty()
1027 finish_wait(&edge_port->wait_chase, &wait); in block_until_tx_empty()
1031 if (lastCount == fifo->count) { in block_until_tx_empty()
1033 loop--; in block_until_tx_empty()
1035 dev_dbg(dev, "%s - TIMEOUT\n", __func__); in block_until_tx_empty()
1056 edge_serial = usb_get_serial_data(port->serial); in edge_close()
1064 edge_port->closePending = true; in edge_close()
1066 if (!edge_serial->is_epic || in edge_close()
1067 edge_serial->epic_descriptor.Supports.IOSPChase) { in edge_close()
1069 edge_port->chaseResponsePending = true; in edge_close()
1071 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__); in edge_close()
1077 edge_port->chaseResponsePending = false; in edge_close()
1080 if (!edge_serial->is_epic || in edge_close()
1081 edge_serial->epic_descriptor.Supports.IOSPClose) { in edge_close()
1083 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", __func__); in edge_close()
1087 /* port->close = true; */ in edge_close()
1088 edge_port->closePending = false; in edge_close()
1089 edge_port->open = false; in edge_close()
1090 edge_port->openPending = false; in edge_close()
1092 usb_kill_urb(edge_port->write_urb); in edge_close()
1094 if (edge_port->write_urb) { in edge_close()
1097 kfree(edge_port->write_urb->transfer_buffer); in edge_close()
1098 usb_free_urb(edge_port->write_urb); in edge_close()
1099 edge_port->write_urb = NULL; in edge_close()
1101 kfree(edge_port->txfifo.fifo); in edge_close()
1102 edge_port->txfifo.fifo = NULL; in edge_close()
1124 return -ENODEV; in edge_write()
1127 fifo = &edge_port->txfifo; in edge_write()
1129 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_write()
1133 (edge_port->txCredits - fifo->count)); in edge_write()
1135 dev_dbg(&port->dev, "%s of %d byte(s) Fifo room %d -- will copy %d bytes\n", in edge_write()
1136 __func__, count, edge_port->txCredits - fifo->count, copySize); in edge_write()
1141 dev_dbg(&port->dev, "%s - copySize = Zero\n", __func__); in edge_write()
1149 * the copy is done is two parts -- first fill to the end of the buffer in edge_write()
1152 bytesleft = fifo->size - fifo->head; in edge_write()
1154 dev_dbg(&port->dev, "%s - copy %d bytes of %d into fifo \n", __func__, in edge_write()
1158 memcpy(&fifo->fifo[fifo->head], data, firsthalf); in edge_write()
1159 usb_serial_debug_data(&port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]); in edge_write()
1162 fifo->head += firsthalf; in edge_write()
1163 fifo->count += firsthalf; in edge_write()
1166 if (fifo->head == fifo->size) in edge_write()
1167 fifo->head = 0; in edge_write()
1169 secondhalf = copySize-firsthalf; in edge_write()
1172 dev_dbg(&port->dev, "%s - copy rest of data %d\n", __func__, secondhalf); in edge_write()
1173 memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); in edge_write()
1174 usb_serial_debug_data(&port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]); in edge_write()
1176 fifo->count += secondhalf; in edge_write()
1177 fifo->head += secondhalf; in edge_write()
1184 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_write()
1187 usb_get_serial_data(port->serial), edge_port); in edge_write()
1189 dev_dbg(&port->dev, "%s wrote %d byte(s) TxCredits %d, Fifo %d\n", in edge_write()
1190 __func__, copySize, edge_port->txCredits, fifo->count); in edge_write()
1212 struct TxFifo *fifo = &edge_port->txfifo; in send_more_port_data()
1213 struct device *dev = &edge_port->port->dev; in send_more_port_data()
1223 spin_lock_irqsave(&edge_port->ep_lock, flags); in send_more_port_data()
1225 if (edge_port->write_in_progress || in send_more_port_data()
1226 !edge_port->open || in send_more_port_data()
1227 (fifo->count == 0)) { in send_more_port_data()
1228 dev_dbg(dev, "%s EXIT - fifo %d, PendingWrite = %d\n", in send_more_port_data()
1229 __func__, fifo->count, edge_port->write_in_progress); in send_more_port_data()
1240 …if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_… in send_more_port_data()
1241 dev_dbg(dev, "%s Not enough credit - fifo %d TxCredit %d\n", in send_more_port_data()
1242 __func__, fifo->count, edge_port->txCredits); in send_more_port_data()
1247 edge_port->write_in_progress = true; in send_more_port_data()
1250 urb = edge_port->write_urb; in send_more_port_data()
1253 kfree(urb->transfer_buffer); in send_more_port_data()
1254 urb->transfer_buffer = NULL; in send_more_port_data()
1258 count = fifo->count; in send_more_port_data()
1261 edge_port->write_in_progress = false; in send_more_port_data()
1264 buffer[0] = IOSP_BUILD_DATA_HDR1(edge_port->port->port_number, count); in send_more_port_data()
1265 buffer[1] = IOSP_BUILD_DATA_HDR2(edge_port->port->port_number, count); in send_more_port_data()
1268 bytesleft = fifo->size - fifo->tail; in send_more_port_data()
1270 memcpy(&buffer[2], &fifo->fifo[fifo->tail], firsthalf); in send_more_port_data()
1271 fifo->tail += firsthalf; in send_more_port_data()
1272 fifo->count -= firsthalf; in send_more_port_data()
1273 if (fifo->tail == fifo->size) in send_more_port_data()
1274 fifo->tail = 0; in send_more_port_data()
1276 secondhalf = count-firsthalf; in send_more_port_data()
1278 memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail], in send_more_port_data()
1280 fifo->tail += secondhalf; in send_more_port_data()
1281 fifo->count -= secondhalf; in send_more_port_data()
1285 usb_serial_debug_data(&edge_port->port->dev, __func__, count, &buffer[2]); in send_more_port_data()
1288 usb_fill_bulk_urb(urb, edge_serial->serial->dev, in send_more_port_data()
1289 usb_sndbulkpipe(edge_serial->serial->dev, in send_more_port_data()
1290 edge_serial->bulk_out_endpoint), in send_more_port_data()
1295 edge_port->txCredits -= count; in send_more_port_data()
1296 edge_port->port->icount.tx += count; in send_more_port_data()
1301 dev_err_console(edge_port->port, in send_more_port_data()
1302 "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", in send_more_port_data()
1304 edge_port->write_in_progress = false; in send_more_port_data()
1307 edge_port->txCredits += count; in send_more_port_data()
1308 edge_port->port->icount.tx -= count; in send_more_port_data()
1311 __func__, count, edge_port->txCredits, fifo->count); in send_more_port_data()
1314 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in send_more_port_data()
1325 struct usb_serial_port *port = tty->driver_data; in edge_write_room()
1331 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_write_room()
1332 room = edge_port->txCredits - edge_port->txfifo.count; in edge_write_room()
1333 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_write_room()
1335 dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); in edge_write_room()
1348 struct usb_serial_port *port = tty->driver_data; in edge_chars_in_buffer()
1353 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_chars_in_buffer()
1354 num_chars = edge_port->maxTxCredits - edge_port->txCredits + in edge_chars_in_buffer()
1355 edge_port->txfifo.count; in edge_chars_in_buffer()
1356 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_chars_in_buffer()
1358 dev_dbg(&port->dev, "%s - returns %u\n", __func__, num_chars); in edge_chars_in_buffer()
1372 struct usb_serial_port *port = tty->driver_data; in edge_throttle()
1379 if (!edge_port->open) { in edge_throttle()
1380 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in edge_throttle()
1394 edge_port->shadowMCR &= ~MCR_RTS; in edge_throttle()
1396 edge_port->shadowMCR); in edge_throttle()
1410 struct usb_serial_port *port = tty->driver_data; in edge_unthrottle()
1417 if (!edge_port->open) { in edge_unthrottle()
1418 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in edge_unthrottle()
1431 edge_port->shadowMCR |= MCR_RTS; in edge_unthrottle()
1433 edge_port->shadowMCR); in edge_unthrottle()
1452 if (!edge_port->open) { in edge_set_termios()
1453 dev_dbg(&port->dev, "%s - port not opened\n", __func__); in edge_set_termios()
1463 * get_lsr_info - get line status register info
1478 spin_lock_irqsave(&edge_port->ep_lock, flags); in get_lsr_info()
1479 if (edge_port->maxTxCredits == edge_port->txCredits && in get_lsr_info()
1480 edge_port->txfifo.count == 0) { in get_lsr_info()
1481 dev_dbg(&edge_port->port->dev, "%s -- Empty\n", __func__); in get_lsr_info()
1484 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in get_lsr_info()
1487 return -EFAULT; in get_lsr_info()
1494 struct usb_serial_port *port = tty->driver_data; in edge_tiocmset()
1498 mcr = edge_port->shadowMCR; in edge_tiocmset()
1513 edge_port->shadowMCR = mcr; in edge_tiocmset()
1515 send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); in edge_tiocmset()
1522 struct usb_serial_port *port = tty->driver_data; in edge_tiocmget()
1528 msr = edge_port->shadowMSR; in edge_tiocmget()
1529 mcr = edge_port->shadowMCR; in edge_tiocmget()
1547 struct usb_serial_port *port = tty->driver_data; in edge_ioctl()
1552 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); in edge_ioctl()
1555 return -ENOIOCTLCMD; in edge_ioctl()
1565 struct usb_serial_port *port = tty->driver_data; in edge_break()
1567 struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); in edge_break()
1570 if (!edge_serial->is_epic || in edge_break()
1571 edge_serial->epic_descriptor.Supports.IOSPChase) { in edge_break()
1573 edge_port->chaseResponsePending = true; in edge_break()
1575 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__); in edge_break()
1581 edge_port->chaseResponsePending = false; in edge_break()
1585 if (!edge_serial->is_epic || in edge_break()
1586 edge_serial->epic_descriptor.Supports.IOSPSetClrBreak) { in edge_break()
1587 if (break_state == -1) { in edge_break()
1588 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_SET_BREAK\n", __func__); in edge_break()
1592 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLEAR_BREAK\n", __func__); in edge_break()
1597 dev_dbg(&port->dev, "%s - error sending break set/clear command.\n", in edge_break()
1612 struct usb_serial *serial = edge_serial->serial; in process_rcvd_data()
1613 struct device *dev = &serial->dev->dev; in process_rcvd_data()
1624 dev_dbg(dev, "%s - stuck in loop, exiting it.\n", __func__); in process_rcvd_data()
1629 switch (edge_serial->rxState) { in process_rcvd_data()
1631 edge_serial->rxHeader1 = *buffer; in process_rcvd_data()
1633 --bufferLength; in process_rcvd_data()
1636 edge_serial->rxState = EXPECT_HDR2; in process_rcvd_data()
1641 edge_serial->rxHeader2 = *buffer; in process_rcvd_data()
1643 --bufferLength; in process_rcvd_data()
1645 dev_dbg(dev, "%s - Hdr1=%02X Hdr2=%02X\n", __func__, in process_rcvd_data()
1646 edge_serial->rxHeader1, edge_serial->rxHeader2); in process_rcvd_data()
1650 if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) { in process_rcvd_data()
1655 edge_serial->rxPort = in process_rcvd_data()
1656 IOSP_GET_HDR_PORT(edge_serial->rxHeader1); in process_rcvd_data()
1657 edge_serial->rxStatusCode = in process_rcvd_data()
1659 edge_serial->rxHeader1); in process_rcvd_data()
1662 edge_serial->rxStatusCode)) { in process_rcvd_data()
1664 * Save what we have and then wait for in process_rcvd_data()
1667 edge_serial->rxStatusParam in process_rcvd_data()
1668 = edge_serial->rxHeader2; in process_rcvd_data()
1669 edge_serial->rxState = EXPECT_HDR3; in process_rcvd_data()
1675 edge_serial->rxHeader2, 0); in process_rcvd_data()
1676 edge_serial->rxState = EXPECT_HDR1; in process_rcvd_data()
1680 edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1); in process_rcvd_data()
1681 edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, in process_rcvd_data()
1682 edge_serial->rxHeader2); in process_rcvd_data()
1683 dev_dbg(dev, "%s - Data for Port %u Len %u\n", __func__, in process_rcvd_data()
1684 edge_serial->rxPort, in process_rcvd_data()
1685 edge_serial->rxBytesRemaining); in process_rcvd_data()
1688 edge_serial->rxState = EXPECT_DATA; in process_rcvd_data()
1693 if (bufferLength < edge_serial->rxBytesRemaining) { in process_rcvd_data()
1696 edge_serial->rxState = EXPECT_DATA; in process_rcvd_data()
1699 rxLen = edge_serial->rxBytesRemaining; in process_rcvd_data()
1701 edge_serial->rxState = EXPECT_HDR1; in process_rcvd_data()
1704 bufferLength -= rxLen; in process_rcvd_data()
1705 edge_serial->rxBytesRemaining -= rxLen; in process_rcvd_data()
1709 if (rxLen && edge_serial->rxPort < serial->num_ports) { in process_rcvd_data()
1710 port = serial->port[edge_serial->rxPort]; in process_rcvd_data()
1712 if (edge_port && edge_port->open) { in process_rcvd_data()
1713 dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", in process_rcvd_data()
1715 edge_serial->rxPort); in process_rcvd_data()
1716 edge_tty_recv(edge_port->port, buffer, in process_rcvd_data()
1718 edge_port->port->icount.rx += rxLen; in process_rcvd_data()
1725 edge_serial->rxHeader3 = *buffer; in process_rcvd_data()
1727 --bufferLength; in process_rcvd_data()
1732 edge_serial->rxStatusParam, in process_rcvd_data()
1733 edge_serial->rxHeader3); in process_rcvd_data()
1734 edge_serial->rxState = EXPECT_HDR1; in process_rcvd_data()
1753 __u8 code = edge_serial->rxStatusCode; in process_rcvd_status()
1756 if (edge_serial->rxPort >= edge_serial->serial->num_ports) in process_rcvd_status()
1758 port = edge_serial->serial->port[edge_serial->rxPort]; in process_rcvd_status()
1761 dev_err(&edge_serial->serial->dev->dev, in process_rcvd_status()
1762 "%s - edge_port == NULL for port %d\n", in process_rcvd_status()
1763 __func__, edge_serial->rxPort); in process_rcvd_status()
1766 dev = &port->dev; in process_rcvd_status()
1773 dev_dbg(dev, "%s - Port %u EXT CHASE_RSP Data = %02x\n", in process_rcvd_status()
1774 __func__, edge_serial->rxPort, byte3); in process_rcvd_status()
1784 edge_port->chaseResponsePending = false; in process_rcvd_status()
1785 wake_up(&edge_port->wait_chase); in process_rcvd_status()
1790 __func__, edge_serial->rxPort, byte3); in process_rcvd_status()
1791 /* Port->RxCheckRsp = true; */ in process_rcvd_status()
1797 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); in process_rcvd_status()
1798 edge_port->maxTxCredits = edge_port->txCredits; in process_rcvd_status()
1799 dev_dbg(dev, "%s - Port %u Open Response Initial MSR = %02x TxBufferSize = %d\n", in process_rcvd_status()
1800 __func__, edge_serial->rxPort, byte2, edge_port->txCredits); in process_rcvd_status()
1805 tty = tty_port_tty_get(&edge_port->port->port); in process_rcvd_status()
1808 edge_port, &tty->termios); in process_rcvd_status()
1813 edge_port->openPending = false; in process_rcvd_status()
1814 edge_port->open = true; in process_rcvd_status()
1815 wake_up(&edge_port->wait_open); in process_rcvd_status()
1823 if (!edge_port->open || edge_port->closePending) in process_rcvd_status()
1829 dev_dbg(dev, "%s - Port %u LSR Status = %02x\n", in process_rcvd_status()
1830 __func__, edge_serial->rxPort, byte2); in process_rcvd_status()
1835 dev_dbg(dev, "%s - Port %u LSR Status = %02x, Data = %02x\n", in process_rcvd_status()
1836 __func__, edge_serial->rxPort, byte2, byte3); in process_rcvd_status()
1838 /* byte3 is broken data byte */ in process_rcvd_status()
1843 * dev_dbg(dev, "%s - Port %u LSR Status = %02x Data = %02x\n", in process_rcvd_status()
1844 * __func__, edge_serial->rxPort, byte2, byte3); in process_rcvd_status()
1848 dev_dbg(dev, "%s - Port %u MSR Status = %02x\n", in process_rcvd_status()
1849 __func__, edge_serial->rxPort, byte2); in process_rcvd_status()
1853 * also saves the MSR in Port->ShadowMsr. in process_rcvd_status()
1859 dev_dbg(dev, "%s - Unrecognized IOSP status code %u\n", __func__, code); in process_rcvd_status()
1874 cnt = tty_insert_flip_string(&port->port, data, length); in edge_tty_recv()
1876 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", in edge_tty_recv()
1877 __func__, length - cnt); in edge_tty_recv()
1880 length -= cnt; in edge_tty_recv()
1882 tty_flip_buffer_push(&port->port); in edge_tty_recv()
1896 icount = &edge_port->port->icount; in handle_new_msr()
1900 icount->cts++; in handle_new_msr()
1902 icount->dsr++; in handle_new_msr()
1904 icount->dcd++; in handle_new_msr()
1906 icount->rng++; in handle_new_msr()
1907 wake_up_interruptible(&edge_port->port->port.delta_msr_wait); in handle_new_msr()
1910 /* Save the new modem status */ in handle_new_msr()
1911 edge_port->shadowMSR = newMsr & 0xf0; in handle_new_msr()
1926 edge_port->shadowLSR = lsr; in handle_new_lsr()
1939 edge_tty_recv(edge_port->port, &data, 1); in handle_new_lsr()
1942 icount = &edge_port->port->icount; in handle_new_lsr()
1944 icount->brk++; in handle_new_lsr()
1946 icount->overrun++; in handle_new_lsr()
1948 icount->parity++; in handle_new_lsr()
1950 icount->frame++; in handle_new_lsr()
1968 dev_dbg(&serial->dev->dev, "%s - %x, %x, %d\n", __func__, extAddr, addr, length); in sram_write()
1972 return -ENOMEM; in sram_write()
1982 /* dev_dbg(&serial->dev->dev, "%s - writing %x, %x, %d\n", __func__, extAddr, addr, current_length… in sram_write()
1984 result = usb_control_msg(serial->dev, in sram_write()
1985 usb_sndctrlpipe(serial->dev, 0), in sram_write()
1991 length -= current_length; in sram_write()
2017 return -ENOMEM; in rom_write()
2027 result = usb_control_msg(serial->dev, in rom_write()
2028 usb_sndctrlpipe(serial->dev, 0), in rom_write()
2034 length -= current_length; in rom_write()
2059 return -ENOMEM; in rom_read()
2068 result = usb_control_msg(serial->dev, in rom_read()
2069 usb_rcvctrlpipe(serial->dev, 0), in rom_read()
2075 result = -EIO; in rom_read()
2079 length -= current_length; in rom_read()
2105 return -ENOMEM; in send_iosp_ext_cmd()
2109 MAKE_CMD_EXT_CMD(¤tCommand, &length, edge_port->port->port_number, in send_iosp_ext_cmd()
2130 usb_get_serial_data(edge_port->port->serial); in write_cmd_usb()
2131 struct device *dev = &edge_port->port->dev; in write_cmd_usb()
2140 return -ENOMEM; in write_cmd_usb()
2143 dev_dbg(dev, "%s - ALLOCATE URB %p (outstanding %d)\n", in write_cmd_usb()
2146 usb_fill_bulk_urb(urb, edge_serial->serial->dev, in write_cmd_usb()
2147 usb_sndbulkpipe(edge_serial->serial->dev, in write_cmd_usb()
2148 edge_serial->bulk_out_endpoint), in write_cmd_usb()
2151 edge_port->commandPending = true; in write_cmd_usb()
2156 dev_err(dev, "%s - usb_submit_urb(write command) failed, status = %d\n", in write_cmd_usb()
2164 wait_event(&edge_port->wait_command, !edge_port->commandPending); in write_cmd_usb()
2166 if (edge_port->commandPending) { in write_cmd_usb()
2168 dev_dbg(dev, "%s - command timed out\n", __func__); in write_cmd_usb()
2169 status = -EINVAL; in write_cmd_usb()
2185 usb_get_serial_data(edge_port->port->serial); in send_cmd_write_baud_rate()
2186 struct device *dev = &edge_port->port->dev; in send_cmd_write_baud_rate()
2192 u32 number = edge_port->port->port_number; in send_cmd_write_baud_rate()
2194 if (edge_serial->is_epic && in send_cmd_write_baud_rate()
2195 !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { in send_cmd_write_baud_rate()
2196 dev_dbg(dev, "SendCmdWriteBaudRate - NOT Setting baud rate for port, baud = %d\n", in send_cmd_write_baud_rate()
2201 dev_dbg(dev, "%s - baud = %d\n", __func__, baudRate); in send_cmd_write_baud_rate()
2205 dev_err(dev, "%s - bad baud rate\n", __func__); in send_cmd_write_baud_rate()
2212 return -ENOMEM; in send_cmd_write_baud_rate()
2223 /* Restore original value to disable access to divisor latch */ in send_cmd_write_baud_rate()
2225 edge_port->shadowLCR); in send_cmd_write_baud_rate()
2263 dev_dbg(dev, "%s - Baud %d = %d\n", __func__, baudrate, custom); in calc_baud_rate_divisor()
2267 return -1; in calc_baud_rate_divisor()
2279 usb_get_serial_data(edge_port->port->serial); in send_cmd_write_uart_register()
2280 struct device *dev = &edge_port->port->dev; in send_cmd_write_uart_register()
2286 dev_dbg(dev, "%s - write to %s register 0x%02x\n", in send_cmd_write_uart_register()
2289 if (edge_serial->is_epic && in send_cmd_write_uart_register()
2290 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && in send_cmd_write_uart_register()
2292 dev_dbg(dev, "SendCmdWriteUartReg - Not writing to MCR Register\n"); in send_cmd_write_uart_register()
2296 if (edge_serial->is_epic && in send_cmd_write_uart_register()
2297 !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && in send_cmd_write_uart_register()
2299 dev_dbg(dev, "SendCmdWriteUartReg - Not writing to LCR Register\n"); in send_cmd_write_uart_register()
2306 return -ENOMEM; in send_cmd_write_uart_register()
2311 MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, edge_port->port->port_number, in send_cmd_write_uart_register()
2333 struct device *dev = &edge_port->port->dev; in change_port_settings()
2335 usb_get_serial_data(edge_port->port->serial); in change_port_settings()
2346 if (!edge_port->open && in change_port_settings()
2347 !edge_port->openPending) { in change_port_settings()
2348 dev_dbg(dev, "%s - port not opened\n", __func__); in change_port_settings()
2352 cflag = tty->termios.c_cflag; in change_port_settings()
2357 dev_dbg(dev, "%s - data bits = 5\n", __func__); in change_port_settings()
2361 dev_dbg(dev, "%s - data bits = 6\n", __func__); in change_port_settings()
2365 dev_dbg(dev, "%s - data bits = 7\n", __func__); in change_port_settings()
2370 dev_dbg(dev, "%s - data bits = 8\n", __func__); in change_port_settings()
2379 dev_dbg(dev, "%s - parity = mark\n", __func__); in change_port_settings()
2382 dev_dbg(dev, "%s - parity = space\n", __func__); in change_port_settings()
2386 dev_dbg(dev, "%s - parity = odd\n", __func__); in change_port_settings()
2389 dev_dbg(dev, "%s - parity = even\n", __func__); in change_port_settings()
2392 dev_dbg(dev, "%s - parity = none\n", __func__); in change_port_settings()
2397 dev_dbg(dev, "%s - stop bits = 2\n", __func__); in change_port_settings()
2400 dev_dbg(dev, "%s - stop bits = 1\n", __func__); in change_port_settings()
2408 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__); in change_port_settings()
2410 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__); in change_port_settings()
2419 if (!edge_serial->is_epic || in change_port_settings()
2420 edge_serial->epic_descriptor.Supports.IOSPSetXChar) { in change_port_settings()
2430 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", in change_port_settings()
2433 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__); in change_port_settings()
2439 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", in change_port_settings()
2442 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__); in change_port_settings()
2447 if (!edge_serial->is_epic || in change_port_settings()
2448 edge_serial->epic_descriptor.Supports.IOSPSetRxFlow) in change_port_settings()
2450 if (!edge_serial->is_epic || in change_port_settings()
2451 edge_serial->epic_descriptor.Supports.IOSPSetTxFlow) in change_port_settings()
2455 edge_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); in change_port_settings()
2456 edge_port->shadowLCR |= (lData | lParity | lStop); in change_port_settings()
2458 edge_port->validDataMask = mask; in change_port_settings()
2462 edge_port->shadowLCR); in change_port_settings()
2467 edge_port->shadowMCR = MCR_MASTER_IE; in change_port_settings()
2469 edge_port->shadowMCR |= (MCR_DTR | MCR_RTS); in change_port_settings()
2472 edge_port->shadowMCR); in change_port_settings()
2483 dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud); in change_port_settings()
2485 if (status == -1) { in change_port_settings()
2486 /* Speed change was not possible - put back the old speed */ in change_port_settings()
2507 --buflen; /* space for nul */ in unicode_to_ascii()
2525 struct device *dev = &edge_serial->serial->dev->dev; in get_manufacturing_desc()
2530 response = rom_read(edge_serial->serial, in get_manufacturing_desc()
2534 (__u8 *)(&edge_serial->manuf_descriptor)); in get_manufacturing_desc()
2543 edge_serial->manuf_descriptor.RomSize); in get_manufacturing_desc()
2545 edge_serial->manuf_descriptor.RamSize); in get_manufacturing_desc()
2547 edge_serial->manuf_descriptor.CpuRev); in get_manufacturing_desc()
2549 edge_serial->manuf_descriptor.BoardRev); in get_manufacturing_desc()
2551 edge_serial->manuf_descriptor.NumPorts); in get_manufacturing_desc()
2553 edge_serial->manuf_descriptor.DescDate[0], in get_manufacturing_desc()
2554 edge_serial->manuf_descriptor.DescDate[1], in get_manufacturing_desc()
2555 edge_serial->manuf_descriptor.DescDate[2]+1900); in get_manufacturing_desc()
2557 edge_serial->manuf_descriptor.SerialNumber, in get_manufacturing_desc()
2558 edge_serial->manuf_descriptor.SerNumLength/2); in get_manufacturing_desc()
2561 edge_serial->manuf_descriptor.AssemblyNumber, in get_manufacturing_desc()
2562 edge_serial->manuf_descriptor.AssemblyNumLength/2); in get_manufacturing_desc()
2565 edge_serial->manuf_descriptor.OemAssyNumber, in get_manufacturing_desc()
2566 edge_serial->manuf_descriptor.OemAssyNumLength/2); in get_manufacturing_desc()
2569 edge_serial->manuf_descriptor.UartType); in get_manufacturing_desc()
2571 edge_serial->manuf_descriptor.IonPid); in get_manufacturing_desc()
2573 edge_serial->manuf_descriptor.IonConfig); in get_manufacturing_desc()
2585 struct device *dev = &edge_serial->serial->dev->dev; in get_boot_desc()
2590 response = rom_read(edge_serial->serial, in get_boot_desc()
2594 (__u8 *)(&edge_serial->boot_descriptor)); in get_boot_desc()
2602 le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); in get_boot_desc()
2604 edge_serial->boot_descriptor.MajorVersion); in get_boot_desc()
2606 edge_serial->boot_descriptor.MinorVersion); in get_boot_desc()
2608 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); in get_boot_desc()
2610 le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); in get_boot_desc()
2612 edge_serial->boot_descriptor.UConfig0); in get_boot_desc()
2614 edge_serial->boot_descriptor.UConfig1); in get_boot_desc()
2625 struct device *dev = &edge_serial->serial->dev->dev; in load_application_firmware()
2627 const struct firmware *fw; in load_application_firmware() local
2634 switch (edge_serial->product_info.iDownloadFile) { in load_application_firmware()
2637 fw_name = "edgeport/down.fw"; in load_application_firmware()
2642 fw_name = "edgeport/down2.fw"; in load_application_firmware()
2653 response = request_ihex_firmware(&fw, fw_name, in load_application_firmware()
2654 &edge_serial->serial->dev->dev); in load_application_firmware()
2661 rec = (const struct ihex_binrec *)fw->data; in load_application_firmware()
2662 build = (rec->data[2] << 8) | rec->data[3]; in load_application_firmware()
2664 dev_dbg(dev, "%s %d.%d.%d\n", fw_info, rec->data[0], rec->data[1], build); in load_application_firmware()
2666 edge_serial->product_info.FirmwareMajorVersion = rec->data[0]; in load_application_firmware()
2667 edge_serial->product_info.FirmwareMinorVersion = rec->data[1]; in load_application_firmware()
2668 edge_serial->product_info.FirmwareBuildNumber = cpu_to_le16(build); in load_application_firmware()
2672 Operaddr = be32_to_cpu(rec->addr); in load_application_firmware()
2673 response = sram_write(edge_serial->serial, in load_application_firmware()
2676 be16_to_cpu(rec->len), in load_application_firmware()
2677 &rec->data[0]); in load_application_firmware()
2679 dev_err(&edge_serial->serial->dev->dev, in load_application_firmware()
2682 be16_to_cpu(rec->len)); in load_application_firmware()
2688 response = usb_control_msg (edge_serial->serial->dev, in load_application_firmware()
2689 usb_sndctrlpipe(edge_serial->serial->dev, 0), in load_application_firmware()
2693 release_firmware(fw); in load_application_firmware()
2704 struct device *ddev = &serial->dev->dev; in edge_startup()
2714 dev = serial->dev; in edge_startup()
2719 return -ENOMEM; in edge_startup()
2721 spin_lock_init(&edge_serial->es_lock); in edge_startup()
2722 edge_serial->serial = serial; in edge_startup()
2726 i = usb_string(dev, dev->descriptor.iManufacturer, in edge_startup()
2727 &edge_serial->name[0], MAX_NAME_LEN+1); in edge_startup()
2730 edge_serial->name[i++] = ' '; in edge_startup()
2731 usb_string(dev, dev->descriptor.iProduct, in edge_startup()
2732 &edge_serial->name[i], MAX_NAME_LEN+2 - i); in edge_startup()
2734 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name); in edge_startup()
2739 memcpy(&edge_serial->epic_descriptor.Supports, descriptor, in edge_startup()
2752 /* serial->num_ports = serial->product_info.NumPorts; */ in edge_startup()
2753 if ((!edge_serial->is_epic) && in edge_startup()
2754 (edge_serial->product_info.NumPorts != serial->num_ports)) { in edge_startup()
2757 edge_serial->product_info.NumPorts, in edge_startup()
2758 serial->num_ports); in edge_startup()
2761 dev_dbg(ddev, "%s - time 1 %ld\n", __func__, jiffies); in edge_startup()
2764 if (!edge_serial->is_epic) { in edge_startup()
2768 dev_dbg(ddev, "%s - time 2 %ld\n", __func__, jiffies); in edge_startup()
2773 dev_dbg(ddev, "%s - time 3 %ld\n", __func__, jiffies); in edge_startup()
2780 edge_serial->product_info.FirmwareMajorVersion, in edge_startup()
2781 edge_serial->product_info.FirmwareMinorVersion, in edge_startup()
2782 le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber)); in edge_startup()
2789 if (edge_serial->is_epic) { in edge_startup()
2792 alt = serial->interface->cur_altsetting; in edge_startup()
2797 for (i = 0; i < alt->desc.bNumEndpoints; ++i) { in edge_startup()
2801 endpoint = &alt->endpoint[i].desc; in edge_startup()
2809 edge_serial->interrupt_read_urb = in edge_startup()
2811 if (!edge_serial->interrupt_read_urb) { in edge_startup()
2812 response = -ENOMEM; in edge_startup()
2816 edge_serial->interrupt_in_buffer = in edge_startup()
2818 if (!edge_serial->interrupt_in_buffer) { in edge_startup()
2819 response = -ENOMEM; in edge_startup()
2822 edge_serial->interrupt_in_endpoint = in edge_startup()
2823 endpoint->bEndpointAddress; in edge_startup()
2827 edge_serial->interrupt_read_urb, in edge_startup()
2830 endpoint->bEndpointAddress), in edge_startup()
2831 edge_serial->interrupt_in_buffer, in edge_startup()
2835 endpoint->bInterval); in edge_startup()
2846 edge_serial->read_urb = in edge_startup()
2848 if (!edge_serial->read_urb) { in edge_startup()
2849 response = -ENOMEM; in edge_startup()
2853 edge_serial->bulk_in_buffer = in edge_startup()
2855 if (!edge_serial->bulk_in_buffer) { in edge_startup()
2856 response = -ENOMEM; in edge_startup()
2859 edge_serial->bulk_in_endpoint = in edge_startup()
2860 endpoint->bEndpointAddress; in edge_startup()
2863 usb_fill_bulk_urb(edge_serial->read_urb, dev, in edge_startup()
2865 endpoint->bEndpointAddress), in edge_startup()
2866 edge_serial->bulk_in_buffer, in edge_startup()
2877 edge_serial->bulk_out_endpoint = in edge_startup()
2878 endpoint->bEndpointAddress; in edge_startup()
2887 response = -ENODEV; in edge_startup()
2895 response = usb_submit_urb(edge_serial->interrupt_read_urb, in edge_startup()
2898 dev_err(ddev, "%s - Error %d submitting control urb\n", in edge_startup()
2907 usb_free_urb(edge_serial->interrupt_read_urb); in edge_startup()
2908 kfree(edge_serial->interrupt_in_buffer); in edge_startup()
2910 usb_free_urb(edge_serial->read_urb); in edge_startup()
2911 kfree(edge_serial->bulk_in_buffer); in edge_startup()
2927 if (edge_serial->is_epic) { in edge_disconnect()
2928 usb_kill_urb(edge_serial->interrupt_read_urb); in edge_disconnect()
2929 usb_kill_urb(edge_serial->read_urb); in edge_disconnect()
2942 if (edge_serial->is_epic) { in edge_release()
2943 usb_kill_urb(edge_serial->interrupt_read_urb); in edge_release()
2944 usb_free_urb(edge_serial->interrupt_read_urb); in edge_release()
2945 kfree(edge_serial->interrupt_in_buffer); in edge_release()
2947 usb_kill_urb(edge_serial->read_urb); in edge_release()
2948 usb_free_urb(edge_serial->read_urb); in edge_release()
2949 kfree(edge_serial->bulk_in_buffer); in edge_release()
2961 return -ENOMEM; in edge_port_probe()
2963 spin_lock_init(&edge_port->ep_lock); in edge_port_probe()
2964 edge_port->port = port; in edge_port_probe()
3125 MODULE_FIRMWARE("edgeport/boot.fw");
3126 MODULE_FIRMWARE("edgeport/boot2.fw");
3127 MODULE_FIRMWARE("edgeport/down.fw");
3128 MODULE_FIRMWARE("edgeport/down2.fw");