Long ago we agreed on kicking the _direct appendix because everything in
authorStefan Reinauer <stepan@coresystems.de>
Tue, 25 May 2010 16:17:45 +0000 (16:17 +0000)
committerStefan Reinauer <stepan@openbios.org>
Tue, 25 May 2010 16:17:45 +0000 (16:17 +0000)
coreboot is direct. This patch does it.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5586 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

38 files changed:
src/console/Makefile.inc
src/console/usbdebug_console.c [new file with mode: 0644]
src/console/usbdebug_direct_console.c [deleted file]
src/cpu/intel/model_106cx/model_106cx_init.c
src/cpu/intel/model_6bx/model_6bx_init.c
src/cpu/intel/model_6ex/model_6ex_init.c
src/cpu/intel/model_6fx/model_6fx_init.c
src/include/usbdebug.h [new file with mode: 0644]
src/include/usbdebug_direct.h [deleted file]
src/lib/Makefile.inc
src/lib/usbdebug.c [new file with mode: 0644]
src/lib/usbdebug_direct.c [deleted file]
src/mainboard/getac/p470/romstage.c
src/mainboard/gigabyte/ga_2761gxdk/romstage.c
src/mainboard/gigabyte/m57sli/romstage.c
src/mainboard/intel/d945gclf/romstage.c
src/mainboard/kontron/986lcd-m/romstage.c
src/mainboard/msi/ms7260/romstage.c
src/mainboard/msi/ms9652_fam10/romstage.c
src/mainboard/nvidia/l1_2pvv/romstage.c
src/mainboard/roda/rk886ex/romstage.c
src/mainboard/tyan/s2912/romstage.c
src/mainboard/tyan/s2912_fam10/romstage.c
src/pc80/usbdebug_direct_serial.c [deleted file]
src/pc80/usbdebug_serial.c [new file with mode: 0644]
src/southbridge/amd/sb600/sb600_enable_usbdebug.c [new file with mode: 0644]
src/southbridge/amd/sb600/sb600_enable_usbdebug_direct.c [deleted file]
src/southbridge/amd/sb600/sb600_usb.c
src/southbridge/amd/sb700/sb700_enable_usbdebug.c [new file with mode: 0644]
src/southbridge/amd/sb700/sb700_enable_usbdebug_direct.c [deleted file]
src/southbridge/amd/sb700/sb700_usb.c
src/southbridge/intel/i82801gx/i82801gx_usb_ehci.c
src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c [new file with mode: 0644]
src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c [deleted file]
src/southbridge/nvidia/mcp55/mcp55_usb2.c
src/southbridge/sis/sis966/sis966_enable_usbdebug.c [new file with mode: 0644]
src/southbridge/sis/sis966/sis966_enable_usbdebug_direct.c [deleted file]
src/southbridge/sis/sis966/sis966_usb2.c

index cb8c1dfba5df162b4227b790acf4665425ecc039..f5fa880b66733b1af5753dec80ac0091df8a11c7 100644 (file)
@@ -10,7 +10,7 @@ initobj-y += vtxprintf.o
 initobj-$(CONFIG_USE_DCACHE_RAM) += console.o
 
 driver-$(CONFIG_CONSOLE_SERIAL8250) += uart8250_console.o
-driver-$(CONFIG_USBDEBUG_DIRECT) += usbdebug_direct_console.o
+driver-$(CONFIG_USBDEBUG_DIRECT) += usbdebug_console.o
 driver-$(CONFIG_CONSOLE_VGA) += vga_console.o
 driver-$(CONFIG_CONSOLE_BTEXT) += btext_console.o
 driver-$(CONFIG_CONSOLE_BTEXT) += font-8x16.o
diff --git a/src/console/usbdebug_console.c b/src/console/usbdebug_console.c
new file mode 100644 (file)
index 0000000..2e71cc3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include <string.h>
+#include <console/console.h>
+#include <usbdebug.h>
+#include <pc80/mc146818rtc.h>
+
+static struct ehci_debug_info dbg_info;
+
+void set_ehci_base(unsigned ehci_base)
+{
+       unsigned diff;
+
+       if (!dbg_info.ehci_debug)
+               return;
+
+       diff = dbg_info.ehci_caps - ehci_base;
+       dbg_info.ehci_regs -= diff;
+       dbg_info.ehci_debug -= diff;
+       dbg_info.ehci_caps = ehci_base;
+}
+
+void set_ehci_debug(unsigned ehci_debug)
+{
+       dbg_info.ehci_debug = ehci_debug;
+}
+
+unsigned get_ehci_debug(void)
+{
+       return dbg_info.ehci_debug;
+}
+
+static void dbgp_init(void)
+{
+       struct ehci_debug_info *dbg_infox;
+
+       /* At this point, all we have to do is copy the fixed address
+        * debug_info data structure to our version defined above. */
+
+       dbg_infox = (struct ehci_debug_info *)
+               ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
+
+       memcpy(&dbg_info, dbg_infox, sizeof(struct ehci_debug_info));
+}
+
+static void dbgp_tx_byte(unsigned char data)
+{
+       if (dbg_info.ehci_debug)
+               dbgp_bulk_write_x(&dbg_info, &data, 1);
+}
+
+static unsigned char dbgp_rx_byte(void)
+{
+       unsigned char data = 0xff;
+
+       if (dbg_info.ehci_debug)
+               dbgp_bulk_read_x(&dbg_info, &data, 1);
+
+       return data;
+}
+
+static int dbgp_tst_byte(void)
+{
+       return dbg_info.ehci_debug;
+}
+
+static const struct console_driver usbdebug_direct_console __console = {
+       .init     = dbgp_init,
+       .tx_byte  = dbgp_tx_byte,
+       .rx_byte  = dbgp_rx_byte,
+       .tst_byte = dbgp_tst_byte,
+};
diff --git a/src/console/usbdebug_direct_console.c b/src/console/usbdebug_direct_console.c
deleted file mode 100644 (file)
index d100659..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * 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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#include <string.h>
-#include <console/console.h>
-#include <usbdebug_direct.h>
-#include <pc80/mc146818rtc.h>
-
-static struct ehci_debug_info dbg_info;
-
-void set_ehci_base(unsigned ehci_base)
-{
-       unsigned diff;
-
-       if (!dbg_info.ehci_debug)
-               return;
-
-       diff = dbg_info.ehci_caps - ehci_base;
-       dbg_info.ehci_regs -= diff;
-       dbg_info.ehci_debug -= diff;
-       dbg_info.ehci_caps = ehci_base;
-}
-
-void set_ehci_debug(unsigned ehci_debug)
-{
-       dbg_info.ehci_debug = ehci_debug;
-}
-
-unsigned get_ehci_debug(void)
-{
-       return dbg_info.ehci_debug;
-}
-
-static void dbgp_init(void)
-{
-       struct ehci_debug_info *dbg_infox;
-
-       /* At this point, all we have to do is copy the fixed address
-        * debug_info data structure to our version defined above. */
-
-       dbg_infox = (struct ehci_debug_info *)
-               ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
-
-       memcpy(&dbg_info, dbg_infox, sizeof(struct ehci_debug_info));
-}
-
-static void dbgp_tx_byte(unsigned char data)
-{
-       if (dbg_info.ehci_debug)
-               dbgp_bulk_write_x(&dbg_info, &data, 1);
-}
-
-static unsigned char dbgp_rx_byte(void)
-{
-       unsigned char data = 0xff;
-
-       if (dbg_info.ehci_debug)
-               dbgp_bulk_read_x(&dbg_info, &data, 1);
-
-       return data;
-}
-
-static int dbgp_tst_byte(void)
-{
-       return dbg_info.ehci_debug;
-}
-
-static const struct console_driver usbdebug_direct_console __console = {
-       .init     = dbgp_init,
-       .tx_byte  = dbgp_tx_byte,
-       .rx_byte  = dbgp_rx_byte,
-       .tst_byte = dbgp_tst_byte,
-};
index 65dfebba5b2ec8bccf890961e9c7ed3f0e273259..79164beae79296ca59a9c6019ae2f0a44e685083 100644 (file)
@@ -29,7 +29,7 @@
 #include <cpu/intel/hyperthreading.h>
 #include <cpu/x86/cache.h>
 #include <cpu/x86/mtrr.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 
 static const uint32_t microcode_updates[] = {
        /*  Dummy terminator  */
index 783138ec836afec7ac8bf78c868503a22ff5e68f..f8a4a77de26b6423e801869b77c93b73e89f0a96 100644 (file)
@@ -30,7 +30,7 @@
 #include <cpu/x86/lapic.h>
 #include <cpu/intel/microcode.h>
 #include <cpu/x86/cache.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 
 static const uint32_t microcode_updates[] = {
        #include "microcode-737-MU16b11c.h"
index 4f1d2043b6b86e43e04699963427d9df74032d49..91cde9350e833c46324a98ea05db56a2a14ccddf 100644 (file)
@@ -31,7 +31,7 @@
 #include <cpu/intel/hyperthreading.h>
 #include <cpu/x86/cache.h>
 #include <cpu/x86/mtrr.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 
 static const uint32_t microcode_updates[] = {
        #include "microcode-1624-m206e839.h"
index 3d1e9ba9a34871e7fa939a6f337f3b65558d38d9..3d2ca619bacc2ddbd6f57e96f902c18c2c351c89 100644 (file)
@@ -31,7 +31,7 @@
 #include <cpu/intel/hyperthreading.h>
 #include <cpu/x86/cache.h>
 #include <cpu/x86/mtrr.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 
 static const uint32_t microcode_updates[] = {
        #include "microcode-2129-m206f257.h"
diff --git a/src/include/usbdebug.h b/src/include/usbdebug.h
new file mode 100644 (file)
index 0000000..b9d170b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#ifndef USBDEBUG_H
+#define USBDEBUG_H
+
+struct ehci_debug_info {
+        void *ehci_caps;
+        void *ehci_regs;
+        void *ehci_debug;
+        unsigned devnum;
+        unsigned endpoint_out;
+        unsigned endpoint_in;
+};
+
+int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size);
+int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size);
+void set_ehci_base(unsigned ehci_base);
+void set_ehci_debug(unsigned ehci_deug);
+unsigned get_ehci_debug(void);
+void set_debug_port(unsigned port);
+
+#endif
diff --git a/src/include/usbdebug_direct.h b/src/include/usbdebug_direct.h
deleted file mode 100644 (file)
index b9d170b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * 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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#ifndef USBDEBUG_H
-#define USBDEBUG_H
-
-struct ehci_debug_info {
-        void *ehci_caps;
-        void *ehci_regs;
-        void *ehci_debug;
-        unsigned devnum;
-        unsigned endpoint_out;
-        unsigned endpoint_in;
-};
-
-int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size);
-int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size);
-void set_ehci_base(unsigned ehci_base);
-void set_ehci_debug(unsigned ehci_deug);
-unsigned get_ehci_debug(void);
-void set_debug_port(unsigned port);
-
-#endif
index 5b4091251a04ce8951e6ed9b28e1fd671dc4523c..6d32de9e37da43ebd0ba1f191e913b1b4cf101b5 100644 (file)
@@ -23,7 +23,8 @@ initobj-y += cbfs.o
 initobj-y += lzma.o
 #initobj-y += lzmadecode.o
 
