Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Commit initial USB adapter support and associated D...



details:   https://anonhg.NetBSD.org/src/rev/a504fe7bc6b1
branches:  trunk
changeset: 329017:a504fe7bc6b1
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Tue Apr 29 16:47:10 2014 +0000

description:
Commit initial USB adapter support and associated DMA tags

diffstat:

 sys/arch/arm/samsung/exynos4_loc.c |    5 +-
 sys/arch/arm/samsung/exynos4_reg.h |    4 +-
 sys/arch/arm/samsung/exynos5_loc.c |    3 +-
 sys/arch/arm/samsung/exynos_dma.c  |   85 +++++++++
 sys/arch/arm/samsung/exynos_io.c   |   31 +-
 sys/arch/arm/samsung/exynos_soc.c  |    7 +-
 sys/arch/arm/samsung/exynos_usb.c  |  331 +++++++++++++++++++++++++++++++++++++
 sys/arch/arm/samsung/exynos_var.h  |    9 +-
 sys/arch/arm/samsung/files.exynos  |   18 +-
 sys/arch/evbarm/conf/ODROID-U      |   16 +-
 10 files changed, 468 insertions(+), 41 deletions(-)

diffs (truncated from 706 to 300 lines):

diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos4_loc.c
--- a/sys/arch/arm/samsung/exynos4_loc.c        Tue Apr 29 11:52:51 2014 +0000
+++ b/sys/arch/arm/samsung/exynos4_loc.c        Tue Apr 29 16:47:10 2014 +0000
@@ -260,8 +260,8 @@
 #define IRQ_MDNIE_LCD0_1               EXYNOS_COMBINERIRQ(0, 1)
 #define IRQ_MDNIE_LCD0_0               EXYNOS_COMBINERIRQ(0, 0)
 
