From f4d3faac6b7ed8b0dd5e82401d6e3f824614a280 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 4 Sep 2006 16:27:30 +0300 Subject: [PATCH] MUSB: tusb updates 1/2 -- host side test support Preliminary high speed electrical test support for the host side. --- drivers/usb/musb/g_ep0.c | 30 ++---------------------------- drivers/usb/musb/musbdefs.h | 2 ++ drivers/usb/musb/plat_uds.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/musb/virthub.c | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 29 deletions(-) diff --git a/drivers/usb/musb/g_ep0.c b/drivers/usb/musb/g_ep0.c index 69fabd4af38..0f0142b1607 100644 --- a/drivers/usb/musb/g_ep0.c +++ b/drivers/usb/musb/g_ep0.c @@ -200,27 +200,6 @@ static void musb_g_ep0_giveback(struct musb *pThis, struct usb_request *req) musb_g_giveback(&pThis->aLocalEnd[0].ep_in, req, 0); } - -/* for high speed test mode; see USB 2.0 spec 7.1.20 */ -static const u8 musb_test_packet[53] = { - /* implicit SYNC then DATA0 to start */ - - /* JKJKJKJK x9 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* JJKKJJKK x8 */ - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - /* JJJJKKKK x8 */ - 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, - /* JJJJJJJKKKKKKK x8 */ - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* JJJJJJJK x8 */ - 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, - /* JKKKKKKK x10, JK */ - 0xfc, 0x7e, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0x7e - - /* implicit CRC16 then EOP to end */ -}; - /* * Handle all control requests with no DATA stage, including standard * requests such as: @@ -684,13 +663,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *pThis) else if (pThis->bTestMode) { DBG(1, "entering TESTMODE\n"); - if (MGC_M_TEST_PACKET == pThis->bTestModeValue) { - musb_write_fifo(&pThis->aLocalEnd[0], - sizeof(musb_test_packet), - musb_test_packet); - } - - musb_writew(regs, MGC_O_HDRC_CSR0, MGC_M_CSR0_TXPKTRDY); + if (MGC_M_TEST_PACKET == pThis->bTestModeValue) + musb_load_testpacket(pThis); musb_writeb(pBase, MGC_O_HDRC_TESTMODE, pThis->bTestModeValue); diff --git a/drivers/usb/musb/musbdefs.h b/drivers/usb/musb/musbdefs.h index 6962be49e69..f27aea7fb4b 100644 --- a/drivers/usb/musb/musbdefs.h +++ b/drivers/usb/musb/musbdefs.h @@ -525,6 +525,8 @@ extern void musb_write_fifo(struct musb_hw_ep *ep, extern void musb_read_fifo(struct musb_hw_ep *ep, u16 wCount, u8 * pDest); +extern void musb_load_testpacket(struct musb *); + extern irqreturn_t musb_interrupt(struct musb *); extern void musb_platform_enable(struct musb *musb); diff --git a/drivers/usb/musb/plat_uds.c b/drivers/usb/musb/plat_uds.c index 62c215cb11c..772a8a67641 100644 --- a/drivers/usb/musb/plat_uds.c +++ b/drivers/usb/musb/plat_uds.c @@ -318,6 +318,37 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 wCount, u8 *pDest) #endif /* normal PIO */ + +/*-------------------------------------------------------------------------*/ + +/* for high speed test mode; see USB 2.0 spec 7.1.20 */ +static const u8 musb_test_packet[53] = { + /* implicit SYNC then DATA0 to start */ + + /* JKJKJKJK x9 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* JJKKJJKK x8 */ + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + /* JJJJKKKK x8 */ + 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, + /* JJJJJJJKKKKKKK x8 */ + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + /* JJJJJJJK x8 */ + 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, + /* JKKKKKKK x10, JK */ + 0xfc, 0x7e, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0x7e + + /* implicit CRC16 then EOP to end */ +}; + +void musb_load_testpacket(struct musb *musb) +{ + MGC_SelectEnd(musb->pRegs, 0); + musb_write_fifo(musb->control_ep, + sizeof(musb_test_packet), musb_test_packet); + musb_writew(musb->pRegs, MGC_O_HDRC_CSR0, MGC_M_CSR0_TXPKTRDY); +} + /*-------------------------------------------------------------------------*/ /* diff --git a/drivers/usb/musb/virthub.c b/drivers/usb/musb/virthub.c index 94ead8a79dd..f581415f228 100644 --- a/drivers/usb/musb/virthub.c +++ b/drivers/usb/musb/virthub.c @@ -257,7 +257,7 @@ int musb_hub_control( musb->port1_status); break; case SetPortFeature: - if (wIndex != 1) + if ((wIndex & 0xff) != 1) goto error; switch (wValue) { @@ -282,6 +282,37 @@ int musb_hub_control( musb_port_suspend(musb, TRUE); break; case USB_PORT_FEAT_TEST: + wIndex >>= 8; + switch (wIndex) { + case 1: + pr_debug("TEST_J\n"); + temp = MGC_M_TEST_J; + break; + case 2: + pr_debug("TEST_K\n"); + temp = MGC_M_TEST_K; + break; + case 3: + pr_debug("TEST_SE0_NAK\n"); + temp = MGC_M_TEST_SE0_NAK; + break; + case 4: + pr_debug("TEST_PACKET\n"); + temp = MGC_M_TEST_PACKET; + musb_load_testpacket(musb); + break; + case 5: + pr_debug("TEST_FORCE_ENABLE\n"); + temp = MGC_M_TEST_FORCE_HOST + | MGC_M_TEST_FORCE_HS; + + /* FIXME and enable a session too */ + break; + default: + goto error; + } + musb_writeb(musb->pRegs, MGC_O_HDRC_TESTMODE, temp); + musb->port1_status |= USB_PORT_STAT_TEST; break; default: goto error; -- 2.41.1