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 allow for a single board specific devi...
details: https://anonhg.NetBSD.org/src/rev/476e86977902
branches: trunk
changeset: 783755:476e86977902
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Jan 07 20:15:32 2013 +0000
description:
allow for a single board specific device to attach to the mbox driver
diffstat:
sys/arch/arm/broadcom/bcm2835_mbox.c | 60 ++++++++++++++++++++++++++++++++++-
sys/arch/arm/broadcom/bcm2835_mbox.h | 8 ++++-
sys/arch/arm/broadcom/files.bcm2835 | 6 ++-
3 files changed, 69 insertions(+), 5 deletions(-)
diffs (154 lines):
diff -r 71980160c109 -r 476e86977902 sys/arch/arm/broadcom/bcm2835_mbox.c
--- a/sys/arch/arm/broadcom/bcm2835_mbox.c Mon Jan 07 17:03:06 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_mbox.c Mon Jan 07 20:15:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_mbox.c,v 1.2 2012/08/22 13:19:47 jakllsch Exp $ */
+/* $NetBSD: bcm2835_mbox.c,v 1.3 2013/01/07 20:15:32 jmcneill 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.2 2012/08/22 13:19:47 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_mbox.c,v 1.3 2013/01/07 20:15:32 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -46,9 +46,11 @@
struct bcm2835mbox_softc {
device_t sc_dev;
+ device_t sc_platdev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
+ bus_dma_tag_t sc_dmat;
};
static struct bcm2835mbox_softc *bcm2835mbox_sc;
@@ -76,6 +78,7 @@
{
struct bcm2835mbox_softc *sc = device_private(self);
struct amba_attach_args *aaa = aux;
+ struct bcmmbox_attach_args baa;
aprint_naive("\n");
aprint_normal(": VC mailbox\n");
@@ -85,12 +88,16 @@
sc->sc_dev = self;
sc->sc_iot = aaa->aaa_iot;
+ sc->sc_dmat = aaa->aaa_dmat;
if (bus_space_map(aaa->aaa_iot, aaa->aaa_addr, BCM2835_MBOX_SIZE, 0,
&sc->sc_ioh)) {
aprint_error_dev(sc->sc_dev, "unable to map device\n");
return;
}
+
+ baa.baa_dmat = aaa->aaa_dmat;
+ sc->sc_platdev = config_found_ia(self, "bcmmboxbus", &baa, NULL);
}
void
@@ -112,3 +119,52 @@
return bcm2835_mbox_write(sc->sc_iot, sc->sc_ioh, chan, data);
}
+
+int
+bcmmbox_request(uint8_t chan, void *buf, size_t buflen, uint32_t *pres)
+{
+ struct bcm2835mbox_softc *sc = bcm2835mbox_sc;
+ void *dma_buf;
+ bus_dmamap_t map;
+ bus_dma_segment_t segs[1];
+ int nsegs;
+ int error;
+
+ KASSERT(sc != NULL);
+
+ error = bus_dmamem_alloc(sc->sc_dmat, buflen, 16, 0, segs, 1,
+ &nsegs, BUS_DMA_WAITOK);
+ if (error)
+ return error;
+ error = bus_dmamem_map(sc->sc_dmat, segs, nsegs, buflen, &dma_buf,
+ BUS_DMA_WAITOK);
+ if (error)
+ goto map_failed;
+ error = bus_dmamap_create(sc->sc_dmat, buflen, 1, buflen, 0,
+ BUS_DMA_WAITOK, &map);
+ if (error)
+ goto create_failed;
+ error = bus_dmamap_load(sc->sc_dmat, map, dma_buf, buflen, NULL,
+ BUS_DMA_WAITOK);
+ if (error)
+ goto load_failed;
+
+ memcpy(dma_buf, buf, buflen);
+
+ bus_dmamap_sync(sc->sc_dmat, map, 0, buflen, BUS_DMASYNC_PREWRITE);
+ bcmmbox_write(chan, map->dm_segs[0].ds_addr);
+ bus_dmamap_sync(sc->sc_dmat, map, 0, buflen, BUS_DMASYNC_POSTWRITE);
+ bus_dmamap_sync(sc->sc_dmat, map, 0, buflen, BUS_DMASYNC_PREREAD);
+ bcmmbox_read(chan, pres);
+
+ memcpy(buf, dma_buf, buflen);
+
+ bus_dmamap_unload(sc->sc_dmat, map);
+load_failed:
+ bus_dmamap_destroy(sc->sc_dmat, map);
+create_failed:
+ bus_dmamem_unmap(sc->sc_dmat, dma_buf, buflen);
+map_failed:
+ bus_dmamem_free(sc->sc_dmat, segs, nsegs);
+ return error;
+}
diff -r 71980160c109 -r 476e86977902 sys/arch/arm/broadcom/bcm2835_mbox.h
--- a/sys/arch/arm/broadcom/bcm2835_mbox.h Mon Jan 07 17:03:06 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_mbox.h Mon Jan 07 20:15:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_mbox.h,v 1.3 2012/10/13 08:42:50 skrll Exp $ */
+/* $NetBSD: bcm2835_mbox.h,v 1.4 2013/01/07 20:15:32 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -42,4 +42,10 @@
void bcmmbox_read(uint8_t, uint32_t *);
void bcmmbox_write(uint8_t, uint32_t);
+int bcmmbox_request(uint8_t, void *, size_t, uint32_t *);
+
+struct bcmmbox_attach_args {
+ bus_dma_tag_t baa_dmat;
+};
+
#endif /* _BCM2835_MBOX_H_ */
diff -r 71980160c109 -r 476e86977902 sys/arch/arm/broadcom/files.bcm2835
--- a/sys/arch/arm/broadcom/files.bcm2835 Mon Jan 07 17:03:06 2013 +0000
+++ b/sys/arch/arm/broadcom/files.bcm2835 Mon Jan 07 20:15:32 2013 +0000
@@ -1,10 +1,12 @@
-# $NetBSD: files.bcm2835,v 1.8 2013/01/05 20:31:23 jakllsch Exp $
+# $NetBSD: files.bcm2835,v 1.9 2013/01/07 20:15:32 jmcneill Exp $
#
# Configuration info for Broadcom BCM2835 ARM Peripherals
#
include "arch/arm/pic/files.pic"
+define bcmmboxbus { }
+
file arch/arm/arm32/irq_dispatch.S
file arch/arm/broadcom/bcm2835_dma.c
file arch/arm/broadcom/bcm2835_mbox_subr.c
@@ -26,7 +28,7 @@
file arch/arm/broadcom/bcm2835_intr.c bcmicu
# VC Mailbox (BCM2835_ARMMBOX_BASE)
-device bcmmbox
+device bcmmbox: bcmmboxbus
attach bcmmbox at obio with bcmmbox
file arch/arm/broadcom/bcm2835_mbox.c bcmmbox
Home |
Main Index |
Thread Index |
Old Index