Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/omap add a simple driver for OMAP3's built-in D...
details: https://anonhg.NetBSD.org/src/rev/82f772dfd043
branches: trunk
changeset: 783787:82f772dfd043
user: macallan <macallan%NetBSD.org@localhost>
date: Tue Jan 08 19:03:16 2013 +0000
description:
add a simple driver for OMAP3's built-in DMA controller
diffstat:
sys/arch/arm/omap/omap2_obio.c | 11 +-
sys/arch/arm/omap/omap2_reg.h | 11 ++-
sys/arch/arm/omap/omapdma.c | 157 ++++++++++++++++++++++++++++++++++++
sys/arch/arm/omap/omapdmareg.h | 176 +++++++++++++++++++++++++++++++++++++++++
sys/arch/arm/omap/omapdmavar.h | 41 +++++++++
5 files changed, 390 insertions(+), 6 deletions(-)
diffs (truncated from 458 to 300 lines):
diff -r 080ee5ff1dfb -r 82f772dfd043 sys/arch/arm/omap/omap2_obio.c
--- a/sys/arch/arm/omap/omap2_obio.c Tue Jan 08 16:58:59 2013 +0000
+++ b/sys/arch/arm/omap/omap2_obio.c Tue Jan 08 19:03:16 2013 +0000
@@ -1,7 +1,7 @@
-/* $Id: omap2_obio.c,v 1.18 2012/12/24 06:28:55 kiyohara Exp $ */
+/* $Id: omap2_obio.c,v 1.19 2013/01/08 19:03:16 macallan Exp $ */
/* adapted from: */
-/* $NetBSD: omap2_obio.c,v 1.18 2012/12/24 06:28:55 kiyohara Exp $ */
+/* $NetBSD: omap2_obio.c,v 1.19 2013/01/08 19:03:16 macallan Exp $ */
/*
@@ -103,7 +103,7 @@
#include "opt_omap.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.18 2012/12/24 06:28:55 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.19 2013/01/08 19:03:16 macallan Exp $");
#include "locators.h"
#include "obio.h"
@@ -364,7 +364,7 @@
{ .name = "avic", .addr = INTC_BASE_3430, .required = true },
#endif
#if defined(OMAP_3530)
- { .name = "avic", .addr = INTC_BASE_3530, .required = true },
+ { .name = "avic", .addr = INTC_BASE_3530, .required = true },
#endif
{ .name = "gpio1", .addr = GPIO1_BASE, .required = false },
{ .name = "gpio2", .addr = GPIO2_BASE, .required = false },
@@ -385,6 +385,9 @@
{ .name = "omapicu", .addr = 0x48200000, .required = true },
{ .name = "prcm", .addr = 0x44e00000, .required = true },
#endif
+#if defined(OMAP_3530)
+ { .name = "omapdma", .addr = OMAP3530_SDMA_BASE, .required = true },
+#endif
};
static void
diff -r 080ee5ff1dfb -r 82f772dfd043 sys/arch/arm/omap/omap2_reg.h
--- a/sys/arch/arm/omap/omap2_reg.h Tue Jan 08 16:58:59 2013 +0000
+++ b/sys/arch/arm/omap/omap2_reg.h Tue Jan 08 19:03:16 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_reg.h,v 1.15 2012/12/13 01:15:50 matt Exp $ */
+/* $NetBSD: omap2_reg.h,v 1.16 2013/01/08 19:03:16 macallan Exp $ */
/*
* Copyright (c) 2007 Microsoft
@@ -143,7 +143,8 @@
#define OMAP2_CM_ICLKEN1_CORE 0x210
#define OMAP2_CM_ICLKEN2_CORE 0x214
#define OMAP2_CM_CLKSEL2_CORE 0x244
-#define OMAP2_CM_SIZE (OMAP2_CM_CLKSEL2_CORE + 4)
+#define OMAP3_CM_IDLEST1_CORE 0xa20
+#define OMAP2_CM_SIZE (0x1000)
/*
* bit defines for OMAP2_CM_CLKSEL_MPU
@@ -729,4 +730,10 @@
#define OMAP3530_SDRC_BASE 0x6d000000
#define OMAP3530_SDRC_SIZE 0x00010000 /* 16KB */
+/*
+ * DMA
+ */
+#define OMAP3530_SDMA_BASE 0x48056000
+#define OMAP3530_SDMA_SIZE 0x00001000 /* 4KB */
+
#endif /* _ARM_OMAP_OMAP2_REG_H_ */
diff -r 080ee5ff1dfb -r 82f772dfd043 sys/arch/arm/omap/omapdma.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/omap/omapdma.c Tue Jan 08 19:03:16 2013 +0000
@@ -0,0 +1,157 @@
+/* $NetBSD: omapdma.c,v 1.1 2013/01/08 19:03:16 macallan Exp $ */
+
+/*
+ * Copyright (c) 2012 Michael Lorenz
+ * All rights reserved.
+ *
+ * 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 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.
+ */
+
+/*
+ * OMAP 3530 DMA controller
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: omapdma.c,v 1.1 2013/01/08 19:03:16 macallan Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/lwp.h>
+#include <sys/kauth.h>
+
+#include <sys/bus.h>
+#include <arm/omap/omapdmareg.h>
+#include <arm/omap/omapdmavar.h>
+#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_obioreg.h>
+#include <arm/omap/omap2_prcm.h>
+
+struct omapdma_softc {
+ device_t sc_dev;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_regh;
+};
+
+static int omapdma_match(device_t, cfdata_t, void *);
+static void omapdma_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(omapdma, sizeof(struct omapdma_softc),
+ omapdma_match, omapdma_attach, NULL, NULL);
+
+struct omapdma_softc *omapdma_sc = NULL;
+
+static int
+omapdma_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct obio_attach_args *obio = aux;
+
+ if ((obio->obio_addr == -1) || (obio->obio_size == 0))
+ return 0;
+ return 1;
+}
+
+static void
+omapdma_attach(device_t parent, device_t self, void *aux)
+{
+ struct omapdma_softc *sc = device_private(self);
+ struct obio_attach_args *obio = aux;
+ uint32_t reg;
+
+ sc->sc_iot = obio->obio_iot;
+ sc->sc_dev = self;
+
+ printf(": OMAP DMA controller rev ");
+ if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size, 0,
+ &sc->sc_regh)) {
+ aprint_error_dev(sc->sc_dev, ": couldn't map register space\n");
+ return;
+ }
+ reg = bus_space_read_4(sc->sc_iot, sc->sc_regh, OMAPDMA_REVISION);
+ printf("%d.%d\n", (reg >> 4) & 0xf, reg & 0xf);
+
+ /* disable & clear all interrupts etc. */
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPDMA_IRQENABLE_L0, 0);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPDMA_IRQENABLE_L1, 0);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPDMA_IRQENABLE_L2, 0);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPDMA_IRQENABLE_L3, 0);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh,
+ OMAPDMA_IRQSTATUS_L0, 0xffffffff);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh,
+ OMAPDMA_IRQSTATUS_L1, 0xffffffff);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh,
+ OMAPDMA_IRQSTATUS_L2, 0xffffffff);
+ bus_space_write_4(sc->sc_iot, sc->sc_regh,
+ OMAPDMA_IRQSTATUS_L3, 0xffffffff);
+
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPDMA_SYSCONFIG,
+ OMAPDMA_IDLEMODE_NO_STANDBY | OMAPDMA_SMART_IDLE |
+ OMAPDMA_AUTOIDLE);
+
+ omapdma_sc = sc;
+
+ /*
+ * TODO:
+ * - channel allocation
+ */
+}
+
+void
+omapdma_write_reg(int reg, uint32_t val)
+{
+ if (omapdma_sc != NULL) {
+ bus_space_write_4(omapdma_sc->sc_iot, omapdma_sc->sc_regh,
+ reg, val);
+ }
+}
+
+uint32_t
+omapdma_read_reg(int reg)
+{
+ if (omapdma_sc != NULL) {
+ return bus_space_read_4(omapdma_sc->sc_iot,
+ omapdma_sc->sc_regh, reg);
+ }
+ return 0;
+}
+
+void
+omapdma_write_ch_reg(int ch, int reg, uint32_t val)
+{
+ if (omapdma_sc != NULL) {
+ bus_space_write_4(omapdma_sc->sc_iot, omapdma_sc->sc_regh,
+ OMAPDMA_CHANNEL_BASE + 0x60 * ch + reg, val);
+ }
+}
+
+uint32_t
+omapdma_read_ch_reg(int ch, int reg)
+{
+ if (omapdma_sc != NULL) {
+ return bus_space_read_4(omapdma_sc->sc_iot,
+ omapdma_sc->sc_regh,
+ OMAPDMA_CHANNEL_BASE + 0x60 * ch + reg);
+ }
+ return 0;
+}
diff -r 080ee5ff1dfb -r 82f772dfd043 sys/arch/arm/omap/omapdmareg.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/omap/omapdmareg.h Tue Jan 08 19:03:16 2013 +0000
@@ -0,0 +1,176 @@
+/* $NetBSD: omapdmareg.h,v 1.1 2013/01/08 19:03:16 macallan Exp $ */
+
+/*
+ * Copyright (c) 2012 Michael Lorenz
+ * All rights reserved.
+ *
+ * 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: omapdmareg.h,v 1.1 2013/01/08 19:03:16 macallan Exp $");
+
+#ifndef OMAPDMA_REG_H
+#define OMAPDMA_REG_H
+
+/*
+ * all register offsets are relative to OMAP3530_SDMA_BASE
+ */
+
+#define OMAPDMA_REVISION 0x00000000
+
+/* each bit corresponds to a DMA channel, write 1 to clear */
+#define OMAPDMA_IRQSTATUS_L0 0x00000008
+#define OMAPDMA_IRQSTATUS_L1 0x0000000c
+#define OMAPDMA_IRQSTATUS_L2 0x00000010
+#define OMAPDMA_IRQSTATUS_L3 0x00000014
+
+#define OMAPDMA_IRQENABLE_L0 0x00000018
+#define OMAPDMA_IRQENABLE_L1 0x0000001c
+#define OMAPDMA_IRQENABLE_L2 0x00000020
+#define OMAPDMA_IRQENABLE_L3 0x00000024
+
+#define OMAPDMA_SYSSTATUS 0x00000028
+ #define OMAPDMA_RESET_DONE 0x00000001
+
+#define OMAPDMA_SYSCONFIG 0x0000002c
+ #define OMAPDMA_IDLEMODE_MASK 0x00003000
+ #define OMAPDMA_IDLEMODE_FORCE_STANDBY 0x00000000
+ #define OMAPDMA_IDLEMODE_NO_STANDBY 0x00001000
+ #define OMAPDMA_IDLEMODE_SMART_STANDBY 0x00002000
+ #define OMAPDMA_CLKACT_MASK 0x00000300
+ #define OMAPDMA_EMUFREE 0x00000020
+ #define OMAPDMA_SIDLEMODE_MASK 0x00000018
+ #define OMAPDMA_FORCE_IDLE 0x00000000
+ #define OMAPDMA_NO_IDLE 0x00000008
Home |
Main Index |
Thread Index |
Old Index