[U-Boot] [PATCH v6] ulpi: add generic ULPI functionality

2011-11-28 Thread Jana Rapava
Add generic functions for reading, writing and setting bits in ULPI registers.

Signed-off-by: Jana Rapava 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
Cc: Simon Glass 

Acked-by: Igor Grinberg 
Acked-by: Simon Glass 
---
Changes for v2:
  - make code EHCI-independent
  - use udelay() in waiting loop
  - mark static functions as static
  - naming changes
Changes for v3:
   - merge with patch ulpi: add generic ULPI support header file
   - rewrite ULPI interface in more functionality-oriented way
Changes for v4:
   - add error-checking
   - add waiting for completion into ulpi_reset() function
Changes for v5:
- CodingStyle changes
- add comments
- simplify implemenation of the ULPI interface functions
Changes for v6:
- cleanup function ulpi_drive_vbus()

 Makefile |1 +
 drivers/usb/ulpi/Makefile|   45 +++
 drivers/usb/ulpi/ulpi-viewport.c |  114 ++
 drivers/usb/ulpi/ulpi.c  |  161 +
 include/usb/ulpi.h   |  238 ++
 5 files changed, 559 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c
 create mode 100644 include/usb/ulpi.h

diff --git a/Makefile b/Makefile
index dfe939f..70a1e1e 100644
--- a/Makefile
+++ b/Makefile
@@ -272,6 +272,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..a1a2244
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI)   += ulpi.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT)  += ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..7764939
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+/* This function issues ULPI wakeup/read-write request
+ * and waits until ULPI interface signalizes completion.
+ * 'ulpi_value' is properly constructed ULPI request,
+ * 'ulpi_mask' is ULPI_WU for wakeup, ULPI_RWRUN for read or write.
+ */
+static int ulpi_request(u32 ulpi_viewp

[U-Boot] [PATCH v5] ulpi: add generic ULPI functionality

2011-11-27 Thread Jana Rapava
Add generic functions for reading, writing and setting bits in ULPI registers.

Signed-off-by: Jana Rapava 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
Cc: Simon Glass 
---
Changes for v2:
  - make code EHCI-independent
  - use udelay() in waiting loop
  - mark static functions as static
  - naming changes
Changes for v3:
   - merge with patch ulpi: add generic ULPI support header file
   - rewrite ULPI interface in more functionality-oriented way
Changes for v4:
   - add error-checking
   - add waiting for completion into ulpi_reset() function
Changes for v5:
- CodingStyle changes
- add comments
- simplify implemenation of the ULPI interface functions

 Makefile |1 +
 drivers/usb/ulpi/Makefile|   45 +++
 drivers/usb/ulpi/ulpi-viewport.c |  114 ++
 drivers/usb/ulpi/ulpi.c  |  158 +
 include/usb/ulpi.h   |  238 ++
 5 files changed, 556 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c
 create mode 100644 include/usb/ulpi.h

diff --git a/Makefile b/Makefile
index dfe939f..70a1e1e 100644
--- a/Makefile
+++ b/Makefile
@@ -272,6 +272,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..a1a2244
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI)   += ulpi.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT)  += ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..7764939
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+/* This function issues ULPI wakeup/read-write request
+ * and waits until ULPI interface signalizes completion.
+ * 'ulpi_value' is properly constructed ULPI request,
+ * 'ulpi_mask' is ULPI_WU for wakeup, ULPI_RWRUN for read or write.
+ */
+static int ulpi_request(u32 ulpi_viewport, u32 ulpi_value, u32 ulpi_mask)
+{
+   int timeout = CONFIG_USB_ULPI_TIMEOUT;
+   u32 tmp;
+
+   writel(ulp

Re: [U-Boot] [PATCH v4] ulpi: add generic ULPI functionality

2011-11-27 Thread Jana Rapava
2011/11/27 Igor Grinberg 

> >
> >> +{
> >> +   int timeout = CONFIG_USB_ULPI_TIMEOUT;
> >> +   u32 tmp;
> >> +
> >> +   writel(ulpi_value, ulpi_viewport);
> >
> > Why do the write here? Should it be done in the write call below? At
> > the very least you should rename this function.
>
>
> If you move this writel() from here, then you need to add
> it to every function calling this one (it is not just the write below).
> It can be done, but again can we do this later?
>
>
If you would really want, I can do it later, but I think that rename this
function
and document it properly is better way.

>
> >
> >> +}
> >> +
> >> +static int ulpi_wakeup(u32 ulpi_viewport)
> >> +{
> >> +   if (readl(ulpi_viewport) & ULPI_SS)
> >> +   return 0; /* already awake */
> >> +
> >> +   return ulpi_wait(ulpi_viewport, ULPI_WU, ULPI_WU);
> >> +}
> >> +
> >> +u32 ulpi_write(u32 ulpi_viewport, u32 reg, u32 value)
> >
> > It seems that every caller requires a cast for the second parameter.
> > Perhaps you could avoid this if you make the reg parameter u8 *
> > instead?
>
> This is what I would call a "no go"...
> Jana, can you, please deal with this?
> And if you do, then you can deal with *most* of other comments as well.
>
>
Ok, I'll do so.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] ulpi: add generic ULPI functionality

2011-11-27 Thread Jana Rapava
2011/11/27 Simon Glass 

> > +static int ulpi_wait(u32 ulpi_viewport, u32 ulpi_value, u32 ulpi_mask)
>
>
> How about a comment as to what this function does, params and return
> values?
>
> Also perhaps if you pass the operation to this function it can print
> the error message (perhaps with debug()) rather than ever calling
> having to do it? Or at least decide whether messages should be in
> bottom-level functions or in top-level - and perhaps considering using
> debug() instead of printf() at lower levels.
>
> > +{
> > +   int timeout = CONFIG_USB_ULPI_TIMEOUT;
> > +   u32 tmp;
> > +
> > +   writel(ulpi_value, ulpi_viewport);
>
> Why do the write here? Should it be done in the write call below? At
> the very least you should rename this function.
>
>
This function issues ULPI wakeup or read-write request, writes the request
into ULPI viewport register and waits until ULPI interface signalizes
completion
of this request.
With error messages is the situation a bit difficult, because this function
only knows
whether the request was for wakeup or for read-write.
 I think more specific error messages  are more helpful, so I decided to
put them into
functions which knows what we've attempted to
do(ulpi_wakeup()/ulpi_read()/ulpi-write()).
 If you really think that debug() is more appropriate in these functions, I
can change this,
but Igor doesn't consider this a reason for this patch not to be accepted,
and I agree with him.

And I'll rename this function into ulpi_request(), ulpi_wait() is really a
bit deceiveing.
Thanks for your comments.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4] ulpi: add generic ULPI functionality

2011-11-25 Thread Jana Rapava
Add generic functions for ULPI init and setting bits in
ULPI registers.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
---
Changes for v2:
   - make code EHCI-independent
   - use udelay() in waiting loop
   - mark static functions as static
   - naming changes
Changes for v3:
- merge with patch ulpi: add generic ULPI support header file
- rewrite ULPI interface in more functionality-oriented way
Changes for v4:
- add error-checking
- add waiting for completion into ulpi_reset() function

 Makefile |1 +
 drivers/usb/ulpi/Makefile|   45 +++
 drivers/usb/ulpi/ulpi-viewport.c |   91 ++
 drivers/usb/ulpi/ulpi.c  |  256 ++
 include/usb/ulpi.h   |  221 
 5 files changed, 614 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c
 create mode 100644 include/usb/ulpi.h

diff --git a/Makefile b/Makefile
index c9e2624..da7352c 100644
--- a/Makefile
+++ b/Makefile
@@ -283,6 +283,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..a1a2244
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI)   += ulpi.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT)  += ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..8f7d94c
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+static int ulpi_wait(u32 ulpi_viewport, u32 ulpi_value, u32 ulpi_mask)
+{
+   int timeout = CONFIG_USB_ULPI_TIMEOUT;
+   u32 tmp;
+
+   writel(ulpi_value, ulpi_viewport);
+
+   /* Wait for the bits in ulpi_mask to become zero. */
+   while (--timeout) {
+   tmp = readl(ulpi_viewport);
+   if (!(tmp & ulpi_mask))
+   break;
+   udelay(1);
+   }
+
+   return !timeout;
+}
+
+static int ulpi_wakeup(u32 ulpi_viewport)
+{
+   if (readl(ulpi_viewport) & ULPI_

Re: [U-Boot] [PATCH v3]ulpi: add generic ULPI functionality

2011-11-25 Thread Jana Rapava
2011/11/24 Igor Grinberg 

> > +/*
> > + * If enable is 0, pull-down resistor not connected to D+, else
> pull-down
> > + * resistor connected to D+.
> > + * Default behaviour is as for enable equal to 1.
> > + */
> > +void ulpi_dp_pulldown(u32 ulpi_viewport, int enable)
> > +{
> > + if (enable)
> > + ulpi_write(ulpi_viewport,
> > + (u32)&ulpi->otg_ctrl_set, ULPI_OTG_DP_PULLDOWN);
> > + else
> > + ulpi_write(ulpi_viewport,
> > + (u32)&ulpi->otg_ctrl_clear, ULPI_OTG_DP_PULLDOWN);
> > +}
> > +
> > +/*
> > + * If enable is 0, pull-down resistor not connected to D- else pull-down
> > + * resistor connected to D-.
> > + * Default behaviour is as for enable equal to 1.
> > + */
> > +void ulpi_dm_pulldown(u32 ulpi_viewport, int enable)
> > +{
> > + if (enable)
> > + ulpi_write(ulpi_viewport,
> > + (u32)&ulpi->otg_ctrl_set, ULPI_OTG_DM_PULLDOWN);
> > + else
> > + ulpi_write(ulpi_viewport,
> > + (u32)&ulpi->otg_ctrl_clear, ULPI_OTG_DM_PULLDOWN);
> > +}
>
>
> Correct me if I'm wrong, but I don't think there is a use for
> the above functions in separate and the user will have to
> call them both.
> So, can these two functions be united in one,
> say ulpi_pulldown(u32 ..., int enable)?
>
>
If I understand ULPI specification well, the overall effect is the same
when both bits are set to 1 as when they are set to 0.
And default setting is for both bits to be 1, so I don't think that have
one function for both bits make sense.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3]ulpi: add generic ULPI functionality

2011-11-24 Thread Jana Rapava
Add generic functions for ULPI init and setting bits in
ULPI registers.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
---
Changes for v2:
   - make code EHCI-independent
   - use udelay() in waiting loop
   - mark static functions as static
   - naming changes
Changes for v3:
- merge with patch ulpi: add generic ULPI support header file
- rewrite ULPI interface in more functionality-oriented way

 Makefile |1 +
 drivers/usb/ulpi/Makefile|   45 
 drivers/usb/ulpi/ulpi-viewport.c |   88 +++
 drivers/usb/ulpi/ulpi.c  |  199 ++
 include/usb/ulpi.h   |  222 ++
 5 files changed, 555 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c
 create mode 100644 include/usb/ulpi.h

diff --git a/Makefile b/Makefile
index dfe939f..70a1e1e 100644
--- a/Makefile
+++ b/Makefile
@@ -272,6 +272,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..a1a2244
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI)   += ulpi.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT)  += ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..9a1f59f
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+static int ulpi_wait(u32 ulpi_viewport, u32 ulpi_value, u32 ulpi_mask)
+{
+   int timeout = CONFIG_USB_ULPI_TIMEOUT;
+   u32 tmp;
+
+   writel(ulpi_value, ulpi_viewport);
+
+   /* Wait for the bits in ulpi_mask to become zero. */
+   while (--timeout) {
+   tmp = readl(ulpi_viewport);
+   if (!(tmp & ulpi_mask))
+   break;
+   udelay(1);
+   }
+
+   return !timeout;
+}
+
+static int ulpi_wakeup(u32 ulpi_viewport)
+{
+   if (readl(ulpi_viewport) & ULPI_SS)
+   return 0; /* already awake */
+
+   return ulpi_wait(ulpi_viewport, ULPI_WU, ULPI_WU)

Re: [U-Boot] [PATCH v8 4/4] Add USB support for Efika

2011-11-24 Thread Jana Rapava
2011/11/24 Marek Vasut 

> > On 11/12/2011 06:45 PM, Jana Rapava wrote:
> > > This commit adds USB support for EfikaMX and EfikaSB.
> > >
> > > Signed-off-by: Jana Rapava 
> > > Signed-off-by: Marek Vasut 
> > > Cc: Remy Bohmer 
> > > Cc: Stefano Babic 
> > > Cc: Igor Grinberg 
> > > Cc: Wolfgang Grandegger 
> > >
> > > Acked-by: Marek Vasut 
>
> Ok, I think I've had just about enough of this damn shit going on here. I
> see no
> updates, no progress, nothing. Basically, I dropped these patches from my
> tree
> and applied the old ones from my reflog. I think there was about enough
> time to
> get the patches into shape (3 months, maybe more).
>

Ok, I'm really stuck with this stuff (I haven't any idea how to split this
patch into general and board-specific code how was demanded), so your
suggestion is probably a better way how to do it.
I finally have something which I consider a usable version of ULPI support
patch, so I'll post it today and you can use it if you want.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Efika: Configure additional regulators for HDMI output

2011-11-20 Thread Jana Rapava
2011/11/20 Marek Vasut 

>
> >  HDMI output doesn't work with current u-boot-imx tree (no LCD output
> after
> > 'setenv stdout lcd'),
> > but works with current u-boot-marex/efikasb tree.
> >
>
> Ok, so are you debugging it or not ?
>

No, I thought that if it works with u-boot-marex/efikasb, it's only a
question of
getting some more patches into u-boot-imx.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Efika: Configure additional regulators for HDMI output

2011-11-20 Thread Jana Rapava
2011/11/19 Marek Vasut 

> > 2011/11/17 Marek Vasut 
> >
> > > Jana, you have efikamx and I can get you HDMI cable. Can you recheck
> > > tomorrow ?
> > >
> > > M
> >
> > Ok, I can.
>
> So any updates?
>

 HDMI output doesn't work with current u-boot-imx tree (no LCD output after
'setenv stdout lcd'),
but works with current u-boot-marex/efikasb tree.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Efika: Configure additional regulators for HDMI output

2011-11-17 Thread Jana Rapava
2011/11/17 Marek Vasut 

>
> Jana, you have efikamx and I can get you HDMI cable. Can you recheck
> tomorrow ?
>
> M
>

Ok, I can.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 3/4] EHCI: adjust for mx5

2011-11-14 Thread Jana Rapava
2011/11/14 Wolfgang Grandegger 

>
> >
> > +#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
> > +#define USBCTRL_OTGBASE_OFFSET   0x600
> > +#endif
> > +
> > +#ifdef CONFIG_MX25
> > +#define MX25_USB_CTRL_IP_PUE_DOWN_BIT(1<<6)
> > +#define MX25_USB_CTRL_HSTD_BIT   (1<<5)
> > +#define MX25_USB_CTRL_USBTE_BIT  (1<<4)
> > +#define MX25_USB_CTRL_OCPOL_OTG_BIT  (1<<3)
> > +#endif
> > +
> > +#ifdef CONFIG_MX31
> > +#define MX31_H2_SIC_SHIFT21
> > +#define MX31_H2_SIC_MASK (0x3 << MX31_H2_SIC_SHIFT)
> > +#define MX31_H2_PM_BIT   (1 << 16)
> > +#define MX31_H2_DT_BIT   (1 << 5)
> > +
> > +#define MX31_H1_SIC_SHIFT13
> > +#define MX31_H1_SIC_MASK (0x3 << MX31_H1_SIC_SHIFT)
> > +#define MX31_H1_PM_BIT   (1 << 8)
> > +#define MX31_H1_DT_BIT   (1 << 4)
> > +#endif
> > +
> > +#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
> > +/* offset for first USB CTRL register */
> > +#define MX5_CTRL_REGS_OFFSET 0x800
> > +#endif
> > +
> > +#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
> > +/* USB_CTRL register bits of interest*/
> > +#define MXC_OTG_SIC_SHIFT29
> > +#define MXC_OTG_SIC_MASK (0x3 << MX31_OTG_SIC_SHIFT)
> > +#define MXC_OTG_WUE  (1 << 27)
> > +#define MXC_OTG_PM   (1 << 24)
> > +#endif
> > +
> > +#ifdef CONFIG_MX51
> > +#define MX51_REGISTER_LAYOUT_LENGTH  0x200
> > +
> > +/* Register offsets for MX51 */
> > +#define MX51_OTG_ID  0x000
> > +#define MX51_UH1_ID  0x200
> > +#define MX51_UH2_ID  0x400
> > +
> > +/* USB_CTRL register bits of interest*/
> > +#define MX51_OTG_PM  (1 << 24)
> > +#define MX51_H1_ULPI_IE  (1 << 12)
> > +#define MX51_H1_WUE  (1 << 11)
> > +#define MX51_H1_PM   (1 << 8)
> > +
> > +/* PHY_CTRL_0 register bits of interest */
> > +#define MX51_OTG_OVERCURD(1 << 8)
> > +#define MX51_EHCI_POWERPINSE (1 << 5)
> > +
> > +/* PHY_CTRL_1 register bits of interest */
> > +#define MX51_SYSCLOCK_24_MHZ (1 << 0)
> > +#define MX51_SYSCLOCK_MASK   (~(0x << 2))
> > +
> > +/* USB_CTRL_1 register bits of interest */
> > +#define MX51_H1_EXTCLKE  (1 << 25)
> > +
> > +/* USB Host 2 CTRL register bits of interest */
> > +#define MX51_H2_ULPI_IE  (1 << 8)
> > +#define MX51_H2_WUE  (1 << 7)
> > +#define MX51_H2_PM   (1 << 4)
>
> Most of the definitions above are arch specific and would better be
> placed in arch/arm/include/asm/arch-mx25/31/5, I think.
>
> Stefano, what do you think? You said that these definitions could be in
ehci-fsl.h, is arch-specific place better?