-obj-$(CONFIG_USBDEBUG_DIRECT) += usbdebug_direct.o
+obj-$(CONFIG_USBDEBUG_DIRECT) += usbdebug.o
+
 obj-$(CONFIG_COMPRESSED_PAYLOAD_LZMA) += lzma.o
 
 obj-$(CONFIG_BOOTSPLASH) += jpeg.o
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
new file mode 100644 (file)
index 0000000..56ec1e3
--- /dev/null
@@ -0,0 +1,550 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2006 Eric Biederman (ebiederm@xmission.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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+/*
+ *     2006.12.10 yhlu moved it to corbeoot and use struct instead
+ */
+#if !defined(__ROMCC__)
+#include <console/console.h>
+#else
+#if CONFIG_USE_PRINTK_IN_CAR==0
+#define printk(BIOS_DEBUG, fmt, arg...)   do {} while(0)
+#endif
+#endif
+
+#include <arch/io.h>
+
+#include <usb_ch9.h>
+#include <ehci.h>
+#include <usbdebug.h>
+
+#define USB_DEBUG_DEVNUM 127
+
+#define DBGP_DATA_TOGGLE       0x8800
+#define DBGP_PID_UPDATE(x, tok) \
+       ((((x) ^ DBGP_DATA_TOGGLE) & 0xffff00) | ((tok) & 0xff))
+
+#define DBGP_LEN_UPDATE(x, len) (((x) & ~0x0f) | ((len) & 0x0f))
+/*
+ * USB Packet IDs (PIDs)
+ */
+
+/* token */
+#define USB_PID_OUT            0xe1
+#define USB_PID_IN             0x69
+#define USB_PID_SOF            0xa5
+#define USB_PID_SETUP          0x2d
+/* handshake */
+#define USB_PID_ACK            0xd2
+#define USB_PID_NAK            0x5a
+#define USB_PID_STALL          0x1e
+#define USB_PID_NYET           0x96
+/* data */
+#define USB_PID_DATA0          0xc3
+#define USB_PID_DATA1          0x4b
+#define USB_PID_DATA2          0x87
+#define USB_PID_MDATA          0x0f
+/* Special */
+#define USB_PID_PREAMBLE       0x3c
+#define USB_PID_ERR            0x3c
+#define USB_PID_SPLIT          0x78
+#define USB_PID_PING           0xb4
+#define USB_PID_UNDEF_0                0xf0
+
+#define USB_PID_DATA_TOGGLE    0x88
+#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
+
+#define PCI_CAP_ID_EHCI_DEBUG  0xa
+
+#define HUB_ROOT_RESET_TIME    50      /* times are in msec */
+#define HUB_SHORT_RESET_TIME   10
+#define HUB_LONG_RESET_TIME    200
+#define HUB_RESET_TIMEOUT      500
+
+#define DBGP_MAX_PACKET                8
+
+static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
+{
+       unsigned ctrl;
+       int loop = 0x100000;
+       do {
+               ctrl = read32(&ehci_debug->control);
+               /* Stop when the transaction is finished */
+               if (ctrl & DBGP_DONE)
+                       break;
+       } while(--loop>0);
+
+       if (!loop) return -1000;
+
+       /* Now that we have observed the completed transaction,
+        * clear the done bit.
+        */
+       write32(&ehci_debug->control, ctrl | DBGP_DONE);
+       return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl);
+}
+
+static void dbgp_mdelay(int ms)
+{
+       int i;
+       while (ms--) {
+               for (i = 0; i < 1000; i++)
+                       inb(0x80);
+       }
+}
+
+static void dbgp_breath(void)
+{
+       /* Sleep to give the debug port a chance to breathe */
+}
+
+static int dbgp_wait_until_done(struct ehci_dbg_port *ehci_debug, unsigned ctrl)
+{
+       unsigned pids, lpid;
+       int ret;
+
+       int loop = 3;
+retry:
+       write32(&ehci_debug->control, ctrl | DBGP_GO);
+       ret = dbgp_wait_until_complete(ehci_debug);
+       pids = read32(&ehci_debug->pids);
+       lpid = DBGP_PID_GET(pids);
+
+       if (ret < 0)
+               return ret;
+
+       /* If the port is getting full or it has dropped data
+        * start pacing ourselves, not necessary but it's friendly.
+        */
+       if ((lpid == USB_PID_NAK) || (lpid == USB_PID_NYET))
+               dbgp_breath();
+
+       /* If I get a NACK reissue the transmission */
+       if (lpid == USB_PID_NAK) {
+               if (--loop > 0) goto retry;
+       }
+
+       return ret;
+}
+
+static void dbgp_set_data(struct ehci_dbg_port *ehci_debug, const void *buf, int size)
+{
+       const unsigned char *bytes = buf;
+       unsigned lo, hi;
+       int i;
+       lo = hi = 0;
+       for (i = 0; i < 4 && i < size; i++)
+               lo |= bytes[i] << (8*i);
+       for (; i < 8 && i < size; i++)
+               hi |= bytes[i] << (8*(i - 4));
+       write32(&ehci_debug->data03, lo);
+       write32(&ehci_debug->data47, hi);
+}
+
+static void dbgp_get_data(struct ehci_dbg_port *ehci_debug, void *buf, int size)
+{
+       unsigned char *bytes = buf;
+       unsigned lo, hi;
+       int i;
+       lo = read32(&ehci_debug->data03);
+       hi = read32(&ehci_debug->data47);
+       for (i = 0; i < 4 && i < size; i++)
+               bytes[i] = (lo >> (8*i)) & 0xff;
+       for (; i < 8 && i < size; i++)
+               bytes[i] = (hi >> (8*(i - 4))) & 0xff;
+}
+
+static int dbgp_bulk_write(struct ehci_dbg_port *ehci_debug, unsigned devnum, unsigned endpoint, const char *bytes, int size)
+{
+       unsigned pids, addr, ctrl;
+       int ret;
+       if (size > DBGP_MAX_PACKET)
+               return -1;
+
+       addr = DBGP_EPADDR(devnum, endpoint);
+
+       pids = read32(&ehci_debug->pids);
+       pids = DBGP_PID_UPDATE(pids, USB_PID_OUT);
+
+       ctrl = read32(&ehci_debug->control);
+       ctrl = DBGP_LEN_UPDATE(ctrl, size);
+       ctrl |= DBGP_OUT;
+       ctrl |= DBGP_GO;
+
+       dbgp_set_data(ehci_debug, bytes, size);
+       write32(&ehci_debug->address, addr);
+       write32(&ehci_debug->pids, pids);
+
+       ret = dbgp_wait_until_done(ehci_debug, ctrl);
+       if (ret < 0) {
+               return ret;
+       }
+       return ret;
+}
+
+int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size)
+{
+       return dbgp_bulk_write(dbg_info->ehci_debug, dbg_info->devnum, dbg_info->endpoint_out, bytes, size);
+}
+
+static int dbgp_bulk_read(struct ehci_dbg_port *ehci_debug, unsigned devnum, unsigned endpoint, void *data, int size)
+{
+       unsigned pids, addr, ctrl;
+       int ret;
+
+       if (size > DBGP_MAX_PACKET)
+               return -1;
+
+       addr = DBGP_EPADDR(devnum, endpoint);
+
+       pids = read32(&ehci_debug->pids);
+       pids = DBGP_PID_UPDATE(pids, USB_PID_IN);
+
+       ctrl = read32(&ehci_debug->control);
+       ctrl = DBGP_LEN_UPDATE(ctrl, size);
+       ctrl &= ~DBGP_OUT;
+       ctrl |= DBGP_GO;
+
+       write32(&ehci_debug->address, addr);
+       write32(&ehci_debug->pids, pids);
+       ret = dbgp_wait_until_done(ehci_debug, ctrl);
+       if (ret < 0)
+               return ret;
+       if (size > ret)
+               size = ret;
+       dbgp_get_data(ehci_debug, data, size);
+       return ret;
+}
+int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size)
+{
+       return dbgp_bulk_read(dbg_info->ehci_debug, dbg_info->devnum, dbg_info->endpoint_in, data, size);
+}
+
+static int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned devnum, int requesttype, int request,
+       int value, int index, void *data, int size)
+{
+       unsigned pids, addr, ctrl;
+       struct usb_ctrlrequest req;
+       int read;
+       int ret;
+
+       read = (requesttype & USB_DIR_IN) != 0;
+       if (size > (read?DBGP_MAX_PACKET:0))
+               return -1;
+
+       /* Compute the control message */
+       req.bRequestType = requesttype;
+       req.bRequest = request;
+       req.wValue = value;
+       req.wIndex = index;
+       req.wLength = size;
+
+       pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP);
+       addr = DBGP_EPADDR(devnum, 0);
+
+       ctrl = read32(&ehci_debug->control);
+       ctrl = DBGP_LEN_UPDATE(ctrl, sizeof(req));
+       ctrl |= DBGP_OUT;
+       ctrl |= DBGP_GO;
+
+       /* Send the setup message */
+       dbgp_set_data(ehci_debug, &req, sizeof(req));
+       write32(&ehci_debug->address, addr);
+       write32(&ehci_debug->pids, pids);
+       ret = dbgp_wait_until_done(ehci_debug, ctrl);
+       if (ret < 0)
+               return ret;
+
+
+       /* Read the result */
+       ret = dbgp_bulk_read(ehci_debug, devnum, 0, data, size);
+       return ret;
+}
+
+static int ehci_reset_port(struct ehci_regs *ehci_regs, int port)
+{
+       unsigned portsc;
+       unsigned delay_time, delay;
+       int loop;
+
+       /* Reset the usb debug port */
+       portsc = read32(&ehci_regs->port_status[port - 1]);
+       portsc &= ~PORT_PE;
+       portsc |= PORT_RESET;
+       write32(&ehci_regs->port_status[port - 1], portsc);
+
+       delay = HUB_ROOT_RESET_TIME;
+       for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT;
+            delay_time += delay) {
+               dbgp_mdelay(delay);
+
+               portsc = read32(&ehci_regs->port_status[port - 1]);
+               if (portsc & PORT_RESET) {
+                       /* force reset to complete */
+                       loop = 2;
+                       write32(&ehci_regs->port_status[port - 1],
+                                       portsc & ~(PORT_RWC_BITS | PORT_RESET));
+                       do {
+                               dbgp_mdelay(delay);
+                               portsc = read32(&ehci_regs->port_status[port - 1]);
+                               delay_time += delay;
+                       } while ((portsc & PORT_RESET) && (--loop > 0));
+                       if (!loop) {
+                               printk(BIOS_DEBUG, "ehci_reset_port forced done");
+                       }
+               }
+
+               /* Device went away? */
+               if (!(portsc & PORT_CONNECT))
+                       return -107;//-ENOTCONN;
+
+               /* bomb out completely if something weird happend */
+               if ((portsc & PORT_CSC))
+                       return -22;//-EINVAL;
+
+               /* If we've finished resetting, then break out of the loop */
+               if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
+                       return 0;
+       }
+       return -16;//-EBUSY;
+}
+
+static int ehci_wait_for_port(struct ehci_regs *ehci_regs, int port)
+{
+       unsigned status;
+       int ret, reps;
+       for (reps = 0; reps < 3; reps++) {
+               dbgp_mdelay(100);
+               status = read32(&ehci_regs->status);
+               if (status & STS_PCD) {
+                       ret = ehci_reset_port(ehci_regs, port);
+                       if (ret == 0)
+                               return 0;
+               }
+       }
+       return -107; //-ENOTCONN;
+}
+
+
+#define DBGP_DEBUG 1
+#if DBGP_DEBUG
+# define dbgp_printk(fmt_arg...) printk(BIOS_DEBUG, fmt_arg)
+#else
+#define dbgp_printk(fmt_arg...)   do {} while(0)
+#endif
+static void usbdebug_direct_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info)
+{
+       struct ehci_caps *ehci_caps;
+       struct ehci_regs *ehci_regs;
+       struct ehci_dbg_port *ehci_debug;
+       unsigned dbgp_endpoint_out;
+       unsigned dbgp_endpoint_in;
+       struct usb_debug_descriptor dbgp_desc;
+       unsigned ctrl, devnum;
+       int ret;
+       unsigned delay_time, delay;
+       int loop;
+
+       unsigned cmd,  status, portsc, hcs_params, debug_port, n_ports, new_debug_port;
+       int i;
+       unsigned port_map_tried;
+
+       unsigned playtimes = 3;
+
+       ehci_caps  = (struct ehci_caps *)ehci_bar;
+       ehci_regs  = (struct ehci_regs *)(ehci_bar + HC_LENGTH(read32(&ehci_caps->hc_capbase)));
+       ehci_debug = (struct ehci_dbg_port *)(ehci_bar + offset);
+
+       info->ehci_debug = (void *)0;
+
+try_next_time:
+       port_map_tried = 0;
+
+try_next_port:
+       hcs_params = read32(&ehci_caps->hcs_params);
+       debug_port = HCS_DEBUG_PORT(hcs_params);
+       n_ports    = HCS_N_PORTS(hcs_params);
+
+       dbgp_printk("ehci_bar: 0x%x\n", ehci_bar);
+       dbgp_printk("debug_port: %d\n", debug_port);
+       dbgp_printk("n_ports:    %d\n", n_ports);
+
+#if 1
+        for (i = 1; i <= n_ports; i++) {
+                portsc = read32(&ehci_regs->port_status[i-1]);
+                dbgp_printk("PORTSC #%d: %08x\n", i, portsc);
+        }
+#endif
+
+       if(port_map_tried && (new_debug_port!=debug_port)) {
+               if(--playtimes) {
+                       set_debug_port(debug_port);
+                       goto try_next_time;
+               }
+               return;
+       }
+
+       /* Reset the EHCI controller */
+       loop = 10;
+       cmd = read32(&ehci_regs->command);
+       cmd |= CMD_RESET;
+       write32(&ehci_regs->command, cmd);
+       do {
+               cmd = read32(&ehci_regs->command);
+       } while ((cmd & CMD_RESET) && (--loop > 0));
+
+       if(!loop)
+               dbgp_printk("Could not reset EHCI controller.\n");
+       else
+               dbgp_printk("EHCI controller reset successfully.\n");
+
+       /* Claim ownership, but do not enable yet */
+       ctrl = read32(&ehci_debug->control);
+       ctrl |= DBGP_OWNER;
+       ctrl &= ~(DBGP_ENABLED | DBGP_INUSE);
+       write32(&ehci_debug->control, ctrl);
+
+       /* Start the ehci running */
+       cmd = read32(&ehci_regs->command);
+       cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET);
+       cmd |= CMD_RUN;
+       write32(&ehci_regs->command, cmd);
+
+       /* Ensure everything is routed to the EHCI */
+       write32(&ehci_regs->configured_flag, FLAG_CF);
+
+       /* Wait until the controller is no longer halted */
+       loop = 10;
+       do {
+               status = read32(&ehci_regs->status);
+       } while ((status & STS_HALT) && (--loop>0));
+
+       if(!loop) {
+               dbgp_printk("EHCI could not be started.\n");
+               return;
+       }
+       dbgp_printk("EHCI started.\n");
+
+       /* Wait for a device to show up in the debug port */
+       ret = ehci_wait_for_port(ehci_regs, debug_port);
+       if (ret < 0) {
+               dbgp_printk("No device found in debug port %d\n", debug_port);
+               goto next_debug_port;
+       }
+       dbgp_printk("EHCI done waiting for port.\n");
+
+       /* Enable the debug port */
+       ctrl = read32(&ehci_debug->control);
+       ctrl |= DBGP_CLAIM;
+       write32(&ehci_debug->control, ctrl);
+       ctrl = read32(&ehci_debug->control);
+       if ((ctrl & DBGP_CLAIM) != DBGP_CLAIM) {
+               dbgp_printk("No device in EHCI debug port.\n");
+               write32(&ehci_debug->control, ctrl & ~DBGP_CLAIM);
+               goto err;
+       }
+       dbgp_printk("EHCI debug port enabled.\n");
+
+       /* Completely transfer the debug device to the debug controller */
+       portsc = read32(&ehci_regs->port_status[debug_port - 1]);
+       portsc &= ~PORT_PE;
+       write32(&ehci_regs->port_status[debug_port - 1], portsc);
+
+       dbgp_mdelay(100);
+
+       /* Find the debug device and make it device number 127 */
+       for (devnum = 0; devnum <= 127; devnum++) {
+               ret = dbgp_control_msg(ehci_debug, devnum,
+                       USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+                       USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
+                       &dbgp_desc, sizeof(dbgp_desc));
+               if (ret > 0)
+                       break;
+       }
+       if (devnum > 127) {
+               dbgp_printk("Could not find attached debug device.\n");
+               goto err;
+       }
+       if (ret < 0) {
+               dbgp_printk("Attached device is not a debug device.\n");
+               goto err;
+       }
+       dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;
+       dbgp_endpoint_in = dbgp_desc.bDebugInEndpoint;
+
+       /* Move the device to 127 if it isn't already there */
+       if (devnum != USB_DEBUG_DEVNUM) {
+               ret = dbgp_control_msg(ehci_debug, devnum,
+                       USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+                       USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, (void *)0, 0);
+               if (ret < 0) {
+                       dbgp_printk("Could not move attached device to %d.\n",
+                               USB_DEBUG_DEVNUM);
+                       goto err;
+               }
+               devnum = USB_DEBUG_DEVNUM;
+               dbgp_printk("EHCI debug device renamed to 127.\n");
+       }
+
+       /* Enable the debug interface */
+       ret = dbgp_control_msg(ehci_debug, USB_DEBUG_DEVNUM,
+               USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+               USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, 0, (void *)0, 0);
+       if (ret < 0) {
+               dbgp_printk("Could not enable EHCI debug device.\n");
+               goto err;
+       }
+       dbgp_printk("EHCI debug interface enabled.\n");
+
+       /* Perform a small write to get the even/odd data state in sync
+        */
+       ret = dbgp_bulk_write(ehci_debug, USB_DEBUG_DEVNUM, dbgp_endpoint_out, " ",1);
+       if (ret < 0) {
+               dbgp_printk("dbgp_bulk_write failed: %d\n", ret);
+               goto err;
+       }
+       dbgp_printk("Test write done\n");
+
+       info->ehci_caps = ehci_caps;
+       info->ehci_regs = ehci_regs;
+       info->ehci_debug = ehci_debug;
+       info->devnum = devnum;
+       info->endpoint_out = dbgp_endpoint_out;
+       info->endpoint_in = dbgp_endpoint_in;
+
+       return;
+err:
+       /* Things didn't work so remove my claim */
+       ctrl = read32(&ehci_debug->control);
+       ctrl &= ~(DBGP_CLAIM | DBGP_OUT);
+       write32((unsigned long)&ehci_debug->control, ctrl);
+
+next_debug_port:
+       port_map_tried |= (1<<(debug_port-1));
+       if(port_map_tried != ((1<<n_ports) -1)) {
+               new_debug_port = ((debug_port-1+1)%n_ports) + 1;
+               set_debug_port(new_debug_port);
+               goto try_next_port;
+       }
+       if(--playtimes) {
+               set_debug_port(debug_port);
+               goto try_next_time;
+       }
+
+}
+
+
diff --git a/src/lib/usbdebug_direct.c b/src/lib/usbdebug_direct.c
deleted file mode 100644 (file)
index 19ce150..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2006 Eric Biederman (ebiederm@xmission.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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-/*
- *     2006.12.10 yhlu moved it to corbeoot and use struct instead
- */
-#if !defined(__ROMCC__)
-#include <console/console.h>
-#else
-#if CONFIG_USE_PRINTK_IN_CAR==0
-#define printk(BIOS_DEBUG, fmt, arg...)   do {} while(0)
-#endif
-#endif
-
-#include <arch/io.h>
-
-#include <usb_ch9.h>
-#include <ehci.h>
-#include <usbdebug_direct.h>
-
-#define USB_DEBUG_DEVNUM 127
-
-#define DBGP_DATA_TOGGLE       0x8800
-#define DBGP_PID_UPDATE(x, tok) \
-       ((((x) ^ DBGP_DATA_TOGGLE) & 0xffff00) | ((tok) & 0xff))
-
-#define DBGP_LEN_UPDATE(x, len) (((x) & ~0x0f) | ((len) & 0x0f))
-/*
- * USB Packet IDs (PIDs)
- */
-
-/* token */
-#define USB_PID_OUT            0xe1
-#define USB_PID_IN             0x69
-#define USB_PID_SOF            0xa5
-#define USB_PID_SETUP          0x2d
-/* handshake */
-#define USB_PID_ACK            0xd2
-#define USB_PID_NAK            0x5a
-#define USB_PID_STALL          0x1e
-#define USB_PID_NYET           0x96
-/* data */
-#define USB_PID_DATA0          0xc3
-#define USB_PID_DATA1          0x4b
-#define USB_PID_DATA2          0x87
-#define USB_PID_MDATA          0x0f
-/* Special */
-#define USB_PID_PREAMBLE       0x3c
-#define USB_PID_ERR            0x3c
-#define USB_PID_SPLIT          0x78
-#define USB_PID_PING           0xb4
-#define USB_PID_UNDEF_0                0xf0
-
-#define USB_PID_DATA_TOGGLE    0x88
-#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
-
-#define PCI_CAP_ID_EHCI_DEBUG  0xa
-
-#define HUB_ROOT_RESET_TIME    50      /* times are in msec */
-#define HUB_SHORT_RESET_TIME   10
-#define HUB_LONG_RESET_TIME    200
-#define HUB_RESET_TIMEOUT      500
-
-#define DBGP_MAX_PACKET                8
-
-static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
-{
-       unsigned ctrl;
-       int loop = 0x100000;
-       do {
-               ctrl = read32(&ehci_debug->control);
-               /* Stop when the transaction is finished */
-               if (ctrl & DBGP_DONE)
-                       break;
-       } while(--loop>0);
-
-       if (!loop) return -1000;
-
-       /* Now that we have observed the completed transaction,
-        * clear the done bit.
-        */
-       write32(&ehci_debug->control, ctrl | DBGP_DONE);
-       return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl);
-}
-
-static void dbgp_mdelay(int ms)
-{
-       int i;
-       while (ms--) {
-               for (i = 0; i < 1000; i++)
-                       inb(0x80);
-       }
-}
-
-static void dbgp_breath(void)
-{
-       /* Sleep to give the debug port a chance to breathe */
-}
-
-static int dbgp_wait_until_done(struct ehci_dbg_port *ehci_debug, unsigned ctrl)
-{
-       unsigned pids, lpid;
-       int ret;
-
-       int loop = 3;
-retry:
-       write32(&ehci_debug->control, ctrl | DBGP_GO);
-       ret = dbgp_wait_until_complete(ehci_debug);
-       pids = read32(&ehci_debug->pids);
-       lpid = DBGP_PID_GET(pids);
-
-       if (ret < 0)
-               return ret;
-
-       /* If the port is getting full or it has dropped data
-        * start pacing ourselves, not necessary but it's friendly.
-        */
-       if ((lpid == USB_PID_NAK) || (lpid == USB_PID_NYET))
-               dbgp_breath();
-
-       /* If I get a NACK reissue the transmission */
-       if (lpid == USB_PID_NAK) {
-               if (--loop > 0) goto retry;
-       }
-
-       return ret;
-}
-
-static void dbgp_set_data(struct ehci_dbg_port *ehci_debug, const void *buf, int size)
-{
-       const unsigned char *bytes = buf;
-       unsigned lo, hi;
-       int i;
-       lo = hi = 0;
-       for (i = 0; i < 4 && i < size; i++)
-               lo |= bytes[i] << (8*i);
-       for (; i < 8 && i < size; i++)
-               hi |= bytes[i] << (8*(i - 4));
-       write32(&ehci_debug->data03, lo);
-       write32(&ehci_debug->data47, hi);
-}
-
-static void dbgp_get_data(struct ehci_dbg_port *ehci_debug, void *buf, int size)
-{
-       unsigned char *bytes = buf;
-       unsigned lo, hi;
-       int i;
-       lo = read32(&ehci_debug->data03);
-       hi = read32(&ehci_debug->data47);
-       for (i = 0; i < 4 && i < size; i++)
-               bytes[i] = (lo >> (8*i)) & 0xff;
-       for (; i < 8 && i < size; i++)
-               bytes[i] = (hi >> (8*(i - 4))) & 0xff;
-}
-
-static int dbgp_bulk_write(struct ehci_dbg_port *ehci_debug, unsigned devnum, unsigned endpoint, const char *bytes, int size)
-{
-       unsigned pids, addr, ctrl;
-       int ret;
-       if (size > DBGP_MAX_PACKET)
-               return -1;
-
-       addr = DBGP_EPADDR(devnum, endpoint);
-
-       pids = read32(&ehci_debug->pids);
-       pids = DBGP_PID_UPDATE(pids, USB_PID_OUT);
-
-       ctrl = read32(&ehci_debug->control);
-       ctrl = DBGP_LEN_UPDATE(ctrl, size);
-       ctrl |= DBGP_OUT;
-       ctrl |= DBGP_GO;
-
-       dbgp_set_data(ehci_debug, bytes, size);
-       write32(&ehci_debug->address, addr);
-       write32(&ehci_debug->pids, pids);
-
-       ret = dbgp_wait_until_done(ehci_debug, ctrl);
-       if (ret < 0) {
-               return ret;
-       }
-       return ret;
-}
-
-int dbgp_bulk_write_x(struct ehci_debug_info *dbg_info, const char *bytes, int size)
-{
-       return dbgp_bulk_write(dbg_info->ehci_debug, dbg_info->devnum, dbg_info->endpoint_out, bytes, size);
-}
-
-static int dbgp_bulk_read(struct ehci_dbg_port *ehci_debug, unsigned devnum, unsigned endpoint, void *data, int size)
-{
-       unsigned pids, addr, ctrl;
-       int ret;
-
-       if (size > DBGP_MAX_PACKET)
-               return -1;
-
-       addr = DBGP_EPADDR(devnum, endpoint);
-
-       pids = read32(&ehci_debug->pids);
-       pids = DBGP_PID_UPDATE(pids, USB_PID_IN);
-
-       ctrl = read32(&ehci_debug->control);
-       ctrl = DBGP_LEN_UPDATE(ctrl, size);
-       ctrl &= ~DBGP_OUT;
-       ctrl |= DBGP_GO;
-
-       write32(&ehci_debug->address, addr);
-       write32(&ehci_debug->pids, pids);
-       ret = dbgp_wait_until_done(ehci_debug, ctrl);
-       if (ret < 0)
-               return ret;
-       if (size > ret)
-               size = ret;
-       dbgp_get_data(ehci_debug, data, size);
-       return ret;
-}
-int dbgp_bulk_read_x(struct ehci_debug_info *dbg_info, void *data, int size)
-{
-       return dbgp_bulk_read(dbg_info->ehci_debug, dbg_info->devnum, dbg_info->endpoint_in, data, size);
-}
-
-static int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned devnum, int requesttype, int request,
-       int value, int index, void *data, int size)
-{
-       unsigned pids, addr, ctrl;
-       struct usb_ctrlrequest req;
-       int read;
-       int ret;
-
-       read = (requesttype & USB_DIR_IN) != 0;
-       if (size > (read?DBGP_MAX_PACKET:0))
-               return -1;
-
-       /* Compute the control message */
-       req.bRequestType = requesttype;
-       req.bRequest = request;
-       req.wValue = value;
-       req.wIndex = index;
-       req.wLength = size;
-
-       pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP);
-       addr = DBGP_EPADDR(devnum, 0);
-
-       ctrl = read32(&ehci_debug->control);
-       ctrl = DBGP_LEN_UPDATE(ctrl, sizeof(req));
-       ctrl |= DBGP_OUT;
-       ctrl |= DBGP_GO;
-
-       /* Send the setup message */
-       dbgp_set_data(ehci_debug, &req, sizeof(req));
-       write32(&ehci_debug->address, addr);
-       write32(&ehci_debug->pids, pids);
-       ret = dbgp_wait_until_done(ehci_debug, ctrl);
-       if (ret < 0)
-               return ret;
-
-
-       /* Read the result */
-       ret = dbgp_bulk_read(ehci_debug, devnum, 0, data, size);
-       return ret;
-}
-
-static int ehci_reset_port(struct ehci_regs *ehci_regs, int port)
-{
-       unsigned portsc;
-       unsigned delay_time, delay;
-       int loop;
-
-       /* Reset the usb debug port */
-       portsc = read32(&ehci_regs->port_status[port - 1]);
-       portsc &= ~PORT_PE;
-       portsc |= PORT_RESET;
-       write32(&ehci_regs->port_status[port - 1], portsc);
-
-       delay = HUB_ROOT_RESET_TIME;
-       for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT;
-            delay_time += delay) {
-               dbgp_mdelay(delay);
-
-               portsc = read32(&ehci_regs->port_status[port - 1]);
-               if (portsc & PORT_RESET) {
-                       /* force reset to complete */
-                       loop = 2;
-                       write32(&ehci_regs->port_status[port - 1],
-                                       portsc & ~(PORT_RWC_BITS | PORT_RESET));
-                       do {
-                               dbgp_mdelay(delay);
-                               portsc = read32(&ehci_regs->port_status[port - 1]);
-                               delay_time += delay;
-                       } while ((portsc & PORT_RESET) && (--loop > 0));
-                       if (!loop) {
-                               printk(BIOS_DEBUG, "ehci_reset_port forced done");
-                       }
-               }
-
-               /* Device went away? */
-               if (!(portsc & PORT_CONNECT))
-                       return -107;//-ENOTCONN;
-
-               /* bomb out completely if something weird happend */
-               if ((portsc & PORT_CSC))
-                       return -22;//-EINVAL;
-
-               /* If we've finished resetting, then break out of the loop */
-               if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
-                       return 0;
-       }
-       return -16;//-EBUSY;
-}
-
-static int ehci_wait_for_port(struct ehci_regs *ehci_regs, int port)
-{
-       unsigned status;
-       int ret, reps;
-       for (reps = 0; reps < 3; reps++) {
-               dbgp_mdelay(100);
-               status = read32(&ehci_regs->status);
-               if (status & STS_PCD) {
-                       ret = ehci_reset_port(ehci_regs, port);
-                       if (ret == 0)
-                               return 0;
-               }
-       }
-       return -107; //-ENOTCONN;
-}
-
-
-#define DBGP_DEBUG 1
-#if DBGP_DEBUG
-# define dbgp_printk(fmt_arg...) printk(BIOS_DEBUG, fmt_arg)
-#else
-#define dbgp_printk(fmt_arg...)   do {} while(0)
-#endif
-static void usbdebug_direct_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info)
-{
-       struct ehci_caps *ehci_caps;
-       struct ehci_regs *ehci_regs;
-       struct ehci_dbg_port *ehci_debug;
-       unsigned dbgp_endpoint_out;
-       unsigned dbgp_endpoint_in;
-       struct usb_debug_descriptor dbgp_desc;
-       unsigned ctrl, devnum;
-       int ret;
-       unsigned delay_time, delay;
-       int loop;
-
-       unsigned cmd,  status, portsc, hcs_params, debug_port, n_ports, new_debug_port;
-       int i;
-       unsigned port_map_tried;
-
-       unsigned playtimes = 3;
-
-       ehci_caps  = (struct ehci_caps *)ehci_bar;
-       ehci_regs  = (struct ehci_regs *)(ehci_bar + HC_LENGTH(read32(&ehci_caps->hc_capbase)));
-       ehci_debug = (struct ehci_dbg_port *)(ehci_bar + offset);
-
-       info->ehci_debug = (void *)0;
-
-try_next_time:
-       port_map_tried = 0;
-
-try_next_port:
-       hcs_params = read32(&ehci_caps->hcs_params);
-       debug_port = HCS_DEBUG_PORT(hcs_params);
-       n_ports    = HCS_N_PORTS(hcs_params);
-
-       dbgp_printk("ehci_bar: 0x%x\n", ehci_bar);
-       dbgp_printk("debug_port: %d\n", debug_port);
-       dbgp_printk("n_ports:    %d\n", n_ports);
-
-#if 1
-        for (i = 1; i <= n_ports; i++) {
-                portsc = read32(&ehci_regs->port_status[i-1]);
-                dbgp_printk("PORTSC #%d: %08x\n", i, portsc);
-        }
-#endif
-
-       if(port_map_tried && (new_debug_port!=debug_port)) {
-               if(--playtimes) {
-                       set_debug_port(debug_port);
-                       goto try_next_time;
-               }
-               return;
-       }
-
-       /* Reset the EHCI controller */
-       loop = 10;
-       cmd = read32(&ehci_regs->command);
-       cmd |= CMD_RESET;
-       write32(&ehci_regs->command, cmd);
-       do {
-               cmd = read32(&ehci_regs->command);
-       } while ((cmd & CMD_RESET) && (--loop > 0));
-
-       if(!loop)
-               dbgp_printk("Could not reset EHCI controller.\n");
-       else
-               dbgp_printk("EHCI controller reset successfully.\n");
-
-       /* Claim ownership, but do not enable yet */
-       ctrl = read32(&ehci_debug->control);
-       ctrl |= DBGP_OWNER;
-       ctrl &= ~(DBGP_ENABLED | DBGP_INUSE);
-       write32(&ehci_debug->control, ctrl);
-
-       /* Start the ehci running */
-       cmd = read32(&ehci_regs->command);
-       cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET);
-       cmd |= CMD_RUN;
-       write32(&ehci_regs->command, cmd);
-
-       /* Ensure everything is routed to the EHCI */
-       write32(&ehci_regs->configured_flag, FLAG_CF);
-
-       /* Wait until the controller is no longer halted */
-       loop = 10;
-       do {
-               status = read32(&ehci_regs->status);
-       } while ((status & STS_HALT) && (--loop>0));
-
-       if(!loop) {
-               dbgp_printk("EHCI could not be started.\n");
-               return;
-       }
-       dbgp_printk("EHCI started.\n");
-
-       /* Wait for a device to show up in the debug port */
-       ret = ehci_wait_for_port(ehci_regs, debug_port);
-       if (ret < 0) {
-               dbgp_printk("No device found in debug port %d\n", debug_port);
-               goto next_debug_port;
-       }
-       dbgp_printk("EHCI done waiting for port.\n");
-
-       /* Enable the debug port */
-       ctrl = read32(&ehci_debug->control);
-       ctrl |= DBGP_CLAIM;
-       write32(&ehci_debug->control, ctrl);
-       ctrl = read32(&ehci_debug->control);
-       if ((ctrl & DBGP_CLAIM) != DBGP_CLAIM) {
-               dbgp_printk("No device in EHCI debug port.\n");
-               write32(&ehci_debug->control, ctrl & ~DBGP_CLAIM);
-               goto err;
-       }
-       dbgp_printk("EHCI debug port enabled.\n");
-
-       /* Completely transfer the debug device to the debug controller */
-       portsc = read32(&ehci_regs->port_status[debug_port - 1]);
-       portsc &= ~PORT_PE;
-       write32(&ehci_regs->port_status[debug_port - 1], portsc);
-
-       dbgp_mdelay(100);
-
-       /* Find the debug device and make it device number 127 */
-       for (devnum = 0; devnum <= 127; devnum++) {
-               ret = dbgp_control_msg(ehci_debug, devnum,
-                       USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
-                       USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
-                       &dbgp_desc, sizeof(dbgp_desc));
-               if (ret > 0)
-                       break;
-       }
-       if (devnum > 127) {
-               dbgp_printk("Could not find attached debug device.\n");
-               goto err;
-       }
-       if (ret < 0) {
-               dbgp_printk("Attached device is not a debug device.\n");
-               goto err;
-       }
-       dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;
-       dbgp_endpoint_in = dbgp_desc.bDebugInEndpoint;
-
-       /* Move the device to 127 if it isn't already there */
-       if (devnum != USB_DEBUG_DEVNUM) {
-               ret = dbgp_control_msg(ehci_debug, devnum,
-                       USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
-                       USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, (void *)0, 0);
-               if (ret < 0) {
-                       dbgp_printk("Could not move attached device to %d.\n",
-                               USB_DEBUG_DEVNUM);
-                       goto err;
-               }
-               devnum = USB_DEBUG_DEVNUM;
-               dbgp_printk("EHCI debug device renamed to 127.\n");
-       }
-
-       /* Enable the debug interface */
-       ret = dbgp_control_msg(ehci_debug, USB_DEBUG_DEVNUM,
-               USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
-               USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, 0, (void *)0, 0);
-       if (ret < 0) {
-               dbgp_printk("Could not enable EHCI debug device.\n");
-               goto err;
-       }
-       dbgp_printk("EHCI debug interface enabled.\n");
-
-       /* Perform a small write to get the even/odd data state in sync
-        */
-       ret = dbgp_bulk_write(ehci_debug, USB_DEBUG_DEVNUM, dbgp_endpoint_out, " ",1);
-       if (ret < 0) {
-               dbgp_printk("dbgp_bulk_write failed: %d\n", ret);
-               goto err;
-       }
-       dbgp_printk("Test write done\n");
-
-       info->ehci_caps = ehci_caps;
-       info->ehci_regs = ehci_regs;
-       info->ehci_debug = ehci_debug;
-       info->devnum = devnum;
-       info->endpoint_out = dbgp_endpoint_out;
-       info->endpoint_in = dbgp_endpoint_in;
-
-       return;
-err:
-       /* Things didn't work so remove my claim */
-       ctrl = read32(&ehci_debug->control);
-       ctrl &= ~(DBGP_CLAIM | DBGP_OUT);
-       write32((unsigned long)&ehci_debug->control, ctrl);
-
-next_debug_port:
-       port_map_tried |= (1<<(debug_port-1));
-       if(port_map_tried != ((1<<n_ports) -1)) {
-               new_debug_port = ((debug_port-1+1)%n_ports) + 1;
-               set_debug_port(new_debug_port);
-               goto try_next_port;
-       }
-       if(--playtimes) {
-               set_debug_port(debug_port);
-               goto try_next_time;
-       }
-
-}
-
-
index ecc9e4bb03e6d29290a6cb72a57d2483fe5a05d3..0da4b8f2934830469702d6179a33d8696f26d3d7 100644 (file)
@@ -40,7 +40,7 @@
 #if CONFIG_USBDEBUG_DIRECT
 #define DBGP_DEFAULT 0
 #include "southbridge/intel/i82801gx/i82801gx_usb_debug.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 
 #include "lib/ramtest.c"
