Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/arch Pull up following revision(s) (requested by bouy...
details: https://anonhg.NetBSD.org/src/rev/5987929af0a6
branches: netbsd-7
changeset: 799220:5987929af0a6
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Apr 19 04:37:17 2015 +0000
description:
Pull up following revision(s) (requested by bouyer in ticket #704):
sys/arch/arm/omap/omap_edma.c: revision 1.1
sys/arch/arm/omap/omap_edma.h: revision 1.1
sys/arch/arm/omap/files.omap2: revision 1.30
sys/arch/arm/omap/omap2_obiovar.h: revision 1.3
sys/arch/arm/omap/omap3_sdhc.c: revision 1.16
sys/arch/arm/omap/omap2_reg.h: revision 1.29
sys/arch/evbarm/conf/BEAGLEBONE: revision 1.31
sys/arch/arm/omap/omap2_obio.c: revision 1.22
- Add a driver for the Enhanced Direct Memory Access controller found
in the AM335x SoC. Written by Jared D. McNeill, with some final debug by me.
- Supports only DMA (not QDMA) yet, and there's no support for DMA event
matrix yet (this means that only primary DMA events can be used)
- Add support for DMA transfers. From Jared D. McNeill, with final debug by
me. With this I can get nearly 20MB/s from my sdcard on the BB black at 1Ghz
(not bad for a 50Mhz 4-bits bus), and still 15MB/s on the BB white at
low speed (275Mhz).
- Add the edma controller, and enable DMA for sdhc0 and sdhc1
diffstat:
sys/arch/arm/omap/files.omap2 | 8 +-
sys/arch/arm/omap/omap2_obio.c | 9 +-
sys/arch/arm/omap/omap2_obiovar.h | 3 +-
sys/arch/arm/omap/omap2_reg.h | 19 +-
sys/arch/arm/omap/omap3_sdhc.c | 206 +++++++++++++-
sys/arch/arm/omap/omap_edma.c | 578 ++++++++++++++++++++++++++++++++++++++
sys/arch/arm/omap/omap_edma.h | 173 +++++++++++
sys/arch/evbarm/conf/BEAGLEBONE | 9 +-
8 files changed, 988 insertions(+), 17 deletions(-)
diffs (truncated from 1184 to 300 lines):
diff -r e22650d883d0 -r 5987929af0a6 sys/arch/arm/omap/files.omap2
--- a/sys/arch/arm/omap/files.omap2 Sun Apr 19 04:31:40 2015 +0000
+++ b/sys/arch/arm/omap/files.omap2 Sun Apr 19 04:37:17 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.omap2,v 1.28 2014/07/16 18:31:17 bouyer Exp $
+# $NetBSD: files.omap2,v 1.28.2.1 2015/04/19 04:37:17 msaitoh Exp $
#
# Configuration info for Texas Instruments OMAP2/OMAP3 CPU support
# Based on xscale/files.pxa2x0
@@ -32,7 +32,7 @@
defflag opt_omap.h TI_DM37XX: OMAP3
# OBIO just an attach point
-device obio { [addr=-1], [size=0], [intr=-1], [mult=1], [intrbase=-1], [nobyteacc=0]
+device obio { [addr=-1], [size=0], [intr=-1], [mult=1], [intrbase=-1], [nobyteacc=0], [edmabase=-1]
} : bus_space_generic
attach obio at mainbus
file arch/arm/omap/omap2_obio.c obio needs-count
@@ -170,6 +170,10 @@
attach omapdma at obio
file arch/arm/omap/omap3_sdma.c omapdma needs-flag
+device edma
+attach edma at obio
+file arch/arm/omap/omap_edma.c edma needs-flag
+
# these bus space methods are not bus-specific ...
#
file arch/arm/omap/omap_nobyteacc_space.c emifs | gpmc
diff -r e22650d883d0 -r 5987929af0a6 sys/arch/arm/omap/omap2_obio.c
--- a/sys/arch/arm/omap/omap2_obio.c Sun Apr 19 04:31:40 2015 +0000
+++ b/sys/arch/arm/omap/omap2_obio.c Sun Apr 19 04:37:17 2015 +0000
@@ -1,7 +1,7 @@
-/* $Id: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $ */
+/* $Id: omap2_obio.c,v 1.21.8.1 2015/04/19 04:37:17 msaitoh Exp $ */
/* adapted from: */
-/* $NetBSD: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $ */
+/* $NetBSD: omap2_obio.c,v 1.21.8.1 2015/04/19 04:37:17 msaitoh Exp $ */
/*
@@ -103,7 +103,7 @@
#include "opt_omap.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.21 2013/06/15 21:58:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_obio.c,v 1.21.8.1 2015/04/19 04:37:17 msaitoh Exp $");
#include "locators.h"
#include "obio.h"
@@ -284,6 +284,7 @@
oa.obio_size = cf->cf_loc[OBIOCF_SIZE];
oa.obio_intr = cf->cf_loc[OBIOCF_INTR];
oa.obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE];
+ oa.obio_edmabase = cf->cf_loc[OBIOCF_EDMABASE];
#if defined(OMAP2)
if ((oa.obio_addr >= sc->sc_base)
@@ -351,6 +352,7 @@
oa->obio_size = cf->cf_loc[OBIOCF_SIZE];
oa->obio_intr = cf->cf_loc[OBIOCF_INTR];
oa->obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE];
+ oa->obio_edmabase = cf->cf_loc[OBIOCF_EDMABASE];
return config_match(parent, cf, oa);
}
@@ -398,6 +400,7 @@
{ .name = "omapicu", .addr = 0x48200000, .required = true },
{ .name = "prcm", .addr = 0x44e00000, .required = true },
{ .name = "sitaracm", .addr = 0x44e10000, .required = true },
+ { .name = "edma", .addr = 0x49000000, .required = false },
#endif
#if defined(OMAP_3530)
{ .name = "omapdma", .addr = OMAP3530_SDMA_BASE, .required = true },
diff -r e22650d883d0 -r 5987929af0a6 sys/arch/arm/omap/omap2_obiovar.h
--- a/sys/arch/arm/omap/omap2_obiovar.h Sun Apr 19 04:31:40 2015 +0000
+++ b/sys/arch/arm/omap/omap2_obiovar.h Sun Apr 19 04:37:17 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_obiovar.h,v 1.2 2012/09/05 00:19:59 matt Exp $ */
+/* $NetBSD: omap2_obiovar.h,v 1.2.14.1 2015/04/19 04:37:17 msaitoh Exp $ */
/*
* Copyright (c) 2007 Microsoft
@@ -40,6 +40,7 @@
bus_dma_tag_t obio_dmat;
unsigned int obio_mult;
unsigned int obio_intrbase;
+ int obio_edmabase;
};
struct obio_softc {
diff -r e22650d883d0 -r 5987929af0a6 sys/arch/arm/omap/omap2_reg.h
--- a/sys/arch/arm/omap/omap2_reg.h Sun Apr 19 04:31:40 2015 +0000
+++ b/sys/arch/arm/omap/omap2_reg.h Sun Apr 19 04:37:17 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_reg.h,v 1.28 2014/07/20 23:08:43 bouyer Exp $ */
+/* $NetBSD: omap2_reg.h,v 1.28.2.1 2015/04/19 04:37:17 msaitoh Exp $ */
/*
* Copyright (c) 2007 Microsoft
@@ -896,5 +896,20 @@
#define SDRAM_CONFIG_EBANK __BIT(3)
#define SDRAM_CONFIG_PAGESIZE __BITS(2,0)
#endif
-
+
+/* EDMA3 */
+#define AM335X_TPCC_BASE 0x49000000
+#define AM335X_TPCC_SIZE 0x00100000
+#define AM335X_TPTC0_BASE 0x49800000
+#define AM335X_TPTC0_SIZE 0x00100000
+#define AM335X_TPTC1_BASE 0x49900000
+#define AM335X_TPTC1_SIZE 0x00100000
+#define AM335X_TPTC2_BASE 0x49a00000
+#define AM335X_TPTC2_SIZE 0x00100000
+#define AM335X_INT_EDMACOMPINT 12
+#define AM335X_INT_EDMAMPERR 13
+#define AM335X_INT_EDMAERRINT 14
+#define AM335X_INT_TCERRINT0 112
+#define AM335X_INT_TCERRINT1 113
+#define AM335X_INT_TCERRINT2 114
#endif /* _ARM_OMAP_OMAP2_REG_H_ */
diff -r e22650d883d0 -r 5987929af0a6 sys/arch/arm/omap/omap3_sdhc.c
--- a/sys/arch/arm/omap/omap3_sdhc.c Sun Apr 19 04:31:40 2015 +0000
+++ b/sys/arch/arm/omap/omap3_sdhc.c Sun Apr 19 04:37:17 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_sdhc.c,v 1.14 2014/03/29 23:32:41 matt Exp $ */
+/* $NetBSD: omap3_sdhc.c,v 1.14.4.1 2015/04/19 04:37:17 msaitoh Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,9 +29,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.14 2014/03/29 23:32:41 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.14.4.1 2015/04/19 04:37:17 msaitoh Exp $");
#include "opt_omap.h"
+#include "edma.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -39,7 +40,8 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/queue.h>
-
+#include <sys/mutex.h>
+#include <sys/condvar.h>
#include <sys/bus.h>
#include <arm/omap/omap2_obiovar.h>
@@ -51,8 +53,25 @@
# include <arm/omap/omap2_prcm.h>
#endif
+#if NEDMA > 0
+# include <arm/omap/omap_edma.h>
+#endif
+
#include <dev/sdmmc/sdhcreg.h>
#include <dev/sdmmc/sdhcvar.h>
+#include <dev/sdmmc/sdmmcvar.h>
+
+#ifdef TI_AM335X
+#define EDMA_MAX_PARAMS 32
+#endif
+
+#ifdef OM3SDHC_DEBUG
+int om3sdhcdebug = 1;
+#define DPRINTF(n,s) do { if ((n) <= om3sdhcdebug) device_printf s; } while (0)
+#else
+#define DPRINTF(n,s) do {} while (0)
+#endif
+
#define CLKD(kz) (sc->sc.sc_clkbase / (kz))
@@ -77,8 +96,25 @@
bus_space_handle_t sc_sdhc_bsh;
struct sdhc_host *sc_hosts[1];
void *sc_ih; /* interrupt vectoring */
+
+#if NEDMA > 0
+ struct edma_channel *sc_edma_tx;
+ struct edma_channel *sc_edma_rx;
+ uint16_t sc_edma_param_tx[EDMA_MAX_PARAMS];
+ uint16_t sc_edma_param_rx[EDMA_MAX_PARAMS];
+ kmutex_t sc_edma_lock;
+ kcondvar_t sc_edma_cv;
+ bus_addr_t sc_edma_fifo;
+ bool sc_edma_pending;
+#endif
};
+#if NEDMA > 0
+static void obiosdhc_edma_init(struct obiosdhc_softc *, unsigned int);
+static int obiosdhc_edma_xfer_data(struct sdhc_softc *, struct sdmmc_command *);
+static void obiosdhc_edma_done(void *);
+#endif
+
#ifdef TI_AM335X
struct am335x_sdhc {
const char *as_name;
@@ -147,6 +183,7 @@
uint32_t clkd, stat;
int error, timo, clksft, n;
bool support8bit = false;
+ const char *transfer_mode = "PIO";
#ifdef TI_AM335X
size_t i;
#endif
@@ -155,7 +192,6 @@
sc->sc.sc_dmat = oa->obio_dmat;
sc->sc.sc_dev = self;
- //sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
sc->sc.sc_flags |= SDHC_FLAG_32BIT_ACCESS;
sc->sc.sc_flags |= SDHC_FLAG_NO_LED_ON;
sc->sc.sc_flags |= SDHC_FLAG_RSP136_CRC;
@@ -192,8 +228,24 @@
bus_space_subregion(sc->sc_bst, sc->sc_bsh, OMAP3_SDMMC_SDHC_OFFSET,
OMAP3_SDMMC_SDHC_SIZE, &sc->sc_sdhc_bsh);
- aprint_naive(": SDHC controller\n");
- aprint_normal(": SDHC controller\n");
+#if NEDMA > 0
+ if (oa->obio_edmabase != -1) {
+ mutex_init(&sc->sc_edma_lock, MUTEX_DEFAULT, IPL_SCHED);
+ cv_init(&sc->sc_edma_cv, "sdhcedma");
+ sc->sc_edma_fifo = oa->obio_addr +
+ OMAP3_SDMMC_SDHC_OFFSET + SDHC_DATA;
+ obiosdhc_edma_init(sc, oa->obio_edmabase);
+ sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
+ sc->sc.sc_flags |= SDHC_FLAG_EXTERNAL_DMA;
+ sc->sc.sc_flags |= SDHC_FLAG_EXTDMA_DMAEN;
+ sc->sc.sc_flags &= ~SDHC_FLAG_SINGLE_ONLY;
+ sc->sc.sc_vendor_transfer_data_dma = obiosdhc_edma_xfer_data;
+ transfer_mode = "EDMA";
+ }
+#endif
+
+ aprint_naive("\n");
+ aprint_normal(": SDHC controller (%s)\n", transfer_mode);
#ifdef TI_AM335X
/* XXX Not really AM335X-specific. */
@@ -380,3 +432,145 @@
return 0;
}
+
+#if NEDMA > 0
+static void
+obiosdhc_edma_init(struct obiosdhc_softc *sc, unsigned int edmabase)
+{
+ int i;
+
+ /* Request tx and rx DMA channels */
+ sc->sc_edma_tx = edma_channel_alloc(EDMA_TYPE_DMA, edmabase + 0,
+ obiosdhc_edma_done, sc);
+ KASSERT(sc->sc_edma_tx != NULL);
+ sc->sc_edma_rx = edma_channel_alloc(EDMA_TYPE_DMA, edmabase + 1,
+ obiosdhc_edma_done, sc);
+ KASSERT(sc->sc_edma_rx != NULL);
+
+ device_printf(sc->sc.sc_dev, "EDMA tx channel %d, rx channel %d\n",
+ edma_channel_index(sc->sc_edma_tx),
+ edma_channel_index(sc->sc_edma_rx));
+
+ /* Allocate some PaRAM pages */
+ for (i = 0; i < __arraycount(sc->sc_edma_param_tx); i++) {
+ sc->sc_edma_param_tx[i] = edma_param_alloc(sc->sc_edma_tx);
+ KASSERT(sc->sc_edma_param_tx[i] != 0xffff);
+ }
+ for (i = 0; i < __arraycount(sc->sc_edma_param_rx); i++) {
+ sc->sc_edma_param_rx[i] = edma_param_alloc(sc->sc_edma_rx);
+ KASSERT(sc->sc_edma_param_rx[i] != 0xffff);
+ }
+
+ return;
+}
+
+static int
+obiosdhc_edma_xfer_data(struct sdhc_softc *sdhc_sc, struct sdmmc_command *cmd)
+{
+ struct obiosdhc_softc *sc = device_private(sdhc_sc->sc_dev);
+ struct edma_channel *edma;
+ uint16_t *edma_param;
+ struct edma_param ep;
+ size_t seg;
+ int error;
+ int blksize = MIN(cmd->c_datalen, cmd->c_blklen);
+
+ edma = ISSET(cmd->c_flags, SCF_CMD_READ) ?
+ sc->sc_edma_rx : sc->sc_edma_tx;
+ edma_param = ISSET(cmd->c_flags, SCF_CMD_READ) ?
+ sc->sc_edma_param_rx : sc->sc_edma_param_tx;
Home |
Main Index |
Thread Index |
Old Index