-#define        OFFANDSIZE(p,n) EXYNOS4##p##_##n##_OFFSET, 0x10000
-
+#define        OFFANDSIZE(p,n) \
+       EXYNOS4##p##_##n##_OFFSET, 0x10000
 
 static const struct exyo_locators exynos4_locators[] = {
        { "mct", OFFANDSIZE(,MCT), NOPORT, IRQ_G0_IRQ, 0 },
@@ -270,6 +270,7 @@
        { "sscom", OFFANDSIZE(,UART1), 1, IRQ_UART1, 0 },
        { "sscom", OFFANDSIZE(,UART2), 2, IRQ_UART2, 0 },
        { "sscom", OFFANDSIZE(,UART3), 3, IRQ_UART3, 0 },
+       { "exyousb", OFFANDSIZE(,USBHOST0), 0, IRQ_UHOST, 0},   /* ehci+ohci */
 };
 
 const struct exyo_locinfo exynos4_locinfo = {
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos4_reg.h
--- a/sys/arch/arm/samsung/exynos4_reg.h        Tue Apr 29 11:52:51 2014 +0000
+++ b/sys/arch/arm/samsung/exynos4_reg.h        Tue Apr 29 16:47:10 2014 +0000
@@ -204,8 +204,8 @@
 #define EXYNOS4_SDMMC4_OFFSET          0x02550000
 #define EXYNOS4_MIPI_HSI_OFFSET                0x02560000      /* LCD0 */
 #define EXYNOS4_SROMC_OFFSET           0x02570000
-#define EXYNOS4_USBHOST0_OFFSET                0x02580000      /* USB interface 0 */
-#define EXYNOS4_USBHOST1_OFFSET                0x02590000      /* USB interface 1 */
+#define EXYNOS4_USBHOST0_OFFSET                0x02580000      /* USB EHCI */
+#define EXYNOS4_USBHOST1_OFFSET                0x02590000      /* USB OHCI companion to EHCI (paired) */
 #define EXYNOS4_USBOTG1_OFFSET         0x025B0000      /* USB On The Go interface */
 #define EXYNOS4_PDMA0_OFFSET           0x02680000      /* Peripheral DMA */
 #define EXYNOS4_PDMA1_OFFSET           0x02690000
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos5_loc.c
--- a/sys/arch/arm/samsung/exynos5_loc.c        Tue Apr 29 11:52:51 2014 +0000
+++ b/sys/arch/arm/samsung/exynos5_loc.c        Tue Apr 29 16:47:10 2014 +0000
@@ -209,7 +209,8 @@
 #define IRQ_TZASC_CBXR                 EXYNOS_COMBINERIRQ(0, 0)
 
 
-#define        OFFANDSIZE(p,n) EXYNOS5##p##_##n##_OFFSET, 0x10000
+#define        OFFANDSIZE(p,n) \
+       EXYNOS5##p##_##n##_OFFSET, 0x10000
 
 static const struct exyo_locators exynos5_locators[] = {
        { "exywdt", OFFANDSIZE(,WDT), NOPORT, IRQ_WDT, 0 },
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos_dma.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/samsung/exynos_dma.c Tue Apr 29 16:47:10 2014 +0000
@@ -0,0 +1,85 @@
+/*     $NetBSD: exynos_dma.c,v 1.1 2014/04/29 16:47:10 reinoud Exp $   */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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_exynos.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: exynos_dma.c,v 1.1 2014/04/29 16:47:10 reinoud Exp $");
+
+#define _ARM32_BUS_DMA_PRIVATE
+
+#include <sys/param.h>
+#include <sys/bus.h>
+
+#include <arm/samsung/exynos_reg.h>
+#include <arm/samsung/exynos_var.h>
+
+struct arm32_bus_dma_tag exynos_bus_dma_tag = {
+       _BUS_DMAMAP_FUNCS,
+       _BUS_DMAMEM_FUNCS,
+       _BUS_DMATAG_FUNCS,
+};
+
+struct arm32_dma_range exynos_coherent_dma_ranges[1] = {
+       [0] = {
+               .dr_sysbase = 0,        /* filled in */
+               .dr_busbase = 0,        /* filled in */
+               .dr_flags = _BUS_DMAMAP_COHERENT,
+       },
+};
+
+struct arm32_bus_dma_tag exynos_coherent_bus_dma_tag = {
+       ._ranges  = exynos_coherent_dma_ranges,
+       ._nranges = __arraycount(exynos_coherent_dma_ranges),
+       _BUS_DMAMAP_FUNCS,
+       _BUS_DMAMEM_FUNCS,
+       _BUS_DMATAG_FUNCS,
+};
+
+
+#ifndef EXYNOS4
+#      define EXYNOS4_SDRAM_PBASE 0
+#endif
+#ifndef EXYNOS5
+#      define EXYNOS5_SDRAM_PBASE 0
+#endif
+void
+exynos_dma_bootstrap(psize_t memsize)
+{
+       bus_addr_t dram_base = IS_EXYNOS4_P() ?
+               EXYNOS4_SDRAM_PBASE : EXYNOS5_SDRAM_PBASE;
+
+       KASSERT(dram_base);
+       exynos_coherent_dma_ranges[0].dr_sysbase = dram_base;
+       exynos_coherent_dma_ranges[0].dr_busbase = dram_base;
+       exynos_coherent_dma_ranges[0].dr_len = memsize;
+}
+
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos_io.c
--- a/sys/arch/arm/samsung/exynos_io.c  Tue Apr 29 11:52:51 2014 +0000
+++ b/sys/arch/arm/samsung/exynos_io.c  Tue Apr 29 16:47:10 2014 +0000
@@ -34,7 +34,7 @@
 #include "opt_exynos.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exynos_io.c,v 1.1 2014/04/13 02:26:26 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exynos_io.c,v 1.2 2014/04/29 16:47:10 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -58,12 +58,12 @@
 static void exyo_attach(device_t, device_t, void *);
 
 static struct exyo_softc {
-       device_t sc_dev;
-       bus_space_tag_t sc_bst;
-       bus_space_tag_t sc_a4x_bst;
-       bus_space_handle_t sc_bsh;
-       bus_dma_tag_t sc_dmat;
-       bus_dma_tag_t sc_coherent_dmat;
+       device_t                sc_dev;
+       bus_space_tag_t         sc_bst;
+       bus_space_tag_t         sc_a4x_bst;
+       bus_space_handle_t      sc_bsh;
+       bus_dma_tag_t           sc_dmat;
+       bus_dma_tag_t           sc_coherent_dmat;
 } exyo_sc;
 
 CFATTACH_DECL_NEW(exyo_io, 0, exyo_match, exyo_attach, NULL, NULL);
@@ -119,27 +119,29 @@
        return config_match(parent, cf, aux);
 }
 
+
+#if !defined(EXYNOS4) && !defined(EXYNOS5)
+#error Must define a SoC
+#endif
 static void
 exyo_attach(device_t parent, device_t self, void *aux)
 {
+       const struct exyo_locators *l = NULL;
        struct exyo_softc * const sc = &exyo_sc;
        prop_dictionary_t dict = device_properties(self);
+       size_t nl = 0;
 
        sc->sc_dev = self;
-
        sc->sc_bst = &exynos_bs_tag;
        sc->sc_a4x_bst = &exynos_a4x_bs_tag;
        sc->sc_bsh = exynos_core_bsh;
-//     sc->sc_dmat = &exynos_dma_tag;
-//     sc->sc_coherent_dmat = &exynos_coherent_dma_tag;
+       sc->sc_dmat = &exynos_bus_dma_tag;
+       sc->sc_coherent_dmat = &exynos_coherent_bus_dma_tag;
 
        const uint16_t product_id = EXYNOS_PRODUCT_ID(exynos_soc_id);
        aprint_naive(": Exynos %x\n", product_id);
        aprint_normal(": Exynos %x\n", product_id);
 
-       const struct exyo_locators *l = NULL;
-       size_t nl = 0;
-
 #if defined(EXYNOS4)
        if (IS_EXYNOS4_P()) {
                l = exynos4_locinfo.locators;
@@ -152,9 +154,6 @@
                nl = exynos5_locinfo.nlocators;
        }       
 #endif 
-#if !defined(EXYNOS4) && !defined(EXYNOS5)
-#error Must define a SoC
-#endif
        KASSERT(l != NULL);
        KASSERT(nl > 0);
 
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos_soc.c
--- a/sys/arch/arm/samsung/exynos_soc.c Tue Apr 29 11:52:51 2014 +0000
+++ b/sys/arch/arm/samsung/exynos_soc.c Tue Apr 29 16:47:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exynos_soc.c,v 1.6 2014/04/22 16:10:48 reinoud Exp $   */
+/*     $NetBSD: exynos_soc.c,v 1.7 2014/04/29 16:47:10 reinoud Exp $   */
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #define        _ARM32_BUS_DMA_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.6 2014/04/22 16:10:48 reinoud Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.7 2014/04/29 16:47:10 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -231,6 +231,9 @@
                panic("%s: failed to map in Exynos io registers: %d",
                        __func__, error);
        KASSERT(exynos_core_bsh == iobase);
+
+       /* init bus dma tags */
+       exynos_dma_bootstrap(physmem * PAGE_SIZE);
 }
 
 
diff -r 60c2e71468dd -r a504fe7bc6b1 sys/arch/arm/samsung/exynos_usb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/samsung/exynos_usb.c Tue Apr 29 16:47:10 2014 +0000
@@ -0,0 +1,331 @@
+/*     $NetBSD: exynos_usb.c,v 1.1 2014/04/29 16:47:10 reinoud Exp $   */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Reinoud Zandijk.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 "locators.h"
+#include "ohci.h"
+#include "ehci.h"
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(1, "$NetBSD: exynos_usb.c,v 1.1 2014/04/29 16:47:10 reinoud Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/intr.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/queue.h>
+#include <sys/kmem.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
+#include <dev/usb/usb_mem.h>



Home | Main Index | Thread Index | Old Index