Module Name:    src
Committed By:   martin
Date:           Mon Sep 23 07:09:47 UTC 2019

Modified Files:
        src/sys/arch/dreamcast/dev/g1 [netbsd-9]: wdc_g1.c
        src/sys/arch/evbppc/mpc85xx [netbsd-9]: wdc_obio.c
        src/sys/arch/mips/adm5120/dev [netbsd-9]: wdc_extio.c
        src/sys/arch/mmeye/dev [netbsd-9]: wdc_mainbus.c
        src/sys/dev/ic [netbsd-9]: wdc.c wdcvar.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #232):

        sys/arch/evbppc/mpc85xx/wdc_obio.c: revision 1.7
        sys/arch/dreamcast/dev/g1/wdc_g1.c: revision 1.4
        sys/arch/dreamcast/dev/g1/wdc_g1.c: revision 1.5
        sys/arch/mmeye/dev/wdc_mainbus.c: revision 1.7
        sys/dev/ic/wdcvar.h: revision 1.99
        sys/dev/ic/wdc.c: revision 1.292
        sys/arch/mips/adm5120/dev/wdc_extio.c: revision 1.11

adjust several missed drivers for wdcprobe() changes of ATA NCQ branch
for dreamcast g1 just drop the custom reset function, it doesn't seem to do
anything useful over the generic variant

PR kern/54538 by Izumi Tsutsui

Restore interface to pass a MD reset function to MI wdcprobe().

Fixes silent hang on G1IDE on Dreamcast. PR kern/54538
Should be pulled up to netbsd-9 with the previous changes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.10.1 src/sys/arch/dreamcast/dev/g1/wdc_g1.c
cvs rdiff -u -r1.6 -r1.6.8.1 src/sys/arch/evbppc/mpc85xx/wdc_obio.c
cvs rdiff -u -r1.10 -r1.10.8.1 src/sys/arch/mips/adm5120/dev/wdc_extio.c
cvs rdiff -u -r1.6 -r1.6.8.1 src/sys/arch/mmeye/dev/wdc_mainbus.c
cvs rdiff -u -r1.291 -r1.291.4.1 src/sys/dev/ic/wdc.c
cvs rdiff -u -r1.98 -r1.98.10.1 src/sys/dev/ic/wdcvar.h

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/dreamcast/dev/g1/wdc_g1.c
diff -u src/sys/arch/dreamcast/dev/g1/wdc_g1.c:1.3 src/sys/arch/dreamcast/dev/g1/wdc_g1.c:1.3.10.1
--- src/sys/arch/dreamcast/dev/g1/wdc_g1.c:1.3	Fri Oct 20 07:06:06 2017
+++ src/sys/arch/dreamcast/dev/g1/wdc_g1.c	Mon Sep 23 07:09:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc_g1.c,v 1.3 2017/10/20 07:06:06 jdolecek Exp $ */
+/* $NetBSD: wdc_g1.c,v 1.3.10.1 2019/09/23 07:09:47 martin Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -71,25 +71,14 @@ CFATTACH_DECL_NEW(wdc_g1bus, sizeof(stru
 static int
 wdc_g1_probe(device_t parent, cfdata_t cf, void *aux)
 {
-	struct ata_channel ch;
 	struct g1bus_attach_args *ga = aux;
-	struct wdc_softc wdc;
 	struct wdc_regs wdr;
 	int result = 0, i;
-#ifdef ATADEBUG
-	struct device dev;
-#endif
 
 	*((volatile uint32_t *)0xa05f74e4) = 0x1fffff;
 	for (i = 0; i < 0x200000 / 4; i++)
 		(void)((volatile uint32_t *)0xa0000000)[i];
 
-	memset(&wdc, 0, sizeof(wdc));
-	memset(&ch, 0, sizeof(ch));
-	ch.ch_atac = &wdc.sc_atac;
-	wdc.reset = wdc_g1_do_reset;
-	wdc.regs = &wdr;
-
 	wdr.cmd_iot = ga->ga_memt;
 	if (bus_space_map(wdr.cmd_iot, WDC_G1_CMD_ADDR,
 	    WDC_G1_REG_NPORTS * 4, 0, &wdr.cmd_baseioh))
@@ -101,20 +90,14 @@ wdc_g1_probe(device_t parent, cfdata_t c
 			goto outunmap;
 	}
 
-	wdc_init_shadow_regs(&ch);
+	wdc_init_shadow_regs(&wdr);
 
 	wdr.ctl_iot = ga->ga_memt;
 	if (bus_space_map(wdr.ctl_iot, WDC_G1_CTL_ADDR,
 	    WDC_G1_AUXREG_NPORTS, 0, &wdr.ctl_ioh))
 	  goto outunmap;
 
-#ifdef ATADEBUG
-	/* fake up device name for ATADEBUG_PRINT() with DEBUG_PROBE */
-	memset(&dev, 0, sizeof(dev));
-	strncat(dev.dv_xname, "wdc(g1probe)", sizeof(dev.dv_xname));
-	wdc.sc_atac.atac_dev = &dev;
-#endif
-	result = wdcprobe(&ch);
+	result = wdcprobe_with_reset(&wdr, wdc_g1_do_reset);
 	
 	bus_space_unmap(wdr.ctl_iot, wdr.ctl_ioh, WDC_G1_AUXREG_NPORTS);
  outunmap:
@@ -181,6 +164,12 @@ wdc_g1_intr(void *arg)
 	return wdcintr(arg);
 }
 
+/*
+ * This does what the generic wdc_do_reset() does, with additional
+ * GD-ROM reset. GD-ROM is a very early ATAPI device appeared in 1998
+ * and it doesn't reset itself by the WDCTL_RST in AUX_CTLR but requires
+ * ATAPI_SOFT_RESET command to reset whole device as a master.
+ */
 static void
 wdc_g1_do_reset(struct ata_channel *chp, int poll)
 {

Index: src/sys/arch/evbppc/mpc85xx/wdc_obio.c
diff -u src/sys/arch/evbppc/mpc85xx/wdc_obio.c:1.6 src/sys/arch/evbppc/mpc85xx/wdc_obio.c:1.6.8.1
--- src/sys/arch/evbppc/mpc85xx/wdc_obio.c:1.6	Fri Oct 20 07:06:06 2017
+++ src/sys/arch/evbppc/mpc85xx/wdc_obio.c	Mon Sep 23 07:09:47 2019
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.6 2017/10/20 07:06:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.6.8.1 2019/09/23 07:09:47 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -100,8 +100,6 @@ wdc_obio_match(device_t parent, cfdata_t
 {
 	struct generic_attach_args * const ga = aux;
 	bus_size_t size = ga->ga_size;
-	struct ata_channel ch;
-	struct wdc_softc wdc;
 	struct wdc_regs wdr;
 	struct device dev;
 	int rv = 0;
@@ -115,18 +113,13 @@ wdc_obio_match(device_t parent, cfdata_t
 	 * We need to see if a CF is attached in True-IDE mode
 	 */
 	memset(&dev, 0, sizeof(dev));
-	memset(&wdc, 0, sizeof(wdc));
-	memset(&ch, 0, sizeof(ch));
 	memset(&wdr, 0, sizeof(wdr));
 
 	dev.dv_xname[0] = '?';
-	wdc.sc_atac.atac_dev = &dev;
-	ch.ch_atac = &wdc.sc_atac;
-	wdc.regs = &wdr;
 
 	if (wdc_obio_initregmap(&wdr, ga->ga_bst, ga->ga_addr, size)) {
-		wdc_init_shadow_regs(&ch);
-		rv = wdcprobe(&ch);
+		wdc_init_shadow_regs(&wdr);
+		rv = wdcprobe(&wdr);
 		bus_space_unmap(wdr.cmd_iot, wdr.cmd_baseioh, size);
 	}
 

Index: src/sys/arch/mips/adm5120/dev/wdc_extio.c
diff -u src/sys/arch/mips/adm5120/dev/wdc_extio.c:1.10 src/sys/arch/mips/adm5120/dev/wdc_extio.c:1.10.8.1
--- src/sys/arch/mips/adm5120/dev/wdc_extio.c:1.10	Fri Oct 20 07:06:07 2017
+++ src/sys/arch/mips/adm5120/dev/wdc_extio.c	Mon Sep 23 07:09:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc_extio.c,v 1.10 2017/10/20 07:06:07 jdolecek Exp $ */
+/*	$NetBSD: wdc_extio.c,v 1.10.8.1 2019/09/23 07:09:47 martin Exp $ */
 
 /*-
  * Copyright (c) 2007 David Young.  All rights reserved.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc_extio.c,v 1.10 2017/10/20 07:06:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_extio.c,v 1.10.8.1 2019/09/23 07:09:47 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -156,7 +156,7 @@ wdc_extio_reset(struct ata_channel *chp,
 
 static int
 wdc_extio_map(struct extio_attach_args *ea, struct wdc_regs *wdr,
-    struct ata_channel *chp, void **gpio, struct gpio_pinmap *pinmap)
+    void **gpio, struct gpio_pinmap *pinmap)
 {
 	int i;
 
@@ -200,7 +200,7 @@ wdc_extio_map(struct extio_attach_args *
 		goto post_bus_err;
 	}
 
-	wdc_init_shadow_regs(chp);
+	wdc_init_shadow_regs(wdr);
 
 	return 0;
 post_bus_err:
@@ -234,8 +234,6 @@ int
 wdc_extio_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct extio_attach_args *ea = (struct extio_attach_args *)aux;
-	struct ata_channel ch;
-	struct wdc_softc wdc;
 	struct wdc_regs wdr;
 	int result = 0;
 	void *gpio;
@@ -260,10 +258,10 @@ wdc_extio_match(device_t parent, cfdata_
 		    (WDC_CAPABILITY_PREATA|WDC_CAPABILITY_NO_EXTRA_RESETS);
 	}
 
-	if (wdc_extio_map(ea, &wdr, &ch, &gpio, &pm) == -1)
+	if (wdc_extio_map(ea, &wdr, &gpio, &pm) == -1)
 		return 0;
 
-	result = wdcprobe(&ch);
+	result = wdcprobe(&wdr);
 
 	bus_space_unmap(wdr.cmd_iot, wdr.cmd_baseioh, WDC_OBIO_CF_WINSIZE);
 #if 0
@@ -289,7 +287,7 @@ wdc_extio_attach(device_t parent, device
 	sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;
 	chp->ch_atac = &sc->sc_wdcdev.sc_atac;
 
-	if (wdc_extio_map(ea, wdr, chp, &sc->sc_gpio, &sc->sc_pinmap) == -1)
+	if (wdc_extio_map(ea, wdr, &sc->sc_gpio, &sc->sc_pinmap) == -1)
 		return;
 
 	cf = device_cfdata(sc->sc_wdcdev.sc_atac.atac_dev);

Index: src/sys/arch/mmeye/dev/wdc_mainbus.c
diff -u src/sys/arch/mmeye/dev/wdc_mainbus.c:1.6 src/sys/arch/mmeye/dev/wdc_mainbus.c:1.6.8.1
--- src/sys/arch/mmeye/dev/wdc_mainbus.c:1.6	Fri Oct 20 07:06:07 2017
+++ src/sys/arch/mmeye/dev/wdc_mainbus.c	Mon Sep 23 07:09:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc_mainbus.c,v 1.6 2017/10/20 07:06:07 jdolecek Exp $	*/
+/*	$NetBSD: wdc_mainbus.c,v 1.6.8.1 2019/09/23 07:09:47 martin Exp $	*/
 /*
  * Copyright (c) 2010 KIYOHARA Takashi
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc_mainbus.c,v 1.6 2017/10/20 07:06:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_mainbus.c,v 1.6.8.1 2019/09/23 07:09:47 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -70,8 +70,6 @@ static int
 wdc_mainbus_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
-	struct ata_channel ch;
-	struct wdc_softc wdc;
 	struct wdc_regs wdr;
 	int result = 0, i;
 
@@ -83,11 +81,6 @@ wdc_mainbus_match(device_t parent, cfdat
 	    ma->ma_irq1 == MAINBUSCF_IRQ1_DEFAULT)
 		return 0;
 
-	memset(&wdc, 0, sizeof(wdc));
-	memset(&ch, 0, sizeof(ch));
-	ch.ch_atac = &wdc.sc_atac;
-	wdc.regs = &wdr;
-
 	wdr.cmd_iot = SH3_BUS_SPACE_PCMCIA_IO;
 	if (bus_space_map(wdr.cmd_iot, ma->ma_addr1,
 	    WDC_MAINBUS_REG_NPORTS, 0, &wdr.cmd_baseioh) != 0)
@@ -98,7 +91,7 @@ wdc_mainbus_match(device_t parent, cfdat
 		    i == 0 ? 4 : 1, &wdr.cmd_iohs[i]) != 0)
 			goto outunmap;
 	}
-	wdc_init_shadow_regs(&ch);
+	wdc_init_shadow_regs(&wdr);
 
 	wdr.ctl_iot = SH3_BUS_SPACE_PCMCIA_IO;
 	if (bus_space_map(wdr.ctl_iot, ma->ma_addr1 + WDC_MAINBUS_AUXREG_OFFSET,
@@ -115,7 +108,7 @@ bus_space_write_1(iot, ioh, 0x200, 0x41)
 printf("CF COR=0x%x\n", bus_space_read_1(iot, ioh, 0x200));
 delay(1000000);
 #endif
-	result = wdcprobe(&ch);
+	result = wdcprobe(&wdr);
 
 	bus_space_unmap(wdr.ctl_iot, wdr.ctl_ioh, WDC_MAINBUS_AUXREG_NPORTS);
 outunmap:

Index: src/sys/dev/ic/wdc.c
diff -u src/sys/dev/ic/wdc.c:1.291 src/sys/dev/ic/wdc.c:1.291.4.1
--- src/sys/dev/ic/wdc.c:1.291	Sat Oct 27 05:38:08 2018
+++ src/sys/dev/ic/wdc.c	Mon Sep 23 07:09:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.291 2018/10/27 05:38:08 maya Exp $ */
+/*	$NetBSD: wdc.c,v 1.291.4.1 2019/09/23 07:09:47 martin Exp $ */
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.291 2018/10/27 05:38:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.291.4.1 2019/09/23 07:09:47 martin Exp $");
 
 #include "opt_ata.h"
 #include "opt_wdc.h"
@@ -477,6 +477,14 @@ wdc_drvprobe(struct ata_channel *chp)
 int
 wdcprobe(struct wdc_regs *wdr)
 {
+
+	return wdcprobe_with_reset(wdr, NULL);
+}
+
+int
+wdcprobe_with_reset(struct wdc_regs *wdr,
+    void (*do_reset)(struct ata_channel *, int))
+{
 	struct wdc_softc wdc;
 	struct ata_channel ch;
 	int rv;
@@ -487,9 +495,8 @@ wdcprobe(struct wdc_regs *wdr)
 	ch.ch_atac = &wdc.sc_atac;
 	wdc.regs = wdr;
 
-	/* default reset method */
-	if (wdc.reset == NULL)
-		wdc.reset = wdc_do_reset;
+	/* check the MD reset method */
+	wdc.reset = (do_reset != NULL) ? do_reset : wdc_do_reset;
 
 	rv = wdcprobe1(&ch, 1);
 

Index: src/sys/dev/ic/wdcvar.h
diff -u src/sys/dev/ic/wdcvar.h:1.98 src/sys/dev/ic/wdcvar.h:1.98.10.1
--- src/sys/dev/ic/wdcvar.h:1.98	Sat Oct  7 16:05:32 2017
+++ src/sys/dev/ic/wdcvar.h	Mon Sep 23 07:09:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdcvar.h,v 1.98 2017/10/07 16:05:32 jdolecek Exp $	*/
+/*	$NetBSD: wdcvar.h,v 1.98.10.1 2019/09/23 07:09:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -145,6 +145,8 @@ void	wdc_allocate_regs(struct wdc_softc 
 void	wdc_init_shadow_regs(struct wdc_regs *);
 
 int	wdcprobe(struct wdc_regs *);
+int	wdcprobe_with_reset(struct wdc_regs *,
+	    void (*)(struct ata_channel *, int));
 void	wdcattach(struct ata_channel *);
 int	wdcdetach(device_t, int);
 void	wdc_childdetached(device_t, device_t);

Reply via email to