Ejemplo n.º 1
0
bool nxRawInputDevice::Enumerate(std::vector<nxRawInputDevice>&vcRawDevices)
{
    nxRawInputDevice objDevice;
    UINT uNumDev;
    vcRawDevices.clear();
    try
    {
        if (GetRawInputDeviceList(NULL,&uNumDev,sizeof(RAWINPUTDEVICELIST)) != 0)
            nxThrow("Error retrieving number of raw input devices.");
        std::vector<RAWINPUTDEVICELIST> rdl(uNumDev);
        if (uNumDev && (GetRawInputDeviceList(&rdl[0],&uNumDev,sizeof(RAWINPUTDEVICELIST)) == (UINT)-1))
            nxThrow("Error retrieving list of raw input devices.");

        for (std::vector<RAWINPUTDEVICELIST>::iterator it=rdl.begin();it!=rdl.end();++it)
        {

            objDevice.hDevice = it->hDevice;
            objDevice.dwType = it->dwType;


            if (objDevice.GetInformation())
				vcRawDevices.push_back(objDevice);

            objDevice.Clear();
        }

    } catch (const std::exception&e)
    {
        nxLog << e.what() << std::endl;
        return false;
    }
    return true;

}
Ejemplo n.º 2
0
/*
 * Implement Orion USB controller specification guidelines
 */