> > +/* PORTSCx bits of interest */
> > +#define MX51_ULPI_MODE_MASK  (2 << 30)
> > +#define MX51_16BIT_UTMI  (1 << 28)
>
> In ehci-fsl.h we have already
>
>  #define PORT_PTS_ULPI   (2 << 30)
>  #define PORT_PTS_PTW(1 << 28)
>
> Ok, I'll use them.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3] ulpi: add generic ULPI support header file

2011-11-14 Thread Jana Rapava
2011/11/14 Igor Grinberg 


> > +void ulpi_write(u32 ulpi_viewport, u32 reg, u32 value);
> > +u32 ulpi_read(u32 ulpi_viewport, u32 reg);
> > +
> > +void ulpi_init(u32 ulpi_viewport, struct ulpi_regs *ulpi);
>
>
> Are there any ULPI transceivers with memory mapped access?
>
>
As far as I know, there aren't any.


> Because if there are no such devices, then passing that
> struct ulpi_regs *ulpi pointer is redundant and it will
> always be 0.
>
> I think it will clearer _not_ to pass this pointer, but have it
> defined locally inside the ulpi.c. Any objections?
>
>
This looks like a good idea, thanks.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8 4/4] Add USB support for Efika

2011-11-12 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 

Acked-by: Marek Vasut 
---
Changes for v2:
- introduce temporary variable in ulpi_write
- whitespace changes
Changes for v3:
 - add protection against multiple inclusion of efika.h
Changes for v4:
  - rename multiple inclusion protection macro in efika.h
Changes for v5:
   - fix unterminated #ifndef in efika.h
Changes for v6:
- add Acked-by
- no changes
Changes for v7:
- use ULPI-related definitions from ./include/usb/ulpi.h
Changes for v8:
- adjust to new and more generic ULPI implementation

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   35 +
 board/efikamx/efikamx-usb.c |  344 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   18 +++
 5 files changed, 403 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..fec9ee0
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef __BOARD_EFIKAMX_EFIKA_H__
+#define __BOARD_EFIKAMX_EFIKA_H__
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
+
+#endif /* __BOARD_EFIKAMX_EFIKA_H__ */
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..cbcdb18
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,344 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG

[U-Boot] [PATCH v4 3/4] EHCI: adjust for mx5

2011-11-12 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
---
Changes for v2:
- whitespace and coding style changes
Changes for v3:
- ULPI-related definitions moved to ULPI header file
Changes for v4:
- rename "ulpi_viewpoint", because it's called "ulpi_viewport"
in documentation

 drivers/usb/host/ehci-mxc.c |   31 +--
 include/usb/ehci-fsl.h  |   86 ++-
 2 files changed, 88 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..2b1ac22 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,80 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#

[U-Boot] [PATCH v2] ulpi: add generic ULPI functionality

2011-11-12 Thread Jana Rapava
Add generic functions for ULPI init and setting bits in
ULPI registers.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
---
This patch is a prerequisite for Efika USB patchset.

Changes for v2:
- make code EHCI-independent
- use udelay() in waiting loop
- mark static functions as static
- naming changes
I haven't rewritten the ULPI registers interface, because I haven't any
idea how to implement it in some better way.

 Makefile |1 +
 drivers/usb/ulpi/Makefile|   45 +++
 drivers/usb/ulpi/ulpi-viewport.c |   87 +
 drivers/usb/ulpi/ulpi.c  |  113 ++
 4 files changed, 246 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c

diff --git a/Makefile b/Makefile
index dfe939f..70a1e1e 100644
--- a/Makefile
+++ b/Makefile
@@ -272,6 +272,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..64561af
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI) += ulpi.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..9250b09
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+static int ulpi_wait(u32 ulpi_viewport, u32 ulpi_value, u32 ulpi_mask)
+{
+   int timeout = ULPI_TIMEOUT;
+   u32 tmp;
+
+   writel(ulpi_value, ulpi_viewport);
+
+   /* Wait for the bits in ulpi_mask to become zero. */
+   while (--timeout) {
+   tmp = readl(ulpi_viewport);
+   if (!(tmp & ulpi_mask))
+   break;
+   udelay(1);
+   }
+
+   return !timeout;
+}
+
+static int ulpi_wakeup(u32 ulpi_viewport)
+{
+   if (readl(ulpi_viewport) & ULPI_SS)
+   return 0; /* already awake */
+
+   return ulpi_wait(ulpi_viewport, ULPI_WU, ULPI_WU);
+}
+
+void ulpi_write(u32 ulpi_viewport, u32 reg, u32 value)
+

[U-Boot] [PATCH v3] ulpi: add generic ULPI support header file

2011-11-12 Thread Jana Rapava
Add ULPI header file needed by Efika USB support patchset and generic
ULPI support patch.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
Cc: Wolfgang Grandegger 
---
This patch is a prerequisite for Efika USB patchset.

Changes for v2:
   - whitespace and comment changes
Changes for v3:
- remove _write suffix in register names
- change first argument of ULPI-related functions from "ehci"
to "ulpi_viewport"

 include/usb/ulpi.h |  220 
 1 files changed, 220 insertions(+), 0 deletions(-)
 create mode 100644 include/usb/ulpi.h

diff --git a/include/usb/ulpi.h b/include/usb/ulpi.h
new file mode 100644
index 000..f131861
--- /dev/null
+++ b/include/usb/ulpi.h
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/include/linux/usb/ulpi.h
+ * ULPI defines and function prototypes
+ *
+ * Original Copyrights follow:
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * This software is distributed under the terms of the GNU General
+ * Public License ("GPL") as published by the Free Software Foundation,
+ * version 2 of that License.
+ */
+
+#ifndef __USB_ULPI_H
+#define __USB_ULPI_H
+
+#define ULPI_ID_REGS_COUNT 4
+#define ULPI_TEST_VALUE0x55
+/* value greater than 0xff indicates failure */
+#define ULPI_ERROR (1 << 8)
+#define ULPI_TIMEOUT   1000 /* some reasonable value */
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+/* ULPI access modes */
+#define ULPI_WRITE 0x00
+#define ULPI_SET   0x01
+#define ULPI_CLEAR 0x02
+
+struct ulpi_regs {
+   /* Vendor ID and Product ID: 0x00 - 0x03 Read-only */
+   u8  vendor_id_low;
+   u8  vendor_id_high;
+   u8  product_id_low;
+   u8  product_id_high;
+   /* Function Control: 0x04 - 0x06 Read */
+   u8  function_ctrl;  /* 0x04 Write */
+   u8  function_ctrl_set;  /* 0x05 Set */
+   u8  function_ctrl_clear;/* 0x06 Clear */
+   /* Interface Control: 0x07 - 0x09 Read */
+   u8  iface_ctrl; /* 0x07 Write */
+   u8  iface_ctrl_set; /* 0x08 Set */
+   u8  iface_ctrl_clear;   /* 0x09 Clear */
+   /* OTG Control: 0x0A - 0x0C Read */
+   u8  otg_ctrl;   /* 0x0A Write */
+   u8  otg_ctrl_set;   /* 0x0B Set */
+   u8  otg_ctrl_clear; /* 0x0C Clear */
+   /* USB Interrupt Enable Rising: 0x0D - 0x0F Read */
+   u8  usb_ie_rising;  /* 0x0D Write */
+   u8  usb_ie_rising_set;  /* 0x0E Set */
+   u8  usb_ie_rising_clear;/* 0x0F Clear */
+   /* USB Interrupt Enable Falling: 0x10 - 0x12 Read */
+   u8  usb_ie_falling; /* 0x10 Write */
+   u8  usb_ie_falling_set; /* 0x11 Set */
+   u8  usb_ie_falling_clear;   /* 0x12 Clear */
+   /* USB Interrupt Status: 0x13 Read-only */
+   u8  usb_int_status;
+   /* USB Interrupt Latch: 0x14 Read-only with auto-clear */
+   u8  usb_int_latch;
+   /* Debug: 0x15 Read-only */
+   u8  debug;
+   /* Scratch Register: 0x16 - 0x18 Read */
+   u8  scratch;/* 0x16 Write */
+   u8  scratch_set;/* 0x17 Set */
+   u8  scratch_clear;  /* 0x18 Clear */
+   /*
+* Optional Carkit registers
+*/
+   /* Carkit Control: 0x19 - 0x1B Read */
+   u8  carkit_ctrl;/* 0x19 Write */
+   u8  carkit_ctrl_set;/* 0x1A Set */
+   u8  carkit_ctrl_clear;  /* 0x1B Clear */
+   /* Carkit Interrupt Delay: 0x1C Read, Write */
+   u8  carkit_int_delay;
+   /* Carkit Interrupt Enable: 0x1D - 0x1F Read */
+   u8  carkit_ie;  /* 0x1D Write */
+   u8  carkit_ie_set;  /* 0x1E Set */
+   u8  carkit_ie_clear;/* 0x1F Clear */
+   /* Carkit Interrupt Status: 0x20 Read-only */
+   u8  carkit_int_status;
+   /* Carkit Interrupt Latch: 0x21 Read-only with auto-clear */
+   u8  carkit_int_latch;
+   /* Carkit Pulse Control: 0x22 - 0x24 Read */
+   u8  carkit_pulse_ctrl;  /* 0x22 Write */
+   u8  carkit_pulse_ctrl_set;  /* 0x23 Set */
+   u8  carkit_pulse_ctrl_clear;/* 0x24 Clear */
+   /*
+* Other optional registers
+*/
+   /* Transmit Positive Width: 0x25 Read, Write */
+   u8  transmit_pos_width;
+   /* Transmit Negative Width: 0x26 Read, Write */
+   u8  transmit_neg_width;
+   /* Receive Polarity Recovery: 0x27 Read, Write */
+   u8  recv_pol_recovery;
+  

Re: [U-Boot] [PATCH] ulpi: add generic ULPI functionality

2011-11-11 Thread Jana Rapava
2011/11/8 Igor Grinberg 

>
> > +/*
> > + * This is a family of wrapper functions which sets bits in ULPI
> registers.
> > + * Access mode could be WRITE, SET or CLEAR.
>
> What about READ?
> I know it can be done from any of those registers, but it is confusing.
>
> > + * For further informations see ULPI 1.1 specification.
> > + */
> > +void ulpi_otg_ctrl_flags
> > + (struct usb_ehci *ehci, struct ulpi_regs *ulpi, int access_mode,
> u32 flags)
> > +{
> > + switch (access_mode) {
> > + case WRITE:
> > + ulpi_write(ehci, (u32)&ulpi->otg_ctrl_write, flags);
> > + break;
> > + case SET:
> > + ulpi_write(ehci, (u32)&ulpi->otg_ctrl_set, flags);
> > + break;
> > + case CLEAR:
> > + ulpi_write(ehci, (u32)&ulpi->otg_ctrl_clear, flags);
> > + break;
> > + }
> > +}
> > +
> > +void ulpi_function_ctrl_flags
> > + (struct usb_ehci *ehci, struct ulpi_regs *ulpi, int access_mode,
> u32 flags)
> > +{
> > + switch (access_mode) {
> > + case WRITE:
> > + ulpi_write(ehci, (u32)&ulpi->function_ctrl_write, flags);
> > + break;
> > + case SET:
> > + ulpi_write(ehci, (u32)&ulpi->function_ctrl_set, flags);
> > + break;
> > + case CLEAR:
> > + ulpi_write(ehci, (u32)&ulpi->function_ctrl_clear, flags);
> > + break;
> > + }
> > +}
> > +
> > +void ulpi_iface_ctrl_flags
> > + (struct usb_ehci *ehci, struct ulpi_regs *ulpi, int access_mode,
> u32 flags)
> > +{
> > + switch (access_mode) {
> > + case WRITE:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_write, flags);
> > + break;
> > + case SET:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_set, flags);
> > + break;
> > + case CLEAR:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_clear, flags);
> > + break;
> > + }
> > +
> > +}
>
> All the above functions are just making users hard to understand
> what they should do and what information they should know and
> supply to the driver.
> More function oriented API would be much more useful here.
>
>
Please, could you be more specific? I would be thankful, because I know
only Linux kernel ULPI API, where driver has to fill otg_transciever
structure with bits it needs to set (if I understand it well) and I would
like to use something more lightweight here.

> > +
> > +void ulpi_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi)
> > +{
> > + u32 tmp = 0;
> > + int reg;
> > +
> > + /* Assemble ID from four ULPI ID registers (8 bits each). */
> > + for (reg = ULPI_ID_REGS_COUNT - 1; reg >= 0; reg--)
> > + tmp |= ulpi_read(ehci, reg) << (reg * 8);
> > +
> > + /* Split ID into vendor and product ID. */
> > + debug("Found ULPI TX, ID %04x:%04x\n", tmp >> 16, tmp & 0x);
>
> What is TX? Is it transceiver or xceiver or both in one?
>
>
According to ULPI 1.1 specification, it is transceiver.

--
> Regards,
> Igor.
>

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/5] mx5: USB host support for mx51evk and mx53loco

2011-11-11 Thread Jana Rapava
> This patches series provides USB host support for the mx51evk and
> mx53loco. The generic ehci-mx5 interface is derived from ehci-mxc
> and uses the header files of the ehci-fsl interface. The callback
> board_ehci_hcd_init() allows to do board-specific setup when USB is
> started.
> 
> Wolfgang.
> 
> Wolfgang Grandegger (5):
>   mx5: add helper functions to enable USB clocks
>   mx5: add helper function to retrieve the GPIO number
>   mx5: add generic USB EHCI support for mx51 and mx53
>   mx53loco: add end enable USB host support on port 1
>   mx51evk: add end enable USB host support on port 1
> 
>  arch/arm/cpu/armv7/mx5/clock.c|   72 
>  arch/arm/include/asm/arch-mx5/clock.h |5 +
>  arch/arm/include/asm/arch-mx5/crm_regs.h  |3 +
>  arch/arm/include/asm/arch-mx5/mx5x_pins.h |4 +
>  board/freescale/mx51evk/mx51evk.c |   92 +++
>  board/freescale/mx53loco/mx53loco.c   |   10 ++
>  drivers/usb/host/Makefile |1 +
>  drivers/usb/host/ehci-mx5.c   |  174
> + include/configs/mx51evk.h | 
>  13 ++
>  include/configs/mx53loco.h|   13 ++
>  include/usb/ehci-fsl.h|   10 ++
>  11 files changed, 397 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/usb/host/ehci-mx5.c

Hi, I'm working on MX51 USB support based on some patches from Marek Vasut. 
It solves the problem in another way (uses structure-based offsets and generic
ULPI implementation I've written for this) and is probably more polished because
it's spent in the mailing list something like 2 months.
However, your patch supports both mx51 and mx53, so I think it would be nice
to find some way to get them together.
Last but not least, I'm sorry that I didn't respond to your first e-mail,
but I had to study for a test and hadn't time to look at your patch better.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ulpi: add generic ULPI functionality

2011-11-05 Thread Jana Rapava
2011/11/6 Marek Vasut 

> > 2011/11/5 Marek Vasut 
> >
> > > > +int ulpi_wait(struct usb_ehci *ehci, u32 ulpi_value, u32 ulpi_mask)
> > >
> > > So this works only with EHCI? How generic is it then ?
> >
> > I thought until now that ULPI is EHCI-dependent, but isn't... Ok, what
> else
> > should be supported? OHCI? I haven't any hardware to test it, but I could
> > give it a try.
>
> What about xHCI? I have no idea about OHCI, but why won't you be able to
> have
> OHCI and ULPI PHY?
>

I'll look at it.


> >
> > > > +void ulpi_iface_ctrl_flags
> > > > + (struct usb_ehci *ehci, struct ulpi_regs *ulpi, int
> access_mode,
> > >
> > > u32
> > >
> > > > flags) +{
> > > > + switch (access_mode) {
> > > > + case WRITE:
> > > > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_write, flags);
> > > > + break;
> > > > + case SET:
> > > > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_set, flags);
> > > > + break;
> > > > + case CLEAR:
> > > > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_clear, flags);
> > > > + break;
> > > > + }
> > > > +
> > > > +}
> > >
> > > Is this crap from linux or something?
> >
> > No, Linux has offset-based access to ULPI registers, some structure
> > otg_transceiver, where the driver sets the bits which it wants to be set
> in
> > ULPI registers (if I understand it well) and family of functions, which
> set
> > bits according to informations in otg_transceiver.
>
> Ok, you have writel() functions, why do you need this switch stuff ?
>

