On 13:40 Tue 25 Nov , Michael Trimarchi wrote: > Add ehci core support > > Signed-off-by: Michael Trimarchi <[EMAIL PROTECTED]> > > --- > common/cmd_usb.c | 3 +- > common/usb.c | 2 +- > drivers/usb/Makefile | 2 + > drivers/usb/usb_ehci.h | 120 ++++++++ > drivers/usb/usb_ehci_core.c | 635 > +++++++++++++++++++++++++++++++++++++++++++ > drivers/usb/usb_ehci_core.h | 29 ++ > include/usb.h | 15 +- > include/usb_defs.h | 10 + > 8 files changed, 808 insertions(+), 8 deletions(-) > create mode 100644 drivers/usb/usb_ehci.h > create mode 100644 drivers/usb/usb_ehci_core.c > create mode 100644 drivers/usb/usb_ehci_core.h > > diff --git a/common/cmd_usb.c b/common/cmd_usb.c > index 99e551f..532df37 100644 > --- a/common/cmd_usb.c > +++ b/common/cmd_usb.c > @@ -276,7 +276,8 @@ void usb_show_tree_graph(struct usb_device *dev,char *pre) > pre[index++]= has_child ? '|' : ' '; > pre[index]=0; > printf(" %s (%s, > %dmA)\n",usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), too long please split > - dev->slow ? "1.5MBit/s" : "12MBit/s",dev->config.MaxPower * 2); > + (dev->speed == USB_SPEED_LOW) ? "1.5MBit/s" : (dev->speed == > USB_SPEED_FULL) too long please split > + ? "12MBit/s" : "480MBit/s", dev->config.MaxPower * 2); > if (strlen(dev->mf) || > strlen(dev->prod) || > strlen(dev->serial)) > diff --git a/common/usb.c b/common/usb.c > index 7ab5df6..1518d9a 100644 > --- a/common/usb.c > +++ b/common/usb.c > @@ -1126,7 +1126,7 @@ void usb_hub_port_connect_change(struct usb_device > *dev, int port) > > /* Allocate a new device struct for it */ > usb = usb_alloc_new_device(); > - usb->slow = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0; > + usb->speed = (portstatus & USB_PORT_STAT_LOW_SPEED) ? 1 : 0; > > dev->children[port] = usb; > usb->parent = dev; > diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile > index c67a490..6a4df02 100644 > --- a/drivers/usb/Makefile > +++ b/drivers/usb/Makefile > @@ -34,6 +34,8 @@ COBJS-y += usbdcore.o > COBJS-y += usbdcore_ep0.o > COBJS-y += usbdcore_mpc8xx.o > COBJS-y += usbdcore_omap1510.o > +COBJS-$(CONFIG_USB_EHCI) += usb_ehci_core.o > +COBJS-$(CONFIG_USB_EHCI_FSL) += usb_ehci_fsl.o I've send a patch to move condition compile to Makefile please base your after this one > > COBJS := $(COBJS-y) > SRCS := $(COBJS:.o=.c) > diff --git a/drivers/usb/usb_ehci.h b/drivers/usb/usb_ehci.h > new file mode 100644 > index 0000000..9911068 > --- /dev/null > +++ b/drivers/usb/usb_ehci.h > @@ -0,0 +1,120 @@ > +/*- > + * Copyright (c) 2007-2008, Juniper Networks, Inc. > + * All rights reserved. > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License as > + * published by the Free Software Foundation version 2 of > + * the License. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, > + * MA 02111-1307 USA > + */ > + > +#ifndef USB_EHCI_H > +#define USB_EHCI_H > + > +/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */ > +#define DeviceRequest \ > + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) please a space before and after '|' and '<<' > +#define DeviceOutRequest \ > + ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) please a space before and after '|' and '<<' > + > +#define InterfaceRequest \ > + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) please a space before and after '|' and '<<' > + > +#define EndpointRequest \ > + ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) please a space before and after '|' and '<<' > +#define EndpointOutRequest \ > + ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) please a space before and after '|' and '<<' > + > +/* > + * Register Space. > + */ > +struct ehci_hccr { > + uint8_t cr_caplength; > + uint16_t cr_hciversion; > + uint32_t cr_hcsparams; > + uint32_t cr_hccparams; > + uint8_t cr_hcsp_portrt[8]; > +}; > + > +struct ehci_hcor { > + uint32_t or_usbcmd; > + uint32_t or_usbsts; > + uint32_t or_usbintr; > + uint32_t or_frindex; > + uint32_t or_ctrldssegment; > + uint32_t or_periodiclistbase; > + uint32_t or_asynclistaddr; > + uint32_t _reserved_[9]; > + uint32_t or_configflag; > + uint32_t or_portsc[2]; > + uint32_t or_systune; > +}; > + > +#define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over > current */ > +#define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect */ > +#define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect */ > +#define EHCI_PS_PTC 0x000f0000 /* RW port test control */ > +#define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */ > +#define EHCI_PS_PO 0x00002000 /* RW port owner */ > +#define EHCI_PS_PP 0x00001000 /* RW,RO port power */ > +#define EHCI_PS_LS 0x00000c00 /* RO line status */ > +#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400) > +#define EHCI_PS_PR 0x00000100 /* RW port reset */ > +#define EHCI_PS_SUSP 0x00000080 /* RW suspend */ > +#define EHCI_PS_FPR 0x00000040 /* RW force port resume */ > +#define EHCI_PS_OCC 0x00000020 /* RWC over current change */ > +#define EHCI_PS_OCA 0x00000010 /* RO over current active */ > +#define EHCI_PS_PEC 0x00000008 /* RWC port enable change */ > +#define EHCI_PS_PE 0x00000004 /* RW port enable */ > +#define EHCI_PS_CSC 0x00000002 /* RWC connect status change */ > +#define EHCI_PS_CS 0x00000001 /* RO connect status */ > +#define EHCI_PS_CLEAR (EHCI_PS_OCC|EHCI_PS_PEC|EHCI_PS_CSC) please a space before and after '|' and '<<' > + > +/* > + * Schedule Interface Space. > + * > + * IMPORTANT: Software must ensure that no interface data structure > + * reachable by the EHCI host controller spans a 4K page boundary! > + * > + * Periodic transfers (i.e. isochronous and interrupt transfers) are > + * not supported. > + */ > + > +/* Queue Element Transfer Descriptor (qTD). */ > +struct qTD { > + uint32_t qt_next; > +#define QT_NEXT_TERMINATE 1 > + uint32_t qt_altnext; > + uint32_t qt_token; > + uint32_t qt_buffer[5]; > +}; > + > +/* Queue Head (QH). */ > +struct QH { > + uint32_t qh_link; > +#define QH_LINK_TERMINATE 1 > +#define QH_LINK_TYPE_ITD 0 > +#define QH_LINK_TYPE_QH 2 > +#define QH_LINK_TYPE_SITD 4 > +#define QH_LINK_TYPE_FSTN 6 > + uint32_t qh_endpt1; > + uint32_t qh_endpt2; > + uint32_t qh_curtd; > + struct qTD qh_overlay; > +}; > + > +/* Low level intit functions */ > + > +int ehci_hcd_init(void); > +int ehci_hcd_stop(void); > +#endif /* USB_EHCI_H */ > +#include <asm/io.h> > +#include "usb_ehci.h" > + > +int rootdev; > +struct ehci_hccr *hccr; /* R/O registers, not need for volatile > */ > +volatile struct ehci_hcor *hcor; > + > +static uint16_t portreset; > +static struct QH qh_list __attribute__((aligned(32))); > + > +struct usb_device_descriptor device = { > + sizeof(struct usb_device_descriptor), /* bLength */ ^^^ whitespace please fix > + 1, /* bDescriptorType: UDESC_DEVICE */ > + 0x0002, /* bcdUSB: v2.0 */ > + 9, /* bDeviceClass: UDCLASS_HUB */ > + 0, /* bDeviceSubClass: UDSUBCLASS_HUB */ > + 1, /* bDeviceProtocol: UDPROTO_HSHUBSTT */ > + 64, /* bMaxPacketSize: 64 bytes */ > + 0x0000, /* idVendor */ > + 0x0000, /* idProduct */ > + 0x0001, /* bcdDevice */ ^^^^^^^^^ whitespace please fix > + 1, /* bDescriptorType: UDESC_DEVICE */ > + 1, /* iManufacturer */ > + 2, /* iProduct */ > + 0, /* iSerialNumber */ > + 1 /* bNumConfigurations: 1 */ > +}; > + > +struct usb_config_descriptor config = { > + sizeof(struct usb_config_descriptor), > + 2, /* bDescriptorType: UDESC_CONFIG */ > + sizeof(struct usb_config_descriptor) + > + sizeof(struct usb_interface_descriptor) + > + sizeof(struct usb_endpoint_descriptor), > + 0, > + 1, /* bNumInterface */ > + 1, /* bConfigurationValue */ > + 0, /* iConfiguration */ > + 0x40, /* bmAttributes: UC_SELF_POWER */ > + 0 /* bMaxPower */ > +}; > + > +struct usb_interface_descriptor interface = { > + sizeof(struct usb_interface_descriptor), /* bLength */ ^^^^^^^^ whitespace please fix > + 4, /* bDescriptorType: UDESC_INTERFACE */ > + 0, /* bInterfaceNumber */ > + 0, /* bAlternateSetting */ > + 1, /* bNumEndpoints */ > + 9, /* bInterfaceClass: UICLASS_HUB */ > + 0, /* bInterfaceSubClass: UISUBCLASS_HUB */ > + 0, /* bInterfaceProtocol: UIPROTO_HSHUBSTT */ > + 0 /* iInterface */ > +}; > + > +struct usb_endpoint_descriptor endpoint = { > +sizeof(struct usb_endpoint_descriptor), /* bLength */ ^^^^^^^^^ whitespace please fix > + 5, /* bDescriptorType: UDESC_ENDPOINT */ > + 0x81, /* bEndpointAddress: UE_DIR_IN | EHCI_INTR_ENDPT */ > + 3, /* bmAttributes: UE_INTERRUPT */ > + 8, 0, /* wMaxPacketSize */ > + 255 /* bInterval */ > +}; > + > +struct usb_hub_descriptor hub = { > + sizeof(struct usb_hub_descriptor), /* bDescLength */ > + 0x29, /* bDescriptorType: hub > + descriptor */ ^^^ whitespace please fix and please use this style of comment /* * */ > + 2, /* bNrPorts -- runtime modified */ > + 0, 0, /* wHubCharacteristics */ > + 0xff, /* bPwrOn2PwrGood */ > + {}, /* bHubCntrCurrent */ > + {} /* at most 7 ports! XXX */ > +}; > + > .... > #define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | > create_pipe(dev,endpoint)) > #define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | > create_pipe(dev,endpoint) | USB_DIR_IN) > @@ -333,7 +335,8 @@ int usb_set_interface(struct usb_device *dev, int > interface, int alternate); > #define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff) > #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) > #define usb_pipedata(pipe) (((pipe) >> 19) & 1) > -#define usb_pipeslow(pipe) (((pipe) >> 26) & 1) > +#define usb_pipespeed(pipe) (((pipe) >> 26) & 3) > +#define usb_pipeslow(pipe) (usb_pipespeed(pipe) == USB_SPEED_LOW) > #define usb_pipetype(pipe) (((pipe) >> 30) & 3) > #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) > #define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) > diff --git a/include/usb_defs.h b/include/usb_defs.h > index 353019f..8032e57 100644 > --- a/include/usb_defs.h > +++ b/include/usb_defs.h > @@ -80,6 +80,12 @@ > #define USB_DIR_OUT 0 whitespace please fix > #define USB_DIR_IN 0x80 whitespace please fix > > +/* USB device speeds */ > +#define USB_SPEED_FULL 0x0 /* 12Mbps */ > +#define USB_SPEED_LOW 0x1 /* 1.5Mbps */ > +#define USB_SPEED_HIGH 0x2 /* 480Mbps */ > +#define USB_SPEED_RESERVED 0x3 > + > /* Descriptor types */ > #define USB_DT_DEVICE 0x01 ^^^^^^^^ whitespace please fix > #define USB_DT_CONFIG 0x02 ^^^^^^^^ whitespace please fix > @@ -202,6 +208,7 @@ > #define USB_PORT_FEAT_RESET 4 ^^^^^^^^^^ whitespace please fix > #define USB_PORT_FEAT_POWER 8 ^^^^^^^^^^ whitespace please fix > #define USB_PORT_FEAT_LOWSPEED 9 ^^^^^^^ whitespace please fix > +#define USB_PORT_FEAT_HIGHSPEED 10 ^^^^^^ whitespace please fix > #define USB_PORT_FEAT_C_CONNECTION 16 ^^^ whitespace please fix > #define USB_PORT_FEAT_C_ENABLE 17 ^^^^^^^ whitespace please fix > #define USB_PORT_FEAT_C_SUSPEND 18 ^^^^^^ whitespace please fix > @@ -216,6 +223,9 @@ whitespace please fix > #define USB_PORT_STAT_RESET 0x0010 ^^^^^^^^^ whitespace please fix > #define USB_PORT_STAT_POWER 0x0100 ^^^^^^^^^ whitespace please fix > #define USB_PORT_STAT_LOW_SPEED 0x0200 ^^^^^ whitespace please fix > +#define USB_PORT_STAT_HIGH_SPEED 0x0400 /* support for EHCI */ ^^^^ whitespace please fix > +#define USB_PORT_STAT_SPEED \ > + (USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED) > > /* wPortChange bits */ > #define USB_PORT_STAT_C_CONNECTION 0x0001 ^^^^^^^^ whitespace please fix
for the non modified line with a whiteplease it will be nice to send an other patch Best Regards, J. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot