From b33d4dabfec0c884df3d18033ce8408d42387041 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 26 Feb 2014 00:19:01 +0000 Subject: [PATCH] Include latent support for coherent dma though for now it seems that isn't possible. --- sys/arch/arm/allwinner/awin_board.c | 29 +++++++++++++++++++++++++++-- sys/arch/arm/allwinner/awin_io.c | 5 ++++- sys/arch/arm/allwinner/awin_var.h | 5 ++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sys/arch/arm/allwinner/awin_board.c b/sys/arch/arm/allwinner/awin_board.c index e1ae7a571ee3..71e9384aa2f3 100644 --- a/sys/arch/arm/allwinner/awin_board.c +++ b/sys/arch/arm/allwinner/awin_board.c @@ -1,4 +1,4 @@ -/* $NetBSD: awin_board.c,v 1.8 2014/02/24 16:50:49 matt Exp $ */ +/* $NetBSD: awin_board.c,v 1.9 2014/02/26 00:19:01 matt Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -34,7 +34,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.8 2014/02/24 16:50:49 matt Exp $"); +__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.9 2014/02/26 00:19:01 matt Exp $"); #include #include @@ -63,6 +63,23 @@ struct arm32_bus_dma_tag awin_dma_tag = { _BUS_DMATAG_FUNCS, }; +struct arm32_dma_range awin_coherent_dma_ranges[] = { + [0] = { + .dr_sysbase = AWIN_SDRAM_PBASE, + .dr_busbase = AWIN_SDRAM_PBASE, + .dr_flags = _BUS_DMAMAP_COHERENT, + }, +}; + + +struct arm32_bus_dma_tag awin_coherent_dma_tag = { + ._ranges = awin_coherent_dma_ranges, + ._nranges = __arraycount(awin_coherent_dma_ranges), + _BUS_DMAMAP_FUNCS, + _BUS_DMAMEM_FUNCS, + _BUS_DMATAG_FUNCS, +}; + #ifdef AWIN_CONSOLE_EARLY #include #include @@ -181,6 +198,14 @@ awin_bootstrap(vaddr_t iobase, vaddr_t uartbase) #endif } +#if 0 +void +awin_dma_bootstrap(psize_t psize) +{ + awin_coherent_dma_ranges[0].dr_len = psize; +} +#endif + #ifdef MULTIPROCESSOR void awin_cpu_hatch(struct cpu_info *ci) diff --git a/sys/arch/arm/allwinner/awin_io.c b/sys/arch/arm/allwinner/awin_io.c index 5ea25b851a01..8ba13fa89949 100644 --- a/sys/arch/arm/allwinner/awin_io.c +++ b/sys/arch/arm/allwinner/awin_io.c @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.7 2014/02/25 00:08:29 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.8 2014/02/26 00:19:01 matt Exp $"); #include #include @@ -56,6 +56,7 @@ static struct awinio_softc { bus_space_handle_t sc_bsh; bus_space_handle_t sc_ccm_bsh; bus_dma_tag_t sc_dmat; + bus_dma_tag_t sc_coherent_dmat; } awinio_sc; CFATTACH_DECL_NEW(awin_io, 0, @@ -152,6 +153,7 @@ awinio_attach(device_t parent, device_t self, void *aux) sc->sc_a4x_bst = &awin_a4x_bs_tag; sc->sc_bsh = awin_core_bsh; sc->sc_dmat = &awin_dma_tag; + sc->sc_coherent_dmat = &awin_coherent_dma_tag; bus_space_subregion(sc->sc_bst, sc->sc_bsh, AWIN_CCM_OFFSET, 0x1000, &sc->sc_ccm_bsh); @@ -188,6 +190,7 @@ awinio_attach(device_t parent, device_t self, void *aux) .aio_core_bsh = sc->sc_bsh, .aio_ccm_bsh = sc->sc_ccm_bsh, .aio_dmat = sc->sc_dmat, + .aio_coherent_dmat = sc->sc_coherent_dmat, }; cfdata_t cf = config_search_ia(awinio_find, sc->sc_dev, "awinio", &aio); diff --git a/sys/arch/arm/allwinner/awin_var.h b/sys/arch/arm/allwinner/awin_var.h index 92254f80b4cc..736f1b8fa009 100644 --- a/sys/arch/arm/allwinner/awin_var.h +++ b/sys/arch/arm/allwinner/awin_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: awin_var.h,v 1.8 2014/02/25 00:08:29 jmcneill Exp $ */ +/* $NetBSD: awin_var.h,v 1.9 2014/02/26 00:19:01 matt Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. @@ -58,6 +58,7 @@ struct awinio_attach_args { bus_space_handle_t aio_core_bsh; bus_space_handle_t aio_ccm_bsh; bus_dma_tag_t aio_dmat; + bus_dma_tag_t aio_coherent_dmat; }; struct awin_gpio_pinset { @@ -75,9 +76,11 @@ extern struct bus_space awin_bs_tag; extern struct bus_space awin_a4x_bs_tag; extern bus_space_handle_t awin_core_bsh; extern struct arm32_bus_dma_tag awin_dma_tag; +extern struct arm32_bus_dma_tag awin_coherent_dma_tag; psize_t awin_memprobe(void); void awin_bootstrap(vaddr_t, vaddr_t); +void awin_dma_bootstrap(psize_t); void awin_pll6_enable(void); void awin_cpu_hatch(struct cpu_info *);