Beispiel #1
0
static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
		u16 tempbuffer[], u16 dpram)
{
	int status;
	u16 resultbuffer[64];
	int i;

	for (i = 0; i < 10; i++) {
		status = ft1000_write_dpram32(ft1000dev, dpram,
				(u8 *)&tempbuffer[0], 64);
		if (status == 0) {
			/* Work around for ASIC bit stuffing problem. */
			if ((tempbuffer[31] & 0xfe00) == 0xfe00) {
				status = ft1000_write_dpram32(ft1000dev,
						dpram+12, (u8 *)&tempbuffer[24],
						64);
			}
			/* Let's check the data written */
			status = ft1000_read_dpram32(ft1000dev, dpram,
					(u8 *)&resultbuffer[0], 64);
			if ((tempbuffer[31] & 0xfe00) == 0xfe00) {
				if (check_buffers(tempbuffer, resultbuffer, 28,
							0)) {
					DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
				status = ft1000_read_dpram32(ft1000dev,
						dpram+12,
						(u8 *)&resultbuffer[0], 64);

				if (check_buffers(tempbuffer, resultbuffer, 16,
							24)) {
					DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
			} else {
				if (check_buffers(tempbuffer, resultbuffer, 32,
							0)) {
					DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
			}
			if (status == 0)
				break;
		}
	}
	return status;
}
Beispiel #2
0
static u16 get_handshake_usb(struct ft1000_device *ft1000dev, u16 expected_value)
{
	u16 handshake;
	int loopcnt;
	u16 temp;
	u32 status = 0;

	struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
	loopcnt = 0;
	handshake = 0;

	while (loopcnt < 100) {
		if (pft1000info->usbboot == 2) {
			status = ft1000_read_dpram32(ft1000dev, 0,
					(u8 *)&(pft1000info->tempbuf[0]), 64);
			for (temp = 0; temp < 16; temp++) {
				DEBUG("tempbuf %d = 0x%x\n", temp,
					pft1000info->tempbuf[temp]);
			}
			status = ft1000_read_dpram16(ft1000dev,
						DWNLD_MAG1_HANDSHAKE_LOC,
						(u8 *)&handshake, 1);
			DEBUG("handshake from read_dpram16 = 0x%x\n",
				handshake);
			if (pft1000info->dspalive == pft1000info->tempbuf[6]) {
				handshake = 0;
			} else {
				handshake = pft1000info->tempbuf[1];
				pft1000info->dspalive =
						pft1000info->tempbuf[6];
			}
		} else {
			status = ft1000_read_dpram16(ft1000dev,
						DWNLD_MAG1_HANDSHAKE_LOC,
						(u8 *)&handshake, 1);
		}

		loopcnt++;
		msleep(10);
		handshake = ntohs(handshake);
		if ((handshake == expected_value) ||
		    (handshake == HANDSHAKE_RESET_VALUE_USB))
			return handshake;
	}

	return HANDSHAKE_TIMEOUT_VALUE;
}
Beispiel #3
0
//---------------------------------------------------------------------------
// Function:    write_blk
//
// Parameters:  struct ft1000_device  - device structure
//              u16 **pUsFile - DSP image file pointer in u16
//              u8  **pUcFile - DSP image file pointer in u8
//              long   word_length - length of the buffer to be written
//                                   to DPRAM
//
// Returns:     STATUS_SUCCESS - success
//              STATUS_FAILURE - failure
//
// Description: This function writes a block of DSP image to DPRAM
//
// Notes:
//
//---------------------------------------------------------------------------
static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length)
{
   u32 Status = STATUS_SUCCESS;
   u16 dpram;
   int loopcnt, i, j;
   u16 tempword;
   u16 tempbuffer[64];
   u16 resultbuffer[64];
	struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);

   //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length);
   dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
   tempword = *(*pUsFile);
   (*pUsFile)++;
   Status = ft1000_write_dpram16(ft1000dev, dpram, tempword, 0);
   tempword = *(*pUsFile);
   (*pUsFile)++;
   Status = ft1000_write_dpram16(ft1000dev, dpram++, tempword, 1);

   *pUcFile = *pUcFile + 4;
   word_length--;
   tempword = (u16)word_length;
   word_length = (word_length / 16) + 1;
   for (; word_length > 0; word_length--) /* In words */
   {
	   loopcnt = 0;

	      for (i=0; i<32; i++)
	      {
		       if (tempword != 0)
		       {
    		           tempbuffer[i++] = *(*pUsFile);
			   (*pUsFile)++;
   	    	           tempbuffer[i] = *(*pUsFile);
			   (*pUsFile)++;
			   *pUcFile = *pUcFile + 4;
			   loopcnt++;
			   tempword--;
		       }
		       else
		       {
			   tempbuffer[i++] = 0;
			   tempbuffer[i] = 0;
                       }
	      }

              //DEBUG("write_blk: loopcnt is %d\n", loopcnt);
              //DEBUG("write_blk: bootmode = %d\n", bootmode);
              //DEBUG("write_blk: dpram = %x\n", dpram);
	      if (pft1000info->bootmode == 0)
	      {
		 if (dpram >= 0x3F4)
                     Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 8);
	         else
                    Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64);
	      }
	      else
	      {
                 for (j=0; j<10; j++)
                 {
                   Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64);
		   if (Status == STATUS_SUCCESS)
		   {
		       // Work around for ASIC bit stuffing problem.
		       if ( (tempbuffer[31] & 0xfe00) == 0xfe00)
		       {
      		           Status = ft1000_write_dpram32(ft1000dev, dpram+12, (u8 *)&tempbuffer[24], 64);
		       }
    		       // Let's check the data written
	    	       Status = ft1000_read_dpram32 (ft1000dev, dpram, (u8 *)&resultbuffer[0], 64);
		       if ( (tempbuffer[31] & 0xfe00) == 0xfe00)
		       {
				if (check_buffers(tempbuffer, resultbuffer, 28, 0)) {
					DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n");
					msleep(10);
					Status = STATUS_FAILURE;
					break;
				}
   			   Status = ft1000_read_dpram32 (ft1000dev, dpram+12, (u8 *)&resultbuffer[0], 64);

				if (check_buffers(tempbuffer, resultbuffer, 16, 24)) {
					DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n");
					msleep(10);
					Status = STATUS_FAILURE;
					break;
				}

			}
			else
			{
				if (check_buffers(tempbuffer, resultbuffer, 32, 0)) {
					DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n");
					msleep(10);
					Status = STATUS_FAILURE;
					break;
				}

			}

			if (Status == STATUS_SUCCESS)
			    break;

		    }
		}

		if (Status != STATUS_SUCCESS)
		{
                    DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]);
		    break;
		}

	     }
   	     dpram = dpram + loopcnt;
   }

   return Status;
}