I tried to design some interface, which would allow its user care only
about register, access mode and flags and not about the exact way this huge
bunch od u8 fields called "ulpi_regs" is implemented.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ulpi: add generic ULPI functionality

2011-11-05 Thread Jana Rapava
2011/11/5 Marek Vasut 

>
> > +int ulpi_wait(struct usb_ehci *ehci, u32 ulpi_value, u32 ulpi_mask)
>
> So this works only with EHCI? How generic is it then ?
>
>
I thought until now that ULPI is EHCI-dependent, but isn't... Ok, what else
should be supported? OHCI? I haven't any hardware to test it, but I could
give it a try.


>
> > +void ulpi_iface_ctrl_flags
> > + (struct usb_ehci *ehci, struct ulpi_regs *ulpi, int access_mode,
> u32
> > flags) +{
> > + switch (access_mode) {
> > + case WRITE:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_write, flags);
> > + break;
> > + case SET:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_set, flags);
> > + break;
> > + case CLEAR:
> > + ulpi_write(ehci, (u32)&ulpi->iface_ctrl_clear, flags);
> > + break;
> > + }
> > +
> > +}
>
> Is this crap from linux or something?
>
>
No, Linux has offset-based access to ULPI registers, some structure
otg_transceiver, where the driver sets the bits which it wants to be set in
ULPI registers (if I understand it well) and family of functions, which set
bits according to informations in otg_transceiver.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] usb: adjust Efika USB code to generic ULPI framework

2011-11-05 Thread Jana Rapava
This patch changes Efika USB support code to use generic ULPI implementation
instead of driver's own.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
 board/efikamx/efikamx-usb.c |  105 +--
 include/configs/efikamx.h   |1 +
 2 files changed, 13 insertions(+), 93 deletions(-)

diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
index 3b42256..2a0341f 100644
--- a/board/efikamx/efikamx-usb.c
+++ b/board/efikamx/efikamx-usb.c
@@ -205,104 +205,21 @@ void control_regs_setup(struct mx5_usb_control_regs 
*control)
udelay(1);
 }
 
-#define ULPI_ADDR_SHIFT16
-#define ulpi_write_mask(value) ((value) & 0xff)
-#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
-
-int ulpi_wait(struct usb_ehci *ehci, u32 ulpi_value, u32 ulpi_mask)
+void ulpi_set_flags(struct usb_ehci *ehci, struct ulpi_regs *ulpi)
 {
-   int timeout = ULPI_TIMEOUT;
-   u32 tmp;
-
-   writel(ulpi_value, &ehci->ulpi_viewpoint);
-
-   /* Wait for the bits in ulpi_mask to become zero. */
-   while (--timeout) {
-   tmp = readl(&ehci->ulpi_viewpoint);
-   if (!(tmp & ulpi_mask))
-   break;
-   WATCHDOG_RESET();
-   }
-
-   return !timeout;
-}
-
-int ulpi_wakeup(struct usb_ehci *ehci)
-{
-   if (readl(&ehci->ulpi_viewpoint) & ULPI_SS)
-   return 0; /* already awake */
-   return ulpi_wait(ehci, ULPI_WU, ULPI_WU);
-}
-
-void ulpi_write(struct usb_ehci *ehci, u32 reg, u32 value)
-{
-   u32 tmp;
-   if (ulpi_wakeup(ehci)) {
-   printf("ULPI wakeup timed out\n");
-   return;
-   }
-
-   tmp = ulpi_wait(ehci, ULPI_RWRUN | ULPI_RWCTRL |
-   reg << ULPI_ADDR_SHIFT | ulpi_write_mask(value), ULPI_RWRUN);
-   if (tmp)
-   printf("ULPI write timed out\n");
-}
-
-u32 ulpi_read(struct usb_ehci *ehci, u32 reg)
-{
-   if (ulpi_wakeup(ehci)) {
-   printf("ULPI wakeup timed out\n");
-   return 0;
-   }
-
-   if (ulpi_wait(ehci, ULPI_RWRUN | reg << ULPI_ADDR_SHIFT, ULPI_RWRUN)) {
-   printf("ULPI read timed out\n");
-   return 0;
-   }
-
-   return ulpi_read_mask(readl(&ehci->ulpi_viewpoint));
-}
-
-void ulpi_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi)
-{
-   u32 tmp = 0;
-   int reg, i;
-
-   /* Assemble ID from four ULPI ID registers (8 bits each). */
-   for (reg = ULPI_ID_REGS_COUNT - 1; reg >= 0; reg--)
-   tmp |= ulpi_read(ehci, reg) << (reg * 8);
-
-   /* Split ID into vendor and product ID. */
-   debug("Found ULPI TX, ID %04x:%04x\n", tmp >> 16, tmp & 0x);
-
-   /* ULPI integrity check */
-   for (i = 0; i < 2; i++) {
-   ulpi_write(ehci, (u32)&ulpi->scratch_write,
-   ULPI_TEST_VALUE << i);
-   tmp = ulpi_read(ehci, (u32)&ulpi->scratch_write);
-
-   if (tmp != (ULPI_TEST_VALUE << i)) {
-   printf("ULPI integrity check failed\n");
-   return;
-   }
-   }
-
-   /* Set ULPI flags. */
-   ulpi_write(ehci, (u32)&ulpi->otg_ctrl_write,
-   ULPI_OTG_EXTVBUSIND |
+   ulpi_otg_ctrl_flags(ehci, ulpi, WRITE, ULPI_OTG_EXTVBUSIND |
ULPI_OTG_DM_PULLDOWN | ULPI_OTG_DP_PULLDOWN);
-   ulpi_write(ehci, (u32)&ulpi->function_ctrl_write,
-   ULPI_FC_XCVRSEL | ULPI_FC_OPMODE_NORMAL |
-   ULPI_FC_SUSPENDM);
-   ulpi_write(ehci, (u32)&ulpi->iface_ctrl_write, 0);
-   ulpi_write(ehci, (u32)&ulpi->otg_ctrl_set,
-   ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
+   ulpi_function_ctrl_flags(ehci, ulpi, WRITE, ULPI_FC_XCVRSEL |
+   ULPI_FC_OPMODE_NORMAL | ULPI_FC_SUSPENDM);
+   ulpi_iface_ctrl_flags(ehci, ulpi, WRITE, 0);
 
/*
-* NOTE: This violates USB specification, but otherwise, USB on Efika
-* doesn't charge VBUS and as a result, USB doesn't work.
+* NOTE: Setting ULPI_OTG_CHRGVBUS violates USB specification,
+* but otherwise, USB on Efika doesn't charge VBUS
+* and as a result, USB doesn't work.
 */
-   ulpi_write(ehci, (u32)&ulpi->otg_ctrl_set, ULPI_OTG_CHRGVBUS);
+   ulpi_otg_ctrl_flags(ehci, ulpi, SET, ULPI_OTG_DRVVBUS |
+   ULPI_OTG_DRVVBUS_EXT | ULPI_OTG_CHRGVBUS);
 }
 
 /*
@@ -353,6 +270,7 @@ void ehci1_init(struct usb_ehci *ehci, struct ulpi_regs 
*ulpi)
udelay(1);
 
ulpi_init(ehci, ulpi);
+   ulpi_set_flags(ehci, ulpi);
 }
 
 void ehci2_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi)
@@ -372,6 +290,7

[U-Boot] [PATCH] ulpi: add generic ULPI functionality

2011-11-05 Thread Jana Rapava
Add generic functions for ULPI init and setting bits in 
ULPI registers. 

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
 Makefile |1 +
 drivers/usb/ulpi/Makefile|   44 ++
 drivers/usb/ulpi/ulpi-viewport.c |   87 +++
 drivers/usb/ulpi/ulpi.c  |  123 ++
 include/usb/ulpi.h   |   16 +
 5 files changed, 271 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/ulpi/Makefile
 create mode 100644 drivers/usb/ulpi/ulpi-viewport.c
 create mode 100644 drivers/usb/ulpi/ulpi.c

diff --git a/Makefile b/Makefile
index 571c3eb..a475cb9 100644
--- a/Makefile
+++ b/Makefile
@@ -283,6 +283,7 @@ LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
 LIBS += drivers/usb/phy/libusb_phy.o
+LIBS += drivers/usb/ulpi/libusb_ulpi.o
 LIBS += drivers/video/libvideo.o
 LIBS += drivers/watchdog/libwatchdog.o
 LIBS += common/libcommon.o
diff --git a/drivers/usb/ulpi/Makefile b/drivers/usb/ulpi/Makefile
new file mode 100644
index 000..f7b6e20
--- /dev/null
+++ b/drivers/usb/ulpi/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2011 Jana Rapava 
+# 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 $(TOPDIR)/config.mk
+
+LIB:= $(obj)libusb_ulpi.o
+
+COBJS-$(CONFIG_USB_ULPI) += ulpi.o ulpi-viewport.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
new file mode 100644
index 000..a0c213e
--- /dev/null
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/drivers/usb/otg/ulpi_viewport.c
+ *
+ * Original Copyright follow:
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+#define ULPI_ADDR_SHIFT16
+#define ulpi_write_mask(value) ((value) & 0xff)
+#define ulpi_read_mask(value)  (((value) >> 8) & 0xff)
+
+int ulpi_wait(struct usb_ehci *ehci, u32 ulpi_value, u32 ulpi_mask)
+{
+   int timeout = ULPI_TIMEOUT;
+   u32 tmp;
+
+   writel(ulpi_value, &ehci->ulpi_viewpoint);
+
+   /* Wait for the bits in ulpi_mask to become zero. */
+   while (--timeout) {
+   tmp = readl(&ehci->ulpi_viewpoint);
+   if (!(tmp & ulpi_mask))
+   break;
+   WATCHDOG_RESET();
+   }
+
+   return !timeout;
+}
+
+int ulpi_wakeup(struct usb_ehci *ehci)
+{
+   if (readl(&ehci->ulpi_viewpoint) & ULPI_SS)
+   return 0; /* already awake */
+   return ulpi_wait(ehci, ULPI_WU, ULPI_WU);
+}
+
+void ulpi_write(struct usb_ehci *ehci, u32 reg, u32 value)
+{
+   u32 tmp;
+   if (ulpi_wakeup(ehci)) {
+   printf("ULPI wakeup timed out\n");
+   return;
+   }
+
+   tmp = ulpi_wait(ehci, ULPI_RWRUN | ULPI_RWCTRL |
+   reg << ULPI_ADDR_SHIFT | ulpi_write_mask(value), ULPI_RWRUN);
+   if (tmp)
+   printf("ULP

[U-Boot] [PATCH v2] ulpi: add generic ULPI support header file

2011-11-02 Thread Jana Rapava
Add ULPI header file needed by Efika USB support patchset and generic
ULPI support patch, which is to be posted soon.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
Changes for v2:
- whitespace and comment changes
 include/usb/ulpi.h |  204 
 1 files changed, 204 insertions(+), 0 deletions(-)
 create mode 100644 include/usb/ulpi.h

diff --git a/include/usb/ulpi.h b/include/usb/ulpi.h
new file mode 100644
index 000..1519cc5
--- /dev/null
+++ b/include/usb/ulpi.h
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/include/linux/usb/ulpi.h
+ * ULPI defines and function prototypes
+ *
+ * Original Copyrights follow:
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * This software is distributed under the terms of the GNU General
+ * Public License ("GPL") as published by the Free Software Foundation,
+ * version 2 of that License.
+ */
+
+#ifndef __USB_ULPI_H
+#define __USB_ULPI_H
+
+#define ULPI_ID_REGS_COUNT 4
+#define ULPI_TEST_VALUE0x55
+#define ULPI_TIMEOUT   1000 /* some reasonable value */
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+struct ulpi_regs {
+   /* Vendor ID and Product ID: 0x00 - 0x03 Read-only */
+   u8  vendor_id_low;
+   u8  vendor_id_high;
+   u8  product_id_low;
+   u8  product_id_high;
+   /* Function Control: 0x04 - 0x06 Read */
+   u8  function_ctrl_write;/* 0x04 Write */
+   u8  function_ctrl_set;  /* 0x05 Set */
+   u8  function_ctrl_clear;/* 0x06 Clear */
+   /* Interface Control: 0x07 - 0x09 Read */
+   u8  iface_ctrl_write;   /* 0x07 Write */
+   u8  iface_ctrl_set; /* 0x08 Set */
+   u8  iface_ctrl_clear;   /* 0x09 Clear */
+   /* OTG Control: 0x0A - 0x0C Read */
+   u8  otg_ctrl_write; /* 0x0A Write */
+   u8  otg_ctrl_set;   /* 0x0B Set */
+   u8  otg_ctrl_clear; /* 0x0C Clear */
+   /* USB Interrupt Enable Rising: 0x0D - 0x0F Read */
+   u8  usb_ie_rising_write;/* 0x0D Write */
+   u8  usb_ie_rising_set;  /* 0x0E Set */
+   u8  usb_ie_rising_clear;/* 0x0F Clear */
+   /* USB Interrupt Enable Falling: 0x10 - 0x12 Read */
+   u8  usb_ie_falling_write;   /* 0x10 Write */
+   u8  usb_ie_falling_set; /* 0x11 Set */
+   u8  usb_ie_falling_clear;   /* 0x12 Clear */
+   /* USB Interrupt Status: 0x13 Read-only */
+   u8  usb_int_status;
+   /* USB Interrupt Latch: 0x14 Read-only with auto-clear */
+   u8  usb_int_latch;
+   /* Debug: 0x15 Read-only */
+   u8  debug;
+   /* Scratch Register: 0x16 - 0x18 Read */
+   u8  scratch_write;  /* 0x16 Write */
+   u8  scratch_set;/* 0x17 Set */
+   u8  scratch_clear;  /* 0x18 Clear */
+   /*
+* Optional Carkit registers
+*/
+   /* Carkit Control: 0x19 - 0x1B Read */
+   u8  carkit_ctrl_write;  /* 0x19 Write */
+   u8  carkit_ctrl_set;/* 0x1A Set */
+   u8  carkit_ctrl_clear;  /* 0x1B Clear */
+   /* Carkit Interrupt Delay: 0x1C Read, Write */
+   u8  carkit_int_delay;
+   /* Carkit Interrupt Enable: 0x1D - 0x1F Read */
+   u8  carkit_ie_write;/* 0x1D Write */
+   u8  carkit_ie_set;  /* 0x1E Set */
+   u8  carkit_ie_clear;/* 0x1F Clear */
+   /* Carkit Interrupt Status: 0x20 Read-only */
+   u8  carkit_int_status;
+   /* Carkit Interrupt Latch: 0x21 Read-only with auto-clear */
+   u8  carkit_int_latch;
+   /* Carkit Pulse Control: 0x22 - 0x24 Read */
+   u8  carkit_pulse_ctrl_write;/* 0x22 Write */
+   u8  carkit_pulse_ctrl_set;  /* 0x23 Set */
+   u8  carkit_pulse_ctrl_clear;/* 0x24 Clear */
+   /*
+* Other optional registers
+*/
+   /* Transmit Positive Width: 0x25 Read, Write */
+   u8  transmit_pos_width;
+   /* Transmit Negative Width: 0x26 Read, Write */
+   u8  transmit_neg_width;
+   /* Receive Polarity Recovery: 0x27 Read, Write */
+   u8  recv_pol_recovery;
+   /*
+* Addresses 0x28 - 0x2E are reserved, so we use offsets
+* for immediate registers with higher addresses
+*/
+};
+
+/* Access Extended Register Set (indicator) */
+#define ACCESS_EXT_REGS_OFFSET 0x2f/* read-write */
+/* Vendor-specific */
+#define VENDOR_SPEC_OFFSET 0x30
+
+/*
+ * Extended Register Set
+ *
+ * Addresses 0x00-0x3F map directly to Immediate Register Set.
+ * Addresses 0x40-0x7F are res

Re: [U-Boot] [PATCH v7 4/4] usb: add USB support for Efika

2011-11-02 Thread Jana Rapava
2011/11/2 Igor Grinberg 

> Hi Jana,
>
> On 11/01/11 21:24, Jana Rapava wrote:
>
> > diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
> > new file mode 100644
> > index 000..fec9ee0
> > --- /dev/null
> > +++ b/board/efikamx/efika.h
> >
> > diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
> > new file mode 100644
> > index 000..3b42256
> > --- /dev/null
> > +++ b/board/efikamx/efikamx-usb.c
> >
>
> Most of the functions and defines above aren't board specific, right?
> It would be a good thing to put them in an SoC specific location,
> so any other board using that SoC can benefit from them.
>

Ok, so non-board-specific parts should go into ./arch/arm/cpu/armv7/mx5/
and board-specific callbacks should stay here? Do I understand you well?

>
> I don't want to block on that issue, so if it simplifies you a
> further ULPI patches submission - I don't care if you leave it here
> and in the next patch set move to a common location.
>
>
Thanks.


> Although the proper way would be to submit the framework(s) and then
> adjust the users.
>
>
Ok, I'll do it that way in the future patchsets.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v7 4/4] usb: add USB support for Efika

2011-11-01 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 

Acked-by: Marek Vasut 
---
Changes for v2:
- introduce temporary variable in ulpi_write
- whitespace changes
Changes for v3:
 - add protection against multiple inclusion of efika.h
Changes for v4:
  - rename multiple inclusion protection macro in efika.h
Changes for v5:
   - fix unterminated #ifndef in efika.h
Changes for v6:
- add Acked-by
- no changes
Changes for v7:
- use ULPI-related definitions from ./include/usb/ulpi.h

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   35 
 board/efikamx/efikamx-usb.c |  424 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 481 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..fec9ee0
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef __BOARD_EFIKAMX_EFIKA_H__
+#define __BOARD_EFIKAMX_EFIKA_H__
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
+
+#endif /* __BOARD_EFIKAMX_EFIKA_H__ */
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..3b42256
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,424 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG

[U-Boot] [PATCH v3 3/4] EHCI: adjust for mx5

2011-11-01 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
Changes for v2:
- whitespace and coding style changes
Changes for v3:
- ULPI-related definitions moved to ULPI header file
 
 drivers/usb/host/ehci-mxc.c |   31 +--
 include/usb/ehci-fsl.h  |   86 ++-
 2 files changed, 88 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..9c6cd88 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,80 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#define MX51_H2_WUE(1 << 7)
+#define MX51_H2_PM (1 << 4)
+
+/* PORTSCx bits of interest */
+#define MX51_ULPI_MODE_MASK(2 <<

[U-Boot] [PATCH] ulpi: add generic ULPI support header file

2011-11-01 Thread Jana Rapava
Add ULPI header file needed by Efika USB support patchset and generic
ULPI support patch, which is to be posted soon.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
 include/usb/ulpi.h |  195 
 1 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100644 include/usb/ulpi.h

diff --git a/include/usb/ulpi.h b/include/usb/ulpi.h
new file mode 100644
index 000..4a88b5f
--- /dev/null
+++ b/include/usb/ulpi.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ * Based on:
+ * linux/include/linux/usb/ulpi.h
+ * ULPI defines and function prototypes
+ *
+ * Original Copyrights follow:
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * This software is distributed under the terms of the GNU General
+ * Public License ("GPL") as published by the Free Software Foundation,
+ * version 2 of that License.
+ */
+
+#ifndef __USB_ULPI_H
+#define __USB_ULPI_H
+
+#define ULPI_ID_REGS_COUNT 4
+#define ULPI_TEST_VALUE0x55
+#define ULPI_TIMEOUT   1000 /* some reasonable value */
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+struct ulpi_regs {
+   u8  vendor_id_low;  /* 0x00 - Vendor ID lower byte */
+   u8  vendor_id_high; /* 0x01 - Vendor ID upper byte */
+   u8  product_id_low; /* 0x02 - Product ID lower byte */
+   u8  product_id_high;/* 0x03 - Product ID higher byte */
+   /* Function Control; 0x04 - 0x06 Read, 0x04 Write */
+   u8  function_ctrl_write;
+   u8  function_ctrl_set;  /* 0x05 Set */
+   u8  function_ctrl_clear;/* 0x06 Clear */
+   /* Interface Control; 0x07 - 0x09 Read, 0x07 Write */
+   u8  iface_ctrl_write;
+   u8  iface_ctrl_set; /* 0x08 Set */
+   u8  iface_ctrl_clear;   /* 0x09 Clear */
+   /* OTG Control; 0x0A - 0x0C Read, 0x0A Write */
+   u8  otg_ctrl_write;
+   u8  otg_ctrl_set;   /* 0x0B Set */
+   u8  otg_ctrl_clear; /* 0x0C Clear */
+   /* USB Interrupt Enable Rising; 0x0D - 0x0F Read, 0x0D Write */
+   u8  usb_ie_rising_write;
+   u8  usb_ie_rising_set;  /* 0x0E Set */
+   u8  usb_ie_rising_clear;/* 0x0F Clear */
+   /* USB Interrupt Enable Falling; 0x10 - 0x12 Read, 0x10 Write */
+   u8  usb_ie_falling_write;
+   u8  usb_ie_falling_set; /* 0x11 Set */
+   u8  usb_ie_falling_clear;   /* 0x12 Clear */
+   u8  usb_int_status; /* 0x13 - USB Interrupt Status */
+   u8  usb_int_latch;  /* 0x14 - USB Interrupt Latch */
+   u8  debug;  /* 0x15 - Debug */
+   /* Scratch Register; 0x16 - 0x18 Read, 0x16 Write */
+   u8  scratch_write;
+   u8  scratch_set;/* 0x17 Set */
+   u8  scratch_clear;  /* 0x18 Clear */
+   /*
+* Optional Carkit registers
+*/
+   /* Carkit Control; 0x19 - 0x1B Read, 0x19 Write */
+   u8 carkit_ctrl_write;
+   u8 carkit_ctrl_set;
+   u8 carkit_ctrl_clear;
+   /* Carkit Interrupt Delay */
+   u8 carkit_int_delay;/* 0x1C Read, Write */
+   /* Carkit Interrupt Enable; 0x1D - 0x1F Read, 0x1D Write */
+   u8 carkit_ie_write;
+   u8 carkit_ie_set;
+   u8 carkit_ie_clear;
+   u8 carkit_int_status;   /* 0x20 - Carkit Interrupt Status */
+   u8 carkit_int_latch;/* 0x21 - Carkit Interrupt Latch */
+   /* Carkit Pulse Control; 0x22 - 0x24 Read, 0x22 Write */
+   u8 carkit_pulse_ctrl_write;
+   u8 carkit_pulse_ctrl_set;
+   u8 carkit_pulse_ctrl_clear;
+   /*
+* Other optional registers
+*/
+   u8  transmit_pos_width; /* 0x25 - Transmit Positive Width */
+   u8  transmit_neg_width; /* 0x26 - Transmit Negative Width */
+   u8  recv_pol_recovery;  /* 0x27 - Receive Polarity Recovery */
+   /*
+* Addresses 0x28 - 0x2E are reserved, so we use offsets
+* for immediate registers with higher addresses
+*/
+};
+
+/* Access Extended Register Set (indicator) */
+#define ACCESS_EXT_REGS_OFFSET 0x2f/* read-write */
+/* Vendor-specific */
+#define VENDOR_SPEC_OFFSET 0x30
+
+/*
+ * Extended Register Set
+ *
+ * Addresses 0x00-0x3F map directly to Immediate Register Set.
+ * Addresses 0x40-0x7F are reserved.
+ * Addresses 0x80-0xff are vendor-specific.
+ */
+#define EXT_VENDOR_SPEC_OFFSET 0x80
+
+/*
+ * Register Bits
+ */
+
+/* Function Control */
+#define ULPI_FC_XCVRSEL(1 << 0)
+#define ULPI_FC_XCVRSEL_MASK   (3 << 0)
+#define ULPI_FC_HIGH_SPEED (0 << 0)
+#def

Re: [U-Boot] [PATCH v2 3/4] EHCI: adjust for mx5

2011-11-01 Thread Jana Rapava
2011/11/1 Igor Grinberg 

>
> Do you already have a header for the generic ULPI support?
> Can't the above be put in that header and the next patch set
> (ULPI) will just extend this?
>

Ok, I'll send ulpi header as a separate patch, thanks for suggestion.

>
>
> --
> Regards,
> Igor.
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/4] EHCI: adjust for mx5

2011-10-31 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
Cc: Igor Grinberg 
---
Changes for v2:
- whitespace and coding style changes (no actual changes)

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..f957c65 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1 << 6)
+#define MX25_USB_CTRL_HSTD_BIT (1 << 5)
+#define MX25_USB_CTRL_USBTE_BIT(1 << 4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1 << 3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest */
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest */
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (0x3)
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#define MX51_H2_WUE(1 << 7)
+#define MX51_H2_PM (1 << 4)
+
+/* PORTSCx bits of interest */
+#define MX51_ULPI_MODE_MASK(2 << 30)
+#define MX51_16BIT_UTMI   

Re: [U-Boot] [PATCH 3/4] EHCI: adjust for mx5

2011-10-31 Thread Jana Rapava
2011/10/31 Igor Grinberg 


> > +struct mxc_ulpi_regs {
> > + u8  vendor_id_low;  /* 0x00 - Vendor ID lower byte */
> > + u8  vendor_id_high; /* 0x01 - Vendor ID upper byte */
> > + u8  product_id_low; /* 0x02 - Product ID lower byte */
> > + u8  product_id_high;/* 0x03 - Product ID higher byte */
> > + /* Function Control; 0x04 - 0x06 Read, 0x04 Write */
> > + u8  function_ctrl_write;
> > + u8  function_ctrl_set;  /* 0x05 Set */
> > + u8  function_ctrl_clear;/* 0x06 Clear */
> > + /* Interface Control; 0x07 - 0x09 Read, 0x07 Write */
> > + u8  iface_ctrl_write;
> > + u8  iface_ctrl_set; /* 0x08 Set */
> > + u8  iface_ctrl_clear;   /* 0x09 Clear */
> > + /* OTG Control; 0x0A - 0x0C Read, 0x0A Write */
> > + u8  otg_ctrl_write;
> > + u8  otg_ctrl_set;   /* 0x0B Set */
> > + u8  otg_ctrl_clear; /* 0x0C Clear */
> > + /* USB Interrupt Enable Rising; 0x0D - 0x0F Read, 0x0D Write */
> > + u8  usb_ie_rising_write;
> > + u8  usb_ie_rising_set;  /* 0x0E Set */
> > + u8  usb_ie_rising_clear;/* 0x0F Clear */
> > + /* USB Interrupt Enable Falling; 0x10 - 0x12 Read, 0x10 Write */
> > + u8  usb_ie_falling_write;
> > + u8  usb_ie_falling_set; /* 0x11 Set */
> > + u8  usb_ie_falling_clear;   /* 0x12 Clear */
> > + u8  usb_int_status; /* 0x13 - USB Interrupt Status */
> > + u8  usb_int_latch;  /* 0x14 - USB Interrupt Latch */
> > + u8  debug;  /* 0x15 - Debug */
> > + /* Scratch Register; 0x16 - 0x18 Read, 0x16 Write */
> > + u8  scratch_write;
> > + u8  scratch_set;/* 0x17 Set */
> > + u8  scratch_clear;  /* 0x18 Clear*/
> > +};
>
>
> These are the generic ULPI specification registers
> and not mxc specific.
> I'd expect to have them in a more generic location.
>

This would be fixed in general ULPI support patch I'm working on. It should
be ready for posting in a few days.


> --
>
Regards,
> Igor.
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v6 4/4] usb: add USB support for Efika

