Re: Texas Instruments XHCI

2010-12-11 Thread Hans Petter Selasky
Hi,

On Saturday 11 December 2010 02:08:37 Dwight Schauer wrote:
 I'm with Texas Instruments and I'm trying to get our USB3 host
 controller working with FreeBSD 8.2-BETA1
 

  
 However, nothing happens when I attach a mass storage device to the
 Texas Instruments USB3 host controller.
 
 Any advice is welcome.
 

The mode your XHCI controller is using is currently not supported.

Please try the attached patch and report back.

--HPS
 Patch xhci_context.patch level 1
Source: [No source]
Target: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f:/head/sys/dev/usb/controller:215649 [mirrored] [updated]
(svn+ssh://hsela...@svn.freebsd.org/base)
Log:
- Add support for 64-byte contexts to XHCI driver.
- Remove some dead code.
- Fixed one instance of missing endian conversion.

MFC after:	3 days
Approved by:	thompsa (mentor)


=== xhci.c
==
--- xhci.c	(revision 215649)
+++ xhci.c	(patch xhci_context.patch level 1)
@@ -134,6 +134,10 @@
 static usb_error_t xhci_cmd_evaluate_ctx(struct xhci_softc *,
 		uint64_t, uint8_t);
 static void xhci_endpoint_doorbell(struct usb_xfer *);
+static void xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val);
+static uint32_t xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr);
+static void xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val);
+static uint64_t xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr);
 
 extern struct usb_bus_methods xhci_bus_methods;
 
@@ -148,26 +152,26 @@
 }
 
 static void
-xhci_dump_endpoint(struct xhci_endp_ctx *pep)
+xhci_dump_endpoint(struct xhci_softc *sc, struct xhci_endp_ctx *pep)
 {
 	DPRINTFN(5, pep = %p\n, pep);
-	DPRINTFN(5, dwEpCtx0=0x%08x\n, pep-dwEpCtx0);
-	DPRINTFN(5, dwEpCtx1=0x%08x\n, pep-dwEpCtx1);
-	DPRINTFN(5, qwEpCtx2=0x%016llx\n, (long long)pep-qwEpCtx2);
-	DPRINTFN(5, dwEpCtx4=0x%08x\n, pep-dwEpCtx4);
-	DPRINTFN(5, dwEpCtx5=0x%08x\n, pep-dwEpCtx5);
-	DPRINTFN(5, dwEpCtx6=0x%08x\n, pep-dwEpCtx6);
-	DPRINTFN(5, dwEpCtx7=0x%08x\n, pep-dwEpCtx7);
+	DPRINTFN(5, dwEpCtx0=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx0));
+	DPRINTFN(5, dwEpCtx1=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx1));
+	DPRINTFN(5, qwEpCtx2=0x%016llx\n, (long long)xhci_ctx_get_le64(sc, pep-qwEpCtx2));
+	DPRINTFN(5, dwEpCtx4=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx4));
+	DPRINTFN(5, dwEpCtx5=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx5));
+	DPRINTFN(5, dwEpCtx6=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx6));
+	DPRINTFN(5, dwEpCtx7=0x%08x\n, xhci_ctx_get_le32(sc, pep-dwEpCtx7));
 }
 
 static void
-xhci_dump_device(struct xhci_slot_ctx *psl)
+xhci_dump_device(struct xhci_softc *sc, struct xhci_slot_ctx *psl)
 {
 	DPRINTFN(5, psl = %p\n, psl);
-	DPRINTFN(5, dwSctx0=0x%08x\n, psl-dwSctx0);
-	DPRINTFN(5, dwSctx1=0x%08x\n, psl-dwSctx1);
-	DPRINTFN(5, dwSctx2=0x%08x\n, psl-dwSctx2);
-	DPRINTFN(5, dwSctx3=0x%08x\n, psl-dwSctx3);
+	DPRINTFN(5, dwSctx0=0x%08x\n, xhci_ctx_get_le32(sc, psl-dwSctx0));
+	DPRINTFN(5, dwSctx1=0x%08x\n, xhci_ctx_get_le32(sc, psl-dwSctx1));
+	DPRINTFN(5, dwSctx2=0x%08x\n, xhci_ctx_get_le32(sc, psl-dwSctx2));
+	DPRINTFN(5, dwSctx3=0x%08x\n, xhci_ctx_get_le32(sc, psl-dwSctx3));
 }
 #endif
 
