summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-12-21 21:01:56 +0100
committerWolfgang Denk <wd@denx.de>2009-12-21 21:01:56 +0100
commitf7767c7541a8cdae55655d10f039a5bc62894ee8 (patch)
treec559df77384b70faa52a3b1993c6587a37245fb8 /include
parentb6535daefd65c93ea429bc4728062379dda6e482 (diff)
parent127e10842b2474ac20e40572a4102dd4d5ed80f1 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-usb
Diffstat (limited to 'include')
-rw-r--r--include/configs/omap3_beagle.h16
-rw-r--r--include/configs/omap3_evm.h39
-rw-r--r--include/configs/omap3_zoom1.h16
-rw-r--r--include/configs/omap3_zoom2.h17
-rw-r--r--include/serial.h18
-rw-r--r--include/twl4030.h143
-rw-r--r--include/usb.h73
-rw-r--r--include/usb/musb_udc.h54
-rw-r--r--include/usbdescriptors.h26
-rw-r--r--include/usbdevice.h103
10 files changed, 428 insertions, 77 deletions
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index a6fe5e12b..4fe3bd8be 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -100,6 +100,21 @@
/* DDR - I use Micron DDR */
#define CONFIG_OMAP3_MICRON_DDR 1
+/* USB */
+#define CONFIG_MUSB_UDC 1
+#define CONFIG_USB_OMAP3 1
+#define CONFIG_TWL4030_USB 1
+
+/* USB device configuration */
+#define CONFIG_USB_DEVICE 1
+#define CONFIG_USB_TTY 1
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1
+/* Change these to suit your needs */
+#define CONFIG_USBD_VENDORID 0x0451
+#define CONFIG_USBD_PRODUCTID 0x5678
+#define CONFIG_USBD_MANUFACTURER "Texas Instruments"
+#define CONFIG_USBD_PRODUCT_NAME "Beagle"
+
/* commands to include */
#include <config_cmd_default.h>
@@ -164,6 +179,7 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
"loadaddr=0x82000000\0" \
+ "usbtty=cdc_acm\0" \
"console=ttyS2,115200n8\0" \
"vram=12M\0" \
"dvimode=1024x768MR-16@60\0" \
diff --git a/include/configs/omap3_evm.h b/include/configs/omap3_evm.h
index 00093f83d..630b00fae 100644
--- a/include/configs/omap3_evm.h
+++ b/include/configs/omap3_evm.h
@@ -104,6 +104,44 @@
/* DDR - I use Micron DDR */
#define CONFIG_OMAP3_MICRON_DDR 1
+/* USB
+ * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard
+ * Enable CONFIG_MUSB_UDD for Device functionalities.
+ */
+#define CONFIG_USB_OMAP3 1
+#define CONFIG_MUSB_HCD 1
+/* #define CONFIG_MUSB_UDC 1 */
+
+#ifdef CONFIG_USB_OMAP3
+
+#ifdef CONFIG_MUSB_HCD
+#define CONFIG_CMD_USB
+
+#define CONFIG_USB_STORAGE
+#define CONGIG_CMD_STORAGE
+#define CONFIG_CMD_FAT
+
+#ifdef CONFIG_USB_KEYBOARD
+#define CONFIG_SYS_USB_EVENT_POLL
+#define CONFIG_PREBOOT "usb start"
+#endif /* CONFIG_USB_KEYBOARD */
+
+#endif /* CONFIG_MUSB_HCD */
+
+#ifdef CONFIG_MUSB_UDC
+/* USB device configuration */
+#define CONFIG_USB_DEVICE 1
+#define CONFIG_USB_TTY 1
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1
+/* Change these to suit your needs */
+#define CONFIG_USBD_VENDORID 0x0451
+#define CONFIG_USBD_PRODUCTID 0x5678
+#define CONFIG_USBD_MANUFACTURER "Texas Instruments"
+#define CONFIG_USBD_PRODUCT_NAME "EVM"
+#endif /* CONFIG_MUSB_UDC */
+
+#endif /* CONFIG_USB_OMAP3 */
+
/* commands to include */
#include <config_cmd_default.h>
@@ -160,6 +198,7 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
"loadaddr=0x82000000\0" \
+ "usbtty=cdc_acm\0" \
"console=ttyS2,115200n8\0" \
"mmcargs=setenv bootargs console=${console} " \
"root=/dev/mmcblk0p2 rw " \
diff --git a/include/configs/omap3_zoom1.h b/include/configs/omap3_zoom1.h
index ef7a28bbc..fa5828159 100644
--- a/include/configs/omap3_zoom1.h
+++ b/include/configs/omap3_zoom1.h
@@ -101,6 +101,21 @@
/* DDR - I use Micron DDR */
#define CONFIG_OMAP3_MICRON_DDR 1
+/* USB */
+#define CONFIG_MUSB_UDC 1
+#define CONFIG_USB_OMAP3 1
+#define CONFIG_TWL4030_USB 1
+
+/* USB device configuration */
+#define CONFIG_USB_DEVICE 1
+#define CONFIG_USB_TTY 1
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV 1
+/* Change these to suit your needs */
+#define CONFIG_USBD_VENDORID 0x0451
+#define CONFIG_USBD_PRODUCTID 0x5678
+#define CONFIG_USBD_MANUFACTURER "Texas Instruments"
+#define CONFIG_USBD_PRODUCT_NAME "Zoom1"
+
/* commands to include */
#include <config_cmd_default.h>
@@ -160,6 +175,7 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
"loadaddr=0x82000000\0" \
+ "usbtty=cdc_acm\0" \
"console=ttyS2,115200n8\0" \
"videomode=1024x768@60,vxres=1024,vyres=768\0" \
"videospec=omapfb:vram:2M,vram:4M\0" \
diff --git a/include/configs/omap3_zoom2.h b/include/configs/omap3_zoom2.h
index 2b076666e..7a8beb850 100644
--- a/include/configs/omap3_zoom2.h
+++ b/include/configs/omap3_zoom2.h
@@ -125,6 +125,20 @@
#define CONFIG_OMAP3_GPIO_3 /* board revision */
#define CONFIG_OMAP3_GPIO_5 /* debug board detection, ZOOM2_LED_BLUE */
+/* USB */
+#define CONFIG_MUSB_UDC 1
+#define CONFIG_USB_OMAP3 1
+#define CONFIG_TWL4030_USB 1
+
+/* USB device configuration */
+#define CONFIG_USB_DEVICE 1
+#define CONFIG_USB_TTY 1
+/* Change these to suit your needs */
+#define CONFIG_USBD_VENDORID 0x0451
+#define CONFIG_USBD_PRODUCTID 0x5678
+#define CONFIG_USBD_MANUFACTURER "Texas Instruments"
+#define CONFIG_USBD_PRODUCT_NAME "Zoom2"
+
/* commands to include */
#include <config_cmd_default.h>
@@ -170,6 +184,9 @@
/* Environment information */
#define CONFIG_BOOTDELAY 10
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "usbtty=cdc_acm\0" \
+
/*
* Miscellaneous configurable options
*/
diff --git a/include/serial.h b/include/serial.h
index bbda3f08c..f2638ec56 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -66,4 +66,22 @@ extern void serial_stdio_init(void);
extern int serial_assign(char * name);
extern void serial_reinit_all(void);
+/* For usbtty */
+#ifdef CONFIG_USB_TTY
+
+extern int usbtty_getc(void);
+extern void usbtty_putc(const char c);
+extern void usbtty_puts(const char *str);
+extern int usbtty_tstc(void);
+
+#else
+
+/* stubs */
+#define usbtty_getc() 0
+#define usbtty_putc(a)
+#define usbtty_puts(a)
+#define usbtty_tstc() 0
+
+#endif /* CONFIG_USB_TTY */
+
#endif
diff --git a/include/twl4030.h b/include/twl4030.h
index f260ecb8b..feaec47b3 100644
--- a/include/twl4030.h
+++ b/include/twl4030.h
@@ -342,21 +342,129 @@
#define TWL4030_KEYPAD_CTRL_SOFT_NRST (1 << 0)
/* USB */
-#define TWL4030_USB_FUNC_CTRL (0x04)
-#define TWL4030_USB_OPMODE_MASK (3 << 3)
-#define TWL4030_USB_XCVRSELECT_MASK (3 << 0)
-#define TWL4030_USB_IFC_CTRL (0x07)
-#define TWL4030_USB_CARKITMODE (1 << 2)
-#define TWL4030_USB_POWER_CTRL (0xAC)
-#define TWL4030_USB_OTG_ENAB (1 << 5)
-#define TWL4030_USB_PHY_PWR_CTRL (0xFD)
-#define TWL4030_USB_PHYPWD (1 << 0)
-#define TWL4030_USB_PHY_CLK_CTRL (0xFE)
-#define TWL4030_USB_CLOCKGATING_EN (1 << 2)
-#define TWL4030_USB_CLK32K_EN (1 << 1)
-#define TWL4030_USB_REQ_PHY_DPLL_CLK (1 << 0)
-#define TWL4030_USB_PHY_CLK_CTRL_STS (0xFF)
-#define TWL4030_USB_PHY_DPLL_CLK (1 << 0)
+#define TWL4030_USB_VENDOR_ID_LO 0x00
+#define TWL4030_USB_VENDOR_ID_HI 0x01
+#define TWL4030_USB_PRODUCT_ID_LO 0x02
+#define TWL4030_USB_PRODUCT_ID_HI 0x03
+#define TWL4030_USB_FUNC_CTRL 0x04
+#define TWL4030_USB_FUNC_CTRL_SET 0x05
+#define TWL4030_USB_FUNC_CTRL_CLR 0x06
+#define TWL4030_USB_IFC_CTRL 0x07
+#define TWL4030_USB_IFC_CTRL_SET 0x08
+#define TWL4030_USB_IFC_CTRL_CLR 0x09
+#define TWL4030_USB_OTG_CTRL 0x0A
+#define TWL4030_USB_OTG_CTRL_SET 0x0B
+#define TWL4030_USB_OTG_CTRL_CLR 0x0C
+#define TWL4030_USB_USB_INT_EN_RISE 0x0D
+#define TWL4030_USB_USB_INT_EN_RISE_SET 0x0E
+#define TWL4030_USB_USB_INT_EN_RISE_CLR 0x0F
+#define TWL4030_USB_USB_INT_EN_FALL 0x10
+#define TWL4030_USB_USB_INT_EN_FALL_SET 0x11
+#define TWL4030_USB_USB_INT_EN_FALL_CLR 0x12
+#define TWL4030_USB_USB_INT_STS 0x13
+#define TWL4030_USB_USB_INT_LATCH 0x14
+#define TWL4030_USB_DEBUG 0x15
+#define TWL4030_USB_SCRATCH_REG 0x16
+#define TWL4030_USB_SCRATCH_REG_SET 0x17
+#define TWL4030_USB_SCRATCH_REG_CLR 0x18
+#define TWL4030_USB_CARKIT_CTRL 0x19
+#define TWL4030_USB_CARKIT_CTRL_SET 0x1A
+#define TWL4030_USB_CARKIT_CTRL_CLR 0x1B
+#define TWL4030_USB_CARKIT_INT_DELAY 0x1C
+#define TWL4030_USB_CARKIT_INT_EN 0x1D
+#define TWL4030_USB_CARKIT_INT_EN_SET 0x1E
+#define TWL4030_USB_CARKIT_INT_EN_CLR 0x1F
+#define TWL4030_USB_CARKIT_INT_STS 0x20
+#define TWL4030_USB_CARKIT_INT_LATCH 0x21
+#define TWL4030_USB_CARKIT_PLS_CTRL 0x22
+#define TWL4030_USB_CARKIT_PLS_CTRL_SET 0x23
+#define TWL4030_USB_CARKIT_PLS_CTRL_CLR 0x24
+#define TWL4030_USB_TRANS_POS_WIDTH 0x25
+#define TWL4030_USB_TRANS_NEG_WIDTH 0x26
+#define TWL4030_USB_RCV_PLTY_RECOVERY 0x27
+#define TWL4030_USB_MCPC_CTRL 0x30
+#define TWL4030_USB_MCPC_CTRL_SET 0x31
+#define TWL4030_USB_MCPC_CTRL_CLR 0x32
+#define TWL4030_USB_MCPC_IO_CTRL 0x33
+#define TWL4030_USB_MCPC_IO_CTRL_SET 0x34
+#define TWL4030_USB_MCPC_IO_CTRL_CLR 0x35
+#define TWL4030_USB_MCPC_CTRL2 0x36
+#define TWL4030_USB_MCPC_CTRL2_SET 0x37
+#define TWL4030_USB_MCPC_CTRL2_CLR 0x38
+#define TWL4030_USB_OTHER_FUNC_CTRL 0x80
+#define TWL4030_USB_OTHER_FUNC_CTRL_SET 0x81
+#define TWL4030_USB_OTHER_FUNC_CTRL_CLR 0x82
+#define TWL4030_USB_OTHER_IFC_CTRL 0x83
+#define TWL4030_USB_OTHER_IFC_CTRL_SET 0x84
+#define TWL4030_USB_OTHER_IFC_CTRL_CLR 0x85
+#define TWL4030_USB_OTHER_INT_EN_RISE_SET 0x87
+#define TWL4030_USB_OTHER_INT_EN_RISE_CLR 0x88
+#define TWL4030_USB_OTHER_INT_EN_FALL 0x89
+#define TWL4030_USB_OTHER_INT_EN_FALL_SET 0x8A
+#define TWL4030_USB_OTHER_INT_EN_FALL_CLR 0x8B
+#define TWL4030_USB_OTHER_INT_STS 0x8C
+#define TWL4030_USB_OTHER_INT_LATCH 0x8D
+#define TWL4030_USB_ID_STATUS 0x96
+#define TWL4030_USB_CARKIT_SM_1_INT_EN 0x97
+#define TWL4030_USB_CARKIT_SM_1_INT_EN_SET 0x98
+#define TWL4030_USB_CARKIT_SM_1_INT_EN_CLR 0x99
+#define TWL4030_USB_CARKIT_SM_1_INT_STS 0x9A
+#define TWL4030_USB_CARKIT_SM_1_INT_LATCH 0x9B
+#define TWL4030_USB_CARKIT_SM_2_INT_EN 0x9C
+#define TWL4030_USB_CARKIT_SM_2_INT_EN_SET 0x9D
+#define TWL4030_USB_CARKIT_SM_2_INT_EN_CLR 0x9E
+#define TWL4030_USB_CARKIT_SM_2_INT_STS 0x9F
+#define TWL4030_USB_CARKIT_SM_2_INT_LATCH 0xA0
+#define TWL4030_USB_CARKIT_SM_CTRL 0xA1
+#define TWL4030_USB_CARKIT_SM_CTRL_SET 0xA2
+#define TWL4030_USB_CARKIT_SM_CTRL_CLR 0xA3
+#define TWL4030_USB_CARKIT_SM_CMD 0xA4
+#define TWL4030_USB_CARKIT_SM_CMD_SET 0xA5
+#define TWL4030_USB_CARKIT_SM_CMD_CLR 0xA6
+#define TWL4030_USB_CARKIT_SM_CMD_STS 0xA7
+#define TWL4030_USB_CARKIT_SM_STATUS 0xA8
+#define TWL4030_USB_CARKIT_SM_ERR_STATUS 0xAA
+#define TWL4030_USB_CARKIT_SM_CTRL_STATE 0xAB
+#define TWL4030_USB_POWER_CTRL 0xAC
+#define TWL4030_USB_POWER_CTRL_SET 0xAD
+#define TWL4030_USB_POWER_CTRL_CLR 0xAE
+#define TWL4030_USB_OTHER_IFC_CTRL2 0xAF
+#define TWL4030_USB_OTHER_IFC_CTRL2_SET 0xB0
+#define TWL4030_USB_OTHER_IFC_CTRL2_CLR 0xB1
+#define TWL4030_USB_REG_CTRL_EN 0xB2
+#define TWL4030_USB_REG_CTRL_EN_SET 0xB3
+#define TWL4030_USB_REG_CTRL_EN_CLR 0xB4
+#define TWL4030_USB_REG_CTRL_ERROR 0xB5
+#define TWL4030_USB_OTHER_FUNC_CTRL2 0xB8
+#define TWL4030_USB_OTHER_FUNC_CTRL2_SET 0xB9
+#define TWL4030_USB_OTHER_FUNC_CTRL2_CLR 0xBA
+#define TWL4030_USB_CARKIT_ANA_CTRL 0xBB
+#define TWL4030_USB_CARKIT_ANA_CTRL_SET 0xBC
+#define TWL4030_USB_CARKIT_ANA_CTRL_CLR 0xBD
+#define TWL4030_USB_VBUS_DEBOUNCE 0xC0
+#define TWL4030_USB_ID_DEBOUNCE 0xC1
+#define TWL4030_USB_TPH_DP_CON_MIN 0xC2
+#define TWL4030_USB_TPH_DP_CON_MAX 0xC3
+#define TWL4030_USB_TCR_DP_CON_MIN 0xC4
+#define TWL4030_USB_TCR_DP_CON_MAX 0xC5
+#define TWL4030_USB_TPH_DP_PD_SHORT 0xC6
+#define TWL4030_USB_TPH_CMD_DLY 0xC7
+#define TWL4030_USB_TPH_DET_RST 0xC8
+#define TWL4030_USB_TPH_AUD_BIAS 0xC9
+#define TWL4030_USB_TCR_UART_DET_MIN 0xCA
+#define TWL4030_USB_TCR_UART_DET_MAX 0xCB
+#define TWL4030_USB_TPH_ID_INT_PW 0xCD
+#define TWL4030_USB_TACC_ID_INT_WAIT 0xCE
+#define TWL4030_USB_TACC_ID_INT_PW 0xCF
+#define TWL4030_USB_TPH_CMD_WAIT 0xD0
+#define TWL4030_USB_TPH_ACK_WAIT 0xD1
+#define TWL4030_USB_TPH_DP_DISC_DET 0xD2
+#define TWL4030_USB_VBAT_TIMER 0xD3
+#define TWL4030_USB_CARKIT_4W_DEBUG 0xE0
+#define TWL4030_USB_CARKIT_5W_DEBUG 0xE1
+#define TWL4030_USB_PHY_PWR_CTRL 0xFD
+#define TWL4030_USB_PHY_CLK_CTRL 0xFE
+#define TWL4030_USB_PHY_CLK_CTRL_STS 0xFF
/*
* Convience functions to read and write from TWL4030
@@ -398,4 +506,9 @@ void twl4030_power_mmc_init(void);
*/
void twl4030_led_init(void);
+/*
+ * USB
+ */
+int twl4030_usb_ulpi_init(void);
+
#endif /* TWL4030_H */
diff --git a/include/usb.h b/include/usb.h
index 7c47098d8..1cc3e4229 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -27,6 +27,7 @@
#define _USB_H_
#include <usb_defs.h>
+#include <usbdescriptors.h>
/* Everything is aribtrary */
#define USB_ALTSETTINGALLOC 4
@@ -41,13 +42,6 @@
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
-/* String descriptor */
-struct usb_string_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short wData[1];
-} __attribute__ ((packed));
-
/* device request (setup) */
struct devrequest {
unsigned char requesttype;
@@ -63,47 +57,9 @@ struct usb_descriptor_header {
unsigned char bDescriptorType;
} __attribute__ ((packed));
-/* Device descriptor */
-struct usb_device_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short bcdUSB;
- unsigned char bDeviceClass;
- unsigned char bDeviceSubClass;
- unsigned char bDeviceProtocol;
- unsigned char bMaxPacketSize0;
- unsigned short idVendor;
- unsigned short idProduct;
- unsigned short bcdDevice;
- unsigned char iManufacturer;
- unsigned char iProduct;
- unsigned char iSerialNumber;
- unsigned char bNumConfigurations;
-} __attribute__ ((packed));
-
-/* Endpoint descriptor */
-struct usb_endpoint_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned char bEndpointAddress;
- unsigned char bmAttributes;
- unsigned short wMaxPacketSize;
- unsigned char bInterval;
- unsigned char bRefresh;
- unsigned char bSynchAddress;
-} __attribute__ ((packed)) __attribute__ ((aligned(2)));
-
-/* Interface descriptor */
-struct usb_interface_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned char bInterfaceNumber;
- unsigned char bAlternateSetting;
- unsigned char bNumEndpoints;
- unsigned char bInterfaceClass;
- unsigned char bInterfaceSubClass;
- unsigned char bInterfaceProtocol;
- unsigned char iInterface;
+/* Interface */
+struct usb_interface {
+ struct usb_interface_descriptor desc;
unsigned char no_of_ep;
unsigned char num_altsetting;
@@ -112,20 +68,12 @@ struct usb_interface_descriptor {
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
} __attribute__ ((packed));
-
-/* Configuration descriptor information.. */
-struct usb_config_descriptor {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short wTotalLength;
- unsigned char bNumInterfaces;
- unsigned char bConfigurationValue;
- unsigned char iConfiguration;
- unsigned char bmAttributes;
- unsigned char MaxPower;
+/* Configuration information.. */
+struct usb_config {
+ struct usb_configuration_descriptor desc;
unsigned char no_of_if; /* number of interfaces */
- struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
+ struct usb_interface if_desc[USB_MAXINTERFACES];
} __attribute__ ((packed));
enum {
@@ -156,7 +104,7 @@ struct usb_device {
int configno; /* selected config number */
struct usb_device_descriptor descriptor; /* Device Descriptor */
- struct usb_config_descriptor config; /* config descriptor */
+ struct usb_config config; /* config descriptor */
int have_langid; /* whether string_langid is valid yet */
int string_langid; /* language ID for strings */
@@ -183,7 +131,8 @@ struct usb_device {
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || \
defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_OHCI_NEW) || \
defined(CONFIG_USB_SL811HS) || defined(CONFIG_USB_ISP116X_HCD) || \
- defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI)
+ defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI) || \
+ defined(CONFIG_USB_OMAP3)
int usb_lowlevel_init(void);
int usb_lowlevel_stop(void);
diff --git a/include/usb/musb_udc.h b/include/usb/musb_udc.h
new file mode 100644
index 000000000..ef37dbbcc
--- /dev/null
+++ b/include/usb/musb_udc.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009 Wind River Systems, Inc.
+ * Tom Rix <Tom.Rix@windriver.com>
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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 __MUSB_UDC_H__
+#define __MUSB_UDC_H__
+
+#include <usbdevice.h>
+
+/* UDC level routines */
+void udc_irq(void);
+void udc_set_nak(int ep_num);
+void udc_unset_nak(int ep_num);
+int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
+void udc_setup_ep(struct usb_device_instance *device, unsigned int id,
+ struct usb_endpoint_instance *endpoint);
+void udc_connect(void);
+void udc_disconnect(void);
+void udc_enable(struct usb_device_instance *device);
+void udc_disable(void);
+void udc_startup_events(struct usb_device_instance *device);
+int udc_init(void);
+
+/* usbtty */
+#ifdef CONFIG_USB_TTY
+
+#define EP0_MAX_PACKET_SIZE 64 /* MUSB_EP0_FIFOSIZE */
+#define UDC_INT_ENDPOINT 1
+#define UDC_INT_PACKET_SIZE 64
+#define UDC_OUT_ENDPOINT 2
+#define UDC_OUT_PACKET_SIZE 64
+#define UDC_IN_ENDPOINT 3
+#define UDC_IN_PACKET_SIZE 64
+#define UDC_BULK_PACKET_SIZE 64
+
+#endif /* CONFIG_USB_TTY */
+
+#endif /* __MUSB_UDC_H__ */
+
diff --git a/include/usbdescriptors.h b/include/usbdescriptors.h
index a752097e5..2dec3b93d 100644
--- a/include/usbdescriptors.h
+++ b/include/usbdescriptors.h
@@ -504,4 +504,30 @@ struct usb_class_descriptor {
} __attribute__ ((packed));
+#ifdef DEBUG
+static inline void print_device_descriptor(struct usb_device_descriptor *d)
+{
+ serial_printf("usb device descriptor \n");
+ serial_printf("\tbLength %2.2x\n", d->bLength);
+ serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
+ serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
+ serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
+ serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
+ serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
+ serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
+ serial_printf("\tidVendor %4.4x\n", d->idVendor);
+ serial_printf("\tidProduct %4.4x\n", d->idProduct);
+ serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
+ serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
+ serial_printf("\tiProduct %2.2x\n", d->iProduct);
+ serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
+ serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
+}
+
+#else
+
+/* stubs */
+#define print_device_descriptor(d)
+
+#endif /* DEBUG */
#endif
diff --git a/include/usbdevice.h b/include/usbdevice.h
index 206dbbc86..41716364b 100644
--- a/include/usbdevice.h
+++ b/include/usbdevice.h
@@ -663,4 +663,107 @@ int usbd_endpoint_halted (struct usb_device_instance *device, int endpoint);
void usbd_rcv_complete(struct usb_endpoint_instance *endpoint, int len, int urb_bad);
void usbd_tx_complete (struct usb_endpoint_instance *endpoint);
+/* These are macros used in debugging */
+#ifdef DEBUG
+static inline void print_urb(struct urb *u)
+{
+ serial_printf("urb %p\n", (u));
+ serial_printf("\tendpoint %p\n", u->endpoint);
+ serial_printf("\tdevice %p\n", u->device);
+ serial_printf("\tbuffer %p\n", u->buffer);
+ serial_printf("\tbuffer_length %d\n", u->buffer_length);
+ serial_printf("\tactual_length %d\n", u->actual_length);
+ serial_printf("\tstatus %d\n", u->status);
+ serial_printf("\tdata %d\n", u->data);
+}
+
+static inline void print_usb_device_request(struct usb_device_request *r)
+{
+ serial_printf("usb request\n");
+ serial_printf("\tbmRequestType 0x%2.2x\n", r->bmRequestType);
+ if ((r->bmRequestType & USB_REQ_DIRECTION_MASK) == 0)
+ serial_printf("\t\tDirection : To device\n");
+ else
+ serial_printf("\t\tDirection : To host\n");
+ if ((r->bmRequestType & USB_TYPE_STANDARD) == USB_TYPE_STANDARD)
+ serial_printf("\t\tType : Standard\n");
+ if ((r->bmRequestType & USB_TYPE_CLASS) == USB_TYPE_CLASS)
+ serial_printf("\t\tType : Standard\n");
+ if ((r->bmRequestType & USB_TYPE_VENDOR) == USB_TYPE_VENDOR)
+ serial_printf("\t\tType : Standard\n");
+ if ((r->bmRequestType & USB_TYPE_RESERVED) == USB_TYPE_RESERVED)
+ serial_printf("\t\tType : Standard\n");
+ if ((r->bmRequestType & USB_REQ_RECIPIENT_MASK) ==
+ USB_REQ_RECIPIENT_DEVICE)
+ serial_printf("\t\tRecipient : Device\n");
+ if ((r->bmRequestType & USB_REQ_RECIPIENT_MASK) ==
+ USB_REQ_RECIPIENT_INTERFACE)
+ serial_printf("\t\tRecipient : Interface\n");
+ if ((r->bmRequestType & USB_REQ_RECIPIENT_MASK) ==
+ USB_REQ_RECIPIENT_ENDPOINT)
+ serial_printf("\t\tRecipient : Endpoint\n");
+ if ((r->bmRequestType & USB_REQ_RECIPIENT_MASK) ==
+ USB_REQ_RECIPIENT_OTHER)
+ serial_printf("\t\tRecipient : Other\n");
+ serial_printf("\tbRequest 0x%2.2x\n", r->bRequest);
+ if (r->bRequest == USB_REQ_GET_STATUS)
+ serial_printf("\t\tGET_STATUS\n");
+ else if (r->bRequest == USB_REQ_SET_ADDRESS)
+ serial_printf("\t\tSET_ADDRESS\n");
+ else if (r->bRequest == USB_REQ_SET_FEATURE)
+ serial_printf("\t\tSET_FEATURE\n");
+ else if (r->bRequest == USB_REQ_GET_DESCRIPTOR)
+ serial_printf("\t\tGET_DESCRIPTOR\n");
+ else if (r->bRequest == USB_REQ_SET_CONFIGURATION)
+ serial_printf("\t\tSET_CONFIGURATION\n");
+ else if (r->bRequest == USB_REQ_SET_INTERFACE)
+ serial_printf("\t\tUSB_REQ_SET_INTERFACE\n");
+ else
+ serial_printf("\tUNKNOWN %d\n", r->bRequest);
+ serial_printf("\twValue 0x%4.4x\n", r->wValue);
+ if (r->bRequest == USB_REQ_GET_DESCRIPTOR) {
+ switch (r->wValue >> 8) {
+ case USB_DESCRIPTOR_TYPE_DEVICE:
+ serial_printf("\tDEVICE\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_CONFIGURATION:
+ serial_printf("\tCONFIGURATION\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_STRING:
+ serial_printf("\tSTRING\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_INTERFACE:
+ serial_printf("\tINTERFACE\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_ENDPOINT:
+ serial_printf("\tENDPOINT\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
+ serial_printf("\tDEVICE_QUALIFIER\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION:
+ serial_printf("\tOTHER_SPEED_CONFIGURATION\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_INTERFACE_POWER:
+ serial_printf("\tINTERFACE_POWER\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_HID:
+ serial_printf("\tHID\n");
+ break;
+ case USB_DESCRIPTOR_TYPE_REPORT:
+ serial_printf("\tREPORT\n");
+ break;
+ default:
+ serial_printf("\tUNKNOWN TYPE\n");
+ break;
+ }
+ }
+ serial_printf("\twIndex 0x%4.4x\n", r->wIndex);
+ serial_printf("\twLength 0x%4.4x\n", r->wLength);
+}
+#else
+/* stubs */
+#define print_urb(u)
+#define print_usb_device_request(r)
+#endif /* DEBUG */
#endif