Index: apps/plugins/usb-pp-debug.c
===================================================================
--- apps/plugins/usb-pp-debug.c	(wersja 0)
+++ apps/plugins/usb-pp-debug.c	(wersja 0)
@@ -0,0 +1,536 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 Barry Wardell
+ *
+ * This plugin is to be used for tests related to getting the USB controller
+ * in PortalPlayer based targets working.
+ *
+ * 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.
+ *
+ ****************************************************************************/
+#include "plugin.h"
+#include "arcotg_udc.h"
+
+/* welcome to the example rockbox plugin */
+
+/* This macros must always be included. Should be placed at the top by
+   convention, although the actual position doesn't matter */
+PLUGIN_HEADER
+
+/* here is a global api struct pointer. while not strictly necessary,
+   it's nice not to have to pass the api pointer in all function calls
+   in the plugin */
+static struct plugin_api* rb;
+
+#if (CONFIG_KEYPAD == IPOD_4G_PAD)
+
+#define BACK        BUTTON_MENU
+#define PREV_PAGE   BUTTON_SCROLL_BACK
+#define NEXT_PAGE   BUTTON_SCROLL_FWD
+
+#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
+
+#define BACK        BUTTON_LEFT
+#define PREV_PAGE   BUTTON_SCROLL_UP
+#define NEXT_PAGE   BUTTON_SCROLL_DOWN
+
+#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
+
+#define BACK        BUTTON_LEFT
+#define PREV_PAGE   BUTTON_SCROLL_UP
+#define NEXT_PAGE   BUTTON_SCROLL_DOWN
+
+#endif
+
+#define USB_DEBUG_LOG "/usb_debug.txt"
+
+/* USB debug screen for Freescale i.MX31 USB device based on proc filesystem 
+ * code in the linux i.MX31 USB driver from the Linux Target Image Builder.
+ * http://www.bitshrine.org/
+ * http://www.bitshrine.org/gpp/linux-2.6.16-mx31-usb-2.patch
+ * Original file: drivers/usb/gadget/arcotg_udc.c
+ */
+static bool dbg_usb_info(void)
+{
+    char buf[128];
+    bool done = false;
+    int page = 0;
+    const int max_page = 10;
+    unsigned int tmp_reg;
+
+    rb->lcd_setmargins(0, 0);
+
+    while(!done)
+    {
+        int y=0;
+        int key;
+        rb->lcd_clear_display();
+        rb->lcd_puts(0, y++, "USB info:");
+        y++;
+
+        switch (page) {
+            case 0:
+                tmp_reg = UDC_USBCMD;
+                rb->lcd_puts(0, y++, "USB Command Reg:");
+                rb->snprintf(buf, sizeof(buf), "SetupTW: %d",
+                            (tmp_reg & USB_CMD_SUTW) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Run/Stop: %s",
+                            (tmp_reg & USB_CMD_RUN_STOP) ? "Run" : "Stop");
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 1:
+                tmp_reg = UDC_USBSTS;
+                rb->lcd_puts(0, y++, "USB Status Reg:");
+                rb->snprintf(buf, sizeof(buf), "Dr Suspend: %d",
+                            (tmp_reg & USB_STS_SUSPEND) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Reset Received: %d",
+                            (tmp_reg & USB_STS_RESET) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "System Error: %s",
+                            (tmp_reg & USB_STS_SYS_ERR) ? "Err" : "Normal");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "USB Error Interrupt: %s",
+                            (tmp_reg & USB_STS_ERR) ? "Err detected" : "No err");
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 2:
+                tmp_reg = UDC_USBINTR;
+                rb->lcd_puts(0, y++, "USB Intrrupt Enable Reg:");
+                rb->snprintf(buf, sizeof(buf), "Sleep Enable: %d",
+                            (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "SOF Received Enable: %d",
+                            (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Reset Enable: %d",
+                            (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "System Error Enable: %d",
+                            (tmp_reg & USB_INTR_SYS_ERR_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Change Dectected Enable: %d",
+                            (tmp_reg & USB_INTR_PTC_DETECT_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "USB Error Intr Enable: %d",
+                            (tmp_reg & USB_INTR_ERR_INT_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "USB Intr Enable: %d",
+                            (tmp_reg & USB_INTR_INT_EN) ? 1 : 0);
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 3:
+                tmp_reg = UDC_FRINDEX;
+                rb->lcd_puts(0, y++, "USB Frame Index Reg:");
+                rb->snprintf(buf, sizeof(buf), "Frame Number is 0x%x",
+                            (tmp_reg & USB_FRINDEX_MASKS));
+                rb->lcd_puts(0, y++, buf);
+		        break;
+            case 4:
+                tmp_reg = UDC_DEVICEADDR;
+                rb->lcd_puts(0, y++, "USB Device Address Reg:");
+                rb->snprintf(buf, sizeof(buf), "Device Addr is 0x%x",
+                            (tmp_reg & USB_DEVICE_ADDRESS_MASK));
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 5:
+                tmp_reg = UDC_ENDPOINTLISTADDR;
+                rb->lcd_puts(0, y++, "USB Endpoint List Address Reg:");
+                rb->snprintf(buf, sizeof(buf), "Device Addr is 0x%x",
+                            (tmp_reg & USB_EP_LIST_ADDRESS_MASK));
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 6:
+                tmp_reg = UDC_PORTSC1;
+                rb->lcd_puts(0, y++, "USB Port Status&Control Reg:");
+                rb->snprintf(buf, sizeof(buf), "Port Transceiver Type : %s", 
+                    ( {
+                        char *s;
+                        switch (tmp_reg & PORTSCX_PTS_FSLS) {
+                            case PORTSCX_PTS_UTMI:
+                                s = "UTMI";
+                                break;
+                            case PORTSCX_PTS_ULPI:
+                                s = "ULPI ";
+                                break;
+                            case PORTSCX_PTS_FSLS:
+                                s = "FS/LS Serial";
+                                break;
+                            default:
+                                s = "None";
+                                break;
+                        }
+                        s;
+                    } ));
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Speed: %s", 
+                    ( {
+                        char *s;
+                        switch (tmp_reg & PORTSCX_PORT_SPEED_UNDEF) {
+                            case PORTSCX_PORT_SPEED_FULL:
+                                s = "Full Speed";
+                                break;
+                            case PORTSCX_PORT_SPEED_LOW:
+                                s = "Low Speed";
+                                break;
+                            case PORTSCX_PORT_SPEED_HIGH:
+                                s = "High Speed";
+                                break;
+                            default:
+                                s = "Undefined";
+                                break;
+                        }
+                        s;
+                    } ));
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "PHY Low Power Suspend: %s",
+                            (tmp_reg & PORTSCX_PHY_LOW_POWER_SPD) ?
+                            "Normal PHY mode" : "Low power mode");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Reset: %s",
+                            (tmp_reg & PORTSCX_PORT_RESET) ?
+                            "In Reset" : "Not in Reset");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Suspend Mode: %s",
+                            (tmp_reg & PORTSCX_PORT_SUSPEND) ?
+                            "In " : "Not in");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Over-current Change: %s",
+                            (tmp_reg & PORTSCX_OVER_CURRENT_CHG) ?
+                            "Dected" : "No");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Enable/Disable Change: %s",
+                            (tmp_reg & PORTSCX_PORT_EN_DIS_CHANGE) ?
+                            "Disable" : "Not change");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Port Enabled/Disabled: %s",
+                            (tmp_reg & PORTSCX_PORT_ENABLE) ?
+                            "Enable" : "Not correct");
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "Current Connect Status: %s",
+                            (tmp_reg & PORTSCX_CURRENT_CONNECT_STATUS) ?
+                            "Attached" : "Not-Att");
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 7:
+                tmp_reg = UDC_USBMODE;
+                rb->lcd_puts(0, y++, "USB Mode Reg:");
+                rb->snprintf(buf, sizeof(buf), "Controller Mode is : %s", 
+                    ( {
+                        char *s;
+                        switch(tmp_reg & USB_MODE_CTRL_MODE_HOST) {
+                            case USB_MODE_CTRL_MODE_IDLE:
+                                s = "Idle";
+                                break;
+                            case USB_MODE_CTRL_MODE_DEVICE:
+                                s = "Device Controller";
+                                break;
+                            case USB_MODE_CTRL_MODE_HOST:
+                                s = "Host Controller";
+                                break;
+                            default:
+                                s = "None";
+                                break;
+                        }
+                        s;
+                    } ));
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 8:
+                tmp_reg = UDC_ENDPTSETUPSTAT;
+                rb->lcd_puts(0, y++, "Endpoint Setup Status Reg:");
+                rb->snprintf(buf, sizeof(buf), "SETUP on ep 0x%x", (tmp_reg & EP_SETUP_STATUS_MASK));
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 9:
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [0]: = [0x%x]", ENDPTCRTL0);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [1]: = [0x%x]", ENDPTCRTL1);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [2]: = [0x%x]", ENDPTCRTL2);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [3]: = [0x%x]", ENDPTCRTL3);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [4]: = [0x%x]", ENDPTCRTL4);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [5]: = [0x%x]", ENDPTCRTL5);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [6]: = [0x%x]", ENDPTCRTL6);
+                rb->lcd_puts(0, y++, buf);
+                rb->snprintf(buf, sizeof(buf), "EP Ctrl Reg [7]: = [0x%x]", ENDPTCRTL7);
+                rb->lcd_puts(0, y++, buf);
+                break;
+            case 10:
+                rb->snprintf(buf, sizeof(buf), "EP Prime Reg = [0x%x]", UDC_ENDPTPRIME);
+                rb->lcd_puts(0, y++, buf);
+                break;
+        }
+        rb->lcd_update();
+
+        /* Wait for a key to be pushed */
+        key = rb->button_get(true);
+        switch(key) {
+            case BACK:
+                done = true;
+                break;
+
+            case PREV_PAGE:
+                if (--page < 0)
+                    page = max_page;
+                break;
+
+            case NEXT_PAGE:
+                if (++page > max_page)
+                    page = 0;
+                break;
+        }
+    }
+    return false;
+}
+
+/* Write debug info to a file */
+static bool write_dbg_usb_info(void)
+{
+    int fd;
+    unsigned int tmp_reg;
+    fd = rb->open(USB_DEBUG_LOG, O_RDWR | O_CREAT | O_APPEND);
+    if(fd < 0)
+    {
+        return false;
+    } else {
+        rb->fdprintf(fd,"==================================================\n"
+                        "==================== USB info ====================\n"
+                        "==================================================\n"
+                        "\n");
+        
+        tmp_reg = UDC_USBCMD;
+        rb->fdprintf(fd,"----------------- USB Command Reg ----------------\n");
+        rb->fdprintf(fd,"SetupTW: %d\n",
+                        (tmp_reg & USB_CMD_SUTW) ? 1 : 0);
+        rb->fdprintf(fd,"Run/Stop: %s\n",
+                        (tmp_reg & USB_CMD_RUN_STOP) ? "Run" : "Stop");
+        rb->fdprintf(fd,"\n");
+
+        tmp_reg = UDC_USBSTS;
+        rb->fdprintf(fd,"----------------- USB Status Reg -----------------\n");
+        rb->fdprintf(fd,"Dr Suspend: %d\n",
+                        (tmp_reg & USB_STS_SUSPEND) ? 1 : 0);
+        rb->fdprintf(fd,"Reset Received: %d\n",
+                        (tmp_reg & USB_STS_RESET) ? 1 : 0);
+        rb->fdprintf(fd,"System Error: %s\n", 
+                        (tmp_reg & USB_STS_SYS_ERR) ? "Err" : "Normal");
+        rb->fdprintf(fd,"USB Error Interrupt: %s\n",
+                        (tmp_reg & USB_STS_ERR) ? "Err detected" : "No err");
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_USBINTR;
+        rb->fdprintf(fd,"------------- USB Intrrupt Enable Reg ------------\n");
+        rb->fdprintf(fd,"Sleep Enable: %d\n",
+                        (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0);
+        rb->fdprintf(fd,"SOF Received Enable: %d\n",
+                        (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0);
+        rb->fdprintf(fd,"Reset Enable: %d\n",
+                        (tmp_reg & USB_INTR_RESET_EN) ? 1 : 0);
+        rb->fdprintf(fd,"System Error Enable: %d\n",
+                        (tmp_reg & USB_INTR_SYS_ERR_EN) ? 1 : 0);
+        rb->fdprintf(fd,"Port Change Dectected Enable: %d\n",
+                        (tmp_reg & USB_INTR_PTC_DETECT_EN) ? 1 : 0);
+        rb->fdprintf(fd,"USB Error Intr Enable: %d\n",
+                        (tmp_reg & USB_INTR_ERR_INT_EN) ? 1 : 0);
+        rb->fdprintf(fd,"USB Intr Enable: %d\n",
+                        (tmp_reg & USB_INTR_INT_EN) ? 1 : 0);
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_FRINDEX;
+        rb->fdprintf(fd,"--------------- USB Frame Index Reg --------------\n");
+        rb->fdprintf(fd,"Frame Number is 0x%x\n",
+                        (tmp_reg & USB_FRINDEX_MASKS));
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_DEVICEADDR;
+        rb->fdprintf(fd,"------------- USB Device Address Reg -------------\n");
+        rb->fdprintf(fd,"Device Addr is 0x%x\n",
+                        (tmp_reg & USB_DEVICE_ADDRESS_MASK));
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_ENDPOINTLISTADDR;
+        rb->fdprintf(fd,"---------- USB Endpoint List Address Reg ---------\n");
+        rb->fdprintf(fd,"Device Addr is 0x%x\n",
+                        (tmp_reg & USB_EP_LIST_ADDRESS_MASK));
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_PORTSC1;
+        rb->fdprintf(fd,"---------- USB Port Status & Control Reg ---------\n");
+        rb->fdprintf(fd,"Port Transceiver Type : %s\n", 
+            ( {
+                char *s;
+                switch (tmp_reg & PORTSCX_PTS_FSLS) {
+                    case PORTSCX_PTS_UTMI:
+                        s = "UTMI";
+                        break;
+                    case PORTSCX_PTS_ULPI:
+                        s = "ULPI ";
+                        break;
+                    case PORTSCX_PTS_FSLS:
+                        s = "FS/LS Serial";
+                        break;
+                    default:
+                        s = "None";
+                        break;
+                }
+                s;
+            } ));
+        rb->fdprintf(fd,"Port Speed: %s\n", 
+            ( {
+                char *s;
+                switch (tmp_reg & PORTSCX_PORT_SPEED_UNDEF) {
+                    case PORTSCX_PORT_SPEED_FULL:
+                        s = "Full Speed";
+                        break;
+                    case PORTSCX_PORT_SPEED_LOW:
+                        s = "Low Speed";
+                        break;
+                    case PORTSCX_PORT_SPEED_HIGH:
+                        s = "High Speed";
+                        break;
+                    default:
+                        s = "Undefined";
+                        break;
+                }
+                s;
+            } ));
+        rb->fdprintf(fd,"PHY Low Power Suspend: %s\n",
+                        (tmp_reg & PORTSCX_PHY_LOW_POWER_SPD) ?
+                        "Normal PHY mode" : "Low power mode");
+        rb->fdprintf(fd,"Port Reset: %s\n",
+                        (tmp_reg & PORTSCX_PORT_RESET) ?
+                        "In Reset" : "Not in Reset");
+        rb->fdprintf(fd,"Port Suspend Mode: %s\n",
+                        (tmp_reg & PORTSCX_PORT_SUSPEND) ?
+                        "In " : "Not in");
+        rb->fdprintf(fd,"Over-current Change: %s\n",
+                        (tmp_reg & PORTSCX_OVER_CURRENT_CHG) ?
+                        "Dected" : "No");
+        rb->fdprintf(fd,"Port Enable/Disable Change: %s\n",
+                        (tmp_reg & PORTSCX_PORT_EN_DIS_CHANGE) ?
+                        "Disable" : "Not change");
+        rb->fdprintf(fd,"Port Enabled/Disabled: %s\n",
+                        (tmp_reg & PORTSCX_PORT_ENABLE) ?
+                        "Enable" : "Not correct");
+        rb->fdprintf(fd,"Current Connect Status: %s\n",
+                        (tmp_reg & PORTSCX_CURRENT_CONNECT_STATUS) ?
+                        "Attached" : "Not-Att");
+        rb->fdprintf(fd,"\n");
+        
+        tmp_reg = UDC_USBMODE;
+        rb->fdprintf(fd,"------------------ USB Mode Reg ------------------\n");
+        rb->fdprintf(fd,"Controller Mode is : %s\n", 
+            ( {
+                char *s;
+                switch(tmp_reg & USB_MODE_CTRL_MODE_HOST) {
+                    case USB_MODE_CTRL_MODE_IDLE:
+                        s = "Idle";
+                        break;
+                    case USB_MODE_CTRL_MODE_DEVICE:
+                        s = "Device Controller";
+                        break;
+                    case USB_MODE_CTRL_MODE_HOST:
+                        s = "Host Controller";
+                        break;
+                    default:
+                        s = "None";
+                        break;
+                }
+                s;
+            } ));
+        rb->fdprintf(fd,"\n");
+            
+        tmp_reg = UDC_ENDPTSETUPSTAT;
+        rb->fdprintf(fd,"------------ Endpoint Setup Status Reg -----------\n");
+        rb->fdprintf(fd,"SETUP on ep 0x%x\n", (tmp_reg & EP_SETUP_STATUS_MASK));
+        rb->fdprintf(fd,"\n");
+        
+        rb->fdprintf(fd,"EP Ctrl Reg [0]: = [0x%x]\n", ENDPTCRTL0);
+        rb->fdprintf(fd,"EP Ctrl Reg [1]: = [0x%x]\n", ENDPTCRTL1);
+        rb->fdprintf(fd,"EP Ctrl Reg [2]: = [0x%x]\n", ENDPTCRTL2);
+        rb->fdprintf(fd,"EP Ctrl Reg [3]: = [0x%x]\n", ENDPTCRTL3);
+        rb->fdprintf(fd,"EP Ctrl Reg [4]: = [0x%x]\n", ENDPTCRTL4);
+        rb->fdprintf(fd,"EP Ctrl Reg [5]: = [0x%x]\n", ENDPTCRTL5);
+        rb->fdprintf(fd,"EP Ctrl Reg [6]: = [0x%x]\n", ENDPTCRTL6);
+        rb->fdprintf(fd,"EP Ctrl Reg [7]: = [0x%x]\n", ENDPTCRTL7);
+        rb->fdprintf(fd,"\n");
+        
+        rb->fdprintf(fd,"EP Prime Reg = [0x%x]\n", UDC_ENDPTPRIME);
+
+        rb->close(fd);
+    }
+    
+    return true;
+}
+
+/* this is the plugin entry point */
+enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
+{
+    int m;
+    int result;
+
+    /* if you don't use the parameter, you can do like
+       this to avoid the compiler warning about it */
+    (void)parameter;
+
+    /* if you are using a global api pointer, don't forget to copy it!
+       otherwise you will get lovely "I04: IllInstr" errors... :-) */
+    rb = api;
+
+
+    static const struct menu_item items[] = {
+        { "Show Debug Info", NULL },
+        { "Write Debug Info", NULL },
+/*        { "dr_controller_setup()", NULL },
+        { "dr_controller_run()", NULL },*/
+        { "Quit", NULL },
+    };
+    
+    m = rb->menu_init(items, sizeof(items) / sizeof(*items),
+                      NULL, NULL, NULL, NULL);
+    
+    while (1) {
+        result=rb->menu_show(m);
+        switch (result)
+        {
+            case 0:     /* Just show debug info */
+                dbg_usb_info();
+                break;
+            case 1:
+                write_dbg_usb_info();
+                rb->splash(2*HZ, true, "USB Debug Info Written");
+                break;
+/*            case 2:
+                dr_controller_setup();
+                rb->splash(2*HZ, true, "dr_controller_setup() done");
+                break;
+            case 3:
+                dr_controller_run();
+                rb->splash(2*HZ, true, "dr_controller_run() done");
+                break;*/
+            case 2:     /* Quit */
+                rb->menu_exit(m);
+                return PLUGIN_OK;
+                break;
+        }
+    }
+
+    return PLUGIN_OK;
+}
Index: apps/plugins/SOURCES
===================================================================
--- apps/plugins/SOURCES	(wersja 12477)
+++ apps/plugins/SOURCES	(kopia robocza)
@@ -19,6 +19,10 @@
 vbrfix.c
 viewer.c
 
+#if (CONFIG_USBOTG == USBOTG_ARC)
+usb-pp-debug.c
+#endif
+
 /* plugins built for all targets, but not for the simulator */
 #if !defined(SIMULATOR)
 metronome.c
Index: firmware/export/arcotg_udc.h
===================================================================
--- firmware/export/arcotg_udc.h	(wersja 12477)
+++ firmware/export/arcotg_udc.h	(kopia robocza)
@@ -88,6 +88,66 @@
 #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 */
 
+#define ENDPTCRTL0              (*(volatile unsigned int *)(USB_BASE+0x1c0))
+#define ENDPTCRTL1              (*(volatile unsigned int *)(USB_BASE+0x1c4))
+#define ENDPTCRTL2              (*(volatile unsigned int *)(USB_BASE+0x1c8))
+#define ENDPTCRTL3              (*(volatile unsigned int *)(USB_BASE+0x1cc))
+#define ENDPTCRTL4              (*(volatile unsigned int *)(USB_BASE+0x1d0))
+#define ENDPTCRTL5              (*(volatile unsigned int *)(USB_BASE+0x1d4))
+#define ENDPTCRTL6              (*(volatile unsigned int *)(USB_BASE+0x1d8))
+#define ENDPTCRTL7              (*(volatile unsigned int *)(USB_BASE+0x1dc))
+/*#define ENDPTCRTL8              (*(volatile unsigned int *)(USB_BASE+0x1e0))
+#define ENDPTCRTL9              (*(volatile unsigned int *)(USB_BASE+0x1e4))
+#define ENDPTCRTL10             (*(volatile unsigned int *)(USB_BASE+0x1e8))
+#define ENDPTCRTL11             (*(volatile unsigned int *)(USB_BASE+0x1ec))
+#define ENDPTCRTL12             (*(volatile unsigned int *)(USB_BASE+0x1f0))
+#define ENDPTCRTL13             (*(volatile unsigned int *)(USB_BASE+0x1f4))
+#define ENDPTCRTL14             (*(volatile unsigned int *)(USB_BASE+0x1f8))
+#define ENDPTCRTL15             (*(volatile unsigned int *)(USB_BASE+0x1fc))*/
+
+/* Host 1 */
+#define UH1_ID                  (*(volatile unsigned int *)(USB_BASE+0x200))
+#define UH1_HWGENERAL           (*(volatile unsigned int *)(USB_BASE+0x204))
+#define UH1_HWHOST              (*(volatile unsigned int *)(USB_BASE+0x208))
+#define UH1_HWTXBUF             (*(volatile unsigned int *)(USB_BASE+0x210))
+#define UH1_HWRXBUF             (*(volatile unsigned int *)(USB_BASE+0x214))
+#define UH1_CAPLENGTH           (*(volatile unsigned int *)(USB_BASE+0x300))
+#define UH1_HCIVERSION          (*(volatile unsigned int *)(USB_BASE+0x302))
+#define UH1_HCSPARAMS           (*(volatile unsigned int *)(USB_BASE+0x304))
+#define UH1_HCCPARAMS           (*(volatile unsigned int *)(USB_BASE+0x308))
+#define UH1_USBCMD              (*(volatile unsigned int *)(USB_BASE+0x340))
+#define UH1_USBSTS              (*(volatile unsigned int *)(USB_BASE+0x344))
+#define UH1_USBINTR             (*(volatile unsigned int *)(USB_BASE+0x348))
+#define UH1_FRINDEX             (*(volatile unsigned int *)(USB_BASE+0x34c))
+#define UH1_PERIODICLISTBASE    (*(volatile unsigned int *)(USB_BASE+0x354))
+#define UH1_ASYNCLISTADDR       (*(volatile unsigned int *)(USB_BASE+0x358))
+#define UH1_BURSTSIZE           (*(volatile unsigned int *)(USB_BASE+0x360))
+#define UH1_TXFILLTUNING        (*(volatile unsigned int *)(USB_BASE+0x364))
+#define UH1_PORTSC1             (*(volatile unsigned int *)(USB_BASE+0x384))
+#define UH1_USBMODE             (*(volatile unsigned int *)(USB_BASE+0x3a8))
+
+/* Host 2 */
+#define UH2_ID                  (*(volatile unsigned int *)(USB_BASE+0x400))
+#define UH2_HWGENERAL           (*(volatile unsigned int *)(USB_BASE+0x404))
+#define UH2_HWHOST              (*(volatile unsigned int *)(USB_BASE+0x408))
+#define UH2_HWTXBUF             (*(volatile unsigned int *)(USB_BASE+0x410))
+#define UH2_HWRXBUF             (*(volatile unsigned int *)(USB_BASE+0x414))
+#define UH2_CAPLENGTH           (*(volatile unsigned int *)(USB_BASE+0x500))
+#define UH2_HCIVERSION          (*(volatile unsigned int *)(USB_BASE+0x502))
+#define UH2_HCSPARAMS           (*(volatile unsigned int *)(USB_BASE+0x504))
+#define UH2_HCCPARAMS           (*(volatile unsigned int *)(USB_BASE+0x508))
+#define UH2_USBCMD              (*(volatile unsigned int *)(USB_BASE+0x540))
+#define UH2_USBSTS              (*(volatile unsigned int *)(USB_BASE+0x544))
+#define UH2_USBINTR             (*(volatile unsigned int *)(USB_BASE+0x548))
+#define UH2_FRINDEX             (*(volatile unsigned int *)(USB_BASE+0x54c))
+#define UH2_PERIODICLISTBASE    (*(volatile unsigned int *)(USB_BASE+0x554))
+#define UH2_ASYNCLISTADDR       (*(volatile unsigned int *)(USB_BASE+0x558))
+#define UH2_BURSTSIZE           (*(volatile unsigned int *)(USB_BASE+0x560))
+#define UH2_TXFILLTUNING        (*(volatile unsigned int *)(USB_BASE+0x564))
+#define UH2_ULPIVIEW            (*(volatile unsigned int *)(USB_BASE+0x570))
+#define UH2_PORTSC1             (*(volatile unsigned int *)(USB_BASE+0x584))
+#define UH2_USBMODE             (*(volatile unsigned int *)(USB_BASE+0x5a8))
+
 /* ep0 transfer state */
 #define WAIT_FOR_SETUP          0
 #define DATA_STATE_XMIT         1
Index: firmware/target/arm/usb-pp.c
===================================================================
--- firmware/target/arm/usb-pp.c	(wersja 12477)
+++ firmware/target/arm/usb-pp.c	(kopia robocza)
@@ -96,6 +96,7 @@
        handling, which should be the same for all PortalPlayer targets. */
     if (on)
     {
+#ifndef USBOTG_ARC   /* Disable reboot on USB connect so that we can debug */
 #if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined (IRIVER_H10_5GB)
         /* For the H10 and iPod, we can only do one thing with USB mode - reboot
            into the flash-based disk-mode.  This does not return. */
@@ -120,6 +121,7 @@
             system_reboot(); /* Reboot */
         }
 #endif
+#endif
     }
 }
 