static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
{
	/* The below GLs are according to the Orion Errata document */
	/*
	 * Clear interrupt cause and mask
	 */
	wrl(USB_CAUSE, 0);
	wrl(USB_MASK, 0);

	/*
	 * Reset controller
	 */
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);

	/*
	 * GL# USB-10: Set IPG for non start of frame packets
	 * Bits[14:8]=0xc
	 */
	wrl(USB_IPG, (rdl(USB_IPG) & ~0x7f00) | 0xc00);

	/*
	 * GL# USB-9: USB 2.0 Power Control
	 * BG_VSEL[7:6]=0x1
	 */
	wrl(USB_PHY_PWR_CTRL, (rdl(USB_PHY_PWR_CTRL) & ~0xc0)| 0x40);

	/*
	 * GL# USB-1: USB PHY Tx Control - force calibration to '8'
	 * TXDATA_BLOCK_EN[21]=0x1, EXT_RCAL_EN[13]=0x1, IMP_CAL[6:3]=0x8
	 */
	wrl(USB_PHY_TX_CTRL, (rdl(USB_PHY_TX_CTRL) & ~0x78) | 0x202040);

	/*
	 * GL# USB-3 GL# USB-9: USB PHY Rx Control
	 * RXDATA_BLOCK_LENGHT[31:30]=0x3, EDGE_DET_SEL[27:26]=0,
	 * CDR_FASTLOCK_EN[21]=0, DISCON_THRESHOLD[9:8]=0, SQ_THRESH[7:4]=0x1
	 */
	wrl(USB_PHY_RX_CTRL, (rdl(USB_PHY_RX_CTRL) & ~0xc2003f0) | 0xc0000010);

	/*
	 * GL# USB-3 GL# USB-9: USB PHY IVREF Control
	 * PLLVDD12[1:0]=0x2, RXVDD[5:4]=0x3, Reserved[19]=0
	 */
	wrl(USB_PHY_IVREF_CTRL, (rdl(USB_PHY_IVREF_CTRL) & ~0x80003 ) | 0x32);

	/*
	 * GL# USB-3 GL# USB-9: USB PHY Test Group Control
	 * REG_FIFO_SQ_RST[15]=0
	 */
	wrl(USB_PHY_TST_GRP_CTRL, rdl(USB_PHY_TST_GRP_CTRL) & ~0x8000);

	/*
	 * Stop and reset controller
	 */
	wrl(USB_CMD, rdl(USB_CMD) & ~0x1);
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);

	/*
	 * GL# USB-5 Streaming disable REG_USB_MODE[4]=1
	 * TBD: This need to be done after each reset!
	 * GL# USB-4 Setup USB Host mode
	 */
	wrl(USB_MODE, 0x13);
}
Ejemplo n.º 3
0
static void orion_usb_phy_v2_setup(struct usb_hcd *hcd)
{
	u32 reg;

	/* The below GLs are according to the Orion Errata document */
	/*
	 * Clear interrupt cause and mask
	 */
	wrl(USB_CAUSE, 0);
	wrl(USB_MASK, 0);

	/*
	 * Reset controller
	 */
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);


	/* Clear bits 30 and 31.
         */
	reg = rdl(USB_IPG);
	reg &= ~(0x3 << 30);
	/* Change bits[14:8] - IPG for non Start of Frame Packets
	 * from 0x9(default) to 0xD
	 */
	reg &= ~(0x7f << 8);
	reg |= 0xd << 8;
	wrl(USB_IPG, reg);

	/* VCO recalibrate */
	wrl(USB_PHY_PLL_CTRL, rdl(USB_PHY_PLL_CTRL) | (1 << 21));
	udelay(100);
	wrl(USB_PHY_PLL_CTRL, rdl(USB_PHY_PLL_CTRL) & ~(1 << 21));
	
	reg = rdl(USB_PHY_TX_CTRL);
	reg |= 1 << 11; /* LOWVDD_EN */
	reg |= 1 << 12; /* REG_RCAL_START */
	/* bits[16:14]     (IMPCAL_VTH[2:0] = 101) */
	reg &= ~(0x7 << 14);
	reg |= (0x5 << 14);
	reg &= ~(1 << 21); /* TX_BLOCK_EN */
	reg &= ~(1 << 31); /* HS_STRESS_CTRL */
	wrl(USB_PHY_TX_CTRL, reg);
	udelay(100);
	reg = rdl(USB_PHY_TX_CTRL);
	reg &= ~(1 << 12); /* REG_RCAL_START */
	wrl(USB_PHY_TX_CTRL, reg);

	reg = rdl(USB_PHY_RX_CTRL);
	reg &= ~(3 << 2); /* LPL_COEF */
	reg |= 1 << 2;

	reg &= ~(0xf << 4);
	reg |= 0xc << 4; /* SQ_THRESH */ 
	reg &= ~(3 << 15); /* REG_SQ_LENGTH */
	reg |= 1 << 15;
	reg &= ~(1 << 21); /* CDR_FASTLOCK_EN */
	reg &= ~(3 << 26); /* EDGE_DET */
	wrl(USB_PHY_RX_CTRL, reg);


	/*
	 * USB PHY IVREF Control
	 * TXVDD12[9:8]=0x3
	 */
	wrl(USB_PHY_IVREF_CTRL, rdl(USB_PHY_IVREF_CTRL) | (0x3 << 8));


	/*
	 * GL# USB-3 GL# USB-9: USB PHY Test Group Control
	 * REG_FIFO_SQ_RST[15]=0
	 */
	wrl(USB_PHY_TST_GRP_CTRL, rdl(USB_PHY_TST_GRP_CTRL) & ~0x8000);

	/*
	 * Stop and reset controller
	 */
	wrl(USB_CMD, rdl(USB_CMD) & ~0x1);
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);

	/*
	 * GL# USB-4 Setup USB Host mode
	 */
	wrl(USB_MODE, 0x3);
}
Ejemplo n.º 4
0
static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
{
	
	
	wrl(USB_CAUSE, 0);
	wrl(USB_MASK, 0);

	
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);

	
	wrl(USB_IPG, (rdl(USB_IPG) & ~0x7f00) | 0xc00);

	
	wrl(USB_PHY_PWR_CTRL, (rdl(USB_PHY_PWR_CTRL) & ~0xc0)| 0x40);

	
	wrl(USB_PHY_TX_CTRL, (rdl(USB_PHY_TX_CTRL) & ~0x78) | 0x202040);

	
	wrl(USB_PHY_RX_CTRL, (rdl(USB_PHY_RX_CTRL) & ~0xc2003f0) | 0xc0000010);

	
	wrl(USB_PHY_IVREF_CTRL, (rdl(USB_PHY_IVREF_CTRL) & ~0x80003 ) | 0x32);

	
	wrl(USB_PHY_TST_GRP_CTRL, rdl(USB_PHY_TST_GRP_CTRL) & ~0x8000);

	
	wrl(USB_CMD, rdl(USB_CMD) & ~0x1);
	wrl(USB_CMD, rdl(USB_CMD) | 0x2);
	while (rdl(USB_CMD) & 0x2);

	
	wrl(USB_MODE, 0x13);
}