2011-10-31 Thread Jana Rapava
2011/10/31 Stefano Babic 

> > There are some issues with: [PATCH 3/4] EHCI: adjust for mx5
> > If you have already applied it
>
> Jana, can you answer / fix this point ?
>
>
I really don't know what happens there. Code file looks aligned, but when I
generate a patch with git-format-patch, aligning is messed up. So I fix it
in git-send-email, but after sending  whitespace characters are messed up
again.
I wasn't able to find a way to fix it yet.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC] general ULPI support

2011-10-15 Thread Jana Rapava
Hi all,
my patch, which added USB support for Efika, needed som ULPI functions. I
was suggested to write general ULPI support code rather than implenent
demanded functionality in the driver.
However, I've encountered following problems:
1. Where should I put this code? Linux kernel has it in ./drivers/usb/otg/
together with OTG utility code. Use this name looks a bit deceiving for me.
Should I create some directory named like ./drivers/usb/ulpi/, or is there
better place?
2. I don't know what to add to the Makefile. Should I create a new config
option (named CONFIG_ULPI I suppose) or simply add rule for new files?

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/4] USB: move ehci.h and ehci-core.h into /include/usb/

2011-10-09 Thread Jana Rapava
2011/10/9 Marek Vasut 

> On Sunday, September 25, 2011 07:25:07 PM Jana Rapava wrote:
> > Signed-off-by: Jana Rapava 
> > Cc: Marek Vasut 
> > Cc: Remy Bohmer 
> > Cc: Fabio Estevam 
> > ---
> > Changes for v2:
> >   - changed to proper patch
> > Changes for v3:
> >   - merged other USB patches from u-boot-pxa/efikasb
> >   - offset-based access changed to struct-based access
> >   - use {clrset,clr,set}bits_le32() calls
> >   - CodingStyle and naming cleanup
> > Changes for v4:
> >- split into patchset
> >- move ehci.h and ehci-core.h into /include/usb/
> >
>
> Uh,
>
> I have totally no idea which is the last set of patches here now anymore.
> Anyway, is there any update or is this plain stuck ?
>
> Cheers
>

Last set of patches is there:
[0/4] http://lists.denx.de/pipermail/u-boot/2011-September/102729.html
[1/4] http://lists.denx.de/pipermail/u-boot/2011-September/102720.html
[2/4] http://lists.denx.de/pipermail/u-boot/2011-September/102719.html
[3/4] http://lists.denx.de/pipermail/u-boot/2011-September/102721.html
[4/4] http://lists.denx.de/pipermail/u-boot/2011-September/102803.html

I haven't found time to work on this recently, I have some problems in
school which I absolutely have to solve first.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v8 4/4] Add USB support for Efika

2011-10-07 Thread Jana Rapava
2011/10/6 Wolfgang Denk 

>
> Checkpatch says:
>
> total: 1 errors, 0 warnings, 502 lines checked
>
> Please clean up and resubmit.  Thanks.
>
>
Last version of this patch is here:
http://lists.denx.de/pipermail/u-boot/2011-September/102803.html
(sorry for breaking the thread but I messed up some In-Reply-To: headers).
On the last version checkpatch says only two warnings, both are about
including files not from  and doesn't make sense in this case.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v6 4/4] usb: add USB support for Efika

2011-09-29 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 

Acked-by: Marek Vasut 
---
Changes for v2:
- introduce temporary variable in ulpi_write
- whitespace changes
Changes for v3:
 - add protection against multiple inclusion of efika.h
Changes for v4:
  - rename multiple inclusion protection macro in efika.h
Changes for v5:
   - fix unterminated #ifndef in efika.h
Changes for v6:
- add Acked-by
- no changes

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   35 
 board/efikamx/efikamx-usb.c |  423 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 480 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..fec9ee0
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef __BOARD_EFIKAMX_EFIKA_H__
+#define __BOARD_EFIKAMX_EFIKA_H__
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
+
+#endif /* __BOARD_EFIKAMX_EFIKA_H__ */
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..b169ea7
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad

[U-Boot] [PATCH v5 4/4] Add USB support for Efika

2011-09-29 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
 - introduce temporary variable in ulpi_write
 - whitespace changes
Changes for v3:
  - add protection against multiple inclusion of efika.h
Changes for v4:
   - rename multiple inclusion protection macro in efika.h
Changes for v5:
- fix unterminated #ifndef in efika.h

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   35 
 board/efikamx/efikamx-usb.c |  423 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 480 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..fec9ee0
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef __BOARD_EFIKAMX_EFIKA_H__
+#define __BOARD_EFIKAMX_EFIKA_H__
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
+
+#endif /* __BOARD_EFIKAMX_EFIKA_H__ */
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..b169ea7
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux

[U-Boot] [PATCH v4 4/4] usb: add USB support for Efika

2011-09-29 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
  - introduce temporary variable in ulpi_write
  - whitespace changes
