CVS commit: src/sys/arch/sgimips/hpc

2023-12-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec  5 21:54:53 UTC 2023

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
add explicit braces around SQ_DPRINTF() to fix dangling else compiler error.

fixes build with SQ_DEBUG option enabled for sgimips.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sgimips/hpc/if_sq.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/sgimips/hpc/if_sq.c
diff -u src/sys/arch/sgimips/hpc/if_sq.c:1.55 src/sys/arch/sgimips/hpc/if_sq.c:1.56
--- src/sys/arch/sgimips/hpc/if_sq.c:1.55	Sun Sep 18 13:23:53 2022
+++ src/sys/arch/sgimips/hpc/if_sq.c	Tue Dec  5 21:54:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sq.c,v 1.55 2022/09/18 13:23:53 thorpej Exp $	*/
+/*	$NetBSD: if_sq.c,v 1.56 2023/12/05 21:54:53 andvar Exp $	*/
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.55 2022/09/18 13:23:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.56 2023/12/05 21:54:53 andvar Exp $");
 
 
 #include 
@@ -896,10 +896,10 @@ sq_intr(void *arg)
 
 	stat = sq_hpc_read(sc, sc->hpc_regs->enetr_reset);
 
-	if ((stat & 2) == 0)
+	if ((stat & 2) == 0) {
 		SQ_DPRINTF(("%s: Unexpected interrupt!\n",
 		device_xname(sc->sc_dev)));
-	else
+	} else
 		sq_hpc_write(sc, sc->hpc_regs->enetr_reset, (stat | 2));
 
 	/*



CVS commit: src/sys/arch/sgimips/hpc

2023-12-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec  5 21:54:53 UTC 2023

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
add explicit braces around SQ_DPRINTF() to fix dangling else compiler error.

fixes build with SQ_DEBUG option enabled for sgimips.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sgimips/hpc/if_sq.c

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



CVS commit: src/sys/arch/sgimips/hpc

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 13:23:53 UTC 2022

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sgimips/hpc/if_sq.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/sgimips/hpc/if_sq.c
diff -u src/sys/arch/sgimips/hpc/if_sq.c:1.54 src/sys/arch/sgimips/hpc/if_sq.c:1.55
--- src/sys/arch/sgimips/hpc/if_sq.c:1.54	Thu Jan 30 06:25:46 2020
+++ src/sys/arch/sgimips/hpc/if_sq.c	Sun Sep 18 13:23:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sq.c,v 1.54 2020/01/30 06:25:46 martin Exp $	*/
+/*	$NetBSD: if_sq.c,v 1.55 2022/09/18 13:23:53 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.54 2020/01/30 06:25:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.55 2022/09/18 13:23:53 thorpej Exp $");
 
 
 #include 
@@ -456,7 +456,6 @@ sq_init(struct ifnet *ifp)
 		sq_hpc_write(sc, HPC1_ENET_INTDELAY, HPC1_ENET_INTDELAY_OFF);
 
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
 
 	return 0;
 }
@@ -535,7 +534,7 @@ sq_start(struct ifnet *ifp)
 	bus_dmamap_t dmamap;
 	int err, totlen, nexttx, firsttx, lasttx = -1, ofree, seg;
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
 	/*
@@ -619,13 +618,11 @@ sq_start(struct ifnet *ifp)
 			 * Not enough free descriptors to transmit this
 			 * packet.  We haven't committed to anything yet,
 			 * so just unload the DMA map, put the packet
-			 * back on the queue, and punt.  Notify the upper
-			 * layer that there are no more slots left.
+			 * back on the queue, and punt.
 			 *
 			 * XXX We could allocate an mbuf and copy, but
 			 * XXX it is worth it?
 			 */
-			ifp->if_flags |= IFF_OACTIVE;
 			bus_dmamap_unload(sc->sc_dmat, dmamap);
 			if (m != NULL)
 m_freem(m);
@@ -719,10 +716,6 @@ sq_start(struct ifnet *ifp)
 		sc->sc_nexttx = nexttx;
 	}
 
-	/* All transmit descriptors used up, let upper layers know */
-	if (sc->sc_nfreetx == 0)
-		ifp->if_flags |= IFF_OACTIVE;
-
 	if (sc->sc_nfreetx != ofree) {
 		SQ_DPRINTF(("%s: %d packets enqueued, first %d, INTR on %d\n",
 		device_xname(sc->sc_dev), lasttx - firsttx + 1,
@@ -839,7 +832,7 @@ sq_stop(struct ifnet *ifp, int disable)
 
 	sq_reset(sc);
 
-	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	ifp->if_flags &= ~IFF_RUNNING;
 	ifp->if_timer = 0;
 }
 
@@ -1101,10 +1094,6 @@ sq_txintr(struct sq_softc *sc)
 	else
 		sq_txring_hpc1(sc);
 
-	/* If we have buffers free, let upper layers know */
-	if (sc->sc_nfreetx > 0)
-		ifp->if_flags &= ~IFF_OACTIVE;
-
 	/* If all packets have left the coop, cancel watchdog */
 	if (sc->sc_nfreetx == SQ_NTXDESC)
 		ifp->if_timer = 0;



CVS commit: src/sys/arch/sgimips/hpc

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 13:23:53 UTC 2022

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sgimips/hpc/if_sq.c

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



CVS commit: src/sys/arch/sgimips/hpc

2020-01-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 30 06:25:46 UTC 2020

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/sgimips/hpc/if_sq.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/sgimips/hpc/if_sq.c
diff -u src/sys/arch/sgimips/hpc/if_sq.c:1.53 src/sys/arch/sgimips/hpc/if_sq.c:1.54
--- src/sys/arch/sgimips/hpc/if_sq.c:1.53	Wed Jan 29 05:37:08 2020
+++ src/sys/arch/sgimips/hpc/if_sq.c	Thu Jan 30 06:25:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sq.c,v 1.53 2020/01/29 05:37:08 thorpej Exp $	*/
+/*	$NetBSD: if_sq.c,v 1.54 2020/01/30 06:25:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.53 2020/01/29 05:37:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.54 2020/01/30 06:25:46 martin Exp $");
 
 
 #include 
@@ -1074,7 +1074,7 @@ sq_txintr(struct sq_softc *sc)
 
 	SQ_TRACE(SQ_TXINTR_ENTER, sc, sc->sc_prevtx, status);
 
-	net_stats_ref_t nsr = IF_STAT_GETREF(ifp);
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 	tmp = (sc->hpc_regs->enetx_ctl_active >> shift) | TXSTAT_GOOD;
 	if ((status & tmp) == 0) {
 		if (status & TXSTAT_COLL)



CVS commit: src/sys/arch/sgimips/hpc

2020-01-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 30 06:25:46 UTC 2020

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/sgimips/hpc/if_sq.c

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



CVS commit: src/sys/arch/sgimips/hpc

2018-09-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 15 01:05:07 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
remove long unused power button handler


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sgimips/hpc/hpc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2018-09-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 15 01:05:07 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
remove long unused power button handler


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sgimips/hpc/hpc.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/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.70 src/sys/arch/sgimips/hpc/hpc.c:1.71
--- src/sys/arch/sgimips/hpc/hpc.c:1.70	Sat Sep 15 00:37:53 2018
+++ src/sys/arch/sgimips/hpc/hpc.c	Sat Sep 15 01:05:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.70 2018/09/15 00:37:53 macallan Exp $	*/
+/*	$NetBSD: hpc.c,v 1.71 2018/09/15 01:05:06 macallan Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.70 2018/09/15 00:37:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.71 2018/09/15 01:05:06 macallan Exp $");
 
 #include 
 #include 
@@ -347,9 +347,6 @@ static struct hpc_values hpc3_values = {
 	.scsi_dmactl_reset =	HPC3_SCSI_DMACTL_RESET
 };
 
-
-static int powerintr_established;
-
 static int	hpc_match(device_t, cfdata_t, void *);
 static void	hpc_attach(device_t, device_t, void *);
 static int	hpc_print(void *, const char *);
@@ -547,19 +544,6 @@ hpc_attach(device_t parent, device_t sel
 		}
 	}
 
-	/*
-	 * XXX: Only attach the powerfail interrupt once, since the
-	 * interrupt code doesn't let you share interrupt just yet.
-	 *
-	 * Since the powerfail interrupt is hardcoded to read from
-	 * a specific register anyway (XXX#2!), we don't care when
-	 * it gets attached, as long as it only happens once.
-	 */
-	if (mach_type == MACH_SGI_IP22 && !powerintr_established) {
-//		cpu_intr_establish(9, IPL_NONE, hpc_power_intr, sc);
-		powerintr_established++;
-	}
-
 #if defined(BLINK)
 	if (mach_type == MACH_SGI_IP12 || mach_type == MACH_SGI_IP20)
 		hpc_blink(sc);
@@ -672,24 +656,6 @@ hpc_print(void *aux, const char *pnp)
 	return (UNCONF);
 }
 
-#if 0
-static int
-hpc_power_intr(void *arg)
-{
-	uint32_t pwr_reg;
-
-	pwr_reg = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850));
-	*((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850)) = pwr_reg;
-
-	printf("hpc_power_intr: panel reg = %08x\n", pwr_reg);
-
-	if (pwr_reg & 2)
-		cpu_reboot(RB_HALT, NULL);
-
-	return 1;
-}
-#endif
-
 #if defined(BLINK)
 static void
 hpc_blink(void *arg)



CVS commit: src/sys/arch/sgimips/hpc

