summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/arcotg_udc.h318
-rw-r--r--firmware/export/config-c200.h6
-rw-r--r--firmware/export/config-e200.h7
-rw-r--r--firmware/export/config-h10.h6
-rw-r--r--firmware/export/config-h10_5gb.h6
-rw-r--r--firmware/export/linkedlist.h355
-rw-r--r--firmware/export/pp5020.h2
-rw-r--r--firmware/export/usb.h2
-rw-r--r--firmware/export/usb_core.h55
-rw-r--r--firmware/export/usb_drv.h35
-rw-r--r--firmware/export/usbstack.h63
11 files changed, 104 insertions, 751 deletions
diff --git a/firmware/export/arcotg_udc.h b/firmware/export/arcotg_udc.h
deleted file mode 100644
index e016321b37..0000000000
--- a/firmware/export/arcotg_udc.h
+++ /dev/null
@@ -1,318 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Barry Wardell
- *
- * ARC OTG USB device driver based on code from the Linux Target Image Builder
- * from Freescale - http://www.bitshrine.org/ and
- * http://www.bitshrine.org/gpp/linux-2.6.16-mx31-usb-2.patch
- * Adapted for Rockbox in January 2007
- * Original file: drivers/usb/gadget/arcotg_udc.h
- *
- * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
- *
- * Based on mpc-udc.h
- * Author: Li Yang (leoli@freescale.com)
- * Jiang Bo (Tanya.jiang@freescale.com)
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-/*
- * Freescale USB device/endpoint management registers
- */
-#ifndef __ARCOTG_UDC_H
-#define __ARCOTG_UDC_H
-
-#include "cpu.h"
-
-#define USB_MAX_ENDPOINTS 8
-#define USB_MAX_PIPES (USB_MAX_ENDPOINTS*2)
-#define USB_MAX_CTRL_PAYLOAD 64
-
-/* USB DR device mode registers (Little Endian) */
-/* Identification registers */
-#define UDC_ID (*(volatile unsigned int *)(USB_BASE+0x000))
-#define UDC_HWGENERAL (*(volatile unsigned int *)(USB_BASE+0x004))
-#define UDC_HWHOST (*(volatile unsigned int *)(USB_BASE+0x008))
-#define UDC_HWTXBUF (*(volatile unsigned int *)(USB_BASE+0x010))
-#define UDC_HWRXBUF (*(volatile unsigned int *)(USB_BASE+0x014))
-
-/* Capability registers */
-#define UDC_CAPLENGTH (*(volatile unsigned char *)(USB_BASE+0x100)) /* Capability Register Length */
-#define UDC_HCIVERSION (*(volatile unsigned short *)(USB_BASE+0x102)) /* Host Controller Interface Version */
-#define UDC_HCSPARAMS (*(volatile unsigned int *)(USB_BASE+0x104)) /* Host Controller Structual Parameters */
-#define UDC_HCCPARAMS (*(volatile unsigned int *)(USB_BASE+0x108)) /* Host Controller Capability Parameters */
-#define UDC_DCIVERSION (*(volatile unsigned short *)(USB_BASE+0x120)) /* Device Controller Interface Version */
-#define UDC_DCCPARAMS (*(volatile unsigned int *)(USB_BASE+0x124)) /* Device Controller Capability Parameters */
-
-/* Operation registers */
-#define UDC_USBCMD (*(volatile unsigned int *)(USB_BASE+0x140)) /* USB Command Register */
-#define UDC_USBSTS (*(volatile unsigned int *)(USB_BASE+0x144)) /* USB Status Register */
-#define UDC_USBINTR (*(volatile unsigned int *)(USB_BASE+0x148)) /* USB Interrupt Enable Register */
-#define UDC_FRINDEX (*(volatile unsigned int *)(USB_BASE+0x14c)) /* Frame Index Register */
-#define UDC_DEVICEADDR (*(volatile unsigned int *)(USB_BASE+0x154)) /* Device Address */
-#define UDC_ENDPOINTLISTADDR (*(volatile unsigned int *)(USB_BASE+0x158)) /* Endpoint List Address Register */
-#define UDC_BURSTSIZE (*(volatile unsigned int *)(USB_BASE+0x160)) /* Master Interface Data Burst Size Register */
-#define UDC_TXFILLTUNING (*(volatile unsigned int *)(USB_BASE+0x164)) /* Transmit FIFO Tuning Controls Register */
-#define UDC_ULPIVIEW (*(volatile unsigned int *)(USB_BASE+0x170))
-#define UDC_CFGFLAG (*(volatile unsigned int *)(USB_BASE+0x180)) /* Configure Flag Register */
-#define UDC_PORTSC1 (*(volatile unsigned int *)(USB_BASE+0x184)) /* Port 1 Status and Control Register */
-#define UDC_OTGSC (*(volatile unsigned int *)(USB_BASE+0x1a4)) /* On-The-Go Status and Control */
-#define UDC_USBMODE (*(volatile unsigned int *)(USB_BASE+0x1a8)) /* USB Mode Register */
-#define UDC_ENDPTSETUPSTAT (*(volatile unsigned int *)(USB_BASE+0x1ac)) /* Endpoint Setup Status Register */
-#define UDC_ENDPTPRIME (*(volatile unsigned int *)(USB_BASE+0x1b0)) /* Endpoint Initialization Register */
-#define UDC_ENDPTFLUSH (*(volatile unsigned int *)(USB_BASE+0x1b4)) /* Endpoint Flush Register */
-#define UDC_ENDPTSTAT (*(volatile unsigned int *)(USB_BASE+0x1b8)) /* Endpoint Status Register */
-#define UDC_ENDPTCOMPLETE (*(volatile unsigned int *)(USB_BASE+0x1bc)) /* Endpoint Complete Register */
-#define UDC_ENDPTCTRL0 (*(volatile unsigned int *)(USB_BASE+0x1c0)) /* Endpoint 0 Control Register */
-#define UDC_ENDPTCTRL1 (*(volatile unsigned int *)(USB_BASE+0x1c4)) /* Endpoint 1 Control Register */
-#define UDC_ENDPTCTRL2 (*(volatile unsigned int *)(USB_BASE+0x1c8)) /* Endpoint 2 Control Register */
-#define UDC_ENDPTCTRL3 (*(volatile unsigned int *)(USB_BASE+0x1cc)) /* Endpoint 3 Control Register */
-#define UDC_ENDPTCTRL4 (*(volatile unsigned int *)(USB_BASE+0x1d0)) /* Endpoint 4 Control Register */
-#define UDC_ENDPTCTRL5 (*(volatile unsigned int *)(USB_BASE+0x1d4)) /* Endpoint 5 Control Register */
-#define UDC_ENDPTCTRL6 (*(volatile unsigned int *)(USB_BASE+0x1d8)) /* Endpoint 6 Control Register */
-#define UDC_ENDPTCTRL7 (*(volatile unsigned int *)(USB_BASE+0x1dc)) /* Endpoint 7 Control Register */
-#define UDC_ENDPTCTRL(x) (*(volatile unsigned int *)(USB_BASE+0x1c0+4*(x))) /* Endpoint X Control Register */
-
-/* ep0 transfer state */
-#define WAIT_FOR_SETUP 0
-#define DATA_STATE_XMIT 1
-#define DATA_STATE_NEED_ZLP 2
-#define WAIT_FOR_OUT_STATUS 3
-#define DATA_STATE_RECV 4
-
-/* Frame Index Register Bit Masks */
-#define USB_FRINDEX_MASKS (0x3fff)
-
-/* USB CMD Register Bit Masks */
-#define USB_CMD_RUN (0x00000001)
-#define USB_CMD_CTRL_RESET (0x00000002)
-#define USB_CMD_PERIODIC_SCHEDULE_EN (0x00000010)
-#define USB_CMD_ASYNC_SCHEDULE_EN (0x00000020)
-#define USB_CMD_INT_AA_DOORBELL (0x00000040)
-#define USB_CMD_ASP (0x00000300)
-#define USB_CMD_ASYNC_SCH_PARK_EN (0x00000800)
-#define USB_CMD_SUTW (0x00002000)
-#define USB_CMD_ATDTW (0x00004000)
-#define USB_CMD_ITC (0x00FF0000)
-
-/* bit 15,3,2 are frame list size */
-#define USB_CMD_FRAME_SIZE_1024 (0x00000000)
-#define USB_CMD_FRAME_SIZE_512 (0x00000004)
-#define USB_CMD_FRAME_SIZE_256 (0x00000008)
-#define USB_CMD_FRAME_SIZE_128 (0x0000000C)
-#define USB_CMD_FRAME_SIZE_64 (0x00008000)
-#define USB_CMD_FRAME_SIZE_32 (0x00008004)
-#define USB_CMD_FRAME_SIZE_16 (0x00008008)
-#define USB_CMD_FRAME_SIZE_8 (0x0000800C)
-
-/* bit 9-8 are async schedule park mode count */
-#define USB_CMD_ASP_00 (0x00000000)
-#define USB_CMD_ASP_01 (0x00000100)
-#define USB_CMD_ASP_10 (0x00000200)
-#define USB_CMD_ASP_11 (0x00000300)
-#define USB_CMD_ASP_BIT_POS (8)
-
-/* bit 23-16 are interrupt threshold control */
-#define USB_CMD_ITC_NO_THRESHOLD (0x00000000)
-#define USB_CMD_ITC_1_MICRO_FRM (0x00010000)
-#define USB_CMD_ITC_2_MICRO_FRM (0x00020000)
-#define USB_CMD_ITC_4_MICRO_FRM (0x00040000)
-#define USB_CMD_ITC_8_MICRO_FRM (0x00080000)
-#define USB_CMD_ITC_16_MICRO_FRM (0x00100000)
-#define USB_CMD_ITC_32_MICRO_FRM (0x00200000)
-#define USB_CMD_ITC_64_MICRO_FRM (0x00400000)
-#define USB_CMD_ITC_BIT_POS (16)
-
-/* USB STS Register Bit Masks */
-#define USB_STS_INT (0x00000001)
-#define USB_STS_ERR (0x00000002)
-#define USB_STS_PORT_CHANGE (0x00000004)
-#define USB_STS_FRM_LST_ROLL (0x00000008)
-#define USB_STS_SYS_ERR (0x00000010)
-#define USB_STS_IAA (0x00000020)
-#define USB_STS_RESET (0x00000040)
-#define USB_STS_SOF (0x00000080)
-#define USB_STS_SUSPEND (0x00000100)
-#define USB_STS_HC_HALTED (0x00001000)
-#define USB_STS_RCL (0x00002000)
-#define USB_STS_PERIODIC_SCHEDULE (0x00004000)
-#define USB_STS_ASYNC_SCHEDULE (0x00008000)
-
-/* USB INTR Register Bit Masks */
-#define USB_INTR_INT_EN (0x00000001)
-#define USB_INTR_ERR_INT_EN (0x00000002)
-#define USB_INTR_PTC_DETECT_EN (0x00000004)
-#define USB_INTR_FRM_LST_ROLL_EN (0x00000008)
-#define USB_INTR_SYS_ERR_EN (0x00000010)
-#define USB_INTR_ASYN_ADV_EN (0x00000020)
-#define USB_INTR_RESET_EN (0x00000040)
-#define USB_INTR_SOF_EN (0x00000080)
-#define USB_INTR_DEVICE_SUSPEND (0x00000100)
-
-/* Device Address bit masks */
-#define USB_DEVICE_ADDRESS_MASK (0xFE000000)
-#define USB_DEVICE_ADDRESS_BIT_POS (25)
-
-/* endpoint list address bit masks */
-#define USB_EP_LIST_ADDRESS_MASK (0xfffff800)
-
-/* PORTSCX Register Bit Masks */
-#define PORTSCX_CURRENT_CONNECT_STATUS (0x00000001)
-#define PORTSCX_CONNECT_STATUS_CHANGE (0x00000002)
-#define PORTSCX_PORT_ENABLE (0x00000004)
-#define PORTSCX_PORT_EN_DIS_CHANGE (0x00000008)
-#define PORTSCX_OVER_CURRENT_ACT (0x00000010)
-#define PORTSCX_OVER_CURRENT_CHG (0x00000020)
-#define PORTSCX_PORT_FORCE_RESUME (0x00000040)
-#define PORTSCX_PORT_SUSPEND (0x00000080)
-#define PORTSCX_PORT_RESET (0x00000100)
-#define PORTSCX_LINE_STATUS_BITS (0x00000C00)
-#define PORTSCX_PORT_POWER (0x00001000)
-#define PORTSCX_PORT_INDICTOR_CTRL (0x0000C000)
-#define PORTSCX_PORT_TEST_CTRL (0x000F0000)
-#define PORTSCX_WAKE_ON_CONNECT_EN (0x00100000)
-#define PORTSCX_WAKE_ON_CONNECT_DIS (0x00200000)
-#define PORTSCX_WAKE_ON_OVER_CURRENT (0x00400000)
-#define PORTSCX_PHY_LOW_POWER_SPD (0x00800000)
-#define PORTSCX_PORT_FORCE_FULL_SPEED (0x01000000)
-#define PORTSCX_PORT_SPEED_MASK (0x0C000000)
-#define PORTSCX_PORT_WIDTH (0x10000000)
-#define PORTSCX_PHY_TYPE_SEL (0xC0000000)
-
-/* bit 11-10 are line status */
-#define PORTSCX_LINE_STATUS_SE0 (0x00000000)
-#define PORTSCX_LINE_STATUS_JSTATE (0x00000400)
-#define PORTSCX_LINE_STATUS_KSTATE (0x00000800)
-#define PORTSCX_LINE_STATUS_UNDEF (0x00000C00)
-#define PORTSCX_LINE_STATUS_BIT_POS (10)
-
-/* bit 15-14 are port indicator control */
-#define PORTSCX_PIC_OFF (0x00000000)
-#define PORTSCX_PIC_AMBER (0x00004000)
-#define PORTSCX_PIC_GREEN (0x00008000)
-#define PORTSCX_PIC_UNDEF (0x0000C000)
-#define PORTSCX_PIC_BIT_POS (14)
-
-/* bit 19-16 are port test control */
-#define PORTSCX_PTC_DISABLE (0x00000000)
-#define PORTSCX_PTC_JSTATE (0x00010000)
-#define PORTSCX_PTC_KSTATE (0x00020000)
-#define PORTSCX_PTC_SEQNAK (0x00030000)
-#define PORTSCX_PTC_PACKET (0x00040000)
-#define PORTSCX_PTC_FORCE_EN (0x00050000)
-#define PORTSCX_PTC_BIT_POS (16)
-
-/* bit 27-26 are port speed */
-#define PORTSCX_PORT_SPEED_FULL (0x00000000)
-#define PORTSCX_PORT_SPEED_LOW (0x04000000)
-#define PORTSCX_PORT_SPEED_HIGH (0x08000000)
-#define PORTSCX_PORT_SPEED_UNDEF (0x0C000000)
-#define PORTSCX_SPEED_BIT_POS (26)
-
-/* bit 28 is parallel transceiver width for UTMI interface */
-#define PORTSCX_PTW (0x10000000)
-#define PORTSCX_PTW_8BIT (0x00000000)
-#define PORTSCX_PTW_16BIT (0x10000000)
-
-/* bit 31-30 are port transceiver select */
-#define PORTSCX_PTS_UTMI (0x00000000)
-#define PORTSCX_PTS_ULPI (0x80000000)
-#define PORTSCX_PTS_FSLS (0xC0000000)
-#define PORTSCX_PTS_BIT_POS (30)
-
-/* USB MODE Register Bit Masks */
-#define USB_MODE_CTRL_MODE_IDLE (0x00000000)
-#define USB_MODE_CTRL_MODE_DEVICE (0x00000002)
-#define USB_MODE_CTRL_MODE_HOST (0x00000003)
-#define USB_MODE_CTRL_MODE_RSV (0x00000001)
-#define USB_MODE_SETUP_LOCK_OFF (0x00000008)
-#define USB_MODE_STREAM_DISABLE (0x00000010)
-
-/* Endpoint Flush Register */
-#define EPFLUSH_TX_OFFSET (0x00010000)
-#define EPFLUSH_RX_OFFSET (0x00000000)
-
-/* Endpoint Setup Status bit masks */
-#define EP_SETUP_STATUS_MASK (0x0000003F)
-#define EP_SETUP_STATUS_EP0 (0x00000001)
-
-/* ENDPOINTCTRLx Register Bit Masks */
-#define EPCTRL_TX_ENABLE (0x00800000)
-#define EPCTRL_TX_DATA_TOGGLE_RST (0x00400000) /* Not EP0 */
-#define EPCTRL_TX_DATA_TOGGLE_INH (0x00200000) /* Not EP0 */
-#define EPCTRL_TX_TYPE (0x000C0000)
-#define EPCTRL_TX_DATA_SOURCE (0x00020000) /* Not EP0 */
-#define EPCTRL_TX_EP_STALL (0x00010000)
-#define EPCTRL_RX_ENABLE (0x00000080)
-#define EPCTRL_RX_DATA_TOGGLE_RST (0x00000040) /* Not EP0 */
-#define EPCTRL_RX_DATA_TOGGLE_INH (0x00000020) /* Not EP0 */
-#define EPCTRL_RX_TYPE (0x0000000C)
-#define EPCTRL_RX_DATA_SINK (0x00000002) /* Not EP0 */
-#define EPCTRL_RX_EP_STALL (0x00000001)
-
-/* bit 19-18 and 3-2 are endpoint type */
-#define EPCTRL_EP_TYPE_CONTROL (0)
-#define EPCTRL_EP_TYPE_ISO (1)
-#define EPCTRL_EP_TYPE_BULK (2)
-#define EPCTRL_EP_TYPE_INTERRUPT (3)
-#define EPCTRL_TX_EP_TYPE_SHIFT (18)
-#define EPCTRL_RX_EP_TYPE_SHIFT (2)
-
-/* SNOOPn Register Bit Masks */
-#define SNOOP_ADDRESS_MASK (0xFFFFF000)
-#define SNOOP_SIZE_ZERO (0x00) /* snooping disable */
-#define SNOOP_SIZE_4KB (0x0B) /* 4KB snoop size */
-#define SNOOP_SIZE_8KB (0x0C)
-#define SNOOP_SIZE_16KB (0x0D)
-#define SNOOP_SIZE_32KB (0x0E)
-#define SNOOP_SIZE_64KB (0x0F)
-#define SNOOP_SIZE_128KB (0x10)
-#define SNOOP_SIZE_256KB (0x11)
-#define SNOOP_SIZE_512KB (0x12)
-#define SNOOP_SIZE_1MB (0x13)
-#define SNOOP_SIZE_2MB (0x14)
-#define SNOOP_SIZE_4MB (0x15)
-#define SNOOP_SIZE_8MB (0x16)
-#define SNOOP_SIZE_16MB (0x17)
-#define SNOOP_SIZE_32MB (0x18)
-#define SNOOP_SIZE_64MB (0x19)
-#define SNOOP_SIZE_128MB (0x1A)
-#define SNOOP_SIZE_256MB (0x1B)
-#define SNOOP_SIZE_512MB (0x1C)
-#define SNOOP_SIZE_1GB (0x1D)
-#define SNOOP_SIZE_2GB (0x1E) /* 2GB snoop size */
-
-/* pri_ctrl Register Bit Masks */
-#define PRI_CTRL_PRI_LVL1 (0x0000000C)
-#define PRI_CTRL_PRI_LVL0 (0x00000003)
-
-/* si_ctrl Register Bit Masks */
-#define SI_CTRL_ERR_DISABLE (0x00000010)
-#define SI_CTRL_IDRC_DISABLE (0x00000008)
-#define SI_CTRL_RD_SAFE_EN (0x00000004)
-#define SI_CTRL_RD_PREFETCH_DISABLE (0x00000002)
-#define SI_CTRL_RD_PREFEFETCH_VAL (0x00000001)
-
-/* control Register Bit Masks */
-#define USB_CTRL_IOENB (0x00000004)
-#define USB_CTRL_ULPI_INT0EN (0x00000001)
-
-/* Externally used functions */
-int dr_controller_setup(void);
-void dr_controller_run(void);
-void dr_controller_stop(void);
-
-#endif /* __ARCOTG_UDC_H */
diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h
index 8a1d6a37fa..53ff97326a 100644
--- a/firmware/export/config-c200.h
+++ b/firmware/export/config-c200.h
@@ -162,10 +162,10 @@
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
-/* enable these for the experimental usb stack
+/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
-#define USBSTACK_CAPS CONTROLLER_DEVICE
-*/
+#define USB_VENDOR_ID 0x0781
+#define USB_PRODUCT_ID 0x7450
/* Virtual LED (icon) */
#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index f5ba8f0c4d..c49ee23841 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -157,11 +157,10 @@
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
-/* enable these for the experimental usb stack
+/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
-#define USBSTACK_CAPS CONTROLLER_DEVICE
-*/
-
+#define USB_VENDOR_ID 0x0781
+#define USB_PRODUCT_ID 0x7421
/* Virtual LED (icon) */
#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h
index aa60b106da..c69b433503 100644
--- a/firmware/export/config-h10.h
+++ b/firmware/export/config-h10.h
@@ -152,10 +152,10 @@
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
-/* enable these for the experimental usb stack
+/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
-#define USBSTACK_CAPS CONTROLLER_DEVICE
-*/
+#define USB_VENDOR_ID 0x0B70
+#define USB_PRODUCT_ID 0x00BA
/* Virtual LED (icon) */
#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h
index e8f7d7562a..efb62c03fb 100644
--- a/firmware/export/config-h10_5gb.h
+++ b/firmware/export/config-h10_5gb.h
@@ -135,10 +135,10 @@
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
-/* enable these for the experimental usb stack
+/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
-#define USBSTACK_CAPS CONTROLLER_DEVICE
-*/
+#define USB_VENDOR_ID 0x0B70
+#define USB_PRODUCT_ID 0x00BA
/* Virtual LED (icon) */
#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/linkedlist.h b/firmware/export/linkedlist.h
deleted file mode 100644
index bea41eeca5..0000000000
--- a/firmware/export/linkedlist.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) by Linux Kernel Developers
- *
- * Original source can be found in linux kernel: <kernel>/include/list.h
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef _LINKED_LIST_H_
-#define _LINKED_LIST_H_
-
-#include <stddef.h> /* used for offsetof */
-
-static inline void prefetch(const void *x) { (void)x; }
-
-/*
- * Simple doubly linked list implementation.
- *
- * Some of the internal functions ("__xxx") are useful when
- * manipulating whole lists rather than single entries, as
- * sometimes we already know the next/prev entries and we can
- * generate better code by using them directly rather than
- * using the generic single-entry routines.
- */
-
-/* TODO move this macro? */
-/* more about this macro: http://www.kroah.com/log/linux/container_of.html */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
-
-struct list_head {
- struct list_head *next, *prev;
-};
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-static inline void INIT_LIST_HEAD(struct list_head *list)
-{
- list->next = list;
- list->prev = list;
-}
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-
-/**
- * list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
- *
- * Insert a new entry after the specified head.
- * This is good for implementing stacks.
- */
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head, head->next);
-}
-
-
-/**
- * list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- */
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head->prev, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty() on entry does not return true after this, the entry is
- * in an undefined state.
- */
-static inline void list_del(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- entry->next = LIST_POISON1;
- entry->prev = LIST_POISON2;
-}
-
-/**
- * list_replace - replace old entry by new one
- * @old : the element to be replaced
- * @new : the new element to insert
- *
- * If @old was empty, it will be overwritten.
- */
-static inline void list_replace(struct list_head *old,
- struct list_head *new)
-{
- new->next = old->next;
- new->next->prev = new;
- new->prev = old->prev;
- new->prev->next = new;
-}
-
-static inline void list_replace_init(struct list_head *old,
- struct list_head *new)
-{
- list_replace(old, new);
- INIT_LIST_HEAD(old);
-}
-
-/**
- * list_del_init - deletes entry from list and reinitialize it.
- * @entry: the element to delete from the list.
- */
-static inline void list_del_init(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- INIT_LIST_HEAD(entry);
-}
-
-/**
- * list_move - delete from one list and add as another's head
- * @list: the entry to move
- * @head: the head that will precede our entry
- */
-static inline void list_move(struct list_head *list, struct list_head *head)
-{
- __list_del(list->prev, list->next);
- list_add(list, head);
-}
-
-/**
- * list_move_tail - delete from one list and add as another's tail
- * @list: the entry to move
- * @head: the head that will follow our entry
- */
-static inline void list_move_tail(struct list_head *list,
- struct list_head *head)
-{
- __list_del(list->prev, list->next);
- list_add_tail(list, head);
-}
-
-/**
- * list_is_last - tests whether @list is the last entry in list @head
- * @list: the entry to test
- * @head: the head of the list
- */
-static inline int list_is_last(const struct list_head *list,
- const struct list_head *head)
-{
- return list->next == head;
-}
-
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(const struct list_head *head)
-{
- return head->next == head;
-}
-
-static inline void __list_splice(struct list_head *list,
- struct list_head *head)
-{
- struct list_head *first = list->next;
- struct list_head *last = list->prev;
- struct list_head *at = head->next;
-
- first->prev = head;
- head->next = first;
-
- last->next = at;
- at->prev = last;
-}
-
-/**
- * list_splice - join two lists
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- */
-static inline void list_splice(struct list_head *list, struct list_head *head)
-{
- if (!list_empty(list)) {
- __list_splice(list, head);
- }
-}
-
-/**
- * list_splice_init - join two lists and reinitialise the emptied list.
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * The list at @list is reinitialised
- */
-static inline void list_splice_init(struct list_head *list,
- struct list_head *head)
-{
- if (!list_empty(list)) {
- __list_splice(list, head);
- INIT_LIST_HEAD(list);
- }
-}
-
-/**
- * list_entry - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
-
-/**
- * list_for_each - iterate over a list
- * @pos: the &struct list_head to use as a loop cursor.
- * @head: the head for your list.
- */
-#define list_for_each(pos, head) \
- for (pos = (head)->next; prefetch(pos->next), pos != (head); \
- pos = pos->next)
-
-/**
- * __list_for_each - iterate over a list
- * @pos: the &struct list_head to use as a loop cursor.
- * @head: the head for your list.
- *
- * This variant differs from list_for_each() in that it's the
- * simplest possible list iteration code, no prefetching is done.
- * Use this for code that knows the list to be very short (empty
- * or 1 entry) most of the time.
- */
-#define __list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
-
-/**
- * list_for_each_prev - iterate over a list backwards
- * @pos: the &struct list_head to use as a loop cursor.
- * @head: the head for your list.
- */
-#define list_for_each_prev(pos, head) \
- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
- pos = pos->prev)
-
-/**
- * list_for_each_entry - iterate over list of given type
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_reverse - iterate backwards over list of given type.
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry_reverse(pos, head, member) \
- for (pos = list_entry((head)->prev, typeof(*pos), member); \
- prefetch(pos->member.prev), &pos->member != (head); \
- pos = list_entry(pos->member.prev, typeof(*pos), member))
-
-/**
- * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
- * @pos: the type * to use as a start point
- * @head: the head of the list
- * @member: the name of the list_struct within the struct.
- *
- * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
- */
-#define list_prepare_entry(pos, head, member) \
- ((pos) ? : list_entry(head, typeof(*pos), member))
-
-/**
- * list_for_each_entry_continue - continue iteration over list of given type
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- *
- * Continue to iterate over list of given type, continuing after
- * the current position.
- */
-#define list_for_each_entry_continue(pos, head, member) \
- for (pos = list_entry(pos->member.next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_from - iterate over list of given type from the current point
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- *
- * Iterate over list of given type, continuing from current position.
- */
-#define list_for_each_entry_from(pos, head, member) \
- for (; prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-#endif /*_LINKED_LIST_H_*/
diff --git a/firmware/export/pp5020.h b/firmware/export/pp5020.h
index b559aa3665..845c89c616 100644
--- a/firmware/export/pp5020.h
+++ b/firmware/export/pp5020.h
@@ -92,8 +92,8 @@
#define TIMER2_IRQ 1
#define MAILBOX_IRQ 4
#define IIS_IRQ 10
+#define USB_IRQ 20
#define IDE_IRQ 23
-#define USB_IRQ 24
#define FIREWIRE_IRQ 25
#define HI_IRQ 30
#define GPIO0_IRQ (32+0) /* Ports A..D */
diff --git a/firmware/export/usb.h b/firmware/export/usb.h
index 17dbafa10e..0977ff4d7d 100644
--- a/firmware/export/usb.h
+++ b/firmware/export/usb.h
@@ -51,7 +51,7 @@
#define USBPOWER_BUTTON BUTTON_MENU
#define USBPOWER_BTN_IGNORE BUTTON_BACK
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
-#define USBPOWER_BUTTON BUTTON_NONE
+#define USBPOWER_BUTTON BUTTON_RIGHT
#define USBPOWER_BTN_IGNORE BUTTON_POWER
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
(CONFIG_KEYPAD == SANSA_C200_PAD)
diff --git a/firmware/export/usb_core.h b/firmware/export/usb_core.h
new file mode 100644
index 0000000000..be3e4789d9
--- /dev/null
+++ b/firmware/export/usb_core.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 by Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef USB_CORE_H
+#define USB_CORE_H
+
+#include "usb_ch9.h"
+
+#if defined(CPU_PP)
+#define USB_IRAM_ORIGIN ((unsigned char *)0x4000c000)
+#define USB_IRAM_SIZE ((size_t)0xc000)
+#endif
+
+/* endpoints */
+enum {
+ EP_CONTROL = 0,
+ EP_RX,
+ EP_TX,
+ NUM_ENDPOINTS
+};
+
+/* queue events */
+#define USB_TRANSFER_COMPLETE 1
+
+struct queue_msg {
+ int endpoint;
+ int length;
+ void* data;
+};
+
+extern int usb_max_pkt_size;
+
+void usb_core_init(void);
+void usb_core_exit(void);
+void usb_core_control_request(struct usb_ctrlrequest* req);
+void usb_core_transfer_complete(int endpoint, bool in);
+void usb_core_bus_reset(void);
+
+#endif
+
diff --git a/firmware/export/usb_drv.h b/firmware/export/usb_drv.h
new file mode 100644
index 0000000000..a30f2ec494
--- /dev/null
+++ b/firmware/export/usb_drv.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 by Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef ARCOTG_DRV_H
+#define ARCOTG_DRV_H
+#include "usb_ch9.h"
+#include "kernel.h"
+
+void usb_drv_init(void);
+void usb_drv_exit(void);
+void usb_drv_int(void);
+void usb_drv_stall(int endpoint, bool stall);
+void usb_drv_send(int endpoint, void* ptr, int length);
+void usb_drv_recv(int endpoint, void* ptr, int length);
+void usb_drv_ack(struct usb_ctrlrequest* req);
+void usb_drv_set_address(int address);
+void usb_drv_reset_endpoint(int endpoint, bool send);
+void usb_drv_wait(int endpoint, bool send);
+
+#endif
diff --git a/firmware/export/usbstack.h b/firmware/export/usbstack.h
deleted file mode 100644
index 4ad477ec97..0000000000
--- a/firmware/export/usbstack.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Christian Gmeiner
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef _USBSTACK_H_
-#define _USBSTACK_H_
-
-#include <errno.h>
-
-#define USB_STACK_MAX_SETTINGS_NAME 32*10 /* should be enough for > 10 driver names */
-
-/* usb stack configuration */
-#ifndef USBSTACK_CAPS
-#define USBSTACK_CAPS 0 /* default: use no controller */
-#endif
-
-#define CONTROLLER_DEVICE (1 << 0)
-#define CONTROLLER_HOST (1 << 1)
-
-/*
- * error codes
- */
-#define ENOFREESLOT 1
-#define EWRONGCONTROLLERTYPE 2
-#define ENODRIVERFOUND 3
-#define EHWCRITICAL 4
-
-enum usb_controller_type {
- DEVICE = 0,
- HOST,
-};
-
-/*
- * stack routines
- */
-void usb_stack_init(void);
-void usb_stack_start(void);
-void usb_stack_stop(void);
-
-void usb_controller_select(int type);
-int usb_stack_get_mode(void);
-int usb_device_driver_bind(const char* name);
-void ubs_device_driver_unbind(void);
-
-/* used by apps settings code */
-unsigned char device_driver_names[USB_STACK_MAX_SETTINGS_NAME];
-
-#endif /*_USBSTACK_H_*/