Module Name:    src
Committed By:   tsutsui
Date:           Sun Apr 23 06:58:00 UTC 2023

Modified Files:
        src/sys/arch/luna68k/dev: spc.c
        src/sys/arch/luna68k/luna68k: mainbus.c

Log Message:
Explicitly check machine type (LUNA-II) on secondary spc(4) probe.

So that individual mainbus_attach_args for both LUNA and LUNA-II
are no longer necessary.
While here, use proper address macro in <machine/board.h>.

Tested on both LUNA and LUNA-II.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/luna68k/dev/spc.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/luna68k/luna68k/mainbus.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/luna68k/dev/spc.c
diff -u src/sys/arch/luna68k/dev/spc.c:1.10 src/sys/arch/luna68k/dev/spc.c:1.11
--- src/sys/arch/luna68k/dev/spc.c:1.10	Tue Jan 22 15:44:25 2013
+++ src/sys/arch/luna68k/dev/spc.c	Sun Apr 23 06:57:59 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: spc.c,v 1.10 2013/01/22 15:44:25 tsutsui Exp $ */
+/* $NetBSD: spc.c,v 1.11 2023/04/23 06:57:59 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.10 2013/01/22 15:44:25 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.11 2023/04/23 06:57:59 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.10
 #include <machine/bus.h>
 #include <machine/cpu.h>
 #include <machine/autoconf.h>
+#include <machine/board.h>
 
 #include <dev/scsipi/scsi_all.h>
 #include <dev/scsipi/scsipi_all.h>
@@ -66,11 +67,17 @@ spc_mainbus_match(device_t parent, cfdat
 
 	if (strcmp(ma->ma_name, spc_cd.cd_name))
 		return 0;
-#if 0
-	if (badaddr((void *)ma->ma_addr, 4))
+
+	/*
+	 * LUNA-I doesn't have the secondary SCSI.
+	 * However we cannot check it by badaddr() at the address range
+	 * of the secondary SCSI on LUNA-II because the address bus lines
+	 * are not fully decoded on LUNA-I and the primary SCSI registers
+	 * are also accessible at the seconadary address range.
+	 */
+	if (machtype == LUNA_I && ma->ma_addr != SCSI_ADDR)
 		return 0;
-	/* Experiments proved 2nd SPC address does NOT make a buserror. */
-#endif
+
 	return 1;
 }
 

Index: src/sys/arch/luna68k/luna68k/mainbus.c
diff -u src/sys/arch/luna68k/luna68k/mainbus.c:1.20 src/sys/arch/luna68k/luna68k/mainbus.c:1.21
--- src/sys/arch/luna68k/luna68k/mainbus.c:1.20	Thu Apr 13 11:44:10 2023
+++ src/sys/arch/luna68k/luna68k/mainbus.c	Sun Apr 23 06:57:59 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.20 2023/04/13 11:44:10 tsutsui Exp $ */
+/* $NetBSD: mainbus.c,v 1.21 2023/04/23 06:57:59 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2023/04/13 11:44:10 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.21 2023/04/23 06:57:59 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -39,26 +39,17 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 
 
 #include <machine/cpu.h>
 #include <machine/autoconf.h>
+#include <machine/board.h>
 
 static const struct mainbus_attach_args luna_devs[] = {
-	{ "clock",  0x45000000, -1 },	/* Mostek TimeKeeper */
-	{ "lcd",    0x4d000000, -1 },	/* Sharp LM16X212 LCD module */
-	{ "le",     0xf1000000, 3 },	/* Am7990 */
-	{ "sio",    0x51000000, 6 },	/* uPD7201A */
-	{ "xpbus",  0x71000000, -1 },	/* HD647180XP */
-	{ "fb",     0xc1100000, -1 },	/* BrookTree RAMDAC */
-	{ "spc",    0xe1000000, 2 },	/* MB89352 */
-};
-
-static const struct mainbus_attach_args luna2_devs[] = {
-	{ "clock",  0x45000000, -1 },	/* Dallas TimeKeeper */
-	{ "lcd",    0x4d000000, -1 },	/* Sharp LM16X212 LCD module */
-	{ "le",     0xf1000000, 3 },	/* Am7990 */
-	{ "sio",    0x51000000, 6 },	/* uPD7201A */
-	{ "xpbus",  0x71000000, -1 },	/* HD647180XP */
-	{ "fb",     0xc1100000, -1 },	/* BrookTree RAMDAC */
-	{ "spc",    0xe1000000, 2 },	/* internal MB89352 */
-	{ "spc",    0xe1000040, 2 },	/* external MB89352 */
+	{ "clock",  NVRAM_ADDR, -1 },	/* Mostek/Dallas TimeKeeper */
+	{ "lcd",    OBIO_PIO1A, -1 },	/* Sharp LM16X212 LCD module */
+	{ "le",     LANCE_ADDR, 3 },	/* Am7990 */
+	{ "sio",    OBIO_SIO, 6 },	/* uPD7201A */
+	{ "xpbus",  TRI_PORT_RAM, -1 },	/* HD647180XP */
+	{ "fb",     BMAP_PALLET2, -1 },	/* BrookTree RAMDAC */
+	{ "spc",    SCSI_ADDR, 2 },	/* internal MB89352 */
+	{ "spc",    SCSI_2_ADDR, 2 },	/* external MB89352 (on LUNA-II) */
 };
 
 static void mainbus_attach(device_t, device_t, void *);
@@ -87,13 +78,9 @@ mainbus_attach(device_t parent, device_t
 	const struct mainbus_attach_args *devs;
 	struct mainbus_attach_args ma;
 
-	if (machtype == LUNA_II) {
-		devs = luna2_devs;
-		ndevs = __arraycount(luna2_devs);
-	} else {
-		devs = luna_devs;
-		ndevs = __arraycount(luna_devs);
-	}
+	devs = luna_devs;
+	ndevs = __arraycount(luna_devs);
+
 	aprint_normal("\n");
 	for (i = 0; i < ndevs; i++) {
 		ma = devs[i];

Reply via email to