Ejemplo n.º 1
0
//---------------------------------------------------------------------------
// Function:    get_handshake
//
// Parameters:  struct ft1000_device  - device structure
//              u16 expected_value - the handshake value expected
//
// Returns:     handshakevalue - success
//              HANDSHAKE_TIMEOUT_VALUE - failure
//
// Description: This function gets the handshake and compare with the expected value
//
// Notes:
//
//---------------------------------------------------------------------------
static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value)
{
	u16 handshake;
	int loopcnt;
	u32 status = 0;
	struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);

	loopcnt = 0;

	while (loopcnt < 100) {
		/* Need to clear downloader doorbell if Hartley ASIC */
		status = ft1000_write_register(ft1000dev,  FT1000_DB_DNLD_RX,
						FT1000_REG_DOORBELL);
		if (pft1000info->fcodeldr) {
			DEBUG(" get_handshake: fcodeldr is %d\n",
				pft1000info->fcodeldr);
			pft1000info->fcodeldr = 0;
			status = check_usb_db(ft1000dev);
			if (status != STATUS_SUCCESS) {
				DEBUG("get_handshake: check_usb_db failed\n");
				status = STATUS_FAILURE;
				break;
			}
			status = ft1000_write_register(ft1000dev,
					FT1000_DB_DNLD_RX,
					FT1000_REG_DOORBELL);
		}

		status = ft1000_read_dpram16(ft1000dev,
				DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1);
		handshake = ntohs(handshake);

		if (status)
			return HANDSHAKE_TIMEOUT_VALUE;

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

	return HANDSHAKE_TIMEOUT_VALUE;
}
Ejemplo n.º 2
0
/* gets the handshake and compares it with the expected value */
static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
{
	u16 handshake;
	int loopcnt;
	int status = 0;

	loopcnt = 0;

	while (loopcnt < 100) {
		/* Need to clear downloader doorbell if Hartley ASIC */
		status = ft1000_write_register(ft1000dev,  FT1000_DB_DNLD_RX,
					       FT1000_REG_DOORBELL);
		if (ft1000dev->fcodeldr) {
			pr_debug("fcodeldr is %d\n", ft1000dev->fcodeldr);
			ft1000dev->fcodeldr = 0;
			status = check_usb_db(ft1000dev);
			if (status != 0) {
				pr_debug("check_usb_db failed\n");
				break;
			}
			status = ft1000_write_register(ft1000dev,
						       FT1000_DB_DNLD_RX,
						       FT1000_REG_DOORBELL);
		}

		status = ft1000_read_dpram16(ft1000dev,
					     DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1);
		handshake = ntohs(handshake);

		if (status)
			return HANDSHAKE_TIMEOUT_VALUE;

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

	return HANDSHAKE_TIMEOUT_VALUE;
}