Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/imx From Petri Laakso <petri.laakso%asd.fi@localhost>:
details: https://anonhg.NetBSD.org/src/rev/cb011d8ba026
branches: trunk
changeset: 335496:cb011d8ba026
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Jan 10 12:13:00 2015 +0000
description:
>From Petri Laakso <petri.laakso%asd.fi@localhost>:
- Fix typo: AHBH should be APBH
- Add support for APBX DMA
- New function apbdma_wait(); wait for DMA completion
diffstat:
sys/arch/arm/imx/imx23_apbdma.c | 66 ++++++++++++++++++++++++++++---------
sys/arch/arm/imx/imx23_apbdmareg.h | 4 +-
sys/arch/arm/imx/imx23_apbdmavar.h | 7 ++-
3 files changed, 56 insertions(+), 21 deletions(-)
diffs (181 lines):
diff -r f8b8ca5214cc -r cb011d8ba026 sys/arch/arm/imx/imx23_apbdma.c
--- a/sys/arch/arm/imx/imx23_apbdma.c Sat Jan 10 12:11:39 2015 +0000
+++ b/sys/arch/arm/imx/imx23_apbdma.c Sat Jan 10 12:13:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $Id: imx23_apbdma.c,v 1.3 2013/03/03 10:33:56 jkunz Exp $ */
+/* $Id: imx23_apbdma.c,v 1.4 2015/01/10 12:13:00 jmcneill Exp $ */
/*
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -92,10 +92,10 @@
static u_int apbdma_attached = 0;
if ((strncmp(device_xname(parent), "apbh", 4) == 0) &&
- (apbdma_attached & F_AHBH_DMA))
+ (apbdma_attached & F_APBH_DMA))
return;
if ((strncmp(device_xname(parent), "apbx", 4) == 0) &&
- (apbdma_attached & F_AHBX_DMA))
+ (apbdma_attached & F_APBX_DMA))
return;
sc->sc_dev = self;
@@ -109,25 +109,30 @@
}
if (strncmp(device_xname(parent), "apbh", 4) == 0)
- sc->flags = F_AHBH_DMA;
+ sc->flags = F_APBH_DMA;
if (strncmp(device_xname(parent), "apbx", 4) == 0)
- sc->flags = F_AHBX_DMA;
+ sc->flags = F_APBX_DMA;
apbdma_reset(sc);
apbdma_init(sc);
- if (sc->flags & F_AHBH_DMA)
- apbdma_attached |= F_AHBH_DMA;
- if (sc->flags & F_AHBX_DMA)
- apbdma_attached |= F_AHBX_DMA;
+ if (sc->flags & F_APBH_DMA)
+ apbdma_attached |= F_APBH_DMA;
+ if (sc->flags & F_APBX_DMA)
+ apbdma_attached |= F_APBX_DMA;
sc_parent->dmac = self;
/* Initialize mutex to control concurrent access from the drivers. */
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_HIGH);
- aprint_normal("\n");
+ if (sc->flags & F_APBH_DMA)
+ aprint_normal(": APBH DMA\n");
+ else if (sc->flags & F_APBX_DMA)
+ aprint_normal(": APBX DMA\n");
+ else
+ panic("dma flag missing!\n");
return;
}
@@ -192,7 +197,7 @@
apbdma_init(struct apbdma_softc *sc)
{
- if (sc->flags & F_AHBH_DMA) {
+ if (sc->flags & F_APBH_DMA) {
DMA_WR(sc, HW_APBH_CTRL0_SET, HW_APBH_CTRL0_AHB_BURST8_EN);
DMA_WR(sc, HW_APBH_CTRL0_SET, HW_APBH_CTRL0_APB_BURST4_EN);
}
@@ -279,7 +284,7 @@
{
uint32_t reg;
- if (sc->flags & F_AHBH_DMA)
+ if (sc->flags & F_APBH_DMA)
reg = HW_APB_CHN_NXTCMDAR(HW_APBH_CH0_NXTCMDAR, channel);
else
reg = HW_APB_CHN_NXTCMDAR(HW_APBX_CH0_NXTCMDAR, channel);
@@ -301,7 +306,7 @@
uint32_t reg;
uint8_t val;
- if (sc->flags & F_AHBH_DMA) {
+ if (sc->flags & F_APBH_DMA) {
reg = HW_APB_CHN_SEMA(HW_APBH_CH0_SEMA, channel);
val = __SHIFTIN(1, HW_APBH_CH0_SEMA_INCREMENT_SEMA);
} else {
@@ -324,7 +329,11 @@
{
mutex_enter(&sc->sc_lock);
- DMA_WR(sc, HW_APB_CTRL1_CLR, (1<<channel));
+ if (sc->flags & F_APBH_DMA) {
+ DMA_WR(sc, HW_APB_CTRL1_CLR, (1<<channel));
+ } else {
+ DMA_WR(sc, HW_APB_CTRL1_CLR, (1<<channel));
+ }
mutex_exit(&sc->sc_lock);
return;
@@ -383,11 +392,34 @@
mutex_enter(&sc->sc_lock);
- DMA_WR(sc, HW_APB_CTRL0_SET,
- __SHIFTIN((1<<channel), HW_APBH_CTRL0_RESET_CHANNEL));
- while(DMA_RD(sc, HW_APB_CTRL0) & HW_APBH_CTRL0_RESET_CHANNEL);
+ if (sc->flags & F_APBH_DMA) {
+ DMA_WR(sc, HW_APB_CTRL0_SET,
+ __SHIFTIN((1<<channel), HW_APBH_CTRL0_RESET_CHANNEL));
+ while(DMA_RD(sc, HW_APB_CTRL0) & HW_APBH_CTRL0_RESET_CHANNEL);
+ } else {
+ DMA_WR(sc, HW_APBX_CHANNEL_CTRL_SET,
+ __SHIFTIN((1<<channel), HW_APBH_CTRL0_RESET_CHANNEL));
+ while(DMA_RD(sc, HW_APBX_CHANNEL_CTRL) & (1<<channel));
+ }
mutex_exit(&sc->sc_lock);
return;
}
+
+void
+apbdma_wait(struct apbdma_softc *sc, unsigned int channel)
+{
+
+ mutex_enter(&sc->sc_lock);
+
+ if (sc->flags & F_APBH_DMA) {
+ while (DMA_RD(sc, HW_APB_CHN_SEMA(HW_APBH_CH0_SEMA, channel)) & HW_APBH_CH0_SEMA_PHORE)
+ ;
+ } else {
+ while (DMA_RD(sc, HW_APB_CHN_SEMA(HW_APBX_CH0_SEMA, channel)) & HW_APBX_CH0_SEMA_PHORE)
+ ;
+ }
+
+ mutex_exit(&sc->sc_lock);
+}
diff -r f8b8ca5214cc -r cb011d8ba026 sys/arch/arm/imx/imx23_apbdmareg.h
--- a/sys/arch/arm/imx/imx23_apbdmareg.h Sat Jan 10 12:11:39 2015 +0000
+++ b/sys/arch/arm/imx/imx23_apbdmareg.h Sat Jan 10 12:13:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $Id: imx23_apbdmareg.h,v 1.2 2013/03/03 10:33:56 jkunz Exp $ */
+/* $Id: imx23_apbdmareg.h,v 1.3 2015/01/10 12:13:00 jmcneill Exp $ */
/*
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -66,4 +66,6 @@
#define HW_APB_CTRL2_CLR 0x028
#define HW_APB_CTRL2_TOG 0x02C
+#define HW_APBX_CHANNEL_CTRL 0x30
+#define HW_APBX_CHANNEL_CTRL_SET 0x34
#endif /* !_ARM_IMX_IMX23_APBDMAREG_H_ */
diff -r f8b8ca5214cc -r cb011d8ba026 sys/arch/arm/imx/imx23_apbdmavar.h
--- a/sys/arch/arm/imx/imx23_apbdmavar.h Sat Jan 10 12:11:39 2015 +0000
+++ b/sys/arch/arm/imx/imx23_apbdmavar.h Sat Jan 10 12:13:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $Id: imx23_apbdmavar.h,v 1.1 2013/03/03 10:33:56 jkunz Exp $ */
+/* $Id: imx23_apbdmavar.h,v 1.2 2015/01/10 12:13:00 jmcneill Exp $ */
/*
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -58,8 +58,8 @@
#define APBDMA_CMD_DMA_SENSE 3
/* Flags. */
-#define F_AHBH_DMA __BIT(0)
-#define F_AHBX_DMA __BIT(1)
+#define F_APBH_DMA __BIT(0)
+#define F_APBX_DMA __BIT(1)
/* Number of channels. */
#define AHBH_DMA_CHANNELS 8
@@ -133,5 +133,6 @@
void apbdma_ack_error_intr(struct apbdma_softc *, unsigned int);
unsigned int apbdma_intr_status(struct apbdma_softc *, unsigned int);
void apbdma_chan_reset(struct apbdma_softc *, unsigned int);
+void apbdma_wait(struct apbdma_softc *, unsigned int);
#endif /* !_ARM_IMX_IMX23_APBDMAVAR_H_ */
Home |
Main Index |
Thread Index |
Old Index