Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Improved USB EHCI support OMAP3 variants.



details:   https://anonhg.NetBSD.org/src/rev/cfdbc5118584
branches:  trunk
changeset: 783236:cfdbc5118584
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Dec 12 00:33:45 2012 +0000

description:
Improved USB EHCI support OMAP3 variants.
>From jmcneill.

diffstat:

 sys/arch/arm/omap/files.omap2           |    6 +-
 sys/arch/arm/omap/omap2_gpio.c          |   64 ++-
 sys/arch/arm/omap/omap2_gpio.h          |   44 +
 sys/arch/arm/omap/omap2_reg.h           |    4 +-
 sys/arch/arm/omap/omap3_ehci.c          |  764 +++++++++++++++++++++++++------
 sys/arch/arm/omap/omap3_uhhreg.h        |   78 +++
 sys/arch/arm/omap/omap3_usbtllreg.h     |  166 ++++++
 sys/arch/evbarm/beagle/beagle_machdep.c |   22 +-
 8 files changed, 971 insertions(+), 177 deletions(-)

diffs (truncated from 1336 to 300 lines):

diff -r b907d2b78e6d -r cfdbc5118584 sys/arch/arm/omap/files.omap2
--- a/sys/arch/arm/omap/files.omap2     Wed Dec 12 00:29:17 2012 +0000
+++ b/sys/arch/arm/omap/files.omap2     Wed Dec 12 00:33:45 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.omap2,v 1.17 2012/12/11 19:21:05 riastradh Exp $
+#      $NetBSD: files.omap2,v 1.18 2012/12/12 00:33:45 matt Exp $
 #
 # Configuration info for Texas Instruments OMAP2/OMAP3 CPU support
 # Based on xscale/files.pxa2x0
@@ -112,8 +112,8 @@
 attach ohci at obio with obioohci
 file   arch/arm/omap/obio_ohci.c               obioohci
 
-attach ehci at obio with obioehci
-file   arch/arm/omap/omap3_ehci.c              obioehci
+attach ehci at obio with omap3_ehci
+file   arch/arm/omap/omap3_ehci.c              omap3_ehci
 
 device omapfb: rasops16, rasops8, wsemuldisplaydev, vcons
 attach omapfb at obio
diff -r b907d2b78e6d -r cfdbc5118584 sys/arch/arm/omap/omap2_gpio.c
--- a/sys/arch/arm/omap/omap2_gpio.c    Wed Dec 12 00:29:17 2012 +0000
+++ b/sys/arch/arm/omap/omap2_gpio.c    Wed Dec 12 00:33:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap2_gpio.c,v 1.13 2012/12/11 01:54:42 khorben Exp $  */
+/*     $NetBSD: omap2_gpio.c,v 1.14 2012/12/12 00:33:45 matt Exp $     */
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_gpio.c,v 1.13 2012/12/11 01:54:42 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_gpio.c,v 1.14 2012/12/12 00:33:45 matt Exp $");
 
 #define _INTR_PRIVATE
 
@@ -52,6 +52,7 @@
 
 #include <arm/omap/omap2_reg.h>
 #include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_gpio.h>
 #include <arm/pic/picvar.h>
 
 #if NGPIO > 0
@@ -277,7 +278,7 @@
 }
 
 static void
-gpio_defer(device_t self)
+gpio_attach1(device_t self)
 {
        struct gpio_softc * const gpio = device_private(self);
        struct gpio_chipset_tag * const gp = &gpio->gpio_chipset;
@@ -430,6 +431,61 @@
        }
        aprint_normal("\n");
 #if NGPIO > 0
-       config_interrupts(self, gpio_defer);
+#if 0
+       config_interrupts(self, gpio_attach1);
+#else
+       gpio_attach1(self);
+#endif
 #endif
 }
