Commit 42b5db51 authored by ROOL's avatar ROOL 🤖
Browse files

Updates from NetBSD

Detail:
  ehcivar.h sync'd with NetBSD revision 1.38.
  ehci.c minor changes from NetBSD revision 1.169, being careful to keep the ETTF handling.
  ehcireg.h already at NetBSD revision 1.34 (unchanged).
  usbroothub_subr.c already at NetBSD revision 1.1 (unchanged).
  Function prototype for build_veneer() changed to match implementation in ehci.c.
Admin:
  Submission for USB bounty.

Version 0.39. Tagged as 'EHCIDriver-0_39'
parent ab1224c4
/* (0.38)
/* (0.39)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.38
#define Module_MajorVersion_CMHG 0.39
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 07 Oct 2017
#define Module_Date_CMHG 21 Oct 2017
#define Module_MajorVersion "0.38"
#define Module_Version 38
#define Module_MajorVersion "0.39"
#define Module_Version 39
#define Module_MinorVersion ""
#define Module_Date "07 Oct 2017"
#define Module_Date "21 Oct 2017"
#define Module_ApplicationDate "07-Oct-17"
#define Module_ApplicationDate "21-Oct-17"
#define Module_ComponentName "EHCIDriver"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/Controllers/EHCIDriver"
#define Module_FullVersion "0.38"
#define Module_HelpVersion "0.38 (07 Oct 2017)"
#define Module_LibraryVersionInfo "0:38"
#define Module_FullVersion "0.39"
#define Module_HelpVersion "0.39 (21 Oct 2017)"
#define Module_LibraryVersionInfo "0:39"
......@@ -16,13 +16,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
......@@ -59,7 +52,7 @@
*/
#include <sys/cdefs.h>
//__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.91 2005/02/27 00:27:51 perry Exp $");
//__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.169 2010/07/07 03:55:01 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
......@@ -344,7 +337,7 @@ static const uint8_t revbits[EHCI_MAX_POLLRATE] = {
#ifdef __riscos
static int veneers_built = 0;
void build_veneer (void* vn, void* st, size_t sz);
void build_veneer (int *vn, int *st, size_t sz);
static struct {
struct usbd_bus_methods methods;
struct {
......@@ -380,26 +373,26 @@ ehci_init(ehci_softc_t *sc)
#ifdef __riscos
if (!veneers_built)
{
build_veneer(&ehci_bus_methods_entry,
&ehci_bus_methods,
build_veneer((int *)&ehci_bus_methods_entry,
(int *)&ehci_bus_methods,
sizeof ehci_bus_methods);
build_veneer(&ehci_root_ctrl_methods_entry,
&ehci_root_ctrl_methods,
build_veneer((int *)&ehci_root_ctrl_methods_entry,
(int *)&ehci_root_ctrl_methods,
sizeof ehci_root_ctrl_methods);
build_veneer(&ehci_root_intr_methods_entry,
&ehci_root_intr_methods,
build_veneer((int *)&ehci_root_intr_methods_entry,
(int *)&ehci_root_intr_methods,
sizeof ehci_root_intr_methods);
build_veneer(&ehci_device_ctrl_methods_entry,
&ehci_device_ctrl_methods,
build_veneer((int *)&ehci_device_ctrl_methods_entry,
(int *)&ehci_device_ctrl_methods,
sizeof ehci_device_ctrl_methods);
build_veneer(&ehci_device_intr_methods_entry,
&ehci_device_intr_methods,
build_veneer((int *)&ehci_device_intr_methods_entry,
(int *)&ehci_device_intr_methods,
sizeof ehci_device_intr_methods);
build_veneer(&ehci_device_bulk_methods_entry,
&ehci_device_bulk_methods,
build_veneer((int *)&ehci_device_bulk_methods_entry,
(int *)&ehci_device_bulk_methods,
sizeof ehci_device_bulk_methods);
build_veneer(&ehci_device_isoc_methods_entry,
&ehci_device_isoc_methods,
build_veneer((int *)&ehci_device_isoc_methods_entry,
(int *)&ehci_device_isoc_methods,
sizeof ehci_device_isoc_methods);
veneers_built = 1;
}
......@@ -421,8 +414,11 @@ ehci_init(ehci_softc_t *sc)
if (ncomp != sc->sc_ncomp) {
aprint_verbose("%s: wrong number of companions (%d != %d)\n",
USBDEVNAME(sc->sc_bus.bdev), ncomp, sc->sc_ncomp);
#ifdef __riscos0
return (USBD_IOERROR);
#ifndef __riscos
#if NOHCI == 0 || NUHCI == 0
aprint_error("%s: ohci or uhci probably not configured\n",
device_xname(sc->sc_dev));
#endif
#endif
if (ncomp < sc->sc_ncomp)
sc->sc_ncomp = ncomp;
......@@ -502,7 +498,7 @@ ehci_init(ehci_softc_t *sc)
if (err)
return (err);
DPRINTF(("%s: flsize=%d\n", USBDEVNAME(sc->sc_bus.bdev),sc->sc_flsize));
sc->sc_flist = KERNADDR(&sc->sc_fldma, 0);
sc->sc_flist = KERNADDR(&sc->sc_fldma, 0);
for (i = 0; i < sc->sc_flsize; i++) {
sc->sc_flist[i] = EHCI_NULL;
......@@ -1385,11 +1381,18 @@ ehci_allocm(struct usbd_bus *bus, usb_dma_t *dma, u_int32_t size)
struct ehci_softc *sc = (struct ehci_softc *)bus;
usbd_status err;
/* The EHCI controller in the DM37x seems to have difficulty if the last packet of a bulk transfer is a short packet that crosses a page boundary. It looks like the second half of the packet doesn't get written to memory, or gets written to completely the wrong place.
This problem is easiest to reproduce using the USB ethernet on the BB-xM
As a simple workaround, force all EHCI buffers to be 512 byte aligned */
#ifdef __riscos
/* The EHCI controller in the DM37x seems to have difficulty if the
* last packet of a bulk transfer is a short packet that crosses a page
* boundary. It looks like the second half of the packet doesn't get
* written to memory, or gets written to completely the wrong place.
* This problem is easiest to reproduce using the USB ethernet on the
* BB-xM
* As a simple workaround, force all EHCI buffers to be 512 byte
* aligned */
err = usb_allocmem(&sc->sc_bus, size, 512, dma);
#ifndef __riscos
#else
err = usb_allocmem(&sc->sc_bus, size, 0, dma);
if (err == USBD_NOMEM)
err = usb_reserve_allocm(&sc->sc_dma_reserve, dma, size);
#endif
......@@ -1404,7 +1407,7 @@ Static void
ehci_freem(struct usbd_bus *bus, usb_dma_t *dma)
{
struct ehci_softc *sc = (struct ehci_softc *)bus;
(void) sc;
#ifndef __riscos
if (dma->block->flags & USB_DMA_RESERVE) {
usb_reserve_freem(&sc->sc_dma_reserve,
......@@ -2452,8 +2455,8 @@ ehci_root_ctrl_start(usbd_xfer_handle xfer)
goto ret;
}
v = EOREAD4(sc, EHCI_PORTSC(index));
DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n", v));
DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n",
v));
i = UPS_HIGH_SPEED;
if (sc->sc_flags & EHCIF_ETTF) {
/*
......@@ -2738,7 +2741,7 @@ ehci_alloc_sqh(ehci_softc_t *sc)
if (sc->sc_freeqhs == NULL) {
DPRINTFN(2, ("ehci_alloc_sqh: allocating chunk\n"));
err = usb_allocmem(&sc->sc_bus, EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
EHCI_SMALL_PAGE_SIZE, &dma);
EHCI_PAGE_SIZE, &dma);
#ifdef EHCI_DEBUG
if (err)
printf("ehci_alloc_sqh: usb_allocmem()=%d\n", err);
......@@ -2781,7 +2784,7 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
if (sc->sc_freeqtds == NULL) {
DPRINTFN(2, ("ehci_alloc_sqtd: allocating chunk\n"));
err = usb_allocmem(&sc->sc_bus, EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK,
EHCI_SMALL_PAGE_SIZE, &dma);
EHCI_PAGE_SIZE, &dma);
#ifdef EHCI_DEBUG
if (err)
printf("ehci_alloc_sqtd: usb_allocmem()=%d\n", err);
......@@ -3013,7 +3016,7 @@ ehci_alloc_itd(ehci_softc_t *sc)
if (freeitd == NULL) {
DPRINTFN(2, ("ehci_alloc_itd allocating chunk\n"));
err = usb_allocmem(&sc->sc_bus, EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
EHCI_SMALL_PAGE_SIZE, &dma);
EHCI_PAGE_SIZE, &dma);
if (err) {
DPRINTF(("ehci_alloc_itd, alloc returned %d\n", err));
......@@ -3191,7 +3194,6 @@ ehci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
#endif /* USB_USE_SOFTINTR */
#if defined (__riscos) && !defined(USB_USE_SOFTINTR)
ehci_softintr(&sc->sc_bus);
// tsleep(&sc->sc_softwake, PZERO, "ehciab", 0, 1);
#else
usb_schedsoftintr(&sc->sc_bus);
#endif
......
/* $NetBSD: ehcivar.h,v 1.17 2005/01/11 07:45:34 imp Exp $ */
/* $NetBSD: ehcivar.h,v 1.38 2011/01/18 08:29:24 matt Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
......@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
......@@ -36,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#define EHCI_SMALL_PAGE_SIZE EHCI_PAGE_SIZE
#ifdef __riscos
/* EHCI could use SyncLib for mutex, but for now, just wing it */
#define mutex_init(a,b,c)
......@@ -44,6 +36,7 @@
#define mutex_enter(a)
#define mutex_exit(a)
typedef struct { int a; } kmutex_t;
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
#endif
typedef struct ehci_soft_qtd {
......@@ -57,7 +50,7 @@ typedef struct ehci_soft_qtd {
u_int16_t len;
} ehci_soft_qtd_t;
#define EHCI_SQTD_SIZE ((sizeof (struct ehci_soft_qtd) + EHCI_QTD_ALIGN - 1) / EHCI_QTD_ALIGN * EHCI_QTD_ALIGN)
#define EHCI_SQTD_CHUNK (EHCI_SMALL_PAGE_SIZE / EHCI_SQTD_SIZE)
#define EHCI_SQTD_CHUNK (EHCI_PAGE_SIZE / EHCI_SQTD_SIZE)
typedef struct ehci_soft_qh {
ehci_qh_t qh;
......@@ -69,7 +62,7 @@ typedef struct ehci_soft_qh {
int islot;
} ehci_soft_qh_t;
#define EHCI_SQH_SIZE ((sizeof (struct ehci_soft_qh) + EHCI_QH_ALIGN - 1) / EHCI_QH_ALIGN * EHCI_QH_ALIGN)
#define EHCI_SQH_CHUNK (EHCI_SMALL_PAGE_SIZE / EHCI_SQH_SIZE)
#define EHCI_SQH_CHUNK (EHCI_PAGE_SIZE / EHCI_SQH_SIZE)
typedef struct ehci_soft_itd {
ehci_itd_t itd;
......@@ -90,7 +83,7 @@ typedef struct ehci_soft_itd {
struct timeval t; /* store free time */
} ehci_soft_itd_t;
#define EHCI_ITD_SIZE ((sizeof(struct ehci_soft_itd) + EHCI_QH_ALIGN - 1) / EHCI_ITD_ALIGN * EHCI_ITD_ALIGN)
#define EHCI_ITD_CHUNK (EHCI_SMALL_PAGE_SIZE / EHCI_ITD_SIZE)
#define EHCI_ITD_CHUNK (EHCI_PAGE_SIZE / EHCI_ITD_SIZE)
struct ehci_xfer {
struct usbd_xfer xfer;
......@@ -141,7 +134,7 @@ typedef struct ehci_softc {
u_int sc_ncomp;
u_int sc_npcomp;
struct usbd_bus *sc_comps[EHCI_COMPANION_MAX];
device_t sc_comps[EHCI_COMPANION_MAX];
usb_dma_t sc_fldma;
ehci_link_t *sc_flist;
......@@ -181,12 +174,14 @@ typedef struct ehci_softc {
struct callout sc_tmo_intrlist;
device_ptr_t sc_child; /* /dev/usb# device */
device_t sc_child; /* /dev/usb# device */
char sc_dying;
#ifdef __NetBSD__
struct usb_dma_reserve sc_dma_reserve;
#endif
void (*sc_vendor_init)(struct ehci_softc *);
int (*sc_vendor_port_status)(struct ehci_softc *, uint32_t, int);
#endif
#ifdef __riscos
int sc_irqdevno; /* IRQ device number */
#endif
......@@ -208,9 +203,13 @@ typedef struct ehci_softc {
usbd_status ehci_init(ehci_softc_t *);
int ehci_intr(void *);
int ehci_detach(ehci_softc_t *, int);
int ehci_activate(device_ptr_t, enum devact);
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
int ehci_activate(device_t, enum devact);
void ehci_childdet(device_t, device_t);
#ifdef __riscos
extern void ehci_softintr(void *);
extern bool ehci_shutdown(void *);
void ehci_softintr(void *);
bool ehci_shutdown(void *);
#else
bool ehci_suspend(device_t, const pmf_qual_t *);
bool ehci_resume(device_t, const pmf_qual_t *);
bool ehci_shutdown(device_t, int);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment