23 #define __KERNEL_SYSCALLS__
25 #include <linux/module.h>
28 #include <linux/slab.h>
30 #include <linux/netdevice.h>
34 #include <asm/uaccess.h>
41 #define DEBUG(n, args...) printk(KERN_DEBUG args);
43 #define DEBUG(n, args...)
46 #define MAX_DSP_WAIT_LOOPS 100
47 #define DSP_WAIT_SLEEP_TIME 1
49 #define MAX_LENGTH 0x7f0
51 #define DWNLD_MAG_HANDSHAKE_LOC 0x00
52 #define DWNLD_MAG_TYPE_LOC 0x01
53 #define DWNLD_MAG_SIZE_LOC 0x02
54 #define DWNLD_MAG_PS_HDR_LOC 0x03
56 #define DWNLD_HANDSHAKE_LOC 0x02
57 #define DWNLD_TYPE_LOC 0x04
58 #define DWNLD_SIZE_MSW_LOC 0x06
59 #define DWNLD_SIZE_LSW_LOC 0x08
60 #define DWNLD_PS_HDR_LOC 0x0A
62 #define HANDSHAKE_TIMEOUT_VALUE 0xF1F1
63 #define HANDSHAKE_RESET_VALUE 0xFEFE
64 #define HANDSHAKE_DSP_BL_READY 0xFEFE
65 #define HANDSHAKE_DRIVER_READY 0xFFFF
66 #define HANDSHAKE_SEND_DATA 0x0000
68 #define HANDSHAKE_REQUEST 0x0001
69 #define HANDSHAKE_RESPONSE 0x0000
71 #define REQUEST_CODE_LENGTH 0x0000
72 #define REQUEST_RUN_ADDRESS 0x0001
73 #define REQUEST_CODE_SEGMENT 0x0002
74 #define REQUEST_DONE_BL 0x0003
75 #define REQUEST_DONE_CL 0x0004
76 #define REQUEST_VERSION_INFO 0x0005
77 #define REQUEST_CODE_BY_VERSION 0x0006
78 #define REQUEST_MAILBOX_DATA 0x0007
79 #define REQUEST_FILE_CHECKSUM 0x0008
81 #define STATE_START_DWNLD 0x01
82 #define STATE_BOOT_DWNLD 0x02
83 #define STATE_CODE_DWNLD 0x03
84 #define STATE_DONE_DWNLD 0x04
85 #define STATE_SECTION_PROV 0x05
86 #define STATE_DONE_PROV 0x06
87 #define STATE_DONE_FILE 0x07
130 DEBUG(0,
"card_bootload is called\n");
145 for (i = 0; i < (size >> 2); i++) {
150 spin_unlock_irqrestore(&info->
dpram_lock, flags);
171 handshake = (
u16) tempx;
174 if ((handshake == expected_value)
198 tempx = (
u32) handshake_value;
199 tempx =
ntohl(tempx);
215 tempx =
ntohl(tempx);
216 request_type = (
u16) tempx;
235 value = (
long)(w_val << 16);
242 value = (
long)(value | w_val);
245 value =
ntohl(value);
259 size = (
u16) (lvalue >> 16);
266 size = (
u16) (lvalue);
273 tempx =
ntohl(lvalue);
281 u16 *usPtr = (
u16 *) pHdr;
284 chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^
285 usPtr[4]) ^ usPtr[5]) ^ usPtr[6]);
306 long requested_version;
307 bool bGoodVersion = 0;
321 unsigned long templong;
322 unsigned long image_chksum = 0;
324 file_version = *(
long *)pFileStart;
325 if (file_version != 6) {
326 printk(
KERN_ERR "ft1000: unsupported firmware version %ld\n", file_version);
339 bGoodVersion =
false;
368 loader_code_address);
376 pUsFile = (
u16 *) ((
long)pBootEnd);
377 pUcFile = (
u8 *) ((
long)pBootEnd);
386 if ((word_length * 2 + (
long)pUcFile) >
403 if (word_length & 0x01)
405 word_length = word_length / 2;
407 for (; word_length > 0; word_length--) {
408 templong = *pUsFile++;
416 spin_unlock_irqrestore(&info->
441 "ft1000_dnld: REQUEST_FOR_CHECKSUM\n");
478 if ((word_length * 2 + (
long)pUcFile) >
492 if (word_length & 0x01)
494 word_length = word_length / 2;
496 for (; word_length > 0; word_length--) {
497 templong = *pUsFile++;
515 (
u16 *) & pMailBoxData->
data[0];
519 if (file_version == 5) {
523 ft1000_write_reg(dev,
527 for (; word_length > 0; word_length--) {
528 temp =
ntohs(*pUsData);
529 ft1000_write_reg(dev,
541 if (word_length & 0x01) {
544 word_length = word_length / 2;
546 for (; word_length > 0; word_length--) {
547 templong = *pUsData++;
555 spin_unlock_irqrestore(&info->
565 (
u16 *) ((
long)pFileStart +
577 if (word_length & 0x01)
579 word_length = word_length / 2;
581 for (; word_length > 0; word_length--) {
592 spin_unlock_irqrestore(&info->
598 bGoodVersion =
false;
656 "ft1000_dnld: image_chksum = 0x%8x\n",
685 if (((
unsigned long) (pUcFile) - (
unsigned long) pFileStart) >=
686 (
unsigned long) FileLength) {
699 "FT1000:download:Download error: Bad Port IDs in Pseudo Record\n");
700 DEBUG(1,
"\t Port Source = 0x%2.2x\n",
702 DEBUG(1,
"\t Port Destination = 0x%2.2x\n",
725 memcpy(pbuffer, (
void *)pUcFile,
740 (
u8 *) ((
unsigned long) pUcFile +
741 (
unsigned long) ((usHdrLength + 1) & 0xFFFFFFFE) +
sizeof(
struct pseudo_hdr));
742 if ((
unsigned long) (pUcFile) -