Module Name:    src
Committed By:   isaki
Date:           Fri Aug 11 07:08:40 UTC 2017

Modified Files:
        src/sys/arch/x68k/dev: dmacvar.h fd.c intio_dmac.c vs.c

Log Message:
Allow dmac_alloc_channel() to specify DCR and OCR.
FDC uses 'Cycle Steal Mode with Hold' but ADPCM
should use 'Cycle Steal Mode without Hold' on x68k.
>From Y.Suhagara and it was found by XM6i.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/dev/dmacvar.h
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/x68k/dev/fd.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x68k/dev/intio_dmac.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x68k/dev/vs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/dev/dmacvar.h
diff -u src/sys/arch/x68k/dev/dmacvar.h:1.10 src/sys/arch/x68k/dev/dmacvar.h:1.11
--- src/sys/arch/x68k/dev/dmacvar.h:1.10	Wed Jun 25 13:30:24 2008
+++ src/sys/arch/x68k/dev/dmacvar.h	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmacvar.h,v 1.10 2008/06/25 13:30:24 isaki Exp $	*/
+/*	$NetBSD: dmacvar.h,v 1.11 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -99,9 +99,14 @@ struct dmac_softc {
 #define DMAC_MAXSEGSZ	0xff00
 #define DMAC_BOUNDARY	0
 
-struct dmac_channel_stat *dmac_alloc_channel(device_t, int, const char *,
-	int, dmac_intr_handler_t, void *, int, dmac_intr_handler_t, void *);
-		/* ch, name, normalv, normal, errorv, error */
+struct dmac_channel_stat *dmac_alloc_channel(device_t,
+	int,		/* ch */
+	const char *,	/* name */
+	int, dmac_intr_handler_t, void *,	/* normal handler */
+	int, dmac_intr_handler_t, void *,	/* error handler */
+	uint8_t,	/* dcr */
+	uint8_t		/* ocr */
+);
 int dmac_free_channel(device_t, int, void *);
 		/* ch, channel */
 struct dmac_dma_xfer *dmac_alloc_xfer(struct dmac_channel_stat *,

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.119 src/sys/arch/x68k/dev/fd.c:1.120
--- src/sys/arch/x68k/dev/fd.c:1.119	Thu Jan 12 14:24:53 2017
+++ src/sys/arch/x68k/dev/fd.c	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $	*/
+/*	$NetBSD: fd.c,v 1.120 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.120 2017/08/11 07:08:40 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -487,7 +487,10 @@ fdcattach(device_t parent, device_t self
 	/* Initialize DMAC channel */
 	fdc->sc_dmachan = dmac_alloc_channel(parent, ia->ia_dma, "fdc",
 	    ia->ia_dmaintr, fdcdmaintr, fdc,
-	    ia->ia_dmaintr + 1, fdcdmaerrintr, fdc);
+	    ia->ia_dmaintr + 1, fdcdmaerrintr, fdc,
+	    (DMAC_DCR_XRM_CSWH | DMAC_DCR_OTYP_EASYNC | DMAC_DCR_OPS_8BIT),
+	    (DMAC_OCR_SIZE_BYTE | DMAC_OCR_REQG_EXTERNAL));
+
 	if (bus_dmamap_create(fdc->sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
 	    0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &fdc->sc_dmamap)) {
 		aprint_error_dev(self, "can't set up intio DMA map\n");

Index: src/sys/arch/x68k/dev/intio_dmac.c
diff -u src/sys/arch/x68k/dev/intio_dmac.c:1.35 src/sys/arch/x68k/dev/intio_dmac.c:1.36
--- src/sys/arch/x68k/dev/intio_dmac.c:1.35	Wed Mar 26 08:17:59 2014
+++ src/sys/arch/x68k/dev/intio_dmac.c	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio_dmac.c,v 1.35 2014/03/26 08:17:59 christos Exp $	*/
+/*	$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.35 2014/03/26 08:17:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -159,9 +159,10 @@ dmac_init_channels(struct dmac_softc *sc
  * Channel initialization/deinitialization per user device.
  */
 struct dmac_channel_stat *
-dmac_alloc_channel(device_t self, int ch, const char *name, int normalv,
-    dmac_intr_handler_t normal, void *normalarg, int errorv,
-    dmac_intr_handler_t error, void *errorarg)
+dmac_alloc_channel(device_t self, int ch, const char *name,
+    int normalv, dmac_intr_handler_t normal, void *normalarg,
+    int errorv,  dmac_intr_handler_t error,  void *errorarg,
+    uint8_t dcr, uint8_t ocr)
 {
 	struct intio_softc *intio = device_private(self);
 	struct dmac_softc *dmac = device_private(intio->sc_dmac);
@@ -201,9 +202,8 @@ dmac_alloc_channel(device_t self, int ch
 
 	/* fill the channel status structure by the default values. */
 	strcpy(chan->ch_name, name);
-	chan->ch_dcr = (DMAC_DCR_XRM_CSWH | DMAC_DCR_OTYP_EASYNC |
-			DMAC_DCR_OPS_8BIT);
-	chan->ch_ocr = (DMAC_OCR_SIZE_BYTE | DMAC_OCR_REQG_EXTERNAL);
+	chan->ch_dcr = dcr;
+	chan->ch_ocr = ocr;
 	chan->ch_normalv = normalv;
 	chan->ch_errorv = errorv;
 	chan->ch_normal = normal;
@@ -217,6 +217,7 @@ dmac_alloc_channel(device_t self, int ch
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht,
 			   DMAC_REG_DCR, chan->ch_dcr);
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CPR, 0);
+	/* OCR will be written at dmac_load_xfer() */
 
 	/*
 	 * X68k physical user space is a subset of the kernel space;

Index: src/sys/arch/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.45 src/sys/arch/x68k/dev/vs.c:1.46
--- src/sys/arch/x68k/dev/vs.c:1.45	Fri Aug 11 06:47:35 2017
+++ src/sys/arch/x68k/dev/vs.c	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.45 2017/08/11 06:47:35 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.46 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.45 2017/08/11 06:47:35 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.46 2017/08/11 07:08:40 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -235,7 +235,9 @@ vs_attach(device_t parent, device_t self
 	sc->sc_dmat = ia->ia_dmat;
 	sc->sc_dma_ch = dmac_alloc_channel(parent, ia->ia_dma, "vs",
 		ia->ia_dmaintr,   vs_dmaintr, sc,
-		ia->ia_dmaintr+1, vs_dmaerrintr, sc);
+		ia->ia_dmaintr+1, vs_dmaerrintr, sc,
+		(DMAC_DCR_XRM_CSWOH | DMAC_DCR_OTYP_EASYNC | DMAC_DCR_OPS_8BIT),
+		(DMAC_OCR_SIZE_BYTE | DMAC_OCR_REQG_EXTERNAL));
 
 	aprint_normal_dev(self, "MSM6258V ADPCM voice synthesizer\n");
 
@@ -517,9 +519,6 @@ vs_start_output(void *hdl, void *block, 
 	vd = sc->sc_dmas;
 
 	chan = sc->sc_dma_ch;
-	chan->ch_dcr = (DMAC_DCR_XRM_CSWOH | DMAC_DCR_OTYP_EASYNC |
-			DMAC_DCR_OPS_8BIT);
-	chan->ch_ocr = DMAC_OCR_REQG_EXTERNAL;
 
 	sc->sc_current.xfer = dmac_prepare_xfer(chan, sc->sc_dmat, vd->vd_map,
 	    DMAC_OCR_DIR_MTD,
@@ -565,9 +564,6 @@ vs_start_input(void *hdl, void *block, i
 	vd = sc->sc_dmas;
 
 	chan = sc->sc_dma_ch;
-	chan->ch_dcr = (DMAC_DCR_XRM_CSWOH | DMAC_DCR_OTYP_EASYNC |
-			DMAC_DCR_OPS_8BIT);
-	chan->ch_ocr = DMAC_OCR_REQG_EXTERNAL;
 
 	sc->sc_current.xfer = dmac_prepare_xfer(chan, sc->sc_dmat, vd->vd_map,
 	    DMAC_OCR_DIR_DTM,

Reply via email to