2018-09-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 15 00:37:53 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
one more s/panel/button, now this actually works again.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sgimips/hpc/hpc.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/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.69 src/sys/arch/sgimips/hpc/hpc.c:1.70
--- src/sys/arch/sgimips/hpc/hpc.c:1.69	Sun Jul 24 16:47:49 2016
+++ src/sys/arch/sgimips/hpc/hpc.c	Sat Sep 15 00:37:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.69 2016/07/24 16:47:49 macallan Exp $	*/
+/*	$NetBSD: hpc.c,v 1.70 2018/09/15 00:37:53 macallan Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.69 2016/07/24 16:47:49 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.70 2018/09/15 00:37:53 macallan Exp $");
 
 #include 
 #include 
@@ -201,7 +201,7 @@ static const struct hpc_device hpc3_devi
 	  -1,
 	  HPCDEV_IP22 | HPCDEV_IP24 },
 
-	{ "panel",	/* Indy front panel */
+	{ "button",	/* Indy front panel */
 	  HPC_BASE_ADDRESS_0,
 	  HPC3_PBUS_CH6_DEVREGS + IOC_PANEL, 0,
 	  9,



CVS commit: src/sys/arch/sgimips/hpc

2018-09-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 15 00:37:53 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
one more s/panel/button, now this actually works again.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sgimips/hpc/hpc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2018-09-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep  2 16:18:50 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: wdsc.c

Log Message:
Fix wdsc(4) probe failure on HPC1.5 machines (Indigo R3k/R4k, IP6/IP10/IP12).

The alignment adjustment code was removed in rev 1.36 for common
mips bus_space changes, but the code was not bus_space related
but used for uint32_t register acccess during probe.

Reported and tested by Naruaki Etomi in PR port-sgimips/53522.
Should be pulled up to netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sgimips/hpc/wdsc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2018-09-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep  2 16:18:50 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: wdsc.c

Log Message:
Fix wdsc(4) probe failure on HPC1.5 machines (Indigo R3k/R4k, IP6/IP10/IP12).

The alignment adjustment code was removed in rev 1.36 for common
mips bus_space changes, but the code was not bus_space related
but used for uint32_t register acccess during probe.

Reported and tested by Naruaki Etomi in PR port-sgimips/53522.
Should be pulled up to netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sgimips/hpc/wdsc.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/sgimips/hpc/wdsc.c
diff -u src/sys/arch/sgimips/hpc/wdsc.c:1.34 src/sys/arch/sgimips/hpc/wdsc.c:1.35
--- src/sys/arch/sgimips/hpc/wdsc.c:1.34	Wed Feb 18 16:47:58 2015
+++ src/sys/arch/sgimips/hpc/wdsc.c	Sun Sep  2 16:18:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdsc.c,v 1.34 2015/02/18 16:47:58 macallan Exp $	*/
+/*	$NetBSD: wdsc.c,v 1.35 2018/09/02 16:18:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdsc.c,v 1.34 2015/02/18 16:47:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdsc.c,v 1.35 2018/09/02 16:18:50 tsutsui Exp $");
 
 #include 
 #include 
@@ -105,6 +105,9 @@ wdsc_match(device_t parent, cfdata_t cf,
 		haa->hpc_regs->scsi0_ctl);
 		asr = MIPS_PHYS_TO_KSEG1(haa->ha_sh + haa->ha_devoff);
 
+		/* XXX: hpc1 offset due to SGIMIPS_BUS_SPACE_HPC brain damage */
+		asr = (asr + 3) & ~0x3;
+
 		if (platform.badaddr((void *)reset, sizeof(reset)))
 			return 0;
 



CVS commit: src/sys/arch/sgimips/hpc

2018-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  9 20:07:22 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: files.hpc
Added Files:
src/sys/arch/sgimips/hpc: button.c
Removed Files:
src/sys/arch/sgimips/hpc: panel.c

Log Message:
rename panel to button.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/sgimips/hpc/button.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sgimips/hpc/files.hpc
cvs rdiff -u -r1.3 -r0 src/sys/arch/sgimips/hpc/panel.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/sgimips/hpc/files.hpc
diff -u src/sys/arch/sgimips/hpc/files.hpc:1.15 src/sys/arch/sgimips/hpc/files.hpc:1.16
--- src/sys/arch/sgimips/hpc/files.hpc:1.15	Mon Apr  9 15:11:38 2018
+++ src/sys/arch/sgimips/hpc/files.hpc	Mon Apr  9 16:07:22 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpc,v 1.15 2018/04/09 19:11:38 christos Exp $
+# $NetBSD: files.hpc,v 1.16 2018/04/09 20:07:22 christos Exp $
 
 device	sq: arp, ether, ifnet
 attach	sq at hpc
@@ -27,4 +27,4 @@ file	arch/sgimips/hpc/pi1ppc.c	pi1ppc
 
 device	button : sysmon_power, sysmon_taskq
 attach	button at hpc
-file	arch/sgimips/hpc/panel.c	button
+file	arch/sgimips/hpc/button.c	button

Added files:

Index: src/sys/arch/sgimips/hpc/button.c
diff -u /dev/null src/sys/arch/sgimips/hpc/button.c:1.1
--- /dev/null	Mon Apr  9 16:07:22 2018
+++ src/sys/arch/sgimips/hpc/button.c	Mon Apr  9 16:07:22 2018
@@ -0,0 +1,154 @@
+/*	$NetBSD: button.c,v 1.1 2018/04/09 20:07:22 christos Exp $ */
+
+/*-
+ * Copyright (c) 2009 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.1 2018/04/09 20:07:22 christos Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct button_softc {
+	device_t sc_dev;
+	struct sysmon_pswitch sc_pbutton;
+	bus_space_tag_t sc_tag;
+	bus_space_handle_t sc_hreg;
+	int sc_last, sc_fired;
+};
+
+static int button_match(device_t, cfdata_t, void *);
+static void button_attach(device_t, device_t, void *);
+
+static int button_intr(void *);
+static void button_powerbutton(void *);
+
+CFATTACH_DECL_NEW(button, sizeof(struct button_softc), 
+button_match, 
+button_attach, 
+NULL, 
+NULL);
+
+static int
+button_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct hpc_attach_args *ha = aux;
+
+	if (strcmp(ha->ha_name, match->cf_name) != 0)
+		return 0;
+
+	if (mach_type == MACH_SGI_IP22)
+		return 1;
+
+	return 0;
+}
+
+static void
+button_attach(device_t parent, device_t self, void *aux)
+{
+	struct button_softc *sc;
+	struct hpc_attach_args *haa;
+
+	sc = device_private(self);
+	sc->sc_dev = self;
+	haa = aux;
+	sc->sc_tag = haa->ha_st;
+	sc->sc_fired = 0;
+	
+	aprint_normal("\n");
+	if (bus_space_subregion(haa->ha_st, haa->ha_sh, haa->ha_devoff,
+			0x4, 		/* just a single register */
+			>sc_hreg)) {
+		aprint_error(": unable to map button register\n");
+		return;
+	}
+
+	if ((cpu_intr_establish(haa->ha_irq, IPL_BIO,
+	 button_intr, sc)) == NULL) {
+		printf(": unable to establish interrupt!\n");
+		return;
+	}
+
+	sc->sc_last = 0;
+
+	sysmon_task_queue_init();
+	memset(>sc_pbutton, 0, sizeof(struct sysmon_pswitch));
+	sc->sc_pbutton.smpsw_name = device_xname(sc->sc_dev);
+	sc->sc_pbutton.smpsw_type = PSWITCH_TYPE_POWER;
+	if (sysmon_pswitch_register(>sc_pbutton) != 0)
+		aprint_error_dev(sc->sc_dev,
+		"unable to register power button with sysmon\n");
+	pmf_device_register(self, NULL, NULL);
+}
+

CVS commit: src/sys/arch/sgimips/hpc

2018-04-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  9 20:07:22 UTC 2018

Modified Files:
src/sys/arch/sgimips/hpc: files.hpc
Added Files:
src/sys/arch/sgimips/hpc: button.c
Removed Files:
src/sys/arch/sgimips/hpc: panel.c

Log Message:
rename panel to button.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/sgimips/hpc/button.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sgimips/hpc/files.hpc
cvs rdiff -u -r1.3 -r0 src/sys/arch/sgimips/hpc/panel.c

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



CVS commit: src/sys/arch/sgimips/hpc

2016-07-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jul 24 16:47:49 UTC 2016

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
use bus_space_map()


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sgimips/hpc/hpc.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/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.68 src/sys/arch/sgimips/hpc/hpc.c:1.69
--- src/sys/arch/sgimips/hpc/hpc.c:1.68	Wed Feb 18 16:47:58 2015
+++ src/sys/arch/sgimips/hpc/hpc.c	Sun Jul 24 16:47:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.68 2015/02/18 16:47:58 macallan Exp $	*/
+/*	$NetBSD: hpc.c,v 1.69 2016/07/24 16:47:49 macallan Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.68 2015/02/18 16:47:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpc.c,v 1.69 2016/07/24 16:47:49 macallan Exp $");
 
 #include 
 #include 
@@ -527,7 +527,9 @@ hpc_attach(device_t parent, device_t sel
 
 		/* XXX This is disgusting. */
 		ha.ha_st = normal_memt;
-		ha.ha_sh = MIPS_PHYS_TO_KSEG1(sc->sc_base);
+		if (bus_space_map(normal_memt, sc->sc_base, 0,
+		BUS_SPACE_MAP_LINEAR, _sh) != 0)
+			continue;
 		ha.ha_dmat = _default_bus_dma_tag;
 		if (hpctype == 3)
 			ha.hpc_regs = _values;



CVS commit: src/sys/arch/sgimips/hpc

2016-07-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jul 24 16:47:49 UTC 2016

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
use bus_space_map()


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sgimips/hpc/hpc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2011-06-08 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Jun  9 02:49:32 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: pi1ppc.c pi1ppcvar.h

Log Message:
Convert simple_lock/ltsleep to mutex/condvar and malloc to kmem.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sgimips/hpc/pi1ppc.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sgimips/hpc/pi1ppcvar.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/sgimips/hpc/pi1ppc.c
diff -u src/sys/arch/sgimips/hpc/pi1ppc.c:1.9 src/sys/arch/sgimips/hpc/pi1ppc.c:1.10
--- src/sys/arch/sgimips/hpc/pi1ppc.c:1.9	Wed Feb 16 23:44:20 2011
+++ src/sys/arch/sgimips/hpc/pi1ppc.c	Thu Jun  9 02:49:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $ */
+/* $NetBSD: pi1ppc.c,v 1.10 2011/06/09 02:49:32 rmind Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -33,19 +33,16 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: pi1ppc.c,v 1.10 2011/06/09 02:49:32 rmind Exp $);
 
 #include opt_pi1ppc.h
 
 #include sys/types.h
 #include sys/param.h
 #include sys/kernel.h
+#include sys/kmem.h
 #include sys/device.h
-#include sys/malloc.h
-#include sys/proc.h
 #include sys/systm.h
-#include sys/vnode.h
-#include sys/syslog.h
 
 #include machine/bus.h
 /*#include machine/intr.h*/
@@ -74,7 +71,6 @@
 int pi1ppc_verbose = 1;
 #endif
 
-
 /* Prototypes for functions. */
 
 /* PC-style register emulation */
@@ -100,7 +96,6 @@
 	0,4,BUS_SPACE_BARRIER_WRITE)
 #define	pi1ppc_barrier(_x)  pi1ppc_barrier_r(_x)
 
-
 /* Print function for config_found() */
 static int pi1ppc_print(void *, const char *);
 
@@ -139,7 +134,7 @@
 
 static int pi1ppc_poll_str(struct pi1ppc_softc * const, const uint8_t,
 	const uint8_t);
-static int pi1ppc_wait_interrupt(struct pi1ppc_softc * const, const void *,
+static int pi1ppc_wait_interrupt(struct pi1ppc_softc * const, kcondvar_t *,
 	const uint8_t);
 
 static int pi1ppc_poll_interrupt_stat(struct pi1ppc_softc * const, 
@@ -209,8 +204,6 @@
 	struct parport_adapter sc_parport_adapter;
 	char buf[64];
 
-	PI1PPC_LOCK_INIT(lsc);
-
 	/* For a PC, this is where the installed chipset is probed.
 	 * We *know* what we have, no need to probe.
 	 */
@@ -219,7 +212,11 @@
 
 	/* XXX Once we support Interrupts  DMA, update this */
 	lsc-sc_has = PI1PPC_HAS_PS2;
-	   
+
+	mutex_init(lsc-sc_lock, MUTEX_DEFAULT, IPL_TTY);
+	cv_init(lsc-sc_in_cv, pi1ppcin);
+	cv_init(lsc-sc_out_cv, pi1ppcou);
+
 /* Print out chipset capabilities */
 	snprintb(buf, sizeof(buf), \20\1INTR\2DMA\3FIFO\4PS2\5ECP\6EPP,
 	lsc-sc_has);
@@ -233,14 +230,9 @@
 	/* Last configuration step: set mode to standard mode */
 	if (pi1ppc_setmode(lsc-sc_dev, PPBUS_COMPATIBLE) != 0) {
 		PI1PPC_DPRINTF((%s: unable to initialize mode.\n,
-device_xname(lsc-sc_dev)));
+   device_xname(lsc-sc_dev)));
 	}
 
-#if defined (MULTIPROCESSOR) || defined (LOCKDEBUG)
-	/* Initialize lock structure */
-	simple_lock_init((lsc-sc_lock));
-#endif
-
 	/* Set up parport_adapter structure */
 
 	/* Set capabilites */
@@ -311,10 +303,12 @@
 			printf(continuing (DETACH_FORCE)\n);
 		}
 	}
-
 	if (!(flag  DETACH_QUIET))
 		printf(%s detached, device_xname(dev));
 
+	mutex_destroy(lsc-sc_lock);
+	cv_destroy(lsc-sc_in_cv);
+	cv_destroy(lsc-sc_out_cv);
 	return 0;
 }
 
@@ -341,9 +335,7 @@
 	struct pi1ppc_softc *pi1ppc = device_private(dev);
 	int claim = 1;
 	enum { NONE, READER, WRITER } wake_up = NONE;
-	int s;
 
-	s = splpi1ppc();
 	PI1PPC_LOCK(pi1ppc);
 
 	/* Record registers' status */
@@ -435,17 +427,15 @@
 			break;
 
 		case READER:
-			wakeup(atppc-sc_inb);
+			cv_broadcast(atppc-sc_in_cv);
 			break;
 
 		case WRITER:
-			wakeup(atppc-sc_outb);
+			cv_broadcast(atppc-sc_out_cv);
 			break;
 		}
 	}
 
-	PI1PPC_UNLOCK(atppc);
-
 	/* Call all of the installed handlers */
 	if (claim) {
 		struct atppc_handler_node * callback;
@@ -454,8 +444,7 @@
 (*callback-func)(callback-arg);
 		}
 	}
-
-	splx(s);
+	PI1PPC_UNLOCK(atppc);
 
 	return claim;
 #else
@@ -478,9 +467,7 @@
 {
 	struct pi1ppc_softc *pi1ppc = device_private(dev);
 	int error = 0;
-	int s;
 
-	s = splpi1ppc();
 	PI1PPC_LOCK(pi1ppc);
 
 	*cnt = 0;
@@ -522,7 +509,6 @@
 		error = pi1ppc-sc_inerr;
 
 	PI1PPC_UNLOCK(pi1ppc);
-	splx(s);
 
 	return (error);
 }
@@ -533,11 +519,9 @@
 {
 	struct pi1ppc_softc * const pi1ppc = device_private(dev);
 	int error = 0;
-	int s;
 
 	*cnt = 0;
 
-	s = splpi1ppc();
 	PI1PPC_LOCK(pi1ppc);
 
 	/* Set up line buffer */
@@ -574,7 +558,6 @@
 		error = pi1ppc-sc_outerr;
 
 	PI1PPC_UNLOCK(pi1ppc);
-	splx(s);
 
 	return (error);
 }
@@ -596,10 +579,8 @@
 	struct pi1ppc_softc *pi1ppc = device_private(dev);
 	uint8_t ecr;
 	uint8_t chipset_mode;
-	int s;
 	int rval = 0;
 
-	s = splpi1ppc();
 	PI1PPC_LOCK(pi1ppc);
 
 	

CVS commit: src/sys/arch/sgimips/hpc

2011-06-08 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Jun  9 02:49:32 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: pi1ppc.c pi1ppcvar.h

Log Message:
Convert simple_lock/ltsleep to mutex/condvar and malloc to kmem.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sgimips/hpc/pi1ppc.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sgimips/hpc/pi1ppcvar.h

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



CVS commit: src/sys/arch/sgimips/hpc

2011-02-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Feb 16 23:44:20 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: panel.c pi1ppc.c

Log Message:
validate cf_name in driver match method


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sgimips/hpc/panel.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sgimips/hpc/pi1ppc.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/sgimips/hpc/panel.c
diff -u src/sys/arch/sgimips/hpc/panel.c:1.1 src/sys/arch/sgimips/hpc/panel.c:1.2
--- src/sys/arch/sgimips/hpc/panel.c:1.1	Thu May 14 01:10:19 2009
+++ src/sys/arch/sgimips/hpc/panel.c	Wed Feb 16 23:44:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: panel.c,v 1.1 2009/05/14 01:10:19 macallan Exp $ */
+/*	$NetBSD: panel.c,v 1.2 2011/02/16 23:44:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: panel.c,v 1.1 2009/05/14 01:10:19 macallan Exp $);
+__KERNEL_RCSID(0, $NetBSD: panel.c,v 1.2 2011/02/16 23:44:19 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -71,6 +71,11 @@
 static int
 panel_match(device_t parent, cfdata_t match, void *aux)
 {
+	struct hpc_attach_args *ha = aux;
+
+	if (strcmp(ha-ha_name, match-cf_name) != 0)
+		return 0;
+
 	if (mach_type == MACH_SGI_IP22)
 		return 1;
 

Index: src/sys/arch/sgimips/hpc/pi1ppc.c
diff -u src/sys/arch/sgimips/hpc/pi1ppc.c:1.8 src/sys/arch/sgimips/hpc/pi1ppc.c:1.9
--- src/sys/arch/sgimips/hpc/pi1ppc.c:1.8	Tue Jan 25 12:21:04 2011
+++ src/sys/arch/sgimips/hpc/pi1ppc.c	Wed Feb 16 23:44:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pi1ppc.c,v 1.8 2011/01/25 12:21:04 tsutsui Exp $ */
+/* $NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pi1ppc.c,v 1.8 2011/01/25 12:21:04 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: pi1ppc.c,v 1.9 2011/02/16 23:44:20 jmcneill Exp $);
 
 #include opt_pi1ppc.h
 
@@ -162,6 +162,11 @@
 static int
 pi1ppc_match(device_t parent, cfdata_t match, void *aux)
 {
+	struct hpc_attach_args *ha = aux;
+
+	if (strcmp(ha-ha_name, match-cf_name) != 0)
+		return 0;
+
 	if (mach_type == MACH_SGI_IP22)
 		return 1;
 



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:11:27 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpcdma.c hpcdma.h

Log Message:
Small bus_dma(9) tweaks:
- call bus_dmamap_create(9) after bus_dmamem_alloc(9) and bus_dmamem_map(9)
  return successfully
- no need to use PAGE_SIZE for size of descriptor dmamap
- use bus_addr_t to store DMA address
- BUS_DMASYNC_PREWRITE is enough for host-to-device only descriptors

Tested on R5000 Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sgimips/hpc/hpcdma.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/sgimips/hpc/hpcdma.c
diff -u src/sys/arch/sgimips/hpc/hpcdma.c:1.17 src/sys/arch/sgimips/hpc/hpcdma.c:1.18
--- src/sys/arch/sgimips/hpc/hpcdma.c:1.17	Mon Dec 14 00:46:13 2009
+++ src/sys/arch/sgimips/hpc/hpcdma.c	Tue Jan 25 12:11:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcdma.c,v 1.17 2009/12/14 00:46:13 matt Exp $	*/
+/*	$NetBSD: hpcdma.c,v 1.18 2011/01/25 12:11:27 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -44,7 +44,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.17 2009/12/14 00:46:13 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.18 2011/01/25 12:11:27 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -81,14 +81,6 @@
 
 	/* Alloc 1 additional descriptor - needed for DMA bug fix */
 	allocsz = sizeof(struct hpc_dma_desc) * (ndesc + 1);
-	KASSERT(allocsz = PAGE_SIZE);
-
-	if (bus_dmamap_create(sc-sc_dmat, PAGE_SIZE, 1 /*seg*/,
-			  PAGE_SIZE, 0, BUS_DMA_WAITOK,
-			  sc-sc_dmamap) != 0) {
-		printf(: failed to create dmamap\n);
-		return;
-	}
 
 	/*
 	 * Allocate a block of memory for dma chaining pointers
@@ -106,20 +98,28 @@
 		return;
 	}
 
+	if (bus_dmamap_create(sc-sc_dmat, allocsz, 1 /*seg*/,
+			  allocsz, 0, BUS_DMA_WAITOK,
+			  sc-sc_dmamap) != 0) {
+		printf(: failed to create dmamap\n);
+		return;
+	}
+
 	if (bus_dmamap_load(sc-sc_dmat, sc-sc_dmamap, sc-sc_desc_kva,
 			allocsz, NULL, BUS_DMA_NOWAIT)) {
 		printf(: can't load sglist\n);
 		return;
 	}
 
-	sc-sc_desc_pa = (void *) (vaddr_t)sc-sc_dmamap-dm_segs[0].ds_addr;
+	sc-sc_desc_pa = sc-sc_dmamap-dm_segs[0].ds_addr;
 }
 
 
 void
 hpcdma_sglist_create(struct hpc_dma_softc *sc, bus_dmamap_t dmamap)
 {
-	struct hpc_dma_desc *hva, *hpa;
+	struct hpc_dma_desc *hva;
+	bus_addr_t hpa;
 	bus_dma_segment_t *segp;
 	int i;
 
@@ -136,16 +136,17 @@
 #ifdef DMA_DEBUG
 		printf(%p:%ld, , (void *)segp-ds_addr, segp-ds_len);
 #endif
+		hpa += sizeof(struct hpc_dma_desc);	/* next chain desc */
 		if (sc-hpc-revision == 3) {
 			hva-hpc3_hdd_bufptr = segp-ds_addr;
 			hva-hpc3_hdd_ctl= segp-ds_len;
-			hva-hdd_descptr = (uintptr_t) ++hpa;
+			hva-hdd_descptr = hpa;
 		} else /* HPC 1/1.5 */ {
 			/* there doesn't seem to be any good way of doing this
 		   	   via an abstraction layer */
 			hva-hpc1_hdd_bufptr = segp-ds_addr;
 			hva-hpc1_hdd_ctl= segp-ds_len;
-			hva-hdd_descptr = (uintptr_t) ++hpa;
+			hva-hdd_descptr = hpa;
 		}
 		++hva; ++segp;
 	}
@@ -156,7 +157,6 @@
 		hva-hpc3_hdd_bufptr  = 0;
 		hva-hpc3_hdd_ctl = HPC3_HDD_CTL_EOCHAIN;
 		hva-hdd_descptr = 0;
-		hva++;
 	} else {
 		hva--;
 		hva-hpc1_hdd_bufptr |= HPC1_HDD_CTL_EOCHAIN;
@@ -167,12 +167,12 @@
 	printf(\n);
 #endif
 	bus_dmamap_sync(sc-sc_dmat, sc-sc_dmamap,
-	0, sc-sc_dmamap-dm_mapsize,
-	BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+	0, sizeof(struct hpc_dma_desc) * (dmamap-dm_nsegs + 1),
+	BUS_DMASYNC_PREWRITE);
 
 	/* Load DMA Descriptor list */
 	bus_space_write_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ndbp,
-			(uintptr_t)sc-sc_desc_pa);
+	sc-sc_desc_pa);
 }
 
 void

Index: src/sys/arch/sgimips/hpc/hpcdma.h
diff -u src/sys/arch/sgimips/hpc/hpcdma.h:1.8 src/sys/arch/sgimips/hpc/hpcdma.h:1.9
--- src/sys/arch/sgimips/hpc/hpcdma.h:1.8	Sat May 10 15:31:05 2008
+++ src/sys/arch/sgimips/hpc/hpcdma.h	Tue Jan 25 12:11:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcdma.h,v 1.8 2008/05/10 15:31:05 martin Exp $	*/
+/*	$NetBSD: hpcdma.h,v 1.9 2011/01/25 12:11:27 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -54,7 +54,7 @@
 	int			sc_ndesc;
 	bus_dmamap_t		sc_dmamap;
 	struct hpc_dma_desc*sc_desc_kva;	/* Virtual address */
-	struct hpc_dma_desc*sc_desc_pa;	/* Physical address */
+	bus_addr_t		sc_desc_pa;	/* DMA address */
 	ssize_t			sc_dlen;	/* number of bytes transfered */
 	struct hpc_values   *hpc;		/* constants for HPC1/3 */
 };



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:14:03 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: wdsc.c

Log Message:
- MAXPHYS is enough for DMA xfer size (hpc-scsi_max_xfer seems too large)
- switch BUS_DMASYNC_*READ and BUS_DMASYNC_*WRITE properly in
  bus_dmamap_sync(9) ops per each xfer dir

Tested on R5000 Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sgimips/hpc/wdsc.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/sgimips/hpc/wdsc.c
diff -u src/sys/arch/sgimips/hpc/wdsc.c:1.29 src/sys/arch/sgimips/hpc/wdsc.c:1.30
--- src/sys/arch/sgimips/hpc/wdsc.c:1.29	Mon Dec 14 00:46:13 2009
+++ src/sys/arch/sgimips/hpc/wdsc.c	Tue Jan 25 12:14:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdsc.c,v 1.29 2009/12/14 00:46:13 matt Exp $	*/
+/*	$NetBSD: wdsc.c,v 1.30 2011/01/25 12:14:02 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: wdsc.c,v 1.29 2009/12/14 00:46:13 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: wdsc.c,v 1.30 2011/01/25 12:14:02 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -162,7 +162,7 @@
 	}
 
 	if (bus_dmamap_create(wsc-sc_dmat,
-			  wsc-sc_hpcdma.hpc-scsi_max_xfer,
+			  MAXPHYS,
 			  wsc-sc_hpcdma.hpc-scsi_dma_segs,
 			  wsc-sc_hpcdma.hpc-scsi_dma_segs_size,
 			  wsc-sc_hpcdma.hpc-scsi_dma_segs_size,
@@ -261,7 +261,8 @@
 
 	bus_dmamap_sync(wsc-sc_dmat, wsc-sc_dmamap, 0,
 			wsc-sc_dmamap-dm_mapsize,
-			BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+			(dsc-sc_flags  HPCDMA_READ) ?
+			BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
 	hpcdma_cntl(dsc, dsc-sc_dmacmd);	/* Thunderbirds are go! */
 
@@ -283,7 +284,8 @@
 		hpcdma_cntl(dsc, 0);	/* Stop DMA */
 		bus_dmamap_sync(wsc-sc_dmat, wsc-sc_dmamap, 0,
 		wsc-sc_dmamap-dm_mapsize,
-		BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
+		(dsc-sc_flags  HPCDMA_READ) ?
+		BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
 	}
 	if (wsc-sc_flags  WDSC_DMA_MAPLOADED)
 		bus_dmamap_unload(wsc-sc_dmat, wsc-sc_dmamap);



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:21:05 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: haltwo.c hpc.c hpcdma.c hpcdma.h hpcreg.h
hpcvar.h if_sq.c pi1ppc.c pi1ppcvar.h sqvar.h

