forked from len0rd/rockbox
added support for USB port test modes, which are (a) required by the spec, and (b) needed for electrical (i.e. signal quality) testing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16427 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a36dbaa2c4
commit
97d7f39680
3 changed files with 43 additions and 6 deletions
|
@ -36,5 +36,6 @@ void usb_drv_wait(int endpoint, bool send);
|
|||
bool usb_drv_powered(void);
|
||||
int usb_drv_port_speed(void);
|
||||
void usb_drv_cancel_all_transfers(void);
|
||||
void usb_drv_set_test_mode(int mode);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
#define PORTSCX_PTC_DISABLE (0x00000000)
|
||||
#define PORTSCX_PTC_JSTATE (0x00010000)
|
||||
#define PORTSCX_PTC_KSTATE (0x00020000)
|
||||
#define PORTSCX_PTC_SEQNAK (0x00030000)
|
||||
#define PORTSCX_PTC_SE0NAK (0x00030000)
|
||||
#define PORTSCX_PTC_PACKET (0x00040000)
|
||||
#define PORTSCX_PTC_FORCE_EN (0x00050000)
|
||||
#define PORTSCX_PTC_BIT_POS (16)
|
||||
|
@ -530,6 +530,29 @@ void usb_drv_reset_endpoint(int endpoint, bool send)
|
|||
while (REG_ENDPTFLUSH & mask);
|
||||
}
|
||||
|
||||
void usb_drv_set_test_mode(int mode)
|
||||
{
|
||||
switch(mode){
|
||||
case 0:
|
||||
REG_PORTSC1 &= ~PORTSCX_PORT_TEST_CTRL;
|
||||
break;
|
||||
case 1:
|
||||
REG_PORTSC1 |= PORTSCX_PTC_JSTATE;
|
||||
break;
|
||||
case 2:
|
||||
REG_PORTSC1 |= PORTSCX_PTC_KSTATE;
|
||||
break;
|
||||
case 3:
|
||||
REG_PORTSC1 |= PORTSCX_PTC_SE0NAK;
|
||||
break;
|
||||
case 4:
|
||||
REG_PORTSC1 |= PORTSCX_PTC_PACKET;
|
||||
break;
|
||||
case 5:
|
||||
REG_PORTSC1 |= PORTSCX_PTC_FORCE_EN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -571,12 +571,25 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
|
|||
|
||||
case USB_REQ_SET_FEATURE:
|
||||
logf("usb_core: SET_FEATURE");
|
||||
switch(req->bRequestType & 0x0f){
|
||||
case 0: /* Device */
|
||||
if(req->wValue == 2) { /* TEST_MODE */
|
||||
int mode=req->wIndex>>8;
|
||||
ack_control(req);
|
||||
usb_drv_set_test_mode(mode);
|
||||
}
|
||||
break;
|
||||
case 2: /* Endpoint */
|
||||
if (req->wValue)
|
||||
usb_drv_stall(req->wIndex & 0xf, true,(req->wIndex & 0x80) !=0);
|
||||
else
|
||||
usb_drv_stall(req->wIndex & 0xf, false,(req->wIndex & 0x80) !=0);
|
||||
ack_control(req);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_ADDRESS: {
|
||||
unsigned char address = req->wValue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue