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 Deal with bus addresses better. Switch...
details: https://anonhg.NetBSD.org/src/rev/e9f5b21c1ffe
branches: trunk
changeset: 784343:e9f5b21c1ffe
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Jan 26 08:01:49 2013 +0000
description:
Deal with bus addresses better. Switch the DMA bus address base to the
cache coherent range - not that anything uses it yet.
diffstat:
sys/arch/arm/broadcom/bcm2835_obio.c | 6 +++---
sys/arch/arm/broadcom/bcm2835_space.c | 26 ++++++++++++++++----------
sys/arch/arm/broadcom/bcm2835reg.h | 8 +++++++-
3 files changed, 26 insertions(+), 14 deletions(-)
diffs (134 lines):
diff -r 3c64c6671295 -r e9f5b21c1ffe sys/arch/arm/broadcom/bcm2835_obio.c
--- a/sys/arch/arm/broadcom/bcm2835_obio.c Sat Jan 26 07:52:16 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_obio.c Sat Jan 26 08:01:49 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_obio.c,v 1.12 2013/01/25 00:04:06 jmcneill Exp $ */
+/* $NetBSD: bcm2835_obio.c,v 1.13 2013/01/26 08:01:49 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_obio.c,v 1.12 2013/01/25 00:04:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_obio.c,v 1.13 2013/01/26 08:01:49 skrll Exp $");
#include "locators.h"
#include "obio.h"
@@ -181,7 +181,7 @@
sc->sc_dmat = &bcm2835_bus_dma_tag;
sc->sc_dmarange.dr_sysbase = 0;
- sc->sc_dmarange.dr_busbase = 0xc0000000; /* 0x40000000 if L2 */
+ sc->sc_dmarange.dr_busbase = BCM2835_BUSADDR_CACHE_COHERENT;
sc->sc_dmarange.dr_len = physmem * PAGE_SIZE;
bcm2835_bus_dma_tag._ranges = &sc->sc_dmarange;
bcm2835_bus_dma_tag._nranges = 1;
diff -r 3c64c6671295 -r e9f5b21c1ffe sys/arch/arm/broadcom/bcm2835_space.c
--- a/sys/arch/arm/broadcom/bcm2835_space.c Sat Jan 26 07:52:16 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_space.c Sat Jan 26 08:01:49 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_space.c,v 1.4 2013/01/23 16:51:14 macallan Exp $ */
+/* $NetBSD: bcm2835_space.c,v 1.5 2013/01/26 08:01:49 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.4 2013/01/23 16:51:14 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.5 2013/01/26 08:01:49 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -40,6 +40,8 @@
#include <sys/bus.h>
+#include <arm/broadcom/bcm2835reg.h>
+
/* Prototypes for all the bus_space structure functions */
bs_protos(bcm2835);
bs_protos(bcm2835_a4x);
@@ -280,7 +282,7 @@
int
-bcm2835_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag,
+bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
bus_space_handle_t *bshp)
{
u_long startpa, endpa, pa;
@@ -288,14 +290,17 @@
const struct pmap_devmap *pd;
int pmap_flags;
- if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) {
+ pa = ba & ~BCM2835_BUSADDR_CACHE_MASK;
+
+ /* this does device addresses */
+ if ((pd = pmap_devmap_find_pa(pa, size)) != NULL) {
/* Device was statically mapped. */
- *bshp = pd->pd_va + (bpa - pd->pd_pa);
+ *bshp = pd->pd_va + (pa - pd->pd_pa);
return 0;
}
- startpa = trunc_page(bpa);
- endpa = round_page(bpa + size);
+ startpa = trunc_page(pa);
+ endpa = round_page(pa + size);
/* XXX use extent manager to check duplicate mapping */
@@ -304,7 +309,7 @@
if (!va)
return ENOMEM;
- *bshp = (bus_space_handle_t)(va + (bpa - startpa));
+ *bshp = (bus_space_handle_t)(va + (pa - startpa));
pmap_flags = (flag & BUS_SPACE_MAP_CACHEABLE) ? 0 : PMAP_NOCACHE;
for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
@@ -368,14 +373,15 @@
}
paddr_t
-bcm2835_bs_mmap(void *t, bus_addr_t paddr, off_t offset, int prot, int flags)
+bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
{
+ paddr_t pa = ba & ~BCM2835_BUSADDR_CACHE_MASK;
paddr_t bus_flags = 0;
if (flags & BUS_SPACE_MAP_PREFETCHABLE)
bus_flags |= ARM32_MMAP_WRITECOMBINE;
- return (arm_btop(paddr + offset) | bus_flags);
+ return (arm_btop(pa + offset) | bus_flags);
}
int
diff -r 3c64c6671295 -r e9f5b21c1ffe sys/arch/arm/broadcom/bcm2835reg.h
--- a/sys/arch/arm/broadcom/bcm2835reg.h Sat Jan 26 07:52:16 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm2835reg.h Sat Jan 26 08:01:49 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835reg.h,v 1.8 2013/01/25 00:04:06 jmcneill Exp $ */
+/* $NetBSD: bcm2835reg.h,v 1.9 2013/01/26 08:01:49 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -77,6 +77,12 @@
#define BCM2835_IOPHYSTOVIRT(a) \
((0xf0000000 | (((a) & 0xf0000000) >> 4)) + ((a) & ~0xf0000000))
+#define BCM2835_BUSADDR_CACHE_MASK 0xc0000000
+#define BCM2835_BUSADDR_CACHE_COHERENT 0x40000000
+#define BCM2835_BUSADDR_CACHE_L1L2 0x00000000
+#define BCM2835_BUSADDR_CACHE_L2ONLY 0x80000000
+#define BCM2835_BUSADDR_CACHE_DIRECT 0xc0000000
+
#define BCM2835_PERIPHERALS_VBASE \
BCM2835_IOPHYSTOVIRT(BCM2835_PERIPHERALS_BASE)
#define BCM2835_STIMER_VBASE BCM2835_IOPHYSTOVIRT(BCM2835_ST_BASE)
Home |
Main Index |
Thread Index |
Old Index