コード例 #1
0
ファイル: flexcop-usb.c プロジェクト: CSCLOG/beaglebone
/*
 * DKT 020228
 * - forget about this VENDOR_BUFFER_SIZE, read and write register
 *   deal with DWORD or 4 bytes, that should be should from now on
 * - from now on, we don't support anything older than firm 1.00
 *   I eliminated the write register as a 2 trip of writing hi word and lo word
 *   and force this to write only 4 bytes at a time.
 *   NOTE: this should work with all the firmware from 1.00 and newer
 */
static int flexcop_usb_readwrite_dw(struct flexcop_device *fc, u16 wRegOffsPCI, u32 *val, u8 read)
{
	struct flexcop_usb *fc_usb = fc->bus_specific;
	u8 request = read ? B2C2_USB_READ_REG : B2C2_USB_WRITE_REG;
	u8 request_type = (read ? USB_DIR_IN : USB_DIR_OUT) | USB_TYPE_VENDOR;
	u8 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) |
		(read ? 0x80 : 0);

	int len = usb_control_msg(fc_usb->udev,
			read ? B2C2_USB_CTRL_PIPE_IN : B2C2_USB_CTRL_PIPE_OUT,
			request,
			request_type, /* 0xc0 read or 0x40 write */
			wAddress,
			0,
			val,
			sizeof(u32),
			B2C2_WAIT_FOR_OPERATION_RDW * HZ);

	if (len != sizeof(u32)) {
		err("error while %s dword from %d (%d).", read ? "reading" :
				"writing", wAddress, wRegOffsPCI);
		return -EIO;
	}
	return 0;
}
コード例 #2
0
/*
 * DKT 020228 - from now on, we don't support anything older than firm 1.00
 * I eliminated the write register as a 2 trip of writing hi word and lo word
 * and force this to write only 4 bytes at a time.
 * NOTE: this should work with all the firmware from 1.00 and newer
 */
static int b2c2_usb_write_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI, u32 val)
{
	u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI);
	int len = usb_control_msg(b2c2->udev,
			B2C2_USB_CTRL_PIPE_OUT,
			B2C2_USB_WRITE_REG,
			RTYPE_WRITE_DW_1,
			wAddress,
			0,
			&val,
			sizeof(u32),
			B2C2_WAIT_FOR_OPERATION_RDW * HZ);

	if (len != sizeof(u32)) {
		err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
		return -EIO;
	} else
		return 0;
}
コード例 #3
0
/*
 * DKT 020228 - forget about this VENDOR_BUFFER_SIZE, read and write register
 * deal with DWORD or 4 bytes, that should be should from now on
 */
static u32 b2c2_usb_read_dw(struct usb_b2c2_usb *b2c2, u16 wRegOffsPCI)
{
	u32 val;
	u16 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) | 0x0080;
	int len = usb_control_msg(b2c2->udev,
			B2C2_USB_CTRL_PIPE_IN,
			B2C2_USB_READ_REG,
			RTYPE_READ_DW,
			wAddress,
			0,
			&val,
			sizeof(u32),
			B2C2_WAIT_FOR_OPERATION_RDW * HZ);

	if (len != sizeof(u32)) {
		err("error while reading dword from %d (%d).",wAddress,wRegOffsPCI);
		return -EIO;
	} else
		return val;
}