summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb_ohci.c133
-rw-r--r--drivers/usb_ohci.h2
2 files changed, 110 insertions, 25 deletions
diff --git a/drivers/usb_ohci.c b/drivers/usb_ohci.c
index c32245a..9b3ca12 100644
--- a/drivers/usb_ohci.c
+++ b/drivers/usb_ohci.c
@@ -21,7 +21,7 @@
*
* 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
+ * 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
@@ -45,13 +45,25 @@
#ifdef CONFIG_USB_OHCI
-#include <asm/arch/hardware.h>
+#if defined(CONFIG_S3C2400)
+# include <s3c2400.h>
+#elif defined(CONFIG_S3C2410)
+# include <s3c2410.h>
+#elif defined(CONFIG_ARM920T)
+# include <asm/arch/hardware.h>
+#elif defined(CONFIG_CPU_MONAHANS)
+# include <asm/arch/pxa-regs.h>
+#endif
#include <malloc.h>
#include <usb.h>
#include "usb_ohci.h"
-#ifdef CONFIG_ARM920T
+#undef S3C24X0_merge
+
+#if defined(CONFIG_ARM920T) || \
+ defined(CONFIG_S3C2400) || \
+ defined(CONFIG_S3C2410)
# define OHCI_USE_NPS /* force NoPowerSwitching mode */
#endif
@@ -98,6 +110,12 @@ int got_rhsc;
/* device which was disconnected */
struct usb_device *devgone;
+#ifdef S3C24X0_merge
+/* flag guarding URB transation */
+int urb_finished = 0;
+#endif
+
+
/*-------------------------------------------------------------------------*/
/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
@@ -402,6 +420,17 @@ int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
err("sohci_submit_job: EPIPE");
return -1;
}
+#ifdef S3C24X0_merge
+ /* if we have an unfinished URB from previous transaction let's
+ * fail and scream as quickly as possible so as not to corrupt
+ * further communication */
+ if (!urb_finished) {
+ err("sohci_submit_job: URB NOT FINISHED");
+ return -1;
+ }
+ /* we're about to begin a new transaction here so mark the URB unfinished */
+ urb_finished = 0;
+#endif
/* every endpoint has a ed, locate and fill it */
if (!(ed = ep_add_ed (dev, pipe))) {
@@ -574,12 +603,14 @@ static int ep_unlink (ohci_t *ohci, ed_t *ed)
/*-------------------------------------------------------------------------*/
-/* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
- * but the USB stack is a little bit stateless so we do it at every transaction
- * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
- * in all other cases the state is left unchanged
- * the ed info fields are setted anyway even though most of them should not change */
-
+/* add/reinit an endpoint; this should be done once at the
+ * usb_set_configuration command, but the USB stack is a little bit
+ * stateless so we do it at every transaction if the state of the ed
+ * is ED_NEW then a dummy td is added and the state is changed to
+ * ED_UNLINK in all other cases the state is left unchanged the ed
+ * info fields are setted anyway even though most of them should not
+ * change
+ */
static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
{
td_t *td;
@@ -663,7 +694,9 @@ static void td_fill (ohci_t *ohci, unsigned int info,
else
td->hwBE = 0;
td->hwNextTD = m32_swap (td_pt);
+#ifndef S3C24X0_merge
td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
+#endif
/* append to queue */
td->ed->hwTailP = td->hwNextTD;
@@ -830,7 +863,18 @@ static int dl_done_list (ohci_t *ohci, td_t *td_list)
dbg("ConditionCode %#x", cc);
stat = cc_to_error[cc];
}
-
+#ifdef S3C24X0_merge
+ /* see if this done list makes for all TD's of current URB,
+ * and mark the URB finished if so */
+ if (++(lurb_priv->td_cnt) == lurb_priv->length) {
+ if ((ed->state & (ED_OPER | ED_UNLINK)))
+ urb_finished = 1;
+ else
+ dbg("dl_done_list: strange.., ED state %x, ed->state\n");
+ } else
+ dbg("dl_done_list: processing TD %x, len %x\n", lurb_priv->td_cnt,
+ lurb_priv->length);
+#endif
if (ed->state != ED_NEW) {
edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
edTailP = m32_swap (ed->hwTailP);
@@ -1172,7 +1216,7 @@ pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
}
len = min_t(unsigned int, leni,
- min_t(unsigned int, data_buf [0], wLength));
+ min_t(unsigned int, data_buf [0], wLength));
OK (len);
}
@@ -1260,18 +1304,38 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
stat = USB_ST_CRC_ERR;
break;
}
+
+#ifdef S3C24X0_merge
+ /* NOTE: since we are not interrupt driven in U-Boot and always
+ * handle only one URB at a time, we cannot assume the
+ * transaction finished on the first successful return from
+ * hc_interrupt().. unless the flag for current URB is set,
+ * meaning that all TD's to/from device got actually
+ * transferred and processed. If the current URB is not
+ * finished we need to re-iterate this loop so as
+ * hc_interrupt() gets called again as there needs to be some
+ * more TD's to process still */
+ if ((stat >= 0) && (stat != 0xff) && (urb_finished)) {
+#else
if (stat >= 0 && stat != 0xff) {
+#endif
/* 0xff is returned for an SF-interrupt */
break;
}
+
if (--timeout) {
wait_ms(1);
} else {
err("CTL:TIMEOUT ");
+#ifdef S3C24X0_merge
+ dbg("submit_common_msg: TO status %x\n", stat);
+ urb_finished = 1;
+#endif
stat = USB_ST_CRC_ERR;
break;
}
}
+#ifndef S3C24X0_merge
/* we got an Root Hub Status Change interrupt */
if (got_rhsc) {
#ifdef DEBUG
@@ -1293,6 +1357,7 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
devgone = dev;
}
}
+#endif /* S3C24X0_merge */
dev->status = stat;
dev->act_len = transfer_len;
@@ -1462,24 +1527,40 @@ static int hc_start (ohci_t * ohci)
/* an interrupt happens */
-static int
-hc_interrupt (void)
+static int hc_interrupt (void)
{
ohci_t *ohci = &gohci;
struct ohci_regs *regs = ohci->regs;
int ints;
int stat = -1;
+#ifdef S3C24X0_merge
+
+ if ((ohci->hcca->done_head != 0) &&
+ !(m32_swap (ohci->hcca->done_head) & 0x01)) {
+ ints = OHCI_INTR_WDH;
+ } else if ((ints = readl (&regs->intrstatus)) == ~(u32)0) {
+ ohci->disabled++;
+ err ("%s device removed!", ohci->slot_name);
+ return -1;
+ } else if ((ints &= readl (&regs->intrenable)) == 0) {
+ dbg("hc_interrupt: returning..\n");
+ return 0xff;
+ }
+#else
if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
ints = OHCI_INTR_WDH;
} else {
ints = readl (&regs->intrstatus);
}
-
+#endif
/* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
if (ints & OHCI_INTR_RHSC) {
got_rhsc = 1;
+#ifdef S3C24X0_merge
+ stat = 0xff;
+#endif
}
if (ints & OHCI_INTR_UE) {
@@ -1552,13 +1633,13 @@ static char ohci_inited = 0;
int usb_lowlevel_init(void)
{
-#if CFG_USB_OHCI_CPU_INIT
+#ifdef CFG_USB_OHCI_CPU_INIT
/* cpu dependant init */
if(usb_cpu_init())
return -1;
#endif
-#if CFG_USB_OHCI_BOARD_INIT
+#ifdef CFG_USB_OHCI_BOARD_INIT
/* board dependant init */
if(usb_board_init())
return -1;
@@ -1598,15 +1679,14 @@ int usb_lowlevel_init(void)
if (hc_reset (&gohci) < 0) {
hc_release_ohci (&gohci);
err ("can't reset usb-%s", gohci.slot_name);
- /* Initialization failed disable clocks */
-#if CFG_USB_OHCI_BOARD_INIT
+#ifdef CFG_USB_OHCI_BOARD_INIT
/* board dependant cleanup */
- usb_board_stop();
+ usb_board_init_fail();
#endif
-#if CFG_USB_OHCI_CPU_INIT
+#ifdef CFG_USB_OHCI_CPU_INIT
/* cpu dependant cleanup */
- usb_cpu_stop();
+ usb_cpu_init_fail();
#endif
return -1;
}
@@ -1618,12 +1698,12 @@ int usb_lowlevel_init(void)
err ("can't start usb-%s", gohci.slot_name);
hc_release_ohci (&gohci);
/* Initialization failed */
-#if CFG_USB_OHCI_BOARD_INIT
+#ifdef CFG_USB_OHCI_BOARD_INIT
/* board dependant cleanup */
usb_board_stop();
#endif
-#if CFG_USB_OHCI_CPU_INIT
+#ifdef CFG_USB_OHCI_CPU_INIT
/* cpu dependant cleanup */
usb_cpu_stop();
#endif
@@ -1634,6 +1714,9 @@ int usb_lowlevel_init(void)
ohci_dump (&gohci, 1);
#else
wait_ms(1);
+# ifdef S3C24X0_merge
+ urb_finished = 1;
+# endif
#endif
ohci_inited = 1;
return 0;
@@ -1649,13 +1732,13 @@ int usb_lowlevel_stop(void)
/* call hc_release_ohci() here ? */
hc_reset (&gohci);
-#if CFG_USB_OHCI_BOARD_INIT
+#ifdef CFG_USB_OHCI_BOARD_INIT
/* board dependant cleanup */
if(usb_board_stop())
return -1;
#endif
-#if CFG_USB_OHCI_CPU_INIT
+#ifdef CFG_USB_OHCI_CPU_INIT
/* cpu dependant cleanup */
if(usb_cpu_stop())
return -1;
diff --git a/drivers/usb_ohci.h b/drivers/usb_ohci.h
index c37b5f6..a1b36ed 100644
--- a/drivers/usb_ohci.h
+++ b/drivers/usb_ohci.h
@@ -11,11 +11,13 @@
#ifdef CFG_USB_BOARD_INIT
extern int usb_board_init(void);
extern int usb_board_stop(void);
+extern int usb_cpu_init_fail(void);
#endif
#ifdef CFG_USB_CPU_INIT
extern int usb_cpu_init(void);
extern int usb_cpu_stop(void);
+extern int usb_cpu_init_fail(void);
#endif