Lines Matching +full:serial +full:- +full:number
1 // SPDX-License-Identifier: GPL-2.0+
3 * Edgeport USB Serial Converter driver
5 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
6 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
26 #include <linux/serial.h>
33 #include <linux/usb/serial.h>
39 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
40 #define DRIVER_DESC "Edgeport USB Serial Driver"
76 * "length" is the number of bytes of actual data following the header.
97 * Number of milliseconds the UMP will
122 struct usb_serial *serial; member
228 static int do_download_mode(struct edgeport_serial *serial,
230 static int do_boot_mode(struct edgeport_serial *serial,
269 dev_dbg(&dev->dev, "%s - wanted to read %d, but only read %d\n", in ti_vread_sync()
271 return -ECOMM; in ti_vread_sync()
293 return ti_vread_sync(port->serial->dev, command, value, in read_port_cmd()
294 UMPM_UART1_PORT + port->port_number, in read_port_cmd()
301 return ti_vsend_sync(port->serial->dev, command, value, in send_port_cmd()
302 UMPM_UART1_PORT + port->port_number, in send_port_cmd()
309 int port_number = port->port_number; in purge_port()
311 dev_dbg(&port->dev, "%s - port %d, mask %x\n", __func__, port_number, mask); in purge_port()
317 * read_download_mem - Read edgeport memory from TI chip
331 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length); in read_download_mem()
344 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length); in read_download_mem()
347 * NOTE: Must use swab as wIndex is sent in little-endian in read_download_mem()
357 dev_dbg(&dev->dev, "%s - ERROR %x\n", __func__, status); in read_download_mem()
362 usb_serial_debug_data(&dev->dev, __func__, read_length, buffer); in read_download_mem()
367 length -= read_length; in read_download_mem()
381 static int read_boot_mem(struct edgeport_serial *serial, in read_boot_mem() argument
388 status = ti_vread_sync(serial->serial->dev, in read_boot_mem()
389 UMPC_MEMORY_READ, serial->TI_I2C_Type, in read_boot_mem()
392 dev_dbg(&serial->serial->dev->dev, "%s - ERROR %x\n", __func__, status); in read_boot_mem()
397 dev_dbg(&serial->serial->dev->dev, "%s - start_address = %x, length = %d\n", in read_boot_mem()
399 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); in read_boot_mem()
401 serial->TiReadI2C = 1; in read_boot_mem()
407 static int write_boot_mem(struct edgeport_serial *serial, in write_boot_mem() argument
415 if (!serial->TiReadI2C) { in write_boot_mem()
418 return -ENOMEM; in write_boot_mem()
420 status = read_boot_mem(serial, 0, 1, temp); in write_boot_mem()
427 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, in write_boot_mem()
434 …dev_dbg(&serial->serial->dev->dev, "%s - start_sddr = %x, length = %d\n", __func__, start_address,… in write_boot_mem()
435 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer); in write_boot_mem()
441 static int write_i2c_mem(struct edgeport_serial *serial, in write_i2c_mem() argument
444 struct device *dev = &serial->serial->dev->dev; in write_i2c_mem()
451 /* calculate the number of bytes left in the first page */ in write_i2c_mem()
452 write_length = EPROM_PAGE_SIZE - in write_i2c_mem()
453 (start_address & (EPROM_PAGE_SIZE - 1)); in write_i2c_mem()
458 dev_dbg(dev, "%s - BytesInFirstPage Addr = %x, length = %d\n", in write_i2c_mem()
465 * NOTE: Must use swab as wIndex is sent in little-endian byte order in write_i2c_mem()
469 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, in write_i2c_mem()
473 dev_dbg(dev, "%s - ERROR %d\n", __func__, status); in write_i2c_mem()
477 length -= write_length; in write_i2c_mem()
482 * We should be aligned now -- can write max page size bytes at a in write_i2c_mem()
491 dev_dbg(dev, "%s - Page Write Addr = %x, length = %d\n", in write_i2c_mem()
498 * NOTE: Must use swab as wIndex is sent in little-endian byte in write_i2c_mem()
502 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, in write_i2c_mem()
506 dev_err(dev, "%s - ERROR %d\n", __func__, status); in write_i2c_mem()
510 length -= write_length; in write_i2c_mem()
533 return -ENOMEM; in tx_active()
542 return -ENOMEM; in tx_active()
545 status = read_ram(port->port->serial->dev, port->dma_address, in tx_active()
550 dev_dbg(&port->port->dev, "%s - XByteCount 0x%X\n", __func__, oedb->XByteCount); in tx_active()
553 status = read_ram(port->port->serial->dev, in tx_active()
554 port->uart_base + UMPMEM_OFFS_UART_LSR, 1, lsr); in tx_active()
558 dev_dbg(&port->port->dev, "%s - LSR = 0x%X\n", __func__, *lsr); in tx_active()
561 if ((oedb->XByteCount & 0x80) != 0) in tx_active()
569 dev_dbg(&port->port->dev, "%s - return %d\n", __func__, bytes_left); in tx_active()
585 dev_dbg(&dev->dev, "%s - Number of Interfaces = %d\n", in choose_config()
586 __func__, dev->config->desc.bNumInterfaces); in choose_config()
587 dev_dbg(&dev->dev, "%s - MAX Power = %d\n", in choose_config()
588 __func__, dev->config->desc.bMaxPower * 2); in choose_config()
590 if (dev->config->desc.bNumInterfaces != 1) { in choose_config()
591 dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); in choose_config()
592 return -ENODEV; in choose_config()
598 static int read_rom(struct edgeport_serial *serial, in read_rom() argument
603 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { in read_rom()
604 status = read_download_mem(serial->serial->dev, in read_rom()
607 serial->TI_I2C_Type, in read_rom()
610 status = read_boot_mem(serial, start_address, length, in read_rom()
616 static int write_rom(struct edgeport_serial *serial, int start_address, in write_rom() argument
619 if (serial->product_info.TiMode == TI_MODE_BOOT) in write_rom()
620 return write_boot_mem(serial, start_address, length, in write_rom()
623 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) in write_rom()
624 return write_i2c_mem(serial, start_address, length, in write_rom()
625 serial->TI_I2C_Type, buffer); in write_rom()
626 return -EINVAL; in write_rom()
630 static int get_descriptor_addr(struct edgeport_serial *serial, in get_descriptor_addr() argument
639 status = read_rom(serial, in get_descriptor_addr()
646 if (rom_desc->Type == desc_type) in get_descriptor_addr()
650 le16_to_cpu(rom_desc->Size); in get_descriptor_addr()
652 } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); in get_descriptor_addr()
663 for (i = 0; i < le16_to_cpu(rom_desc->Size); i++) in valid_csum()
666 if (cs != rom_desc->CheckSum) { in valid_csum()
667 pr_debug("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); in valid_csum()
668 return -EINVAL; in valid_csum()
674 static int check_i2c_image(struct edgeport_serial *serial) in check_i2c_image() argument
676 struct device *dev = &serial->serial->dev->dev; in check_i2c_image()
685 return -ENOMEM; in check_i2c_image()
690 return -ENOMEM; in check_i2c_image()
694 status = read_rom(serial, 0, 1, buffer); in check_i2c_image()
699 dev_err(dev, "%s - invalid buffer signature\n", __func__); in check_i2c_image()
700 status = -ENODEV; in check_i2c_image()
706 status = read_rom(serial, in check_i2c_image()
714 le16_to_cpu(rom_desc->Size)) > TI_MAX_I2C_SIZE) { in check_i2c_image()
715 status = -ENODEV; in check_i2c_image()
716 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__); in check_i2c_image()
720 dev_dbg(dev, "%s Type = 0x%x\n", __func__, rom_desc->Type); in check_i2c_image()
723 ttype = rom_desc->Type & 0x0f; in check_i2c_image()
727 status = read_rom(serial, start_address + in check_i2c_image()
729 le16_to_cpu(rom_desc->Size), in check_i2c_image()
739 le16_to_cpu(rom_desc->Size); in check_i2c_image()
741 } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && in check_i2c_image()
744 if ((rom_desc->Type != I2C_DESC_TYPE_ION) || in check_i2c_image()
746 status = -ENODEV; in check_i2c_image()
754 static int get_manuf_info(struct edgeport_serial *serial, u8 *buffer) in get_manuf_info() argument
760 struct device *dev = &serial->serial->dev->dev; in get_manuf_info()
764 return -ENOMEM; in get_manuf_info()
766 start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, in get_manuf_info()
770 dev_dbg(dev, "%s - Edge Descriptor not found in I2C\n", __func__); in get_manuf_info()
771 status = -ENODEV; in get_manuf_info()
776 status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc), in get_manuf_info()
777 le16_to_cpu(rom_desc->Size), buffer); in get_manuf_info()
784 dev_dbg(dev, "%s - IonConfig 0x%x\n", __func__, desc->IonConfig); in get_manuf_info()
785 dev_dbg(dev, "%s - Version %d\n", __func__, desc->Version); in get_manuf_info()
786 dev_dbg(dev, "%s - Cpu/Board 0x%x\n", __func__, desc->CpuRev_BoardRev); in get_manuf_info()
787 dev_dbg(dev, "%s - NumPorts %d\n", __func__, desc->NumPorts); in get_manuf_info()
788 dev_dbg(dev, "%s - NumVirtualPorts %d\n", __func__, desc->NumVirtualPorts); in get_manuf_info()
789 dev_dbg(dev, "%s - TotalPorts %d\n", __func__, desc->TotalPorts); in get_manuf_info()
806 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; in build_i2c_fw_hdr()
819 * Allocate a 15.5k buffer + 2 bytes for version number (Firmware in build_i2c_fw_hdr()
822 buffer_size = (((1024 * 16) - 512 ) + in build_i2c_fw_hdr()
827 return -ENOMEM; in build_i2c_fw_hdr()
832 /* Copy version number into firmware record */ in build_i2c_fw_hdr()
835 firmware_rec->Ver_Major = fw_hdr->major_version; in build_i2c_fw_hdr()
836 firmware_rec->Ver_Minor = fw_hdr->minor_version; in build_i2c_fw_hdr()
839 img_header = (struct ti_i2c_image_header *)&fw->data[4]; in build_i2c_fw_hdr()
842 &fw->data[4 + sizeof(struct ti_i2c_image_header)], in build_i2c_fw_hdr()
843 le16_to_cpu(img_header->Length)); in build_i2c_fw_hdr()
853 firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; in build_i2c_fw_hdr()
855 i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; in build_i2c_fw_hdr()
856 i2c_header->Size = cpu_to_le16(buffer_size); in build_i2c_fw_hdr()
857 i2c_header->CheckSum = cs; in build_i2c_fw_hdr()
858 firmware_rec->Ver_Major = fw_hdr->major_version; in build_i2c_fw_hdr()
859 firmware_rec->Ver_Minor = fw_hdr->minor_version; in build_i2c_fw_hdr()
865 static int i2c_type_bootmode(struct edgeport_serial *serial) in i2c_type_bootmode() argument
867 struct device *dev = &serial->serial->dev->dev; in i2c_type_bootmode()
873 return -ENOMEM; in i2c_type_bootmode()
876 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, in i2c_type_bootmode()
879 dev_dbg(dev, "%s - read 2 status error = %d\n", __func__, status); in i2c_type_bootmode()
881 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); in i2c_type_bootmode()
883 dev_dbg(dev, "%s - ROM_TYPE_II\n", __func__); in i2c_type_bootmode()
884 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; in i2c_type_bootmode()
889 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, in i2c_type_bootmode()
892 dev_dbg(dev, "%s - read 3 status error = %d\n", __func__, status); in i2c_type_bootmode()
894 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data); in i2c_type_bootmode()
896 dev_dbg(dev, "%s - ROM_TYPE_III\n", __func__); in i2c_type_bootmode()
897 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; in i2c_type_bootmode()
901 dev_dbg(dev, "%s - Unknown\n", __func__); in i2c_type_bootmode()
902 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; in i2c_type_bootmode()
903 status = -ENODEV; in i2c_type_bootmode()
909 static int bulk_xfer(struct usb_serial *serial, void *buffer, in bulk_xfer() argument
914 status = usb_bulk_msg(serial->dev, in bulk_xfer()
915 usb_sndbulkpipe(serial->dev, in bulk_xfer()
916 serial->port[0]->bulk_out_endpointAddress), in bulk_xfer()
922 static int download_code(struct edgeport_serial *serial, u8 *image, in download_code() argument
933 transfer = image_length - pos; in download_code()
938 status = bulk_xfer(serial->serial, &image[pos], in download_code()
957 return TI_GET_CPU_REVISION(desc->CpuRev_BoardRev); in ti_cpu_rev()
960 static int check_fw_sanity(struct edgeport_serial *serial, in check_fw_sanity() argument
966 struct device *dev = &serial->serial->interface->dev; in check_fw_sanity()
967 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; in check_fw_sanity()
969 if (fw->size < sizeof(struct edgeport_fw_hdr)) { in check_fw_sanity()
971 return -EINVAL; in check_fw_sanity()
974 length_total = le16_to_cpu(fw_hdr->length) + in check_fw_sanity()
977 if (fw->size != length_total) { in check_fw_sanity()
979 length_total, fw->size); in check_fw_sanity()
980 return -EINVAL; in check_fw_sanity()
983 for (pos = sizeof(struct edgeport_fw_hdr); pos < fw->size; ++pos) in check_fw_sanity()
984 checksum += fw->data[pos]; in check_fw_sanity()
986 if (checksum != fw_hdr->checksum) { in check_fw_sanity()
988 fw_hdr->checksum, checksum); in check_fw_sanity()
989 return -EINVAL; in check_fw_sanity()
996 * DownloadTIFirmware - Download run-time operating firmware to the TI5052
1001 static int download_fw(struct edgeport_serial *serial) in download_fw() argument
1003 struct device *dev = &serial->serial->interface->dev; in download_fw()
1017 if (check_fw_sanity(serial, fw)) { in download_fw()
1018 status = -EINVAL; in download_fw()
1022 fw_hdr = (struct edgeport_fw_hdr *)fw->data; in download_fw()
1024 /* If on-board version is newer, "fw_version" will be updated later. */ in download_fw()
1025 serial->fw_version = (fw_hdr->major_version << 8) + in download_fw()
1026 fw_hdr->minor_version; in download_fw()
1033 serial->product_info.hardware_type = HARDWARE_TYPE_TIUMP; in download_fw()
1036 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; in download_fw()
1038 status = choose_config(serial->serial->dev); in download_fw()
1042 interface = &serial->serial->interface->cur_altsetting->desc; in download_fw()
1044 dev_err(dev, "%s - no interface set, error!\n", __func__); in download_fw()
1045 status = -ENODEV; in download_fw()
1050 * Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING in download_fw()
1054 if (interface->bNumEndpoints > 1) { in download_fw()
1055 serial->product_info.TiMode = TI_MODE_DOWNLOAD; in download_fw()
1056 status = do_download_mode(serial, fw); in download_fw()
1059 serial->product_info.TiMode = TI_MODE_CONFIGURING; in download_fw()
1060 status = do_boot_mode(serial, fw); in download_fw()
1068 static int do_download_mode(struct edgeport_serial *serial, in do_download_mode() argument
1071 struct device *dev = &serial->serial->interface->dev; in do_download_mode()
1077 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; in do_download_mode()
1080 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__); in do_download_mode()
1082 status = check_i2c_image(serial); in do_download_mode()
1084 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__); in do_download_mode()
1089 * Validate Hardware version number in do_download_mode()
1094 return -ENOMEM; in do_download_mode()
1096 status = get_manuf_info(serial, (u8 *)ti_manuf_desc); in do_download_mode()
1102 /* Check version number of ION descriptor */ in do_download_mode()
1104 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", in do_download_mode()
1107 return -EINVAL; in do_download_mode()
1113 return -ENOMEM; in do_download_mode()
1117 start_address = get_descriptor_addr(serial, in do_download_mode()
1123 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", in do_download_mode()
1131 return -ENOMEM; in do_download_mode()
1135 * Validate version number in do_download_mode()
1138 status = read_rom(serial, start_address + in do_download_mode()
1150 * Check version number of download with current in do_download_mode()
1153 download_cur_ver = (firmware_version->Ver_Major << 8) + in do_download_mode()
1154 (firmware_version->Ver_Minor); in do_download_mode()
1155 download_new_ver = (fw_hdr->major_version << 8) + in do_download_mode()
1156 (fw_hdr->minor_version); in do_download_mode()
1158 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n", in do_download_mode()
1159 __func__, firmware_version->Ver_Major, in do_download_mode()
1160 firmware_version->Ver_Minor, in do_download_mode()
1161 fw_hdr->major_version, fw_hdr->minor_version); in do_download_mode()
1168 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n", in do_download_mode()
1170 firmware_version->Ver_Major, in do_download_mode()
1171 firmware_version->Ver_Minor, in do_download_mode()
1172 fw_hdr->major_version, in do_download_mode()
1173 fw_hdr->minor_version); in do_download_mode()
1180 return -ENOMEM; in do_download_mode()
1201 status = write_rom(serial, start_address, in do_download_mode()
1212 * verify the write -- must do this in order in do_download_mode()
1216 status = read_rom(serial, in do_download_mode()
1229 dev_err(dev, "%s - error resetting device\n", in do_download_mode()
1235 return -ENODEV; in do_download_mode()
1238 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__); in do_download_mode()
1240 /* Reset UMP -- Back to BOOT MODE */ in do_download_mode()
1241 status = ti_vsend_sync(serial->serial->dev, in do_download_mode()
1246 dev_dbg(dev, "%s - HARDWARE RESET return %d\n", in do_download_mode()
1254 return -ENODEV; in do_download_mode()
1257 serial->fw_version = download_cur_ver; in do_download_mode()
1262 start_address = get_descriptor_addr(serial, in do_download_mode()
1274 return -ENOMEM; in do_download_mode()
1282 return -ENOMEM; in do_download_mode()
1285 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", in do_download_mode()
1305 return -EINVAL; in do_download_mode()
1312 status = write_rom(serial, in do_download_mode()
1321 return -EINVAL; in do_download_mode()
1325 * verify the write -- must do this in order for in do_download_mode()
1328 status = read_rom(serial, start_address, in do_download_mode()
1332 dev_dbg(dev, "%s - can't read header back\n", in do_download_mode()
1341 dev_dbg(dev, "%s - write download record failed\n", in do_download_mode()
1347 return -EINVAL; in do_download_mode()
1353 dev_dbg(dev, "%s - Start firmware update\n", __func__); in do_download_mode()
1356 status = ti_vsend_sync(serial->serial->dev, in do_download_mode()
1361 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, in do_download_mode()
1365 "%s - UMPC_COPY_DNLD_TO_I2C failed\n", in do_download_mode()
1380 static int do_boot_mode(struct edgeport_serial *serial, in do_boot_mode() argument
1383 struct device *dev = &serial->serial->interface->dev; in do_boot_mode()
1386 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; in do_boot_mode()
1388 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__); in do_boot_mode()
1391 status = config_boot_dev(serial->serial->dev); in do_boot_mode()
1395 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) in do_boot_mode()
1397 dev_dbg(dev, "%s - VID = 0x%x\n", __func__, in do_boot_mode()
1398 le16_to_cpu(serial->serial->dev->descriptor.idVendor)); in do_boot_mode()
1399 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; in do_boot_mode()
1407 if (i2c_type_bootmode(serial)) in do_boot_mode()
1411 if (!check_i2c_image(serial)) { in do_boot_mode()
1419 * Validate Hardware version number in do_boot_mode()
1424 return -ENOMEM; in do_boot_mode()
1426 status = get_manuf_info(serial, (u8 *)ti_manuf_desc); in do_boot_mode()
1434 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", in do_boot_mode()
1457 buffer_size = (((1024 * 16) - 512) + in do_boot_mode()
1461 return -ENOMEM; in do_boot_mode()
1465 memcpy(buffer, &fw->data[4], fw->size - 4); in do_boot_mode()
1475 header->Length = cpu_to_le16((u16)(buffer_size - in do_boot_mode()
1477 header->CheckSum = cs; in do_boot_mode()
1480 dev_dbg(dev, "%s - Downloading operational code image version %d.%d (TI UMP)\n", in do_boot_mode()
1482 fw_hdr->major_version, fw_hdr->minor_version); in do_boot_mode()
1483 status = download_code(serial, buffer, buffer_size); in do_boot_mode()
1488 dev_dbg(dev, "%s - Error downloading operational code image\n", __func__); in do_boot_mode()
1493 serial->product_info.TiMode = TI_MODE_TRANSITIONING; in do_boot_mode()
1495 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); in do_boot_mode()
1502 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); in do_boot_mode()
1503 serial->product_info.TiMode = TI_MODE_BOOT; in do_boot_mode()
1512 return send_port_cmd(port->port, feature, on, NULL, 0); in ti_do_config()
1519 dev_dbg(&port->port->dev, "%s - %x\n", __func__, mcr); in restore_mcr()
1556 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr); in handle_new_msr()
1560 icount = &edge_port->port->icount; in handle_new_msr()
1564 icount->cts++; in handle_new_msr()
1566 icount->dsr++; in handle_new_msr()
1568 icount->dcd++; in handle_new_msr()
1570 icount->rng++; in handle_new_msr()
1571 wake_up_interruptible(&edge_port->port->port.delta_msr_wait); in handle_new_msr()
1575 edge_port->shadow_msr = msr & 0xf0; in handle_new_msr()
1577 tty = tty_port_tty_get(&edge_port->port->port); in handle_new_msr()
1593 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); in handle_new_lsr()
1595 edge_port->shadow_lsr = lsr; in handle_new_lsr()
1606 edge_tty_recv(edge_port->port, &data, 1); in handle_new_lsr()
1609 icount = &edge_port->port->icount; in handle_new_lsr()
1611 icount->brk++; in handle_new_lsr()
1613 icount->overrun++; in handle_new_lsr()
1615 icount->parity++; in handle_new_lsr()
1617 icount->frame++; in handle_new_lsr()
1622 struct edgeport_serial *edge_serial = urb->context; in edge_interrupt_callback()
1626 unsigned char *data = urb->transfer_buffer; in edge_interrupt_callback()
1627 int length = urb->actual_length; in edge_interrupt_callback()
1633 int status = urb->status; in edge_interrupt_callback()
1639 case -ECONNRESET: in edge_interrupt_callback()
1640 case -ENOENT: in edge_interrupt_callback()
1641 case -ESHUTDOWN: in edge_interrupt_callback()
1643 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", in edge_interrupt_callback()
1647 dev_err(&urb->dev->dev, "%s - nonzero urb status received: " in edge_interrupt_callback()
1653 dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__); in edge_interrupt_callback()
1657 dev = &edge_serial->serial->dev->dev; in edge_interrupt_callback()
1661 dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length); in edge_interrupt_callback()
1667 dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__, in edge_interrupt_callback()
1670 if (port_number >= edge_serial->serial->num_ports) { in edge_interrupt_callback()
1671 dev_err(dev, "bad port number %d\n", port_number); in edge_interrupt_callback()
1675 port = edge_serial->serial->port[port_number]; in edge_interrupt_callback()
1678 dev_dbg(dev, "%s - edge_port not found\n", __func__); in edge_interrupt_callback()
1688 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n", in edge_interrupt_callback()
1690 edge_port->lsr_event = 1; in edge_interrupt_callback()
1691 edge_port->lsr_mask = lsr; in edge_interrupt_callback()
1693 dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n", in edge_interrupt_callback()
1702 dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n", in edge_interrupt_callback()
1708 dev_err(&urb->dev->dev, in edge_interrupt_callback()
1709 "%s - Unknown Interrupt code from UMP %x\n", in edge_interrupt_callback()
1718 dev_err(&urb->dev->dev, in edge_interrupt_callback()
1719 "%s - usb_submit_urb failed with result %d\n", in edge_interrupt_callback()
1725 struct edgeport_port *edge_port = urb->context; in edge_bulk_in_callback()
1726 struct device *dev = &edge_port->port->dev; in edge_bulk_in_callback()
1727 unsigned char *data = urb->transfer_buffer; in edge_bulk_in_callback()
1731 int status = urb->status; in edge_bulk_in_callback()
1737 case -ECONNRESET: in edge_bulk_in_callback()
1738 case -ENOENT: in edge_bulk_in_callback()
1739 case -ESHUTDOWN: in edge_bulk_in_callback()
1741 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status); in edge_bulk_in_callback()
1744 dev_err(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", __func__, status); in edge_bulk_in_callback()
1747 if (status == -EPIPE) in edge_bulk_in_callback()
1751 dev_err(&urb->dev->dev, "%s - stopping read!\n", __func__); in edge_bulk_in_callback()
1755 port_number = edge_port->port->port_number; in edge_bulk_in_callback()
1757 if (urb->actual_length > 0 && edge_port->lsr_event) { in edge_bulk_in_callback()
1758 edge_port->lsr_event = 0; in edge_bulk_in_callback()
1760 __func__, port_number, edge_port->lsr_mask, *data); in edge_bulk_in_callback()
1761 handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); in edge_bulk_in_callback()
1763 --urb->actual_length; in edge_bulk_in_callback()
1767 if (urb->actual_length) { in edge_bulk_in_callback()
1768 usb_serial_debug_data(dev, __func__, urb->actual_length, data); in edge_bulk_in_callback()
1769 if (edge_port->close_pending) in edge_bulk_in_callback()
1770 dev_dbg(dev, "%s - close pending, dropping data on the floor\n", in edge_bulk_in_callback()
1773 edge_tty_recv(edge_port->port, data, in edge_bulk_in_callback()
1774 urb->actual_length); in edge_bulk_in_callback()
1775 edge_port->port->icount.rx += urb->actual_length; in edge_bulk_in_callback()
1780 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_bulk_in_callback()
1781 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) in edge_bulk_in_callback()
1783 else if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPING) in edge_bulk_in_callback()
1784 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPED; in edge_bulk_in_callback()
1786 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_bulk_in_callback()
1788 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); in edge_bulk_in_callback()
1796 queued = tty_insert_flip_string(&port->port, data, length); in edge_tty_recv()
1798 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", in edge_tty_recv()
1799 __func__, length - queued); in edge_tty_recv()
1800 tty_flip_buffer_push(&port->port); in edge_tty_recv()
1805 struct usb_serial_port *port = urb->context; in edge_bulk_out_callback()
1807 int status = urb->status; in edge_bulk_out_callback()
1810 edge_port->ep_write_urb_in_use = 0; in edge_bulk_out_callback()
1816 case -ECONNRESET: in edge_bulk_out_callback()
1817 case -ENOENT: in edge_bulk_out_callback()
1818 case -ESHUTDOWN: in edge_bulk_out_callback()
1820 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", in edge_bulk_out_callback()
1824 dev_err_console(port, "%s - nonzero write bulk status " in edge_bulk_out_callback()
1829 tty = tty_port_tty_get(&port->port); in edge_bulk_out_callback()
1845 return -ENODEV; in edge_open()
1847 dev = port->serial->dev; in edge_open()
1852 dev_err(&port->dev, in edge_open()
1853 "%s - cannot send clear loopback command, %d\n", in edge_open()
1860 edge_set_termios(tty, port, &tty->termios); in edge_open()
1867 edge_port->ump_read_timeout = in edge_open()
1875 dev_dbg(&port->dev, "%s - Sending UMPC_OPEN_PORT\n", __func__); in edge_open()
1880 dev_err(&port->dev, "%s - cannot send open command, %d\n", in edge_open()
1888 dev_err(&port->dev, "%s - cannot send start DMA command, %d\n", in edge_open()
1896 dev_err(&port->dev, in edge_open()
1897 "%s - cannot send clear buffers command, %d\n", in edge_open()
1903 status = read_port_cmd(port, UMPC_READ_MSR, 0, &edge_port->shadow_msr, 1); in edge_open()
1905 dev_err(&port->dev, "%s - cannot send read MSR command, %d\n", in edge_open()
1910 dev_dbg(&port->dev, "ShadowMSR 0x%X\n", edge_port->shadow_msr); in edge_open()
1913 edge_port->shadow_mcr = MCR_RTS | MCR_DTR; in edge_open()
1914 dev_dbg(&port->dev, "ShadowMCR 0x%X\n", edge_port->shadow_mcr); in edge_open()
1916 edge_serial = edge_port->edge_serial; in edge_open()
1917 if (mutex_lock_interruptible(&edge_serial->es_lock)) in edge_open()
1918 return -ERESTARTSYS; in edge_open()
1919 if (edge_serial->num_ports_open == 0) { in edge_open()
1921 urb = edge_serial->serial->port[0]->interrupt_in_urb; in edge_open()
1922 urb->context = edge_serial; in edge_open()
1925 dev_err(&port->dev, in edge_open()
1926 "%s - usb_submit_urb failed with value %d\n", in edge_open()
1936 usb_clear_halt(dev, port->write_urb->pipe); in edge_open()
1937 usb_clear_halt(dev, port->read_urb->pipe); in edge_open()
1940 urb = port->read_urb; in edge_open()
1941 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; in edge_open()
1942 urb->context = edge_port; in edge_open()
1945 dev_err(&port->dev, in edge_open()
1946 "%s - read bulk usb_submit_urb failed with value %d\n", in edge_open()
1951 ++edge_serial->num_ports_open; in edge_open()
1956 if (edge_port->edge_serial->num_ports_open == 0) in edge_open()
1957 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); in edge_open()
1959 mutex_unlock(&edge_serial->es_lock); in edge_open()
1969 edge_serial = usb_get_serial_data(port->serial); in edge_close()
1978 edge_port->close_pending = 1; in edge_close()
1980 usb_kill_urb(port->read_urb); in edge_close()
1981 usb_kill_urb(port->write_urb); in edge_close()
1982 edge_port->ep_write_urb_in_use = 0; in edge_close()
1983 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_close()
1984 kfifo_reset_out(&port->write_fifo); in edge_close()
1985 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_close()
1987 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__); in edge_close()
1990 mutex_lock(&edge_serial->es_lock); in edge_close()
1991 --edge_port->edge_serial->num_ports_open; in edge_close()
1992 if (edge_port->edge_serial->num_ports_open <= 0) { in edge_close()
1994 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); in edge_close()
1995 edge_port->edge_serial->num_ports_open = 0; in edge_close()
1997 mutex_unlock(&edge_serial->es_lock); in edge_close()
1998 edge_port->close_pending = 0; in edge_close()
2007 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); in edge_write()
2012 return -ENODEV; in edge_write()
2013 if (edge_port->close_pending == 1) in edge_write()
2014 return -ENODEV; in edge_write()
2016 count = kfifo_in_locked(&port->write_fifo, data, count, in edge_write()
2017 &edge_port->ep_lock); in edge_write()
2029 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_send()
2031 if (edge_port->ep_write_urb_in_use) { in edge_send()
2032 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_send()
2036 count = kfifo_out(&port->write_fifo, in edge_send()
2037 port->write_urb->transfer_buffer, in edge_send()
2038 port->bulk_out_size); in edge_send()
2041 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_send()
2045 edge_port->ep_write_urb_in_use = 1; in edge_send()
2047 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_send()
2049 usb_serial_debug_data(&port->dev, __func__, count, port->write_urb->transfer_buffer); in edge_send()
2052 port->write_urb->transfer_buffer_length = count; in edge_send()
2055 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); in edge_send()
2058 "%s - failed submitting write urb, error %d\n", in edge_send()
2060 edge_port->ep_write_urb_in_use = 0; in edge_send()
2063 edge_port->port->icount.tx += count; in edge_send()
2075 struct usb_serial_port *port = tty->driver_data; in edge_write_room()
2082 if (edge_port->close_pending == 1) in edge_write_room()
2085 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_write_room()
2086 room = kfifo_avail(&port->write_fifo); in edge_write_room()
2087 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_write_room()
2089 dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); in edge_write_room()
2095 struct usb_serial_port *port = tty->driver_data; in edge_chars_in_buffer()
2102 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_chars_in_buffer()
2103 chars = kfifo_len(&port->write_fifo); in edge_chars_in_buffer()
2104 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_chars_in_buffer()
2106 dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars); in edge_chars_in_buffer()
2124 struct usb_serial_port *port = tty->driver_data; in edge_throttle()
2136 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); in edge_throttle()
2151 struct usb_serial_port *port = tty->driver_data; in edge_unthrottle()
2163 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); in edge_unthrottle()
2173 dev_err(&port->dev, in edge_unthrottle()
2174 "%s - read bulk usb_submit_urb failed: %d\n", in edge_unthrottle()
2184 spin_lock_irqsave(&edge_port->ep_lock, flags); in stop_read()
2186 if (edge_port->ep_read_urb_state == EDGE_READ_URB_RUNNING) in stop_read()
2187 edge_port->ep_read_urb_state = EDGE_READ_URB_STOPPING; in stop_read()
2188 edge_port->shadow_mcr &= ~MCR_RTS; in stop_read()
2190 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in stop_read()
2199 spin_lock_irqsave(&edge_port->ep_lock, flags); in restart_read()
2201 if (edge_port->ep_read_urb_state == EDGE_READ_URB_STOPPED) { in restart_read()
2202 urb = edge_port->port->read_urb; in restart_read()
2205 edge_port->ep_read_urb_state = EDGE_READ_URB_RUNNING; in restart_read()
2206 edge_port->shadow_mcr |= MCR_RTS; in restart_read()
2208 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in restart_read()
2216 struct device *dev = &edge_port->port->dev; in change_port_settings()
2224 tty->termios = *old_termios; in change_port_settings()
2228 cflag = tty->termios.c_cflag; in change_port_settings()
2230 config->wFlags = 0; in change_port_settings()
2233 config->wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT; in change_port_settings()
2234 config->wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR; in change_port_settings()
2235 config->bUartMode = (u8)(edge_port->bUartMode); in change_port_settings()
2239 config->bDataBits = UMP_UART_CHAR5BITS; in change_port_settings()
2240 dev_dbg(dev, "%s - data bits = 5\n", __func__); in change_port_settings()
2243 config->bDataBits = UMP_UART_CHAR6BITS; in change_port_settings()
2244 dev_dbg(dev, "%s - data bits = 6\n", __func__); in change_port_settings()
2247 config->bDataBits = UMP_UART_CHAR7BITS; in change_port_settings()
2248 dev_dbg(dev, "%s - data bits = 7\n", __func__); in change_port_settings()
2252 config->bDataBits = UMP_UART_CHAR8BITS; in change_port_settings()
2253 dev_dbg(dev, "%s - data bits = 8\n", __func__); in change_port_settings()
2259 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; in change_port_settings()
2260 config->bParity = UMP_UART_ODDPARITY; in change_port_settings()
2261 dev_dbg(dev, "%s - parity = odd\n", __func__); in change_port_settings()
2263 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; in change_port_settings()
2264 config->bParity = UMP_UART_EVENPARITY; in change_port_settings()
2265 dev_dbg(dev, "%s - parity = even\n", __func__); in change_port_settings()
2268 config->bParity = UMP_UART_NOPARITY; in change_port_settings()
2269 dev_dbg(dev, "%s - parity = none\n", __func__); in change_port_settings()
2273 config->bStopBits = UMP_UART_STOPBIT2; in change_port_settings()
2274 dev_dbg(dev, "%s - stop bits = 2\n", __func__); in change_port_settings()
2276 config->bStopBits = UMP_UART_STOPBIT1; in change_port_settings()
2277 dev_dbg(dev, "%s - stop bits = 1\n", __func__); in change_port_settings()
2282 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; in change_port_settings()
2283 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; in change_port_settings()
2284 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__); in change_port_settings()
2286 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__); in change_port_settings()
2294 config->cXon = START_CHAR(tty); in change_port_settings()
2295 config->cXoff = STOP_CHAR(tty); in change_port_settings()
2299 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; in change_port_settings()
2300 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", in change_port_settings()
2301 __func__, config->cXon, config->cXoff); in change_port_settings()
2303 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__); in change_port_settings()
2307 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; in change_port_settings()
2308 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n", in change_port_settings()
2309 __func__, config->cXon, config->cXoff); in change_port_settings()
2311 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__); in change_port_settings()
2313 tty->termios.c_cflag &= ~CMSPAR; in change_port_settings()
2326 edge_port->baud_rate = baud; in change_port_settings()
2327 config->wBaudRate = (u16)((461550L + baud/2) / baud); in change_port_settings()
2331 dev_dbg(dev, "%s - baud rate = %d, wBaudRate = %d\n", __func__, baud, config->wBaudRate); in change_port_settings()
2333 dev_dbg(dev, "wBaudRate: %d\n", (int)(461550L / config->wBaudRate)); in change_port_settings()
2334 dev_dbg(dev, "wFlags: 0x%x\n", config->wFlags); in change_port_settings()
2335 dev_dbg(dev, "bDataBits: %d\n", config->bDataBits); in change_port_settings()
2336 dev_dbg(dev, "bParity: %d\n", config->bParity); in change_port_settings()
2337 dev_dbg(dev, "bStopBits: %d\n", config->bStopBits); in change_port_settings()
2338 dev_dbg(dev, "cXon: %d\n", config->cXon); in change_port_settings()
2339 dev_dbg(dev, "cXoff: %d\n", config->cXoff); in change_port_settings()
2340 dev_dbg(dev, "bUartMode: %d\n", config->bUartMode); in change_port_settings()
2343 cpu_to_be16s(&config->wFlags); in change_port_settings()
2344 cpu_to_be16s(&config->wBaudRate); in change_port_settings()
2346 status = send_port_cmd(edge_port->port, UMPC_SET_CONFIG, 0, config, in change_port_settings()
2349 dev_dbg(dev, "%s - error %d when trying to write config to device\n", in change_port_settings()
2369 struct usb_serial_port *port = tty->driver_data; in edge_tiocmset()
2374 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_tiocmset()
2375 mcr = edge_port->shadow_mcr; in edge_tiocmset()
2390 edge_port->shadow_mcr = mcr; in edge_tiocmset()
2391 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_tiocmset()
2399 struct usb_serial_port *port = tty->driver_data; in edge_tiocmget()
2406 spin_lock_irqsave(&edge_port->ep_lock, flags); in edge_tiocmget()
2408 msr = edge_port->shadow_msr; in edge_tiocmget()
2409 mcr = edge_port->shadow_mcr; in edge_tiocmget()
2418 dev_dbg(&port->dev, "%s -- %x\n", __func__, result); in edge_tiocmget()
2419 spin_unlock_irqrestore(&edge_port->ep_lock, flags); in edge_tiocmget()
2426 struct usb_serial_port *port = tty->driver_data; in edge_break()
2431 if (break_state == -1) in edge_break()
2436 dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n", in edge_break()
2446 if (!edge_serial->use_heartbeat) in edge_heartbeat_schedule()
2449 schedule_delayed_work(&edge_serial->heartbeat_work, in edge_heartbeat_schedule()
2455 struct edgeport_serial *serial; in edge_heartbeat_work() local
2458 serial = container_of(work, struct edgeport_serial, in edge_heartbeat_work()
2464 if (!rom_desc || !get_descriptor_addr(serial, I2C_DESC_TYPE_ION, in edge_heartbeat_work()
2466 dev_err(&serial->serial->interface->dev, in edge_heartbeat_work()
2467 "%s - Incomplete heartbeat\n", __func__); in edge_heartbeat_work()
2471 edge_heartbeat_schedule(serial); in edge_heartbeat_work()
2474 static int edge_calc_num_ports(struct usb_serial *serial, in edge_calc_num_ports() argument
2477 struct device *dev = &serial->interface->dev; in edge_calc_num_ports()
2478 unsigned char num_ports = serial->type->num_ports; in edge_calc_num_ports()
2481 if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) { in edge_calc_num_ports()
2482 if (epds->num_bulk_in < num_ports || in edge_calc_num_ports()
2483 epds->num_bulk_out < num_ports || in edge_calc_num_ports()
2484 epds->num_interrupt_in < 1) { in edge_calc_num_ports()
2486 return -ENODEV; in edge_calc_num_ports()
2493 static int edge_startup(struct usb_serial *serial) in edge_startup() argument
2499 /* create our private serial structure */ in edge_startup()
2502 return -ENOMEM; in edge_startup()
2504 mutex_init(&edge_serial->es_lock); in edge_startup()
2505 edge_serial->serial = serial; in edge_startup()
2506 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work); in edge_startup()
2507 usb_set_serial_data(serial, edge_serial); in edge_startup()
2519 edge_serial->serial->dev->descriptor.idProduct); in edge_startup()
2522 if (edge_serial->fw_version > FW_HEARTBEAT_VERSION_CUTOFF) { in edge_startup()
2525 edge_serial->use_heartbeat = true; in edge_startup()
2534 static void edge_disconnect(struct usb_serial *serial) in edge_disconnect() argument
2536 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); in edge_disconnect()
2538 cancel_delayed_work_sync(&edge_serial->heartbeat_work); in edge_disconnect()
2541 static void edge_release(struct usb_serial *serial) in edge_release() argument
2543 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); in edge_release()
2545 cancel_delayed_work_sync(&edge_serial->heartbeat_work); in edge_release()
2556 return -ENOMEM; in edge_port_probe()
2558 spin_lock_init(&edge_port->ep_lock); in edge_port_probe()
2559 edge_port->port = port; in edge_port_probe()
2560 edge_port->edge_serial = usb_get_serial_data(port->serial); in edge_port_probe()
2561 edge_port->bUartMode = default_uart_mode; in edge_port_probe()
2563 switch (port->port_number) { in edge_port_probe()
2565 edge_port->uart_base = UMPMEM_BASE_UART1; in edge_port_probe()
2566 edge_port->dma_address = UMPD_OEDB1_ADDRESS; in edge_port_probe()
2569 edge_port->uart_base = UMPMEM_BASE_UART2; in edge_port_probe()
2570 edge_port->dma_address = UMPD_OEDB2_ADDRESS; in edge_port_probe()
2573 dev_err(&port->dev, "unknown port number\n"); in edge_port_probe()
2574 ret = -ENODEV; in edge_port_probe()
2578 dev_dbg(&port->dev, in edge_port_probe()
2579 "%s - port_number = %d, uart_base = %04x, dma_address = %04x\n", in edge_port_probe()
2580 __func__, port->port_number, edge_port->uart_base, in edge_port_probe()
2581 edge_port->dma_address); in edge_port_probe()
2591 * emptied so add a one-character drain delay. in edge_port_probe()
2593 port->port.drain_delay = 1; in edge_port_probe()
2619 return sprintf(buf, "%d\n", edge_port->bUartMode); in uart_mode_show()
2632 edge_port->bUartMode = v; in uart_mode_store()
2634 dev_err(dev, "%s - uart_mode %d is invalid\n", __func__, v); in uart_mode_store()
2642 return device_create_file(&port->dev, &dev_attr_uart_mode); in edge_create_sysfs_attrs()
2647 device_remove_file(&port->dev, &dev_attr_uart_mode); in edge_remove_sysfs_attrs()
2652 static int edge_suspend(struct usb_serial *serial, pm_message_t message) in edge_suspend() argument
2654 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); in edge_suspend()
2656 cancel_delayed_work_sync(&edge_serial->heartbeat_work); in edge_suspend()
2661 static int edge_resume(struct usb_serial *serial) in edge_resume() argument
2663 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); in edge_resume()