index 5aee58d867c9626a23440fc8c5a3583b061d7b18..3ba256a606227d90003daa3ecdef1ff534a55f10 100644 (file)
@@ -55,8 +55,8 @@
 
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/sis/sis966/sis966_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/sis/sis966/sis966_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
index ad6ee79ab72e512d0b16778ef8f8f2109f3f4691..683f92b5f603107d3bcb19017795690efd651fcf 100644 (file)
@@ -53,8 +53,8 @@
 
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
index c50a66f77639691485947d8adc113bc68b84fd39..961069a59acf595e969d679586f6f1f304b62546 100644 (file)
@@ -42,7 +42,7 @@
 #if CONFIG_USBDEBUG_DIRECT
 #define DBGP_DEFAULT 1
 #include "southbridge/intel/i82801gx/i82801gx_usb_debug.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 
 #include "lib/ramtest.c"
index cb400347516f6750df537ccd3af28cde93b54f7d..94a5065fa11ab6e8b0d5aca76939a99c94f968a7 100644 (file)
@@ -50,9 +50,9 @@
 
 #if CONFIG_USBDEBUG_DIRECT
 #define DBGP_DEFAULT 1
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #include "southbridge/intel/i82801gx/i82801gx_usb_debug.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 
 #include "lib/ramtest.c"