Changes for v3:
   - add protection against multiple inclusion of efika.h
Changes for v4:
- rename multiple inclusion protection macro in efika.h

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   33 
 board/efikamx/efikamx-usb.c |  423 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 478 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..f5a09e3
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef __BOARD_EFIKAMX_EFIKA_H__
+#define __BOARD_EFIKAMX_EFIKA_H__
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..b169ea7
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG

[U-Boot] [PATCH v3 4/4] usb: add USB support for Efika

2011-09-29 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
   - introduce temporary variable in ulpi_write
   - whitespace changes
Changes for v3:
- add protection against multiple inclusion of efika.h

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   33 
 board/efikamx/efikamx-usb.c |  423 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 478 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..efda329
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+#ifndef EFIKA_H
+#define EFIKA_H
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..b169ea7
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4

[U-Boot] [PATCH v2 4/4] usb: add USB support for Efika

2011-09-28 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
- introduce temporary variable in ulpi_write
- whitespace changes
 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   30 +++
 board/efikamx/efikamx-usb.c |  423 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 475 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..b3532e2
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..b169ea7
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad

[U-Boot] [PATCH v2 0/4] Move ehci headers, add Efika USB support

2011-09-28 Thread Jana Rapava
This patchset moves header files ehci.h and ehci-core.h 
from drivers/usb/host/ to /include/usb and adds USB support for Efika
with cleanup of file /drivers/usb/host/ehci-mxc.c.

In the previous revisions I messed up versioning and some From: and
In-Reply-To: headers, so I want to bury this mess and start with a clean
plate. Version of patches in this patchset will then be 1.

Changes for v2:
- no changes, I only forget to add Cc: when I sent this

Fabio Estevam (1):
  usb: Move ehci.h and ehci-core.h to include/usb directory

Jana Rapava (3):
  EHCI: add callback ehci_fixup
  EHCI: adjust for mx5
  Add USB support for Efika

 board/efikamx/Makefile   |3 +
 board/efikamx/efika.h|   30 +++
 board/efikamx/efikamx-usb.c  |  420 ++
 board/efikamx/efikamx.c  |3 +
 drivers/usb/host/ehci-core.h |   29 ---
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |   16 ++-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |   35 +---
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/configs/efikamx.h|   16 ++
 include/usb/ehci-core.h  |   29 +++
 include/usb/ehci-fsl.h   |  146 +-
 include/usb/ehci.h   |  203 ++
 19 files changed, 882 insertions(+), 279 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
2011/9/29 Marek Vasut 


> the cover letter is missing


sorry, I forgot to Cc: you


> and it's sent as a set of separate patches. Why?
>

I thought this should be a patchset, it doesn't look like one logical change
to me...

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 4/4] usb: add USB support for Efika

2011-09-28 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   30 +++
 board/efikamx/efikamx-usb.c |  420 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 472 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..b3532e2
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..ac031ef
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,420 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0

[U-Boot] [PATCH 3/4] EHCI: adjust for mx5

2011-09-28 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#define MX51_H2_WUE(1 << 7)
+#define MX51_H2_PM (1 << 4)
+
+/* PORTSCx bits of interest */
+#define MX51_ULPI_MODE_MASK(2 << 30)
+#define MX51_16BIT_UTMI(1 << 28)
+
+/* USBCMD bits of interest */
+#define MX51_ITC_IMMEDIATE_MASK(0xff << 16)
+#endif
+
+/*
+* 

[U-Boot] [PATCH 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
From: Fabio Estevam 

Move ehci.h and ehci-core.h to include/usb directory.

Signed-off-by: Fabio Estevam 
Cc: Remy Bohmer 
Cc: Marek Vasut 
---
 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef CONFIG_PCI_EHCI_DEVICE
 static struct pci_device_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci-ppc4xx.c b/drivers/usb/host/ehci-ppc4xx.c
index 1179919..1a1fae1 100644
--- a/drivers/usb/host/ehci-ppc4xx.c
+++ b/drivers/usb/host/ehci-ppc4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#i

[U-Boot] [PATCH 2/4] EHCI: add callback ehci_fixup

2011-09-28 Thread Jana Rapava
Add callback to ehci_hcd.c to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 

Acked-by: Marek Vasut 
---
 drivers/usb/host/ehci-hcd.c |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..c548276 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -536,6 +536,18 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+/*
+ * This is an alias to __ehci_fixup() unless user provides other definition
+ * of ehci_fixup function.
+ */
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +721,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/4] Move ehci headers, add Efika USB support

2011-09-28 Thread Jana Rapava
This patchset moves header files ehci.h and ehci-core.h 
from drivers/usb/host/ to /include/usb and adds USB support for Efika
with cleanup of file /drivers/usb/host/ehci-mxc.c.

In the previous revisions I messed up versioning and some From: and
In-Reply-To: headers, so I want to bury this mess and start with a clean
plate. Version of patches in this patchset will then be 1.

Fabio Estevam (1):
  usb: Move ehci.h and ehci-core.h to include/usb directory

Jana Rapava (3):
  EHCI: add callback ehci_fixup
  EHCI: adjust for mx5
  Add USB support for Efika

 board/efikamx/Makefile   |3 +
 board/efikamx/efika.h|   30 +++
 board/efikamx/efikamx-usb.c  |  420 ++
 board/efikamx/efikamx.c  |3 +
 drivers/usb/host/ehci-core.h |   29 ---
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |   16 ++-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |   35 +---
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/configs/efikamx.h|   16 ++
 include/usb/ehci-core.h  |   29 +++
 include/usb/ehci-fsl.h   |  146 +-
 include/usb/ehci.h   |  203 ++
 19 files changed, 882 insertions(+), 279 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v9 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
2011/9/29 Marek Vasut 

>
> > Ok, what Message-ID should I then use for In-Reply-To field?
>
> None in this case ... did you actually read the patch submission rules?
>
>
I read this and didn't find this information here:
http://www.denx.de/wiki/U-Boot/Patches
Is there anything else I should read?
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v9 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
2011/9/28 Marek Vasut 

> Can you repost the whole series with proper cover letter explaining you're
> burying this mess and all ? Start versioning from V1 then.
>
> Thanks
>
>
Ok, what Message-ID should I then use for In-Reply-To field?

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v9 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
2011/9/28 Marek Vasut 

> > ---
> > Changes for v1:
> >   - reorder patches in patchset
> >   - use patch from Fabio Estevam
> > Changes for v2:
> >   - fix From field
> >   - rebase on top of u-boot-imx/next(no actual changes)
> > Changes for v3:
> >   - change versioning in changelog from per patchset to per patch
> >   - no actual changes
> > Changes for v4:
> >   - no changes
> > Changes for v5:
> >   - no changes
> >
>
> What the hell ... the patch is V9, but changelog ends with V5 ... well what
> the
> hell.
>

When I started to use in changelog versioning per-patch, I didn't change the
versioning in subjects, because I was afraid it would mess up with previous
patches, which had the same version number.
But I can repost the patchset with proper version numbers if you want.

>
> So please, if you submit a series and then update only SOME patches, you
> have to
> send only the updated patches. And the email in-reply-to should be set
> per-patch
> to it's predecesor.
>

Ok.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v9 2/4] EHCI: add callback ehci_fixup

2011-09-28 Thread Jana Rapava
2011/9/28 Marek Vasut 

> > Changes for v6:
> >   - no actual changes
> >   - fix the comment
>
> So are there any changes or not ?!
>

I only fixed the comment to look better, there were no actual changes.
Sorry, I really don't know how I could express it more clearly. I'll be glad
for any suggestions.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v9 4/4] Add USB support for Efika

2011-09-28 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
 - changed to proper patch
Changes for v3:
 - merged other USB patches from u-boot-pxa/efikasb
 - offset-based access changed to struct-based access
 - use {clrset,clr,set}bits_le32() calls
 - CodingStyle and naming cleanup
Changes for v4:
  - split into patchset
  - CodingStyle and naming cleanup
  - remove endless loops
  - silence compiler warnings
Changes for v5:
- change order of arguments in ulpi* functions
- change type of reg argument
- rename offset macro
Changes for v6:
 - rebase on top of u-boot-imx/next
 - cleanup of CodingStyle and comments
 - use macro machine_is_efikasb()
 - introduce header file efika.h
Changes for v7:
  - add proper header to efika.h
  - include efika.h into efikamx.c
  - check return values from ulpi_wait()
Changes for v8:
   - change the return value of ulpi_wait()
   - CodingStyle cleanup
   - add proper header to efikamx-usb.c
Changes for v9:
- rewrite function ulpi_wait()

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   30 +++
 board/efikamx/efikamx-usb.c |  412 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 464 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..b3532e2
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..aa0d68a
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,412 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR

[U-Boot] [PATCH v9 3/4] EHCI: adjust for mx5

2011-09-28 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v1:
  - split into patchset
Changes for v2:
- make this the third patch in series
- move all #define's from ehci-mxc.c to ehci-fsl.h
- rename structures
Changes for v3:
 - rebase on top of u-boot-imx/next
  (no actual changes)
Changes for v4:
  - no changes
  - change changelog versioning from per patchset to per patch
Changes for v5:
   - whitespace changes (no actual changes)
Changes for v6:
- no changes

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#defi

[U-Boot] [PATCH v9 2/4] EHCI: add callback ehci_fixup

2011-09-28 Thread Jana Rapava
Add callback to ehci_fixup to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 

Acked-by: Marek Vasut 
---
Changes for v1:
  - split into patchset
  - add callback ehci_fixup
Changes for v2:
- make this the second patch in series
- add comment to alias ehci_fixup
- no actual changes
Changes for v3:
 - no actual changes
 - make the comment a sentence
 - rebase patch on top of u-boot-imx/next
Changes for v4:
  - no actual changes
  - change the versioning of changelog
  from per patchset to per patch
  - fix the appearance of comment
Changes for v5:
   - no actual changes
   - reword the comment
Changes for v6:
- no actual changes
- fix the comment

 drivers/usb/host/ehci-hcd.c |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..c548276 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -536,6 +536,18 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+/*
+ * This is an alias to __ehci_fixup() unless user provides other definition
+ * of ehci_fixup function.
+ */
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +721,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v9 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
From: Fabio Estevam 

Move ehci.h and ehci-core.h to include/usb directory.

Signed-off-by: Fabio Estevam 
Cc: Remy Bohmer 
Cc: Marek Vasut 
---
Changes for v1:
- reorder patches in patchset
- use patch from Fabio Estevam
Changes for v2:
- fix From field
- rebase on top of u-boot-imx/next(no actual changes)
Changes for v3:
- change versioning in changelog from per patchset to per patch
- no actual changes
Changes for v4:
- no changes
Changes for v5:
- no changes

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core

Re: [U-Boot] [PATCH v8 4/4] Add USB support for Efika

2011-09-28 Thread Jana Rapava
2011/9/28 Marek Vasut 

> > +if (!timeout)
> > +return -1;
> > +else
> > +return tmp;
> > +}
>
> Won't 'return !timeout;' be enough?
>
> > +tmp = ulpi_wait(ehci, ULPI_RWRUN);
> +if (tmp == -1) {
> +printf("ULPI read timed out\n");
> +return 0;
> +}
> +return ulpi_read_mask(tmp);
> +}

Here in ulpi_read() I need to store and return value which was read in
ulpi_wait(). What is the proper way to do this, If ulpi_wait() should return
!timeout ?


> Also, can you change 'ulpi_bit' to 'ulpi_mask'? That seems more
> appropriate.
>
> Maybe this can be even changed to ulpi_wait(ehci, value_to_be_written,
> bit_to_be_polled), then you won't need those writel()s before every write to
> ulpi anymore.
>

Ok.


> cheers
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8 4/4] Add USB support for Efika

2011-09-28 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset
   - CodingStyle and naming cleanup
   - remove endless loops
   - silence compiler warnings
Changes for v5:
 - change order of arguments in ulpi* functions
 - change type of reg argument
 - rename offset macro
Changes for v6:
  - rebase on top of u-boot-imx/next
  - cleanup of CodingStyle and comments
  - use macro machine_is_efikasb()
  - introduce header file efika.h
Changes for v7:
   - add proper header to efika.h
   - include efika.h into efikamx.c
   - check return values from ulpi_wait()
Changes for v8:
- change the return value of ulpi_wait()
- CodingStyle cleanup
- add proper header to efikamx-usb.c

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   30 +++
 board/efikamx/efikamx-usb.c |  420 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 472 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..b3532e2
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..fc4ebfa
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,420 @@
+/*
+ * Copyright (C) 2011 Marek Vasut 
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux

[U-Boot] [PATCH v8 3/4] EHCI: adjust for mx5

2011-09-28 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v1:
   - split into patchset
Changes for v2:
 - make this the third patch in series
 - move all #define's from ehci-mxc.c to ehci-fsl.h
 - rename structures
Changes for v3:
  - rebase on top of u-boot-imx/next
   (no actual changes)
Changes for v4:
   - no changes
   - change changelog versioning from per patchset to per patch
Changes for v5:
- whitespace changes (no actual changes)

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE   

[U-Boot] [PATCH v8 2/4] EHCI: add callback ehci_fixup

2011-09-28 Thread Jana Rapava
Add callback to ehci_hcd.c to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 

Acked-by: Marek Vasut 
---
Changes for v1:
   - split into patchset
   - add callback ehci_fixup
Changes for v2:
 - make this the second patch in series
 - add comment to alias ehci_fixup
 - no actual changes
Changes for v3:
  - no actual changes
  - make the comment a sentence
  - rebase patch on top of u-boot-imx/next
Changes for v4:
   - no actual changes
   - change the versioning of changelog
   from per patchset to per patch
   - fix the appearance of comment
Changes for v5:
- no actual changes
- reword the comment

 drivers/usb/host/ehci-hcd.c |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..fb64f23 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -536,6 +536,18 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+/*
+ * This is an alias to __ehci_fixup
+ * unless user provides other definition of ehci_fixup function.
+ */
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +721,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-28 Thread Jana Rapava
From: Fabio Estevam 

Move ehci.h and ehci-core.h to include/usb directory.

Signed-off-by: Fabio Estevam 
Cc: Remy Bohmer 
Cc: Marek Vasut 
---
Changes for v1:
- reorder patches in patchset
- use patch from Fabio Estevam
Changes for v2:
- fix From field
- rebase on top of u-boot-imx/next(no actual changes)
Changes for v3:
- change versioning in changelog from per patchset to per patch
- no actual changes
Changes for v4:
- no changes

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef C

Re: [U-Boot] [PATCH v7 4/4] Add USB support for Efika

2011-09-28 Thread Jana Rapava
2011/9/28 Marek Vasut 

> > +/* get ID from ULPI immediate registers */
> > +for (reg = ULPI_ID_REGS_COUNT - 1; reg >= 0; reg--)
> > +tmp |= ulpi_read(ehci, (u32)reg) << (reg * 8);
>
> Are you ignoring my comment and picking only some of them? Is the cast here
> necessary?
>

Sorry, I try to change patches according to your requests, but sometimes I
overlook something.
Also, it looks like I forgot to add proper header to efikamx-usb.c. Should I
add it in the next version?

>
> > +/* USB 2.0 specification say 50 ms resets on root. */
>
> Where can I read about this please?
>

Universal Serial Bus Specification Revision 2.0, chapter 7.1.7.5 Reset
Signaling says: "It is required that resets from root ports have a duration
of at least 50 ms (TDRSTR)."

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5 4/4] Add USB support for Efika

2011-09-28 Thread Jana Rapava
2011/9/28 Stefano Babic 

> This two patches are already accepted and integrated into
> u-boot-imx/next and in u-boot-arm/next.
> You can take u-boot-imx/next as reference for your patchset
>
> >
> > I don't know if they should be part of this patchset,
>
> No, they don't
>

Thanks, Marek already told me.

Regards,
Jana Rapava


> Best regards,
> Stefano Babic
>
> --
> =
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: off...@denx.de
> =
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7 2/4] EHCI: add callback ehci_fixup

2011-09-28 Thread Jana Rapava
> Otherwise:
> Acked-by: Marek Vasut 
>
> (please add this line to the final revision of this patch.)
>

Thanks, should I add this line also to the first two patches of this
patchset? There weren't any change requests for the last version of them.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v7 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset
- CodingStyle and naming cleanup
- remove endless loops
- silence compiler warnings
Changes for v5:
  - change order of arguments in ulpi* functions
  - change type of reg argument
  - rename offset macro
Changes for v6:
   - rebase on top of u-boot-imx/next
   - cleanup of CodingStyle and comments
   - use macro machine_is_efikasb()
   - introduce header file efika.h
