aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/io_ti.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/io_ti.c')
-rw-r--r--drivers/usb/serial/io_ti.c73
1 files changed, 47 insertions, 26 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 05e4fa730730..61daea3f7b2d 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -37,6 +37,7 @@
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/serial.h> 38#include <linux/serial.h>
39#include <linux/ioctl.h> 39#include <linux/ioctl.h>
40#include <linux/firmware.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <linux/usb.h> 42#include <linux/usb.h>
42#include <linux/usb/serial.h> 43#include <linux/usb/serial.h>
@@ -52,13 +53,6 @@
52#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" 53#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli"
53#define DRIVER_DESC "Edgeport USB Serial Driver" 54#define DRIVER_DESC "Edgeport USB Serial Driver"
54 55
55
56/* firmware image code */
57#define IMAGE_VERSION_NAME PagableOperationalCodeImageVersion
58#define IMAGE_ARRAY_NAME PagableOperationalCodeImage
59#define IMAGE_SIZE PagableOperationalCodeSize
60#include "io_fw_down3.h" /* Define array OperationalCodeImage[] */
61
62#define EPROM_PAGE_SIZE 64 56#define EPROM_PAGE_SIZE 64
63 57
64 58
@@ -231,7 +225,9 @@ static struct usb_driver io_driver = {
231}; 225};
232 226
233 227
234static struct EDGE_FIRMWARE_VERSION_INFO OperationalCodeImageVersion; 228static unsigned char OperationalMajorVersion;
229static unsigned char OperationalMinorVersion;
230static unsigned short OperationalBuildNumber;
235 231
236static int debug; 232static int debug;
237 233
@@ -885,10 +881,13 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev)
885 __u8 *buffer; 881 __u8 *buffer;
886 int buffer_size; 882 int buffer_size;
887 int i; 883 int i;
884 int err;
888 __u8 cs = 0; 885 __u8 cs = 0;
889 struct ti_i2c_desc *i2c_header; 886 struct ti_i2c_desc *i2c_header;
890 struct ti_i2c_image_header *img_header; 887 struct ti_i2c_image_header *img_header;
891 struct ti_i2c_firmware_rec *firmware_rec; 888 struct ti_i2c_firmware_rec *firmware_rec;
889 const struct firmware *fw;
890 const char *fw_name = "edgeport/down3.bin";
892 891
893 // In order to update the I2C firmware we must change the type 2 record to type 0xF2. 892 // In order to update the I2C firmware we must change the type 2 record to type 0xF2.
894 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver 893 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver
@@ -909,19 +908,34 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev)
909 // Set entire image of 0xffs 908 // Set entire image of 0xffs
910 memset (buffer, 0xff, buffer_size); 909 memset (buffer, 0xff, buffer_size);
911 910
911 err = request_firmware(&fw, fw_name, dev);
912 if (err) {
913 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
914 fw_name, err);
915 kfree(buffer);
916 return err;
917 }
918
919 /* Save Download Version Number */
920 OperationalMajorVersion = fw->data[0];
921 OperationalMinorVersion = fw->data[1];
922 OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8);
923
912 // Copy version number into firmware record 924 // Copy version number into firmware record
913 firmware_rec = (struct ti_i2c_firmware_rec *)buffer; 925 firmware_rec = (struct ti_i2c_firmware_rec *)buffer;
914 926
915 firmware_rec->Ver_Major = OperationalCodeImageVersion.MajorVersion; 927 firmware_rec->Ver_Major = OperationalMajorVersion;
916 firmware_rec->Ver_Minor = OperationalCodeImageVersion.MinorVersion; 928 firmware_rec->Ver_Minor = OperationalMinorVersion;
917 929
918 // Pointer to fw_down memory image 930 // Pointer to fw_down memory image
919 img_header = (struct ti_i2c_image_header *)&PagableOperationalCodeImage[0]; 931 img_header = (struct ti_i2c_image_header *)&fw->data[4];
920 932
921 memcpy (buffer + sizeof(struct ti_i2c_firmware_rec), 933 memcpy (buffer + sizeof(struct ti_i2c_firmware_rec),
922 &PagableOperationalCodeImage[sizeof(struct ti_i2c_image_header)], 934 &fw->data[4 + sizeof(struct ti_i2c_image_header)],
923 le16_to_cpu(img_header->Length)); 935 le16_to_cpu(img_header->Length));
924 936
937 release_firmware(fw);
938
925 for (i=0; i < buffer_size; i++) { 939 for (i=0; i < buffer_size; i++) {
926 cs = (__u8)(cs + buffer[i]); 940 cs = (__u8)(cs + buffer[i]);
927 } 941 }
@@ -935,8 +949,8 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev)
935 i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; 949 i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK;
936 i2c_header->Size = (__u16)buffer_size; 950 i2c_header->Size = (__u16)buffer_size;
937 i2c_header->CheckSum = cs; 951 i2c_header->CheckSum = cs;
938 firmware_rec->Ver_Major = OperationalCodeImageVersion.MajorVersion; 952 firmware_rec->Ver_Major = OperationalMajorVersion;
939 firmware_rec->Ver_Minor = OperationalCodeImageVersion.MinorVersion; 953 firmware_rec->Ver_Minor = OperationalMinorVersion;
940 954
941 return 0; 955 return 0;
942} 956}
@@ -1075,11 +1089,6 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1075 // Otherwise we will remain in configuring mode 1089 // Otherwise we will remain in configuring mode
1076 serial->product_info.TiMode = TI_MODE_CONFIGURING; 1090 serial->product_info.TiMode = TI_MODE_CONFIGURING;
1077 1091
1078 // Save Download Version Number
1079 OperationalCodeImageVersion.MajorVersion = PagableOperationalCodeImageVersion.MajorVersion;
1080 OperationalCodeImageVersion.MinorVersion = PagableOperationalCodeImageVersion.MinorVersion;
1081 OperationalCodeImageVersion.BuildNumber = PagableOperationalCodeImageVersion.BuildNumber;
1082
1083 /********************************************************************/ 1092 /********************************************************************/
1084 /* Download Mode */ 1093 /* Download Mode */
1085 /********************************************************************/ 1094 /********************************************************************/
@@ -1154,15 +1163,15 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1154 // Check version number of download with current version in I2c 1163 // Check version number of download with current version in I2c
1155 download_cur_ver = (firmware_version->Ver_Major << 8) + 1164 download_cur_ver = (firmware_version->Ver_Major << 8) +
1156 (firmware_version->Ver_Minor); 1165 (firmware_version->Ver_Minor);
1157 download_new_ver = (OperationalCodeImageVersion.MajorVersion << 8) + 1166 download_new_ver = (OperationalMajorVersion << 8) +
1158 (OperationalCodeImageVersion.MinorVersion); 1167 (OperationalMinorVersion);
1159 1168
1160 dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d", 1169 dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d",
1161 __func__, 1170 __func__,
1162 firmware_version->Ver_Major, 1171 firmware_version->Ver_Major,
1163 firmware_version->Ver_Minor, 1172 firmware_version->Ver_Minor,
1164 OperationalCodeImageVersion.MajorVersion, 1173 OperationalMajorVersion,
1165 OperationalCodeImageVersion.MinorVersion); 1174 OperationalMinorVersion);
1166 1175
1167 // Check if we have an old version in the I2C and update if necessary 1176 // Check if we have an old version in the I2C and update if necessary
1168 if (download_cur_ver != download_new_ver) { 1177 if (download_cur_ver != download_new_ver) {
@@ -1170,8 +1179,8 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1170 __func__, 1179 __func__,
1171 firmware_version->Ver_Major, 1180 firmware_version->Ver_Major,
1172 firmware_version->Ver_Minor, 1181 firmware_version->Ver_Minor,
1173 OperationalCodeImageVersion.MajorVersion, 1182 OperationalMajorVersion,
1174 OperationalCodeImageVersion.MinorVersion); 1183 OperationalMinorVersion);
1175 1184
1176 // In order to update the I2C firmware we must change the type 2 record to type 0xF2. 1185 // In order to update the I2C firmware we must change the type 2 record to type 0xF2.
1177 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver 1186 // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver
@@ -1377,6 +1386,9 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1377 __u8 cs = 0; 1386 __u8 cs = 0;
1378 __u8 *buffer; 1387 __u8 *buffer;
1379 int buffer_size; 1388 int buffer_size;
1389 int err;
1390 const struct firmware *fw;
1391 const char *fw_name = "edgeport/down3.bin";
1380 1392
1381 /* Validate Hardware version number 1393 /* Validate Hardware version number
1382 * Read Manufacturing Descriptor from TI Based Edgeport 1394 * Read Manufacturing Descriptor from TI Based Edgeport
@@ -1425,7 +1437,15 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
1425 // Initialize the buffer to 0xff (pad the buffer) 1437 // Initialize the buffer to 0xff (pad the buffer)
1426 memset (buffer, 0xff, buffer_size); 1438 memset (buffer, 0xff, buffer_size);
1427 1439
1428 memcpy (buffer, &PagableOperationalCodeImage[0], PagableOperationalCodeSize); 1440 err = request_firmware(&fw, fw_name, dev);
1441 if (err) {
1442 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
1443 fw_name, err);
1444 kfree(buffer);
1445 return err;
1446 }
1447 memcpy(buffer, &fw->data[4], fw->size - 4);
1448 release_firmware(fw);
1429 1449
1430 for(i = sizeof(struct ti_i2c_image_header); i < buffer_size; i++) { 1450 for(i = sizeof(struct ti_i2c_image_header); i < buffer_size; i++) {
1431 cs = (__u8)(cs + buffer[i]); 1451 cs = (__u8)(cs + buffer[i]);
@@ -3119,6 +3139,7 @@ module_exit(edgeport_exit);
3119MODULE_AUTHOR(DRIVER_AUTHOR); 3139MODULE_AUTHOR(DRIVER_AUTHOR);
3120MODULE_DESCRIPTION(DRIVER_DESC); 3140MODULE_DESCRIPTION(DRIVER_DESC);
3121MODULE_LICENSE("GPL"); 3141MODULE_LICENSE("GPL");
3142MODULE_FIRMWARE("edgeport/down3.bin");
3122 3143
3123module_param(debug, bool, S_IRUGO | S_IWUSR); 3144module_param(debug, bool, S_IRUGO | S_IWUSR);
3124MODULE_PARM_DESC(debug, "Debug enabled or not"); 3145MODULE_PARM_DESC(debug, "Debug enabled or not");