Log Message:
u_intNN_t - uintNN_t


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sgimips/hpc/haltwo.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sgimips/hpc/hpc.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sgimips/hpc/hpcdma.h \
src/sys/arch/sgimips/hpc/sqvar.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sgimips/hpc/hpcreg.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sgimips/hpc/hpcvar.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sgimips/hpc/pi1ppc.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sgimips/hpc/pi1ppcvar.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/sgimips/hpc/haltwo.c
diff -u src/sys/arch/sgimips/hpc/haltwo.c:1.17 src/sys/arch/sgimips/hpc/haltwo.c:1.18
--- src/sys/arch/sgimips/hpc/haltwo.c:1.17	Thu Sep 24 14:09:18 2009
+++ src/sys/arch/sgimips/hpc/haltwo.c	Tue Jan 25 12:21:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwo.c,v 1.17 2009/09/24 14:09:18 tsutsui Exp $ */
+/* $NetBSD: haltwo.c,v 1.18 2011/01/25 12:21:04 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.17 2009/09/24 14:09:18 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.18 2011/01/25 12:21:04 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -269,12 +269,12 @@
 		return 0;
 
 	if ( platform.badaddr((void *)(vaddr_t)(haa-ha_sh + haa-ha_devoff),
-	sizeof(u_int32_t)) )
+	sizeof(uint32_t)) )
 		return 0;
 
 	if ( platform.badaddr(
 	(void *)(vaddr_t)(haa-ha_sh + haa-ha_devoff + HAL2_REG_CTL_REV),
-	sizeof(u_int32_t)) )
+	sizeof(uint32_t)) )
 		return 0;
 
 	rev = *(uint32_t *)MIPS_PHYS_TO_KSEG1(haa-ha_sh + haa-ha_devoff +

Index: src/sys/arch/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.63 src/sys/arch/sgimips/hpc/hpc.c:1.64
--- src/sys/arch/sgimips/hpc/hpc.c:1.63	Mon Dec 14 00:46:13 2009
+++ src/sys/arch/sgimips/hpc/hpc.c	Tue Jan 25 12:21:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.63 2009/12/14 00:46:13 matt Exp $	*/
+/*	$NetBSD: hpc.c,v 1.64 2011/01/25 12:21:04 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.63 2009/12/14 00:46:13 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.64 2011/01/25 12:21:04 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -382,7 +382,7 @@
 	mach_type == MACH_SGI_IP22) {
 		/* Make sure it's actually there and readable */
 		if (!platform.badaddr((void*)MIPS_PHYS_TO_KSEG1(ga-ga_addr),
-		sizeof(u_int32_t)))
+		sizeof(uint32_t)))
 			return 1;
 	}
 