Changes for v7:
- add proper header to efika.h
- include efika.h into efikamx.c
- check return values from ulpi_wait()

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |   30 
 board/efikamx/efikamx-usb.c |  397 +++
 board/efikamx/efikamx.c |3 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 449 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..b3532e2
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 Jana Rapava 
+ *
+ * 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
+ */
+
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..06a4cdc
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,397 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6

[U-Boot] [PATCH v7 3/4] EHCI: adjust for mx5

2011-09-27 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v1:
- split into patchset
Changes for v2:
  - make this the third patch in series
  - move all #define's from ehci-mxc.c to ehci-fsl.h
  - rename structures
Changes for v3:
   - rebase on top of u-boot-imx/next
(no actual changes)
Changes for v4:
- change changelog versioning from per patchset to per patch
- no changes

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CT

[U-Boot] [PATCH v7 2/4] EHCI: add callback ehci_fixup

2011-09-27 Thread Jana Rapava
Add callback to ehci_fixup to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v1:
- split into patchset
- add callback ehci_fixup
Changes for v2:
  - make this the second patch in series
  - add comment to alias ehci_fixup
Changes for v3:
   - make the comment a sentence
   - rebase patch on top of u-boot-imx/next
Changes for v4:
- change the versioning of changelog
from per patchset to per patch
- fix the appearance of comment

 drivers/usb/host/ehci-hcd.c |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..ef0c578 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -536,6 +536,17 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+/*
+ * this function will alias to __ehci_fixup,
+ * unless function ehci_fixup is defined somewhere
+ */
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +720,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v7 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-27 Thread Jana Rapava
From: Fabio Estevam 

Move ehci.h and ehci-core.h to include/usb directory.

Signed-off-by: Fabio Estevam 
Cc: Remy Bohmer 
Cc: Marek Vasut 
---
Changes for v1:
- reorder patches in patchset
- use patch from Fabio Estevam
Changes for v2:
- fix From field
- rebase on top of u-boot-imx/next(no actual changes)
Changes for v3:
- change versioning in changelog from per patchset to per patch
- no actual changes

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef CONFIG_PCI_EHCI_DEVICE
 static struct 

