diff options
-rw-r--r-- | lib/libusb/Makefile | 2 | ||||
-rw-r--r-- | lib/libusb/usb-ehci.c | 86 | ||||
-rw-r--r-- | lib/libusb/usb-ehci.h | 49 | ||||
-rw-r--r-- | lib/libusb/usb.code | 9 | ||||
-rw-r--r-- | lib/libusb/usb.h | 4 | ||||
-rw-r--r-- | lib/libusb/usb.in | 1 | ||||
-rw-r--r-- | slof/fs/usb/usb-static.fs | 4 |
7 files changed, 154 insertions, 1 deletions
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile index 25c8002..3153e6b 100644 --- a/lib/libusb/Makefile +++ b/lib/libusb/Makefile @@ -22,7 +22,7 @@ TARGET = ../libusb.a all: $(TARGET) -SRCS = usb-core.c usb-ohci.c +SRCS = usb-core.c usb-ohci.c usb-ehci.c OBJS = $(SRCS:%.c=%.o) diff --git a/lib/libusb/usb-ehci.c b/lib/libusb/usb-ehci.c new file mode 100644 index 0000000..c1aeed5 --- /dev/null +++ b/lib/libusb/usb-ehci.c @@ -0,0 +1,86 @@ +/***************************************************************************** + * Copyright (c) 2013 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ + +#include "usb.h" +#include "usb-core.h" +#include "usb-ehci.h" +#include "tools.h" + +struct ehci_controller ehci_cntl; +#undef EHCI_DEBUG +//#define EHCI_DEBUG +#ifdef EHCI_DEBUG +#define dprintf(_x ...) printf(_x) +#else +#define dprintf(_x ...) +#endif + +static void dump_ehci_regs(void) +{ + struct ehci_cap_regs *cap_regs; + struct ehci_op_regs *op_regs; + + cap_regs = ehci_cntl.cap_regs; + op_regs = ehci_cntl.op_regs; + + dprintf("\n - CAPLENGTH %02X", read_reg8(&cap_regs->caplength)); + dprintf("\n - HCIVERSION %04X", read_reg16(&cap_regs->hciversion)); + dprintf("\n - HCSPARAMS %08X", read_reg32(&cap_regs->hcsparams)); + dprintf("\n - HCCPARAMS %08X", read_reg32(&cap_regs->hccparams)); + dprintf("\n - HCSP_PORTROUTE %016llX", read_reg64(&cap_regs->portroute)); + dprintf("\n"); + + dprintf("\n - USBCMD %08X", read_reg32(&op_regs->usbcmd)); + dprintf("\n - USBSTS %08X", read_reg32(&op_regs->usbsts)); + dprintf("\n - USBINTR %08X", read_reg32(&op_regs->usbintr)); + dprintf("\n - FRINDEX %08X", read_reg32(&op_regs->frindex)); + dprintf("\n - CTRLDSSEGMENT %08X", read_reg32(&op_regs->ctrldssegment)); + dprintf("\n - PERIODICLISTBASE %08X", read_reg32(&op_regs->periodiclistbase)); + dprintf("\n - ASYNCLISTADDR %08X", read_reg32(&op_regs->asynclistaddr)); + dprintf("\n - CONFIGFLAG %08X", read_reg32(&op_regs->configflag)); + dprintf("\n - PORTSC %08X", read_reg32(&op_regs->portsc[0])); + dprintf("\n"); +} + +static void ehci_init(struct usb_hcd_dev *hcidev) +{ + printf(" EHCI: Initializing\n"); + dprintf("%s: device base address %p\n", __func__, hcidev->base); + ehci_cntl.cap_regs = (struct ehci_cap_regs *)(hcidev->base); + ehci_cntl.op_regs = (struct ehci_op_regs *)(hcidev->base + + read_reg8(&ehci_cntl.cap_regs->caplength)); + dump_ehci_regs(); +} + +static void ehci_detect(void) +{ + +} + +static void ehci_disconnect(void) +{ + +} + +struct usb_hcd_ops ehci_ops = { + .name = "ehci-hcd", + .init = ehci_init, + .detect = ehci_detect, + .disconnect = ehci_disconnect, + .usb_type = USB_EHCI, + .next = NULL, +}; + +void usb_ehci_register(void) +{ + usb_hcd_register(&ehci_ops); +} diff --git a/lib/libusb/usb-ehci.h b/lib/libusb/usb-ehci.h new file mode 100644 index 0000000..1f95388 --- /dev/null +++ b/lib/libusb/usb-ehci.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * Copyright (c) 2007, 2012, 2013 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ +/* + * Definitions for EHCI Controller + * + */ + +#ifndef USB_EHCI_H +#define USB_EHCI_H + +#include <stdint.h> + +struct ehci_cap_regs { + uint8_t caplength; + uint8_t reserved; + uint16_t hciversion; + uint32_t hcsparams; + uint32_t hccparams; + uint64_t portroute; +} __attribute__ ((packed)); + +struct ehci_op_regs { + uint32_t usbcmd; + uint32_t usbsts; + uint32_t usbintr; + uint32_t frindex; + uint32_t ctrldssegment; + uint32_t periodiclistbase; + uint32_t asynclistaddr; + uint32_t reserved[9]; + uint32_t configflag; + uint32_t portsc[0]; +} __attribute__ ((packed)); + +struct ehci_controller { + struct ehci_cap_regs *cap_regs; + struct ehci_op_regs *op_regs; +}; + +#endif /* USB_EHCI_H */ diff --git a/lib/libusb/usb.code b/lib/libusb/usb.code index b906aea..44339af 100644 --- a/lib/libusb/usb.code +++ b/lib/libusb/usb.code @@ -26,6 +26,15 @@ PRIM(USB_X2d_OHCI_X2d_REGISTER) MIRP /************************************************/ +/* Register with the usb-core */ +/* SLOF: USB-EHCI-REGISTER ( -- ) */ +/* LIBNEWUSB: usb_ehci_register(void) */ +/************************************************/ +PRIM(USB_X2d_EHCI_X2d_REGISTER) + usb_ehci_register(); +MIRP + +/************************************************/ /* Initialize hcidev with the usb-core */ /* SLOF: USB-HCD-INIT ( hcidev -- ) */ /* LIBNEWUSB: usb_hcd_init(hcidev) */ diff --git a/lib/libusb/usb.h b/lib/libusb/usb.h index 8acc9b8..c5ecf87 100644 --- a/lib/libusb/usb.h +++ b/lib/libusb/usb.h @@ -22,6 +22,10 @@ /*******************************************/ extern void usb_ohci_register(void); /*******************************************/ +/* SLOF: USB-EHCI-REGISTER */ +/*******************************************/ +extern void usb_ehci_register(void); +/*******************************************/ /* SLOF: USB-HCD-INIT */ /*******************************************/ extern void usb_hcd_init(void *hcidev); diff --git a/lib/libusb/usb.in b/lib/libusb/usb.in index 4d6d163..0efc9c2 100644 --- a/lib/libusb/usb.in +++ b/lib/libusb/usb.in @@ -14,4 +14,5 @@ */ cod(USB-OHCI-REGISTER) +cod(USB-EHCI-REGISTER) cod(USB-HCD-INIT) diff --git a/slof/fs/usb/usb-static.fs b/slof/fs/usb/usb-static.fs index 508c207..73a7176 100644 --- a/slof/fs/usb/usb-static.fs +++ b/slof/fs/usb/usb-static.fs @@ -57,6 +57,10 @@ THEN LOOP + ehci-alias-num 1 >= IF + USB-EHCI-REGISTER + THEN + ehci-alias-num 0 ?DO " ehci" i $cathex find-device " get-hci-dev" get-node find-method |