@@ -189,6 +193,60 @@
 	}
 }
 
+static void
+xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val)
+{
+	if (sc-sc_ctx_is_64_byte) {
+		uint32_t offset;
+		/* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */
+		offset = ((uintptr_t)ptr)  (XHCI_PAGE_SIZE - 1);
+		offset = ~31U;	/* all contexts are initially 32-bytes */
+		ptr = (volatile uint32_t *)(((volatile uint8_t *)ptr) + offset);
+	}
+	*ptr = htole32(val);
+}
+
+static uint32_t
+xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr)
+{
+	if (sc-sc_ctx_is_64_byte) {
+		uint32_t offset;
+		/* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */
+		offset = ((uintptr_t)ptr)  (XHCI_PAGE_SIZE - 1);
+		offset = ~31U;	/* all contexts are initially 32-bytes */
+		ptr = (volatile uint32_t *)(((volatile uint8_t *)ptr) + offset);
+	}
+	return (le32toh(*ptr));
+}
+
+static void
+xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val)
+{
+	if (sc-sc_ctx_is_64_byte) {
+		uint32_t offset;
+		/* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */
+		offset = ((uintptr_t)ptr)  (XHCI_PAGE_SIZE - 1);
+		offset = ~31U;	/* all contexts are initially 32-bytes */
+		ptr = (volatile uint64_t *)(((volatile uint8_t *)ptr) + offset);
+	}
+	*ptr = htole64(val);
+}
+
+#ifdef USB_DEBUG
+static uint64_t
+xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr)
+{
+	if (sc-sc_ctx_is_64_byte) {
+		uint32_t offset;
+		/* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */
+		offset = ((uintptr_t)ptr)  (XHCI_PAGE_SIZE - 1);
+		offset = ~31U;	/* all contexts are initially 32-bytes */
+		ptr = (volatile uint64_t *)(((volatile uint8_t *)ptr) + offset);
+	}
+	return 

Texas Instruments XHCI

2010-12-10 Thread Dwight Schauer
I'm with Texas Instruments and I'm trying to get our USB3 host 
controller working with FreeBSD 8.2-BETA1


This is the NEC controller wiuth xhci.ko:

xhci0: XHCI (generic) USB 3.0 controller mem 0xffa0-0xffa01fff irq 
16 at device 0.0 on pci1

xhci0: [ITHREAD]
usbus5 on xhci0
usbus5: 4.8Gbps Super Speed USB v3.0

This is the TI controller:

xhci1: XHCI (generic) USB 3.0 controller mem 
0xff60-0xff60,0xff61-0xff611fff irq 16 at device 0.0 on pci5

xhci1: [ITHREAD]
ugen5.1: 0x1033 at usbus5
uhub5: 0x1033 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1 on usbus5
xhci1: Driver does not support 64-byte contexts.xhci1: XHCI 
halt/start/probe failed err=18

device_attach: xhci1 attach returned 6
uhub5: 4 ports with 4 removable, self powered

I can attach a mass storage device to the NEC USB3 host controller and 
it enumerates:


ugen5.2: Texas Instruments at usbus5
umass0: Texas Instruments TUSB9260 Firmware v1, class 0/0, rev 
2.10/1.00, addr 1 on usbus5

umass0:  SCSI over Bulk-Only; quirks = 0x
umass0:0:0:-1: Attached to scbus0
da0 at umass-sim0 bus 0 scbus0 target 0 lun 0
da0: ATA TOSHIBA MK1655GS 1J Fixed Direct Access SCSI-6 device
da0: 40.000MB/s transfers
da0: 152627MB (312581808 512 byte sectors: 255H 63S/T 19457C)

However, nothing happens when I attach a mass storage device to the 
Texas Instruments USB3 host controller.


Any advice is welcome.

Our host controller has been supported by the generic xhci_hcd driver in 
Linux for a while now, and we need FreeBSD support for our host 
controller as well.


If need be I can send a Texas Instruments USB3 host controller 
evaluation module to whoever is working on FreeBSD XHCI to help out in 
this effort.


Sincerely,
Dwight Schauer

Applications Software Engineer
Connectivity Interface Solutions
Texas Instruments Inc.
Office: 214-567-5695
Fax: 972-761-5168

Email:dscha...@ti.com


___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org