@@ -590,7 +590,7 @@
 		return (0);
 
 	if (mach_type == MACH_SGI_IP12 || mach_type == MACH_SGI_IP20) {
-		u_int32_t reg;
+		uint32_t reg;
 
 		if (!platform.badaddr((void *)MIPS_PHYS_TO_KSEG1(ga-ga_addr +
 		HPC1_BIGENDIAN), 4)) {
@@ -665,10 +665,10 @@
 static int
 hpc_power_intr(void *arg)
 {
-	u_int32_t pwr_reg;
+	uint32_t pwr_reg;
 
-	pwr_reg = *((volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850));
-	*((volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850)) = pwr_reg;
+	pwr_reg = *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850));
+	*((volatile uint32_t *)MIPS_PHYS_TO_KSEG1(0x1fbd9850)) = pwr_reg;
 
 	printf(hpc_power_intr: panel reg = %08x\n, pwr_reg);
 
@@ -692,7 +692,7 @@
 	value = *(volatile uint8_t *)MIPS_PHYS_TO_KSEG1(HPC_BASE_ADDRESS_0 +
 	HPC1_AUX_REGS);
 	value ^= HPC1_AUX_CONSLED;
-	*(volatile u_int8_t *)MIPS_PHYS_TO_KSEG1(HPC_BASE_ADDRESS_0 +
+	*(volatile uint8_t *)MIPS_PHYS_TO_KSEG1(HPC_BASE_ADDRESS_0 +
 	HPC1_AUX_REGS) = value;
 	splx(s);
 

Index: src/sys/arch/sgimips/hpc/hpcdma.c
diff -u src/sys/arch/sgimips/hpc/hpcdma.c:1.18 src/sys/arch/sgimips/hpc/hpcdma.c:1.19
--- src/sys/arch/sgimips/hpc/hpcdma.c:1.18	Tue Jan 25 12:11:27 2011
+++ src/sys/arch/sgimips/hpc/hpcdma.c	Tue Jan 25 12:21:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcdma.c,v 1.18 2011/01/25 12:11:27 tsutsui Exp $	*/
+/*	$NetBSD: hpcdma.c,v 1.19 2011/01/25 12:21:04 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -44,7 +44,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.18 2011/01/25 12:11:27 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.19 2011/01/25 12:21:04 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -196,7 +196,7 @@
 void
 hpcdma_flush(struct hpc_dma_softc *sc)
 {
-	u_int32_t	mode;
+	uint32_t mode;
 
 	mode = bus_space_read_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ctl);
 	bus_space_write_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ctl,

Index: 

CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:30:32 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpcdma.c wdsc.c

Log Message:
Some KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sgimips/hpc/wdsc.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/sgimips/hpc/hpcdma.c
diff -u src/sys/arch/sgimips/hpc/hpcdma.c:1.19 src/sys/arch/sgimips/hpc/hpcdma.c:1.20
--- src/sys/arch/sgimips/hpc/hpcdma.c:1.19	Tue Jan 25 12:21:04 2011
+++ src/sys/arch/sgimips/hpc/hpcdma.c	Tue Jan 25 12:30:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcdma.c,v 1.19 2011/01/25 12:21:04 tsutsui Exp $	*/
+/*	$NetBSD: hpcdma.c,v 1.20 2011/01/25 12:30:32 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -44,7 +44,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.19 2011/01/25 12:21:04 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpcdma.c,v 1.20 2011/01/25 12:30:32 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -85,28 +85,27 @@
 	/*
 	 * Allocate a block of memory for dma chaining pointers
 	 */
-	if (bus_dmamem_alloc(sc-sc_dmat, allocsz, 0, 0,
-			 seg, 1, rseg, BUS_DMA_NOWAIT)) {
+	if (bus_dmamem_alloc(sc-sc_dmat, allocsz, 0, 0, seg, 1, rseg,
+	BUS_DMA_NOWAIT)) {
 		printf(: can't allocate sglist\n);
 		return;
 	}
 	/* Map pages into kernel memory */
 	if (bus_dmamem_map(sc-sc_dmat, seg, rseg, allocsz,
-			   (void **)sc-sc_desc_kva, BUS_DMA_NOWAIT)) {
+	(void **)sc-sc_desc_kva, BUS_DMA_NOWAIT)) {
 		printf(: can't map sglist\n);
 		bus_dmamem_free(sc-sc_dmat, seg, rseg);
 		return;
 	}
 
-	if (bus_dmamap_create(sc-sc_dmat, allocsz, 1 /*seg*/,
-			  allocsz, 0, BUS_DMA_WAITOK,
-			  sc-sc_dmamap) != 0) {
+	if (bus_dmamap_create(sc-sc_dmat, allocsz, 1 /*seg*/, allocsz, 0,
+	BUS_DMA_WAITOK, sc-sc_dmamap) != 0) {
 		printf(: failed to create dmamap\n);
 		return;
 	}
 
-	if (bus_dmamap_load(sc-sc_dmat, sc-sc_dmamap, sc-sc_desc_kva,
-			allocsz, NULL, BUS_DMA_NOWAIT)) {
+	if (bus_dmamap_load(sc-sc_dmat, sc-sc_dmamap,
+	sc-sc_desc_kva, allocsz, NULL, BUS_DMA_NOWAIT)) {
 		printf(: can't load sglist\n);
 		return;
 	}
@@ -142,18 +141,20 @@
 			hva-hpc3_hdd_ctl= segp-ds_len;
 			hva-hdd_descptr = hpa;
 		} else /* HPC 1/1.5 */ {
-			/* there doesn't seem to be any good way of doing this
-		   	   via an abstraction layer */
+			/*
+			 * there doesn't seem to be any good way of doing this
+		   	 * via an abstraction layer
+			 */
 			hva-hpc1_hdd_bufptr = segp-ds_addr;
 			hva-hpc1_hdd_ctl= segp-ds_len;
 			hva-hdd_descptr = hpa;
 		}
-		++hva; ++segp;
+		++hva;
+		++segp;
 	}
 
 	/* Work around HPC3 DMA bug */
-	if (sc-hpc-revision == 3)
-	{
+	if (sc-hpc-revision == 3) {
 		hva-hpc3_hdd_bufptr  = 0;
 		hva-hpc3_hdd_ctl = HPC3_HDD_CTL_EOCHAIN;
 		hva-hdd_descptr = 0;
@@ -199,8 +200,8 @@
 	uint32_t mode;
 
 	mode = bus_space_read_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ctl);
-	bus_space_write_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ctl,
-				mode | sc-hpc-scsi_dmactl_flush);
+	bus_space_write_4(sc-sc_bst, sc-sc_bsh,
+	sc-hpc-scsi0_ctl, mode | sc-hpc-scsi_dmactl_flush);
 
 	/* Wait for Active bit to drop */
 	while (bus_space_read_4(sc-sc_bst, sc-sc_bsh, sc-hpc-scsi0_ctl) 

Index: src/sys/arch/sgimips/hpc/wdsc.c
diff -u src/sys/arch/sgimips/hpc/wdsc.c:1.30 src/sys/arch/sgimips/hpc/wdsc.c:1.31
--- src/sys/arch/sgimips/hpc/wdsc.c:1.30	Tue Jan 25 12:14:02 2011
+++ src/sys/arch/sgimips/hpc/wdsc.c	Tue Jan 25 12:30:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdsc.c,v 1.30 2011/01/25 12:14:02 tsutsui Exp $	*/
+/*	$NetBSD: wdsc.c,v 1.31 2011/01/25 12:30:32 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wayne Knowles
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: wdsc.c,v 1.30 2011/01/25 12:14:02 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: wdsc.c,v 1.31 2011/01/25 12:30:32 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -77,19 +77,18 @@
 };
 
 
-void	wdsc_attach	(device_t, device_t, void *);
-int	wdsc_match	(device_t, cfdata_t, void *);
+int	wdsc_match(device_t, cfdata_t, void *);
+void	wdsc_attach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(wdsc, sizeof(struct wdsc_softc),
 wdsc_match, wdsc_attach, NULL, NULL);
 
-int	wdsc_dmasetup	(struct wd33c93_softc *, void ** ,size_t *,
-int, size_t *);
-int	wdsc_dmago	(struct wd33c93_softc *);
-void	wdsc_dmastop	(struct wd33c93_softc *);
-void	wdsc_reset	(struct wd33c93_softc *);
-int	wdsc_dmaintr	(void *);
-int	wdsc_scsiintr	(void *);
+int	wdsc_dmasetup(struct wd33c93_softc *, void ** ,size_t *, int, size_t *);
+int	wdsc_dmago(struct wd33c93_softc *);
+void	wdsc_dmastop(struct wd33c93_softc *);
+void	wdsc_reset(struct wd33c93_softc *);
+int	wdsc_dmaintr(void *);
+int	wdsc_scsiintr(void *);
 
 /*
  * Match for SCSI 

CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:43:30 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c sqvar.h

Log Message:
Split device_t/softc. Tested on Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sgimips/hpc/sqvar.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/sgimips/hpc/if_sq.c
diff -u src/sys/arch/sgimips/hpc/if_sq.c:1.38 src/sys/arch/sgimips/hpc/if_sq.c:1.39
--- src/sys/arch/sgimips/hpc/if_sq.c:1.38	Tue Jan 25 12:21:04 2011
+++ src/sys/arch/sgimips/hpc/if_sq.c	Tue Jan 25 12:43:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sq.c,v 1.38 2011/01/25 12:21:04 tsutsui Exp $	*/
+/*	$NetBSD: if_sq.c,v 1.39 2011/01/25 12:43:30 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_sq.c,v 1.38 2011/01/25 12:21:04 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_sq.c,v 1.39 2011/01/25 12:43:30 tsutsui Exp $);
 
 
 #include sys/param.h
@@ -99,8 +99,8 @@
  #define SQ_DPRINTF(x)
 #endif
 
-static int	sq_match(struct device *, struct cfdata *, void *);
-static void	sq_attach(struct device *, struct device *, void *);
+static int	sq_match(device_t, cfdata_t, void *);
+static void	sq_attach(device_t, device_t, void *);
 static int	sq_init(struct ifnet *);
 static void	sq_start(struct ifnet *);
 static void	sq_stop(struct ifnet *, int);
@@ -118,7 +118,7 @@
 static void 	sq_dump_buffer(paddr_t addr, psize_t len);
 static void	sq_trace_dump(struct sq_softc *);
 
-CFATTACH_DECL(sq, sizeof(struct sq_softc),
+CFATTACH_DECL_NEW(sq, sizeof(struct sq_softc),
 sq_match, sq_attach, NULL, NULL);
 
 #defineETHER_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
@@ -141,7 +141,7 @@
 #define SGI_OUI_2		0x69
 
 static int
-sq_match(struct device *parent, struct cfdata *cf, void *aux)
+sq_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct hpc_attach_args *ha = aux;
 
@@ -171,14 +171,15 @@
 }
 
 static void
-sq_attach(struct device *parent, struct device *self, void *aux)
+sq_attach(device_t parent, device_t self, void *aux)
 {
 	int i, err;
 	const char* macaddr;
-	struct sq_softc *sc = (void *)self;
+	struct sq_softc *sc = device_private(self);
 	struct hpc_attach_args *haa = aux;
 	struct ifnet *ifp = sc-sc_ethercom.ec_if;
 
+	sc-sc_dev = self;
 	sc-sc_hpct = haa-ha_st;
 	sc-hpc_regs = haa-hpc_regs;  /* HPC register definitions */
 
@@ -284,7 +285,7 @@
 	}
 
 	evcnt_attach_dynamic(sc-sq_intrcnt, EVCNT_TYPE_INTR, NULL,
-	  self-dv_xname, intr);
+	device_xname(self), intr);
 
 	if ((cpu_intr_establish(haa-ha_irq, IPL_NET, sq_intr, sc)) == NULL) {
 		printf(: unable to establish interrupt!\n);
@@ -310,10 +311,10 @@
 	printf(: SGI Seeq %s\n,
 	sc-sc_type == SQ_TYPE_80C03 ? 80c03 : 8003);
 
-	printf(%s: Ethernet address %s\n, sc-sc_dev.dv_xname,
-	   ether_sprintf(sc-sc_enaddr));
+	printf(%s: Ethernet address %s\n,
+	device_xname(self), ether_sprintf(sc-sc_enaddr));
 
-	strcpy(ifp-if_xname, sc-sc_dev.dv_xname);
+	strcpy(ifp-if_xname, device_xname(self));
 	ifp-if_softc = sc;
 	ifp-if_mtu = ETHERMTU;
 	ifp-if_init = sq_init;
@@ -575,14 +576,15 @@
 			MGETHDR(m, M_DONTWAIT, MT_DATA);
 			if (m == NULL) {
 printf(%s: unable to allocate Tx mbuf\n,
-sc-sc_dev.dv_xname);
+device_xname(sc-sc_dev));
 break;
 			}
 			if (m0-m_pkthdr.len  MHLEN) {
 MCLGET(m, M_DONTWAIT);
 if ((m-m_flags  M_EXT) == 0) {
 	printf(%s: unable to allocate Tx 
-	cluster\n, sc-sc_dev.dv_xname);
+	cluster\n,
+	device_xname(sc-sc_dev));
 	m_freem(m);
 	break;
 }
@@ -599,7 +601,8 @@
 			if ((err = bus_dmamap_load_mbuf(sc-sc_dmat, dmamap,
 		m, BUS_DMA_NOWAIT)) != 0) {
 printf(%s: unable to load Tx buffer, 
-error = %d\n, sc-sc_dev.dv_xname, err);
+error = %d\n,
+device_xname(sc-sc_dev), err);
 break;
 			}
 		}
@@ -678,7 +681,8 @@
 			sc-sc_txdesc[lasttx].hpc1_hdd_ctl |=
 			HPC1_HDD_CTL_EOPACKET;
 
-		SQ_DPRINTF((%s: transmit %d-%d, len %d\n, sc-sc_dev.dv_xname,
+		SQ_DPRINTF((%s: transmit %d-%d, len %d\n,
+		   device_xname(sc-sc_dev),
 		   sc-sc_nexttx, lasttx,
 		   totlen));
 
@@ -720,7 +724,7 @@
 
 	if (sc-sc_nfreetx != ofree) {
 		SQ_DPRINTF((%s: %d packets enqueued, first %d, INTR on %d\n,
-			sc-sc_dev.dv_xname, lasttx - firsttx + 1,
+			device_xname(sc-sc_dev), lasttx - firsttx + 1,
 			firsttx, lasttx));
 
 		/*
@@ -847,7 +851,7 @@
 
 	status = sq_hpc_read(sc, sc-hpc_regs-enetx_ctl);
 	log(LOG_ERR, %s: device timeout (prev %d, next %d, free %d, 
-		 status %08x)\n, sc-sc_dev.dv_xname, sc-sc_prevtx,
+		 status %08x)\n, device_xname(sc-sc_dev), sc-sc_prevtx,
    sc-sc_nexttx, sc-sc_nfreetx, status);
 
 	sq_trace_dump(sc);
@@ -882,7 +886,7 @@
 	

CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 13:12:40 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c sqvar.h

Log Message:
KNF and misc cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sgimips/hpc/sqvar.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/sgimips/hpc/if_sq.c
diff -u src/sys/arch/sgimips/hpc/if_sq.c:1.39 src/sys/arch/sgimips/hpc/if_sq.c:1.40
--- src/sys/arch/sgimips/hpc/if_sq.c:1.39	Tue Jan 25 12:43:30 2011
+++ src/sys/arch/sgimips/hpc/if_sq.c	Tue Jan 25 13:12:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sq.c,v 1.39 2011/01/25 12:43:30 tsutsui Exp $	*/
+/*	$NetBSD: if_sq.c,v 1.40 2011/01/25 13:12:39 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_sq.c,v 1.39 2011/01/25 12:43:30 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_sq.c,v 1.40 2011/01/25 13:12:39 tsutsui Exp $);
 
 
 #include sys/param.h
@@ -114,14 +114,14 @@
 static void	sq_txring_hpc1(struct sq_softc *);
 static void	sq_txring_hpc3(struct sq_softc *);
 static void	sq_reset(struct sq_softc *);
-static int 	sq_add_rxbuf(struct sq_softc *, int);
-static void 	sq_dump_buffer(paddr_t addr, psize_t len);
+static int	sq_add_rxbuf(struct sq_softc *, int);
+static void	sq_dump_buffer(paddr_t addr, psize_t len);
 static void	sq_trace_dump(struct sq_softc *);
 
 CFATTACH_DECL_NEW(sq, sizeof(struct sq_softc),
 sq_match, sq_attach, NULL, NULL);
 
-#defineETHER_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
+#define ETHER_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
 
 #define sq_seeq_read(sc, off) \
 	bus_space_read_1(sc-sc_regt, sc-sc_regh, off)
@@ -129,9 +129,9 @@
 	bus_space_write_1(sc-sc_regt, sc-sc_regh, off, val)
 
 #define sq_hpc_read(sc, off) \
-	bus_space_read_4(sc-sc_hpct, sc-sc_hpch, off)	
+	bus_space_read_4(sc-sc_hpct, sc-sc_hpch, off)
 #define sq_hpc_write(sc, off, val) \
-	bus_space_write_4(sc-sc_hpct, sc-sc_hpch, off, val)	
+	bus_space_write_4(sc-sc_hpct, sc-sc_hpch, off, val)
 
 /* MAC address offset for non-onboard implementations */
 #define SQ_HPC_EEPROM_ENADDR	250
@@ -154,20 +154,20 @@
 		ha-ha_devoff + (SEEQ_TXSTAT  2));
 
 		if (platform.badaddr((void *)reset, sizeof(reset)))
-			return (0);
+			return 0;
 
 		*(volatile uint32_t *)reset = 0x1;
 		delay(20);
 		*(volatile uint32_t *)reset = 0x0;
 
 		if (platform.badaddr((void *)txstat, sizeof(txstat)))
-			return (0);
+			return 0;
 
 		if ((*(volatile uint32_t *)txstat  0xff) == TXSTAT_OLDNEW)
-			return (1);
+			return 1;
 	}
 
-	return (0);
+	return 0;
 }
 
 static void
@@ -184,18 +184,16 @@
 	sc-hpc_regs = haa-hpc_regs;  /* HPC register definitions */
 
 	if ((err = bus_space_subregion(haa-ha_st, haa-ha_sh,
-   haa-ha_dmaoff,
-   sc-hpc_regs-enet_regs_size,
-   sc-sc_hpch)) != 0) {
+	haa-ha_dmaoff, sc-hpc_regs-enet_regs_size,
+	sc-sc_hpch)) != 0) {
 		printf(: unable to map HPC DMA registers, error = %d\n, err);
 		goto fail_0;
 	}
 
 	sc-sc_regt = haa-ha_st;
 	if ((err = bus_space_subregion(haa-ha_st, haa-ha_sh,
-   haa-ha_devoff,
-   sc-hpc_regs-enet_devregs_size,
-   sc-sc_regh)) != 0) {
+	haa-ha_devoff, sc-hpc_regs-enet_devregs_size,
+	sc-sc_regh)) != 0) {
 		printf(: unable to map Seeq registers, error = %d\n, err);
 		goto fail_0;
 	}
