Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Add bcm53xx_dma_bootstrap which, if th...



details:   https://anonhg.NetBSD.org/src/rev/571e77786998
branches:  trunk
changeset: 781925:571e77786998
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Oct 07 19:16:39 2012 +0000

description:
Add bcm53xx_dma_bootstrap which, if there is more than 256MB of RAM, add two
ranges to the default dma tag.  This has the side effect of making most initial
bus_dmamem_allocs trying to get memory from the first 256MB which is coherent
on this platform.

diffstat:

 sys/arch/arm/broadcom/bcm53xx_board.c |  26 ++++++++++++++++++++++++--
 sys/arch/arm/broadcom/bcm53xx_var.h   |   3 ++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diffs (71 lines):

diff -r 77295f6204bf -r 571e77786998 sys/arch/arm/broadcom/bcm53xx_board.c
--- a/sys/arch/arm/broadcom/bcm53xx_board.c     Sun Oct 07 18:47:07 2012 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_board.c     Sun Oct 07 19:16:39 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm53xx_board.c,v 1.4 2012/10/03 19:18:40 matt Exp $   */
+/*     $NetBSD: bcm53xx_board.c,v 1.5 2012/10/07 19:16:39 matt Exp $   */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.4 2012/10/03 19:18:40 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.5 2012/10/07 19:16:39 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -67,6 +67,8 @@
 static struct cpu_softc cpu_softc;
 static struct bcm53xx_clock_info clk_info;
 
+struct arm32_dma_range bcm53xx_dma_ranges[2];
+
 struct arm32_bus_dma_tag bcm53xx_dma_tag = {
        _BUS_DMAMAP_FUNCS,
        _BUS_DMAMEM_FUNCS,
@@ -485,6 +487,26 @@
        arml2cc_init(bcm53xx_armcore_bst, bcm53xx_armcore_bsh, ARMCORE_L2C_BASE);
 }
 
+void
+bcm53xx_dma_bootstrap(psize_t memsize)
+{
+       if (memsize > 256*1024*1024) {
+               /*
+                * By setting up two ranges, bus_dmamem_alloc will always
+                * try to allocate from range 0 first resulting in allocations
+                * below 256MB which for PCI and GMAC are coherent.
+                */
+               bcm53xx_dma_ranges[0].dr_sysbase = 0x80000000;
+               bcm53xx_dma_ranges[0].dr_busbase = 0x80000000;
+               bcm53xx_dma_ranges[0].dr_len = 0x10000000;
+               bcm53xx_dma_ranges[1].dr_sysbase = 0x90000000;
+               bcm53xx_dma_ranges[1].dr_busbase = 0x90000000;
+               bcm53xx_dma_ranges[1].dr_len = memsize - 0x10000000;
+               bcm53xx_dma_tag._ranges = bcm53xx_dma_ranges;
+               bcm53xx_dma_tag._nranges = __arraycount(bcm53xx_dma_ranges);
+       }
+}
+
 #ifdef MULTIPROCESSOR
 void
 bcm53xx_cpu_hatch(struct cpu_info *ci)
diff -r 77295f6204bf -r 571e77786998 sys/arch/arm/broadcom/bcm53xx_var.h
--- a/sys/arch/arm/broadcom/bcm53xx_var.h       Sun Oct 07 18:47:07 2012 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_var.h       Sun Oct 07 19:16:39 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm53xx_var.h,v 1.2 2012/10/03 19:18:41 matt Exp $     */
+/*     $NetBSD: bcm53xx_var.h,v 1.3 2012/10/07 19:16:39 matt Exp $     */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -106,6 +106,7 @@
            bus_space_handle_t);
 void   bcm53xx_device_register(device_t, void *);
 psize_t        bcm53xx_memprobe(void);
+void   bcm53xx_dma_bootstrap(psize_t);
 void   bcm53xx_print_clocks(void);
 void   bcm53xx_rng_start(bus_space_tag_t, bus_space_handle_t);
 void   bcm53xx_srab_init(void);



Home | Main Index | Thread Index | Old Index