index 167fa34e265c7226f04d58dc3a8161ae4fad261b..55adf23dbaafcddf23d1a13572afa6bea7484c4d 100644 (file)
@@ -57,8 +57,8 @@
 
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 #include <cpu/amd/model_fxx_rev.h>
index 1e44c86c5b45c84a0e586da0ffb057487df59bfc..e0566b611434cf072d56f13380690ca04bea69ed 100644 (file)
@@ -46,8 +46,8 @@
 #include "option_table.h"
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
index db93735052e994f86e2cb69a732644d61541c0f5..d5b717f8b357dd232bee5c3ecf7634a0ca500adc 100644 (file)
@@ -53,8 +53,8 @@
 
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
index 803aaee89b5751ee4f40499bc3842720ed2d3b40..a910d1aadd85fa7ed19b8a7fdff6e8ee01a0f076 100644 (file)
@@ -44,7 +44,7 @@
 #if CONFIG_USBDEBUG_DIRECT
 #define DBGP_DEFAULT 1
 #include "southbridge/intel/i82801gx/i82801gx_usb_debug.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 
 #include "lib/ramtest.c"
index 180b1eb26f4db54b0bfcb0dceee1908421316578..4f536e77d7a67b2b769e8cb35fc94e25849f2386 100644 (file)
@@ -53,8 +53,8 @@
 
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
index 5d54713ece2632094f6e8f6f4e4e1e3e490714a8..529047092958f70a15dcac324dabaa0e9c7628eb 100644 (file)
@@ -46,8 +46,8 @@
 #include "option_table.h"
 #include <console/console.h>
 #if CONFIG_USBDEBUG_DIRECT
