summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Klotzbuecher <mk@denx.de>2006-05-23 10:33:11 +0200
committerMarkus Klotzbuecher <mk@pollux.denx.de>2006-05-23 10:33:11 +0200
commit24e37645e7378b20fa8f20e2996c8fb8e90c70c9 (patch)
tree466a18dd76abda5b0bd08e90922e3261b780474a
parent3e326ece9eba8184f5d48aa4fb87760a8f6f0f10 (diff)
downloadu-boot-imx-24e37645e7378b20fa8f20e2996c8fb8e90c70c9.zip
u-boot-imx-24e37645e7378b20fa8f20e2996c8fb8e90c70c9.tar.gz
u-boot-imx-24e37645e7378b20fa8f20e2996c8fb8e90c70c9.tar.bz2
More cleanup for the delta board and the generic usb_ohci driver. Added
CFG_USB_BOARD_INIT and CFG_USB_CPU_INIT for enabling board and cpu specific initialization and cleanup hooks respectively.
-rw-r--r--board/delta/delta.c55
-rw-r--r--cpu/pxa/Makefile2
-rw-r--r--cpu/pxa/usb.c71
-rw-r--r--drivers/usb_ohci.c59
-rw-r--r--drivers/usb_ohci.h8
-rw-r--r--include/configs/delta.h8
6 files changed, 130 insertions, 73 deletions
diff --git a/board/delta/delta.c b/board/delta/delta.c
index d9fe8cb..6e22774 100644
--- a/board/delta/delta.c
+++ b/board/delta/delta.c
@@ -1,10 +1,6 @@
/*
- * (C) Copyright 2002
- * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
+ * (C) Copyright 2006
+ * DENX Software Engineering
*
* See file CREDITS for list of people who contributed to this
* project.
@@ -98,53 +94,6 @@ int board_late_init(void)
return 0;
}
-
-/* board dependant usb stuff */
-int usb_board_init()
-{
- /*
- * Enable USB host clock.
- */
- CKENA |= (CKENA_2_USBHOST | CKENA_20_UDC);
- udelay(100);
-
- /* Configure Port 2 for Host (USB Client Registers) */
- UP2OCR = 0x3000c;
-
-#if 0
- GPIO2_2 = 0x801; /* USBHPEN - Alt. Fkt. 1 */
- GPIO3_2 = 0x801; /* USBHPWR - Alt. Fkt. 1 */
-#endif
-
- UHCHR |= UHCHR_FHR;
- wait_ms(11); /* udelay(11); */
- UHCHR &= ~UHCHR_FHR;
-
- UHCHR |= UHCHR_FSBIR;
- while (UHCHR & UHCHR_FSBIR)
- udelay(1);
-
-#if 0
- UHCHR |= UHCHR_PCPL; /* USBHPEN is active low */
- UHCHR |= UHCHR_PSPL; /* USBHPWR is active low */
-#endif
-
- UHCHR &= ~UHCHR_SSEP0;
- UHCHR &= ~UHCHR_SSEP1;
- UHCHR &= ~UHCHR_SSE;
-
- return 0;
-}
-
-int usb_board_stop()
-{
- /* may not want to do this */
- /* CKENA &= ~(CKENA_2_USBHOST | CKENA_20_UDC); */
-
- return 0;
-}
-
-
/*
* Magic Key Handling, mainly copied from board/lwmon/lwmon.c
*/
diff --git a/cpu/pxa/Makefile b/cpu/pxa/Makefile
index 1af53d6..bd476f1 100644
--- a/cpu/pxa/Makefile
+++ b/cpu/pxa/Makefile
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
LIB = lib$(CPU).a
START = start.o
-OBJS = serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o
+OBJS = serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o usb.o
all: .depend $(START) $(LIB)
diff --git a/cpu/pxa/usb.c b/cpu/pxa/usb.c
new file mode 100644
index 0000000..e89391c
--- /dev/null
+++ b/cpu/pxa/usb.c
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright 2006
+ * Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/pxa-regs.h>
+
+#ifdef CFG_USB_CPU_INIT
+# ifdef CONFIG_CPU_MONAHANS
+int usb_cpu_init()
+{
+ /* Enable USB host clock. */
+ CKENA |= (CKENA_2_USBHOST | CKENA_20_UDC);
+ udelay(100);
+
+ /* Configure Port 2 for Host (USB Client Registers) */
+ UP2OCR = 0x3000c;
+
+#if 0
+ GPIO2_2 = 0x801; /* USBHPEN - Alt. Fkt. 1 */
+ GPIO3_2 = 0x801; /* USBHPWR - Alt. Fkt. 1 */
+#endif
+
+ UHCHR |= UHCHR_FHR;
+ wait_ms(11);
+ UHCHR &= ~UHCHR_FHR;
+
+ UHCHR |= UHCHR_FSBIR;
+ while (UHCHR & UHCHR_FSBIR)
+ udelay(1);
+
+#if 0
+ UHCHR |= UHCHR_PCPL; /* USBHPEN is active low */
+ UHCHR |= UHCHR_PSPL; /* USBHPWR is active low */
+#endif
+
+ UHCHR &= ~UHCHR_SSEP0;
+ UHCHR &= ~UHCHR_SSEP1;
+ UHCHR &= ~UHCHR_SSE;
+
+ return 0;
+}
+
+int usb_cpu_stop()
+{
+ /* may not want to do this */
+ /* CKENA &= ~(CKENA_2_USBHOST | CKENA_20_UDC); */
+
+ return 0;
+}
+# endif /* CONFIG_CPU_MONAHANS */
+#endif /* CFG_USB_CPU_INIT */
diff --git a/drivers/usb_ohci.c b/drivers/usb_ohci.c
index 4065489..f5af719 100644
--- a/drivers/usb_ohci.c
+++ b/drivers/usb_ohci.c
@@ -51,7 +51,10 @@
#include <usb.h>
#include "usb_ohci.h"
-/* #define OHCI_USE_NPS /\* force NoPowerSwitching mode *\/ */
+#ifdef CONFIG_ARM920T
+# define OHCI_USE_NPS /* force NoPowerSwitching mode */
+#endif
+
#undef OHCI_VERBOSE_DEBUG /* not always helpful */
/* For initializing controller (mask in an HCFS mode too) */
@@ -311,9 +314,6 @@ static void ohci_dump_roothub (ohci_t *controller, int verbose)
#ifdef CONFIG_AT91C_PQFP_UHPBUG
ndp = (ndp == 2) ? 1:0;
#endif
-#if 0 /* def CONFIG_CPU_MONAHANS */
- data_buf [2] = (data_buf [2] == 2) ? 3:0;
-#endif
if (verbose) {
dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
((temp & RH_A_POTPGT) >> 24) & 0xff,
@@ -1150,19 +1150,13 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
#ifdef CONFIG_AT91C_PQFP_UHPBUG
data_buf [2] = (data_buf [2] == 2) ? 1:0;
#endif
-#if 0 /* def CONFIG_CPU_MONAHANS */
- data_buf [2] = (data_buf [2] == 2) ? 3:0;
-#endif
-
data_buf [3] = 0;
if (temp & RH_A_PSM) /* per-port power switching? */
data_buf [3] |= 0x1;
if (temp & RH_A_NOCP) /* no overcurrent reporting? */
data_buf [3] |= 0x10;
-#if 1
else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */
data_buf [3] |= 0x8;
-#endif
/* corresponds to data_buf[4-7] */
datab [1] = 0;
@@ -1557,10 +1551,18 @@ static char ohci_inited = 0;
int usb_lowlevel_init(void)
{
- /* do board dependant init */
- if(usb_board_init())
+
+#if CFG_USB_CPU_INIT
+ /* cpu dependant init */
+ if(usb_cpu_init())
return -1;
+#endif
+#if CFG_USB_BOARD_INIT
+ /* board dependant init */
+ if(usb_board_init())
+ return -1;
+#endif
memset (&gohci, 0, sizeof (ohci_t));
memset (&urb_priv, 0, sizeof (urb_priv_t));
@@ -1588,28 +1590,43 @@ int usb_lowlevel_init(void)
gohci.disabled = 1;
gohci.sleeping = 0;
gohci.irq = -1;
- gohci.regs = (struct ohci_regs *)OHCI_REGS_BASE;
+ gohci.regs = (struct ohci_regs *)CFG_USB_OHCI_REGS_BASE;
gohci.flags = 0;
- gohci.slot_name = "delta/zylonite";
+ gohci.slot_name = CFG_USB_SLOT_NAME;
if (hc_reset (&gohci) < 0) {
hc_release_ohci (&gohci);
err ("can't reset usb-%s", gohci.slot_name);
/* Initialization failed disable clocks */
- CKENA &= ~(CKENA_2_USBHOST | CKENA_20_UDC);
+#if CFG_USB_BOARD_INIT
+ /* board dependant cleanup */
+ usb_board_stop();
+#endif
+
+#if CFG_USB_CPU_INIT
+ /* cpu dependant cleanup */
+ usb_cpu_stop();
+#endif
return -1;
}
/* FIXME this is a second HC reset; why?? */
/* writel(gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
wait_ms(10); */
-
if (hc_start (&gohci) < 0) {
err ("can't start usb-%s", gohci.slot_name);
hc_release_ohci (&gohci);
/* Initialization failed */
- CKENA &= ~(CKENA_2_USBHOST | CKENA_20_UDC);
+#if CFG_USB_BOARD_INIT
+ /* board dependant cleanup */
+ usb_board_stop();
+#endif
+
+#if CFG_USB_CPU_INIT
+ /* cpu dependant cleanup */
+ usb_cpu_stop();
+#endif
return -1;
}
@@ -1632,9 +1649,17 @@ int usb_lowlevel_stop(void)
/* call hc_release_ohci() here ? */
hc_reset (&gohci);
+#if CFG_USB_BOARD_INIT
/* board dependant cleanup */
if(usb_board_stop())
return -1;
+#endif
+
+#if CFG_USB_CPU_INIT
+ /* cpu dependant cleanup */
+ if(usb_cpu_stop())
+ return -1;
+#endif
return 0;
}
diff --git a/drivers/usb_ohci.h b/drivers/usb_ohci.h
index 7a1d9d9..c37b5f6 100644
--- a/drivers/usb_ohci.h
+++ b/drivers/usb_ohci.h
@@ -8,8 +8,16 @@
*/
/* functions for doing board specific setup/cleanup */
+#ifdef CFG_USB_BOARD_INIT
extern int usb_board_init(void);
extern int usb_board_stop(void);
+#endif
+
+#ifdef CFG_USB_CPU_INIT
+extern int usb_cpu_init(void);
+extern int usb_cpu_stop(void);
+#endif
+
static int cc_to_error[16] = {
diff --git a/include/configs/delta.h b/include/configs/delta.h
index 0423bcb..e6b05e0 100644
--- a/include/configs/delta.h
+++ b/include/configs/delta.h
@@ -102,13 +102,17 @@
| CFG_CMD_IMLS))
#endif
-
+/* USB */
#define CONFIG_USB_OHCI 1
#define CONFIG_USB_STORAGE 1
#define CONFIG_DOS_PARTITION 1
-#define LITTLEENDIAN 1 /* used by usb_ohci.c */
+#undef CFG_USB_BOARD_INIT
+#define CFG_USB_CPU_INIT 1
+#define CFG_USB_OHCI_REGS_BASE OHCI_REGS_BASE
+#define CFG_USB_SLOT_NAME "delta"
+#define LITTLEENDIAN 1 /* used by usb_ohci.c */
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>