Re: [U-Boot] [PATCH v6 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
2011/9/27 Marek Vasut 


> > diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
> > new file mode 100644
> > index 000..2134e75
> > --- /dev/null
> > +++ b/board/efikamx/efika.h
> > @@ -0,0 +1,8 @@
>
> Proper header is missing here, with license, author etc.
>

What should I write into copyright field, if I copied your code into this
header file?


> > +void ulpi_write(struct usb_ehci *ehci, u32 reg, u32 value)
> > +{
> > + if (!(readl(&ehci->ulpi_viewpoint) & ULPI_SS)) {
> > + writel(ULPI_WU, &ehci->ulpi_viewpoint);
> > + ulpi_wait(ehci, ULPI_WU, "wakeup");
>
> This function returns some value, but you're not checking it. It's probably
> if
> the wait timed out, right ? Why aren't you checking it ?
>

I''ll check it, but I don't know what function calling ulpi_write/read/wait
should do if call fails. Should it write error message and return, should it
write message and return error value...?

Cheers
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v6 3/4] EHCI: adjust for mx5

2011-09-27 Thread Jana Rapava
2011/9/27 Marek Vasut 

>
> > Changes for v4:
> >  - split into patchset
> > Changes for v5:
> >- make this the third patch in series
> >- move all #define's from ehci-mxc.c to ehci-fsl.h
> >- rename structures
> > Changes for v6:
> >   - rebase on top of u-boot-imx/next
> >
>
> What's the actual change in here ? Or is it just a resend? If this is a
> resend,
> please say so. Also, keep the whole changelog.
>

I talked to Fabio Estevam and he said that in changelog shouldn't be entries
with version numbers before the patch was introduced (v4 for this patch).
It looks reasonable to me, but if you would insist on keeping the whole
changelog, there is no problem.

Cheers,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v6 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
- changed to proper patch
Changes for v3:
- merged other USB patches from u-boot-pxa/efikasb
- offset-based access changed to struct-based access
- use {clrset,clr,set}bits_le32() calls
- CodingStyle and naming cleanup
Changes for v4:
 - split into patchset
 - CodingStyle and naming cleanup
 - remove endless loops
 - silence compiler warnings
Changes for v5:
   - change order of arguments in ulpi* functions
   - change type of reg argument
   - rename offset macro
Changes for v6:
- rebase on top of u-boot-imx/next
- cleanup of CodingStyle and comments
- use macro machine_is_efikasb()
- introduce header file efika.h

 board/efikamx/Makefile  |3 +
 board/efikamx/efika.h   |8 +
 board/efikamx/efikamx-usb.c |  391 +++
 board/efikamx/efikamx.c |1 +
 include/configs/efikamx.h   |   16 ++
 5 files changed, 419 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efika.h
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efika.h b/board/efikamx/efika.h
new file mode 100644
index 000..2134e75
--- /dev/null
+++ b/board/efikamx/efika.h
@@ -0,0 +1,8 @@
+/*
+ * EHCI USB
+ */
+#ifdef CONFIG_CMD_USB
+void setup_iomux_usb(void);
+#else
+static inline void setup_iomux_usb(void) { }
+#endif
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..86f7619
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,391 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX.
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA7, USB_PAD_CONFIG);
+
+   /*
+* Configure USBH1 control pads
+*/
+
+   /* USB PHY reset */
+   mxc_request_iomux(MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT1);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D27, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+   /* USB HUB reset */
+   mxc_request_iomux(MX51_PIN_GPIO1_5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_GPIO1_5, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+
+   if (machine_is_efikasb()) {
+   /*
+* Configure USBH2 pads (used on EfikaSB)
+*/
+   /* USBH2_DATA */
+   mxc_request_iomux(MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D16, USB_PAD_CONFIG

[U-Boot] [PATCH v6 3/4] EHCI: adjust for mx5

2011-09-27 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v4:
 - split into patchset
Changes for v5:
   - make this the third patch in series
   - move all #define's from ehci-mxc.c to ehci-fsl.h
   - rename structures
Changes for v6:
- rebase on top of u-boot-imx/next

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#define MX51_H2_WUE(1 << 7)
+#

[U-Boot] [PATCH v6 2/4] EHCI: add callback ehci_fixup

2011-09-27 Thread Jana Rapava
Add callback to ehci_fixup to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v4:
 - split into patchset
 - add callback ehci_fixup
Changes for v5:
   - make this the second patch in series
   - add comment to alias ehci_fixup
Changes for v6:
- make the comment a sentence
- rebase patch on top of u-boot-imx/next

 drivers/usb/host/ehci-hcd.c |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..da09f51 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -536,6 +536,17 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+/* This function will alias to __ehci_fixup,
+ * unless function ehci_fixup is defined somewhere.
+*/
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +720,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v6 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-27 Thread Jana Rapava
From: Fabio Estevam 

Move ehci.h and ehci-core.h to include/usb directory.

Signed-off-by: Fabio Estevam 
Cc: Remy Bohmer 
Cc: Marek Vasut 
---
Changes for v5:
- reorder patches in patchset
- use patch from Fabio Estevam
Changes for v6:
- fix From field

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef CONFIG_PCI_EHCI_DEVICE
 static struct pci_device_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci-ppc4xx.c b/drivers/usb/host/ehci-ppc4xx.c
index 1179919..1a1fae1 100644
--- a/drivers/usb/host/ehci-ppc4xx.c
+

Re: [U-Boot] [PATCH v5 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
> > +
> > +#ifdef   CONFIG_MACH_EFIKASB

Please update to mainline, use if (machine_is_efikasb()) { ... } .
>

To get macro machine_is_efikasb() working, I have to get into mainline these
two of your patches in u-boot-marex:

430eacfcf35b1f54b0a1ead989aefe63e2996846  EfikaMX: Add imximage config for
Efika SB

 da3e51089d2b899a8b487b40fa63a04919927351 EfikaSB: Add preliminary EfikaSB
support

I don't know if they should be part of this patchset, but I don't think so.
I would like to try to get them into mainline - with your permission of
course, but they would probably need some changes and I can't test them
because I haven't EfikaSB.
Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
2011/9/27 Marek Vasut 

>
> >  /*
> > + * EHCI USB
> > + */
> > +#ifdef   CONFIG_CMD_USB
> > +void setup_iomux_usb(void);
> > +#else
> > +static inline void setup_iomux_usb(void) { }
> > +#endif
> > +
>
> Can you introduce efika.h header and move this to the header please.
>

Should I move all #define's and #ifdef's, or only this?

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5 2/4] EHCI: add callback ehci_fixup

2011-09-27 Thread Jana Rapava
> what's the _EXACT_ change in this patch since the last revision? I see
> you're
> adding the changes for whole patchset, not for each single patch, that's
> wrong.
>
> In this changelog are only changes, which touches this single patch and
reordering all patches in this patchset is one of them. When I repost this
patch, I'll try to express this more clearly.
Thanks for your comments.

Cheers,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-27 Thread Jana Rapava
2011/9/27 Fabio Estevam 

> Jana,
>
> On Tue, Sep 27, 2011 at 8:07 AM, Fabio Estevam  wrote:
>
> This is even worse: you sent an email with my name. ferma...@gmail.com
> is your email address, not mine.
>

Now I really don't understand where it went wrong. My git send-email log
says "From: Fabio Estevam " and I left your e-mail
address in the body of patch too. If you could say me what I should do in
some other way I would be thankful, because now I really don't know.

You should not change your From field of your gitconfig.
>

I only wrote your e-mail address into the From: field, I didn't change my
gitconfig at all.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
 - changed to proper patch
Changes for v3:
 - merged other USB patches from u-boot-pxa/efikasb
 - offset-based access changed to struct-based access
 - use {clrset,clr,set}bits_le32() calls
 - CodingStyle and naming cleanup
Changes for v4:
  - split into patchset
  - CodingStyle and naming cleanup
  - remove endless loops
  - silence compiler warnings
Changes for v5:
- change order of arguments in ulpi* functions
- change type of reg argument
- rename offset macro

 board/efikamx/Makefile  |3 +
 board/efikamx/efikamx-usb.c |  391 +++
 board/efikamx/efikamx.c |   10 +
 include/configs/efikamx.h   |   16 ++
 4 files changed, 420 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..c91a08b
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,391 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA7, USB_PAD_CONFIG);
+
+   /*
+* Configure USBH1 control pads
+*/
+
+   /* USB PHY reset */
+   mxc_request_iomux(MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT1);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D27, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+   /* USB HUB reset */
+   mxc_request_iomux(MX51_PIN_GPIO1_5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_GPIO1_5, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+
+#ifdef CONFIG_MACH_EFIKASB
+   /*
+* Configure USBH2 pads (used on EfikaSB)
+*/
+   /* USBH2_DATA */
+   mxc_request_iomux(MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D16, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D17, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D18, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D18, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D19, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D19, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D20, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D20, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D21, USB_PAD_CONFIG

[U-Boot] [PATCH v5 3/4] EHCI: adjust for mx5

2011-09-27 Thread Jana Rapava
Add macros and structures needed by Efika USB support code.
Move shared offset and bits definitions into common header file.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
 - changed to proper patch
Changes for v3:
 - merged other USB patches from u-boot-pxa/efikasb
 - offset-based access changed to struct-based access
 - use {clrset,clr,set}bits_le32() calls
 - CodingStyle and naming cleanup
Changes for v4:
  - split into patchset
Changes for v5:
- reorder the patches
- move all #define's from ehci-mxc.c to ehci-fsl.h
- rename structures

 drivers/usb/host/ehci-mxc.c |   31 +
 include/usb/ehci-fsl.h  |  146 ++-
 2 files changed, 148 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fde1f0f..2c1295f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -27,31 +27,6 @@
 #include 
 #include 
 
-#define USBCTRL_OTGBASE_OFFSET 0x600
-
-#ifdef CONFIG_MX25
-#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
-#define MX25_USB_CTRL_HSTD_BIT (1<<5)
-#define MX25_USB_CTRL_USBTE_BIT(1<<4)
-#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
-#endif
-
-#ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
-
-#define MX31_H2_SIC_SHIFT  21
-#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
-#define MX31_H2_PM_BIT (1 << 16)
-#define MX31_H2_DT_BIT (1 << 5)
-
-#define MX31_H1_SIC_SHIFT  13
-#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
-#define MX31_H1_PM_BIT (1 << 8)
-#define MX31_H1_DT_BIT (1 << 4)
-#endif
-
 static int mxc_set_usbcontrol(int port, unsigned int flags)
 {
unsigned int v;
@@ -66,11 +41,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..727134f 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,106 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX25) || defined(CONFIG_MX31)
+#define USBCTRL_OTGBASE_OFFSET 0x600
+#endif
+
+#ifdef CONFIG_MX25
+#define MX25_USB_CTRL_IP_PUE_DOWN_BIT  (1<<6)
+#define MX25_USB_CTRL_HSTD_BIT (1<<5)
+#define MX25_USB_CTRL_USBTE_BIT(1<<4)
+#define MX25_USB_CTRL_OCPOL_OTG_BIT(1<<3)
+#endif
+
+#ifdef CONFIG_MX31
+#define MX31_H2_SIC_SHIFT  21
+#define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
+#define MX31_H2_PM_BIT (1 << 16)
+#define MX31_H2_DT_BIT (1 << 5)
+
+#define MX31_H1_SIC_SHIFT  13
+#define MX31_H1_SIC_MASK   (0x3 << MX31_H1_SIC_SHIFT)
+#define MX31_H1_PM_BIT (1 << 8)
+#define MX31_H1_DT_BIT (1 << 4)
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+/* offset for first USB CTRL register */
+#define MX5_CTRL_REGS_OFFSET   0x800
+#endif
+
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCL

[U-Boot] [PATCH v5 2/4] EHCI: add callback ehci_fixup

2011-09-27 Thread Jana Rapava
Add callback to ehci_fixup to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
 - changed to proper patch
Changes for v3:
 - merged other USB patches from u-boot-pxa/efikasb
 - offset-based access changed to struct-based access
 - use {clrset,clr,set}bits_le32() calls
 - CodingStyle and naming cleanup
Changes for v4:
  - split into patchset
  - add callback ehci_fixup
Changes for v5:
- reorder the patches
- add coments

 drivers/usb/host/ehci-hcd.c |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..2030a40 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -536,6 +537,17 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+/* this function will alias to __ehci_fixup,
+ * unless function ehci_fixup is defined somewhere
+*/
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,7 +721,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
+   ehci_fixup(status_reg, ®);
/* terminate the reset */
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 4/4] Add USB support for Efika

2011-09-27 Thread Jana Rapava
> Actually I think this is the problem:
>   writel(ULPI_RWRUN | (u32)reg << ULPI_ADDR_SHIFT,
> &ehci->ulpi_viewpoint);
>
> You cast the u8 * to u32, making the whole first argument of writel() an
> u32.
> Whereas in the other case, when passing u8, the first argument stays u8 and
> the
> result is truncated.
>
Thanks, but I had to change the type from u8 to u32 to silence compiler
warnings and it's solved the problem too.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 1/4] usb: Move ehci.h and ehci-core.h to include/usb directory

2011-09-27 Thread Jana Rapava
From: feste...@gmail.com (Fabio Estevam)

Move ehci.h and ehci-core.h to include/usb directory.

Cc: Remy Bohmer 
Cc: Marek Vasut 
Signed-off-by: Fabio Estevam 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset
   - move ehci.h and ehci-core.h into /include/usb/
Changes for v5:
- reorder patches in patchset
- use patch from Fabio Estevam

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-ixp4xx.c   |4 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-mxc.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci-vct.c  |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 13 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index b8f15ae..d15237b 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 /*
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..fde1f0f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -24,8 +24,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #define USBCTRL_OTGBASE_OFFSET 0x600
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host

Re: [U-Boot] [PATCH v4 4/4] Add USB support for Efika

2011-09-26 Thread Jana Rapava
> > + while (--timeout) {
> > + tmp = readl(&ehci->ulpi_viewpoint);
> > + if (!(tmp & ulpi_bit))
> > + break;
> > + WATCHDOG_RESET();
> > + }
> > + if (!timeout) {
> > + printf("ULPI %s timed out\n", operation);
> > + return 0;
> > + }
> > + return tmp;
> > +}
> > +
> > +void ulpi_write(u8 *reg, u32 value, struct usb_ehci *ehci)
>
> ulpi_write(ehci, reg, value), please fix globally and in similar functions.
>
> Also, change u8 *reg to u8 reg, why are you passing a pointer?
>

Is it really important in ulpi_read/write function to use u8 reg instead of
u8 *reg?
When I rewrite this, usb reset starts giving me ULPI operations timeout, and
I couldn't find a source of that.
The problem is in the middle of usb_new_device, but it looks like no
function calling ULPI operations is called from that function.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/4] USB: move ehci.h and ehci-core.h into /include/usb/

2011-09-26 Thread Jana Rapava
Why don´t you just resend my original patch (put my name in the From:

> field) as part of this series?
> http://comments.gmane.org/gmane.comp.boot-loaders.u-boot/109335
>

Thanks, I'll be glad to use it.

Regards,
Jana Rapava
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 4/4] Add USB support for Efika

2011-09-25 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset
   - CodingStyle and naming cleanup
   - remove endless loops
   - silence compiler warnings

 board/efikamx/Makefile  |3 +
 board/efikamx/efikamx-usb.c |  380 +++
 board/efikamx/efikamx.c |   10 +
 include/configs/efikamx.h   |   16 ++
 4 files changed, 409 insertions(+), 0 deletions(-)
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..4e5390f
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,380 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA7, USB_PAD_CONFIG);
+
+   /*
+* Configure USBH1 control pads
+*/
+
+   /* USB PHY reset */
+   mxc_request_iomux(MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT1);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D27, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+   /* USB HUB reset */
+   mxc_request_iomux(MX51_PIN_GPIO1_5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_GPIO1_5, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+
+#ifdef CONFIG_MACH_EFIKASB
+   /*
+* Configure USBH2 pads (used on EfikaSB)
+*/
+   /* USBH2_DATA */
+   mxc_request_iomux(MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D16, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D17, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D18, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D18, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D19, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D19, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D20, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D20, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D21, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D22, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D22, USB_PAD_CONFIG

[U-Boot] [PATCH v4 3/4] EHCI: adjust for mx5

2011-09-25 Thread Jana Rapava
Add into ./include/usb/ehci-fsl.h macros and structures
needed by following patch; change prefix of common MX31 USB_CTRL bits
to MXC.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset

 drivers/usb/host/ehci-mxc.c |9 +--
 include/usb/ehci-fsl.h  |  119 ++-
 2 files changed, 121 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..973bb4f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -37,9 +37,6 @@
 #endif
 
 #ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
 
 #define MX31_H2_SIC_SHIFT  21
 #define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
@@ -66,11 +63,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..b107f71 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,6 +169,79 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif
 
+#if defined(CONFIG_MX51) || defined(CONFIG_MX31)
+/* USB_CTRL register bits of interest*/
+#define MXC_OTG_SIC_SHIFT  29
+#define MXC_OTG_SIC_MASK   (0x3 << MX31_OTG_SIC_SHIFT)
+#define MXC_OTG_WUE(1 << 27)
+#define MXC_OTG_PM (1 << 24)
+#endif
+
+#ifdef CONFIG_MX51
+#define MX51_REGISTER_LAYOUT_LENGTH0x200
+
+/* Register offsets for MX51 */
+#define MX51_OTG_ID0x000
+#define MX51_UH1_ID0x200
+#define MX51_UH2_ID0x400
+#define MX51_CTRL_REGS 0x800
+
+/* USB_CTRL register bits of interest*/
+#define MX51_OTG_PM(1 << 24)
+#define MX51_H1_ULPI_IE(1 << 12)
+#define MX51_H1_WUE(1 << 11)
+#define MX51_H1_PM (1 << 8)
+
+/* PHY_CTRL_0 register bits of interest */
+#define MX51_OTG_OVERCURD  (1 << 8)
+#define MX51_EHCI_POWERPINSE   (1 << 5)
+
+/* PHY_CTRL_1 register bits of interest */
+#define MX51_SYSCLOCK_24_MHZ   (1 << 0)
+#define MX51_SYSCLOCK_MASK (~(0x << 2))
+
+/* USB_CTRL_1 register bits of interest */
+#define MX51_H1_EXTCLKE(1 << 25)
+
+/* USB Host 2 CTRL register bits of interest */
+#define MX51_H2_ULPI_IE(1 << 8)
+#define MX51_H2_WUE(1 << 7)
+#define MX51_H2_PM (1 << 4)
+
+/* PORTSCx bits of interest */
+#define MX51_ULPI_MODE_MASK(2 << 30)
+#define MX51_16BIT_UTMI(1 << 28)
+
+/* USBCMD bits of interest */
+#define MX51_ITC_IMMEDIATE_MASK(0xff << 16)
+#endif
+
+/*
+* ULPI
+*/
+#define ULPI_ID_REGS_COUNT 4
+#define ULPI_TEST_VALUE0x55
+#define ULPI_TIMEOUT   1000 /* some reasonable value */
+
+/* ULPI viewport control bits */
+#define ULPI_WU(1 << 31)
+#define ULPI_SS(1 << 27)
+#define ULPI_RWRUN (1 << 30)
+#define ULPI_RWCTRL(1 << 29)
+
+/* ULPI OTG Control bits of interest */
+#define ULPI_OTG_EXT_VBUS_IND  (1 << 7)
+#define ULPI_OTG_DM_PULLDOWN   (1 << 2)
+#define ULPI_OTG_DP_PULLDOWN   (1 << 1)
+#defineULPI_OTG_DRV_VBUS   (1 << 5)
+#define ULPI_OTG_DRV_VBUS_EXT  (1 << 6)
+#define ULPI_OTG_CHRG_VBUS (1 << 4)
+
+/* ULPI Function Control bits of interest */
+#define ULPI_FC_XCVR_SELECT(1 << 0)
+#define ULPI_FC_OPMODE_NORMAL  (0 << 3)
+#define ULPI_FC_SUSPENDM_PWRED (1 << 6)
+
 /*
  * USB Registers
  */
@@ -210,7 +283,7 @@ struct usb_ehci {
u32 txfilltuning;   /* 0x164 - Host TT Transmit
   pre-buffer packet tuning */
u8  res7[0x8];
-   u32 ulpi_viewpoint; /* 0x170 - ULPI Reister Access */
+   u32 ulpi_viewpoint; /* 

[U-Boot] [PATCH v4 2/4] EHCI: add callback ehci_fixup

2011-09-25 Thread Jana Rapava
Add callback to ehci_fixup to prepare
for solving the problem with VBUS reset on Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset
   - add callback ehci_fixup

 drivers/usb/host/ehci-hcd.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index bdadd46..8d31921 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -536,6 +537,14 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,8 +718,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
-   /* terminate the reset */
+   ehci_fixup(status_reg, ®);
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
 * A host controller must terminate the reset
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/4] USB: move ehci.h and ehci-core.h into /include/usb/

2011-09-25 Thread Jana Rapava
Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Fabio Estevam 
---
Changes for v2:
  - changed to proper patch
Changes for v3:
  - merged other USB patches from u-boot-pxa/efikasb
  - offset-based access changed to struct-based access
  - use {clrset,clr,set}bits_le32() calls
  - CodingStyle and naming cleanup
Changes for v4:
   - split into patchset
   - move ehci.h and ehci-core.h into /include/usb/

 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 10 files changed, 243 insertions(+), 243 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..bdadd46 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef CONFIG_PCI_EHCI_DEVICE
 static struct pci_device_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci-ppc4xx.c b/drivers/usb/host/ehci-ppc4xx.c
index 1179919..1a1fae1 100644
--- a/drivers/usb/host/ehci-ppc4xx.c
+++ b/drivers/usb/host/ehci-ppc4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
deleted file mode 100644
index 3d0ad0c..000
--- a/drivers/usb/host/ehci.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Michael Trimarchi 
- * All rights reserved.
- *
- * This program is free software; you 

[U-Boot] [PATCH v4 5/5] USB: move ehci.h and ehci-core.h into /include/usb/

2011-09-25 Thread Jana Rapava
USB: move ehci.h and ehci-core.h into /include/usb/

Signed-off-by: Jana Rapava 
Cc: Remy Bohmer 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset
- move ehci.h and ehci-core.h into /include/usb/

 board/efikamx/efikamx-usb.c  |4 +-
 drivers/usb/host/ehci-core.h |   29 --
 drivers/usb/host/ehci-fsl.c  |4 +-
 drivers/usb/host/ehci-hcd.c  |2 +-
 drivers/usb/host/ehci-kirkwood.c |4 +-
 drivers/usb/host/ehci-mpc512x.c  |4 +-
 drivers/usb/host/ehci-pci.c  |4 +-
 drivers/usb/host/ehci-ppc4xx.c   |4 +-
 drivers/usb/host/ehci.h  |  203 --
 include/usb/ehci-core.h  |   29 ++
 include/usb/ehci.h   |  203 ++
 11 files changed, 245 insertions(+), 245 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-core.h
 delete mode 100644 drivers/usb/host/ehci.h
 create mode 100644 include/usb/ehci-core.h
 create mode 100644 include/usb/ehci.h

diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
index 559470f..4e5390f 100644
--- a/board/efikamx/efikamx-usb.c
+++ b/board/efikamx/efikamx-usb.c
@@ -9,8 +9,8 @@
 #include 
 #include 
 
-#include "../../drivers/usb/host/ehci.h"
-#include "../../drivers/usb/host/ehci-core.h"
+#include 
+#include 
 
 /*
  * Configure the USB H1 and USB H2 IOMUX
diff --git a/drivers/usb/host/ehci-core.h b/drivers/usb/host/ehci-core.h
deleted file mode 100644
index 39e5c5e..000
--- a/drivers/usb/host/ehci-core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * Copyright (c) 2007-2008, Juniper Networks, Inc.
- * Copyright (c) 2008, Excito Elektronik i Skåne AB
- * All rights reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef USB_EHCI_CORE_H
-#define USB_EHCI_CORE_H
-
-extern int rootdev;
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-
-#endif
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6e0043a..19b97ee 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 36f21f9..68d157b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -32,7 +32,7 @@
 extern unsigned char new[];
 #endif
 
-#include "ehci.h"
+#include 
 
 int rootdev;
 struct ehci_hccr *hccr;/* R/O registers, not need for volatile */
diff --git a/drivers/usb/host/ehci-kirkwood.c b/drivers/usb/host/ehci-kirkwood.c
index 5570fc6..ab75acd 100644
--- a/drivers/usb/host/ehci-kirkwood.c
+++ b/drivers/usb/host/ehci-kirkwood.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 #include 
 
 #define rdl(off)   readl(KW_USB20_BASE + (off))
diff --git a/drivers/usb/host/ehci-mpc512x.c b/drivers/usb/host/ehci-mpc512x.c
index d360108..8d2c93b 100644
--- a/drivers/usb/host/ehci-mpc512x.c
+++ b/drivers/usb/host/ehci-mpc512x.c
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 static void fsl_setup_phy(volatile struct ehci_hcor *);
 static void fsl_platform_set_host_mode(volatile struct usb_ehci *ehci);
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 020ab11..e1f84d9 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "ehci.h"
-#include "ehci-core.h"
+#include 
+#include 
 
 #ifdef CONFIG_PCI_EHCI_DEVICE
 static struct pci_device_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci-ppc4xx.c b/drivers/usb/host/ehci-ppc4xx.c
index 1179919..1a1fae1 100644
--- a/drivers/usb/host/ehci-ppc4xx.c
+++ b/drivers/usb/host/ehci-ppc4xx.c
@@ -22,8 +22,8 @@
 #include 
 #include 
 
-#include "

[U-Boot] [PATCH v4 4/5] USB: Add usb_event_poll() to get keyboards working with EHCI

2011-09-25 Thread Jana Rapava
From: Marek Vasut 

USB: Add usb_event_poll() to get keyboards working with
 EHCI

Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset
- added usb_event_poll()

 drivers/usb/host/ehci-hcd.c |   33 -
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index f420279..36f21f9 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -27,6 +27,10 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_USB_KEYBOARD
+#include 
+extern unsigned char new[];
+#endif
 
 #include "ehci.h"
 
@@ -903,5 +907,32 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, 
void *buffer,
 
debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
  dev, pipe, buffer, length, interval);
-   return -1;
+   return ehci_submit_async(dev, pipe, buffer, length, NULL);
+}
+
+#ifdef CONFIG_SYS_USB_EVENT_POLL
+/*
+ * This function polls for USB keyboard data.
+ */
+void usb_event_poll()
+{
+   struct stdio_dev *dev;
+   struct usb_device *usb_kbd_dev;
+   struct usb_interface *iface;
+   struct usb_endpoint_descriptor *ep;
+   int pipe;
+   int maxp;
+
+   /* Get the pointer to USB Keyboard device pointer */
+   dev = stdio_get_by_name("usbkbd");
+   usb_kbd_dev = (struct usb_device *)dev->priv;
+   iface = &usb_kbd_dev->config.if_desc[0];
+   ep = &iface->ep_desc[0];
+   pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress);
+
+   /* Submit a interrupt transfer request */
+   maxp = usb_maxpacket(usb_kbd_dev, pipe);
+   usb_submit_int_msg(usb_kbd_dev, pipe, &new[0],
+   maxp > 8 ? 8 : maxp, ep->bInterval);
 }
+#endif /* CONFIG_SYS_USB_EVENT_POLL */
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 3/5] /drivers/usb/host/ehci-mxc.c: naming cleanup

2011-09-25 Thread Jana Rapava
This commit changes MX31 prefix in common USB_CTRL bits to MXC.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Stefano Babic 
Cc: Remy Bohmer 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset

 drivers/usb/host/ehci-mxc.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index a0cfbb7..973bb4f 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -37,9 +37,6 @@
 #endif
 
 #ifdef CONFIG_MX31
-#define MX31_OTG_SIC_SHIFT 29
-#define MX31_OTG_SIC_MASK  (0x3 << MX31_OTG_SIC_SHIFT)
-#define MX31_OTG_PM_BIT(1 << 24)
 
 #define MX31_H2_SIC_SHIFT  21
 #define MX31_H2_SIC_MASK   (0x3 << MX31_H2_SIC_SHIFT)
@@ -66,11 +63,11 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)
 
switch (port) {
case 0: /* OTG port */
-   v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
+   v &= ~(MXC_OTG_SIC_MASK | MXC_OTG_PM_BIT);
v |= (flags & MXC_EHCI_INTERFACE_MASK)
-   << MX31_OTG_SIC_SHIFT;
+   << MXC_OTG_SIC_SHIFT;
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
-   v |= MX31_OTG_PM_BIT;
+   v |= MXC_OTG_PM_BIT;
 
break;
case 1: /* H1 port */
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 2/5] Add USB support for Efika

2011-09-25 Thread Jana Rapava
This commit adds USB support for EfikaMX and EfikaSB.

Signed-off-by: Jana Rapava 
Signed-off-by: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset
- CodingStyle and naming cleanup
- remove endless loops
- silence compiler warnings

 board/efikamx/Makefile  |3 +
 board/efikamx/efikamx-usb.c |  380 +++
 board/efikamx/efikamx.c |   10 +
 include/configs/efikamx.h   |   16 ++
 include/usb/ehci-fsl.h  |  119 +-
 5 files changed, 527 insertions(+), 1 deletions(-)
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..559470f
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,380 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../drivers/usb/host/ehci.h"
+#include "../../drivers/usb/host/ehci-core.h"
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA7, USB_PAD_CONFIG);
+
+   /*
+* Configure USBH1 control pads
+*/
+
+   /* USB PHY reset */
+   mxc_request_iomux(MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT1);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D27, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+   /* USB HUB reset */
+   mxc_request_iomux(MX51_PIN_GPIO1_5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_GPIO1_5, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+
+#ifdef CONFIG_MACH_EFIKASB
+   /*
+* Configure USBH2 pads (used on EfikaSB)
+*/
+   /* USBH2_DATA */
+   mxc_request_iomux(MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D16, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D17, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D18, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D18, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D19, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D19, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D20, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D20, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM

[U-Boot] [PATCH v4 1/5] EHCI: add callback ehci_fixup

2011-09-25 Thread Jana Rapava
EHCI: add callback ehci_fixup to solve VBUS reset
issue for Efika.

Signed-off-by: Jana Rapava 
Cc: Marek Vasut 
Cc: Remy Bohmer 
Cc: Stefano Babic 
---
Changes for v2:
   - changed to proper patch
Changes for v3:
   - merged other USB patches from u-boot-pxa/efikasb
   - offset-based access changed to struct-based access
   - use {clrset,clr,set}bits_le32() calls
   - CodingStyle and naming cleanup
Changes for v4:
- split into patchset
- add callback ehci_fixup

 drivers/usb/host/ehci-hcd.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2197119..f420279 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ehci.h"
 
@@ -536,6 +537,14 @@ static inline int min3(int a, int b, int c)
return a;
 }
 
+inline void __ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+{
+   wait_ms(50);
+}
+
+void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
+__attribute__((weak, alias("__ehci_fixup")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -709,8 +718,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 * usb 2.0 specification say 50 ms resets on
 * root
 */
-   wait_ms(50);
-   /* terminate the reset */
+   ehci_fixup(status_reg, ®);
ehci_writel(status_reg, reg & ~EHCI_PS_PR);
/*
 * A host controller must terminate the reset
-- 
1.7.6.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] Add USB support for Efika

2011-09-17 Thread Jana Rapava
From: Marek Vasut 

This commit adds USB support for EfikaMX and EfikaSB. 

Signed-off-by: Marek Vasut 
Signed-off-by: Jana Rapava 
---
Changes for v2:
- changed to proper patch
Changes for v3:
- merged other USB patches from u-boot-pxa/efikasb
- offset-based access changed to struct-based access
- use {clrset,clr,set}bits_le32() calls
- CodingStyle and naming cleanup

 board/efikamx/Makefile  |3 +
 board/efikamx/efikamx-usb.c |  349 +++
 board/efikamx/efikamx.c |   10 ++
 drivers/usb/host/ehci-hcd.c |   19 +++
 drivers/usb/host/ehci-mxc.c |9 +-
 include/configs/efikamx.h   |   35 -
 include/usb/ehci-fsl.h  |  112 ++-
 7 files changed, 524 insertions(+), 13 deletions(-)
 create mode 100644 board/efikamx/efikamx-usb.c

diff --git a/board/efikamx/Makefile b/board/efikamx/Makefile
index ee4a16e..860e4d2 100644
--- a/board/efikamx/Makefile
+++ b/board/efikamx/Makefile
@@ -28,6 +28,9 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).o
 
 COBJS  := efikamx.o
+ifdef  CONFIG_CMD_USB
+COBJS  += efikamx-usb.o
+endif
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
new file mode 100644
index 000..19227d4
--- /dev/null
+++ b/board/efikamx/efikamx-usb.c
@@ -0,0 +1,349 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../drivers/usb/host/ehci.h"
+#include "../../drivers/usb/host/ehci-core.h"
+
+/*
+ * Configure the USB H1 and USB H2 IOMUX
+ */
+#define USB_PAD_CONFIG (PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST | \
+   PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | \
+   PAD_CTL_HYS_ENABLE | PAD_CTL_PUE_PULL)
+void setup_iomux_usb(void)
+{
+   /*
+* Configure USBH1 pads
+*/
+   mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_CLK, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_CLK, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DIR, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DIR, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_NXT, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_NXT, USB_PAD_CONFIG);
+
+   mxc_request_iomux(MX51_PIN_USBH1_DATA0, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA0, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA1, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA1, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA2, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA2, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA3, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA3, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA4, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA4, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA5, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA6, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA6, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_USBH1_DATA7, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_USBH1_DATA7, USB_PAD_CONFIG);
+
+   /*
+* Configure USBH1 control pads
+*/
+
+   /* USB PHY reset */
+   mxc_request_iomux(MX51_PIN_EIM_D27, IOMUX_CONFIG_ALT1);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D27, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+   /* USB HUB reset */
+   mxc_request_iomux(MX51_PIN_GPIO1_5, IOMUX_CONFIG_ALT0);
+   mxc_iomux_set_pad(MX51_PIN_GPIO1_5, PAD_CTL_PKE_ENABLE |
+   PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH);
+
+
+#ifdef CONFIG_MACH_EFIKASB
+   /*
+* Configure USBH2 pads (used on EfikaSB)
+*/
+   /* USBH2_DATA */
+   mxc_request_iomux(MX51_PIN_EIM_D16, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D16, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D17, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D18, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D18, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D19, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D19, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D20, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D20, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT2);
+   mxc_iomux_set_pad(MX51_PIN_EIM_D21, USB_PAD_CONFIG);
+   mxc_request_iomux(MX51_PIN_EIM_D22, IOMUX_CONFIG_ALT2);
+

[U-Boot] [PATCH 1/2 v2] USB cleanup for EfikaMX

2011-09-12 Thread Jana Rapava
/board/efikamx/efikamx-usb.c: cleanup

Signed-off-by: Jana Rapava 
---
 board/efikamx/efikamx-usb.c |  111 +++
 include/usb/ehci-fsl.h  |   49 +++
 2 files changed, 108 insertions(+), 52 deletions(-)

diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c
index 70d0daa..a94a64f 100644
--- a/board/efikamx/efikamx-usb.c
+++ b/board/efikamx/efikamx-usb.c
@@ -161,57 +161,70 @@ void control_regs_setup(void)
 {
uint32_t tmp;
 
-   tmp = readl(OTG_BASE_ADDR + 0x800);
-   tmp &= ~((1 << 27) | (1 << 24) | (1 << 12) | (1 << 11));
-   tmp |= 1 << 8;
-   writel(tmp, OTG_BASE_ADDR + 0x800);
-
-   tmp = readl(OTG_BASE_ADDR + 0x808);
-   tmp &= ~(1 << 8);
-   tmp |= 1 << 5;
-   writel(tmp, OTG_BASE_ADDR + 0x808);
-
-   tmp = readl(OTG_BASE_ADDR + 0x80c);
-   tmp &= ~0x3;
-   tmp |= 0x1;
-   writel(tmp, OTG_BASE_ADDR + 0x80c);
-
-   tmp = readl(OTG_BASE_ADDR + 0x810);
-   tmp |= 1 << 25;
-   writel(tmp, OTG_BASE_ADDR + 0x810);
-
-   tmp = readl(OTG_BASE_ADDR + 0x814);
-   tmp &= ~((1 << 8) | (1 << 7));
-   tmp |= 1 << 4;
-   writel(tmp, OTG_BASE_ADDR + 0x814);
+   tmp = readl(OTG_BASE_ADDR + MX51_USB_CTRL_OFFSET);
+   tmp &= ~(MX51_OTG_WUE_BIT | MX51_OTG_PM_BIT | MX51_H1_ULPI_IE_BIT | 
MX51_H1_WUE_BIT);
+   tmp |= MX51_H1_PM_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_USB_CTRL_OFFSET);
+
+   tmp = readl(OTG_BASE_ADDR + MX51_PHY_CTRL0_OFFSET);
+   tmp &= ~MX51_OTG_OVERCURD_BIT;
+   tmp |= MX51_EHCI_POWERPINSE_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_PHY_CTRL0_OFFSET);
+
+   tmp = readl(OTG_BASE_ADDR + MX51_PHY_CTRL1_OFFSET);
+   tmp &= MX51_SYSCLOCK_MASK;
+   tmp |= MX51_SYSCLOCK_24_MHZ_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_PHY_CTRL1_OFFSET);
+
+   tmp = readl(OTG_BASE_ADDR + MX51_USB_CTRL1_OFFSET);
+   tmp |= MX51_H1_EXTCLKE_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_USB_CTRL1_OFFSET);
+
+   tmp = readl(OTG_BASE_ADDR + MX51_UH2_CTRL_OFFSET);
+   tmp &= ~(MX51_H2_ULPI_IE_BIT | MX51_H2_WUE_BIT);
+   tmp |= MX51_H2_PM_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_UH2_CTRL_OFFSET);
 