-#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c"
-#include "pc80/usbdebug_direct_serial.c"
+#include "southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c"
+#include "pc80/usbdebug_serial.c"
 #endif
 #include "lib/ramtest.c"
 
diff --git a/src/pc80/usbdebug_direct_serial.c b/src/pc80/usbdebug_direct_serial.c
deleted file mode 100644 (file)
index 15eac02..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * 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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#include "../lib/usbdebug_direct.c"
-
-static void early_usbdebug_direct_init(void)
-{
-       struct ehci_debug_info *dbg_info = (struct ehci_debug_info *)
-           (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
-
-       usbdebug_direct_init(EHCI_BAR, EHCI_DEBUG_OFFSET, dbg_info);
-}
-
-void usbdebug_direct_tx_byte(unsigned char data)
-{
-       struct ehci_debug_info *dbg_info;
-
-       /* "Find" dbg_info structure in Cache */
-       dbg_info = (struct ehci_debug_info *)
-           (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
-
-       if (dbg_info->ehci_debug) {
-               dbgp_bulk_write_x(dbg_info, &data, 1);
-       }
-}
-
-void usbdebug_direct_ram_tx_byte(unsigned char data)
-{
-       struct ehci_debug_info *dbg_info;
-
-       /* "Find" dbg_info structure in RAM */
-       dbg_info = (struct ehci_debug_info *)
-           ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
-
-       if (dbg_info->ehci_debug) {
-               dbgp_bulk_write_x(dbg_info, &data, 1);
-       }
-}
diff --git a/src/pc80/usbdebug_serial.c b/src/pc80/usbdebug_serial.c
new file mode 100644 (file)
index 0000000..474882b
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include "../lib/usbdebug.c"
+
+static void early_usbdebug_direct_init(void)
+{
+       struct ehci_debug_info *dbg_info = (struct ehci_debug_info *)
+           (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
+
+       usbdebug_direct_init(EHCI_BAR, EHCI_DEBUG_OFFSET, dbg_info);
+}
+
+void usbdebug_direct_tx_byte(unsigned char data)
+{
+       struct ehci_debug_info *dbg_info;
+
+       /* "Find" dbg_info structure in Cache */
+       dbg_info = (struct ehci_debug_info *)
+           (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
+
+       if (dbg_info->ehci_debug) {
+               dbgp_bulk_write_x(dbg_info, &data, 1);
+       }
+}
+
+void usbdebug_direct_ram_tx_byte(unsigned char data)
+{
+       struct ehci_debug_info *dbg_info;
+
+       /* "Find" dbg_info structure in RAM */
+       dbg_info = (struct ehci_debug_info *)
+           ((CONFIG_RAMTOP) - sizeof(struct ehci_debug_info));
+
+       if (dbg_info->ehci_debug) {
+               dbgp_bulk_write_x(dbg_info, &data, 1);
+       }
+}
diff --git a/src/southbridge/amd/sb600/sb600_enable_usbdebug.c b/src/southbridge/amd/sb600/sb600_enable_usbdebug.c
new file mode 100644 (file)
index 0000000..5fded2f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef SB600_DEVN_BASE
+
+#define SB600_DEVN_BASE 0
+
+#endif
+
+#define EHCI_BAR_INDEX 0x10
+#define EHCI_BAR 0xFEF00000
+#define EHCI_DEBUG_OFFSET 0xE0
+
+static void sb600_enable_usbdebug_direct(u32 port)
+{
+       set_debug_port(port);
+       pci_write_config32(PCI_DEV(0, SB600_DEVN_BASE + 0x13, 5),
+                          EHCI_BAR_INDEX, EHCI_BAR);
+       pci_write_config8(PCI_DEV(0, SB600_DEVN_BASE + 0x13, 5), 0x04, 0x2);    /* mem space enabe */
+}
diff --git a/src/southbridge/amd/sb600/sb600_enable_usbdebug_direct.c b/src/southbridge/amd/sb600/sb600_enable_usbdebug_direct.c
deleted file mode 100644 (file)
index 5fded2f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * 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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef SB600_DEVN_BASE
-
-#define SB600_DEVN_BASE 0
-
-#endif
-
-#define EHCI_BAR_INDEX 0x10
-#define EHCI_BAR 0xFEF00000
-#define EHCI_DEBUG_OFFSET 0xE0
-
-static void sb600_enable_usbdebug_direct(u32 port)
-{
-       set_debug_port(port);
-       pci_write_config32(PCI_DEV(0, SB600_DEVN_BASE + 0x13, 5),
-                          EHCI_BAR_INDEX, EHCI_BAR);
-       pci_write_config8(PCI_DEV(0, SB600_DEVN_BASE + 0x13, 5), 0x04, 0x2);    /* mem space enabe */
-}
index b6e1fbec6b5e18fe6c07bf866cb936cae467e89d..3b5e5f562b3501ca5df038d1a8312688d54e707f 100644 (file)
@@ -22,7 +22,7 @@
 #include <device/pci.h>
 #include <device/pci_ids.h>
 #include <device/pci_ops.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #include <arch/io.h>
 #include "sb600.h"
 
diff --git a/src/southbridge/amd/sb700/sb700_enable_usbdebug.c b/src/southbridge/amd/sb700/sb700_enable_usbdebug.c
new file mode 100644 (file)
index 0000000..b739fe2
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2010 Advanced Micro Devices, Inc.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef SB700_DEVN_BASE
+
+#define SB700_DEVN_BASE 0
+
+#endif
+
+#define EHCI_BAR_INDEX 0x10
+#define EHCI_BAR 0xFEF00000
+#define EHCI_DEBUG_OFFSET 0xE0
+
+static void sb700_enable_usbdebug_direct(u32 port)
+{
+       set_debug_port(port);
+       pci_write_config32(PCI_DEV(0, SB700_DEVN_BASE + 0x13, 5),
+                          EHCI_BAR_INDEX, EHCI_BAR);
+       pci_write_config8(PCI_DEV(0, SB700_DEVN_BASE + 0x13, 5), 0x04, 0x2);    /* mem space enabe */
+}
diff --git a/src/southbridge/amd/sb700/sb700_enable_usbdebug_direct.c b/src/southbridge/amd/sb700/sb700_enable_usbdebug_direct.c
deleted file mode 100644 (file)
index b739fe2..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2010 Advanced Micro Devices, Inc.
- *
- * 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; version 2 of the License.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef SB700_DEVN_BASE
-
-#define SB700_DEVN_BASE 0
-
-#endif
-
-#define EHCI_BAR_INDEX 0x10
-#define EHCI_BAR 0xFEF00000
-#define EHCI_DEBUG_OFFSET 0xE0
-
-static void sb700_enable_usbdebug_direct(u32 port)
-{
-       set_debug_port(port);
-       pci_write_config32(PCI_DEV(0, SB700_DEVN_BASE + 0x13, 5),
-                          EHCI_BAR_INDEX, EHCI_BAR);
-       pci_write_config8(PCI_DEV(0, SB700_DEVN_BASE + 0x13, 5), 0x04, 0x2);    /* mem space enabe */
-}
index d2dcf852f2ddb9c6dd07d2104143d7c5dc803287..3b0879820920dc60de85abc5756812d33b3a5d9d 100644 (file)
@@ -22,7 +22,7 @@
 #include <device/pci.h>
 #include <device/pci_ids.h>
 #include <device/pci_ops.h>
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #include <arch/io.h>
 #include "sb700.h"
 
index 1bc5fcaecbd77469bd51a8f8d41cdf002f8ff27b..530518c8e2bc8071454ea00c676c0cd2f1aef8a6 100644 (file)
@@ -24,7 +24,7 @@
 #include <device/pci_ids.h>
 #include "i82801gx.h"
 #if CONFIG_USBDEBUG_DIRECT
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #endif
 #include <arch/io.h>
 
diff --git a/src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c b/src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug.c
new file mode 100644 (file)
index 0000000..1c7a26b
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2004 Tyan Computer
+ * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
+ * Copyright (C) 2006,2007 AMD
+ * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#if CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20
+       #define MCP55_DEVN_BASE CONFIG_HT_CHAIN_END_UNITID_BASE
+#else
+       #define MCP55_DEVN_BASE CONFIG_HT_CHAIN_UNITID_BASE
+#endif
+
+#define EHCI_BAR_INDEX 0x10
+#define EHCI_BAR       0xFEF00000
+#define EHCI_DEBUG_OFFSET      0x98
+
+static void set_debug_port(unsigned port)
+{
+       uint32_t dword;
+       dword = pci_read_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x74);
+       dword &= ~(0xf<<12);
+       dword |= (port<<12);
+       pci_write_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x74, dword);
+
+}
+
+static void mcp55_enable_usbdebug_direct(unsigned port)
+{
+       set_debug_port(port);
+       pci_write_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), EHCI_BAR_INDEX, EHCI_BAR);
+       pci_write_config8(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x04, 0x2); // mem space enabe
+}
+
diff --git a/src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c b/src/southbridge/nvidia/mcp55/mcp55_enable_usbdebug_direct.c
deleted file mode 100644 (file)
index 1c7a26b..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2004 Tyan Computer
- * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
- * Copyright (C) 2006,2007 AMD
- * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#if CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20
-       #define MCP55_DEVN_BASE CONFIG_HT_CHAIN_END_UNITID_BASE
-#else
-       #define MCP55_DEVN_BASE CONFIG_HT_CHAIN_UNITID_BASE
-#endif
-
-#define EHCI_BAR_INDEX 0x10
-#define EHCI_BAR       0xFEF00000
-#define EHCI_DEBUG_OFFSET      0x98
-
-static void set_debug_port(unsigned port)
-{
-       uint32_t dword;
-       dword = pci_read_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x74);
-       dword &= ~(0xf<<12);
-       dword |= (port<<12);
-       pci_write_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x74, dword);
-
-}
-
-static void mcp55_enable_usbdebug_direct(unsigned port)
-{
-       set_debug_port(port);
-       pci_write_config32(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), EHCI_BAR_INDEX, EHCI_BAR);
-       pci_write_config8(PCI_DEV(0, MCP55_DEVN_BASE+2, 1), 0x04, 0x2); // mem space enabe
-}
-
index 86c124c6904ececb9ffa0f5baa2a340a3a37b0fc..cf603848adeae6f56f7b33fc94ef1470e63ddc9f 100644 (file)
@@ -28,7 +28,7 @@
 #include <device/pci_ops.h>
 #include "mcp55.h"
 #if CONFIG_USBDEBUG_DIRECT
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #endif
 
 extern struct ehci_debug_info dbg_info;
