Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Provide bs_mmap implementations for bcm283x based b...
details: https://anonhg.NetBSD.org/src/rev/b15dbe7d026b
branches: trunk
changeset: 833075:b15dbe7d026b
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Jun 08 18:09:43 2018 +0000
description:
Provide bs_mmap implementations for bcm283x based boards.
PR: port-arm/53283
Submitted by: Nick Hudson
diffstat:
sys/arch/aarch64/aarch64/bus_space.c | 10 +++---
sys/arch/aarch64/include/pmap.h | 11 ++++---
sys/arch/arm/broadcom/bcm283x_platform.c | 47 +++++++++++++++++++++++++++----
3 files changed, 52 insertions(+), 16 deletions(-)
diffs (156 lines):
diff -r 8474005f3ed0 -r b15dbe7d026b sys/arch/aarch64/aarch64/bus_space.c
--- a/sys/arch/aarch64/aarch64/bus_space.c Fri Jun 08 14:44:21 2018 +0000
+++ b/sys/arch/aarch64/aarch64/bus_space.c Fri Jun 08 18:09:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.3 2018/04/09 22:26:15 jmcneill Exp $ */
+/* $NetBSD: bus_space.c,v 1.4 2018/06/08 18:09:43 jmcneill Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.3 2018/04/09 22:26:15 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.4 2018/06/08 18:09:43 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -616,11 +616,11 @@
paddr_t bus_flags = 0;
if ((flags & BUS_SPACE_MAP_CACHEABLE) != 0)
- bus_flags |= (AARCH64_MMAP_WRITEBACK << AARCH64_MMAP_FLAG_SHIFT);
+ bus_flags |= ARM_MMAP_WRITEBACK;
else if ((flags & BUS_SPACE_MAP_PREFETCHABLE) != 0)
- bus_flags |= (AARCH64_MMAP_WRITECOMBINE << AARCH64_MMAP_FLAG_SHIFT);
+ bus_flags |= ARM_MMAP_WRITECOMBINE;
else
- bus_flags |= (AARCH64_MMAP_DEVICE << AARCH64_MMAP_FLAG_SHIFT);
+ bus_flags |= ARM_MMAP_DEVICE;
return (atop(bpa + (offset << ((struct bus_space *)t)->bs_stride)) |
bus_flags);
diff -r 8474005f3ed0 -r b15dbe7d026b sys/arch/aarch64/include/pmap.h
--- a/sys/arch/aarch64/include/pmap.h Fri Jun 08 14:44:21 2018 +0000
+++ b/sys/arch/aarch64/include/pmap.h Fri Jun 08 18:09:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.4 2018/04/27 08:07:08 ryo Exp $ */
+/* $NetBSD: pmap.h,v 1.5 2018/06/08 18:09:43 jmcneill Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -150,10 +150,11 @@
#define AARCH64_MMAP_WRITECOMBINE 2UL
#define AARCH64_MMAP_DEVICE 3UL
-#define ARM_MMAP_WRITECOMBINE AARCH64_MMAP_WRITECOMBINE
-#define ARM_MMAP_WRITEBACK AARCH64_MMAP_WRITEBACK
-#define ARM_MMAP_NOCACHE AARCH64_MMAP_NOCACHE
-#define ARM_MMAP_DEVICE AARCH64_MMAP_DEVICE
+#define ARM_MMAP_MASK __BITS(63, AARCH64_MMAP_FLAG_SHIFT)
+#define ARM_MMAP_WRITECOMBINE __SHIFTIN(AARCH64_MMAP_WRITECOMBINE, ARM_MMAP_MASK)
+#define ARM_MMAP_WRITEBACK __SHIFTIN(AARCH64_MMAP_WRITEBACK, ARM_MMAP_MASK)
+#define ARM_MMAP_NOCACHE __SHIFTIN(AARCH64_MMAP_NOCACHE, ARM_MMAP_MASK)
+#define ARM_MMAP_DEVICE __SHIFTIN(AARCH64_MMAP_DEVICE, ARM_MMAP_MASK)
#define PMAP_PTE 0x10000000 /* kenter_pa */
#define PMAP_DEV 0x20000000 /* kenter_pa */
diff -r 8474005f3ed0 -r b15dbe7d026b sys/arch/arm/broadcom/bcm283x_platform.c
--- a/sys/arch/arm/broadcom/bcm283x_platform.c Fri Jun 08 14:44:21 2018 +0000
+++ b/sys/arch/arm/broadcom/bcm283x_platform.c Fri Jun 08 18:09:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm283x_platform.c,v 1.4 2018/04/01 04:35:03 ryo Exp $ */
+/* $NetBSD: bcm283x_platform.c,v 1.5 2018/06/08 18:09:43 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.4 2018/04/01 04:35:03 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.5 2018/06/08 18:09:43 jmcneill Exp $");
#include "opt_arm_debug.h"
#include "opt_bcm283x.h"
@@ -136,6 +136,8 @@
struct bus_space bcm2836_a4x_bs_tag;
int bcm283x_bs_map(void *, bus_addr_t, bus_size_t, int, bus_space_handle_t *);
+paddr_t bcm283x_bs_mmap(void *, bus_addr_t, off_t, int, int);
+paddr_t bcm283x_a4x_bs_mmap(void *, bus_addr_t, off_t, int, int);
int
bcm283x_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
@@ -159,10 +161,13 @@
*bshp = (bus_space_handle_t)(va + (pa - startpa));
- const int pmapflags =
- (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE))
- ? 0
- : PMAP_NOCACHE;
+ int pmapflags;
+ if (flag & BUS_SPACE_MAP_PREFETCHABLE)
+ pmapflags = PMAP_WRITE_COMBINE;
+ else if (flag & BUS_SPACE_MAP_CACHEABLE)
+ pmapflags = 0;
+ else
+ pmapflags = PMAP_NOCACHE;
for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
}
@@ -171,6 +176,32 @@
return 0;
}
+paddr_t
+bcm283x_bs_mmap(void *t, bus_addr_t bpa, off_t offset, int prot, int flags)
+{
+ /* Convert BA to PA */
+ const paddr_t pa = bpa & ~BCM2835_BUSADDR_CACHE_MASK;
+ paddr_t bus_flags = 0;
+
+ if (flags & BUS_SPACE_MAP_PREFETCHABLE)
+ bus_flags |= ARM_MMAP_WRITECOMBINE;
+
+ return arm_btop(pa + offset) | bus_flags;
+}
+
+paddr_t
+bcm283x_a4x_bs_mmap(void *t, bus_addr_t bpa, off_t offset, int prot, int flags)
+{
+ /* Convert BA to PA */
+ const paddr_t pa = bpa & ~BCM2835_BUSADDR_CACHE_MASK;
+ paddr_t bus_flags = 0;
+
+ if (flags & BUS_SPACE_MAP_PREFETCHABLE)
+ bus_flags |= ARM_MMAP_WRITECOMBINE;
+
+ return arm_btop(pa + 4 * offset) | bus_flags;
+}
+
int
bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
bus_space_handle_t *bshp)
@@ -1163,7 +1194,9 @@
bcm2835_a4x_bs_tag = arm_generic_a4x_bs_tag;
bcm2835_bs_tag.bs_map = bcm2835_bs_map;
+ bcm2835_bs_tag.bs_mmap = bcm283x_bs_mmap;
bcm2835_a4x_bs_tag.bs_map = bcm2835_bs_map;
+ bcm2835_a4x_bs_tag.bs_mmap = bcm283x_a4x_bs_mmap;
fdtbus_set_decoderegprop(false);
@@ -1182,7 +1215,9 @@
bcm2836_a4x_bs_tag = arm_generic_a4x_bs_tag;
bcm2836_bs_tag.bs_map = bcm2836_bs_map;
+ bcm2836_bs_tag.bs_mmap = bcm283x_bs_mmap;
bcm2836_a4x_bs_tag.bs_map = bcm2836_bs_map;
+ bcm2836_a4x_bs_tag.bs_mmap = bcm283x_a4x_bs_mmap;
fdtbus_set_decoderegprop(false);
Home |
Main Index |
Thread Index |
Old Index