- URBs are enqueued in DDEKit but not in USBD itself
- DDEKit way of handling interface numbers is not explicitly defined, bitmask
formatting for it, is therefore hardcoded into USBD
+- Waiting for USB0 clock to leave IDLEST.Disable state, by nanosleep, was
+ removed, as this should be implemented for all clocks in clkconf_set
\ No newline at end of file
return EXIT_FAILURE;
}
- /* TODO: dynamic device address when more devices are available */
+ /* TODO: Dynamic device addressing should be added here, when more
+ * than one device can be handled at a time */
/* Set address */
if (EXIT_SUCCESS != hcd_set_address(this_device, HCD_ATTACHED_ADDR)) {
return EXIT_FAILURE;
}
- /* TODO: always first configuration */
+ /* TODO: Always use first configuration, as there is no support for
+ * multiple configurations in DDEKit/devman and devices rarely have
+ * more than one anyway */
/* Set configuration */
- if (EXIT_SUCCESS != hcd_set_configuration(this_device, 0x01)) {
+ if (EXIT_SUCCESS != hcd_set_configuration(this_device,
+ HCD_SET_CONFIG_NUM(HCD_DEFAULT_CONFIG))) {
USB_MSG("Failed to set configuration");
return EXIT_FAILURE;
}
completed = 0;
do {
- /* TODO: configuration 0 is hard-coded
+ /* TODO: Default configuration is hard-coded
* but others are rarely used anyway */
/* TODO: magic numbers, no header for these */
setup.bRequestType = 0x80; /* IN */
setup.bRequest = 0x06; /* Get descriptor */
- setup.wValue = 0x0200; /* Configuration 0 */
+ setup.wValue = 0x0200 | HCD_DEFAULT_CONFIG;
setup.wIndex = 0x0000;
setup.wLength = buffer_length;
}
} else {
- /* TODO: unimplemented */
- USB_MSG("Illegal non-zero length OUT setup packet");
+ /* TODO: Unimplemented OUT DATA stage */
+ d->out_data_stage(d->private_data);
+
return EXIT_FAILURE;
}
}
nanotm.tv_nsec = nanosec;
}
- /* TODO: since it is not likely to be ever interrupted, we do not try
+ /* TODO: Since it is not likely to be ever interrupted, we do not try
* to sleep for a remaining time in case of signal handling */
+ /* Signal handling will most likely end up with termination anyway */
USB_ASSERT(EXIT_SUCCESS == nanosleep(&nanotm, NULL),
"Calling nanosleep() failed");
}
hcd_tree_cleanup(&(this_device->config_tree));
- /* TODO: spilled resources */
+ /* TODO: Spilled resources */
+ /* DDEKit does no resource deallocation, when terminating thread */
ddekit_thread_terminate(this_device->thread);
ddekit_sem_deinit(this_device->lock);
#include "musb_core.h"
-/* TODO: BeagleBone white uses USB0 for PC connection as peripheral */
+/* TODO: BeagleBone white uses USB0 for PC connection as peripheral,
+ * so this is disabled by default */
+/* Should USB0 ever be used on BBB/BBW, one can change it to '#define': */
#undef AM335X_USE_USB0
* AM335x clocking register defines *
*===========================================================================*/
/* Clock module registers offsets */
-#define AM335X_CM_PER_BASE_OFFSET 0x00u
-#define AM335X_REG_CM_PER_USB0_CLKCTRL (AM335X_CM_PER_BASE_OFFSET + 28u)
+#define AM335X_REG_CM_PER_USB0_CLKCTRL_OFFSET 0x1Cu
/* Possible values to be set */
#define AM335X_VAL_CM_PER_USB0_CLKCTRL_MODULEMODE_ENABLE 0x2u
static void musb_am335x_internal_deinit(void);
/* Interrupt related */
-static void musb_am335x_irq_init(void *); /* TODO: required by DDEKit */
+static void musb_am335x_irq_init(void *);
static void musb_am335x_usbss_isr(void *);
static void musb_am335x_usbx_isr(void *);
static int musb_am335x_irqstat0_to_ep(int);
DEBUG_DUMP;
/* Configure clocking */
- if (hcd_os_clkconf(AM335X_REG_CM_PER_USB0_CLKCTRL,
+ if (hcd_os_clkconf(AM335X_REG_CM_PER_USB0_CLKCTRL_OFFSET,
AM335X_VAL_CM_PER_USB0_CLKCTRL_MODULEMODE_ENABLE,
AM335X_CLKCONF_FULL_VAL))
return EXIT_FAILURE;
- /* TODO: time to stabilize? */
- /* Sleep 25msec */
- hcd_os_nanosleep(HCD_NANOSLEEP_MSEC(25));
-
/* Read and dump revision register */
USB_MSG("MUSB revision (REVREG): %08X",
(unsigned int)HCD_RD4(am335x.ss.regs, AM335X_REG_REVREG));
musb_am335x_irq_init(void * UNUSED(unused))
{
DEBUG_DUMP;
+
+ /* TODO: This function does nothing and is not needed by MUSB but
+ * is still required by DDEKit for initialization, as NULL pointer
+ * cannot be passed to ddekit_interrupt_attach */
+ return;
}
irqstat0 = HCD_RD4(r, AM335X_REG_USBXIRQSTAT0);
irqstat1 = HCD_RD4(r, AM335X_REG_USBXIRQSTAT1);
- /* TODO: priority of interrupts */
+ /* Interrupts, seem to appear one at a time
+ * Check which bit is set to resolve event */
if (irqstat1 & AM335X_VAL_USBXIRQSTAT1_DRVVBUS) {
USB_DBG("DRVVBUS level changed");
CLEAR_IRQ1(AM335X_VAL_USBXIRQSTAT1_DRVVBUS);
r = ((musb_core_config *)cfg)->regs;
- /* TODO: add hardware interrupt disable */
+ /* Disable all interrupts */
+ HCD_WR1(r, MUSB_REG_INTRUSBE, MUSB_VAL_INTRUSBE_NONE);
/* Stop session */
devctl = HCD_RD1(r, MUSB_REG_DEVCTL);
/* Set EP and device address to be used in this command */
musb_set_state((musb_core_config *)cfg);
- /* TODO: not needed for enumeration but may be needed later */
- USB_MSG("Setup packet's 'DATA OUT' stage not implemented");
+ /* TODO: Not needed for enumeration but may be needed later, if
+ * additional control transfers are implemented */
+ USB_ASSERT(0, "Setup packet's 'DATA OUT' stage not implemented");
}
#define MUSB_VAL_INTRUSBE_DISCON HCD_BIT(5)
#define MUSB_VAL_INTRUSBE_SESSREQ HCD_BIT(6)
#define MUSB_VAL_INTRUSBE_VBUSERR HCD_BIT(7)
+#define MUSB_VAL_INTRUSBE_NONE 0x00u
/* HOST_TYPE0 */
#define MUSB_VAL_HOST_TYPE0_MASK (HCD_BIT(6) | HCD_BIT(7))
HCD_BIT(3))
/* HOST_RXINTERVAL/HOST_TXINTERVAL */
-/* TODO: Default NAK limit */
+/* Default NAK limit for non-control transfer
+ * When too big this may cause driver to wait for
+ * quite long in case of NAK error */
#define MUSB_VAL_HOST_XXINTERVAL_DEFAULT 0x10u
/* HOST_RXCSR */
#include <minix/usb.h> /* for setup structures */
#include <minix/usb_ch9.h> /* for descriptor structures */
+#include <sys/cdefs.h> /* for __aligned() */
+
/*===========================================================================*
* USB register handling defines *
/* Number of bytes received/transmitted in last transfer */
int data_len;
- /* TODO: forcefully align buffer to make things clear? */
- /* Buffer for each device to hold transfered data */
- hcd_reg1 buffer[MAX_WTOTALLENGTH];
+ /* Word aligned buffer for each device to hold transfered data */
+ hcd_reg1 buffer[MAX_WTOTALLENGTH] __aligned(sizeof(hcd_reg4));
}
hcd_device_state;
/* Default USB communication parameters */
#define HCD_DEFAULT_EP 0x00
#define HCD_DEFAULT_ADDR 0x00
+#define HCD_DEFAULT_CONFIG 0x00
-/* TODO: one device */
+/* TODO: One device only */
#define HCD_ATTACHED_ADDR 0x01
+/* Translates configuration number for 'set configuration' */
+#define HCD_SET_CONFIG_NUM(num) ((num)+0x01u)
+
/*===========================================================================*
* Operating system specific *