diff --git a/src/southbridge/sis/sis966/sis966_enable_usbdebug.c b/src/southbridge/sis/sis966/sis966_enable_usbdebug.c
new file mode 100644 (file)
index 0000000..f17a79e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2004 Tyan Computer
+ * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
+ * Copyright (C) 2006,2007 AMD
+ * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#if CONFIG_HT_CHAIN_END_UNITID_BASE < CONFIG_HT_CHAIN_UNITID_BASE
+       #define SIS966_DEVN_BASE        CONFIG_HT_CHAIN_END_UNITID_BASE
+#else
+       #define SIS966_DEVN_BASE        CONFIG_HT_CHAIN_UNITID_BASE
+#endif
+
+#define EHCI_BAR_INDEX 0x10
+#define EHCI_BAR       0xFEF00000
+#define EHCI_DEBUG_OFFSET      0x98
+
+static void set_debug_port(unsigned port)
+{
+       uint32_t dword;
+       dword = pci_read_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x74);
+       dword &= ~(0xf<<12);
+       dword |= (port<<12);
+       pci_write_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x74, dword);
+
+}
+
+static void sis966_enable_usbdebug_direct(unsigned port)
+{
+       set_debug_port(port);
+       pci_write_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), EHCI_BAR_INDEX, EHCI_BAR);
+       pci_write_config8(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x04, 0x2); // mem space enabe
+}
+
diff --git a/src/southbridge/sis/sis966/sis966_enable_usbdebug_direct.c b/src/southbridge/sis/sis966/sis966_enable_usbdebug_direct.c
deleted file mode 100644 (file)
index f17a79e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2004 Tyan Computer
- * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
- * Copyright (C) 2006,2007 AMD
- * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#if CONFIG_HT_CHAIN_END_UNITID_BASE < CONFIG_HT_CHAIN_UNITID_BASE
-       #define SIS966_DEVN_BASE        CONFIG_HT_CHAIN_END_UNITID_BASE
-#else
-       #define SIS966_DEVN_BASE        CONFIG_HT_CHAIN_UNITID_BASE
-#endif
-
-#define EHCI_BAR_INDEX 0x10
-#define EHCI_BAR       0xFEF00000
-#define EHCI_DEBUG_OFFSET      0x98
-
-static void set_debug_port(unsigned port)
-{
-       uint32_t dword;
-       dword = pci_read_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x74);
-       dword &= ~(0xf<<12);
-       dword |= (port<<12);
-       pci_write_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x74, dword);
-
-}
-
-static void sis966_enable_usbdebug_direct(unsigned port)
-{
-       set_debug_port(port);
-       pci_write_config32(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), EHCI_BAR_INDEX, EHCI_BAR);
-       pci_write_config8(PCI_DEV(0, SIS966_DEVN_BASE+2, 1), 0x04, 0x2); // mem space enabe
-}
-
index 108cfee894284fc2347587606b50b71df43bea94..9d0fa15a57eb70de8e19033c5bd197681a71425e 100644 (file)
@@ -31,7 +31,7 @@
 #include <arch/io.h>
 #include "sis966.h"
 #if CONFIG_USBDEBUG_DIRECT
-#include <usbdebug_direct.h>
+#include <usbdebug.h>
 #endif
 
 extern struct ehci_debug_info dbg_info;