From 75d31887232d41404908304d74bf1d71bef1d726 Mon Sep 17 00:00:00 2001 From: Wojciech Zajac Date: Mon, 30 Jun 2014 12:21:07 +0200 Subject: [PATCH] USB HCD, usbd, hub changes . MUSB full-speed device enumeration fix . More general TEST UNIT READY for mass storage . USB hub driver stub . USB hub's port connection/disconnection discovery . Unified usbd filenames . USB full speed control transfer fix Change-Id: I205d9b107a0be4ee030d71fe02f93fe012f65d18 --- distrib/sets/lists/minix/mi | 4 + etc/Makefile | 1 + etc/devmand/usb_hub.cfg | 8 + minix/drivers/usb/Makefile | 2 +- minix/drivers/usb/usb_hub/Makefile | 20 + minix/drivers/usb/usb_hub/common.h | 35 + minix/drivers/usb/usb_hub/urb_helper.c | 111 +++ minix/drivers/usb/usb_hub/urb_helper.h | 47 + minix/drivers/usb/usb_hub/usb_hub.c | 845 ++++++++++++++++++ minix/drivers/usb/usb_hub/usb_hub.conf | 15 + minix/drivers/usb/usb_storage/usb_storage.c | 29 +- minix/drivers/usb/usbd/base/earm/usbd_earm.c | 6 +- minix/drivers/usb/usbd/base/usbd.c | 4 +- minix/drivers/usb/usbd/hcd/hcd.c | 22 +- minix/drivers/usb/usbd/hcd/hcd_common.c | 9 +- minix/drivers/usb/usbd/hcd/hcd_ddekit.c | 6 +- minix/drivers/usb/usbd/hcd/musb/musb_am335x.c | 8 +- minix/drivers/usb/usbd/hcd/musb/musb_core.c | 13 +- minix/drivers/usb/usbd/hcd/musb/musb_core.h | 2 +- minix/drivers/usb/usbd/hcd/musb/musb_regs.h | 2 +- .../usbd/include/{usb => usbd}/hcd_common.h | 4 +- .../usbd/include/{usb => usbd}/hcd_ddekit.h | 2 +- .../include/{usb => usbd}/hcd_interface.h | 2 +- .../include/{usb => usbd}/hcd_platforms.h | 0 .../{usb/usb_common.h => usbd/usbd_common.h} | 8 +- .../include/{usb => usbd}/usbd_interface.h | 0 26 files changed, 1152 insertions(+), 53 deletions(-) create mode 100644 etc/devmand/usb_hub.cfg create mode 100644 minix/drivers/usb/usb_hub/Makefile create mode 100644 minix/drivers/usb/usb_hub/common.h create mode 100644 minix/drivers/usb/usb_hub/urb_helper.c create mode 100644 minix/drivers/usb/usb_hub/urb_helper.h create mode 100644 minix/drivers/usb/usb_hub/usb_hub.c create mode 100644 minix/drivers/usb/usb_hub/usb_hub.conf rename minix/drivers/usb/usbd/include/{usb => usbd}/hcd_common.h (98%) rename minix/drivers/usb/usbd/include/{usb => usbd}/hcd_ddekit.h (94%) rename minix/drivers/usb/usbd/include/{usb => usbd}/hcd_interface.h (98%) rename minix/drivers/usb/usbd/include/{usb => usbd}/hcd_platforms.h (100%) rename minix/drivers/usb/usbd/include/{usb/usb_common.h => usbd/usbd_common.h} (92%) rename minix/drivers/usb/usbd/include/{usb => usbd}/usbd_interface.h (100%) diff --git a/distrib/sets/lists/minix/mi b/distrib/sets/lists/minix/mi index 0668fe6f9..2076aa230 100644 --- a/distrib/sets/lists/minix/mi +++ b/distrib/sets/lists/minix/mi @@ -82,6 +82,7 @@ ./etc/devmand/scripts minix-sys ./etc/devmand/scripts/block minix-sys ./etc/devmand/scripts/singlechar minix-sys +./etc/devmand/usb_hub.cfg minix-sys ./etc/devmand/usb_storage.cfg minix-sys ./etc/gettytab minix-sys ./etc/group minix-sys @@ -116,6 +117,7 @@ ./etc/system.conf minix-sys ./etc/system.conf.d minix-sys ./etc/system.conf.d/ipc minix-sys +./etc/system.conf.d/usb_hub minix-sys ./etc/system.conf.d/usb_storage minix-sys ./etc/termcap minix-sys ./etc/ttys minix-sys @@ -5167,6 +5169,8 @@ ./usr/sbin/rdate minix-sys ./usr/sbin/traceroute minix-sys ./usr/sbin/unlink minix-sys +./usr/sbin/usb_hub minix-sys +./usr/sbin/usb_storage minix-sys ./usr/sbin/user minix-sys ./usr/sbin/useradd minix-sys ./usr/sbin/userdel minix-sys diff --git a/etc/Makefile b/etc/Makefile index 766ff3762..8f1662064 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -430,6 +430,7 @@ install-etc-files-safe: .PHONY .MAKE check_DESTDIR MAKEDEV ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/ ${DESTDIR}/usr/lib/ crontab \ ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/ ${DESTDIR}/etc/ system.conf \ ${BINOWN} ${BINGRP} ${NONBINMODE} ${NETBSDSRCDIR}/etc/usr/ ${DESTDIR}/usr/ Makefile \ + ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/devmand/ ${DESTDIR}/etc/devmand/ usb_hub.cfg \ ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/devmand/ ${DESTDIR}/etc/devmand/ usb_storage.cfg \ ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/devmand/scripts/ ${DESTDIR}/etc/devmand/scripts/ block \ ${BINOWN} ${BINGRP} ${BINMODE} ${NETBSDSRCDIR}/etc/devmand/scripts/ ${DESTDIR}/etc/devmand/scripts/ singlechar \ diff --git a/etc/devmand/usb_hub.cfg b/etc/devmand/usb_hub.cfg new file mode 100644 index 000000000..5018f6875 --- /dev/null +++ b/etc/devmand/usb_hub.cfg @@ -0,0 +1,8 @@ +usb_driver usb_hub +{ + binary = /usr/sbin/usb_hub; + id { + bInterfaceClass = 0x09; + } + devprefix = usb_hub; +} diff --git a/minix/drivers/usb/Makefile b/minix/drivers/usb/Makefile index 992e26ac4..6ebeeb593 100644 --- a/minix/drivers/usb/Makefile +++ b/minix/drivers/usb/Makefile @@ -4,6 +4,6 @@ SUBDIR+= usbd .endif # ${MACHINE_ARCH} == "earm" -SUBDIR+= usb_storage +SUBDIR+= usb_storage usb_hub .include diff --git a/minix/drivers/usb/usb_hub/Makefile b/minix/drivers/usb/usb_hub/Makefile new file mode 100644 index 000000000..cc18fe3a0 --- /dev/null +++ b/minix/drivers/usb/usb_hub/Makefile @@ -0,0 +1,20 @@ +# Makefile for USB hub driver +PROG=usb_hub +SRCS=usb_hub.c urb_helper.c + +FILES=$(PROG).conf +FILESNAME=$(PROG) +FILESDIR=/etc/system.conf.d + +DPADD+=${LIBDDEKIT_USB_CLIENT} ${LIBDDEKIT} ${LIBUSB} ${LIBSYS} ${LIBMINLIB} +LDADD+=-lddekit_usb_client -lddekit -lusb -lsys -lminlib + +#For easier debugging, uncomment: +#LDADD+=-Wl,-Ttext=0x800000 +#CPPFLAGS+=-DHUB_DEBUG + +MAN= + +BINDIR?= /usr/sbin + +.include diff --git a/minix/drivers/usb/usb_hub/common.h b/minix/drivers/usb/usb_hub/common.h new file mode 100644 index 000000000..de891acbd --- /dev/null +++ b/minix/drivers/usb/usb_hub/common.h @@ -0,0 +1,35 @@ +/* + * Whatever is commonly used in hub driver, should be here + */ + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +/*---------------------------* + * commonly used headers: * + *---------------------------*/ +#include /* For things, like EXIT_*, NULL, ... */ +#include + +/*---------------------------* + * commonly used defines: * + *---------------------------*/ +#define THIS_EXEC_NAME "usb_hub" +#define HUB_MSG(...) do { \ + printf(THIS_EXEC_NAME": "); \ + printf(__VA_ARGS__); \ + printf("; %s:%d\n", __func__, __LINE__); \ + } while(0) + +/*---------------------------* + * debug helpers: * + *---------------------------*/ +#ifdef HUB_DEBUG +#define HUB_DEBUG_MSG HUB_MSG +#define HUB_DEBUG_DUMP printf("%s():%d\n", __func__, __LINE__) +#else +#define HUB_DEBUG_MSG(...) +#define HUB_DEBUG_DUMP +#endif + +#endif /* !_COMMON_H_ */ diff --git a/minix/drivers/usb/usb_hub/urb_helper.c b/minix/drivers/usb/usb_hub/urb_helper.c new file mode 100644 index 000000000..c7a93a35c --- /dev/null +++ b/minix/drivers/usb/usb_hub/urb_helper.c @@ -0,0 +1,111 @@ +/* + * URB formatting related implementation + */ + +#include /* panic */ +#include /* struct usb_ctrlrequest */ + +#include /* memset */ +#include + +#include "common.h" +#include "urb_helper.h" + +/*---------------------------* + * defined functions * + *---------------------------*/ +/*===========================================================================* + * init_urb * + *===========================================================================*/ +void +init_urb(struct ddekit_usb_urb * urb, struct ddekit_usb_dev * dev, + urb_ep_config * conf) +{ + HUB_DEBUG_DUMP; + + /* Sanity checks */ + assert(NULL != urb); + assert(NULL != dev); + assert((DDEKIT_USB_TRANSFER_BLK == conf->type) || + (DDEKIT_USB_TRANSFER_CTL == conf->type) || + (DDEKIT_USB_TRANSFER_INT == conf->type) || + (DDEKIT_USB_TRANSFER_ISO == conf->type)); + assert((conf->ep_num >= 0) && (conf->ep_num < 16)); + assert((DDEKIT_USB_IN == conf->direction) || + (DDEKIT_USB_OUT == conf->direction)); + + /* Clear block first */ + memset(urb, 0, sizeof(*urb)); + + /* Set supplied values */ + urb->dev = dev; + urb->type = conf->type; + urb->endpoint = conf->ep_num; + urb->direction = conf->direction; + urb->interval = conf->interval; +} + + +/*===========================================================================* + * attach_urb_data * + *===========================================================================*/ +void +attach_urb_data(struct ddekit_usb_urb * urb, int buf_type, + void * buf, ddekit_uint32_t buf_len) +{ + HUB_DEBUG_DUMP; + + assert(NULL != urb); + assert(NULL != buf); + + /* Mutual exclusion */ + if (URB_BUF_TYPE_DATA == buf_type) { + urb->data = buf; + urb->size = buf_len; + } else if ( URB_BUF_TYPE_SETUP == buf_type ) { + assert(sizeof(struct usb_ctrlrequest) == buf_len); + urb->setup_packet = buf; + } else + panic("Unexpected buffer type!"); +} + + +/*===========================================================================* + * blocking_urb_submit * + *===========================================================================*/ +int +blocking_urb_submit(struct ddekit_usb_urb * urb, ddekit_sem_t * sem, + int check_len) +{ + HUB_DEBUG_DUMP; + + assert(NULL != urb); + assert(NULL != sem); + assert((check_len == URB_SUBMIT_CHECK_LEN) || + (check_len == URB_SUBMIT_ALLOW_MISMATCH)); + + /* Submit and block until semaphore gets up */ + if (ddekit_usb_submit_urb(urb)) { + HUB_MSG("Submitting DDEKit URB failed"); + return EXIT_FAILURE; + } else { + /* Submitting succeeded so block and wait for reply */ + ddekit_sem_down(sem); + + /* Check for DDEKit status first */ + if (urb->status) { + HUB_MSG("Invalid DDEKit URB status"); + return EXIT_FAILURE; + } else { + if (URB_SUBMIT_CHECK_LEN == check_len) { + /* Compare lengths */ + if (urb->actual_length != urb->size) { + HUB_MSG("URB different than expected"); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; + } + } +} diff --git a/minix/drivers/usb/usb_hub/urb_helper.h b/minix/drivers/usb/usb_hub/urb_helper.h new file mode 100644 index 000000000..c9033c93b --- /dev/null +++ b/minix/drivers/usb/usb_hub/urb_helper.h @@ -0,0 +1,47 @@ +/* + * URB formatting related definitions + */ + +#ifndef _URB_HELPER_H_ +#define _URB_HELPER_H_ + +#include +#include + +/* Possible values for attach_urb_data's buf_type */ +/* Both may be used for single URB */ +#define URB_BUF_TYPE_DATA 0 /* attached buffer is data buffer */ +#define URB_BUF_TYPE_SETUP 1 /* attached buffer is setup structure */ + +/* Possible values for blocking_urb_submit's check_len */ +/* Use URB_SUBMIT_CHECK_LEN when actual data buffer length returned + * by HCD must match expected length, supplied in attach_urb_data */ +#define URB_SUBMIT_CHECK_LEN 0 /* return error on length mismatch */ +#define URB_SUBMIT_ALLOW_MISMATCH 1 /* ignore length check */ + +/* Endpoint configuration related */ +#define URB_INVALID_EP (-1) /* default for unset endpoint */ + +/*---------------------------* + * declared types * + *---------------------------*/ +/* URB's endpoint configuration */ +typedef struct urb_ep_config { + + ddekit_int32_t ep_num; + ddekit_int32_t direction; + ddekit_int32_t type; + ddekit_int32_t max_packet_size; + ddekit_int32_t interval; +} +urb_ep_config; + +/*---------------------------* + * declared functions * + *---------------------------*/ +void init_urb(struct ddekit_usb_urb *, struct ddekit_usb_dev *, + urb_ep_config *); +void attach_urb_data(struct ddekit_usb_urb *, int, void *, ddekit_uint32_t); +int blocking_urb_submit(struct ddekit_usb_urb *, ddekit_sem_t *, int); + +#endif /* !_URB_HELPER_H_ */ diff --git a/minix/drivers/usb/usb_hub/usb_hub.c b/minix/drivers/usb/usb_hub/usb_hub.c new file mode 100644 index 000000000..1dbcd40b8 --- /dev/null +++ b/minix/drivers/usb/usb_hub/usb_hub.c @@ -0,0 +1,845 @@ +/* + * Minix3 USB hub driver implementation + */ + +#include /* assert */ +#include /* memset */ +#include + +#include +#include +#include /* panic */ +#include /* usb_ctrlrequest TODO: remove me */ + +#include "common.h" +#include "urb_helper.h" + + +/*---------------------------* + * declared functions * + *---------------------------*/ +/* TODO: these are missing from DDE header files */ +extern void ddekit_minix_wait_exit(void); +extern void ddekit_shutdown(void); + +/* SEF related functions */ +static int hub_sef_hdlr(int, sef_init_info_t *); +static void hub_signal_handler(int); + +/* DDEKit IPC related */ +static void ddekit_usb_task(void *); + +/* DDEKit's USB driver callbacks */ +static void usb_driver_completion(void *); +static void usb_driver_connect(struct ddekit_usb_dev *, unsigned int); +static void usb_driver_disconnect(struct ddekit_usb_dev *); + +/* Hub driver main task */ +static void hub_task(void *); + + +/*---------------------------* + * class specific stuff * + *---------------------------*/ +#define HUB_PACKED __attribute__((__packed__)) + +/* How often to check for changes */ +#define USB_HUB_POLLING_INTERVAL 1000 + +/* Max number of hub ports */ +#define USB_HUB_PORT_LIMIT 8 + +/* Hub descriptor type */ +#define USB_HUB_DESCRIPTOR_TYPE 0x29 + +/* Hub descriptor structure */ +typedef struct HUB_PACKED hub_descriptor { + + uint8_t bDescLength; + uint8_t bDescriptorType; + uint8_t bNbrPorts; + uint16_t wHubCharacteristics; + uint8_t bPwrOn2PwrGood; + uint8_t bHubContrCurrent; + /* Remaining variable length fields are ignored for now */ +} +hub_descriptor; + +/* Hub port status structure, as defined in USB 2.0 document */ +typedef struct HUB_PACKED hub_port_status { + + uint32_t PORT_CONNECTION : 1; + uint32_t PORT_ENABLE : 1; + uint32_t PORT_SUSPEND : 1; + uint32_t PORT_OVER_CURRENT : 1; + uint32_t PORT_RESET : 1; + uint32_t RESERVED1 : 3; + + uint32_t PORT_POWER : 1; + uint32_t PORT_LOW_SPEED : 1; + uint32_t PORT_HIGH_SPEED : 1; + uint32_t PORT_TEST : 1; + uint32_t PORT_INDICATOR : 1; + uint32_t RESERVED2 : 3; + + uint32_t C_PORT_CONNECTION : 1; + uint32_t C_PORT_ENABLE : 1; + uint32_t C_PORT_SUSPEND : 1; + uint32_t C_PORT_OVER_CURRENT : 1; + uint32_t C_PORT_RESET : 1; + uint32_t RESERVED3 : 11; +} +hub_port_status; + +/* Hub Class Feature Selectors */ +typedef enum { + + C_HUB_LOCAL_POWER = 0 , + C_HUB_OVER_CURRENT = 1 , + PORT_CONNECTION = 0 , + PORT_ENABLE = 1 , + PORT_SUSPEND = 2 , + PORT_OVER_CURRENT = 3 , + PORT_RESET = 4 , + PORT_POWER = 8 , + PORT_LOW_SPEED = 9 , + C_PORT_CONNECTION = 16, + C_PORT_ENABLE = 17, + C_PORT_SUSPEND = 18, + C_PORT_OVER_CURRENT = 19, + C_PORT_RESET = 20, + PORT_TEST = 21, + PORT_INDICATOR = 22 +} +class_feature; + +/* Hub Class Request Codes */ +typedef enum { + + GET_STATUS = 0 , + CLEAR_FEATURE = 1 , + RESERVED1 = 2 , + SET_FEATURE = 3 , + RESERVED2 = 4 , + RESERVED3 = 5 , + GET_DESCRIPTOR = 6 , + SET_DESCRIPTOR = 7 , + CLEAR_TT_BUFFER = 8 , + RESET_TT = 9 , + GET_TT_STATE = 10, + STOP_TT = 11 +} +class_code; + +/* Hub port connection state */ +typedef enum { + + HUB_PORT_DISCONN = 0, + HUB_PORT_CONN = 1, + HUB_PORT_ERROR = 2 +} +port_conn; + +/* Hub port connection changes */ +typedef enum { + + HUB_CHANGE_NONE = 0, /* Nothing changed since last poll */ + HUB_CHANGE_CONN = 1, /* Device was just connected */ + HUB_CHANGE_DISCONN= 2, /* Device was just disconnected */ + HUB_CHANGE_STATUS_ERR = 3, /* Port status mismatch */ + HUB_CHANGE_COM_ERR = 4 /* Something wrong happened to driver */ +} +port_change; + +/* Hub get class specific descriptor call */ +static int hub_get_descriptor(hub_descriptor *); + +/* Hub Set/ClearPortFeature call */ +static int hub_port_feature(int, class_code, class_feature); + +/* Hub GetPortStatus call */ +static int hub_get_port_status(int, hub_port_status *); + +/* Handle port status change */ +static port_change hub_handle_change(int, hub_port_status *); + +/* Handle port connection */ +static int hub_handle_connection(int); + +/* Handle port disconnection */ +static int hub_handle_disconnection(int); + + +/*---------------------------* + * defined variables * + *---------------------------*/ +/* USB hub driver state */ +typedef struct hub_state { + + hub_descriptor descriptor; /* Class specific descriptor */ + struct ddekit_usb_dev * dev; /* DDEKit device */ + int num_ports; /* Number of hub ports */ + port_conn conn[USB_HUB_PORT_LIMIT]; /* Map of connected ports */ +} +hub_state; + +/* Current hub driver state */ +static hub_state driver_state; + +/* USB callback structure */ +static struct ddekit_usb_driver usb_driver = { + .completion = usb_driver_completion, + .connect = usb_driver_connect, + .disconnect = usb_driver_disconnect +}; + +/* Semaphore used to block hub thread to + * allow DDE dispatcher operation */ +static ddekit_sem_t * hub_sem = NULL; + +/* USB hub thread */ +ddekit_thread_t * hub_thread = NULL; + +/* DDEKit USB message handling thread */ +ddekit_thread_t * ddekit_usb_thread = NULL; + + +/*---------------------------* + * defined functions * + *---------------------------*/ +/*===========================================================================* + * main * + *===========================================================================*/ +int +main(int argc, char * argv[]) +{ + HUB_MSG("Starting driver... (built: %s %s)", __DATE__, __TIME__); + + /* Store arguments for future parsing */ + env_setargs(argc, argv); + + /* Clear current state */ + memset(&driver_state, 0, sizeof(driver_state)); + + /* Initialize SEF related callbacks */ + sef_setcb_init_fresh(hub_sef_hdlr); + sef_setcb_init_lu(hub_sef_hdlr); + sef_setcb_init_restart(hub_sef_hdlr); + sef_setcb_signal_handler(hub_signal_handler); + + /* Initialize DDEkit (involves sef_startup()) */ + ddekit_init(); + HUB_DEBUG_MSG("DDEkit ready..."); + + /* Semaphore initialization */ + hub_sem = ddekit_sem_init(0); + if (NULL == hub_sem) + panic("Initializing USB hub semaphore, failed!"); + + /* Starting hub thread */ + hub_thread = ddekit_thread_create(hub_task, NULL, "hub_task"); + if (NULL == hub_thread) + panic("Initializing USB hub thread failed!"); + + HUB_DEBUG_MSG("USB HUB task ready..."); + + /* Run USB IPC task to collect messages */ + ddekit_usb_thread = ddekit_thread_create(ddekit_usb_task, NULL, + "ddekit_task" ); + if (NULL == ddekit_usb_thread) + panic("Initializing ddekit_usb_thread failed!"); + + HUB_DEBUG_MSG("USB IPC task ready..."); + + /* Block and wait until exit signal is received */ + ddekit_minix_wait_exit(); + HUB_DEBUG_MSG("Exiting..."); + + /* Release objects that were explicitly allocated above */ + ddekit_thread_terminate(ddekit_usb_thread); + ddekit_thread_terminate(hub_thread); + ddekit_sem_deinit(hub_sem); + + /* TODO: No ddekit_deinit for proper cleanup? */ + + HUB_DEBUG_MSG("Cleanup completed..."); + + return EXIT_SUCCESS; +} + + +/*===========================================================================* + * hub_sef_hdlr * + *===========================================================================*/ +static int +hub_sef_hdlr(int type, sef_init_info_t * UNUSED(info)) +{ + HUB_DEBUG_DUMP; + + switch (type) { + case SEF_INIT_FRESH: + return EXIT_SUCCESS; + case SEF_INIT_LU: + case SEF_INIT_RESTART: + HUB_MSG("Only 'fresh' SEF initialization supported\n"); + break; + default: + HUB_MSG("illegal SEF type\n"); + break; + } + + return EXIT_FAILURE; +} + + +/*===========================================================================* + * hub_signal_handler * + *===========================================================================*/ +static void +hub_signal_handler(int this_signal) +{ + HUB_DEBUG_DUMP; + + HUB_MSG("Handling signal 0x%X", this_signal); + + /* TODO: Any signal means shutdown for now (it may be OK anyway) */ + /* Try graceful DDEKit exit */ + ddekit_shutdown(); + + /* Unreachable, when ddekit_shutdown works correctly */ + panic("Calling ddekit_shutdown failed!"); +} + + +/*===========================================================================* + * ddekit_usb_task * + *===========================================================================*/ +static void +ddekit_usb_task(void * UNUSED(arg)) +{ + HUB_DEBUG_DUMP; + + /* TODO: This call was meant to return 'int' but loops forever instead, + * so no return value is checked */ + ddekit_usb_init(&usb_driver, NULL, NULL); +} + + +/*===========================================================================* + * usb_driver_completion * + *===========================================================================*/ +static void +usb_driver_completion(void * UNUSED(priv)) +{ + HUB_DEBUG_DUMP; + + /* Last request was completed so allow continuing + * execution from place where semaphore was downed */ + ddekit_sem_up(hub_sem); +} + + +/*===========================================================================* + * usb_driver_connect * + *===========================================================================*/ +static void +usb_driver_connect(struct ddekit_usb_dev * dev, unsigned int interfaces) +{ + HUB_DEBUG_DUMP; + + if (NULL != driver_state.dev) + panic("HUB device driver can be connected only once!"); + + /* Clear current state */ + memset(&driver_state, 0, sizeof(driver_state)); + + /* Hold host information for future use */ + driver_state.dev = dev; + + /* Let driver logic work */ + ddekit_sem_up(hub_sem); +} + + +/*===========================================================================* + * usb_driver_disconnect * + *===========================================================================*/ +static void +usb_driver_disconnect(struct ddekit_usb_dev * UNUSED(dev)) +{ + HUB_DEBUG_DUMP; + + if (NULL == driver_state.dev) + panic("HUB device driver was never connected!"); + + /* Discard connected device information */ + driver_state.dev = NULL; +} + + +/*===========================================================================* + * hub_task * + *===========================================================================*/ +static void +hub_task(void * UNUSED(arg)) +{ + hub_port_status port_status; + hub_state * s; + hub_descriptor * d; + int port; + + HUB_DEBUG_DUMP; + + /* For short */ + s = &(driver_state); + d = &(s->descriptor); + + /* Wait for connection */ + ddekit_sem_down(hub_sem); + + if (hub_get_descriptor(d)) { + HUB_MSG("Getting hub descriptor failed"); + goto HUB_ERROR; + } + + /* Output hub descriptor in debug mode */ + HUB_DEBUG_MSG("bDescLength %4X", d->bDescLength); + HUB_DEBUG_MSG("bDescriptorType %4X", d->bDescriptorType); + HUB_DEBUG_MSG("bNbrPorts %4X", d->bNbrPorts); + HUB_DEBUG_MSG("wHubCharacteristics %4X", d->wHubCharacteristics); + HUB_DEBUG_MSG("bPwrOn2PwrGood %4X", d->bPwrOn2PwrGood); + HUB_DEBUG_MSG("bHubContrCurrent %4X", d->bHubContrCurrent); + + /* Check for sane number of ports... */ + if (d->bNbrPorts > USB_HUB_PORT_LIMIT) { + HUB_MSG("Too many hub ports declared: %d", d->bNbrPorts); + goto HUB_ERROR; + } + + /* ...and reassign */ + s->num_ports = (int)d->bNbrPorts; + + /* Initialize all available ports starting + * from 1, as defined by USB 2.0 document */ + for (port = 1; port <= s->num_ports; port++) { + if (hub_port_feature(port, SET_FEATURE, PORT_POWER)) { + HUB_MSG("Powering port %d failed", port); + goto HUB_ERROR; + } + + /* TODO: Will be needed later with HUB IPC */ +#if 0 + if (hub_port_feature(port, SET_FEATURE, PORT_RESET)) { + HUB_MSG("Resetting port %d failed", port); + goto HUB_ERROR; + } +#endif + } + + /* + * Connection polling loop + */ + for (;;) { + for (port = 1; port <= s->num_ports; port++) { + + /* Ignore previously blocked ports */ + if (HUB_PORT_ERROR == s->conn[port]) { + HUB_DEBUG_MSG("Blocked hub port ignored"); + continue; + } + + /* Get port status */ + if (hub_get_port_status(port, &port_status)) { + HUB_MSG("Reading port %d status failed", port); + goto HUB_ERROR; + } + + /* Resolve port changes */ + switch (hub_handle_change(port, &port_status)) { + + case HUB_CHANGE_NONE: + break; + + case HUB_CHANGE_CONN: + s->conn[port] = HUB_PORT_CONN; + break; + + case HUB_CHANGE_DISCONN: + s->conn[port] = HUB_PORT_DISCONN; + break; + + case HUB_CHANGE_STATUS_ERR: + /* Turn off port */ + if (hub_port_feature(port, + CLEAR_FEATURE, + PORT_POWER)) { + HUB_MSG("Halting port %d " + "failed", port); + goto HUB_ERROR; + } + /* Block this port forever */ + s->conn[port] = HUB_PORT_ERROR; + break; + + case HUB_CHANGE_COM_ERR: + /* Serious error, hang */ + HUB_MSG("Handling port %d " + "change failed", port); + goto HUB_ERROR; + } + } + + ddekit_thread_msleep(USB_HUB_POLLING_INTERVAL); + HUB_DEBUG_MSG("Polling USB hub for status change"); + } + + return; + + HUB_ERROR: + for (;;) { + /* Hang till removed by devmand */ + HUB_MSG("Hub driver error occurred, hanging up"); + ddekit_sem_down(hub_sem); + } +} + + +/*===========================================================================* + * hub_get_descriptor * + *===========================================================================*/ +static int +hub_get_descriptor(hub_descriptor * descriptor) +{ + /* URB to be send */ + struct ddekit_usb_urb urb; + + /* Setup buffer to be attached */ + struct usb_ctrlrequest setup_buf; + + /* Control EP configuration */ + urb_ep_config ep_conf; + + HUB_DEBUG_DUMP; + + /* Initialize EP configuration */ + ep_conf.ep_num = 0; + ep_conf.direction = DDEKIT_USB_IN; + ep_conf.type = DDEKIT_USB_TRANSFER_CTL; + ep_conf.max_packet_size = 0; + ep_conf.interval = 0; + + /* Reset URB and assign given values */ + init_urb(&urb, driver_state.dev, &ep_conf); + + /* Clear setup data */ + memset(&setup_buf, 0, sizeof(setup_buf)); + + /* Class get hub descriptor request */ + setup_buf.bRequestType = 0xA0; + setup_buf.bRequest = 0x06; + setup_buf.wValue = USB_HUB_DESCRIPTOR_TYPE << 8; + setup_buf.wIndex = 0x00; + setup_buf.wLength = sizeof(*descriptor); + + /* Attach buffers to URB */ + attach_urb_data(&urb, URB_BUF_TYPE_SETUP, + &setup_buf, sizeof(setup_buf)); + attach_urb_data(&urb, URB_BUF_TYPE_DATA, + descriptor, sizeof(*descriptor)); + + /* Send and wait for response */ + if (blocking_urb_submit(&urb, hub_sem, URB_SUBMIT_CHECK_LEN)) { + HUB_MSG("Submitting HUB URB failed"); + return EXIT_FAILURE; + } else { + HUB_DEBUG_MSG("HUB descriptor received"); + return EXIT_SUCCESS; + } +} + + +/*===========================================================================* + * hub_port_feature * + *===========================================================================*/ +static int +hub_port_feature(int port_num, class_code code, class_feature feature) +{ + /* URB to be send */ + struct ddekit_usb_urb urb; + + /* Setup buffer to be attached */ + struct usb_ctrlrequest setup_buf; + + /* Control EP configuration */ + urb_ep_config ep_conf; + + HUB_DEBUG_DUMP; + + /* TODO: Add more checks when needed */ + if (!((port_num <= driver_state.num_ports) && (port_num > 0))) + return EXIT_FAILURE; + + if (!((code == SET_FEATURE) || (code == CLEAR_FEATURE))) + return EXIT_FAILURE; + + if (!((feature == PORT_RESET) || (feature == PORT_POWER) || + (feature == C_PORT_CONNECTION))) + return EXIT_FAILURE; + + /* Initialize EP configuration */ + ep_conf.ep_num = 0; + ep_conf.direction = DDEKIT_USB_OUT; + ep_conf.type = DDEKIT_USB_TRANSFER_CTL; + ep_conf.max_packet_size = 0; + ep_conf.interval = 0; + + /* Reset URB and assign given values */ + init_urb(&urb, driver_state.dev, &ep_conf); + + /* Clear setup data */ + memset(&setup_buf, 0, sizeof(setup_buf)); + + /* Standard get endpoint request */ + setup_buf.bRequestType = 0x23; + setup_buf.bRequest = (u8_t)code; + setup_buf.wValue = (u16_t)feature; + setup_buf.wIndex = (u16_t)port_num; + setup_buf.wLength = 0; + + /* Attach buffers to URB */ + attach_urb_data(&urb, URB_BUF_TYPE_SETUP, + &setup_buf, sizeof(setup_buf)); + + /* Send and wait for response */ + if (blocking_urb_submit(&urb, hub_sem, URB_SUBMIT_CHECK_LEN)) { + HUB_MSG("Submitting HUB URB failed"); + return EXIT_FAILURE; + } else { + HUB_DEBUG_MSG("PortFeature operation completed"); + return EXIT_SUCCESS; + } +} + + +/*===========================================================================* + * hub_get_port_status * + *===========================================================================*/ +static int +hub_get_port_status(int port_num, hub_port_status * p) +{ + /* URB to be send */ + struct ddekit_usb_urb urb; + + /* Setup buffer to be attached */ + struct usb_ctrlrequest setup_buf; + + /* Control EP configuration */ + urb_ep_config ep_conf; + + HUB_DEBUG_DUMP; + + if (!((port_num <= driver_state.num_ports) && (port_num > 0))) + return EXIT_FAILURE; + + /* Initialize EP configuration */ + ep_conf.ep_num = 0; + ep_conf.direction = DDEKIT_USB_IN; + ep_conf.type = DDEKIT_USB_TRANSFER_CTL; + ep_conf.max_packet_size = 0; + ep_conf.interval = 0; + + /* Reset URB and assign given values */ + init_urb(&urb, driver_state.dev, &ep_conf); + + /* Clear setup data */ + memset(&setup_buf, 0, sizeof(setup_buf)); + + /* Standard get endpoint request */ + setup_buf.bRequestType = 0xA3; + setup_buf.bRequest = (u8_t)GET_STATUS; + setup_buf.wValue = 0x00; + setup_buf.wIndex = (u16_t)port_num; + setup_buf.wLength = sizeof(*p); + + /* Attach buffers to URB */ + attach_urb_data(&urb, URB_BUF_TYPE_SETUP, + &setup_buf, sizeof(setup_buf)); + attach_urb_data(&urb, URB_BUF_TYPE_DATA, + p, sizeof(*p)); + + /* Send and wait for response */ + if (blocking_urb_submit(&urb, hub_sem, URB_SUBMIT_CHECK_LEN)) { + HUB_MSG("Submitting HUB URB failed"); + return EXIT_FAILURE; + } else { + HUB_DEBUG_MSG("Port%d status: ", port_num); + HUB_DEBUG_MSG("PORT_CONNECTION %01X", p->PORT_CONNECTION); + HUB_DEBUG_MSG("PORT_ENABLE %01X", p->PORT_ENABLE); + HUB_DEBUG_MSG("PORT_POWER %01X", p->PORT_POWER); + HUB_DEBUG_MSG("C_PORT_CONNECTION %01X", p->C_PORT_CONNECTION); + HUB_DEBUG_MSG("C_PORT_ENABLE %01X", p->C_PORT_ENABLE); + return EXIT_SUCCESS; + } +} + + +/*===========================================================================* + * hub_handle_change * + *===========================================================================*/ +static port_change +hub_handle_change(int port_num, hub_port_status * status) +{ + port_conn * c; + + HUB_DEBUG_DUMP; + + /* Possible combinations: */ + /* Change = status->C_PORT_CONNECTION (hub connection change bit) + * Local = driver_state.conn[port_num] (local connection status) + * Remote = status->PORT_CONNECTION (hub connection status) */ + /* + Case Change Local Remote Description + 1. 1 1 1 Polling mismatch (quick disconn-conn) + 2. 1 1 0 Just disconnected + 3. 1 0 1 Just connected + 4. 1 0 0 Polling mismatch (quick conn-disconn) + 5. 0 1 1 Still connected + 6. 0 1 0 Serious ERROR + 7. 0 0 1 Serious ERROR + 8. 0 0 0 Still disconnected + */ + + /* Reassign for code cleanliness */ + c = driver_state.conn; + + /* Resolve combination */ + if (status->C_PORT_CONNECTION) { + + /* C_PORT_CONNECTION was set, so clear change bit + * to allow further polling */ + if (hub_port_feature(port_num, CLEAR_FEATURE, + C_PORT_CONNECTION)) { + HUB_MSG("Clearing port %d change bit failed", port_num); + return HUB_CHANGE_COM_ERR; + } + + if (HUB_PORT_CONN == c[port_num]) { + if (status->PORT_CONNECTION) { + + /* + * 1 + */ + /* Make hub disconnect and connect again */ + if (hub_handle_disconnection(port_num) || + hub_handle_connection(port_num)) + return HUB_CHANGE_STATUS_ERR; + else + return HUB_CHANGE_CONN; + + } else { + + /* + * 2 + */ + /* Handle disconnection */ + if (hub_handle_disconnection(port_num)) + return HUB_CHANGE_STATUS_ERR; + else + return HUB_CHANGE_DISCONN; + + } + } else if (HUB_PORT_DISCONN == c[port_num]) { + if (status->PORT_CONNECTION) { + + /* + * 3 + */ + /* Handle connection */ + if (hub_handle_connection(port_num)) + return HUB_CHANGE_STATUS_ERR; + else + return HUB_CHANGE_CONN; + + } else { + + /* + * 4 + */ + /* Since we were disconnected before and + * are disconnected now, additional handling + * may be ignored */ + return HUB_CHANGE_NONE; + + } + } + } else { + if (HUB_PORT_CONN == c[port_num]) { + if (status->PORT_CONNECTION) { + + /* + * 5 + */ + /* Connected (nothing changed) */ + return HUB_CHANGE_NONE; + + } else { + + /* + * 6 + */ + /* Serious status error */ + return HUB_CHANGE_STATUS_ERR; + + } + } else if (HUB_PORT_DISCONN == c[port_num]) { + if (status->PORT_CONNECTION) { + + /* + * 7 + */ + /* Serious status error */ + return HUB_CHANGE_STATUS_ERR; + + } else { + + /* + * 8 + */ + /* Disconnected (nothing changed) */ + return HUB_CHANGE_NONE; + + } + } + } + + return HUB_CHANGE_COM_ERR; +} + + +/* TODO: Add real connection/disconnection HCD IPC below */ +/*===========================================================================* + * hub_handle_connection * + *===========================================================================*/ +static int +hub_handle_connection(int port_num) +{ + HUB_DEBUG_DUMP; + + HUB_MSG("Device connected to port %d", port_num); + + return EXIT_SUCCESS; +} + + +/*===========================================================================* + * hub_handle_disconnection * + *===========================================================================*/ +static int +hub_handle_disconnection(int port_num) +{ + HUB_DEBUG_DUMP; + + HUB_MSG("Device disconnected from port %d", port_num); + + return EXIT_SUCCESS; +} diff --git a/minix/drivers/usb/usb_hub/usb_hub.conf b/minix/drivers/usb/usb_hub/usb_hub.conf new file mode 100644 index 000000000..f0fecca84 --- /dev/null +++ b/minix/drivers/usb/usb_hub/usb_hub.conf @@ -0,0 +1,15 @@ +service usb_hub +{ + system + PRIVCTL # 4 + UMAP # 14 + IRQCTL # 19 + DEVIO # 21 + SDEVIO # 22 + ; + ipc + SYSTEM pm rs log tty ds vfs vm amddev devman + pci usbd + ; + uid 0; +}; diff --git a/minix/drivers/usb/usb_storage/usb_storage.c b/minix/drivers/usb/usb_storage/usb_storage.c index 2303bdad1..c40789a37 100644 --- a/minix/drivers/usb/usb_storage/usb_storage.c +++ b/minix/drivers/usb/usb_storage/usb_storage.c @@ -3,6 +3,7 @@ * using DDEkit, and libblockdriver */ +#include /* __CTASSERT() */ #include /* cases for mass_storage_ioctl */ #ifdef USB_STORAGE_SIGNAL #include /* signal handling */ @@ -151,7 +152,7 @@ static unsigned char buffer[BUFFER_SIZE]; #define MAX_DESCRIPTORS_LEN 128 /* Maximum 'Test Unit Ready' command retries */ -#define MAX_TEST_RETRIES 20 +#define MAX_TEST_RETRIES 3 /* 'Test Unit Ready' failure delay time (in nanoseconds) */ #define NEXT_TEST_DELAY 50000000 /* 50ms */ @@ -597,6 +598,7 @@ static int mass_storage_test(void) { int repeat; + int error; struct timespec test_wait; @@ -619,8 +621,10 @@ mass_storage_test(void) return EXIT_SUCCESS; /* Check for errors */ - if (mass_storage_check_error()) - return EIO; + if (EXIT_SUCCESS != (error = mass_storage_check_error())) { + MASS_MSG("SCSI sense error checking failed"); + return error; + } /* Ignore potential signal interruption (no return value check), * since it causes driver termination anyway */ @@ -628,8 +632,7 @@ mass_storage_test(void) MASS_MSG("Calling nanosleep() failed"); } - MASS_MSG("Try, ignoring TEST UNIT READY errors"); - return EXIT_SUCCESS; + return EIO; } @@ -667,8 +670,8 @@ mass_storage_check_error(void) MASS_DEBUG_DUMP; - /* TODO: This should become compile-time assert */ - assert(sizeof(sense) == SCSI_REQUEST_SENSE_DATA_LEN); + /* Check if bit-fields are packed correctly */ + __CTASSERT(sizeof(sense) == SCSI_REQUEST_SENSE_DATA_LEN); /* SCSI REQUEST SENSE OUT stage */ if (mass_storage_send_scsi_cbw_out(SCSI_REQUEST_SENSE, NULL)) @@ -684,6 +687,7 @@ mass_storage_check_error(void) /* When any sense code is present something may have failed */ if (sense.sense) { +#ifdef MASS_DEBUG MASS_MSG("SCSI sense: "); MASS_MSG("code : %8X", sense.code ); MASS_MSG("valid : %8X", sense.valid ); @@ -702,6 +706,10 @@ mass_storage_check_error(void) MASS_MSG("key_specific1 : %8X", sense.key_specific1 ); MASS_MSG("sksv : %8X", sense.sksv ); MASS_MSG("key_specific2 : %8X", sense.key_specific2 ); +#else + MASS_MSG("SCSI sense: 0x%02X 0x%02X 0x%02X", sense.sense, + sense.additional_code, sense.additional_qual); +#endif } return EXIT_SUCCESS; @@ -1172,9 +1180,10 @@ mass_storage_open(devminor_t minor, int UNUSED(access)) MASS_MSG("Opening mass storage device" " for the first time failed"); - /* TODO: This could be used in other places too */ - if (mass_storage_check_error()) - MASS_MSG("SCSI error check failed"); + /* Do one more test before failing, to output + * sense errors in case they weren't dumped already */ + if (mass_storage_test()) + MASS_MSG("Final TEST UNIT READY failed"); return r; } diff --git a/minix/drivers/usb/usbd/base/earm/usbd_earm.c b/minix/drivers/usb/usbd/base/earm/usbd_earm.c index 79d8df3fe..24a08b864 100644 --- a/minix/drivers/usb/usbd/base/earm/usbd_earm.c +++ b/minix/drivers/usb/usbd/base/earm/usbd_earm.c @@ -5,9 +5,9 @@ #include #include -#include -#include -#include +#include +#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/base/usbd.c b/minix/drivers/usb/usbd/base/usbd.c index f45929cba..6104b1800 100644 --- a/minix/drivers/usb/usbd/base/usbd.c +++ b/minix/drivers/usb/usbd/base/usbd.c @@ -10,8 +10,8 @@ #include /* Initializing 'devman' */ #include /* SEF handling */ -#include -#include +#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/hcd/hcd.c b/minix/drivers/usb/usbd/hcd/hcd.c index 56687c5b7..b0ed8edb4 100644 --- a/minix/drivers/usb/usbd/hcd/hcd.c +++ b/minix/drivers/usb/usbd/hcd/hcd.c @@ -6,10 +6,10 @@ #include /* errno with sign */ -#include -#include -#include -#include +#include +#include +#include +#include /*===========================================================================* @@ -203,10 +203,10 @@ hcd_enumerate(hcd_device_state * this_device) } /* Default MaxPacketSize, based on speed */ - if (HCD_SPEED_LOW == this_device->speed) - this_device->max_packet_size = HCD_LS_MAXPACKETSIZE; - else + if (HCD_SPEED_HIGH == this_device->speed) this_device->max_packet_size = HCD_HS_MAXPACKETSIZE; + else + this_device->max_packet_size = HCD_LS_MAXPACKETSIZE; /* Get device descriptor */ if (EXIT_SUCCESS != hcd_get_device_descriptor(this_device)) { @@ -725,8 +725,8 @@ hcd_setup_packet(hcd_device_state * this_device, hcd_ctrlrequest * setup, current_byte += rx_len; this_device->control_len += rx_len; - /* If full max sized packet was read... */ - if (rx_len == (int)this_device->max_packet_size) + /* If max sized packet was read (or more)... */ + if (rx_len >= (int)this_device->max_packet_size) /* ...try reading next packet even if * zero bytes may be received */ continue; @@ -811,7 +811,9 @@ hcd_finish_setup(hcd_device_state * this_device, void * output, if (HCD_ANY_LENGTH != expected) { /* ...check for expected length */ if ((hcd_reg4)this_device->control_len != expected) { - USB_MSG("Control transfer output length mismatch"); + USB_MSG("Control transfer output length mismatch:" + "len %d, expected %u", this_device->control_len, + expected); return EXIT_FAILURE; } diff --git a/minix/drivers/usb/usbd/hcd/hcd_common.c b/minix/drivers/usb/usbd/hcd/hcd_common.c index 562496612..6c3b73bf5 100644 --- a/minix/drivers/usb/usbd/hcd/hcd_common.c +++ b/minix/drivers/usb/usbd/hcd/hcd_common.c @@ -13,9 +13,9 @@ #include /* clkconf_* */ #include /* sys_privctl */ -#include -#include -#include +#include +#include +#include /*===========================================================================* @@ -210,9 +210,6 @@ hcd_connect_device(hcd_device_state * this_device, hcd_thread_function funct) return EXIT_FAILURE; } - /* Allow device thread to work */ - ddekit_yield(); - return EXIT_SUCCESS; } diff --git a/minix/drivers/usb/usbd/hcd/hcd_ddekit.c b/minix/drivers/usb/usbd/hcd/hcd_ddekit.c index 0606c20df..75b39e608 100644 --- a/minix/drivers/usb/usbd/hcd/hcd_ddekit.c +++ b/minix/drivers/usb/usbd/hcd/hcd_ddekit.c @@ -6,9 +6,9 @@ #include -#include -#include -#include +#include +#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/hcd/musb/musb_am335x.c b/minix/drivers/usb/usbd/hcd/musb/musb_am335x.c index 4c419904d..824abe69f 100644 --- a/minix/drivers/usb/usbd/hcd/musb/musb_am335x.c +++ b/minix/drivers/usb/usbd/hcd/musb/musb_am335x.c @@ -4,10 +4,10 @@ #include /* memset */ -#include -#include -#include -#include +#include +#include +#include +#include #include "musb_core.h" diff --git a/minix/drivers/usb/usbd/hcd/musb/musb_core.c b/minix/drivers/usb/usbd/hcd/musb/musb_core.c index 2b6c61da3..2232e1584 100644 --- a/minix/drivers/usb/usbd/hcd/musb/musb_core.c +++ b/minix/drivers/usb/usbd/hcd/musb/musb_core.c @@ -4,9 +4,9 @@ #include /* memcpy */ -#include -#include -#include +#include +#include +#include #include "musb_core.h" #include "musb_regs.h" @@ -408,9 +408,14 @@ musb_reset_device(void * cfg, hcd_speed * speed) USB_DBG("High speed USB enabled"); } else { /* Only full-speed supported */ - USB_DBG("High speed USB disabled"); + host_type0 = HCD_RD1(r, MUSB_REG_HOST_TYPE0); + HCD_CLR(host_type0, MUSB_VAL_HOST_TYPE0_MASK); + HCD_SET(host_type0, MUSB_VAL_HOST_TYPE0_FULL_SPEED); + HCD_WR1(r, MUSB_REG_HOST_TYPE0, host_type0); *speed = HCD_SPEED_FULL; + + USB_DBG("High speed USB disabled"); } return EXIT_SUCCESS; diff --git a/minix/drivers/usb/usbd/hcd/musb/musb_core.h b/minix/drivers/usb/usbd/hcd/musb/musb_core.h index 48f5d0bdb..09bd174b6 100644 --- a/minix/drivers/usb/usbd/hcd/musb/musb_core.h +++ b/minix/drivers/usb/usbd/hcd/musb/musb_core.h @@ -5,7 +5,7 @@ #ifndef _MUSB_CORE_H_ #define _MUSB_CORE_H_ -#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/hcd/musb/musb_regs.h b/minix/drivers/usb/usbd/hcd/musb/musb_regs.h index 02028a0f5..49348302f 100644 --- a/minix/drivers/usb/usbd/hcd/musb/musb_regs.h +++ b/minix/drivers/usb/usbd/hcd/musb/musb_regs.h @@ -5,7 +5,7 @@ #ifndef _MUSB_REGS_H_ #define _MUSB_REGS_H_ -#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/include/usb/hcd_common.h b/minix/drivers/usb/usbd/include/usbd/hcd_common.h similarity index 98% rename from minix/drivers/usb/usbd/include/usb/hcd_common.h rename to minix/drivers/usb/usbd/include/usbd/hcd_common.h index 72a55b9f1..09c155684 100644 --- a/minix/drivers/usb/usbd/include/usb/hcd_common.h +++ b/minix/drivers/usb/usbd/include/usbd/hcd_common.h @@ -263,8 +263,8 @@ struct hcd_device_state { #define HCD_SET_CONFIG_NUM(num) ((num)+0x01u) /* Default MaxPacketSize for control transfer */ -#define HCD_LS_MAXPACKETSIZE 8u -#define HCD_HS_MAXPACKETSIZE 64u +#define HCD_LS_MAXPACKETSIZE 8u /* Low-speed, Full-speed */ +#define HCD_HS_MAXPACKETSIZE 64u /* High-speed */ #define HCD_MAX_MAXPACKETSIZE 1024u diff --git a/minix/drivers/usb/usbd/include/usb/hcd_ddekit.h b/minix/drivers/usb/usbd/include/usbd/hcd_ddekit.h similarity index 94% rename from minix/drivers/usb/usbd/include/usb/hcd_ddekit.h rename to minix/drivers/usb/usbd/include/usbd/hcd_ddekit.h index 446e9cd5c..b51365173 100644 --- a/minix/drivers/usb/usbd/include/usb/hcd_ddekit.h +++ b/minix/drivers/usb/usbd/include/usbd/hcd_ddekit.h @@ -5,7 +5,7 @@ #ifndef _HCD_DDEKIT_H_ #define _HCD_DDEKIT_H_ -#include +#include /*===========================================================================* * External declarations * diff --git a/minix/drivers/usb/usbd/include/usb/hcd_interface.h b/minix/drivers/usb/usbd/include/usbd/hcd_interface.h similarity index 98% rename from minix/drivers/usb/usbd/include/usb/hcd_interface.h rename to minix/drivers/usb/usbd/include/usbd/hcd_interface.h index 66a92665b..b3c887d3d 100644 --- a/minix/drivers/usb/usbd/include/usb/hcd_interface.h +++ b/minix/drivers/usb/usbd/include/usbd/hcd_interface.h @@ -8,7 +8,7 @@ #ifndef _HCD_INTERFACE_H_ #define _HCD_INTERFACE_H_ -#include +#include /*===========================================================================* diff --git a/minix/drivers/usb/usbd/include/usb/hcd_platforms.h b/minix/drivers/usb/usbd/include/usbd/hcd_platforms.h similarity index 100% rename from minix/drivers/usb/usbd/include/usb/hcd_platforms.h rename to minix/drivers/usb/usbd/include/usbd/hcd_platforms.h diff --git a/minix/drivers/usb/usbd/include/usb/usb_common.h b/minix/drivers/usb/usbd/include/usbd/usbd_common.h similarity index 92% rename from minix/drivers/usb/usbd/include/usb/usb_common.h rename to minix/drivers/usb/usbd/include/usbd/usbd_common.h index 803699ec7..2cc6aa589 100644 --- a/minix/drivers/usb/usbd/include/usb/usb_common.h +++ b/minix/drivers/usb/usbd/include/usbd/usbd_common.h @@ -1,9 +1,9 @@ /* - * Whatever is commonly used throughout USB code + * Whatever is commonly used throughout USBD code */ -#ifndef _USB_COMMON_H_ -#define _USB_COMMON_H_ +#ifndef _USBD_COMMON_H_ +#define _USBD_COMMON_H_ /* For commonly used: NULL, EXIT_*, and stuff like that */ #include @@ -63,4 +63,4 @@ } while(0) -#endif /* !_USB_COMMON_H_ */ +#endif /* !_USBD_COMMON_H_ */ diff --git a/minix/drivers/usb/usbd/include/usb/usbd_interface.h b/minix/drivers/usb/usbd/include/usbd/usbd_interface.h similarity index 100% rename from minix/drivers/usb/usbd/include/usb/usbd_interface.h rename to minix/drivers/usb/usbd/include/usbd/usbd_interface.h