@@ -203,33 +201,32 @@
 	sc-sc_dmat = haa-ha_dmat;
 
 	if ((err = bus_dmamem_alloc(sc-sc_dmat, sizeof(struct sq_control),
-PAGE_SIZE, PAGE_SIZE, sc-sc_cdseg,
-1, sc-sc_ncdseg, BUS_DMA_NOWAIT)) != 0) {
+	PAGE_SIZE, PAGE_SIZE, sc-sc_cdseg, 1, sc-sc_ncdseg,
+	BUS_DMA_NOWAIT)) != 0) {
 		printf(: unable to allocate control data, error = %d\n, err);
 		goto fail_0;
 	}
 
 	if ((err = bus_dmamem_map(sc-sc_dmat, sc-sc_cdseg, sc-sc_ncdseg,
-  sizeof(struct sq_control),
-  (void **)sc-sc_control,
-  BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
+	sizeof(struct sq_control), (void **)sc-sc_control,
+	BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
 		printf(: unable to map control data, error = %d\n, err);
 		goto fail_1;
 	}
 
-	if ((err = bus_dmamap_create(sc-sc_dmat, sizeof(struct sq_control),
- 1, sizeof(struct sq_control), PAGE_SIZE,
- BUS_DMA_NOWAIT, sc-sc_cdmap)) != 0) {
+	if ((err = bus_dmamap_create(sc-sc_dmat,
+	sizeof(struct sq_control), 1, sizeof(struct sq_control), PAGE_SIZE,
+	BUS_DMA_NOWAIT, sc-sc_cdmap)) != 0) {
 		printf(: unable to create DMA map for control data, error 
-			= %d\n, err);
+		= %d\n, err);
 		goto fail_2;
 	}
 
-	if ((err = bus_dmamap_load(sc-sc_dmat, sc-sc_cdmap, sc-sc_control,
-   sizeof(struct sq_control),
-   NULL, BUS_DMA_NOWAIT)) != 0) {
+	if ((err = bus_dmamap_load(sc-sc_dmat, sc-sc_cdmap,
+	sc-sc_control, sizeof(struct 

CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 13:22:06 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
Split device_t/softc. Tested on Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sgimips/hpc/hpc.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/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.64 src/sys/arch/sgimips/hpc/hpc.c:1.65
--- src/sys/arch/sgimips/hpc/hpc.c:1.64	Tue Jan 25 12:21:04 2011
+++ src/sys/arch/sgimips/hpc/hpc.c	Tue Jan 25 13:22:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.64 2011/01/25 12:21:04 tsutsui Exp $	*/
+/*	$NetBSD: hpc.c,v 1.65 2011/01/25 13:22:05 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.64 2011/01/25 12:21:04 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.65 2011/01/25 13:22:05 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -217,7 +217,7 @@
 };
 
 struct hpc_softc {
-	struct device 		sc_dev;
+	device_t		sc_dev;
 
 	bus_addr_t		sc_base;
 
@@ -351,14 +351,13 @@
 
 static int powerintr_established;
 
-static int	hpc_match(struct device *, struct cfdata *, void *);
-static void	hpc_attach(struct device *, struct device *, void *);
+static int	hpc_match(device_t, cfdata_t, void *);
+static void	hpc_attach(device_t, device_t, void *);
 static int	hpc_print(void *, const char *);
 
 static int	hpc_revision(struct hpc_softc *, struct gio_attach_args *);
 
-static int	hpc_submatch(struct device *, struct cfdata *,
-		 const int *, void *);
+static int	hpc_submatch(device_t, cfdata_t, const int *, void *);
 
 //static int	hpc_power_intr(void *);
 
@@ -370,11 +369,11 @@
 static int	hpc_read_eeprom(int, bus_space_tag_t, bus_space_handle_t,
 		uint8_t *, size_t);
 
-CFATTACH_DECL(hpc, sizeof(struct hpc_softc),
+CFATTACH_DECL_NEW(hpc, sizeof(struct hpc_softc),
 hpc_match, hpc_attach, NULL, NULL);
 
 static int
-hpc_match(struct device *parent, struct cfdata *cf, void *aux)
+hpc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct gio_attach_args* ga = aux;
 
@@ -390,9 +389,9 @@
 }
 
 static void
-hpc_attach(struct device *parent, struct device *self, void *aux)
+hpc_attach(device_t parent, device_t self, void *aux)
 {
-	struct hpc_softc *sc = (struct hpc_softc *)self;
+	struct hpc_softc *sc = device_private(self);
 	struct gio_attach_args* ga = aux;
 	struct hpc_attach_args ha;
 	const struct hpc_device *hd;
@@ -401,6 +400,8 @@
 	int isioplus;
 	int sysmask;
 
+	sc-sc_dev = self;
+
 #ifdef BLINK
 	callout_init(hpc_blink_ch, 0);
 #endif
@@ -467,11 +468,12 @@
 		if (gio_arb_config(arb_slot, GIO_ARB_LB | GIO_ARB_MST |
 		GIO_ARB_64BIT | GIO_ARB_HPC2_64BIT)) {
 			printf(%s: failed to configure GIO bus arbiter\n,
-			sc-sc_dev.dv_xname);
+			device_xname(sc-sc_dev));
 			return;
 		}
 
-		printf(%s: using EXP%d's DMA channel\n, sc-sc_dev.dv_xname,
+		printf(%s: using EXP%d's DMA channel\n,
+		device_xname(sc-sc_dev),
 		(arb_slot == GIO_SLOT_EXP0) ? 0 : 1);
 
 		bus_space_write_4(ga-ga_iot, ga-ga_ioh,
@@ -491,7 +493,7 @@
 
 		if (gio_arb_config(arb_slot, GIO_ARB_RT | GIO_ARB_MST)) {
 			printf(%s: failed to configure GIO bus arbiter\n,
-			sc-sc_dev.dv_xname);
+			device_xname(sc-sc_dev));
 			return;
 		}
 	}
@@ -681,9 +683,9 @@
 
 #if defined(BLINK)
 static void
-hpc_blink(void *self)
+hpc_blink(void *arg)
 {
-	struct hpc_softc *sc = (struct hpc_softc *) self;
+	struct hpc_softc *sc = arg;
 	register int	s;
 	int	value;
 



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:11:27 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpcdma.c hpcdma.h

Log Message:
Small bus_dma(9) tweaks:
- call bus_dmamap_create(9) after bus_dmamem_alloc(9) and bus_dmamem_map(9)
  return successfully
- no need to use PAGE_SIZE for size of descriptor dmamap
- use bus_addr_t to store DMA address
- BUS_DMASYNC_PREWRITE is enough for host-to-device only descriptors

Tested on R5000 Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sgimips/hpc/hpcdma.h

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:14:03 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: wdsc.c

Log Message:
- MAXPHYS is enough for DMA xfer size (hpc-scsi_max_xfer seems too large)
- switch BUS_DMASYNC_*READ and BUS_DMASYNC_*WRITE properly in
  bus_dmamap_sync(9) ops per each xfer dir

Tested on R5000 Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sgimips/hpc/wdsc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:21:05 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: haltwo.c hpc.c hpcdma.c hpcdma.h hpcreg.h
hpcvar.h if_sq.c pi1ppc.c pi1ppcvar.h sqvar.h

Log Message:
u_intNN_t - uintNN_t


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sgimips/hpc/haltwo.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sgimips/hpc/hpc.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sgimips/hpc/hpcdma.h \
src/sys/arch/sgimips/hpc/sqvar.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sgimips/hpc/hpcreg.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sgimips/hpc/hpcvar.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sgimips/hpc/pi1ppc.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sgimips/hpc/pi1ppcvar.h

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:30:32 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpcdma.c wdsc.c

Log Message:
Some KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sgimips/hpc/hpcdma.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sgimips/hpc/wdsc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 12:43:30 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c sqvar.h

Log Message:
Split device_t/softc. Tested on Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sgimips/hpc/sqvar.h

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 13:12:40 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: if_sq.c sqvar.h

Log Message:
KNF and misc cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sgimips/hpc/if_sq.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sgimips/hpc/sqvar.h

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



CVS commit: src/sys/arch/sgimips/hpc

2011-01-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jan 25 13:22:06 UTC 2011

Modified Files:
src/sys/arch/sgimips/hpc: hpc.c

Log Message:
Split device_t/softc. Tested on Indy.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sgimips/hpc/hpc.c

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



CVS commit: src/sys/arch/sgimips/hpc

2009-09-24 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Sep 24 14:09:18 UTC 2009

Modified Files:
src/sys/arch/sgimips/hpc: haltwo.c haltwovar.h

Log Message:
Replace shutdownhook_establish(9) (which was added by me)
with pmf_device_register1(9).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sgimips/hpc/haltwo.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sgimips/hpc/haltwovar.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/sgimips/hpc/haltwo.c
diff -u src/sys/arch/sgimips/hpc/haltwo.c:1.16 src/sys/arch/sgimips/hpc/haltwo.c:1.17
--- src/sys/arch/sgimips/hpc/haltwo.c:1.16	Thu May 14 01:06:15 2009
+++ src/sys/arch/sgimips/hpc/haltwo.c	Thu Sep 24 14:09:18 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwo.c,v 1.16 2009/05/14 01:06:15 macallan Exp $ */
+/* $NetBSD: haltwo.c,v 1.17 2009/09/24 14:09:18 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.16 2009/05/14 01:06:15 macallan Exp $);
+__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.17 2009/09/24 14:09:18 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -75,7 +75,7 @@
 	void *, const audio_params_t *);
 static int haltwo_trigger_input(void *, void *, void *, int, void (*)(void *),
 	void *, const audio_params_t *);
-static void haltwo_shutdown(void *);
+static bool haltwo_shutdown(device_t, int);
 
 static const struct audio_hw_if haltwo_hw_if = {
 	NULL, /* open */
@@ -358,10 +358,9 @@
 
 	audio_attach_mi(haltwo_hw_if, sc, sc-sc_dev);
 
-	sc-sc_sdhook = shutdownhook_establish(haltwo_shutdown, sc);
-	if (sc-sc_sdhook == NULL)
+	if (!pmf_device_register1(self, NULL, NULL, haltwo_shutdown))
 		aprint_error_dev(self,
-		WARNING: unable to establish shutdown hook\n);
+		couldn't establish power handler\n);
 }
 
 static int
@@ -815,12 +814,15 @@
 	return ENXIO;
 }
 
-void
-haltwo_shutdown(void *arg)
+bool
+haltwo_shutdown(device_t self, int howto)
 {
-	struct haltwo_softc *sc = arg;
+	struct haltwo_softc *sc;
 
+	sc = device_private(self);
 	haltwo_write(sc, ctl, HAL2_REG_CTL_ISR, 0);
 	haltwo_write(sc, ctl, HAL2_REG_CTL_ISR,
 	HAL2_ISR_GLOBAL_RESET_N | HAL2_ISR_CODEC_RESET_N);
+
+	return true;
 }

Index: src/sys/arch/sgimips/hpc/haltwovar.h
diff -u src/sys/arch/sgimips/hpc/haltwovar.h:1.5 src/sys/arch/sgimips/hpc/haltwovar.h:1.6
--- src/sys/arch/sgimips/hpc/haltwovar.h:1.5	Sun Aug 24 13:03:39 2008
+++ src/sys/arch/sgimips/hpc/haltwovar.h	Thu Sep 24 14:09:18 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwovar.h,v 1.5 2008/08/24 13:03:39 tsutsui Exp $ */
+/* $NetBSD: haltwovar.h,v 1.6 2009/09/24 14:09:18 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -81,8 +81,6 @@
 	bus_space_handle_t sc_aes_sh;
 	bus_space_handle_t sc_vol_sh;
 	bus_space_handle_t sc_syn_sh;
-
-	void *sc_sdhook;
 };
 
 #endif



CVS commit: src/sys/arch/sgimips/hpc

2009-05-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May 14 01:06:16 UTC 2009

Modified Files:
src/sys/arch/sgimips/hpc: haltwo.c

Log Message:
set delta value for the mixer's master channel


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sgimips/hpc/haltwo.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/sgimips/hpc/haltwo.c
diff -u src/sys/arch/sgimips/hpc/haltwo.c:1.15 src/sys/arch/sgimips/hpc/haltwo.c:1.16
--- src/sys/arch/sgimips/hpc/haltwo.c:1.15	Sun Aug 24 13:03:39 2008
+++ src/sys/arch/sgimips/hpc/haltwo.c	Thu May 14 01:06:15 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwo.c,v 1.15 2008/08/24 13:03:39 tsutsui Exp $ */
+/* $NetBSD: haltwo.c,v 1.16 2009/05/14 01:06:15 macallan Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.15 2008/08/24 13:03:39 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: haltwo.c,v 1.16 2009/05/14 01:06:15 macallan Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -609,6 +609,7 @@
 		dev-prev = dev-next = AUDIO_MIXER_LAST;
 		strcpy(dev-label.name, AudioNmaster);
 		dev-un.v.num_channels = 2;
+		dev-un.v.delta = 16;
 		strcpy(dev-un.v.units.name, AudioNvolume);
 		break;
 



CVS commit: src/sys/arch/sgimips/hpc

2009-05-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May 14 01:10:19 UTC 2009

Modified Files:
src/sys/arch/sgimips/hpc: files.hpc hpc.c
Added Files:
src/sys/arch/sgimips/hpc: panel.c

Log Message:
add a driver for the Indy's front panel buttons.
- power button presses are reported to sysmon
- volume control buttons are reported to PMF
TODO: add better key repeat code. The hardware keeps firing interrupts at us
whenever a button is down and not on - say - status change. If we don't clear
the interrupt we'll be fired on until someone clears it. We should probably
disable the entire interrupt and occasionally poll for button release.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sgimips/hpc/files.hpc
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sgimips/hpc/hpc.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sgimips/hpc/panel.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/sgimips/hpc/files.hpc
diff -u src/sys/arch/sgimips/hpc/files.hpc:1.13 src/sys/arch/sgimips/hpc/files.hpc:1.14
--- src/sys/arch/sgimips/hpc/files.hpc:1.13	Thu Feb 12 06:33:57 2009
+++ src/sys/arch/sgimips/hpc/files.hpc	Thu May 14 01:10:19 2009
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpc,v 1.13 2009/02/12 06:33:57 rumble Exp $
+# $NetBSD: files.hpc,v 1.14 2009/05/14 01:10:19 macallan Exp $
 
 device	sq: arp, ether, ifnet
 attach	sq at hpc
@@ -25,3 +25,6 @@
 attach	pi1ppc at hpc
 file	arch/sgimips/hpc/pi1ppc.c	pi1ppc
 
+device	panel : sysmon_power, sysmon_taskq
+attach	panel at hpc
+file	arch/sgimips/hpc/panel.c	panel

Index: src/sys/arch/sgimips/hpc/hpc.c
diff -u src/sys/arch/sgimips/hpc/hpc.c:1.61 src/sys/arch/sgimips/hpc/hpc.c:1.62
--- src/sys/arch/sgimips/hpc/hpc.c:1.61	Thu Feb 12 06:33:57 2009
+++ src/sys/arch/sgimips/hpc/hpc.c	Thu May 14 01:10:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpc.c,v 1.61 2009/02/12 06:33:57 rumble Exp $	*/
+/*	$NetBSD: hpc.c,v 1.62 2009/05/14 01:10:19 macallan Exp $	*/
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.61 2009/02/12 06:33:57 rumble Exp $);
+__KERNEL_RCSID(0, $NetBSD: hpc.c,v 1.62 2009/05/14 01:10:19 macallan Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -202,6 +202,12 @@
 	  -1,
 	  HPCDEV_IP22 | HPCDEV_IP24 },
 
+	{ panel,	/* Indy front panel */
+	  HPC_BASE_ADDRESS_0,
+	  HPC3_PBUS_CH6_DEVREGS + IOC_PANEL, 0,
+	  9,
+	  HPCDEV_IP24 },
+
 	{ NULL,
 	  0,
 	  0, 0,

Added files:

Index: src/sys/arch/sgimips/hpc/panel.c
diff -u /dev/null src/sys/arch/sgimips/hpc/panel.c:1.1
--- /dev/null	Thu May 14 01:10:19 2009
+++ src/sys/arch/sgimips/hpc/panel.c	Thu May 14 01:10:19 2009
@@ -0,0 +1,149 @@
+/*	$NetBSD: panel.c,v 1.1 2009/05/14 01:10:19 macallan Exp $ */
+
+/*-
+ * Copyright (c) 2009 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: panel.c,v 1.1 2009/05/14 01:10:19 macallan Exp $);
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/kernel.h
+#include sys/device.h
+#include sys/proc.h
+#include sys/kthread.h
+
+#include sys/bus.h
+
+#include dev/sysmon/sysmonvar.h
+#include dev/sysmon/sysmon_taskq.h
+
+#include machine/autoconf.h
+#include machine/machtype.h
+
+#include sgimips/ioc/iocreg.h
+#include sgimips/hpc/hpcvar.h
+#include sgimips/hpc/hpcreg.h
+
+struct panel_softc {
+	device_t sc_dev;
+	struct sysmon_pswitch sc_pbutton;
+	bus_space_tag_t sc_tag;
+	bus_space_handle_t sc_hreg;
+	int sc_last, sc_fired;
+};
+
+static int panel_match(device_t, cfdata_t, void *);
+static void panel_attach(device_t, device_t,