socsvn commit: r255271 - soc2013/bguan/head/sys/dev/xen/usbfront
bguan at FreeBSD.org
bguan at FreeBSD.org
Sun Jul 28 17:24:37 UTC 2013
Author: bguan
Date: Sun Jul 28 17:24:37 2013
New Revision: 255271
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255271
Log:
more initalization for usbfront driver
Modified:
soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c
Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c
==============================================================================
--- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 28 17:24:24 2013 (r255270)
+++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Sun Jul 28 17:24:37 2013 (r255271)
@@ -51,7 +51,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
-//#define USB_DEBUG_VAR xhcidebug
+#define USB_DEBUG_VAR xenhcidebug
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
@@ -68,8 +68,49 @@
#include <dev/xen/usbfront/xenhci.h>
+#define XENHCI_BUS2SC(bus) \
+ ((struct xenhci_softc *)(((uint8_t *)(bus)) - \
+ ((uint8_t *)&(((struct xenhci_softc *)0)->sc_bus))))
+
+#ifdef USB_DEBUG
+static int xenhcidebug;
+static int xenhciroute;
+static int xenhcipolling;
+
+static SYSCTL_NODE(_hw_usb, OID_AUTO, xenhci, CTLFLAG_RW, 0, "USB XENHCI");
+SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN,
+ &xenhcidebug, 0, "Debug level");
+TUNABLE_INT("hw.usb.xenhci.debug", &xenhcidebug);
+SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, xenhci_port_route, CTLFLAG_RW | CTLFLAG_TUN,
+ &xenhciroute, 0, "Routing bitmap for switching EHCI ports to XENHCI controller");
+TUNABLE_INT("hw.usb.xenhci.xenhci_port_route", &xenhciroute);
+SYSCTL_INT(_hw_usb_xenhci, OID_AUTO, use_polling, CTLFLAG_RW | CTLFLAG_TUN,
+ &xenhcipolling, 0, "Set to enable software interrupt polling for XENHCI controller");
+TUNABLE_INT("hw.usb.xenhci.use_polling", &xenhcipolling);
+#endif
+
extern struct usb_bus_methods xenhci_bus_methods;
+
+/*
+static void
+xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
+{
+ struct xhci_softc *sc = XENHCI_BUS2SC(bus);
+ uint8_t i;
+
+ cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg,
+ sizeof(struct xhci_hw_root), XENHCI_PAGE_SIZE);
+
+ cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg,
+ sizeof(struct xhci_dev_ctx_addr), XENHCI_PAGE_SIZE);
+
+ for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+ cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i],
+ XENHCI_PAGE_SIZE, XENHCI_PAGE_SIZE);
+ }
+}*/
+
usb_error_t
xenhci_init(struct xenhci_softc *sc, device_t dev)
{
@@ -83,6 +124,14 @@
sc->sc_bus.devices = sc->sc_devices;
sc->sc_bus.devices_max = XENHCI_MAX_DEVICES;
+ /* get all DMA memory */
+ //if (usb_bus_mem_alloc_all(&sc->sc_bus,
+ // USB_GET_DMA_TAG(dev), &xenhci_iterate_hw_softc)) {
+ if (usb_bus_mem_alloc_all(&sc->sc_bus,
+ USB_GET_DMA_TAG(dev), NULL)) {
+ return (ENOMEM);
+ }
+
return (0);
}
@@ -105,9 +154,6 @@
xenhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address)
{
printf("[gbtest-pv]xenhci.c: xenhci_set_address()\n");
- //usb_error_t err;
-
- //return (err);
//TODO
return (0);
}
@@ -132,42 +178,67 @@
static void
xenhci_xfer_setup(struct usb_setup_params *parm)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_xfer_setup()\n");
//TODO
}
static void
xenhci_xfer_unsetup(struct usb_xfer *xfer)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_xfer_unsetup()\n");
return;
}
static void
xenhci_start_dma_delay(struct usb_xfer *xfer)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_start_dma_delay()\n");
//TODO
}
+
+//TODO ???
static void
xenhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc,
struct usb_endpoint *ep)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_ep_init()\n");
+
+ //struct xhci_endpoint_ext *pepext;
+
+ DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n",
+ ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode);
+
+ printf("[gb-test]endpoint=%p, addr=%d, endpt=%d, mode=%d\n",
+ ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode);
+ if (udev->parent_hub == NULL) {
+ /* root HUB has special endpoint handling */
+ printf("[gb-test]xenhci.c: xenhci_ep_init():udev->parent_hub == NULL\n");
+ return;
+ }
+
+ //ep->methods = &xhci_device_generic_methods;
+
+ //pepext = xhci_get_endpoint_ext(udev, edesc);
+
+ //USB_BUS_LOCK(udev->bus);
+ //pepext->trb_halted = 1;
+ //pepext->trb_running = 0;
+ //USB_BUS_UNLOCK(udev->bus);
+
//TODO
}
static void
xenhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_ep_uninit()\n");
}
static void
xenhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep)
{
- printf("[gbtest-pv]xenhci.c: ()\n");
+ printf("[gbtest-pv]xenhci.c: xenhci_ep_clear_stal()\n");
//TODO
}
@@ -179,7 +250,7 @@
//uint8_t temp;
//return (err);
- //TODO
+ //TODO or not??
return (0);
}
@@ -211,18 +282,59 @@
//TODO
}
+//DONE!
static void
xenhci_set_hw_power(struct usb_bus *bus)
{
printf("[gbtest-pv]xenhci.c: xenhci_set_hw_power()\n");
//DPRINTF("\n");
- //TODO??
}
+//TODO or not ??
static void
xenhci_device_state_change(struct usb_device *udev)
{
+ //struct xhci_softc *sc = XHCI_BUS2SC(udev->bus);
+ //struct usb_page_search buf_inp;
+ //usb_error_t err;
+ //uint8_t index;
+
printf("[gbtest-pv]xenhci.c: xenhci_device_state_change()\n");
+
+ /* check for root HUB */
+ if (udev->parent_hub == NULL) {
+ printf("[gb-test]xenhci.c: xenhci_device_state_change(): udev->parent_hub == NULL\n");
+ return;
+ }
+
+ //index = udev->controller_slot_id;
+
+ //DPRINTF("\n");
+
+ if (usb_get_device_state(udev) == USB_STATE_CONFIGURED) {
+ printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n");
+ }
+
+ //XHCI_CMD_LOCK(sc);
+
+ switch (usb_get_device_state(udev)) {
+ case USB_STATE_POWERED:
+ printf("[gb-test]state(udev) == USB_STATE_POWERED\n");
+ break;
+
+ case USB_STATE_ADDRESSED:
+ printf("[gb-test]state(udev) == USB_STATE_ADDRESSED\n");
+ break;
+
+ case USB_STATE_CONFIGURED:
+ printf("[gb-test]state(udev) == USB_STATE_CONFIGURED\n");
+ break;
+
+ default:
+ printf("[gb-test]state(udev) == other!!\n");
+ break;
+ }
+ //XHCI_CMD_UNLOCK(sc);
//TODO
}
More information about the svn-soc-all
mailing list