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 As we'll soon get boot-time informatio...
details: https://anonhg.NetBSD.org/src/rev/4f579334dfa8
branches: trunk
changeset: 781142:4f579334dfa8
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Wed Aug 22 13:19:47 2012 +0000
description:
As we'll soon get boot-time information via the mailbox method, seperate
the actual access code into a seperate file that can be used by itself.
diffstat:
sys/arch/arm/broadcom/bcm2835_mbox.c | 45 +------------
sys/arch/arm/broadcom/bcm2835_mbox.h | 11 ++-
sys/arch/arm/broadcom/bcm2835_mbox_subr.c | 98 +++++++++++++++++++++++++++++++
sys/arch/arm/broadcom/files.bcm2835 | 3 +-
4 files changed, 113 insertions(+), 44 deletions(-)
diffs (223 lines):
diff -r a0e0c38adf21 -r 4f579334dfa8 sys/arch/arm/broadcom/bcm2835_mbox.c
--- a/sys/arch/arm/broadcom/bcm2835_mbox.c Wed Aug 22 12:36:35 2012 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_mbox.c Wed Aug 22 13:19:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_mbox.c,v 1.1 2012/08/20 07:45:24 skrll Exp $ */
+/* $NetBSD: bcm2835_mbox.c,v 1.2 2012/08/22 13:19:47 jakllsch Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_mbox.c,v 1.1 2012/08/20 07:45:24 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_mbox.c,v 1.2 2012/08/22 13:19:47 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -97,32 +97,10 @@
bcmmbox_read(uint8_t chan, uint32_t *data)
{
struct bcm2835mbox_softc *sc = bcm2835mbox_sc;
- uint32_t mbox;
KASSERT(sc != NULL);
- for (;;) {
- uint8_t rchan;
- uint32_t rdata;
-
- bus_space_barrier(sc->sc_iot, sc->sc_ioh, 0,
- BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_READ);
-
- if ((bus_space_read_4(sc->sc_iot, sc->sc_ioh,
- BCM2835_MBOX0_STATUS) & BCM2835_MBOX_STATUS_EMPTY) != 0)
- continue;
-
- mbox = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
- BCM2835_MBOX0_READ);
-
- rchan = BCM2835_MBOX_CHAN(mbox);
- rdata = BCM2835_MBOX_DATA(mbox);
-
- if (rchan == chan) {
- *data = rdata;
- return;
- }
- }
+ return bcm2835_mbox_read(sc->sc_iot, sc->sc_ioh, chan, data);
}
void
@@ -131,21 +109,6 @@
struct bcm2835mbox_softc *sc = bcm2835mbox_sc;
KASSERT(sc != NULL);
- uint32_t rdata;
- for (;;) {
-
- bus_space_barrier(sc->sc_iot, sc->sc_ioh, 0,
- BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_READ);
-
- if ((rdata = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
- BCM2835_MBOX0_STATUS) & BCM2835_MBOX_STATUS_FULL) == 0)
- break;
- }
-
- bus_space_write_4(sc->sc_iot, sc->sc_ioh,
- BCM2835_MBOX1_WRITE, BCM2835_MBOX_MSG(chan, data));
-
- bus_space_barrier(sc->sc_iot, sc->sc_ioh, 0,
- BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_WRITE);
+ return bcm2835_mbox_write(sc->sc_iot, sc->sc_ioh, chan, data);
}
diff -r a0e0c38adf21 -r 4f579334dfa8 sys/arch/arm/broadcom/bcm2835_mbox.h
--- a/sys/arch/arm/broadcom/bcm2835_mbox.h Wed Aug 22 12:36:35 2012 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_mbox.h Wed Aug 22 13:19:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_mbox.h,v 1.1 2012/08/20 07:45:24 skrll Exp $ */
+/* $NetBSD: bcm2835_mbox.h,v 1.2 2012/08/22 13:19:47 jakllsch Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -32,11 +32,18 @@
#ifndef _BCM2835_MBOX_H_
#define _BCM2835_MBOX_H_
+#include <sys/bus.h>
+
#define BCM2835_MBOX_CHAN(mbox) ((mbox) & 0xf)
-#define BCM2835_MBOX_DATA(mbox) ((mbox) & ~0xf)
+#define BCM2835_MBOX_DATA(mbox) (((mbox) & ~0xf) >> 4)
#define BCM2835_MBOX_MSG(chan, data) (((chan) & 0xf) | ((data) << 4))
+void bcm2835_mbox_read(bus_space_tag_t, bus_space_handle_t, uint8_t,
+ uint32_t *);
+void bcm2835_mbox_write(bus_space_tag_t, bus_space_handle_t, uint8_t,
+ uint32_t);
+
void bcmmbox_read(uint8_t, uint32_t *);
void bcmmbox_write(uint8_t, uint32_t);
diff -r a0e0c38adf21 -r 4f579334dfa8 sys/arch/arm/broadcom/bcm2835_mbox_subr.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_mbox_subr.c Wed Aug 22 13:19:47 2012 +0000
@@ -0,0 +1,98 @@
+/* $NetBSD: bcm2835_mbox_subr.c,v 1.1 2012/08/22 13:19:47 jakllsch Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_mbox_subr.c,v 1.1 2012/08/22 13:19:47 jakllsch Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/timetc.h>
+#include <sys/bus.h>
+
+#include <arm/broadcom/bcm_amba.h>
+#include <arm/broadcom/bcm2835_mbox.h>
+#include <arm/broadcom/bcm2835_mboxreg.h>
+#include <arm/broadcom/bcm2835reg.h>
+
+void
+bcm2835_mbox_read(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t chan,
+ uint32_t *data)
+{
+ uint32_t mbox;
+
+ for (;;) {
+ uint8_t rchan;
+ uint32_t rdata;
+
+ bus_space_barrier(iot, ioh, 0,
+ BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_READ);
+
+ if ((bus_space_read_4(iot, ioh,
+ BCM2835_MBOX0_STATUS) & BCM2835_MBOX_STATUS_EMPTY) != 0)
+ continue;
+
+ mbox = bus_space_read_4(iot, ioh,
+ BCM2835_MBOX0_READ);
+
+ rchan = BCM2835_MBOX_CHAN(mbox);
+ rdata = BCM2835_MBOX_DATA(mbox);
+
+ if (rchan == chan) {
+ *data = rdata;
+ return;
+ }
+ }
+}
+
+void
+bcm2835_mbox_write(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t chan,
+ uint32_t data)
+{
+ uint32_t rdata;
+
+ for (;;) {
+
+ bus_space_barrier(iot, ioh, 0,
+ BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_READ);
+
+ if ((rdata = bus_space_read_4(iot, ioh,
+ BCM2835_MBOX0_STATUS) & BCM2835_MBOX_STATUS_FULL) == 0)
+ break;
+ }
+
+ bus_space_write_4(iot, ioh,
+ BCM2835_MBOX1_WRITE, BCM2835_MBOX_MSG(chan, data));
+
+ bus_space_barrier(iot, ioh, 0,
+ BCM2835_MBOX_SIZE, BUS_SPACE_BARRIER_WRITE);
+}
diff -r a0e0c38adf21 -r 4f579334dfa8 sys/arch/arm/broadcom/files.bcm2835
--- a/sys/arch/arm/broadcom/files.bcm2835 Wed Aug 22 12:36:35 2012 +0000
+++ b/sys/arch/arm/broadcom/files.bcm2835 Wed Aug 22 13:19:47 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.bcm2835,v 1.3 2012/08/22 02:16:59 jakllsch Exp $
+# $NetBSD: files.bcm2835,v 1.4 2012/08/22 13:19:47 jakllsch Exp $
#
# Configuration info for Broadcom BCM2835 ARM Peripherals
#
@@ -7,6 +7,7 @@
file arch/arm/arm32/irq_dispatch.S
file arch/arm/broadcom/bcm2835_dma.c
+file arch/arm/broadcom/bcm2835_box_subr.c
# OBIO just an attach point
#, [mult=1], [intrbase=-1], [nobyteacc=0]
Home |
Main Index |
Thread Index |
Old Index