aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-22 21:25:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-22 21:25:45 -0400
commitf5ee0557c2058226a0d71fd0b22fe02c7de3b021 (patch)
treed0d555b8dab9b52f716504b4136d0bf4d9fdbf2e
parent9e43643b11695911bb1dd585d9a9f758a5ad4d89 (diff)
parent92944c4520edd35a060cfbdaa7431d4e3c3ebd56 (diff)
Merge tag 'usb-serial-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes: USB-serial updates for v4.4-rc1 These updates generalise the option DTR/RTS handling so that all usb-wwan-based drivers can use it. This is specifically needed by some Sierra modems, which can now all be handled by qcserial again. Included are also some clean ups of the io_ti firmware handling. Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r--drivers/usb/serial/io_ti.c530
-rw-r--r--drivers/usb/serial/option.c64
-rw-r--r--drivers/usb/serial/qcserial.c13
-rw-r--r--drivers/usb/serial/usb-wwan.h2
-rw-r--r--drivers/usb/serial/usb_wwan.c42
5 files changed, 352 insertions, 299 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 0ac1b10be1f7..fce82fd79f77 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -54,8 +54,10 @@
54#define TI_MODE_CONFIGURING 0 /* Device has not entered start device */ 54#define TI_MODE_CONFIGURING 0 /* Device has not entered start device */
55#define TI_MODE_BOOT 1 /* Staying in boot mode */ 55#define TI_MODE_BOOT 1 /* Staying in boot mode */
56#define TI_MODE_DOWNLOAD 2 /* Made it to download mode */ 56#define TI_MODE_DOWNLOAD 2 /* Made it to download mode */
57#define TI_MODE_TRANSITIONING 3 /* Currently in boot mode but 57#define TI_MODE_TRANSITIONING 3 /*
58 transitioning to download mode */ 58 * Currently in boot mode but
59 * transitioning to download mode
60 */
59 61
60/* read urb state */ 62/* read urb state */
61#define EDGE_READ_URB_RUNNING 0 63#define EDGE_READ_URB_RUNNING 0
@@ -97,9 +99,11 @@ struct edgeport_port {
97 __u8 shadow_mcr; 99 __u8 shadow_mcr;
98 __u8 shadow_lsr; 100 __u8 shadow_lsr;
99 __u8 lsr_mask; 101 __u8 lsr_mask;
100 __u32 ump_read_timeout; /* Number of milliseconds the UMP will 102 __u32 ump_read_timeout; /*
101 wait without data before completing 103 * Number of milliseconds the UMP will
102 a read short */ 104 * wait without data before completing
105 * a read short
106 */
103 int baud_rate; 107 int baud_rate;
104 int close_pending; 108 int close_pending;
105 int lsr_event; 109 int lsr_event;
@@ -115,8 +119,10 @@ struct edgeport_port {
115struct edgeport_serial { 119struct edgeport_serial {
116 struct product_info product_info; 120 struct product_info product_info;
117 u8 TI_I2C_Type; /* Type of I2C in UMP */ 121 u8 TI_I2C_Type; /* Type of I2C in UMP */
118 u8 TiReadI2C; /* Set to TRUE if we have read the 122 u8 TiReadI2C; /*
119 I2c in Boot Mode */ 123 * Set to TRUE if we have read the
124 * I2c in Boot Mode
125 */
120 struct mutex es_lock; 126 struct mutex es_lock;
121 int num_ports_open; 127 int num_ports_open;
122 struct usb_serial *serial; 128 struct usb_serial *serial;
@@ -223,6 +229,11 @@ static void edge_set_termios(struct tty_struct *tty,
223 struct usb_serial_port *port, struct ktermios *old_termios); 229 struct usb_serial_port *port, struct ktermios *old_termios);
224static void edge_send(struct usb_serial_port *port, struct tty_struct *tty); 230static void edge_send(struct usb_serial_port *port, struct tty_struct *tty);
225 231
232static int do_download_mode(struct edgeport_serial *serial,
233 const struct firmware *fw);
234static int do_boot_mode(struct edgeport_serial *serial,
235 const struct firmware *fw);
236
226/* sysfs attributes */ 237/* sysfs attributes */
227static int edge_create_sysfs_attrs(struct usb_serial_port *port); 238static int edge_create_sysfs_attrs(struct usb_serial_port *port);
228static int edge_remove_sysfs_attrs(struct usb_serial_port *port); 239static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
@@ -324,7 +335,8 @@ static int read_download_mem(struct usb_device *dev, int start_address,
324 335
325 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length); 336 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length);
326 337
327 /* Read in blocks of 64 bytes 338 /*
339 * Read in blocks of 64 bytes
328 * (TI firmware can't handle more than 64 byte reads) 340 * (TI firmware can't handle more than 64 byte reads)
329 */ 341 */
330 while (length) { 342 while (length) {
@@ -430,7 +442,6 @@ static int write_boot_mem(struct edgeport_serial *serial,
430 return status; 442 return status;
431} 443}
432 444
433
434/* Write edgeport I2C memory to TI chip */ 445/* Write edgeport I2C memory to TI chip */
435static int write_i2c_mem(struct edgeport_serial *serial, 446static int write_i2c_mem(struct edgeport_serial *serial,
436 int start_address, int length, __u8 address_type, __u8 *buffer) 447 int start_address, int length, __u8 address_type, __u8 *buffer)
@@ -472,8 +483,10 @@ static int write_i2c_mem(struct edgeport_serial *serial,
472 start_address += write_length; 483 start_address += write_length;
473 buffer += write_length; 484 buffer += write_length;
474 485
475 /* We should be aligned now -- can write 486 /*
476 max page size bytes at a time */ 487 * We should be aligned now -- can write max page size bytes at a
488 * time.
489 */
477 while (length) { 490 while (length) {
478 if (length > EPROM_PAGE_SIZE) 491 if (length > EPROM_PAGE_SIZE)
479 write_length = EPROM_PAGE_SIZE; 492 write_length = EPROM_PAGE_SIZE;
@@ -506,7 +519,8 @@ static int write_i2c_mem(struct edgeport_serial *serial,
506 return status; 519 return status;
507} 520}
508 521
509/* Examine the UMP DMA registers and LSR 522/*
523 * Examine the UMP DMA registers and LSR
510 * 524 *
511 * Check the MSBit of the X and Y DMA byte count registers. 525 * Check the MSBit of the X and Y DMA byte count registers.
512 * A zero in this bit indicates that the TX DMA buffers are empty 526 * A zero in this bit indicates that the TX DMA buffers are empty
@@ -523,9 +537,11 @@ static int tx_active(struct edgeport_port *port)
523 if (!oedb) 537 if (!oedb)
524 return -ENOMEM; 538 return -ENOMEM;
525 539
526 lsr = kmalloc(1, GFP_KERNEL); /* Sigh, that's right, just one byte, 540 /*
527 as not all platforms can do DMA 541 * Sigh, that's right, just one byte, as not all platforms can
528 from stack */ 542 * do DMA from stack
543 */
544 lsr = kmalloc(1, GFP_KERNEL);
529 if (!lsr) { 545 if (!lsr) {
530 kfree(oedb); 546 kfree(oedb);
531 return -ENOMEM; 547 return -ENOMEM;
@@ -615,8 +631,6 @@ static int write_rom(struct edgeport_serial *serial, int start_address,
615 return -EINVAL; 631 return -EINVAL;
616} 632}
617 633
618
619
620/* Read a descriptor header from I2C based on type */ 634/* Read a descriptor header from I2C based on type */
621static int get_descriptor_addr(struct edgeport_serial *serial, 635static int get_descriptor_addr(struct edgeport_serial *serial,
622 int desc_type, struct ti_i2c_desc *rom_desc) 636 int desc_type, struct ti_i2c_desc *rom_desc)
@@ -785,8 +799,7 @@ exit:
785} 799}
786 800
787/* Build firmware header used for firmware update */ 801/* Build firmware header used for firmware update */
788static int build_i2c_fw_hdr(u8 *header, struct device *dev, 802static int build_i2c_fw_hdr(u8 *header, const struct firmware *fw)
789 const struct firmware *fw)
790{ 803{
791 __u8 *buffer; 804 __u8 *buffer;
792 int buffer_size; 805 int buffer_size;
@@ -797,7 +810,8 @@ static int build_i2c_fw_hdr(u8 *header, struct device *dev,
797 struct ti_i2c_firmware_rec *firmware_rec; 810 struct ti_i2c_firmware_rec *firmware_rec;
798 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; 811 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data;
799 812
800 /* In order to update the I2C firmware we must change the type 2 record 813 /*
814 * In order to update the I2C firmware we must change the type 2 record
801 * to type 0xF2. This will force the UMP to come up in Boot Mode. 815 * to type 0xF2. This will force the UMP to come up in Boot Mode.
802 * Then while in boot mode, the driver will download the latest 816 * Then while in boot mode, the driver will download the latest
803 * firmware (padded to 15.5k) into the UMP ram. And finally when the 817 * firmware (padded to 15.5k) into the UMP ram. And finally when the
@@ -806,8 +820,10 @@ static int build_i2c_fw_hdr(u8 *header, struct device *dev,
806 * update the record type from 0xf2 to 0x02. 820 * update the record type from 0xf2 to 0x02.
807 */ 821 */
808 822
809 /* Allocate a 15.5k buffer + 2 bytes for version number 823 /*
810 * (Firmware Record) */ 824 * Allocate a 15.5k buffer + 2 bytes for version number (Firmware
825 * Record)
826 */
811 buffer_size = (((1024 * 16) - 512 ) + 827 buffer_size = (((1024 * 16) - 512 ) +
812 sizeof(struct ti_i2c_firmware_rec)); 828 sizeof(struct ti_i2c_firmware_rec));
813 829
@@ -815,7 +831,7 @@ static int build_i2c_fw_hdr(u8 *header, struct device *dev,
815 if (!buffer) 831 if (!buffer)
816 return -ENOMEM; 832 return -ENOMEM;
817 833
818 // Set entire image of 0xffs 834 /* Set entire image of 0xffs */
819 memset(buffer, 0xff, buffer_size); 835 memset(buffer, 0xff, buffer_size);
820 836
821 /* Copy version number into firmware record */ 837 /* Copy version number into firmware record */
@@ -981,32 +997,41 @@ static int check_fw_sanity(struct edgeport_serial *serial,
981 return 0; 997 return 0;
982} 998}
983 999
984/** 1000/*
985 * DownloadTIFirmware - Download run-time operating firmware to the TI5052 1001 * DownloadTIFirmware - Download run-time operating firmware to the TI5052
986 * 1002 *
987 * This routine downloads the main operating code into the TI5052, using the 1003 * This routine downloads the main operating code into the TI5052, using the
988 * boot code already burned into E2PROM or ROM. 1004 * boot code already burned into E2PROM or ROM.
989 */ 1005 */
990static int download_fw(struct edgeport_serial *serial, 1006static int download_fw(struct edgeport_serial *serial)
991 const struct firmware *fw)
992{ 1007{
993 struct device *dev = &serial->serial->dev->dev; 1008 struct device *dev = &serial->serial->interface->dev;
994 int status = 0; 1009 int status = 0;
995 int start_address;
996 struct edge_ti_manuf_descriptor *ti_manuf_desc;
997 struct usb_interface_descriptor *interface; 1010 struct usb_interface_descriptor *interface;
998 int download_cur_ver; 1011 const struct firmware *fw;
999 int download_new_ver; 1012 const char *fw_name = "edgeport/down3.bin";
1000 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data; 1013 struct edgeport_fw_hdr *fw_hdr;
1001 1014
1002 if (check_fw_sanity(serial, fw)) 1015 status = request_firmware(&fw, fw_name, dev);
1003 return -EINVAL; 1016 if (status) {
1017 dev_err(dev, "Failed to load image \"%s\" err %d\n",
1018 fw_name, status);
1019 return status;
1020 }
1021
1022 if (check_fw_sanity(serial, fw)) {
1023 status = -EINVAL;
1024 goto out;
1025 }
1004 1026
1005 /* If on-board version is newer, "fw_version" will be updated below. */ 1027 fw_hdr = (struct edgeport_fw_hdr *)fw->data;
1028
1029 /* If on-board version is newer, "fw_version" will be updated later. */
1006 serial->fw_version = (fw_hdr->major_version << 8) + 1030 serial->fw_version = (fw_hdr->major_version << 8) +
1007 fw_hdr->minor_version; 1031 fw_hdr->minor_version;
1008 1032
1009 /* This routine is entered by both the BOOT mode and the Download mode 1033 /*
1034 * This routine is entered by both the BOOT mode and the Download mode
1010 * We can determine which code is running by the reading the config 1035 * We can determine which code is running by the reading the config
1011 * descriptor and if we have only one bulk pipe it is in boot mode 1036 * descriptor and if we have only one bulk pipe it is in boot mode
1012 */ 1037 */
@@ -1017,12 +1042,13 @@ static int download_fw(struct edgeport_serial *serial,
1017 1042
1018 status = choose_config(serial->serial->dev); 1043 status = choose_config(serial->serial->dev);
1019 if (status) 1044 if (status)
1020 return status; 1045 goto out;
1021 1046
1022 interface = &serial->serial->interface->cur_altsetting->desc; 1047 interface = &serial->serial->interface->cur_altsetting->desc;
1023 if (!interface) { 1048 if (!interface) {
1024 dev_err(dev, "%s - no interface set, error!\n", __func__); 1049 dev_err(dev, "%s - no interface set, error!\n", __func__);
1025 return -ENODEV; 1050 status = -ENODEV;
1051 goto out;
1026 } 1052 }
1027 1053
1028 /* 1054 /*
@@ -1030,190 +1056,219 @@ static int download_fw(struct edgeport_serial *serial,
1030 * if we have more than one endpoint we are definitely in download 1056 * if we have more than one endpoint we are definitely in download
1031 * mode 1057 * mode
1032 */ 1058 */
1033 if (interface->bNumEndpoints > 1) 1059 if (interface->bNumEndpoints > 1) {
1034 serial->product_info.TiMode = TI_MODE_DOWNLOAD; 1060 serial->product_info.TiMode = TI_MODE_DOWNLOAD;
1035 else 1061 status = do_download_mode(serial, fw);
1062 } else {
1036 /* Otherwise we will remain in configuring mode */ 1063 /* Otherwise we will remain in configuring mode */
1037 serial->product_info.TiMode = TI_MODE_CONFIGURING; 1064 serial->product_info.TiMode = TI_MODE_CONFIGURING;
1065 status = do_boot_mode(serial, fw);
1066 }
1038 1067
1039 /********************************************************************/ 1068out:
1040 /* Download Mode */ 1069 release_firmware(fw);
1041 /********************************************************************/ 1070 return status;
1042 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { 1071}
1043 struct ti_i2c_desc *rom_desc;
1044 1072
1045 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__); 1073static int do_download_mode(struct edgeport_serial *serial,
1074 const struct firmware *fw)
1075{
1076 struct device *dev = &serial->serial->interface->dev;
1077 int status = 0;
1078 int start_address;
1079 struct edge_ti_manuf_descriptor *ti_manuf_desc;
1080 int download_cur_ver;
1081 int download_new_ver;
1082 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data;
1083 struct ti_i2c_desc *rom_desc;
1046 1084
1047 status = check_i2c_image(serial); 1085 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__);
1048 if (status) {
1049 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__);
1050 return status;
1051 }
1052 1086
1053 /* Validate Hardware version number 1087 status = check_i2c_image(serial);
1054 * Read Manufacturing Descriptor from TI Based Edgeport 1088 if (status) {
1055 */ 1089 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__);
1056 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); 1090 return status;
1057 if (!ti_manuf_desc) 1091 }
1092
1093 /*
1094 * Validate Hardware version number
1095 * Read Manufacturing Descriptor from TI Based Edgeport
1096 */
1097 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL);
1098 if (!ti_manuf_desc)
1099 return -ENOMEM;
1100
1101 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc);
1102 if (status) {
1103 kfree(ti_manuf_desc);
1104 return status;
1105 }
1106
1107 /* Check version number of ION descriptor */
1108 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) {
1109 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n",
1110 __func__, ti_cpu_rev(ti_manuf_desc));
1111 kfree(ti_manuf_desc);
1112 return -EINVAL;
1113 }
1114
1115 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
1116 if (!rom_desc) {
1117 kfree(ti_manuf_desc);
1118 return -ENOMEM;
1119 }
1120
1121 /* Search for type 2 record (firmware record) */
1122 start_address = get_descriptor_addr(serial,
1123 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc);
1124 if (start_address != 0) {
1125 struct ti_i2c_firmware_rec *firmware_version;
1126 u8 *record;
1127
1128 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n",
1129 __func__);
1130
1131 firmware_version = kmalloc(sizeof(*firmware_version),
1132 GFP_KERNEL);
1133 if (!firmware_version) {
1134 kfree(rom_desc);
1135 kfree(ti_manuf_desc);
1058 return -ENOMEM; 1136 return -ENOMEM;
1137 }
1059 1138
1060 status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); 1139 /*
1140 * Validate version number
1141 * Read the descriptor data
1142 */
1143 status = read_rom(serial, start_address +
1144 sizeof(struct ti_i2c_desc),
1145 sizeof(struct ti_i2c_firmware_rec),
1146 (__u8 *)firmware_version);
1061 if (status) { 1147 if (status) {
1148 kfree(firmware_version);
1149 kfree(rom_desc);
1062 kfree(ti_manuf_desc); 1150 kfree(ti_manuf_desc);
1063 return status; 1151 return status;
1064 } 1152 }
1065 1153
1066 /* Check version number of ION descriptor */ 1154 /*
1067 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { 1155 * Check version number of download with current
1068 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n", 1156 * version in I2c
1069 __func__, ti_cpu_rev(ti_manuf_desc)); 1157 */
1070 kfree(ti_manuf_desc); 1158 download_cur_ver = (firmware_version->Ver_Major << 8) +
1071 return -EINVAL; 1159 (firmware_version->Ver_Minor);
1072 } 1160 download_new_ver = (fw_hdr->major_version << 8) +
1161 (fw_hdr->minor_version);
1073 1162
1074 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); 1163 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n",
1075 if (!rom_desc) { 1164 __func__, firmware_version->Ver_Major,
1076 kfree(ti_manuf_desc); 1165 firmware_version->Ver_Minor,
1077 return -ENOMEM; 1166 fw_hdr->major_version, fw_hdr->minor_version);
1078 }
1079 1167
1080 /* Search for type 2 record (firmware record) */ 1168 /*
1081 start_address = get_descriptor_addr(serial, 1169 * Check if we have an old version in the I2C and
1082 I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); 1170 * update if necessary
1083 if (start_address != 0) { 1171 */
1084 struct ti_i2c_firmware_rec *firmware_version; 1172 if (download_cur_ver < download_new_ver) {
1085 u8 *record; 1173 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n",
1086 1174 __func__,
1087 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", __func__); 1175 firmware_version->Ver_Major,
1176 firmware_version->Ver_Minor,
1177 fw_hdr->major_version,
1178 fw_hdr->minor_version);
1088 1179
1089 firmware_version = kmalloc(sizeof(*firmware_version), 1180 record = kmalloc(1, GFP_KERNEL);
1090 GFP_KERNEL); 1181 if (!record) {
1091 if (!firmware_version) { 1182 kfree(firmware_version);
1092 kfree(rom_desc); 1183 kfree(rom_desc);
1093 kfree(ti_manuf_desc); 1184 kfree(ti_manuf_desc);
1094 return -ENOMEM; 1185 return -ENOMEM;
1095 } 1186 }
1187 /*
1188 * In order to update the I2C firmware we must
1189 * change the type 2 record to type 0xF2. This
1190 * will force the UMP to come up in Boot Mode.
1191 * Then while in boot mode, the driver will
1192 * download the latest firmware (padded to
1193 * 15.5k) into the UMP ram. Finally when the
1194 * device comes back up in download mode the
1195 * driver will cause the new firmware to be
1196 * copied from the UMP Ram to I2C and the
1197 * firmware will update the record type from
1198 * 0xf2 to 0x02.
1199 */
1200 *record = I2C_DESC_TYPE_FIRMWARE_BLANK;
1096 1201
1097 /* Validate version number 1202 /*
1098 * Read the descriptor data 1203 * Change the I2C Firmware record type to
1204 * 0xf2 to trigger an update
1099 */ 1205 */
1100 status = read_rom(serial, start_address + 1206 status = write_rom(serial, start_address,
1101 sizeof(struct ti_i2c_desc), 1207 sizeof(*record), record);
1102 sizeof(struct ti_i2c_firmware_rec),
1103 (__u8 *)firmware_version);
1104 if (status) { 1208 if (status) {
1209 kfree(record);
1105 kfree(firmware_version); 1210 kfree(firmware_version);
1106 kfree(rom_desc); 1211 kfree(rom_desc);
1107 kfree(ti_manuf_desc); 1212 kfree(ti_manuf_desc);
1108 return status; 1213 return status;
1109 } 1214 }
1110 1215
1111 /* Check version number of download with current 1216 /*
1112 version in I2c */ 1217 * verify the write -- must do this in order
1113 download_cur_ver = (firmware_version->Ver_Major << 8) + 1218 * for write to complete before we do the
1114 (firmware_version->Ver_Minor); 1219 * hardware reset
1115 download_new_ver = (fw_hdr->major_version << 8) + 1220 */
1116 (fw_hdr->minor_version); 1221 status = read_rom(serial,
1117 1222 start_address,
1118 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n", 1223 sizeof(*record),
1119 __func__, firmware_version->Ver_Major, 1224 record);
1120 firmware_version->Ver_Minor, 1225 if (status) {
1121 fw_hdr->major_version, fw_hdr->minor_version); 1226 kfree(record);
1227 kfree(firmware_version);
1228 kfree(rom_desc);
1229 kfree(ti_manuf_desc);
1230 return status;
1231 }
1122 1232
1123 /* Check if we have an old version in the I2C and 1233 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1124 update if necessary */ 1234 dev_err(dev, "%s - error resetting device\n",
1125 if (download_cur_ver < download_new_ver) { 1235 __func__);
1126 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n",
1127 __func__,
1128 firmware_version->Ver_Major,
1129 firmware_version->Ver_Minor,
1130 fw_hdr->major_version,
1131 fw_hdr->minor_version);
1132
1133 record = kmalloc(1, GFP_KERNEL);
1134 if (!record) {
1135 kfree(firmware_version);
1136 kfree(rom_desc);
1137 kfree(ti_manuf_desc);
1138 return -ENOMEM;
1139 }
1140 /* In order to update the I2C firmware we must
1141 * change the type 2 record to type 0xF2. This
1142 * will force the UMP to come up in Boot Mode.
1143 * Then while in boot mode, the driver will
1144 * download the latest firmware (padded to
1145 * 15.5k) into the UMP ram. Finally when the
1146 * device comes back up in download mode the
1147 * driver will cause the new firmware to be
1148 * copied from the UMP Ram to I2C and the
1149 * firmware will update the record type from
1150 * 0xf2 to 0x02.
1151 */
1152 *record = I2C_DESC_TYPE_FIRMWARE_BLANK;
1153
1154 /* Change the I2C Firmware record type to
1155 0xf2 to trigger an update */
1156 status = write_rom(serial, start_address,
1157 sizeof(*record), record);
1158 if (status) {
1159 kfree(record);
1160 kfree(firmware_version);
1161 kfree(rom_desc);
1162 kfree(ti_manuf_desc);
1163 return status;
1164 }
1165
1166 /* verify the write -- must do this in order
1167 * for write to complete before we do the
1168 * hardware reset
1169 */
1170 status = read_rom(serial,
1171 start_address,
1172 sizeof(*record),
1173 record);
1174 if (status) {
1175 kfree(record);
1176 kfree(firmware_version);
1177 kfree(rom_desc);
1178 kfree(ti_manuf_desc);
1179 return status;
1180 }
1181
1182 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1183 dev_err(dev, "%s - error resetting device\n", __func__);
1184 kfree(record);
1185 kfree(firmware_version);
1186 kfree(rom_desc);
1187 kfree(ti_manuf_desc);
1188 return -ENODEV;
1189 }
1190
1191 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__);
1192
1193 /* Reset UMP -- Back to BOOT MODE */
1194 status = ti_vsend_sync(serial->serial->dev,
1195 UMPC_HARDWARE_RESET,
1196 0, 0, NULL, 0,
1197 TI_VSEND_TIMEOUT_DEFAULT);
1198
1199 dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status);
1200
1201 /* return an error on purpose. */
1202 kfree(record); 1236 kfree(record);
1203 kfree(firmware_version); 1237 kfree(firmware_version);
1204 kfree(rom_desc); 1238 kfree(rom_desc);
1205 kfree(ti_manuf_desc); 1239 kfree(ti_manuf_desc);
1206 return -ENODEV; 1240 return -ENODEV;
1207 } else {
1208 /* Same or newer fw version is already loaded */
1209 serial->fw_version = download_cur_ver;
1210 } 1241 }
1242
1243 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__);
1244
1245 /* Reset UMP -- Back to BOOT MODE */
1246 status = ti_vsend_sync(serial->serial->dev,
1247 UMPC_HARDWARE_RESET,
1248 0, 0, NULL, 0,
1249 TI_VSEND_TIMEOUT_DEFAULT);
1250
1251 dev_dbg(dev, "%s - HARDWARE RESET return %d\n",
1252 __func__, status);
1253
1254 /* return an error on purpose. */
1255 kfree(record);
1211 kfree(firmware_version); 1256 kfree(firmware_version);
1257 kfree(rom_desc);
1258 kfree(ti_manuf_desc);
1259 return -ENODEV;
1212 } 1260 }
1213 /* Search for type 0xF2 record (firmware blank record) */ 1261 /* Same or newer fw version is already loaded */
1214 else if ((start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { 1262 serial->fw_version = download_cur_ver;
1263 kfree(firmware_version);
1264 }
1265 /* Search for type 0xF2 record (firmware blank record) */
1266 else {
1267 start_address = get_descriptor_addr(serial,
1268 I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc);
1269 if (start_address != 0) {
1215#define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \ 1270#define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \
1216 sizeof(struct ti_i2c_firmware_rec)) 1271 sizeof(struct ti_i2c_firmware_rec))
1217 __u8 *header; 1272 __u8 *header;
1218 __u8 *vheader; 1273 __u8 *vheader;
1219 1274
@@ -1232,7 +1287,8 @@ static int download_fw(struct edgeport_serial *serial,
1232 return -ENOMEM; 1287 return -ENOMEM;
1233 } 1288 }
1234 1289
1235 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", __func__); 1290 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n",
1291 __func__);
1236 1292
1237 /* 1293 /*
1238 * In order to update the I2C firmware we must change 1294 * In order to update the I2C firmware we must change
@@ -1245,7 +1301,7 @@ static int download_fw(struct edgeport_serial *serial,
1245 * UMP Ram to I2C and the firmware will update the 1301 * UMP Ram to I2C and the firmware will update the
1246 * record type from 0xf2 to 0x02. 1302 * record type from 0xf2 to 0x02.
1247 */ 1303 */
1248 status = build_i2c_fw_hdr(header, dev, fw); 1304 status = build_i2c_fw_hdr(header, fw);
1249 if (status) { 1305 if (status) {
1250 kfree(vheader); 1306 kfree(vheader);
1251 kfree(header); 1307 kfree(header);
@@ -1254,8 +1310,10 @@ static int download_fw(struct edgeport_serial *serial,
1254 return -EINVAL; 1310 return -EINVAL;
1255 } 1311 }
1256 1312
1257 /* Update I2C with type 0xf2 record with correct 1313 /*
1258 size and checksum */ 1314 * Update I2C with type 0xf2 record with correct
1315 * size and checksum
1316 */
1259 status = write_rom(serial, 1317 status = write_rom(serial,
1260 start_address, 1318 start_address,
1261 HEADER_SIZE, 1319 HEADER_SIZE,
@@ -1268,13 +1326,16 @@ static int download_fw(struct edgeport_serial *serial,
1268 return -EINVAL; 1326 return -EINVAL;
1269 } 1327 }
1270 1328
1271 /* verify the write -- must do this in order for 1329 /*
1272 write to complete before we do the hardware reset */ 1330 * verify the write -- must do this in order for
1331 * write to complete before we do the hardware reset
1332 */
1273 status = read_rom(serial, start_address, 1333 status = read_rom(serial, start_address,
1274 HEADER_SIZE, vheader); 1334 HEADER_SIZE, vheader);
1275 1335
1276 if (status) { 1336 if (status) {
1277 dev_dbg(dev, "%s - can't read header back\n", __func__); 1337 dev_dbg(dev, "%s - can't read header back\n",
1338 __func__);
1278 kfree(vheader); 1339 kfree(vheader);
1279 kfree(header); 1340 kfree(header);
1280 kfree(rom_desc); 1341 kfree(rom_desc);
@@ -1282,7 +1343,8 @@ static int download_fw(struct edgeport_serial *serial,
1282 return status; 1343 return status;
1283 } 1344 }
1284 if (memcmp(vheader, header, HEADER_SIZE)) { 1345 if (memcmp(vheader, header, HEADER_SIZE)) {
1285 dev_dbg(dev, "%s - write download record failed\n", __func__); 1346 dev_dbg(dev, "%s - write download record failed\n",
1347 __func__);
1286 kfree(vheader); 1348 kfree(vheader);
1287 kfree(header); 1349 kfree(header);
1288 kfree(rom_desc); 1350 kfree(rom_desc);
@@ -1301,26 +1363,33 @@ static int download_fw(struct edgeport_serial *serial,
1301 0, 0, NULL, 0, 1363 0, 0, NULL, 0,
1302 TI_VSEND_TIMEOUT_FW_DOWNLOAD); 1364 TI_VSEND_TIMEOUT_FW_DOWNLOAD);
1303 1365
1304 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status); 1366 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__,
1367 status);
1305 if (status) { 1368 if (status) {
1306 dev_err(dev, 1369 dev_err(dev,
1307 "%s - UMPC_COPY_DNLD_TO_I2C failed\n", 1370 "%s - UMPC_COPY_DNLD_TO_I2C failed\n",
1308 __func__); 1371 __func__);
1309 kfree(rom_desc); 1372 kfree(rom_desc);
1310 kfree(ti_manuf_desc); 1373 kfree(ti_manuf_desc);
1311 return status; 1374 return status;
1312 } 1375 }
1313 } 1376 }
1314
1315 // The device is running the download code
1316 kfree(rom_desc);
1317 kfree(ti_manuf_desc);
1318 return 0;
1319 } 1377 }
1320 1378
1321 /********************************************************************/ 1379 /* The device is running the download code */
1322 /* Boot Mode */ 1380 kfree(rom_desc);
1323 /********************************************************************/ 1381 kfree(ti_manuf_desc);
1382 return 0;
1383}
1384
1385static int do_boot_mode(struct edgeport_serial *serial,
1386 const struct firmware *fw)
1387{
1388 struct device *dev = &serial->serial->interface->dev;
1389 int status = 0;
1390 struct edge_ti_manuf_descriptor *ti_manuf_desc;
1391 struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw->data;
1392
1324 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__); 1393 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__);
1325 1394
1326 /* Configure the TI device so we can use the BULK pipes for download */ 1395 /* Configure the TI device so we can use the BULK pipes for download */
@@ -1336,8 +1405,10 @@ static int download_fw(struct edgeport_serial *serial,
1336 goto stayinbootmode; 1405 goto stayinbootmode;
1337 } 1406 }
1338 1407
1339 /* We have an ION device (I2c Must be programmed) 1408 /*
1340 Determine I2C image type */ 1409 * We have an ION device (I2c Must be programmed)
1410 * Determine I2C image type
1411 */
1341 if (i2c_type_bootmode(serial)) 1412 if (i2c_type_bootmode(serial))
1342 goto stayinbootmode; 1413 goto stayinbootmode;
1343 1414
@@ -1349,7 +1420,8 @@ static int download_fw(struct edgeport_serial *serial,
1349 __u8 *buffer; 1420 __u8 *buffer;
1350 int buffer_size; 1421 int buffer_size;
1351 1422
1352 /* Validate Hardware version number 1423 /*
1424 * Validate Hardware version number
1353 * Read Manufacturing Descriptor from TI Based Edgeport 1425 * Read Manufacturing Descriptor from TI Based Edgeport
1354 */ 1426 */
1355 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); 1427 ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL);
@@ -1439,7 +1511,6 @@ stayinbootmode:
1439 return 0; 1511 return 0;
1440} 1512}
1441 1513
1442
1443static int ti_do_config(struct edgeport_port *port, int feature, int on) 1514static int ti_do_config(struct edgeport_port *port, int feature, int on)
1444{ 1515{
1445 int port_number = port->port->port_number; 1516 int port_number = port->port->port_number;
@@ -1450,7 +1521,6 @@ static int ti_do_config(struct edgeport_port *port, int feature, int on)
1450 on, NULL, 0); 1521 on, NULL, 0);
1451} 1522}
1452 1523
1453
1454static int restore_mcr(struct edgeport_port *port, __u8 mcr) 1524static int restore_mcr(struct edgeport_port *port, __u8 mcr)
1455{ 1525{
1456 int status = 0; 1526 int status = 0;
@@ -1556,7 +1626,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1556 icount->frame++; 1626 icount->frame++;
1557} 1627}
1558 1628
1559
1560static void edge_interrupt_callback(struct urb *urb) 1629static void edge_interrupt_callback(struct urb *urb)
1561{ 1630{
1562 struct edgeport_serial *edge_serial = urb->context; 1631 struct edgeport_serial *edge_serial = urb->context;
@@ -1616,8 +1685,9 @@ static void edge_interrupt_callback(struct urb *urb)
1616 case TIUMP_INTERRUPT_CODE_LSR: 1685 case TIUMP_INTERRUPT_CODE_LSR:
1617 lsr = map_line_status(data[1]); 1686 lsr = map_line_status(data[1]);
1618 if (lsr & UMP_UART_LSR_DATA_MASK) { 1687 if (lsr & UMP_UART_LSR_DATA_MASK) {
1619 /* Save the LSR event for bulk read 1688 /*
1620 completion routine */ 1689 * Save the LSR event for bulk read completion routine
1690 */
1621 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n", 1691 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n",
1622 __func__, port_number, lsr); 1692 __func__, port_number, lsr);
1623 edge_port->lsr_event = 1; 1693 edge_port->lsr_event = 1;
@@ -1925,8 +1995,10 @@ static void edge_close(struct usb_serial_port *port)
1925 if (edge_serial == NULL || edge_port == NULL) 1995 if (edge_serial == NULL || edge_port == NULL)
1926 return; 1996 return;
1927 1997
1928 /* The bulkreadcompletion routine will check 1998 /*
1929 * this flag and dump add read data */ 1999 * The bulkreadcompletion routine will check
2000 * this flag and dump add read data
2001 */
1930 edge_port->close_pending = 1; 2002 edge_port->close_pending = 1;
1931 2003
1932 usb_kill_urb(port->read_urb); 2004 usb_kill_urb(port->read_urb);
@@ -2016,8 +2088,10 @@ static void edge_send(struct usb_serial_port *port, struct tty_struct *tty)
2016 } else 2088 } else
2017 edge_port->port->icount.tx += count; 2089 edge_port->port->icount.tx += count;
2018 2090
2019 /* wakeup any process waiting for writes to complete */ 2091 /*
2020 /* there is now more room in the buffer for new writes */ 2092 * wakeup any process waiting for writes to complete
2093 * there is now more room in the buffer for new writes
2094 */
2021 if (tty) 2095 if (tty)
2022 tty_wakeup(tty); 2096 tty_wakeup(tty);
2023} 2097}
@@ -2089,8 +2163,10 @@ static void edge_throttle(struct tty_struct *tty)
2089 } 2163 }
2090 } 2164 }
2091 2165
2092 /* if we are implementing RTS/CTS, stop reads */ 2166 /*
2093 /* and the Edgeport will clear the RTS line */ 2167 * if we are implementing RTS/CTS, stop reads
2168 * and the Edgeport will clear the RTS line
2169 */
2094 if (C_CRTSCTS(tty)) 2170 if (C_CRTSCTS(tty))
2095 stop_read(edge_port); 2171 stop_read(edge_port);
2096 2172
@@ -2113,8 +2189,10 @@ static void edge_unthrottle(struct tty_struct *tty)
2113 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); 2189 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
2114 } 2190 }
2115 } 2191 }
2116 /* if we are implementing RTS/CTS, restart reads */ 2192 /*
2117 /* are the Edgeport will assert the RTS line */ 2193 * if we are implementing RTS/CTS, restart reads
2194 * are the Edgeport will assert the RTS line
2195 */
2118 if (C_CRTSCTS(tty)) { 2196 if (C_CRTSCTS(tty)) {
2119 status = restart_read(edge_port); 2197 status = restart_read(edge_port);
2120 if (status) 2198 if (status)
@@ -2236,8 +2314,10 @@ static void change_port_settings(struct tty_struct *tty,
2236 restart_read(edge_port); 2314 restart_read(edge_port);
2237 } 2315 }
2238 2316
2239 /* if we are implementing XON/XOFF, set the start and stop 2317 /*
2240 character in the device */ 2318 * if we are implementing XON/XOFF, set the start and stop
2319 * character in the device
2320 */
2241 config->cXon = START_CHAR(tty); 2321 config->cXon = START_CHAR(tty);
2242 config->cXoff = STOP_CHAR(tty); 2322 config->cXoff = STOP_CHAR(tty);
2243 2323
@@ -2467,9 +2547,6 @@ static int edge_startup(struct usb_serial *serial)
2467{ 2547{
2468 struct edgeport_serial *edge_serial; 2548 struct edgeport_serial *edge_serial;
2469 int status; 2549 int status;
2470 const struct firmware *fw;
2471 const char *fw_name = "edgeport/down3.bin";
2472 struct device *dev = &serial->interface->dev;
2473 u16 product_id; 2550 u16 product_id;
2474 2551
2475 /* create our private serial structure */ 2552 /* create our private serial structure */
@@ -2481,16 +2558,7 @@ static int edge_startup(struct usb_serial *serial)
2481 edge_serial->serial = serial; 2558 edge_serial->serial = serial;
2482 usb_set_serial_data(serial, edge_serial); 2559 usb_set_serial_data(serial, edge_serial);
2483 2560
2484 status = request_firmware(&fw, fw_name, dev); 2561 status = download_fw(edge_serial);
2485 if (status) {
2486 dev_err(dev, "Failed to load image \"%s\" err %d\n",
2487 fw_name, status);
2488 kfree(edge_serial);
2489 return status;
2490 }
2491
2492 status = download_fw(edge_serial, fw);
2493 release_firmware(fw);
2494 if (status) { 2562 if (status) {
2495 kfree(edge_serial); 2563 kfree(edge_serial);
2496 return status; 2564 return status;
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6956c4f62216..685fef71d3d1 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -48,7 +48,6 @@ static int option_probe(struct usb_serial *serial,
48 const struct usb_device_id *id); 48 const struct usb_device_id *id);
49static int option_attach(struct usb_serial *serial); 49static int option_attach(struct usb_serial *serial);
50static void option_release(struct usb_serial *serial); 50static void option_release(struct usb_serial *serial);
51static int option_send_setup(struct usb_serial_port *port);
52static void option_instat_callback(struct urb *urb); 51static void option_instat_callback(struct urb *urb);
53 52
54/* Vendor and product IDs */ 53/* Vendor and product IDs */
@@ -234,8 +233,6 @@ static void option_instat_callback(struct urb *urb);
234 233
235#define QUALCOMM_VENDOR_ID 0x05C6 234#define QUALCOMM_VENDOR_ID 0x05C6
236 235
237#define SIERRA_VENDOR_ID 0x1199
238
239#define CMOTECH_VENDOR_ID 0x16d8 236#define CMOTECH_VENDOR_ID 0x16d8
240#define CMOTECH_PRODUCT_6001 0x6001 237#define CMOTECH_PRODUCT_6001 0x6001
241#define CMOTECH_PRODUCT_CMU_300 0x6002 238#define CMOTECH_PRODUCT_CMU_300 0x6002
@@ -611,11 +608,6 @@ static const struct option_blacklist_info telit_le920_blacklist = {
611 .reserved = BIT(1) | BIT(5), 608 .reserved = BIT(1) | BIT(5),
612}; 609};
613 610
614static const struct option_blacklist_info sierra_mc73xx_blacklist = {
615 .sendsetup = BIT(0) | BIT(2),
616 .reserved = BIT(8) | BIT(10) | BIT(11),
617};
618
619static const struct usb_device_id option_ids[] = { 611static const struct usb_device_id option_ids[] = {
620 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 612 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
621 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 613 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -1113,10 +1105,6 @@ static const struct usb_device_id option_ids[] = {
1113 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 1105 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
1114 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ 1106 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
1115 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 1107 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
1116 { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x68c0, 0xff),
1117 .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC73xx */
1118 { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x9041, 0xff),
1119 .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC7305/MC7355 */
1120 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, 1108 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
1121 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, 1109 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
1122 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), 1110 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
@@ -1835,10 +1823,6 @@ static struct usb_serial_driver * const serial_drivers[] = {
1835 &option_1port_device, NULL 1823 &option_1port_device, NULL
1836}; 1824};
1837 1825
1838struct option_private {
1839 u8 bInterfaceNumber;
1840};
1841
1842module_usb_serial_driver(serial_drivers, option_ids); 1826module_usb_serial_driver(serial_drivers, option_ids);
1843 1827
1844static int option_probe(struct usb_serial *serial, 1828static int option_probe(struct usb_serial *serial,
@@ -1882,29 +1866,19 @@ static int option_attach(struct usb_serial *serial)
1882 struct usb_interface_descriptor *iface_desc; 1866 struct usb_interface_descriptor *iface_desc;
1883 const struct option_blacklist_info *blacklist; 1867 const struct option_blacklist_info *blacklist;
1884 struct usb_wwan_intf_private *data; 1868 struct usb_wwan_intf_private *data;
1885 struct option_private *priv;
1886 1869
1887 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); 1870 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
1888 if (!data) 1871 if (!data)
1889 return -ENOMEM; 1872 return -ENOMEM;
1890 1873
1891 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1892 if (!priv) {
1893 kfree(data);
1894 return -ENOMEM;
1895 }
1896
1897 /* Retrieve blacklist info stored at probe. */ 1874 /* Retrieve blacklist info stored at probe. */
1898 blacklist = usb_get_serial_data(serial); 1875 blacklist = usb_get_serial_data(serial);
1899 1876
1900 iface_desc = &serial->interface->cur_altsetting->desc; 1877 iface_desc = &serial->interface->cur_altsetting->desc;
1901 1878
1902 priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
1903 data->private = priv;
1904
1905 if (!blacklist || !test_bit(iface_desc->bInterfaceNumber, 1879 if (!blacklist || !test_bit(iface_desc->bInterfaceNumber,
1906 &blacklist->sendsetup)) { 1880 &blacklist->sendsetup)) {
1907 data->send_setup = option_send_setup; 1881 data->use_send_setup = 1;
1908 } 1882 }
1909 spin_lock_init(&data->susp_lock); 1883 spin_lock_init(&data->susp_lock);
1910 1884
@@ -1916,9 +1890,7 @@ static int option_attach(struct usb_serial *serial)
1916static void option_release(struct usb_serial *serial) 1890static void option_release(struct usb_serial *serial)
1917{ 1891{
1918 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial); 1892 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
1919 struct option_private *priv = intfdata->private;
1920 1893
1921 kfree(priv);
1922 kfree(intfdata); 1894 kfree(intfdata);
1923} 1895}
1924 1896
@@ -1977,40 +1949,6 @@ static void option_instat_callback(struct urb *urb)
1977 } 1949 }
1978} 1950}
1979 1951
1980/** send RTS/DTR state to the port.
1981 *
1982 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
1983 * CDC.
1984*/
1985static int option_send_setup(struct usb_serial_port *port)
1986{
1987 struct usb_serial *serial = port->serial;
1988 struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
1989 struct option_private *priv = intfdata->private;
1990 struct usb_wwan_port_private *portdata;
1991 int val = 0;
1992 int res;
1993
1994 portdata = usb_get_serial_port_data(port);
1995
1996 if (portdata->dtr_state)
1997 val |= 0x01;
1998 if (portdata->rts_state)
1999 val |= 0x02;
2000
2001 res = usb_autopm_get_interface(serial->interface);
2002 if (res)
2003 return res;
2004
2005 res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2006 0x22, 0x21, val, priv->bInterfaceNumber, NULL,
2007 0, USB_CTRL_SET_TIMEOUT);
2008
2009 usb_autopm_put_interface(serial->interface);
2010
2011 return res;
2012}
2013
2014MODULE_AUTHOR(DRIVER_AUTHOR); 1952MODULE_AUTHOR(DRIVER_AUTHOR);
2015MODULE_DESCRIPTION(DRIVER_DESC); 1953MODULE_DESCRIPTION(DRIVER_DESC);
2016MODULE_LICENSE("GPL"); 1954MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index ebcec8cda858..f224820f7652 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -143,9 +143,11 @@ static const struct usb_device_id id_table[] = {
143 {DEVICE_SWI(0x0f3d, 0x68a2)}, /* Sierra Wireless MC7700 */ 143 {DEVICE_SWI(0x0f3d, 0x68a2)}, /* Sierra Wireless MC7700 */
144 {DEVICE_SWI(0x114f, 0x68a2)}, /* Sierra Wireless MC7750 */ 144 {DEVICE_SWI(0x114f, 0x68a2)}, /* Sierra Wireless MC7750 */
145 {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */ 145 {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */
146 {DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC7304/MC7354 */
146 {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ 147 {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */
147 {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ 148 {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */
148 {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */ 149 {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */
150 {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */
149 {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ 151 {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */
150 {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */ 152 {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */
151 {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */ 153 {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */
@@ -175,6 +177,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
175 __u8 nintf; 177 __u8 nintf;
176 __u8 ifnum; 178 __u8 ifnum;
177 int altsetting = -1; 179 int altsetting = -1;
180 bool sendsetup = false;
178 181
179 nintf = serial->dev->actconfig->desc.bNumInterfaces; 182 nintf = serial->dev->actconfig->desc.bNumInterfaces;
180 dev_dbg(dev, "Num Interfaces = %d\n", nintf); 183 dev_dbg(dev, "Num Interfaces = %d\n", nintf);
@@ -286,6 +289,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
286 break; 289 break;
287 case 3: 290 case 3:
288 dev_dbg(dev, "Modem port found\n"); 291 dev_dbg(dev, "Modem port found\n");
292 sendsetup = true;
289 break; 293 break;
290 default: 294 default:
291 /* don't claim any unsupported interface */ 295 /* don't claim any unsupported interface */
@@ -337,17 +341,25 @@ done:
337 } 341 }
338 } 342 }
339 343
344 if (!retval)
345 usb_set_serial_data(serial, (void *)(unsigned long)sendsetup);
346
340 return retval; 347 return retval;
341} 348}
342 349
343static int qc_attach(struct usb_serial *serial) 350static int qc_attach(struct usb_serial *serial)
344{ 351{
345 struct usb_wwan_intf_private *data; 352 struct usb_wwan_intf_private *data;
353 bool sendsetup;
346 354
347 data = kzalloc(sizeof(*data), GFP_KERNEL); 355 data = kzalloc(sizeof(*data), GFP_KERNEL);
348 if (!data) 356 if (!data)
349 return -ENOMEM; 357 return -ENOMEM;
350 358
359 sendsetup = !!(unsigned long)(usb_get_serial_data(serial));
360 if (sendsetup)
361 data->use_send_setup = 1;
362
351 spin_lock_init(&data->susp_lock); 363 spin_lock_init(&data->susp_lock);
352 364
353 usb_set_serial_data(serial, data); 365 usb_set_serial_data(serial, data);
@@ -374,6 +386,7 @@ static struct usb_serial_driver qcdevice = {
374 .probe = qcprobe, 386 .probe = qcprobe,
375 .open = usb_wwan_open, 387 .open = usb_wwan_open,
376 .close = usb_wwan_close, 388 .close = usb_wwan_close,
389 .dtr_rts = usb_wwan_dtr_rts,
377 .write = usb_wwan_write, 390 .write = usb_wwan_write,
378 .write_room = usb_wwan_write_room, 391 .write_room = usb_wwan_write_room,
379 .chars_in_buffer = usb_wwan_chars_in_buffer, 392 .chars_in_buffer = usb_wwan_chars_in_buffer,
diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h
index f22dff58b587..44b25c08c68a 100644
--- a/drivers/usb/serial/usb-wwan.h
+++ b/drivers/usb/serial/usb-wwan.h
@@ -34,9 +34,9 @@ extern int usb_wwan_resume(struct usb_serial *serial);
34struct usb_wwan_intf_private { 34struct usb_wwan_intf_private {
35 spinlock_t susp_lock; 35 spinlock_t susp_lock;
36 unsigned int suspended:1; 36 unsigned int suspended:1;
37 unsigned int use_send_setup:1;
37 int in_flight; 38 int in_flight;
38 unsigned int open_ports; 39 unsigned int open_ports;
39 int (*send_setup) (struct usb_serial_port *port);
40 void *private; 40 void *private;
41}; 41};
42 42
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 825305cb71d9..be9cb61b4d19 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -36,6 +36,40 @@
36#include <linux/serial.h> 36#include <linux/serial.h>
37#include "usb-wwan.h" 37#include "usb-wwan.h"
38 38
39/*
40 * Generate DTR/RTS signals on the port using the SET_CONTROL_LINE_STATE request
41 * in CDC ACM.
42 */
43static int usb_wwan_send_setup(struct usb_serial_port *port)
44{
45 struct usb_serial *serial = port->serial;
46 struct usb_wwan_port_private *portdata;
47 int val = 0;
48 int ifnum;
49 int res;
50
51 portdata = usb_get_serial_port_data(port);
52
53 if (portdata->dtr_state)
54 val |= 0x01;
55 if (portdata->rts_state)
56 val |= 0x02;
57
58 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
59
60 res = usb_autopm_get_interface(serial->interface);
61 if (res)
62 return res;
63
64 res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
65 0x22, 0x21, val, ifnum, NULL, 0,
66 USB_CTRL_SET_TIMEOUT);
67
68 usb_autopm_put_interface(port->serial->interface);
69
70 return res;
71}
72
39void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) 73void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
40{ 74{
41 struct usb_wwan_port_private *portdata; 75 struct usb_wwan_port_private *portdata;
@@ -43,7 +77,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
43 77
44 intfdata = usb_get_serial_data(port->serial); 78 intfdata = usb_get_serial_data(port->serial);
45 79
46 if (!intfdata->send_setup) 80 if (!intfdata->use_send_setup)
47 return; 81 return;
48 82
49 portdata = usb_get_serial_port_data(port); 83 portdata = usb_get_serial_port_data(port);
@@ -51,7 +85,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
51 portdata->rts_state = on; 85 portdata->rts_state = on;
52 portdata->dtr_state = on; 86 portdata->dtr_state = on;
53 87
54 intfdata->send_setup(port); 88 usb_wwan_send_setup(port);
55} 89}
56EXPORT_SYMBOL(usb_wwan_dtr_rts); 90EXPORT_SYMBOL(usb_wwan_dtr_rts);
57 91
@@ -84,7 +118,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
84 portdata = usb_get_serial_port_data(port); 118 portdata = usb_get_serial_port_data(port);
85 intfdata = usb_get_serial_data(port->serial); 119 intfdata = usb_get_serial_data(port->serial);
86 120
87 if (!intfdata->send_setup) 121 if (!intfdata->use_send_setup)
88 return -EINVAL; 122 return -EINVAL;
89 123
90 /* FIXME: what locks portdata fields ? */ 124 /* FIXME: what locks portdata fields ? */
@@ -97,7 +131,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
97 portdata->rts_state = 0; 131 portdata->rts_state = 0;
98 if (clear & TIOCM_DTR) 132 if (clear & TIOCM_DTR)
99 portdata->dtr_state = 0; 133 portdata->dtr_state = 0;
100 return intfdata->send_setup(port); 134 return usb_wwan_send_setup(port);
101} 135}
102EXPORT_SYMBOL(usb_wwan_tiocmset); 136EXPORT_SYMBOL(usb_wwan_tiocmset);
103 137