Example #1
0
// ============================================================================
// fAddTargetBankChecksum()
// Reads and adds the target bank checksum to the referenced accumulator.
// Returns:
//     0 if successful
//     VERIFY_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fAccTargetBankChecksum(unsigned int *pAcc)
{
	unsigned int wCheckSumData;

	SendVector(checksum_setup, num_bits_checksum_setup);	//PTJ:CHECKSUM-SETUP, it is taking 100ms > time > 200ms to complete the checksum
	if ((fIsError = fDetectHiLoTransition())) {	//100ms is default
		return (VERIFY_ERROR);
	}

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	SendVector(tsync_enable, num_bits_tsync_enable);

	//Send Read Checksum vector and get Target Checksum
	SendVector(read_checksum_v, 11);	// first 11-bits is ReadCKSum-MSB
	RunClock(2);		// Two SCLKs between write & read
	bTargetDataIN = bReceiveByte();
	wCheckSumData = bTargetDataIN << 8;

	RunClock(1);		// See Fig. 6
	SendVector(read_checksum_v + 2, 12);	// 12 bits starting from 3rd character
	RunClock(2);		// Read-LSB Command
	bTargetDataIN = bReceiveByte();
	wCheckSumData |= (bTargetDataIN & 0xFF);
	RunClock(1);
	SendVector(read_checksum_v + 3, 1);	// Send the final bit of the command   //PTJ: read_checksum_v may have to change if TSYNC needs to be enabled

	SendVector(tsync_disable, num_bits_tsync_disable);

	*pAcc = wCheckSumData;

	return (PASS);
}
Example #2
0
// ============================================================================
// fXRESInitializeTargetForISSP()
// Implements the intialization vectors for the device.
// Returns:
//     0 if successful
//     INIT_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fXRESInitializeTargetForISSP(void)
{
	// Configure the pins for initialization
	SetSDATAHiZ();
	SetSCLKStrong();
	SCLKLow();
	// Cycle reset and put the device in programming mode when it exits reset
	AssertXRES();
	DeassertXRES();
	// !!! NOTE:
	//  The timing spec that requires that the first Init-Vector happen within
	//  1 msec after the reset/power up. For this reason, it is not advisable
	//  to separate the above RESET_MODE or POWER_CYCLE_MODE code from the
	//  Init-Vector instructions below. Doing so could introduce excess delay
	//  and cause the target device to exit ISSP Mode.

	//PTJ: Send id_setup_1 instead of init1_v
	//PTJ: both send CA Test Key and do a Calibrate1 SROM function
	SendVector(id_setup_1, num_bits_id_setup_1);
	if (fIsError = fDetectHiLoTransition()) {
//        TX8SW_CPutString("\r\n fDetectHiLoTransition Error");
		printk("\r\n fDetectHiLoTransition Error\n");
		return (INIT_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	// NOTE: DO NOT not wait for HiLo on SDATA after vector Init-3
	//       it does not occur (per spec).
	return (PASS);
}
Example #3
0
// ============================================================================
// fProgramTargetBlock()
// Program one block with data that has been loaded into a RAM buffer in the
// target device.
// Returns:
//     0 if successful
//     BLOCK_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fProgramTargetBlock(unsigned char bBankNumber,
				unsigned char bBlockNumber)
{

	SendVector(tsync_enable, num_bits_tsync_enable);

	SendVector(set_block_num, num_bits_set_block_num);

	// Set the drive here because SendByte() does not.
	SetSDATAStrong();
	SendByte(bBlockNumber, 8);
	SendByte(set_block_num_end, 3);

	SendVector(tsync_disable, num_bits_tsync_disable);	//PTJ:

	// Send the program-block vector.
	SendVector(program_and_verify, num_bits_program_and_verify);	//PTJ: PROGRAM-AND-VERIFY
	// wait for acknowledge from target.
	if ((fIsError = fDetectHiLoTransition())) {
		return (BLOCK_ERROR);
	}
	// Send the Wait-For-Poll-End vector
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return (PASS);

	//PTJ: Don't do READ-STATUS here because that will
	//PTJ: require that we return multiple error values, if error occurs
}
// ============================================================================
// fAddTargetBankChecksum()
// Reads and adds the target bank checksum to the referenced accumulator.
// Returns:
//     0 if successful
//     VERIFY_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fAccTargetBankChecksum(unsigned int* pAcc)
{
	unsigned int wCheckSumData=0;

	SendVector(checksum_v, num_bits_checksum);

	fIsError = fDetectHiLoTransition();
	if (fIsError )
	{
		return(CHECKSUM_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	//SendVector(tsync_enable, num_bits_tsync_enable);

	//Send Read Checksum vector and get Target Checksum
	SendVector(read_checksum_v, 11);     // first 11-bits is ReadCKSum-MSB
	RunClock(2);                         // Two SCLKs between write & read
	bTargetDataIN = bReceiveByte();
	wCheckSumData = ((unsigned int)(bTargetDataIN))<<8;

	RunClock(1);                         // See Fig. 6
	SendVector(read_checksum_v + 2, 12); // 12 bits starting from 3rd character
	RunClock(2);                         // Read-LSB Command
	bTargetDataIN = bReceiveByte();
	wCheckSumData |= (unsigned int) bTargetDataIN;
	RunClock(1);
	SendVector(read_checksum_v + 4, 1);  // Send the final bit of the command

	//SendVector(tsync_disable, num_bits_tsync_disable);

	*pAcc = wCheckSumData;

	return(PASS);
}
Example #5
0
// ============================================================================
// fSecureTargetFlash()
// Before calling, load the array, abTargetDataOUT, with the desired security
// settings using LoadArrayWithSecurityData(StartAddress,Length,SecurityType).
// The can be called multiple times with different SecurityTypes as needed for
// particular Flash Blocks. Or set them all the same using the call below:
// LoadArrayWithSecurityData(0,SECURITY_BYTES_PER_BANK, 0);
// Returns:
//     0 if successful
//     SECURITY_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fSecureTargetFlash(void)
{
	unsigned char bTemp;

	// Transfer the temporary RAM array into the target
	bTargetAddress = 0x00;
	bTargetDataPtr = 0x00;

	SetSDATAStrong();
	while (bTargetDataPtr < SECURITY_BYTES_PER_BANK) {
		bTemp = abTargetDataOUT[bTargetDataPtr];
		SendByte(write_byte_start, 4);
		SendByte(bTargetAddress, 7);
		SendByte(bTemp, 8);
		SendByte(write_byte_end, 3);

		// SendBytes() uses MSBits, so increment the address by '2' to put
		// the 0..n address into the seven MSBit locations
		bTargetAddress += 2;	//PTJ: inc by 2 in order to support a 128 byte address space
		bTargetDataPtr++;
	}

	SendVector(secure, num_bits_secure);	//PTJ:
	if ((fIsError = fDetectHiLoTransition())) {
		return (SECURITY_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return (PASS);
}
Example #6
0
signed char fSecureTargetFlash(void)
{
	unsigned char bTemp;

	bTargetAddress = 0x00;
	bTargetDataPtr = 0x00;

	SetSDATAStrong();
	while (bTargetDataPtr < SecurityBytesPerBank) {
		bTemp = abTargetDataOUT[bTargetDataPtr];
	SendByte(write_byte_start, 4);
	SendByte(bTargetAddress, 7);
		SendByte(bTemp, 8);
		SendByte(write_byte_end, 3);

	bTargetAddress += 2;
	/*PTJ: inc by 2 in order to support a 128 byte address space*/
	bTargetDataPtr++;
	}

	SendVector(secure, num_bits_secure);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return SECURITY_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return PASS;
}
Example #7
0
signed char fAccTargetBankChecksum(unsigned int *pAcc)
{
	unsigned int wCheckSumData = 0;

	SendVector(checksum_v, num_bits_checksum);

	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return CHECKSUM_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	SendVector(tsync_enable, num_bits_tsync_enable);
	SendVector(read_checksum_v, 11); /*first 11-bits is ReadCKSum-MSB*/
	RunClock(2); /*Two SCLKs between write & read*/
	bTargetDataIN = bReceiveByte();
	wCheckSumData = bTargetDataIN<<8;
	RunClock(1);
	/*12 bits starting from 3rd character*/
	SendVector(read_checksum_v + 2, 12);

	RunClock(2);                         /* Read-LSB Command*/
	bTargetDataIN = bReceiveByte();
	wCheckSumData |= (bTargetDataIN & 0xFF);
	RunClock(1);
	 /*Send the final bit of the command */
	SendVector(read_checksum_v + 3, 1);
	/* Send the final bit of the command
	PTJ: read_checksum_v may have to change if TSYNC needs to be enabled*/
	SendVector(tsync_disable, num_bits_tsync_disable);

	*pAcc = wCheckSumData;

	return PASS;
}
Example #8
0
signed char fEraseTarget(void)
{
	SendVector(erase, num_bits_erase);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return ERASE_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return PASS;
}
Example #9
0
// ============================================================================
// fEraseTarget()
// Perform a bulk erase of the target device.
// Returns:
//     0 if successful
//     ERASE_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fEraseTarget(void)
{
    SendVector(erase, num_bits_erase);
    if (fIsError = fDetectHiLoTransition()) {
        return(ERASE_ERROR);
    }
    SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
    return(PASS);
}
Example #10
0
// ============================================================================
// fVerifySiliconID()
// Returns:
//     0 if successful
//     Si_ID_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifySiliconID(void)
{
    SendVector(id_setup_2, num_bits_id_setup_2);
    if (fIsError = fDetectHiLoTransition())
    {
        return(SiID_ERROR);
    }
    SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

    SendVector(tsync_enable, num_bits_tsync_enable);

    //Send Read ID vector and get Target ID
    SendVector(read_id_v, 11);      // Read-MSB Vector is the first 11-Bits
    RunClock(2);                    // Two SCLK cycles between write & read
    bTargetID[0] = bReceiveByte();
    RunClock(1);
    SendVector(read_id_v+2, 12);    // 1+11 bits starting from the 3rd byte

    RunClock(2);                    // Read-LSB Command
    bTargetID[1] = bReceiveByte();

    RunClock(1);
    SendVector(read_id_v+4, 1);     // 1 bit starting from the 5th byte

    //read Revision ID from Accumulator A and Accumulator X
    //SendVector(read_id_v+5, 11);	//11 bits starting from the 6th byte
    //RunClock(2);
    //bTargetID[2] = bReceiveByte();	//Read from Acc.X
    //RunClock(1);
    //SendVector(read_id_v+7, 12);    //1+11 bits starting from the 8th byte
    //
    //RunClock(2);
    //bTargetID[3] = bReceiveByte();	//Read from Acc.A
    //
    //RunClock(1);
    //SendVector(read_id_v+4, 1);     //1 bit starting from the 5th byte,

    SendVector(tsync_disable, num_bits_tsync_disable);

    printk(KERN_ERR "[CYPRESS] Silicon ID : %x %x\n", bTargetID[0], bTargetID[1]);
    
    if (!(bTargetID[0] == target_id_v[0] || bTargetID[0] == target_id_v_2[0]) //etinum
         || !(bTargetID[1] == target_id_v[1] || bTargetID[1] == target_id_v_2[1]) //etinum
        )
    {
        #if 1
        return(PASS);
        #else
        return(SiID_ERROR);
        #endif
    }
    else
    {
        return(PASS);
    }
}
// ============================================================================
// fEraseTarget()
// Perform a bulk erase of the target device.
// Returns:
//     0 if successful
//     ERASE_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fEraseTarget(void)
{
    SendVector(erase, num_bits_erase);
    if ((fIsError = fDetectHiLoTransition()) != PASS) {
//        TX8SW_CPutString("\r\n fDetectHiLoTransition");
        printk("\r\n fDetectHiLoTransition\n");
        return(ERASE_ERROR);
    }
    SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
    return(PASS);
}
// ============================================================================
// fEraseTarget()
// Perform a bulk erase of the target device.
// Returns:
//     0 if successful
//     ERASE_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fEraseTarget(void)
{
	SendVector(erase, num_bits_erase);
	if ((fIsError = fDetectHiLoTransition())) {
//        TX8SW_CPutString("fDetectHiLoTransition");
		//printk(KERN_DEBUG"touchkey:fDetectHiLoTransition\n"); // issp_test_2010 block
		return (ERASE_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return (PASS);
}
// ============================================================================
// fEraseTarget()
// Perform a bulk erase of the target device.
// Returns:
//     0 if successful
//     ERASE_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fEraseTarget(void)
{
	SendVector(erase, num_bits_erase);
	if ((fIsError = fDetectHiLoTransition())) {
//        TX8SW_CPutString("\r\n fDetectHiLoTransition");
		printk(KERN_INFO "\r\n fEraseTarget fDetectHiLoTransition\n");
		/* issp_test_2010 block */
		return (ERASE_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return (PASS);
}
// ============================================================================
// fVerifyTargetBlock()
// Verify the block just written to. This can be done byte-by-byte before the
// protection bits are set.
// Returns:
//     0 if successful
//     BLOCK_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifyTargetBlock(unsigned char bBankNumber,
			       unsigned char bBlockNumber)
{
	SendVector(set_block_number, 11);

	//Set the drive here because SendByte() does not
	SetSDATAStrong();
	SendByte(bBlockNumber, 8);
	SendByte(set_block_number_end, 3);

	SendVector(verify_setup_v, num_bits_verify_setup);
	if ((fIsError = fDetectHiLoTransition())) {
		return (BLOCK_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	bTargetAddress = 0;
	bTargetDataPtr = 0;

	while (bTargetDataPtr < TARGET_DATABUFF_LEN) {
		//Send Read Byte vector and then get a byte from Target
		SendVector(read_byte_v, 4);	//PTJ 308: this was changed from sending the first 5 bits to sending the first 4
		// Set the drive here because SendByte() does not
		SetSDATAStrong();
		SendByte(bTargetAddress, 6);

		RunClock(2);	// Run two SCLK cycles between writing and reading
		SetSDATAHiZ();	// Set to HiZ so Target can drive SDATA
		bTargetDataIN = bReceiveByte();

		RunClock(1);
		SendVector(read_byte_v + 1, 1);	// Send the ReadByte Vector End

		// Test the Byte that was read from the Target against the original
		// value (already in the 128-Byte array "abTargetDataOUT[]"). If it
		// matches, then bump the address & pointer,loop-back and continue.
		// If it does NOT match abort the loop and return an error.
		if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr])
			return (BLOCK_ERROR);

		bTargetDataPtr++;
		// Increment the address by four to accomodate 6-Bit addressing
		// (puts the 6-bit address into MSBit locations for "SendByte()").
		bTargetAddress += 4;
	}
	return (PASS);
}
/* ============================================================================
// fVerifySiliconID()
// Returns:
//     0 if successful
//     Si_ID_ERROR if timed out on handshake to the device.
 ============================================================================*/
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);
	fIsError = fDetectHiLoTransition();
	if (fIsError)
		return SiID_ERROR;

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	SendVector(tsync_enable, num_bits_tsync_enable);

	/* Send Read ID vector and get Target ID */
	SendVector(read_id_v, 11);      /* Read-MSB Vector is the first 11-Bits */
	RunClock(2);                    /* Two SCLK cycles between write & read */
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	SendVector(read_id_v+2, 12);    /* 1+11 bits starting from the 3rd byte */

	RunClock(2);                    /* Read-LSB Command */
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v+4, 1);     /* 1 bit starting from the 5th byte */

	/* read Revision ID from Accumulator A and Accumulator X */
	SendVector(read_id_v+5, 11);	/* 11 bits starting from the 6th byte */
	RunClock(2);
	bTargetID[2] = bReceiveByte();	/* Read from Acc.X */
	RunClock(1);
	SendVector(read_id_v+7, 12);    /* 1+11 bits starting from the 8th byte */

	RunClock(2);
	bTargetID[3] = bReceiveByte();	/* Read from Acc.A */

	RunClock(1);
	SendVector(read_id_v+4, 1);     /*1 bit starting from the 5th byte, */

	SendVector(tsync_disable, num_bits_tsync_disable);

	pr_info("%s: bTargetID[0] = %x, bTargetID[1] = %x\n", __func__, bTargetID[0], bTargetID[1]);
	if (bTargetID[0] == target_id_v_1[0] || bTargetID[1] == target_id_v_1[1])
		return PASS;
	else if (bTargetID[0] == target_id_v_2[0] || bTargetID[1] == target_id_v_2[1])
		return PASS;
	else
		return SiID_ERROR;
}
Example #16
0
signed char fVerifySetup(unsigned char bBankNumber, unsigned char bBlockNumber)
{
	SendVector(set_block_num, num_bits_set_block_num);

	  /* Set the drive here because SendByte() does not */
	SetSDATAStrong();
	SendByte(bBlockNumber, 8);
	SendByte(set_block_num_end, 3);

	SendVector(verify_setup, num_bits_my_verify_setup);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return VERIFY_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	return PASS;
}
/* ============================================================================
// fXRESInitializeTargetForISSP()
// Implements the intialization vectors for the device.
// Returns:
//     0 if successful
//     INIT_ERROR if timed out on handshake to the device.
 ============================================================================*/
signed char fXRESInitializeTargetForISSP(void)
{
	/* Configure the pins for initialization */
	SetSDATAHiZ();
	SetSCLKStrong();
	SCLKLow();

#ifdef ACTIVE_LOW_XRES
	AssertXRES();	/* assert XRES before setting XRES pin to strong */
	SetXRESStrong();
	DeassertXRES();
	/* Delay(XRES_CLK_DELAY); */
	mdelay(1);
	AssertXRES();
#else
	/* Cycle reset and put the device in programming mode when it exits reset */
	SetXRESStrong();
	AssertXRES();
	Delay(XRES_CLK_DELAY);
	DeassertXRES();
#endif

	/* !!! NOTE:
	//  The timing spec that requires that the first Init-Vector happen within
	//  1 msec after the reset/power up. For this reason, it is not advisable
	//  to separate the above RESET_MODE or POWER_CYCLE_MODE code from the
	//  Init-Vector instructions below. Doing so could introduce excess delay
	//  and cause the target device to exit ISSP Mode.
	 */

	SendVector(id_setup_1, num_bits_id_setup_1);
	fIsError = fDetectHiLoTransition();
	if (fIsError)
		return INIT_ERROR;

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	/* NOTE: DO NOT not wait for HiLo on SDATA after vector Init-3
	//       it does not occur (per spec). */
	return PASS;
}
// ============================================================================
// fVerifySetup()
// Verify the block just written to. This can be done byte-by-byte before the
// protection bits are set.
// Returns:
//     0 if successful
//     BLOCK_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifySetup(unsigned char bBankNumber, unsigned char bBlockNumber)
{
	SendVector(tsync_enable, num_bits_tsync_enable);

	SendVector(set_block_num, num_bits_set_block_num);

	//Set the drive here because SendByte() does not
	SetSDATAStrong();
	SendByte(bBlockNumber, 8);
	SendByte(set_block_num_end, 3);	//PTJ:

	SendVector(tsync_disable, num_bits_tsync_disable);	//PTJ:

	SendVector(verify_setup, num_bits_my_verify_setup);	//PTJ:
	if ((fIsError = fDetectHiLoTransition())) {
		return (BLOCK_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	return (PASS);
}
/* ============================================================================
// fSecureTargetFlash()
// Before calling, load the array, abTargetDataOUT, with the desired security
// settings using LoadArrayWithSecurityData(StartAddress,Length,SecurityType).
// The can be called multiple times with different SecurityTypes as needed for
// particular Flash Blocks. Or set them all the same using the call below:
// LoadArrayWithSecurityData(0,SECURITY_BYTES_PER_BANK, 0);
// Returns:
//     0 if successful
//     SECURITY_ERROR if timed out on handshake to the device.
 ============================================================================*/
signed char fSecureTargetFlash(void)
{
	unsigned char bTemp;

	/* Transfer the temporary RAM array into the target */
	bTargetAddress = 0x00;
	bTargetDataPtr = 0x00;

	SendVector(tsync_enable, num_bits_tsync_enable);

	SendVector(read_write_setup, num_bits_read_write_setup);

	SetSDATAStrong();
	while (bTargetDataPtr < SECURITY_BYTES_PER_BANK) {
		bTemp = abTargetDataOUT[bTargetDataPtr];
		SendByte(write_byte_start, 4);
		SendByte(bTargetAddress, 7);
		SendByte(bTemp, 8);
		SendByte(write_byte_end, 3);


		/* SendBytes() uses MSBits, so increment the address by '2' to put
		// the 0..n address into the seven MSBit locations
		*/
		bTargetAddress += 2;	/* inc by 2 in order to support a 128 byte address space */
		bTargetDataPtr++;
	}

	SendVector(tsync_disable, num_bits_tsync_disable);

	SendVector(secure, num_bits_secure);
	fIsError = fDetectHiLoTransition();
	if (fIsError)
		return SECURITY_ERROR;

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	return PASS;
}
Example #20
0
 /*============================================================================
 fXRESInitializeTargetForISSP()
 Implements the intialization vectors for the device.
 Returns:
     0 if successful
     INIT_ERROR if timed out on handshake to the device.
 ============================================================================
*/
signed char fXRESInitializeTargetForISSP(void)
{
	 /*Configure the pins for initialization*/
	SetSDATAHiZ();
	SetSCLKStrong();
	SCLKLow();
	SetXRESStrong();

	/* Cycle reset and put the device
	  in programming mode when it exits reset */
	AssertXRES();
	Delay(XRES_CLK_DELAY);
	DeassertXRES();

	/*
	 !!! NOTE:
	  The timing spec that requires that the first Init-Vector happen within
	  1 msec after the reset/power up. For this reason, it is not advisable
	  to separate the above RESET_MODE or POWER_CYCLE_MODE code from the
	  Init-Vector instructions below. Doing so could introduce excess delay
	  and cause the target device to exit ISSP Mode.

	PTJ: Send id_setup_1 instead of init1_v
	PTJ: both send CA Test Key and do a Calibrate1 SROM function
	*/
	SendVector(id_setup_1, num_bits_id_setup_1);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return INIT_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	/*
	 NOTE: DO NOT not wait for HiLo on SDATA after vector Init-3
		   it does not occur (per spec).
	*/
	return PASS;
}
Example #21
0
signed char fAccTargetBankChecksum(unsigned int *pAcc)
{
	unsigned int wCheckSumData = 0;

	SendVector(checksum_v, num_bits_checksum);

	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return CHECKSUM_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	 /*Send Read Checksum vector and get Target Checksum*/

	 SendVector(read_checksum_v, 11); /*first 11-bits is ReadCKSum-MSB*/

	 RunClock(2); /*Two SCLKs between write & read*/

	 bTargetDataIN = bReceiveByte();
	RunClock(1);
	wCheckSumData = ((unsigned int) bTargetDataIN)<<8;
	/*12 bits starting from 3rd character*/
	SendVector(read_checksum_v + 2, 12);

	 RunClock(2);                         /* Read-LSB Command*/

	 bTargetDataIN = bReceiveByte();
	RunClock(1);
	 /*Send the final bit of the command */
	SendVector(read_checksum_v + 4, 1);

	 wCheckSumData |= (unsigned int) bTargetDataIN;

	*pAcc = wCheckSumData;

	return PASS;
}
Example #22
0
// ============================================================================
// fVerifySiliconID()
// Returns:
//     0 if successful
//     Si_ID_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);

	fIsError = fDetectHiLoTransition();
	if (fIsError)
	{
#ifdef TX_ON
		UART_PutCRLF();
		UART_CPutString("fDetectHiLoTransition Error");
#endif
		return(SiID_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	SendVector(tsync_enable, num_bits_tsync_enable);

	//Send Read ID vector and get Target ID
	SendVector(read_id_v, 11);      // Read-MSB Vector is the first 11-Bits
	RunClock(2);                    // Two SCLK cycles between write & read
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	SendVector(read_id_v+2, 12);    // 1+11 bits starting from the 3rd byte

	RunClock(2);                    // Read-LSB Command
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v+4, 1);     // 1 bit starting from the 5th byte

	//read Revision ID from Accumulator A and Accumulator X
	//SendVector(read_id_v+5, 11);	//11 bits starting from the 6th byte
	//RunClock(2);
	//bTargetID[2] = bReceiveByte();	//Read from Acc.X
	//RunClock(1);
	//SendVector(read_id_v+7, 12);    //1+11 bits starting from the 8th byte
	//
	//RunClock(2);
	//bTargetID[3] = bReceiveByte();	//Read from Acc.A
	//
	//RunClock(1);
	//SendVector(read_id_v+4, 1);     //1 bit starting from the 5th byte,

	SendVector(tsync_disable, num_bits_tsync_disable);


#ifdef TX_ON
	// Print READ-ID
	UART_PutCRLF();
	UART_CPutString("Silicon-ID : ");
	UART_PutChar(' ');
	UART_PutHexByte(bTargetID[0]);
	UART_PutChar(' ');
	UART_PutHexByte(bTargetID[1]);
	UART_PutChar(' ');
#endif

#ifdef LCD_ON
	LCD_Char_Position(1, 0);
	LCD_Char_PrintString("ID : ");
	LCD_Char_PrintInt8(bTargetID[0]);
	LCD_Char_PutChar(' ');
	LCD_Char_PrintInt8(bTargetID[1]);
	LCD_Char_PutChar(' ');
#endif

	if (bTargetID[0] == target_id_v[0] && bTargetID[1] == target_id_v[1])
	{
		return(PASS);
	}
	else if (bTargetID[0] == target_id_v2[0] && bTargetID[1] == target_id_v2[1])	
	{
		return(PASS);
	}
	else
	{
		printk("%x %x \n", bTargetID[0], bTargetID[1]);
		return(SiID_ERROR);
	}
}
// ============================================================================
// fVerifySiliconID()
// Returns:
//     0 if successful
//     Si_ID_ERROR if timed out on handshake to the device.
// ============================================================================
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);
	//printk(KERN_ERR"fVerifySiliconID: SendVector id_stup2 END\n");

	if ((fIsError = fDetectHiLoTransition())) {
		printk(KERN_INFO "fVerifySiliconID(): fDetectHiLoTransition Error\n");
		return (SiID_ERROR);
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	SendVector(tsync_enable, num_bits_tsync_enable);
	//printk(KERN_ERR"fVerifySiliconID: SendVector(wait_and_poll_end) (tsync_enable) END\n");

	//Send Read ID vector and get Target ID
	SendVector(read_id_v, 11);	// Read-MSB Vector is the first 11-Bits
	RunClock(2);		// Two SCLK cycles between write & read
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	SendVector(read_id_v + 2, 12);	// 1+11 bits starting from the 3rd byte

	RunClock(2);		// Read-LSB Command
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v + 4, 1);	// 1 bit starting from the 5th byte

	//read Revision ID from Accumulator A and Accumulator X
	SendVector(read_id_v + 5, 11);	//11 bits starting from the 6th byte
	RunClock(2);
	bTargetID[2] = bReceiveByte();	//Read from Acc.X
	RunClock(1);
	SendVector(read_id_v + 7, 12);	//1+11 bits starting from the 8th byte

	RunClock(2);
	bTargetID[3] = bReceiveByte();	//Read from Acc.A

	RunClock(1);
	SendVector(read_id_v + 4, 1);	//1bit starting from the 5th byte,

	SendVector(tsync_disable, num_bits_tsync_disable);

	// Print READ-ID
	/*
	   TX8SW_CPutString("\r\n Silicon-ID : ");
	   TX8SW_PutChar(' ');
	   TX8SW_PutSHexByte(bTargetID[0]);
	   TX8SW_PutChar(' ');
	   TX8SW_PutSHexByte(bTargetID[1]);
	   TX8SW_PutChar(' ');
	   TX8SW_PutSHexByte(bTargetID[2]);
	   TX8SW_PutChar(' ');
	   TX8SW_PutSHexByte(bTargetID[3]);
	   TX8SW_PutChar(' ');
	 */
#if 0				// issp_test_20100709 block
	printk("issp_routines.c: ID0:0x%X, ID1:0x%X, ID2: 0x%X, ID2: 0x%X\n",
	       bTargetID[0], bTargetID[1], bTargetID[2], bTargetID[3]);

	if ((bTargetID[0] != target_id_v[0]) || (bTargetID[1] != target_id_v[1])
	    || (bTargetID[2] != target_id_v[2])
	    || (bTargetID[3] != target_id_v[3])) {
		return (SiID_ERROR);
	} else {
		return (PASS);
	}
#else
	return (PASS);

#endif
}
Example #24
0
signed char fVerifySiliconID(void)
{
	SendVector(id_setup_2, num_bits_id_setup_2);
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0) {
		#ifdef TX_ON
			TX8SW_PutCRLF();
			TX8SW_CPutString("fDetectHiLoTransition Error");
		#endif

		#ifdef LCD_ON
			LCD_Char_PrintString("fDetectHiLoTransition Error");
		#endif

		return SiID_ERROR;
	}
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

 /*   Send Read ID vector and get Target ID */
	SendVector(read_id_v, 11); /*Read-MSB Vector is the first 11-Bits */
	RunClock(2);  /*Two SCLK cycles between write & read */
	bTargetID[0] = bReceiveByte();
	RunClock(1);
	 /* 1+11 bits starting from the 3rd byte */
	SendVector(read_id_v + 2, 12);
	RunClock(2);                    /* Read-LSB Command */
	bTargetID[1] = bReceiveByte();

	RunClock(1);
	SendVector(read_id_v+4, 1); /*1 bit starting from the 5th byte */


    #ifdef TX_ON
		 /*Print READ-ID */
		TX8SW_PutCRLF();
		TX8SW_CPutString("Silicon-ID : ");
		TX8SW_PutChar(' ');
		TX8SW_PutSHexByte(bTargetID[0]);
		TX8SW_PutChar(' ');
		TX8SW_PutSHexByte(bTargetID[1]);
		TX8SW_PutChar(' ');

		/* See the latest spec. 40-95002, 40-95004, 001-15870, AN2026d*/
		switch (bTargetID[0]) {
		case 0x00:
			TX8SW_CPutString(
				"\r\nPSoC1 = 00xx (including Ovation-ONS)");
			switch (bTargetID[1]) {
			case 0x68:
				TX8SW_CPutString(
					"\r\nCY8C20234 8K, 512B(Quark)");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0xAD:
				TX8SW_CPutString(
					"\r\nCY8C20446A-24LQXI 16K, 2K(Krypton)");
				TargetDatabufLen = 128;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0x37:
				TX8SW_CPutString(
					"\r\nCY8C21334 Automotive(Neutron) 8K,512B");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			case 0x38:
				TX8SW_CPutString(
					"\r\nCY8C21434 Neutron");
				TargetDatabufLen = 64;
				NumBanks = 1;
				BlocksPerBank = 128;
				SecurityBytesPerBank = 64;
				break;
			default:
				break;
			}
			break;
		case 0x01:
			TX8SW_CPutString(
				"\r\nPSoC1 = 01xx(continued family and mask set growth");
			break;
		case 0x02:
			TX8SW_CPutString(
				"\r\nPSoC1 + SmartSense = 02xx");
			break;
		case 0x03:
			TX8SW_CPutString("\r\nUnallocated = 03xx");
			break;
		case 0x04:
			TX8SW_CPutString("\r\nPower PSoC = 04xx");
			break;
		case 0x05:
			TX8SW_CPutString(
				"\r\nTrueTouch Multi-Touch All Points(TMA) = 05xx");
			switch (bTargetID[1]) {
			case 0x9A:
				TX8SW_CPutString(
					"\r\nCY8CTMA340-LQI-01");
				TargetDatabufLen = 128;
				NumBanks = 1;
				BlocksPerBank = 256;
				SecurityBytesPerBank = 64;
				break;
			default:
				break;
			}

			break;
		case 0x06:
			TX8SW_CPutString(
				"\r\nTrueTouch Single Touch(TST) = 06xx");
			break;
		case 0x07:
			TX8SW_CPutString(
				"\r\nTrueTouch Multi-Touch Gesture(TMG) = 07xx");
			break;
		case 0x08:
			TX8SW_CPutString(
				"\r\nPSoC1 Value = 08xx");
			break;
		case 0x09:
			TX8SW_CPutString(
				"\r\nPSoC1 PLC = 09xx");
			break;
		case 0x0A:
			TX8SW_CPutString(
				"\r\nPSoC1 PLC + Ez Color = 0Axx");
			break;
		case 0x0B:
			TX8SW_CPutString(
				"\r\nPSoC1 + SmartSense_EMC = 0Bxx");
			break;
		case 0x0C:
			TX8SW_CPutString(
				"\r\nHaptics Only = 0Cxx");
			break;
		case 0x0D:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Multi-Touch All Points(TMA) = 0Dxx");
			break;
		case 0x0E:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Single Touch(TST = 0Exx");
			break;
		case 0x0F:
			TX8SW_CPutString(
				"\r\nHaptics + TrueTouch Multi-Touch Gesture(TMG) = 0Fxx");
			break;
		default:
			TX8SW_CPutString("\r\nUnknown Silicon ID !!");
			while (1)
				;
			break;
		}
	  #endif

		target_id_v[0] = bTargetID[0];
		target_id_v[1] = bTargetID[1];

	#ifdef LCD_ON
		LCD_Char_Position(1, 0);
		LCD_Char_PrintString("ID : ");
		LCD_Char_PrintInt8(bTargetID[0]);
		LCD_Char_PutChar(' ');
		LCD_Char_PrintInt8(bTargetID[1]);
		LCD_Char_PutChar(' ');
	#endif



	if (bTargetID[0] != target_id_v[0] || bTargetID[1] != target_id_v[1])
		return SiID_ERROR;
	else
		return PASS;
}
Example #25
0
/*
 ============================================================================
 fPowerCycleInitializeTargetForISSP()
 Implements the intialization vectors for the device.
 The first time fDetectHiLoTransition is called the Clk pin is highZ because
 the clock is not needed during acquire.
 Returns:
     0 if successful
     INIT_ERROR if timed out on handshake to the device.
 ============================================================================

*/
signed char fPowerCycleInitializeTargetForISSP(void)
{
	unsigned char n;

/*
     Set all pins to highZ to avoid back powering the PSoC through the GPIO
     protection diodes.
*/
	SetSCLKHiZ();
	SetSDATAHiZ();

	 /* Turn on power to the target device before other signals */
	SetTargetVDDStrong();
		for (n = 0; n < 100; n++)
			Delay(50000);
	ApplyTargetVDD();
	 /* wait 1msec for the power to stabilize */

	for (n = 0; n < 10; n++)
		Delay(DELAY100us);

	/*
	 Set SCLK to high Z so there is no clock and wait for a high to low
	 transition on SDAT. SCLK is not needed this time.

	*/
	SetSCLKHiZ();
	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return INIT_ERROR;

	 /*Configure the pins for initialization */
	SetSDATAHiZ();
	SetSCLKStrong();
	SCLKLow();
/*PTJ: DO NOT SET A BREAKPOINT HERE AND EXPECT SILICON ID TO PASS!

	!!! NOTE:
	The timing spec that requires that the first Init-Vector happen within
	1 msec after the reset/power up. For this reason, it is not advisable
	to separate the above RESET_MODE or POWER_CYCLE_MODE code from the
	Init-Vector instructions below. Doing so could introduce excess delay
	and cause the target device to exit ISSP Mode.

	*/

	 SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	/*20100114 KJHW(Jason)  : 0114 by KJHW */


	SendVector(id_setup_1, num_bits_id_setup_1);

	fIsError = fDetectHiLoTransition();
	if (fIsError != 0)
		return INIT_ERROR;
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	/*
	 NOTE: DO NOT not wait for HiLo on SDATA after vector Init-3
		   it does not occur (per spec).
	*/
	return PASS;
}
/* ============================================================================
// XCH: fVerifySecurity()
// This step is optional. Verifies that the security bits have been written correctly
============================================================================ */
signed char fVerifySecurity(void)
{
	/* unsigned char bBlockNumber = 0;//wly */

	bTargetAddress = 0x00;
#ifdef USE_TP
	SetTPHigh();    /* Only used of Test Points are enabled */
#endif
#ifdef USE_TP
	SetTPLow();    /* Only used of Test Points are enabled */
#endif

	SendVector(verify_security, num_bits_verify_security);
	fIsError = fDetectHiLoTransition();
	if (fIsError)
		return INIT_ERROR;

#ifdef USE_TP
	SetTPHigh();    /* Only used of Test Points are enabled */
#endif

#ifdef USE_TP
	SetTPLow();	/* Only used of Test Points are enabled */
#endif

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	bTargetAddress = 0x00;
	bTargetDataPtr = 0x00;

	SendVector(tsync_enable, num_bits_tsync_enable);

	SendVector(read_write_setup, num_bits_read_write_setup);

	/* fReadWriteSetup(); */

	/* we do SECURITY_BYTES_PER_BANK * 2 because we bTargetAddress += 2 */
	while (bTargetAddress < (SECURITY_BYTES_PER_BANK * 2)) {
		/* Send Read Byte vector and then get a byte from Target */
		SendVector(read_byte_v, 4);
		/* Set the drive here because SendByte() does not */
		SetSDATAStrong();

		SendByte(bTargetAddress, 7);

		SetSDATAHiZ();     /* Set to HiZ so Target can drive SDATA */
		RunClock(2);       /* Run two SCLK cycles between writing and reading */
		bTargetDataIN = bReceiveByte();

		RunClock(1);
		SendVector(read_byte_v + 1, 1);     /* Send the ReadByte Vector End */

		/* Test the Byte that was read from the Target against the original
		// value (already in the 128-Byte array "abTargetDataOUT[]"). If it
		// matches, then bump the address & pointer,loop-back and continue.
		// If it does NOT match abort the loop and return and error.
		*/

		if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr])
			return BLOCK_ERROR;

		/* Increment the address by two to accomodate 7-Bit addressing
		   (puts the 7-bit address into MSBit locations for "SendByte()").
		 */

		bTargetDataPtr++;
		bTargetAddress += 2;
	}

	SendVector(tsync_disable, num_bits_tsync_disable);

	return PASS;
}
/* ============================================================================
// fEraseBlock()
// Perform a block erase of the target device.
// Returns:
//     0 if successful
//     ERASE_ERROR if timed out on handshake to the device.
============================================================================*/
signed char fEraseBlock(unsigned char bBlockNumber)
{
	unsigned char bTargetDataPtr = 0;
	SendVector(tsync_enable, num_bits_tsync_enable);

	SendVector(read_write_setup, num_bits_read_write_setup);

	/* Set SDATA to Strong Drive here because SendByte() does not */
	SetSDATAStrong();

	/* Transfer the temporary RAM array into the target.
	// In this section, a 128-Byte array was specified by #define, so the entire
	// 128-Bytes are written in this loop.
	*/
	bTargetAddress = 0x00;

	while (bTargetDataPtr < TARGET_DATABUFF_LEN) {
		SendByte(write_byte_start, 4);	/* we need to be able to write 128 bytes from address 0x80 to 0xFF*/
		SendByte(bTargetAddress, 7);	 /* we need to be able to write 128 bytes from address 0x80 to 0xFF*/
		SendByte(0, 8);			 /* load 0x00 */
		SendByte(write_byte_end, 3);

		/* !!!NOTE:
		// SendByte() uses MSbits, so inc by '2' to put the 0..128 address into
		// the seven MSBit locations.
		//
		// This can be confusing, but check the logic:
		//   The address is only 7-Bits long. The SendByte() subroutine will
		// send however-many bits, BUT...always reads them bits from left-to-
		// right. So in order to pass a value of 0..128 as the address using
		// SendByte(), we have to left justify the address by 1-Bit.
		//   This can be done easily by incrementing the address each time by
		// '2' rather than by '1'.
		*/

		bTargetAddress += 2;	/* inc by 2 in order to support a 128 byte address space */
		bTargetDataPtr++;
	}

	SendVector(set_block_num, num_bits_set_block_num);

	/* Set the drive here because SendByte() does not. */
	SetSDATAStrong();
	SendByte(bBlockNumber, 8);
	SendByte(set_block_num_end, 3);

	SendVector(tsync_disable, num_bits_tsync_disable);

	/* Send the program-and-verify vector. */
	SendVector(program_and_verify, num_bits_program_and_verify);
	/* wait for acknowledge from target. */
	fIsError = fDetectHiLoTransition();
	if (fIsError)
		return BLOCK_ERROR;

	/* Send the Wait-For-Poll-End vector */
	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	/*----------------------------------------------------------------
	// XCH: the lines below actually implement the erase SROM function
	// however, Product Engineering recommends using the WRITE SROM
	// function instead and write all '0' to the block.  The function
	// below is saved for possible future implementation
	 */

	/*    SendVector(tsync_enable, num_bits_tsync_enable);

	//    SendVector(set_block_num, num_bits_set_block_num);

	// Set the drive here because SendByte() does not.
	//    SetSDATAStrong();
	//    SendByte(bBlockNumber,8);
	//    SendByte(set_block_num_end, 3);

	//    SendVector(tsync_disable, num_bits_tsync_disable);

	// Send the erase-block vector.
	//    SendVector(erase_block, num_bits_erase_block);

	// wait for acknowledge from target.
	//    if (fIsError == fDetectHiLoTransition()) {
	//        return(BLOCK_ERROR);
	//    }

	// Send the Wait-For-Poll-End vector
	//    SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);
	//-----------------------------------------------------------------
	 */
	return PASS;
}
/* ============================================================================
// fPowerCycleInitializeTargetForISSP()
// Implements the intialization vectors for the device.
// The first time fDetectHiLoTransition is called the Clk pin is highZ because
// the clock is not needed during acquire.
// Returns:
//     0 if successful
//     INIT_ERROR if timed out on handshake to the device.
 ============================================================================*/
signed char fPowerCycleInitializeTargetForISSP(void)
{
	unsigned char n;

	SetSDATALow();
	SCLKLow();
	RemoveTargetVDD();
	mdelay(500);
	SetSCLKHiZ();
	SetSDATAHiZ();
	/* Set all pins to highZ to avoid back powering the PSoC through the GPIO
	// protection diodes.
	*/

	/* Turn on power to the target device before other signals */
	SetTargetVDDStrong();
	ApplyTargetVDD();
	/* wait 1msec for the power to stabilize */

	for (n = 0; n < 10; n++)
		udelay(DELAY100us);

	/* Set SCLK to high Z so there is no clock and wait for a high to low
	// transition on SDAT. SCLK is not needed this time.
	*/
	SetSCLKHiZ();
	mdelay(10);

	/*
	//fIsError = fDetectHiLoTransition();
	//if (fIsError ) {
	//printk("wly: fDetectHiLoTransition 11111    failed!\n");
	//return(INIT_ERROR);
	//}
	*/

	/* Configure the pins for initialization */
	SetSDATAHiZ();
	SetSCLKStrong();
	SCLKLow();		/* DO NOT SET A BREAKPOINT HERE AND EXPECT SILICON ID TO PASS! */

	/* !!! NOTE:
	//  The timing spec that requires that the first Init-Vector happen within
	//  1 msec after the reset/power up. For this reason, it is not advisable
	//  to separate the above RESET_MODE or POWER_CYCLE_MODE code from the
	//  Init-Vector instructions below. Doing so could introduce excess delay
	//  and cause the target device to exit ISSP Mode.
	*/

	SendVector(id_setup_1, num_bits_id_setup_1);
	fIsError = fDetectHiLoTransition();
	if (fIsError) {
		pr_info("wly: fDetectHiLoTransition 222222  failed!\n");
		return INIT_ERROR;
	}

	SendVector(wait_and_poll_end, num_bits_wait_and_poll_end);

	/* NOTE: DO NOT not wait for HiLo on SDATA after vector Init-3
	//       it does not occur (per spec).
	 */
	return PASS;
}