udelay(1);
 }
 
-#defineULPI_VIEWPORT(base) (base + 0x170)
+
+#define ULPI_VIEWPORT(base)(base + 0x170)
+
+/* ULPI viewport control bits */
+#define MX51_ULPI_WU_BIT   (1 << 31)
+#define MX51_ULPI_SS_BIT   (1 << 27)
+#define MX51_ULPI_RWRUN(1 << 30)
+#define MX51_ULPI_RWCTRL   (1 << 29)
+
+#define shift_to_ulpiaddr(reg) (reg << 16)
+#define ulpi_write_mask(value) (value & 0xff)
+#define ulpi_read_mask(value)  ((value >> 8) & 0xff)
+
 
 void ulpi_write(u32 base, u32 reg, u32 value)
 {
-   if (!(readl(ULPI_VIEWPORT(base)) & (1 << 27))) {
-   writel(1 << 31, ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 31));
+   if (!(readl(ULPI_VIEWPORT(base)) & MX51_ULPI_SS_BIT)) {
+   writel(MX51_ULPI_WU_BIT, ULPI_VIEWPORT(base));
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_WU_BIT);
}
-   writel((1 << 30) | (1 << 29) | (reg << 16) | (value & 0xff), 
ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 30));
+   writel(MX51_ULPI_RWRUN | MX51_ULPI_RWCTRL | shift_to_ulpiaddr(reg) | 
ulpi_write_mask(value), ULPI_VIEWPORT(base));
+
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_RWRUN);
 }
 
 u32 ulpi_read(u32 base, u32 reg)
 {
u32 tmp;
-   if (!(readl(ULPI_VIEWPORT(base)) & (1 << 27))) {
-   writel(1 << 31, ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 31));
+   if (!(readl(ULPI_VIEWPORT(base)) & MX51_ULPI_SS_BIT)) {
+   writel(MX51_ULPI_WU_BIT, ULPI_VIEWPORT(base));
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_WU_BIT);
}
-   writel((1 << 30) | (reg << 16), ULPI_VIEWPORT(base));
+   writel(MX51_ULPI_RWRUN | shift_to_ulpiaddr(reg), ULPI_VIEWPORT(base));
do {
tmp = readl(ULPI_VIEWPORT(base));
-   } while (tmp & (1 << 30));
-   return (tmp >> 8) & 0xff;
+   } while (tmp & MX51_ULPI_RWRUN);
+   return ulpi_read_mask(tmp);
 }
 
 #defineULPI_CTL_WRITE_OFF  0x00
@@ -229,8 +242,9 @@ void ehciX_init(u32 base)
int reg, i;
 
/* ULPI INIT */
-   for (reg = 3; reg >=0; reg--)
+   for (reg = MX51_USB_HOST_COUNT-1; reg >= 0; reg--)
tmp |= ulpi_read(base, reg) << (reg * 8);
+   /* split ID into first and second half */
printf("Found ULPI TX, ID 

[U-Boot] some USB cleanup on EfikaMX

2011-09-08 Thread Jana Rapava
--- a/board/efikamx/efikamx-usb.c
+++ b/board/efikamx/efikamx-usb.c
@@ -154,6 +154,7 @@ void efika_usb_phy_reset(void)
gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_EIM_D27), 1);
 }

+
 /*
  * Configure control registers of the USB controller
  */
@@ -161,56 +162,56 @@ void control_regs_setup(void)
 {
uint32_t tmp;

-   tmp = readl(OTG_BASE_ADDR + 0x800);
-   tmp &= ~((1 << 27) | (1 << 24) | (1 << 12) | (1 << 11));
-   tmp |= 1 << 8;
-   writel(tmp, OTG_BASE_ADDR + 0x800);
+   tmp = readl(OTG_BASE_ADDR + MX51_USB_CTRL_OFFSET);
+   tmp &= ~(MX51_OTG_WUE_BIT | MX51_OTG_PM_BIT | MX51_H1_ULPI_IE_BIT |
MX51_H1_WUE_BIT);
+   tmp |= MX51_H1_PM_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_USB_CTRL_OFFSET);

-   tmp = readl(OTG_BASE_ADDR + 0x808);
-   tmp &= ~(1 << 8);
-   tmp |= 1 << 5;
-   writel(tmp, OTG_BASE_ADDR + 0x808);
+   tmp = readl(OTG_BASE_ADDR + MX51_PHY_CTRL0_OFFSET);
+   tmp &= ~MX51_OTG_OVERCURD_BIT;
+   tmp |= MX51_EHCI_POWERPINSE_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_PHY_CTRL0_OFFSET);

-   tmp = readl(OTG_BASE_ADDR + 0x80c);
-   tmp &= ~0x3;
-   tmp |= 0x1;
-   writel(tmp, OTG_BASE_ADDR + 0x80c);
+   tmp = readl(OTG_BASE_ADDR + MX51_PHY_CTRL1_OFFSET);
+   tmp &= ~0x3; /* make sure bits 0 and 1 are set to zero */
+   tmp |= MX51_SYSCLOCK_24_MHZ_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_PHY_CTRL1_OFFSET);

-   tmp = readl(OTG_BASE_ADDR + 0x810);
-   tmp |= 1 << 25;
-   writel(tmp, OTG_BASE_ADDR + 0x810);
+   tmp = readl(OTG_BASE_ADDR + MX51_USB_CTRL1_OFFSET);
+   tmp |= MX51_H1_EXTCLKE_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_USB_CTRL1_OFFSET);

-   tmp = readl(OTG_BASE_ADDR + 0x814);
-   tmp &= ~((1 << 8) | (1 << 7));
-   tmp |= 1 << 4;
-   writel(tmp, OTG_BASE_ADDR + 0x814);
+   tmp = readl(OTG_BASE_ADDR + MX51_UH2_CTRL_OFFSET);
+   tmp &= ~(MX51_H2_ULPI_IE_BIT | MX51_H2_WUE_BIT);
+   //Host 2 VBUS enable controlled by Host 2 controller
+   tmp |= MX51_H2_PM_BIT;
+   writel(tmp, OTG_BASE_ADDR + MX51_UH2_CTRL_OFFSET);

udelay(1);
 }

-#defineULPI_VIEWPORT(base) (base + 0x170)

 void ulpi_write(u32 base, u32 reg, u32 value)
 {
-   if (!(readl(ULPI_VIEWPORT(base)) & (1 << 27))) {
-   writel(1 << 31, ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 31));
+   if (!(readl(ULPI_VIEWPORT(base)) & MX51_ULPI_SS_BIT)) {
+   writel(MX51_ULPI_WU_BIT, ULPI_VIEWPORT(base));
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_WU_BIT);
}
-   writel((1 << 30) | (1 << 29) | (reg << 16) | (value & 0xff),
ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 30));
+   writel(MX51_ULPI_RWRUN | MX51_ULPI_RWCTRL | (reg << 16) | (value &
0xff), ULPI_VIEWPORT(base));
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_RWRUN);
 }

 u32 ulpi_read(u32 base, u32 reg)
 {
u32 tmp;
-   if (!(readl(ULPI_VIEWPORT(base)) & (1 << 27))) {
-   writel(1 << 31, ULPI_VIEWPORT(base));
-   while (readl(ULPI_VIEWPORT(base)) & (1 << 31));
+   if (!(readl(ULPI_VIEWPORT(base)) & MX51_ULPI_SS_BIT)) {
+   writel(MX51_ULPI_WU_BIT, ULPI_VIEWPORT(base));
+   while (readl(ULPI_VIEWPORT(base)) & MX51_ULPI_WU_BIT);
}
-   writel((1 << 30) | (reg << 16), ULPI_VIEWPORT(base));
+   writel(MX51_ULPI_RWRUN | (reg << 16), ULPI_VIEWPORT(base));
do {
tmp = readl(ULPI_VIEWPORT(base));
-   } while (tmp & (1 << 30));
+   } while (tmp & MX51_ULPI_RWRUN);
return (tmp >> 8) & 0xff;
 }

diff --git a/include/usb/ehci-fsl.h b/include/usb/ehci-fsl.h
index 67600ed..3af7928 100644
--- a/include/usb/ehci-fsl.h
+++ b/include/usb/ehci-fsl.h
@@ -169,9 +169,46 @@
 #define CONFIG_SYS_FSL_USB_ADDR CONFIG_SYS_MPC512x_USB_ADDR
 #endif

+/* Register offsets for MX51 */
+#define MX51_USB_CTRL_OFFSET   0x800
+#define MX51_PHY_CTRL0_OFFSET  0x808
+#define MX51_PHY_CTRL1_OFFSET  0x80c
+#define MX51_USB_CTRL1_OFFSET  0x810
+#define MX51_UH2_CTRL_OFFSET   0x814
+
+/* Some USB_CTRL register bits*/
+#define MX51_OTG_WUE_BIT   (1 << 27)
+#define MX51_OTG_PM_BIT(1 << 24)
+#define MX51_H1_ULPI_IE_BIT(1 << 12)
+#define MX51_H1_WUE_BIT(1 << 11)
+#define MX51_H1_PM_BIT (1 << 8)
+
+/* Some PHY_CTRL_0 register bits */
+#define MX51_OTG_OVERCURD_BIT  (1 << 8)
+#define MX51_EHCI_POWERPINSE_BIT   (1 << 5)
+
+/* Some PHY_CTRL_1 register bits */
+#define MX51_SYSCLOCK_24_MHZ_BIT   (1 << 0)
+
+/* Some USB_CTRL_1 register bits*/
+#define MX51_H1_EXTCLKE_BIT(1 << 25)
+
+/* Some USB Host 2 CTRL register bits*/
+#define MX51_H2_ULPI_IE_BIT(1 << 8)
+#define MX51_H2_WUE_BIT(1 << 7)
+#define MX51_H2_PM_BIT (1 << 4)
+
+#defineULPI_VIEWPORT(base) (base + 0x170)
+/* ULPI viewport control bits */
+#define