+
+#if NGPIO > 0
+
+extern struct cfdriver omapgpio_cd;
+
+#define        GPIO_MODULE(pin)        ((pin) / 32)
+#define GPIO_PIN(pin)          ((pin) % 32)
+
+u_int
+omap2_gpio_read(u_int gpio)
+{
+       struct gpio_softc *sc;
+
+       sc = device_lookup_private(&omapgpio_cd, GPIO_MODULE(gpio));
+       if (sc == NULL)
+               panic("omap2gpio: GPIO Module for pin %d not configured.", gpio);
+
+       return omap2gpio_pin_read(sc, GPIO_PIN(gpio));
+}
+
+void
+omap2_gpio_write(u_int gpio, u_int value)
+{
+       struct gpio_softc *sc;
+
+       sc = device_lookup_private(&omapgpio_cd, GPIO_MODULE(gpio));
+       if (sc == NULL)
+               panic("omap2gpio: GPIO Module for pin %d not configured.", gpio);
+
+       omap2gpio_pin_write(sc, GPIO_PIN(gpio), value);
+}
+
+void
+omap2_gpio_ctl(u_int gpio, int flags)
+{
+       struct gpio_softc *sc;
+
+       sc = device_lookup_private(&omapgpio_cd, GPIO_MODULE(gpio));
+       if (sc == NULL)
+               panic("omap2gpio: GPIO Module for pin %d not configured.", gpio);
+
+       omap2gpio_pin_ctl(sc, GPIO_PIN(gpio), flags);
+}
+
+bool
+omap2_gpio_has_pin(u_int gpio)
+{
+       return device_lookup_private(&omapgpio_cd, GPIO_MODULE(gpio)) != NULL;
+}
+
+#endif
diff -r b907d2b78e6d -r cfdbc5118584 sys/arch/arm/omap/omap2_gpio.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/omap/omap2_gpio.h    Wed Dec 12 00:33:45 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ARM_OMAP_OMAP2_GPIO_H_
+#define _ARM_OMAP_OMAP2_GPIO_H_
+
+extern bool omap2_gpio_has_pin(u_int);
+extern u_int omap2_gpio_read(u_int);
+extern void omap2_gpio_write(u_int, u_int);
+extern void omap2_gpio_ctl(u_int, int);
+
+#endif /* _ARM_OMAP_OMAP2_GPIO_H_ */
diff -r b907d2b78e6d -r cfdbc5118584 sys/arch/arm/omap/omap2_reg.h
--- a/sys/arch/arm/omap/omap2_reg.h     Wed Dec 12 00:29:17 2012 +0000
+++ b/sys/arch/arm/omap/omap2_reg.h     Wed Dec 12 00:33:45 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_reg.h,v 1.13 2012/12/11 19:24:38 riastradh Exp $ */
+/* $NetBSD: omap2_reg.h,v 1.14 2012/12/12 00:33:45 matt Exp $ */
 
 /*
  * Copyright (c) 2007 Microsoft
@@ -32,6 +32,8 @@
 #ifndef _ARM_OMAP_OMAP2_REG_H_
 #define _ARM_OMAP_OMAP2_REG_H_
 
+#include "opt_omap.h"
+
 /*
  * Header for misc. omap2/3/4 registers
  */
diff -r b907d2b78e6d -r cfdbc5118584 sys/arch/arm/omap/omap3_ehci.c
--- a/sys/arch/arm/omap/omap3_ehci.c    Wed Dec 12 00:29:17 2012 +0000
+++ b/sys/arch/arm/omap/omap3_ehci.c    Wed Dec 12 00:33:45 2012 +0000
@@ -1,197 +1,420 @@
-/*     $Id: omap3_ehci.c,v 1.4 2012/10/27 17:17:40 chs Exp $   */
+/* $NetBSD: omap3_ehci.c,v 1.5 2012/12/12 00:33:45 matt Exp $ */
 
-/* adapted from: */
-/*     $NetBSD: omap3_ehci.c,v 1.4 2012/10/27 17:17:40 chs Exp $       */
-/*     $OpenBSD: pxa2x0_ehci.c,v 1.19 2005/04/08 02:32:54 dlg Exp $ */
-
-/*
- * Copyright (c) 2005 David Gwynne <dlg%openbsd.org@localhost>
+/*-
+ * Copyright (c) 2010-2012 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
  *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
-#include "opt_omap.h"
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: omap3_ehci.c,v 1.5 2012/12/12 00:33:45 matt Exp $");
 
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_ehci.c,v 1.4 2012/10/27 17:17:40 chs Exp $");
+#include "locators.h"
+
+#include "opt_omap.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/intr.h>
+#include <sys/device.h>
 #include <sys/bus.h>
-#include <sys/device.h>
-#include <sys/kernel.h>
+#include <sys/gpio.h>
+
+#include <machine/intr.h>
+
+#include <dev/pci/pcidevs.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
 #include <dev/usb/usbdivar.h>
 #include <dev/usb/usb_mem.h>
-
 #include <dev/usb/ehcireg.h>
 #include <dev/usb/ehcivar.h>
 
-#include <arm/omap/omap2_reg.h>
-#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_gpio.h>
 #include <arm/omap/omap2_obioreg.h>
+#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_reg.h>
+#include <arm/omap/omap3_usbtllreg.h>
+#include <arm/omap/omap3_uhhreg.h>
 
-#include "locators.h"
+/* CORE_CM */
+#define        CORE_CM_BASE            (OMAP2_CM_BASE + 0x0a00)
+#define        CORE_CM_SIZE            0x2000
+
+/*  CORE_CM registers */
+#define CM_FCLKEN1_CORE                0x00
+#define CM_FCLKEN3_CORE                0x08
+#define  EN_USBTLL             4       /* USB TLL clock enable */
+        /* also valid for CM_ICLKEN3_CORE */
+#define CM_ICLKEN1_CORE                0x10
+#define CM_ICLKEN3_CORE                0x18
+#define CM_IDLEST1_CORE                0x20
+#define CM_IDLEST3_CORE                0x28
+#define CM_AUTOIDLE1_CORE      0x30
+#define CM_AUTOIDLE3_CORE      0x38
+#define  AUTO_USBTLL           4       /* USB TLL auto enable/disable */
+#define CM_CLKSEL_CORE         0x40
+#define CM_CLKSTCTRL_CORE      0x48
+#define CM_CLKSTST_CORE                0x4c
+
+/* Clock_Control_Reg_CM */
+#define        CCR_CM_BASE             (OMAP2_CM_BASE + 0x0d00)
+#define        CCR_CM_SIZE             0x800
 
-struct obioehci_softc {
-       ehci_softc_t    sc;



Home | Main Index | Thread Index | Old Index