CVS commit: src/sys/arch/sandpoint/sandpoint

2023-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 10 00:08:14 UTC 2023

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
sandpoint: Use config_detach_children to reduce error branch bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/sandpoint/flash_cfi.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/sandpoint/sandpoint/flash_cfi.c
diff -u src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.4 src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.5
--- src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.4	Mon Sep  7 23:00:08 2015
+++ src/sys/arch/sandpoint/sandpoint/flash_cfi.c	Wed May 10 00:08:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $ */
+/* $NetBSD: flash_cfi.c,v 1.5 2023/05/10 00:08:14 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -32,7 +32,7 @@
  * NOR CFI driver support for sandpoint
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.5 2023/05/10 00:08:14 riastradh Exp $");
 
 #include 
 #include 
@@ -158,16 +158,15 @@ sandpointcfi_attach(device_t parent, dev
 static int
 sandpointcfi_detach(device_t self, int flags)
 {
-	struct sandpointcfi_softc *sc;
-	int rv;
+	struct sandpointcfi_softc *sc device_private(self);
+	int error;
 
-	pmf_device_deregister(self);
-	sc = device_private(self);
-	rv = 0;
+	error = config_detach_children(self, flags);
+	if (error)
+		return error;
 
-	if (sc->sc_nordev != NULL)
-		rv = config_detach(sc->sc_nordev, flags);
+	pmf_device_deregister(self);
 
 	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, sc->sc_size);
-	return rv;
+	return 0;
 }



CVS commit: src/sys/arch/sandpoint/sandpoint

2023-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 10 00:08:14 UTC 2023

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
sandpoint: Use config_detach_children to reduce error branch bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/sandpoint/flash_cfi.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/sandpoint/sandpoint

2021-01-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  4 15:36:22 UTC 2021

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.28 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.29
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.28	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Mon Jan  4 15:36:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.28 2018/09/03 16:29:27 riastradh Exp $ */
+/* $NetBSD: satmgr.c,v 1.29 2021/01/04 15:36:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -589,7 +589,7 @@ filt_rdetach(struct knote *kn)
 	struct satmgr_softc *sc = kn->kn_hook;
 
 	mutex_enter(>sc_lock);
-	SLIST_REMOVE(>sc_rsel.sel_klist, kn, knote, kn_selnext);
+	selremove_knote(>sc_rsel, kn);
 	mutex_exit(>sc_lock);
 }
 
@@ -613,11 +613,9 @@ static int
 satkqfilter(dev_t dev, struct knote *kn)
 {
 	struct satmgr_softc *sc = device_lookup_private(_cd, 0);
-	struct klist *klist;
 
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
-		klist = >sc_rsel.sel_klist;
 		kn->kn_fop = _filtops;
 		break;
 
@@ -628,7 +626,7 @@ satkqfilter(dev_t dev, struct knote *kn)
 	kn->kn_hook = sc;
 
 	mutex_enter(>sc_lock);
-	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+	selrecord_knote(>sc_rsel, kn);
 	mutex_exit(>sc_lock);
 
 	return 0;



CVS commit: src/sys/arch/sandpoint/sandpoint

2021-01-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  4 15:36:22 UTC 2021

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2020-07-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Jul  9 05:12:09 UTC 2020

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/autoconf.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/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.28 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.28	Wed Sep 30 14:18:54 2015
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Thu Jul  9 05:12:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.28 2015/09/30 14:18:54 phx Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.29 2020/07/09 05:12:09 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.28 2015/09/30 14:18:54 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29 2020/07/09 05:12:09 nisimura Exp $");
 
 #include 
 #include 
@@ -152,7 +152,7 @@ device_register(device_t dev, void *aux)
 		&& bi_net->cookie == tag) {
 			prop_data_t pd;
 
-			pd = prop_data_create_data_nocopy(bi_net->mac_address,
+			pd = prop_data_create_nocopy(bi_net->mac_address,
 			ETHER_ADDR_LEN);
 			KASSERT(pd != NULL);
 			if (prop_dictionary_set(device_properties(dev),
@@ -201,7 +201,7 @@ add_i2c_child_devices(device_t self, con
 		!(bi_model->flags & model_i2c_devs[i].model_mask))
 			continue;
 		pd = prop_dictionary_create();
-		prop_dictionary_set_cstring_nocopy(pd, "name",
+		prop_dictionary_set_string_nocopy(pd, "name",
 		model_i2c_devs[i].name);
 		prop_dictionary_set_uint32(pd, "addr",
 		model_i2c_devs[i].addr);



CVS commit: src/sys/arch/sandpoint/sandpoint

2020-07-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Jul  9 05:12:09 UTC 2020

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/autoconf.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/sandpoint/sandpoint

2019-04-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Apr  7 15:44:44 UTC 2019

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c

Log Message:
Call com_init_regs() in eumbcnattach() to set up com port register mapping.
Fixes broken console output after changes to remove COM_REGMAP.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/sandpoint/com_eumb.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/sandpoint/sandpoint/com_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.9 src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.10
--- src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.9	Sat Dec  8 17:46:12 2018
+++ src/sys/arch/sandpoint/sandpoint/com_eumb.c	Sun Apr  7 15:44:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: com_eumb.c,v 1.9 2018/12/08 17:46:12 thorpej Exp $ */
+/* $NetBSD: com_eumb.c,v 1.10 2019/04/07 15:44:44 jdc Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_eumb.c,v 1.9 2018/12/08 17:46:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_eumb.c,v 1.10 2019/04/07 15:44:44 jdc Exp $");
 
 #include 
 #include 
@@ -111,6 +111,9 @@ eumbcnattach(bus_space_tag_t tag,
 int conaddr, int conspeed, int confreq, int contype, int conmode)
 {
 	static int attached = 0;
+	bus_space_handle_t dummy_bsh; /* XXX see com.c:comcnattach() */
+
+	memset(_bsh, 0, sizeof(dummy_bsh));
 
 	if (attached)
 		return 0;
@@ -119,5 +122,6 @@ eumbcnattach(bus_space_tag_t tag,
 	cnregs.cr_iot = tag;
 	cnregs.cr_iobase = conaddr;
 	cnregs.cr_nports = COM_NPORTS;
+	com_init_regs(, tag, dummy_bsh, conaddr);
 	return comcnattach1(, conspeed, confreq, contype, conmode);
 }



CVS commit: src/sys/arch/sandpoint/sandpoint

2019-04-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Apr  7 15:44:44 UTC 2019

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c

Log Message:
Call com_init_regs() in eumbcnattach() to set up com port register mapping.
Fixes broken console output after changes to remove COM_REGMAP.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/sandpoint/com_eumb.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/sandpoint/sandpoint

2015-09-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Sep 30 14:18:54 UTC 2015

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c machdep.c

Log Message:
Now more than a single I2C device per model may be configured directly.
An additional flags argument makes the configuration depend on the model-
flags in an optional BTINFO_MODEL bootinfo node.
Print the model name together with the vendor name, when known.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.27 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.28
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.27	Sun Jul 29 18:05:45 2012
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Wed Sep 30 14:18:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.27 2012/07/29 18:05:45 mlelstv Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.28 2015/09/30 14:18:54 phx Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.27 2012/07/29 18:05:45 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.28 2015/09/30 14:18:54 phx Exp $");
 
 #include 
 #include 
@@ -55,21 +55,30 @@ static struct btinfo_rootdevice *bi_rdev
 static struct btinfo_bootpath *bi_path;
 static struct btinfo_net *bi_net;
 static struct btinfo_prodfamily *bi_pfam;
+static struct btinfo_model *bi_model;
 
-struct i2cdev {
-	const char *family;
-	const char *name;
-	int addr;
+struct i2c_dev {
+	const char	*name;
+	unsigned	addr;
+	/* only attach when one of these bits in the model flags is set */
+	uint32_t	model_mask;
 };
 
-static struct i2cdev rtcmodel[] = {
-{ "dlink","strtc",  0x68 },
-{ "iomega",   "dsrtc",  0x68 },
-{ "kurobox",  "rs5c372rtc", 0x32 },
-{ "kurot4",   "rs5c372rtc", 0x32 },
-{ "nhnas","pcf8563rtc", 0x51 },
-{ "qnap", "s390rtc",0x30 },
-{ "synology", "rs5c372rtc", 0x32 },
+#define MAXI2CDEVS	4
+struct model_i2c {
+	const char	*family;
+	struct i2c_dev	i2c_devs[MAXI2CDEVS];
+};
+
+static struct model_i2c model_i2c_list[] = {
+	{ "dlink",	{	{ "strtc",	0x68, 0 } } },
+	{ "iomega",	{	{ "dsrtc",	0x68, 0 } } },
+	{ "kurobox",	{	{ "rs5c372rtc", 0x32, 0 } } },
+	{ "kurot4",	{	{ "rs5c372rtc", 0x32, 0 } } },
+	{ "nhnas",	{	{ "pcf8563rtc", 0x51, 0 } } },
+	{ "qnap",	{	{ "s390rtc",0x30, 0 } } },
+	{ "synology",	{	{ "rs5c372rtc", 0x32, 0 },
+{ "lmtemp",	0x48, BI_MODEL_THERMAL } } },
 };
 
 static void add_i2c_child_devices(device_t, const char *);
@@ -85,6 +94,7 @@ cpu_configure(void)
 	bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
 	bi_net = lookup_bootinfo(BTINFO_NET);
 	bi_pfam = lookup_bootinfo(BTINFO_PRODFAMILY);
+	bi_model = lookup_bootinfo(BTINFO_MODEL);
 
 	if (config_rootfound("mainbus", NULL) == NULL)
 		panic("configure: mainbus not configured");
@@ -167,27 +177,38 @@ device_register(device_t dev, void *aux)
 static void
 add_i2c_child_devices(device_t self, const char *family)
 {
-	struct i2cdev *rtc;
+	struct i2c_dev *model_i2c_devs;
 	prop_dictionary_t pd;
 	prop_array_t pa;
 	int i;
 
-	rtc = NULL;
-	for (i = 0; i < (int)(sizeof(rtcmodel)/sizeof(rtcmodel[0])); i++) {
-		if (strcmp(family, rtcmodel[i].family) == 0) {
-			rtc = [i];
+	for (i = 0;
+	i < (int)(sizeof(model_i2c_list) / sizeof(model_i2c_list[0]));
+	i++) {
+		if (strcmp(family, model_i2c_list[i].family) == 0) {
+			model_i2c_devs = model_i2c_list[i].i2c_devs;
 			goto found;
 		}
 	}
 	return;
 
  found:
-	pd = prop_dictionary_create();
+	/* make an i2c-child-devices property list with for direct config. */
 	pa = prop_array_create();
-	prop_dictionary_set_cstring_nocopy(pd, "name", rtc->name);
-	prop_dictionary_set_uint32(pd, "addr", rtc->addr);
-	prop_array_add(pa, pd);
+
+	for (i = 0; i < MAXI2CDEVS && model_i2c_devs[i].name != NULL; i++) {
+		if (model_i2c_devs[i].model_mask != 0 &&
+		!(bi_model->flags & model_i2c_devs[i].model_mask))
+			continue;
+		pd = prop_dictionary_create();
+		prop_dictionary_set_cstring_nocopy(pd, "name",
+		model_i2c_devs[i].name);
+		prop_dictionary_set_uint32(pd, "addr",
+		model_i2c_devs[i].addr);
+		prop_array_add(pa, pd);
+		prop_object_release(pd);
+	}
+
 	prop_dictionary_set(device_properties(self), "i2c-child-devices", pa);
-	prop_object_release(pd);
 	prop_object_release(pa);
 }

Index: src/sys/arch/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.64 src/sys/arch/sandpoint/sandpoint/machdep.c:1.65
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.64	Mon Sep  7 23:00:08 2015
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Wed Sep 30 14:18:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 

CVS commit: src/sys/arch/sandpoint/sandpoint

2015-09-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Sep 30 14:18:54 UTC 2015

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c machdep.c

Log Message:
Now more than a single I2C device per model may be configured directly.
An additional flags argument makes the configuration depend on the model-
flags in an optional BTINFO_MODEL bootinfo node.
Print the model name together with the vendor name, when known.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint

2015-09-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Sep  7 23:00:08 UTC 2015

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c machdep.c mainbus.c

Log Message:
Fix nor-flash bus space: extent limit should not be zero and bus space is
definitely big-endian. Reading the flash via /dev/flash0 works now.
Writing is untested.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/sandpoint/flash_cfi.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sandpoint/sandpoint/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/sandpoint/sandpoint/flash_cfi.c
diff -u src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3 src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.4
--- src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3	Mon Jan 30 15:47:01 2012
+++ src/sys/arch/sandpoint/sandpoint/flash_cfi.c	Mon Sep  7 23:00:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $ */
+/* $NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -32,7 +32,7 @@
  * NOR CFI driver support for sandpoint
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $");
 
 #include 
 #include 
@@ -63,7 +63,7 @@ sandpointcfi_probe(device_t parent, cfda
 {
 	extern struct cfdriver cfi_cd;
 	struct mainbus_attach_args *ma = aux;
-	const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	const bus_size_t qrysize = CFI_QRY_MIN_MAP_SIZE;
 	struct cfi cfi;
 	int error, rv;
 
@@ -74,11 +74,12 @@ sandpointcfi_probe(device_t parent, cfda
 
 	cfi.cfi_bst = ma->ma_bst;
 
-	error = bus_space_map(cfi.cfi_bst, ma->ma_addr, tmpsize, 0,
+	/* flash should be at least 2 MiB in size at 0xffe0 */
+	error = bus_space_map(cfi.cfi_bst, 0xffe0, qrysize, 0,
 	_bsh);
 	if (error != 0) {
 		aprint_error("%s: cannot map %d at offset %#x, error %d\n",
-		__func__, tmpsize, ma->ma_addr, error);
+		__func__, qrysize, ma->ma_addr, error);
 		return 0;
 	}
 
@@ -90,7 +91,7 @@ sandpointcfi_probe(device_t parent, cfda
 	} else
 		rv = 1;
 
-	bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, tmpsize);
+	bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, qrysize);
 	return rv;
 }
 
@@ -99,7 +100,7 @@ sandpointcfi_attach(device_t parent, dev
 {
 	struct mainbus_attach_args *ma = aux;
 	struct sandpointcfi_softc *sc;
-	const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	const bus_size_t qrysize = CFI_QRY_MIN_MAP_SIZE;
 	bus_addr_t addr;
 	bool found;
 	int error;
@@ -112,7 +113,7 @@ sandpointcfi_attach(device_t parent, dev
 	sc->sc_cfi.cfi_bst = ma->ma_bst;
 
 	/* map enough to identify, remap later when size is known */
-	error = bus_space_map(sc->sc_cfi.cfi_bst, ma->ma_addr, tmpsize, 0,
+	error = bus_space_map(sc->sc_cfi.cfi_bst, 0xffe0, qrysize, 0,
 	>sc_cfi.cfi_bsh);
 	if (error != 0) {
 		aprint_error_dev(self, "could not map error %d\n", error);
@@ -122,7 +123,7 @@ sandpointcfi_attach(device_t parent, dev
 	/* identify the NOR flash */
 	found = cfi_identify(>sc_cfi);
 
-	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, tmpsize);
+	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, qrysize);
 	if (!found) {
 		/* should not happen, we already probed OK in match */
 		aprint_error_dev(self, "could not map error %d\n", error);
@@ -132,7 +133,7 @@ sandpointcfi_attach(device_t parent, dev
 	/* get size of flash in bytes */
 	sc->sc_size = 1 << sc->sc_cfi.cfi_qry_data.device_size;
 
-	/* real base address */
+	/* determine real base address */
 	addr = (0x - sc->sc_size) + 1;
 
 	sc->sc_nor_if = nor_interface_cfi;

Index: src/sys/arch/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.63 src/sys/arch/sandpoint/sandpoint/machdep.c:1.64
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.63	Sun Apr 21 15:42:12 2013
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Mon Sep  7 23:00:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.63 2013/04/21 15:42:12 kiyohara Exp $	*/
+/*	$NetBSD: machdep.c,v 1.64 2015/09/07 23:00:08 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.63 2013/04/21 15:42:12 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.64 2015/09/07 23:00:08 phx Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -450,8 +450,8 @@ struct powerpc_bus_space sandpoint_eumb_
 	0xfc00, 0x, 0x0010,
 };
 struct powerpc_bus_space sandpoint_flash_space_tag = {
-	_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
-	0x, 0xff00, 0x,
+	_BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,
+	0x, 0xff00, 0x,
 };
 struct powerpc_bus_space sandpoint_nhgpio_space_tag = {
 	

CVS commit: src/sys/arch/sandpoint/sandpoint

2015-09-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Sep  7 23:00:08 UTC 2015

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c machdep.c mainbus.c

Log Message:
Fix nor-flash bus space: extent limit should not be zero and bus space is
definitely big-endian. Reading the flash via /dev/flash0 works now.
Writing is untested.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/sandpoint/flash_cfi.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sandpoint/sandpoint/mainbus.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/sandpoint/sandpoint

2014-02-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Feb  7 08:51:34 UTC 2014

Modified Files:
src/sys/arch/sandpoint/sandpoint: locore.S

Log Message:
Remove enable_intr() and disable_intr(), which are unused.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/sandpoint/locore.S

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/sandpoint/sandpoint/locore.S
diff -u src/sys/arch/sandpoint/sandpoint/locore.S:1.23 src/sys/arch/sandpoint/sandpoint/locore.S:1.24
--- src/sys/arch/sandpoint/sandpoint/locore.S:1.23	Mon Jun 20 19:56:13 2011
+++ src/sys/arch/sandpoint/sandpoint/locore.S	Fri Feb  7 08:51:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.23 2011/06/20 19:56:13 matt Exp $	*/
+/*	$NetBSD: locore.S,v 1.24 2014/02/07 08:51:34 phx Exp $	*/
 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
 
 /*
@@ -129,20 +129,6 @@ __start:
 
 loop:	b	loop			/* not reached */
 
-	.globl	_C_LABEL(enable_intr)
-_C_LABEL(enable_intr):
-	mfmsr	3
-	ori	3,3,PSL_EE@l
-	mtmsr	3
-	blr
-
-	.globl	_C_LABEL(disable_intr)
-_C_LABEL(disable_intr):
-	mfmsr	3
-	andi.	3,3,~PSL_EE@l
-	mtmsr	3
-	blr
-
 	.globl	_C_LABEL(jump_to_ppc_reset_entry)
 _C_LABEL(jump_to_ppc_reset_entry):
 	mfmsr	3



CVS commit: src/sys/arch/sandpoint/sandpoint

2014-02-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Feb  7 08:51:34 UTC 2014

Modified Files:
src/sys/arch/sandpoint/sandpoint: locore.S

Log Message:
Remove enable_intr() and disable_intr(), which are unused.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/sandpoint/locore.S

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



CVS commit: src/sys/arch/sandpoint/sandpoint

2013-02-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Feb 19 15:58:19 UTC 2013

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Implement real hardware power-off for DSM-G600 using the ZWC command.
It seems that not all microcontrollers support the command, though, so
the old solution to flash the power LED is still present as a fallback.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.23 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.24
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.23	Tue May 15 02:14:13 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Tue Feb 19 15:58:19 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.23 2012/05/15 02:14:13 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.24 2013/02/19 15:58:19 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -847,8 +847,11 @@ static void
 dpwroff(struct satmgr_softc *sc)
 {
 
+	send_sat(sc, ZWC\n);
+
 	/*
-	 * The DSM-G600 has no hardware-shutdown, so we flash the power LED
+	 * When this line is reached, then this board revision doesn't
+	 * support hardware-shutdown, so we flash the power LED
 	 * to indicate that the device can be switched off.
 	 */
 	send_sat(sc, SYN\nSYN\n);



CVS commit: src/sys/arch/sandpoint/sandpoint

2013-02-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Feb 19 15:58:19 UTC 2013

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Implement real hardware power-off for DSM-G600 using the ZWC command.
It seems that not all microcontrollers support the command, though, so
the old solution to flash the power LED is still present as a fallback.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-05-14 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue May 15 02:14:13 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
A temporaly fix to avoid a lockup by KBT4 DISP button.  Not sure
the real fix.  Curse on the every poorly written engineering
documents on Earth.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.22 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.23
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.22	Fri May 11 21:40:49 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Tue May 15 02:14:13 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.22 2012/05/11 21:40:49 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.23 2012/05/15 02:14:13 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -1033,7 +1033,7 @@ mbtnintr(void *arg)
 	/* notified after 3 seconds guard time */
 	struct satmgr_softc *sc = arg;
 
-	send_sat(sc, \x80\x36); /* query button state */
+	send_sat(sc, \x80\x36\x4a); /* query button state with parity */
 	mutex_enter(sc-sc_replk);
 	sc-sc_btn_cnt = 0;
 	mutex_exit(sc-sc_replk);



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-05-14 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue May 15 02:14:13 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
A temporaly fix to avoid a lockup by KBT4 DISP button.  Not sure
the real fix.  Curse on the every poorly written engineering
documents on Earth.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-05-12 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sat May 12 13:13:24 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c iic_eumb.c

Log Message:
Move I2C node adjustment stuff to autoconf.c from iic_eumb.c for
the ease of maintainance.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.24 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.25
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.24	Thu Jan 19 07:38:06 2012
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Sat May 12 13:13:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.24 2012/01/19 07:38:06 nisimura Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.25 2012/05/12 13:13:24 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.24 2012/01/19 07:38:06 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.25 2012/05/12 13:13:24 nisimura Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -54,6 +54,25 @@ __KERNEL_RCSID(0, $NetBSD: autoconf.c,v
 static struct btinfo_rootdevice *bi_rdev;
 static struct btinfo_bootpath *bi_path;
 static struct btinfo_net *bi_net;
+static struct btinfo_prodfamily *bi_pfam;
+
+struct i2cdev {
+	const char *family;
+	const char *name;
+	int addr;
+};
+
+static struct i2cdev rtcmodel[] = {
+{ dlink,strtc,  0x68 },
+{ iomega,   dsrtc,  0x68 },
+{ kurobox,  rs5c372rtc, 0x32 },
+{ kurot4,   rs5c372rtc, 0x32 },
+{ nhnas,pcf8563rtc, 0x51 },
+{ qnap, s390rtc,0x30 },
+{ synology, rs5c372rtc, 0x32 },
+};
+
+static void add_i2c_child_devices(device_t, const char *);
 
 /*
  * Determine i/o configuration for a machine.
@@ -65,6 +84,7 @@ cpu_configure(void)
 	bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE);
 	bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
 	bi_net = lookup_bootinfo(BTINFO_NET);
+	bi_pfam = lookup_bootinfo(BTINFO_PRODFAMILY);
 
 	if (config_rootfound(mainbus, NULL) == NULL)
 		panic(configure: mainbus not configured);
@@ -105,8 +125,7 @@ device_register(device_t dev, void *aux)
 			net_tag = pa-pa_tag;
 		}
 	}
-
-	if (device_class(dev) == DV_IFNET) {
+	else if (device_class(dev) == DV_IFNET) {
 		if (device_is_a(device_parent(dev), pci)) {
 			pa = aux;
 			tag = pa-pa_tag;
@@ -136,10 +155,41 @@ device_register(device_t dev, void *aux)
 			bi_net = NULL;	/* do it just once */
 		}
 	}
-	if (bi_rdev != NULL  device_class(dev) == DV_DISK
+	else if (bi_rdev != NULL  device_class(dev) == DV_DISK
 	 device_is_a(dev, bi_rdev-devname)
 	 device_unit(dev) == (bi_rdev-cookie  8)) {
 		booted_device = dev;
 		booted_partition = bi_rdev-cookie  0xff;
 	}
+	else if (device_is_a(dev, ociic)  bi_pfam != NULL) {
+		add_i2c_child_devices(dev, bi_pfam-name);
+	}
+}
+
+static void
+add_i2c_child_devices(device_t self, const char *family)
+{
+	struct i2cdev *rtc;
+	prop_dictionary_t pd;
+	prop_array_t pa;
+	int i;
+
+	rtc = NULL;
+	for (i = 0; i  (int)(sizeof(rtcmodel)/sizeof(rtcmodel[0])); i++) {
+		if (strcmp(family, rtcmodel[i].family) == 0) {
+			rtc = rtcmodel[i];
+			goto found;
+		}
+	}
+	return;
+
+ found:
+	pd = prop_dictionary_create();
+	pa = prop_array_create();
+	prop_dictionary_set_cstring_nocopy(pd, name, rtc-name);
+	prop_dictionary_set_uint32(pd, addr, rtc-addr);
+	prop_array_add(pa, pd);
+	prop_dictionary_set(device_properties(self), i2c-child-devices, pa);
+	prop_object_release(pd);
+	prop_object_release(pa);
 }

Index: src/sys/arch/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.18 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.19
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.18	Fri May 11 21:12:34 2012
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Sat May 12 13:13:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.19 2012/05/12 13:13:24 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.19 2012/05/12 13:13:24 nisimura Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -37,7 +37,6 @@ __KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v
 #include sys/bus.h
 #include dev/i2c/motoi2cvar.h
 #include sandpoint/sandpoint/eumbvar.h
-#include machine/bootinfo.h
 
 struct iic_eumb_softc {
 	device_t		sc_dev;
@@ -52,24 +51,6 @@ CFATTACH_DECL_NEW(iic_eumb, sizeof(struc
 
 static int found;
 
-struct i2cdev {
-	const char *family;
-	const char *name;
-	int addr;
-};
-

CVS commit: src/sys/arch/sandpoint/sandpoint

2012-05-12 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sat May 12 13:13:24 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c iic_eumb.c

Log Message:
Move I2C node adjustment stuff to autoconf.c from iic_eumb.c for
the ease of maintainance.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2012-05-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri May 11 21:12:35 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c satmgr.c

Log Message:
make sure to have the correct I2C TOD attached for KURO-BOX/T4.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/sandpoint/iic_eumb.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.17 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.18
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.17	Sat Jan  7 21:03:05 2012
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Fri May 11 21:12:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.17 2012/01/07 21:03:05 phx Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.17 2012/01/07 21:03:05 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -62,6 +62,7 @@ static struct i2cdev rtcmodel[] = {
 { dlink,strtc,  0x68 },
 { iomega,   dsrtc,  0x68 },
 { kurobox,  rs5c372rtc, 0x32 },
+{ kurot4,   rs5c372rtc, 0x32 },
 { qnap, s390rtc,0x30 },
 { synology, rs5c372rtc, 0x32 },
 { nhnas,pcf8563rtc, 0x51 }

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.20 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.21
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.20	Tue Apr 24 10:09:06 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Fri May 11 21:12:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.20 2012/04/24 10:09:06 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.21 2012/05/11 21:12:34 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/param.h
-#include sys/systm.h	
+#include sys/systm.h
 #include sys/kernel.h
 #include sys/device.h
 #include sys/conf.h
@@ -81,6 +81,8 @@ struct satmgr_softc {
 	char			sc_btn_buf[8];
 	int			sc_btn_cnt;
 	char			sc_cmd_buf[8];
+	kmutex_t		sc_replk;
+	kcondvar_t		sc_repcv;
 	int			sc_sysctl_wdog;
 	int			sc_sysctl_fanlow;
 	int			sc_sysctl_fanhigh;
@@ -120,10 +122,10 @@ static void rxintr(struct satmgr_softc *
 static void txintr(struct satmgr_softc *);
 static void startoutput(struct satmgr_softc *);
 static void swintr(void *);
-static void minit(struct satmgr_softc *);
-static void sinit(struct satmgr_softc *);
-static void qinit(struct satmgr_softc *);
-static void iinit(struct satmgr_softc *);
+static void minit(device_t);
+static void sinit(device_t);
+static void qinit(device_t);
+static void iinit(device_t);
 static void kreboot(struct satmgr_softc *);
 static void mreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
@@ -141,15 +143,15 @@ static void sbutton(struct satmgr_softc 
 static void qbutton(struct satmgr_softc *, int);
 static void dbutton(struct satmgr_softc *, int);
 static void ibutton(struct satmgr_softc *, int);
-static void idosync(void *);
-static void iprepcmd(struct satmgr_softc *, int, int, int, int, int, int);
+static void msattalk(struct satmgr_softc *, const char *);
+static void isattalk(struct satmgr_softc *, int, int, int, int, int, int);
 static int  mbtnintr(void *);
 static void guarded_pbutton(void *);
 static void sched_sysmon_pbutton(void *);
 
 struct satops {
 	const char *family;
-	void (*init)(struct satmgr_softc *);
+	void (*init)(device_t);
 	void (*reboot)(struct satmgr_softc *);
 	void (*pwroff)(struct satmgr_softc *);
 	void (*dispatch)(struct satmgr_softc *, int);
@@ -199,7 +201,7 @@ satmgr_attach(device_t parent, device_t 
 	int i, sataddr, epicirq;
 
 	found = 1;
-	
+
 	if ((pfam = lookup_bootinfo(BTINFO_PRODFAMILY)) == NULL)
 		goto notavail;
 	ops = NULL;
@@ -235,6 +237,8 @@ satmgr_attach(device_t parent, device_t 
 	cv_init(sc-sc_rdcv, satrd);
 	cv_init(sc-sc_wrcv, satwr);
 	sc-sc_btn_cnt = 0;
+	mutex_init(sc-sc_replk, MUTEX_DEFAULT, IPL_SERIAL);
+	cv_init(sc-sc_repcv, stalk);
 
 	epicirq = (eaa-eumb_unit == 0) ? 24 : 25;
 	intr_establish(epicirq + I8259_ICU, IST_LEVEL, IPL_SERIAL, hwintr, sc);
@@ -312,8 +316,8 @@ satmgr_attach(device_t parent, device_t 
 	}
 
 	md_reboot = satmgr_reboot;	/* cpu_reboot() hook */
-	if (ops-init != NULL)
-		(*ops-init)(sc);	/* init sat.cpu, LEDs, etc. */
+	if (ops-init != NULL)		/* init sat.cpu, LEDs, etc. */
+		config_interrupts(self, ops-init);
 	return;
 
   notavail:
@@ -394,7 +398,7 @@ satmgr_sysctl_fanlow(SYSCTLFN_ARGS)
 	if (t  0 || t  99)
 		return EINVAL;
 	sc-sc_sysctl_fanlow = t;
-	iprepcmd(sc, 'b', 'b', 10, 'a',
+	isattalk(sc, 'b', 'b', 10, 'a',
 	

CVS commit: src/sys/arch/sandpoint/sandpoint

2012-05-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri May 11 21:40:50 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
A temporary solution to have KURO-BOX/T4 two way dialogue style
sat protocol. Need more work for robustness. Unbreak the previous
commit made by accident.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.21 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.22
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.21	Fri May 11 21:12:34 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Fri May 11 21:40:49 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.21 2012/05/11 21:12:34 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.22 2012/05/11 21:40:49 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -695,9 +695,6 @@ startoutput(struct satmgr_softc *sc)
 	int n;
 
 	mutex_enter(sc-sc_replk);
-		mutex_exit(sc-sc_replk);
-		return;
-	}
 	n = min(sc-sc_wr_cnt, 16);
 	while (n--  0) {
 		CSR_WRITE(sc, THR, *sc-sc_wr_ptr);
@@ -1039,7 +1036,7 @@ mbtnintr(void *arg)
 	send_sat(sc, \x80\x36); /* query button state */
 	mutex_enter(sc-sc_replk);
 	sc-sc_btn_cnt = 0;
-	mutex_exit(sc-sc_replk);
+	mutex_exit(sc-sc_replk);
 	return 1;
 }
 



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-05-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri May 11 21:12:35 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c satmgr.c

Log Message:
make sure to have the correct I2C TOD attached for KURO-BOX/T4.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/sandpoint/iic_eumb.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-05-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri May 11 21:40:50 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
A temporary solution to have KURO-BOX/T4 two way dialogue style
sat protocol. Need more work for robustness. Unbreak the previous
commit made by accident.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-04-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Apr 24 10:09:06 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Quick fixes to make KURO-BOX/T4 miconv2 power management work.
The patch was supplied by mef@.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.19 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.20
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.19	Mon Apr 16 14:30:42 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Tue Apr 24 10:09:06 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.19 2012/04/16 14:30:42 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.20 2012/04/24 10:09:06 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -997,7 +997,9 @@ msattalk(struct satmgr_softc *sc, const 
 	CSR_WRITE(sc, IER, 0);
 	send_sat_len(sc, cmd, len);
 	send_sat_len(sc, pa, 1);
+	 DELAY(2000); /* XXX */
 	recv_sat_len(sc, rep, n);
+	 DELAY(2000); /* XXX */
 	CSR_WRITE(sc, IER, 0x7f);
 }
 
@@ -1042,10 +1044,10 @@ mbtnintr(void *arg)
 {
 	/* notified after 3 seconds guard time */
 	struct satmgr_softc *sc = arg;
-	char report[2];
+	char report[4];
 
-	msattalk(sc, \x80\x36, report, 2);
-	if ((report[0]  01) == 0) /* power button depressed */
+	msattalk(sc, \x80\x36, report, 4);
+	if ((report[2]  01) == 0) /* power button depressed */
 		sysmon_task_queue_sched(0, sched_sysmon_pbutton, sc);
 	return 1;
 }



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-04-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Apr 24 10:09:06 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Quick fixes to make KURO-BOX/T4 miconv2 power management work.
The patch was supplied by mef@.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-04-16 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Apr 16 14:30:42 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Preliminary support of TS-TGL/KBT4 power down operation.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.18 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.19
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.18	Mon Apr  9 13:26:37 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Mon Apr 16 14:30:42 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.18 2012/04/09 13:26:37 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.19 2012/04/16 14:30:42 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -120,26 +120,30 @@ static void rxintr(struct satmgr_softc *
 static void txintr(struct satmgr_softc *);
 static void startoutput(struct satmgr_softc *);
 static void swintr(void *);
+static void minit(struct satmgr_softc *);
 static void sinit(struct satmgr_softc *);
 static void qinit(struct satmgr_softc *);
 static void iinit(struct satmgr_softc *);
 static void kreboot(struct satmgr_softc *);
+static void mreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
 static void ireboot(struct satmgr_softc *);
 static void kpwroff(struct satmgr_softc *);
+static void mpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
 static void dpwroff(struct satmgr_softc *);
 static void ipwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
+static void mbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
 static void dbutton(struct satmgr_softc *, int);
 static void ibutton(struct satmgr_softc *, int);
 static void idosync(void *);
 static void iprepcmd(struct satmgr_softc *, int, int, int, int, int, int);
-static void mbutton(struct satmgr_softc *, int);
+static int  mbtnintr(void *);
 static void guarded_pbutton(void *);
 static void sched_sysmon_pbutton(void *);
 
@@ -155,7 +159,7 @@ static struct satops satmodel[] = {
 { dlink,NULL,  NULL,dpwroff, dbutton },
 { iomega,   iinit, ireboot, ipwroff, ibutton },
 { kurobox,  NULL,  kreboot, kpwroff, kbutton },
-{ kurot4,   NULL,  NULL,NULL,mbutton },
+{ kurot4,   minit, mreboot, mpwroff, mbutton },
 { qnap, qinit, qreboot, qpwroff, qbutton },
 { synology, sinit, sreboot, spwroff, sbutton }
 };
@@ -302,6 +306,10 @@ satmgr_attach(device_t parent, device_t 
 			satmgr_sysctl_fanhigh, 0, NULL, 0,
 			CTL_CREATE, CTL_EOL);
 	}
+	else if (strcmp(ops-family, kurot4) == 0) {
+		intr_establish(2 + I8259_ICU,
+			IST_LEVEL, IPL_SERIAL, mbtnintr, sc);
+	}
 
 	md_reboot = satmgr_reboot;	/* cpu_reboot() hook */
 	if (ops-init != NULL)
@@ -438,6 +446,24 @@ send_sat_len(struct satmgr_softc *sc, co
 		goto again;
 }
 
+static void
+recv_sat_len(struct satmgr_softc *sc, char *buf, int len)
+{
+	int lsr;
+
+	lsr = CSR_READ(sc, LSR);
+	while (len  0  (lsr  LSR_RXRDY)) {
+		if (lsr  (LSR_BI | LSR_FE | LSR_PE)) {
+			(void) CSR_READ(sc, RBR);
+			lsr = CSR_READ(sc, LSR);
+			continue;
+		}
+		*buf++ = CSR_READ(sc, RBR);
+		len -= 1;
+		lsr = CSR_READ(sc, LSR);
+	}
+}
+
 static int
 satopen(dev_t dev, int flags, int fmt, struct lwp *l)
 {
@@ -721,14 +747,14 @@ static void
 kreboot(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, CCGG);
+	send_sat(sc, CCGG); /* perform reboot */
 }
 
 static void
 kpwroff(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, EEGG);
+	send_sat(sc, EEGG); /* force power off */
 }
 
 static void
@@ -951,10 +977,77 @@ iprepcmd(struct satmgr_softc *sc, int po
 	 */
 }
 
+static void msattalk(struct satmgr_softc *, const char *, char *, int);
+
+static void
+msattalk(struct satmgr_softc *sc, const char *cmd, char *rep, int n)
+{
+	int len, i;
+	uint8_t pa;
+
+	if (cmd[0] != 0x80)
+		len = 2 + cmd[0]; /* cmd[0] is data portion length */
+	else
+		len = 2; /* read report */
+
+	for (i = 0, pa = 0; i  len; i++)
+		pa += cmd[i];
+	pa = 0 - pa; /* parity formula */
+
+	CSR_WRITE(sc, IER, 0);
+	send_sat_len(sc, cmd, len);
+	send_sat_len(sc, pa, 1);
+	recv_sat_len(sc, rep, n);
+	CSR_WRITE(sc, IER, 0x7f);
+}
+
+static void
+minit(struct satmgr_softc *sc)
+{
+	char report[4];
+
+	msattalk(sc, \x00\x03, report, 4);	/* boot has completed */
+}
+
+static void
+mreboot(struct satmgr_softc *sc)
+{
+	char report[4];
+
+	msattalk(sc, \x01\x35\x00, report, 4); /* stop watchdog timer */
+	msattalk(sc, \x00\x0c, report, 4);	 /* shutdown in progress */
+	msattalk(sc, \x00\x03, report, 4);	 /* boot has completed */
+	msattalk(sc, \x00\x0e, report, 4);	 /* 

CVS commit: src/sys/arch/sandpoint/sandpoint

2012-04-16 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Apr 16 14:30:42 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Preliminary support of TS-TGL/KBT4 power down operation.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-04-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Apr  8 12:11:58 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add an entry for miconv2 satellite processor control.  The button
press event handler remains unimplemented for now.  Use /dev/satmgr
to talk the processor.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.16 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.17
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.16	Wed Feb 22 22:56:44 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sun Apr  8 12:11:57 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.16 2012/02/22 22:56:44 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.17 2012/04/08 12:11:57 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -139,6 +139,7 @@ static void dbutton(struct satmgr_softc 
 static void ibutton(struct satmgr_softc *, int);
 static void idosync(void *);
 static void iprepcmd(struct satmgr_softc *, int, int, int, int, int, int);
+static void mbutton(struct satmgr_softc *, int);
 static void guarded_pbutton(void *);
 static void sched_sysmon_pbutton(void *);
 
@@ -154,6 +155,7 @@ static struct satops satmodel[] = {
 { dlink,NULL,  NULL,dpwroff, dbutton },
 { iomega,   iinit, ireboot, ipwroff, ibutton },
 { kurobox,  NULL,  kreboot, kpwroff, kbutton },
+{ miconv2,  NULL,  NULL,NULL,mbutton },
 { qnap, qinit, qreboot, qpwroff, qbutton },
 { synology, sinit, sreboot, spwroff, sbutton }
 };
@@ -950,6 +952,12 @@ iprepcmd(struct satmgr_softc *sc, int po
 }
 
 static void
+mbutton(struct satmgr_softc *sc, int ch)
+{
+	/* do nothing */
+}
+
+static void
 guarded_pbutton(void *arg)
 {
 	struct satmgr_softc *sc = arg;



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-04-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Apr  8 12:11:58 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add an entry for miconv2 satellite processor control.  The button
press event handler remains unimplemented for now.  Use /dev/satmgr
to talk the processor.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-02-22 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Feb 22 22:56:44 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
- fix an error which prevents satmgr from sending NUL bytes.
- a bit cosmetic change for IOMEGA multibyte control sequence.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.15 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.16
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.15	Mon Jan 23 16:22:58 2012
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Wed Feb 22 22:56:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.15 2012/01/23 16:22:58 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.16 2012/02/22 22:56:44 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -678,11 +678,11 @@ txintr(struct satmgr_softc *sc)
 static void
 startoutput(struct satmgr_softc *sc)
 {
-	int n, ch;
+	int n;
 
 	n = min(sc-sc_wr_cnt, 16);
-	while ((ch = *sc-sc_wr_ptr)  n--  0) {
-		CSR_WRITE(sc, THR, ch);
+	while (n--  0) {
+		CSR_WRITE(sc, THR, *sc-sc_wr_ptr);
 		if (++sc-sc_wr_ptr == sc-sc_wr_lim)
 			sc-sc_wr_ptr = sc-sc_wr_buf[0];
 		sc-sc_wr_cnt -= 1;
@@ -933,13 +933,13 @@ iprepcmd(struct satmgr_softc *sc, int po
 	 * Construct the command packet. Values of -1 (0xff) will be
 	 * replaced later by the current values from the last status.
 	 */
-	*p++ = pow;
-	*p++ = led;
-	*p++ = rat;
-	*p++ = fan;
-	*p++ = fhi;
-	*p++ = flo;
-	*p = 7; /* host id */
+	p[0] = pow;
+	p[1] = led;
+	p[2] = rat;
+	p[3] = fan;
+	p[4] = fhi;
+	p[5] = flo;
+	p[6] = 7; /* host id */
 
 	/* synchronize transmitter, before packet can be sent */
 	callout_reset(sc-sc_ch_sync, hz / 5, idosync, sc);



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-02-22 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Feb 22 22:56:44 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
- fix an error which prevents satmgr from sending NUL bytes.
- a bit cosmetic change for IOMEGA multibyte control sequence.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2012-02-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Feb 10 12:02:33 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
oea_batinit() demands a minimum block size of 8M now. OK by releng@.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.61 src/sys/arch/sandpoint/sandpoint/machdep.c:1.62
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.61	Sat Jan 14 19:39:25 2012
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Fri Feb 10 12:02:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.61 2012/01/14 19:39:25 phx Exp $	*/
+/*	$NetBSD: machdep.c,v 1.62 2012/02/10 12:02:33 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.61 2012/01/14 19:39:25 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.62 2012/02/10 12:02:33 phx Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_ddb.h
@@ -173,7 +173,7 @@ initppc(u_int startkernel, u_int endkern
 	oea_batinit(
 	0x8000, BAT_BL_256M,	/* SANDPOINT_BUS_SPACE_MEM */
 	0xfc00, BAT_BL_64M,	/* _EUMB|_IO */
-	0x7000, BAT_BL_128K,	/* only for NH230 board control */
+	0x7000, BAT_BL_8M,	/* only for NH230 board control */
 	0);
 
 	/* Install vectors and interrupt handler */



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-02-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Feb 10 12:02:33 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
oea_batinit() demands a minimum block size of 8M now. OK by releng@.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint

2012-01-31 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Jan 31 21:12:03 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: mainbus.c

Log Message:
Print MPC8245 cpu speed. We can calculate it using the PLL ratio.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/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/sandpoint/sandpoint/mainbus.c
diff -u src/sys/arch/sandpoint/sandpoint/mainbus.c:1.28 src/sys/arch/sandpoint/sandpoint/mainbus.c:1.29
--- src/sys/arch/sandpoint/sandpoint/mainbus.c:1.28	Fri Jan 27 18:53:00 2012
+++ src/sys/arch/sandpoint/sandpoint/mainbus.c	Tue Jan 31 21:12:03 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.28 2012/01/27 18:53:00 para Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.29 2012/01/31 21:12:03 phx Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.28 2012/01/27 18:53:00 para Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.29 2012/01/31 21:12:03 phx Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, $NetBSD: mainbus.c,v 
 #include machine/bootinfo.h
 #include machine/isa_machdep.h
 
+#include powerpc/oea/spr.h
+
 #include dev/pci/pcivar.h
 #include dev/pci/pciconf.h
 
@@ -150,6 +152,7 @@ cpu_match(device_t parent, cfdata_t cf, 
 
 	if (strcmp(mba-ma_name, cpu_cd.cd_name) != 0)
 		return 0;
+
 	if (cpu_info[0].ci_dev != NULL)
 		return 0;
 
@@ -159,8 +162,29 @@ cpu_match(device_t parent, cfdata_t cf, 
 void
 cpu_attach(device_t parent, device_t self, void *aux)
 {
-
-	(void)cpu_attach_common(self, 0);
+	static uint8_t mem_to_cpuclk[] = {
+		25, 30, 45, 20, 20, 00, 10, 30,
+		30, 20, 45, 30, 25, 35, 30, 35,
+		20, 25, 20, 30, 35, 40, 40, 20,
+		30, 25, 40, 30, 30, 25, 35, 00
+	};
+	extern u_long ticks_per_sec;
+	struct cpu_info *ci;
+	u_int hid1, vers;
+
+	ci = cpu_attach_common(self, 0);
+	if (ci == NULL)
+		return;
+
+	vers = (mfpvr()  16)  0x;
+	if (ci-ci_khz == 0  vers == MPC8245) {
+		/* calculate speed from bus clock and PLL ratio */
+		asm volatile (mfspr %0,1009 : =r(hid1));
+		ci-ci_khz = ((uint64_t)ticks_per_sec * 4 *
+		mem_to_cpuclk[hid1  27] + 10) / 1;
+		aprint_normal_dev(self, %u.%02u MHz\n,
+		ci-ci_khz / 1000, (ci-ci_khz / 10) % 100);
+	}
 }
 
 int



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-31 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Jan 31 21:12:03 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: mainbus.c

Log Message:
Print MPC8245 cpu speed. We can calculate it using the PLL ratio.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sandpoint/sandpoint/mainbus.c

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



Re: CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-30 Thread Frank Wille
David Young wrote:

 You should be able to detach it so that you know that the driver can
 return the hardware to initial conditions, and so that in a modular
 universe you can unload the old driver software and load new.

Ok, you're right. I forgot about the modules. I have reverted my changes.

-- 
Frank Wille


CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 30 15:47:01 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
Revert my last modification.
The detach function might make sense to unload and replace a driver module.
http://mail-index.netbsd.org/source-changes-d/2012/01/24/msg004538.html


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/sandpoint/flash_cfi.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/sandpoint/sandpoint/flash_cfi.c
diff -u src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.2 src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3
--- src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.2	Mon Jan 23 15:16:37 2012
+++ src/sys/arch/sandpoint/sandpoint/flash_cfi.c	Mon Jan 30 15:47:01 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: flash_cfi.c,v 1.2 2012/01/23 15:16:37 phx Exp $ */
+/* $NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -32,7 +32,7 @@
  * NOR CFI driver support for sandpoint
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: flash_cfi.c,v 1.2 2012/01/23 15:16:37 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, $NetBSD: flash_cfi.c,
 
 static int  sandpointcfi_probe(device_t, cfdata_t, void *);
 static void sandpointcfi_attach(device_t, device_t, void *);
+static int  sandpointcfi_detach(device_t, int);
 
 struct sandpointcfi_softc {
 	device_t		sc_dev;
@@ -55,7 +56,7 @@ struct sandpointcfi_softc {
 };
 
 CFATTACH_DECL_NEW(sandpointcfi, sizeof(struct sandpointcfi_softc),
-sandpointcfi_probe, sandpointcfi_attach, NULL, NULL);
+sandpointcfi_probe, sandpointcfi_attach, sandpointcfi_detach, NULL);
 
 static int
 sandpointcfi_probe(device_t parent, cfdata_t cf, void *aux)
@@ -152,3 +153,20 @@ sandpointcfi_attach(device_t parent, dev
 
 	sc-sc_nordev = nor_attach_mi(sc-sc_nor_if, self);
 }
+
+static int
+sandpointcfi_detach(device_t self, int flags)
+{
+	struct sandpointcfi_softc *sc;
+	int rv;
+
+	pmf_device_deregister(self);
+	sc = device_private(self);
+	rv = 0;
+
+	if (sc-sc_nordev != NULL)
+		rv = config_detach(sc-sc_nordev, flags);
+
+	bus_space_unmap(sc-sc_cfi.cfi_bst, sc-sc_cfi.cfi_bsh, sc-sc_size);
+	return rv;
+}



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 30 15:47:01 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
Revert my last modification.
The detach function might make sense to unload and replace a driver module.
http://mail-index.netbsd.org/source-changes-d/2012/01/24/msg004538.html


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/sandpoint/flash_cfi.c

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



Re: CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-24 Thread Frank Wille
On Mon, 23 Jan 2012 18:52:11 -0600
David Young dyo...@pobox.com wrote:

  Log Message:
  A detach function for the onboard flash probably makes no sense, so
  remove it.
 
 Sure it makes sense.

Hmm... how do you detach it? With drvctl(8)? Why should you do that?


 Has it been tested, though?

The detach function? No.


Regards,

-- 
Frank Wille


Re: CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-24 Thread David Young
On Tue, Jan 24, 2012 at 12:10:07PM +0100, Frank Wille wrote:
 On Mon, 23 Jan 2012 18:52:11 -0600
 David Young dyo...@pobox.com wrote:
 
   Log Message:
   A detach function for the onboard flash probably makes no sense, so
   remove it.
  
  Sure it makes sense.
 
 Hmm... how do you detach it? With drvctl(8)? Why should you do that?

drvctl -d device

You should be able to detach it so that you know that the driver can
return the hardware to initial conditions, and so that in a modular
universe you can unload the old driver software and load new.

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981


Re: CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-24 Thread David Holland
On Tue, Jan 24, 2012 at 09:07:47PM +0100, Frank Wille wrote:
 A detach function for the onboard flash probably makes no sense,
 so remove it.

Sure it makes sense.
   
   Hmm... how do you detach it? With drvctl(8)? Why should you do that?
  
   Power consumption comes to mind...
  
  I doubt that detaching the driver will change power consumption a lot.
  And I cannot remove the NOR flash chip from the mainboard. ;)

It does if you have to detach the driver to power the thing off.

Then again, I'm making this up as I go along as I have no idea what
power management for flash actually looks like.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-23 Thread David Young
On Mon, Jan 23, 2012 at 03:16:38PM +, Frank Wille wrote:
 Module Name:  src
 Committed By: phx
 Date: Mon Jan 23 15:16:38 UTC 2012
 
 Modified Files:
   src/sys/arch/sandpoint/sandpoint: flash_cfi.c
 
 Log Message:
 A detach function for the onboard flash probably makes no sense, so remove it.

Sure it makes sense.

Has it been tested, though?

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981


CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-23 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 23 15:16:38 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
A detach function for the onboard flash probably makes no sense, so remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/sandpoint/flash_cfi.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/sandpoint/sandpoint

2012-01-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan  7 21:03:06 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Configure pcf8563rtc for nhnas models.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.16 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.17
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.16	Fri Jul  1 19:16:06 2011
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Sat Jan  7 21:03:05 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.16 2011/07/01 19:16:06 dyoung Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.17 2012/01/07 21:03:05 phx Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.16 2011/07/01 19:16:06 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.17 2012/01/07 21:03:05 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -64,6 +64,7 @@ static struct i2cdev rtcmodel[] = {
 { kurobox,  rs5c372rtc, 0x32 },
 { qnap, s390rtc,0x30 },
 { synology, rs5c372rtc, 0x32 },
+{ nhnas,pcf8563rtc, 0x51 }
 };
 
 static void add_i2c_child_devices(device_t, const char *);



CVS commit: src/sys/arch/sandpoint/sandpoint

2012-01-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan  7 21:03:06 UTC 2012

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Configure pcf8563rtc for nhnas models.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2011-12-29 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Dec 29 10:27:36 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c satmgr.c

Log Message:
Replaced 16 by I8259_ICU in intr_establish().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/sandpoint/com_eumb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/com_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.7 src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.8
--- src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.7	Fri Jul  1 19:16:06 2011
+++ src/sys/arch/sandpoint/sandpoint/com_eumb.c	Thu Dec 29 10:27:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: com_eumb.c,v 1.7 2011/07/01 19:16:06 dyoung Exp $ */
+/* $NetBSD: com_eumb.c,v 1.8 2011/12/29 10:27:36 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: com_eumb.c,v 1.7 2011/07/01 19:16:06 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: com_eumb.c,v 1.8 2011/12/29 10:27:36 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -101,8 +101,9 @@ com_eumb_attach(device_t parent, device_
 
 	com_attach_subr(sc);
 
-	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, comintr, sc);
-	aprint_normal_dev(self, interrupting at irq %d\n, epicirq + 16);
+	intr_establish(epicirq + I8259_ICU, IST_LEVEL, IPL_SERIAL, comintr, sc);
+	aprint_normal_dev(self, interrupting at irq %d\n,
+	epicirq + I8259_ICU);
 }
 
 int

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.13 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.14
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.13	Sat Nov 12 23:57:55 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Thu Dec 29 10:27:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.13 2011/11/12 23:57:55 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.14 2011/12/29 10:27:36 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -230,8 +230,9 @@ satmgr_attach(device_t parent, device_t 
 	sc-sc_btn_cnt = 0;
 
 	epicirq = (eaa-eumb_unit == 0) ? 24 : 25;
-	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, hwintr, sc);
-	aprint_normal_dev(self, interrupting at irq %d\n, epicirq + 16);
+	intr_establish(epicirq + I8259_ICU, IST_LEVEL, IPL_SERIAL, hwintr, sc);
+	aprint_normal_dev(self, interrupting at irq %d\n,
+	epicirq + I8259_ICU);
 	sc-sc_si = softint_establish(SOFTINT_SERIAL, swintr, sc);
 
 	CSR_WRITE(sc, IER, 0x7f); /* all but MSR */



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-12-29 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Dec 29 10:27:36 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c satmgr.c

Log Message:
Replaced 16 by I8259_ICU in intr_establish().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/sandpoint/com_eumb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-12-18 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Dec 18 14:29:00 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: eumb.c mainbus.c

Log Message:
Replaced conf_args by mainbus_attach_args.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/eumb.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sandpoint/sandpoint/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/sandpoint/sandpoint/eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/eumb.c:1.5 src/sys/arch/sandpoint/sandpoint/eumb.c:1.6
--- src/sys/arch/sandpoint/sandpoint/eumb.c:1.5	Fri Jul  1 19:16:06 2011
+++ src/sys/arch/sandpoint/sandpoint/eumb.c	Sun Dec 18 14:28:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: eumb.c,v 1.5 2011/07/01 19:16:06 dyoung Exp $ */
+/* $NetBSD: eumb.c,v 1.6 2011/12/18 14:28:59 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,14 +30,14 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: eumb.c,v 1.5 2011/07/01 19:16:06 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: eumb.c,v 1.6 2011/12/18 14:28:59 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
 #include sys/tty.h
 #include sys/systm.h
 
-#include sys/bus.h
+#include machine/autoconf.h
 #include machine/intr.h
 
 #include sandpoint/sandpoint/eumbvar.h
@@ -56,33 +56,35 @@ extern struct cfdriver eumb_cd;
 static int
 eumb_match(device_t parent, cfdata_t cf, void *aux)
 {
-	const char **ca_name = aux; /* XXX */
+	struct mainbus_attach_args *ma = aux;
 
-	if (strcmp(*ca_name, eumb_cd.cd_name) != 0)
-		return (0);
-	return (1);
+	if (strcmp(ma-ma_name, eumb_cd.cd_name) != 0)
+		return 0;
+	return 1;
 }
 
 static void
 eumb_attach(device_t parent, device_t self, void *aux)
 {
 
-	printf(\n);
-	config_search_ia(eumb_search, self, eumb, NULL);
+	aprint_naive(\n);
+	aprint_normal(\n);
+	config_search_ia(eumb_search, self, eumb, aux);
 }
 
 static int
 eumb_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
+	struct mainbus_attach_args *ma = aux;
 	struct eumb_attach_args eaa;
 
 	eaa.eumb_name = cf-cf_name;
-	eaa.eumb_bt = sandpoint_eumb_space_tag;
+	eaa.eumb_bt = ma-ma_bst;
 	eaa.eumb_unit = cf-cf_loc[EUMBCF_UNIT];
 if (config_match(parent, cf, eaa)  0)
 config_attach(parent, cf, eaa, eumb_print);
 
-	return (0);
+	return 0;
 }
 
 static int
@@ -94,5 +96,5 @@ eumb_print(void *aux, const char *pnp)
 		printf(%s at %s, eaa-eumb_name, pnp);
 	if (eaa-eumb_unit != EUMBCF_UNIT_DEFAULT)
 		printf( unit %d, eaa-eumb_unit);
-	return (UNCONF);
+	return UNCONF;
 }

Index: src/sys/arch/sandpoint/sandpoint/mainbus.c
diff -u src/sys/arch/sandpoint/sandpoint/mainbus.c:1.25 src/sys/arch/sandpoint/sandpoint/mainbus.c:1.26
--- src/sys/arch/sandpoint/sandpoint/mainbus.c:1.25	Sat Dec 17 20:20:38 2011
+++ src/sys/arch/sandpoint/sandpoint/mainbus.c	Sun Dec 18 14:28:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.25 2011/12/17 20:20:38 phx Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.25 2011/12/17 20:20:38 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -48,11 +48,6 @@ __KERNEL_RCSID(0, $NetBSD: mainbus.c,v 
 #include dev/pci/pcivar.h
 #include dev/pci/pciconf.h
 
-/* XXX go away! */
-struct conf_args {
-	const char *ca_name;
-};
-
 int	mainbus_match(device_t, cfdata_t, void *);
 void	mainbus_attach(device_t, device_t, void *);
 int	mainbus_print(void *, const char *);
@@ -78,7 +73,6 @@ mainbus_match(device_t parent, cfdata_t 
 void
 mainbus_attach(device_t parent, device_t self, void *aux)
 {
-	struct conf_args ca;
 	struct mainbus_attach_args mba;
 	struct pcibus_attach_args pba;
 #if defined(PCI_NETBSD_CONFIGURE)
@@ -88,10 +82,12 @@ mainbus_attach(device_t parent, device_t
 	aprint_naive(\n);
 	aprint_normal(\n);
 
-	ca.ca_name = cpu;
-	config_found_ia(self, mainbus, ca, mainbus_print);
-	ca.ca_name = eumb;
-	config_found_ia(self, mainbus, ca, mainbus_print);
+	mba.ma_name = cpu;
+	config_found_ia(self, mainbus, mba, mainbus_print);
+
+	mba.ma_name = eumb;
+	mba.ma_bst = sandpoint_eumb_space_tag;
+	config_found_ia(self, mainbus, mba, mainbus_print);
 
 	mba.ma_name = cfi;
 	mba.ma_bst = sandpoint_flash_space_tag;
@@ -140,9 +136,9 @@ extern struct cfdriver cpu_cd;
 int
 cpu_match(device_t parent, cfdata_t cf, void *aux)
 {
-	struct conf_args *ca = aux;
+	struct mainbus_attach_args *mba = aux;
 
-	if (strcmp(ca-ca_name, cpu_cd.cd_name) != 0)
+	if (strcmp(mba-ma_name, cpu_cd.cd_name) != 0)
 		return 0;
 	if (cpu_info[0].ci_dev != NULL)
 		return 0;
@@ -154,15 +150,15 @@ void
 cpu_attach(device_t parent, device_t self, void *aux)
 {
 
-	(void) cpu_attach_common(self, 0);
+	

CVS commit: src/sys/arch/sandpoint/sandpoint

2011-12-18 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Dec 18 14:29:00 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: eumb.c mainbus.c

Log Message:
Replaced conf_args by mainbus_attach_args.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/eumb.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sandpoint/sandpoint/mainbus.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/sandpoint/sandpoint

2011-11-22 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Nov 22 16:56:29 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
Print Model: information with oea_startup().


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.58 src/sys/arch/sandpoint/sandpoint/machdep.c:1.59
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.58	Sat Aug 13 21:04:05 2011
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Tue Nov 22 16:56:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.58 2011/08/13 21:04:05 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.59 2011/11/22 16:56:29 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.58 2011/08/13 21:04:05 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.59 2011/11/22 16:56:29 phx Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_ddb.h
@@ -230,13 +230,15 @@ mem_regions(struct mem_region **mem, str
 void
 cpu_startup(void)
 {
-	int msr;
+	struct btinfo_prodfamily *bi_prod;
 	void *baseaddr;
+	int msr;
 
 	/*
 	 * Do common startup.
 	 */
-	oea_startup(NULL);
+	bi_prod = lookup_bootinfo(BTINFO_PRODFAMILY);
+	oea_startup(bi_prod != NULL ? bi_prod-name : NULL);
 
 	/*
 	 * Prepare EPIC and install external interrupt handler.



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-11-22 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Nov 22 16:56:29 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
Print Model: information with oea_startup().


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint

2011-11-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Nov 12 23:57:55 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add Iomega support (init, reboot, poweroff).
Make new sysctl-nodes for Iomega fan control in machdep.satmgr.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.12 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.13
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.12	Fri Jul  1 19:16:06 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sat Nov 12 23:57:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.12 2011/07/01 19:16:06 dyoung Exp $ */
+/* $NetBSD: satmgr.c,v 1.13 2011/11/12 23:57:55 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@ struct satmgr_softc {
 	struct selinfo		sc_rsel;
 	callout_t		sc_ch_wdog;
 	callout_t		sc_ch_pbutton;
+	callout_t		sc_ch_sync;
 	struct sysmon_pswitch	sc_sm_pbutton;
 	int			sc_open;
 	void			*sc_si;
@@ -79,6 +80,10 @@ struct satmgr_softc {
 	struct satops		*sc_ops;
 	char			sc_btn_buf[8];
 	int			sc_btn_cnt;
+	char			sc_cmd_buf[8];
+	int			sc_sysctl_wdog;
+	int			sc_sysctl_fanlow;
+	int			sc_sysctl_fanhigh;
 };
 
 static int  satmgr_match(device_t, cfdata_t, void *);
@@ -105,8 +110,11 @@ const struct cdevsw satmgr_cdevsw = {
 
 static void satmgr_reboot(int);
 static int satmgr_sysctl_wdogenable(SYSCTLFN_PROTO);
+static int satmgr_sysctl_fanlow(SYSCTLFN_PROTO);
+static int satmgr_sysctl_fanhigh(SYSCTLFN_PROTO);
 static void wdog_tickle(void *);
 static void send_sat(struct satmgr_softc *, const char *);
+static void send_sat_len(struct satmgr_softc *, const char *, int);
 static int hwintr(void *);
 static void rxintr(struct satmgr_softc *);
 static void txintr(struct satmgr_softc *);
@@ -114,17 +122,23 @@ static void startoutput(struct satmgr_so
 static void swintr(void *);
 static void sinit(struct satmgr_softc *);
 static void qinit(struct satmgr_softc *);
+static void iinit(struct satmgr_softc *);
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
+static void ireboot(struct satmgr_softc *);
 static void kpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
 static void dpwroff(struct satmgr_softc *);
+static void ipwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
 static void dbutton(struct satmgr_softc *, int);
+static void ibutton(struct satmgr_softc *, int);
+static void idosync(void *);
+static void iprepcmd(struct satmgr_softc *, int, int, int, int, int, int);
 static void guarded_pbutton(void *);
 static void sched_sysmon_pbutton(void *);
 
@@ -137,8 +151,9 @@ struct satops {
 };
 
 static struct satops satmodel[] = {
-{ dlink,NULL, NULL, dpwroff, dbutton },
-{ kurobox,  NULL, kreboot, kpwroff, kbutton },
+{ dlink,NULL,  NULL,dpwroff, dbutton },
+{ iomega,   iinit, ireboot, ipwroff, ibutton },
+{ kurobox,  NULL,  kreboot, kpwroff, kbutton },
 { qnap, qinit, qreboot, qpwroff, qbutton },
 { synology, sinit, sreboot, spwroff, sbutton }
 };
@@ -155,8 +170,6 @@ static struct satops satmodel[] = {
 #define CSR_READ(t,r)	bus_space_read_1((t)-sc_iot, (t)-sc_ioh, (r))
 #define CSR_WRITE(t,r,v) bus_space_write_1((t)-sc_iot, (t)-sc_ioh, (r), (v))
 
-static int satmgr_wdog;
-
 static int
 satmgr_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -210,6 +223,7 @@ satmgr_attach(device_t parent, device_t 
 	selinit(sc-sc_rsel);
 	callout_init(sc-sc_ch_wdog, 0);
 	callout_init(sc-sc_ch_pbutton, 0);
+	callout_init(sc-sc_ch_sync, 0);
 	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_HIGH);
 	cv_init(sc-sc_rdcv, satrd);
 	cv_init(sc-sc_wrcv, satwr);
@@ -233,11 +247,11 @@ satmgr_attach(device_t parent, device_t 
 		aprint_error_dev(sc-sc_dev,
 		unable to register power button with sysmon\n);
 
+	/* create machdep.satmgr subtree for those models which support it */
 	if (strcmp(ops-family, kurobox) == 0) {
 		const struct sysctlnode *rnode;
 		struct sysctllog *clog;
 
-		/* create machdep.satmgr.* subtree */
 		clog = NULL;
 		sysctl_createv(clog, 0, NULL, rnode,
 			CTLFLAG_PERMANENT,
@@ -256,6 +270,34 @@ satmgr_attach(device_t parent, device_t 
 			satmgr_sysctl_wdogenable, 0, NULL, 0,
 			CTL_CREATE, CTL_EOL);
 	}
+	else if (strcmp(ops-family, iomega) == 0) {
+		const struct sysctlnode *rnode;
+		struct sysctllog *clog;
+
+		clog = NULL;
+		sysctl_createv(clog, 0, NULL, rnode,
+			CTLFLAG_PERMANENT,
+			CTLTYPE_NODE, machdep, NULL,
+			NULL, 0, NULL, 0,
+			CTL_MACHDEP, 

CVS commit: src/sys/arch/sandpoint/sandpoint

2011-11-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Nov 12 23:57:55 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add Iomega support (init, reboot, poweroff).
Make new sysctl-nodes for Iomega fan control in machdep.satmgr.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-07-01 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Jul  1 19:16:06 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c eumb.c eumbvar.h
iic_eumb.c mainbus.c satmgr.c

Log Message:
#include sys/bus.h instead of machine/bus.h.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/sandpoint/com_eumb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/sandpoint/eumb.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/eumbvar.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/sandpoint/iic_eumb.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/sandpoint/mainbus.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-04-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Apr 30 11:14:04 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Add Iomega Storcenter dsrtc device (DS1337).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.13 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.14
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.13	Fri Apr  8 14:09:24 2011
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Sat Apr 30 11:14:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.13 2011/04/08 14:09:24 nisimura Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.14 2011/04/30 11:14:04 phx Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.13 2011/04/08 14:09:24 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.14 2011/04/30 11:14:04 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -60,6 +60,7 @@
 
 static struct i2cdev rtcmodel[] = {
 { dlink,strtc,  0x68 },
+{ iomega,   dsrtc,  0x68 },
 { kurobox,  rs5c372rtc, 0x32 },
 { qnap, s390rtc,0x30 },
 { synology, rs5c372rtc, 0x32 },



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Apr 30 11:14:04 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Add Iomega Storcenter dsrtc device (DS1337).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 18:06:19 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
Make it compile when no kernel symbols and no debugger is configured.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.55 src/sys/arch/sandpoint/sandpoint/machdep.c:1.56
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.55	Sat Mar 12 16:49:16 2011
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Tue Apr 19 18:06:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $	*/
+/*	$NetBSD: machdep.c,v 1.56 2011/04/19 18:06:19 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.56 2011/04/19 18:06:19 phx Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_ddb.h
@@ -183,10 +183,14 @@
 	cn_tab = kcomcons;
 	(*cn_tab-cn_init)(kcomcons);
 
+#if NKSYMS || defined(DDB) || defined(MODULAR)
 	ksyms_addsyms_elf((int)((u_int)endsym - (u_int)startsym), startsym, endsym);
+#endif
+#ifdef DDB
 	if (boothowto  RB_KDB)
 		Debugger();
 #endif
+#endif
 
 	/* Initialize bus_space */
 	sandpoint_bus_space_init();



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 18:16:03 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
It is probably better to flash the power LED after power-off on a DSM-G600,
to make the user aware that he needs to remove power manually.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.10 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.11
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.10	Sun Apr 17 14:05:59 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Tue Apr 19 18:16:03 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.10 2011/04/17 14:05:59 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.11 2011/04/19 18:16:03 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -704,14 +704,14 @@
 qreboot(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, Pf);
+	send_sat(sc, Pf);	/* beep and reboot */
 }
 
 static void
 qpwroff(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, PA);
+	send_sat(sc, PA);	/* beep and power off */
 }
 
 static void
@@ -720,7 +720,7 @@
 
 	switch (ch) {
 	case '@':
-		/* power button, notified after 5 seconds guard time */
+		/* power button, notified after 2 seconds guard time */
 		sysmon_task_queue_sched(0, sched_sysmon_pbutton, sc);
 		break;
 	case 'j':	/* reset to default button */
@@ -734,10 +734,12 @@
 {
 
 	/*
-	 * The DSM-G600 has no hardware-shutdown, but we turn all LEDs off,
-	 * to indicated that we powered down.
+	 * The DSM-G600 has no hardware-shutdown, so we flash the power LED
+	 * to indicate that the device can be switched off.
 	 */
-	send_sat(sc, TSC\nTSC\n);
+	send_sat(sc, SYN\nSYN\n);
+
+	/* drops into default power-off handling (looping forever) */
 }
 
 static void



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 18:06:19 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c

Log Message:
Make it compile when no kernel symbols and no debugger is configured.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sandpoint/sandpoint/machdep.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/sandpoint/sandpoint

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 18:16:03 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
It is probably better to flash the power LED after power-off on a DSM-G600,
to make the user aware that he needs to remove power manually.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-04-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Apr 17 14:05:59 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
DSM-G600: Turn off all LEDs when shutting down, to indicate the device
can be switched off.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.9 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.10
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.9	Sun Apr 10 16:30:32 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sun Apr 17 14:05:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.9 2011/04/10 16:30:32 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.10 2011/04/17 14:05:59 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -120,6 +120,7 @@
 static void kpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
+static void dpwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
@@ -136,7 +137,7 @@
 };
 
 static struct satops satmodel[] = {
-{ dlink,NULL, NULL, NULL, dbutton },
+{ dlink,NULL, NULL, dpwroff, dbutton },
 { kurobox,  NULL, kreboot, kpwroff, kbutton },
 { qnap, qinit, qreboot, qpwroff, qbutton },
 { synology, sinit, sreboot, spwroff, sbutton }
@@ -729,6 +730,17 @@
 }
 
 static void
+dpwroff(struct satmgr_softc *sc)
+{
+
+	/*
+	 * The DSM-G600 has no hardware-shutdown, but we turn all LEDs off,
+	 * to indicated that we powered down.
+	 */
+	send_sat(sc, TSC\nTSC\n);
+}
+
+static void
 dbutton(struct satmgr_softc *sc, int ch)
 {
 



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Apr 17 14:05:59 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
DSM-G600: Turn off all LEDs when shutting down, to indicate the device
can be switched off.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-04-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Apr 10 16:30:32 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Missing comma. Make it compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-04-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Apr  8 14:09:24 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c satmgr.c

Log Message:
Minor format knots; sort a model list in alphabetical order and adjust
spacing.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/sandpoint/iic_eumb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.12 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.13
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.12	Mon Apr  4 18:01:08 2011
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Fri Apr  8 14:09:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.12 2011/04/04 18:01:08 phx Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.13 2011/04/08 14:09:24 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.12 2011/04/04 18:01:08 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.13 2011/04/08 14:09:24 nisimura Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -59,10 +59,10 @@
 };
 
 static struct i2cdev rtcmodel[] = {
-   { dlink,strtc,  0x68 },
-   { kurobox,  rs5c372rtc, 0x32 },
-   { qnap, s390rtc,0x30 },
-   { synology, rs5c372rtc, 0x32 },
+{ dlink,strtc,  0x68 },
+{ kurobox,  rs5c372rtc, 0x32 },
+{ qnap, s390rtc,0x30 },
+{ synology, rs5c372rtc, 0x32 },
 };
 
 static void add_i2c_child_devices(device_t, const char *);

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.7 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.8
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.7	Sat Mar 26 22:36:34 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Fri Apr  8 14:09:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.7 2011/03/26 22:36:34 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.8 2011/04/08 14:09:24 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -136,10 +136,10 @@
 };
 
 static struct satops satmodel[] = {
+{ dlink,NULL, NULL, NULL, dbutton }
 { kurobox,  NULL, kreboot, kpwroff, kbutton },
-{ synology, sinit, sreboot, spwroff, sbutton },
 { qnap, qinit, qreboot, qpwroff, qbutton },
-{ dlink,NULL, NULL, NULL, dbutton }
+{ synology, sinit, sreboot, spwroff, sbutton },
 };
 
 /* single byte stride register layout */



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Apr  8 14:09:24 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c satmgr.c

Log Message:
Minor format knots; sort a model list in alphabetical order and adjust
spacing.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/sandpoint/iic_eumb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-04-04 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr  4 18:01:08 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Add more known I2C devices:
dlink: strtc
qnap: s390rtc


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.11 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.12
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.11	Thu Mar 31 02:32:35 2011
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Mon Apr  4 18:01:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 nisimura Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.12 2011/04/04 18:01:08 phx Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.12 2011/04/04 18:01:08 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -59,11 +59,13 @@
 };
 
 static struct i2cdev rtcmodel[] = {
+   { dlink,strtc,  0x68 },
{ kurobox,  rs5c372rtc, 0x32 },
+   { qnap, s390rtc,0x30 },
{ synology, rs5c372rtc, 0x32 },
 };
 
-void add_i2c_child_devices(device_t, const char *);
+static void add_i2c_child_devices(device_t, const char *);
 
 static int
 iic_eumb_match(device_t parent, cfdata_t cf, void *aux)
@@ -100,7 +102,7 @@
 	motoi2c_attach_common(self, sc-sc_motoi2c, NULL);
 }
 
-void
+static void
 add_i2c_child_devices(device_t self, const char *family)
 {
 	struct i2cdev *rtc;



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-04-04 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr  4 18:01:08 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Add more known I2C devices:
dlink: strtc
qnap: s390rtc


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2011-03-30 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Mar 31 02:32:36 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Build and use i2c-child-devices property to choose the correct RTC
chip among various models.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.10 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.11
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.10	Wed Jan 12 18:09:03 2011
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Thu Mar 31 02:32:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.10 2011/01/12 18:09:03 phx Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.10 2011/01/12 18:09:03 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 nisimura Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -37,6 +37,7 @@
 #include machine/bus.h
 #include dev/i2c/motoi2cvar.h
 #include sandpoint/sandpoint/eumbvar.h
+#include machine/bootinfo.h
 
 struct iic_eumb_softc {
 	device_t		sc_dev;
@@ -51,6 +52,19 @@
 
 static int found;
 
+struct i2cdev {
+	const char *family;
+	const char *name;
+	int addr;
+};
+
+static struct i2cdev rtcmodel[] = {
+   { kurobox,  rs5c372rtc, 0x32 },
+   { synology, rs5c372rtc, 0x32 },
+};
+
+void add_i2c_child_devices(device_t, const char *);
+
 static int
 iic_eumb_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -64,6 +78,7 @@
 	struct iic_eumb_softc *sc;
 	struct eumb_attach_args *eaa;
 	bus_space_handle_t ioh;
+	struct btinfo_prodfamily *pfam;
 
 	sc = device_private(self);
 	sc-sc_dev = self;
@@ -73,6 +88,9 @@
 	aprint_naive(\n);
 	aprint_normal(\n);
 
+	if ((pfam = lookup_bootinfo(BTINFO_PRODFAMILY)) != NULL)
+		add_i2c_child_devices(self, pfam-name);
+
 	/*
 	 * map EUMB registers and attach MI motoi2c with default settings
 	 */
@@ -81,3 +99,31 @@
 	sc-sc_motoi2c.sc_ioh = ioh;
 	motoi2c_attach_common(self, sc-sc_motoi2c, NULL);
 }
+
+void
+add_i2c_child_devices(device_t self, const char *family)
+{
+	struct i2cdev *rtc;
+	prop_dictionary_t pd;
+	prop_array_t pa;
+	int i;
+
+	rtc = NULL;
+	for (i = 0; i  (int)(sizeof(rtcmodel)/sizeof(rtcmodel[0])); i++) {
+		if (strcmp(family, rtcmodel[i].family) == 0) {
+			rtc = rtcmodel[i];
+			goto found;
+		}
+	}
+	return;
+
+ found:
+	pd = prop_dictionary_create();
+	pa = prop_array_create();
+	prop_dictionary_set_cstring_nocopy(pd, name, rtc-name);
+	prop_dictionary_set_uint32(pd, addr, rtc-addr);
+	prop_array_add(pa, pd);
+	prop_dictionary_set(device_properties(self), i2c-child-devices, pa);
+	prop_object_release(pd);
+	prop_object_release(pa);
+}



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-03-30 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Mar 31 02:32:36 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Build and use i2c-child-devices property to choose the correct RTC
chip among various models.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2011-03-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 26 22:36:34 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add QNAP reboot, reset and button handling functions.
Introduced an optional init function per board, which can set LEDs and other
special hardware to an initial state using the satellite processor.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.7
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6	Sat Mar 12 16:49:16 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sat Mar 26 22:36:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.6 2011/03/12 16:49:16 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.7 2011/03/26 22:36:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -112,6 +112,8 @@
 static void txintr(struct satmgr_softc *);
 static void startoutput(struct satmgr_softc *);
 static void swintr(void *);
+static void sinit(struct satmgr_softc *);
+static void qinit(struct satmgr_softc *);
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
@@ -127,16 +129,17 @@
 
 struct satops {
 	const char *family;
+	void (*init)(struct satmgr_softc *);
 	void (*reboot)(struct satmgr_softc *);
 	void (*pwroff)(struct satmgr_softc *);
 	void (*dispatch)(struct satmgr_softc *, int);
 };
 
 static struct satops satmodel[] = {
-{ kurobox,  kreboot, kpwroff, kbutton },
-{ synology, sreboot, spwroff, sbutton },
-{ qnap, qreboot, qpwroff, qbutton },
-{ dlink,NULL, NULL, dbutton }
+{ kurobox,  NULL, kreboot, kpwroff, kbutton },
+{ synology, sinit, sreboot, spwroff, sbutton },
+{ qnap, qinit, qreboot, qpwroff, qbutton },
+{ dlink,NULL, NULL, NULL, dbutton }
 };
 
 /* single byte stride register layout */
@@ -253,7 +256,9 @@
 			CTL_CREATE, CTL_EOL);
 	}
 
-	md_reboot = satmgr_reboot; /* cpu_reboot() hook */
+	md_reboot = satmgr_reboot;	/* cpu_reboot() hook */
+	if (ops-init != NULL)
+		(*ops-init)(sc);	/* init sat.cpu, LEDs, etc. */
 	return;
 
   notavail:
@@ -652,6 +657,13 @@
 }
 
 static void
+sinit(struct satmgr_softc *sc)
+{
+
+	send_sat(sc, 8);	/* status LED green */
+}
+
+static void
 sreboot(struct satmgr_softc *sc)
 {
 
@@ -681,24 +693,39 @@
 }
 
 static void
+qinit(struct satmgr_softc *sc)
+{
+
+	send_sat(sc, V);	/* status LED green */
+}
+
+static void
 qreboot(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, f);
+	send_sat(sc, Pf);
 }
 
 static void
 qpwroff(struct satmgr_softc *sc)
 {
 
-	send_sat(sc, A);
+	send_sat(sc, PA);
 }
 
 static void
 qbutton(struct satmgr_softc *sc, int ch)
 {
 
-	/* research in progress */
+	switch (ch) {
+	case '@':
+		/* power button, notified after 5 seconds guard time */
+		sysmon_task_queue_sched(0, sched_sysmon_pbutton, sc);
+		break;
+	case 'j':	/* reset to default button */
+	case 'h':	/* USB copy button */
+		break;
+	}
 }
 
 static void



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-03-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 26 22:36:34 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Add QNAP reboot, reset and button handling functions.
Introduced an optional init function per board, which can set LEDs and other
special hardware to an initial state using the satellite processor.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-03-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 12 16:46:32 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: locore.S

Log Message:
When rebooting flush the instruction pipeline first, then do an absolute
jump to 0xfff00100.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/sandpoint/locore.S

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/sandpoint/sandpoint/locore.S
diff -u src/sys/arch/sandpoint/sandpoint/locore.S:1.20 src/sys/arch/sandpoint/sandpoint/locore.S:1.21
--- src/sys/arch/sandpoint/sandpoint/locore.S:1.20	Mon Jan 17 08:23:57 2011
+++ src/sys/arch/sandpoint/sandpoint/locore.S	Sat Mar 12 16:46:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.20 2011/01/17 08:23:57 matt Exp $	*/
+/*	$NetBSD: locore.S,v 1.21 2011/03/12 16:46:31 phx Exp $	*/
 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
 
 /*
@@ -150,7 +150,8 @@
 	mfmsr	3
 	ori	3,3,PSL_IP@l
 	mtmsr	3
-	b	0xFFF00100
+	isync
+	ba	0xFFF00100
 
 /*
  * Include common switch / setfault code



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-03-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 12 16:49:17 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c satmgr.c

Log Message:
The DSM-G600's satellite microcontroller provides no possibility to reboot
or powerdown the board, so we can only support reboot by falling back to
a default reboot procedure.
The default procedure will turn off interrupts and the MMU, then jump
through the firmware's reset vector (0xfff00100).


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.54 src/sys/arch/sandpoint/sandpoint/machdep.c:1.55
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.54	Wed Jan 12 07:38:44 2011
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Sat Mar 12 16:49:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.54 2011/01/12 07:38:44 nisimura Exp $	*/
+/*	$NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.54 2011/01/12 07:38:44 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_ddb.h
@@ -353,7 +353,9 @@
 void
 cpu_reboot(int howto, char *what)
 {
+	extern void jump_to_ppc_reset_entry(void);	/* from locore.S */
 	static int syncing;
+	register_t msr;
 
 	boothowto = howto;
 	if ((howto  RB_NOSYNC) == 0  syncing == 0) {
@@ -383,11 +385,21 @@
 		howto = RB_AUTOBOOT;
 	}
 
-	if (md_reboot != NULL) {
+	if (md_reboot != NULL)
 		(*md_reboot)(howto);
-		/* should not come here */
-	}
-	while (1) ; /* may practice PPC processor reset sequence here */
+
+	/*
+	 * No reboot method defined. So we disable the MMU and jump
+	 * through the firmware's reset vector.
+	 */
+	msr = mfmsr();
+	msr = ~PSL_EE;
+	mtmsr(msr);
+	__asm volatile(mtspr %0,%1 : : K(81), r(0));
+	msr = ~(PSL_ME | PSL_DR | PSL_IR);
+	mtmsr(msr);
+	jump_to_ppc_reset_entry();
+	for (;;);
 }
 
 #ifdef MODULAR

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.5 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.5	Wed Mar  9 20:33:57 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sat Mar 12 16:49:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.5 2011/03/09 20:33:57 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.6 2011/03/12 16:49:16 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -115,11 +115,9 @@
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
-static void dreboot(struct satmgr_softc *);
 static void kpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
-static void dpwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
@@ -138,7 +136,7 @@
 { kurobox,  kreboot, kpwroff, kbutton },
 { synology, sreboot, spwroff, sbutton },
 { qnap, qreboot, qpwroff, qbutton },
-{ dlink,dreboot, dpwroff, dbutton }
+{ dlink,NULL, NULL, dbutton }
 };
 
 /* single byte stride register layout */
@@ -266,11 +264,16 @@
 satmgr_reboot(int howto)
 {
 	struct satmgr_softc *sc = device_lookup_private(satmgr_cd, 0);
-	
-	if ((howto  RB_POWERDOWN) == RB_AUTOBOOT)
-		(*sc-sc_ops-reboot)(sc);	/* REBOOT */
-	else
-		(*sc-sc_ops-pwroff)(sc);	/* HALT or POWERDOWN */
+
+	if ((howto  RB_POWERDOWN) == RB_AUTOBOOT) {
+		if (sc-sc_ops-reboot != NULL)
+			(*sc-sc_ops-reboot)(sc);	/* REBOOT */
+		else
+			return;/* default reboot */
+	} else
+		if (sc-sc_ops-pwroff != NULL)
+			(*sc-sc_ops-pwroff)(sc);	/* HALT or POWERDOWN */
+
 	tsleep(satmgr_reboot, PWAIT, reboot, 0);
 	/*NOTREACHED*/
 }
@@ -699,20 +702,6 @@
 }
 
 static void
-dreboot(struct satmgr_softc *sc)
-{
-
-	/* XXX cause a machine check exception? */
-}
-
-static void
-dpwroff(struct satmgr_softc *sc)
-{
-
-	/* not possible */
-}
-
-static void
 dbutton(struct satmgr_softc *sc, int ch)
 {
 



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-03-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 12 16:49:17 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: machdep.c satmgr.c

Log Message:
The DSM-G600's satellite microcontroller provides no possibility to reboot
or powerdown the board, so we can only support reboot by falling back to
a default reboot procedure.
The default procedure will turn off interrupts and the MMU, then jump
through the firmware's reset vector (0xfff00100).


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-03-09 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Mar  9 20:33:57 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
DLink DSM-G600 button handling.
There are no commands to reboot or poweroff a G600, though.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.4 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.5
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.4	Thu Feb 24 19:32:34 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Wed Mar  9 20:33:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.4 2011/02/24 19:32:34 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.5 2011/03/09 20:33:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -76,8 +76,9 @@
 	char			sc_wr_buf[16];
 	char			*sc_wr_lim, *sc_wr_cur, *sc_wr_ptr;
 	int			sc_rd_cnt, sc_wr_cnt;
-	int			sc_btnstate;
 	struct satops		*sc_ops;
+	char			sc_btn_buf[8];
+	int			sc_btn_cnt;
 };
 
 static int  satmgr_match(device_t, cfdata_t, void *);
@@ -114,12 +115,15 @@
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
+static void dreboot(struct satmgr_softc *);
 static void kpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
+static void dpwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
+static void dbutton(struct satmgr_softc *, int);
 static void guarded_pbutton(void *);
 static void sched_sysmon_pbutton(void *);
 
@@ -133,7 +137,8 @@
 static struct satops satmodel[] = {
 { kurobox,  kreboot, kpwroff, kbutton },
 { synology, sreboot, spwroff, sbutton },
-{ qnap, qreboot, qpwroff, qbutton }
+{ qnap, qreboot, qpwroff, qbutton },
+{ dlink,dreboot, dpwroff, dbutton }
 };
 
 /* single byte stride register layout */
@@ -206,7 +211,7 @@
 	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_HIGH);
 	cv_init(sc-sc_rdcv, satrd);
 	cv_init(sc-sc_wrcv, satwr);
-	sc-sc_btnstate = 0;
+	sc-sc_btn_cnt = 0;
 
 	epicirq = (eaa-eumb_unit == 0) ? 24 : 25;
 	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, hwintr, sc);
@@ -663,7 +668,7 @@
 
 	switch (ch) {
 	case '0':
-		/* notified after 3 secord guard time */
+		/* notified after 5 seconds guard time */
 		sysmon_task_queue_sched(0, sched_sysmon_pbutton, sc);
 		break;
 	case 'a':
@@ -689,10 +694,44 @@
 static void
 qbutton(struct satmgr_softc *sc, int ch)
 {
+
 	/* research in progress */
 }
 
 static void
+dreboot(struct satmgr_softc *sc)
+{
+
+	/* XXX cause a machine check exception? */
+}
+
+static void
+dpwroff(struct satmgr_softc *sc)
+{
+
+	/* not possible */
+}
+
+static void
+dbutton(struct satmgr_softc *sc, int ch)
+{
+
+	if (ch == '\n' || ch == '\r') {
+		if (sc-sc_btn_cnt == 3) {
+			if (strncmp(sc-sc_btn_buf, PKO, 3) == 0) {
+/* notified after 5 seconds guard time */
+sysmon_task_queue_sched(0,
+sched_sysmon_pbutton, sc);
+			} else if (strncmp(sc-sc_btn_buf, RKO, 3) == 0) {
+/* notified after 5 seconds guard time */
+			}
+		}
+		sc-sc_btn_cnt = 0;
+	} else if (sc-sc_btn_cnt  7)
+		sc-sc_btn_buf[sc-sc_btn_cnt++] = ch;
+}
+
+static void
 guarded_pbutton(void *arg)
 {
 	struct satmgr_softc *sc = arg;



CVS commit: src/sys/arch/sandpoint/sandpoint

2011-03-09 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Mar  9 20:33:57 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
DLink DSM-G600 button handling.
There are no commands to reboot or poweroff a G600, though.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2011-02-24 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Feb 24 19:32:34 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c satmgr.c

Log Message:
Print interrupting at. Improved style guide conformance.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/com_eumb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/com_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.5 src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.6
--- src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.5	Thu Jul 30 05:57:27 2009
+++ src/sys/arch/sandpoint/sandpoint/com_eumb.c	Thu Feb 24 19:32:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: com_eumb.c,v 1.5 2009/07/30 05:57:27 nisimura Exp $ */
+/* $NetBSD: com_eumb.c,v 1.6 2011/02/24 19:32:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: com_eumb.c,v 1.5 2009/07/30 05:57:27 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: com_eumb.c,v 1.6 2011/02/24 19:32:34 phx Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -56,12 +56,12 @@
 static struct com_regs cnregs;
 
 /*
- * There are two different UART configurations, single 4-wire UART
- * and dual 2-wire.  DCR register selects one of the two operating
- * mode.  A certain group of NAS boxes uses the 2nd UART as system
- * console while the 1st to communicate power management satellite
- * processor. unit locator helps to reverse the two.  Default is a
- * single 4-wire UART as console.
+ * There are two different UART configurations: single 4-wire UART
+ * and dual 2-wire.  The DCR register selects one of the two operating
+ * modes.  A certain group of NAS boxes uses the 2nd UART as system
+ * console while using the 1st to communicate with the power management
+ * satellite processor. The unit locator helps to reverse the two.
+ * Default is a single 4-wire UART as console.
  */
 int
 com_eumb_match(device_t parent, cfdata_t cf, void *aux)
@@ -70,10 +70,10 @@
 	int unit = eaa-eumb_unit;
 
 	if (unit == EUMBCF_UNIT_DEFAULT  found == 0)
-		return (1);
+		return 1;
 	if (unit == 0 || unit == 1)
-		return (1);
-	return (0);
+		return 1;
+	return 0;
 }
 
 void
@@ -92,8 +92,7 @@
 	if (com_is_console(eaa-eumb_bt, comaddr, ioh)) {
 		cnregs.cr_ioh = ioh;
 		sc-sc_regs = cnregs;
-	}
-	else {
+	} else {
 		bus_space_map(eaa-eumb_bt, comaddr, COM_NPORTS, 0, ioh);
 		COM_INIT_REGS(sc-sc_regs, eaa-eumb_bt, ioh, comaddr);
 	}
@@ -101,7 +100,9 @@
 	epicirq = (eaa-eumb_unit == 1) ? 25 : 24;
 
 	com_attach_subr(sc);
+
 	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, comintr, sc);
+	aprint_normal_dev(self, interrupting at irq %d\n, epicirq + 16);
 }
 
 int

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.3 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.4
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.3	Thu Feb 10 13:54:45 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Thu Feb 24 19:32:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.3 2011/02/10 13:54:45 nisimura Exp $ */
+/* $NetBSD: satmgr.c,v 1.4 2011/02/24 19:32:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -71,10 +71,12 @@
 	uint32_t		sc_ierror, sc_overr;
 	kmutex_t		sc_lock;
 	kcondvar_t		sc_rdcv, sc_wrcv;
-	char sc_rd_buf[16], *sc_rd_lim, *sc_rd_cur, *sc_rd_ptr;
-	char sc_wr_buf[16], *sc_wr_lim, *sc_wr_cur, *sc_wr_ptr;
-	int sc_rd_cnt, sc_wr_cnt;
-	int sc_btnstate;
+	char			sc_rd_buf[16];
+	char			*sc_rd_lim, *sc_rd_cur, *sc_rd_ptr;
+	char			sc_wr_buf[16];
+	char			*sc_wr_lim, *sc_wr_cur, *sc_wr_ptr;
+	int			sc_rd_cnt, sc_wr_cnt;
+	int			sc_btnstate;
 	struct satops		*sc_ops;
 };
 
@@ -155,10 +157,10 @@
 	int unit = eaa-eumb_unit;
 
 	if (unit == EUMBCF_UNIT_DEFAULT  found == 0)
-		return (1);
+		return 1;
 	if (unit == 0 || unit == 1)
-		return (1);
-	return (0);
+		return 1;
+	return 0;
 }
 
 static void
@@ -208,6 +210,7 @@
 
 	epicirq = (eaa-eumb_unit == 0) ? 24 : 25;
 	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, hwintr, sc);
+	aprint_normal_dev(self, interrupting at irq %d\n, epicirq + 16);
 	sc-sc_si = softint_establish(SOFTINT_SERIAL, swintr, sc);
 
 	CSR_WRITE(sc, IER, 0x7f); /* all but MSR */
@@ -289,8 +292,7 @@
 		callout_setfunc(sc-sc_ch_wdog, wdog_tickle, sc);
 		callout_schedule(sc-sc_ch_wdog, 90 * hz);
 		send_sat(sc, JJ);
-	}
-	else {
+	} else {
 		callout_stop(sc-sc_ch_wdog);
 		send_sat(sc, KK);
 	}
@@ -466,8 +468,9 @@
 	return (kn-kn_data  0);
 }
 
-static const struct filterops read_filtops =
-	{ 1, NULL, filt_rdetach, filt_read };			
+static const struct filterops read_filtops = {
+	1, NULL, filt_rdetach, filt_read
+};			
 
 static int
 satkqfilter(dev_t dev, struct knote *kn)
@@ -482,7 +485,7 @@
 		break;
 
 	default:
-		return 

CVS commit: src/sys/arch/sandpoint/sandpoint

2011-02-24 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Feb 24 19:32:34 UTC 2011

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c satmgr.c

Log Message:
Print interrupting at. Improved style guide conformance.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/com_eumb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint

2010-10-31 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Oct 31 11:08:06 UTC 2010

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Update copyright notice. This code was completely replaced with
Frank Wille's effort and has no substance made by me anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.8 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.9
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.8	Wed May 12 17:20:24 2010
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Sun Oct 31 11:08:06 2010
@@ -1,11 +1,10 @@
-/* $NetBSD: iic_eumb.c,v 1.8 2010/05/12 17:20:24 phx Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.9 2010/10/31 11:08:06 nisimura Exp $ */
 
 /*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2010 Frank Wille.
  * All rights reserved.
  *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Tohru Nishimura.
+ * Written by Frank Wille for The NetBSD Project.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.8 2010/05/12 17:20:24 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: iic_eumb.c,v 1.9 2010/10/31 11:08:06 nisimura Exp $);
 
 #include sys/param.h
 #include sys/device.h



CVS commit: src/sys/arch/sandpoint/sandpoint

2010-10-31 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Oct 31 11:08:06 UTC 2010

Modified Files:
src/sys/arch/sandpoint/sandpoint: iic_eumb.c

Log Message:
Update copyright notice. This code was completely replaced with
Frank Wille's effort and has no substance made by me anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint

2010-06-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Jun 30 17:50:34 UTC 2010

Modified Files:
src/sys/arch/sandpoint/sandpoint: autoconf.c

Log Message:
Determine the boot disk with bootinfo cookie.
Patch submitted by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/sandpoint/autoconf.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/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.21 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.22
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.21	Tue May 18 15:07:50 2010
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Wed Jun 30 17:50:34 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.21 2010/05/18 15:07:50 phx Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.22 2010/06/30 17:50:34 phx Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.21 2010/05/18 15:07:50 phx Exp $);
+__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.22 2010/06/30 17:50:34 phx Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -137,37 +137,9 @@
 		}
 	}
 	if (bi_rdev != NULL  dev-dv_class == DV_DISK
-	 device_is_a(dev, bi_rdev-devname)) {
+	 device_is_a(dev, bi_rdev-devname)
+	 dev-dv_unit == bi_rdev-cookie) {
 		booted_device = dev;
 		booted_partition = 0;
 	}
 }
-
-#if 0
-void
-findroot(void)
-{
-	int unit, part;
-	device_t dv;
-	const char *name;
-
-#if 0
-	printf(howto %x bootdev %x , boothowto, bootdev);
-#endif
-
-	if ((bootdev  B_MAGICMASK) != (u_long)B_DEVMAGIC)
-		return;
-
-	name = devsw_blk2name((bootdev  B_TYPESHIFT)  B_TYPEMASK);
-	if (name == NULL)
-		return;
-
-	part = (bootdev  B_PARTITIONSHIFT)  B_PARTITIONMASK;
-	unit = (bootdev  B_UNITSHIFT)  B_UNITMASK;
-
-	if ((dv = device_find_by_driver_unit(name, unit)) != NULL) {
-		booted_device = dv;
-		booted_partition = part;
-	}
-}
-#endif



CVS commit: src/sys/arch/sandpoint/sandpoint

2010-06-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jun  3 10:44:21 UTC 2010

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Applied a patch by Toru Nishimura:
Fixed kmutex usage error and replaced tsleep by cv_waitsig.
Now cat /dev/satmgr no longer panics when pressing a button.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/sandpoint/satmgr.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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.1 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.2
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.1	Sat May 29 22:47:02 2010
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Thu Jun  3 10:44:21 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.1 2010/05/29 22:47:02 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.2 2010/06/03 10:44:21 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -59,7 +59,6 @@
 	device_t		sc_dev;
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
-	kmutex_t		sc_lock;
 	struct selinfo		sc_rsel;
 	callout_t		sc_ch_wdog;
 	callout_t		sc_ch_pbutton;
@@ -67,6 +66,8 @@
 	int			sc_open;
 	void			*sc_si;
 	uint32_t		sc_ierror, sc_overr;
+	kmutex_t		sc_lock;
+	kcondvar_t		sc_rdcv, sc_wrcv;
 	char sc_rd_buf[16], *sc_rd_lim, *sc_rd_cur, *sc_rd_ptr;
 	char sc_wr_buf[16], *sc_wr_lim, *sc_wr_cur, *sc_wr_ptr;
 	int sc_rd_cnt, sc_wr_cnt;
@@ -100,6 +101,7 @@
 static void send_sat(struct satmgr_softc *, const char *);
 static int hwintr(void *);
 static void rxintr(struct satmgr_softc *);
+static void txintr(struct satmgr_softc *);
 static void startoutput(struct satmgr_softc *);
 static void swintr(void *);
 static void kbutton(struct satmgr_softc *, int);
@@ -114,11 +116,12 @@
 	void (*dispatch)(struct satmgr_softc *, int);
 };
 
-const struct satmsg satmodel[] = {
+static const struct satmsg satmodel[] = {
 { kurobox,  CCGG, EEGG, kbutton },
 { synology, C,1,sbutton },
 { qnap, f,A,qbutton }
-} *satmgr_msg;
+};
+static const struct satmsg *satmgr_msg;
 
 /* single byte stride register layout */
 #define RBR		0
@@ -182,10 +185,13 @@
 	sc-sc_wr_cnt = 0;
 	sc-sc_wr_cur = sc-sc_wr_ptr = sc-sc_wr_buf[0];
 	sc-sc_wr_lim = sc-sc_wr_cur + sizeof(sc-sc_wr_buf);
+	sc-sc_ierror = sc-sc_overr = 0;
 	selinit(sc-sc_rsel);
 	callout_init(sc-sc_ch_wdog, 0);
 	callout_init(sc-sc_ch_pbutton, 0);
 	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_HIGH);
+	cv_init(sc-sc_rdcv, satrd);
+	cv_init(sc-sc_wrcv, satwr);
 
 	epicirq = (eaa-eumb_unit == 0) ? 24 : 25;
 	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, hwintr, sc);
@@ -345,12 +351,14 @@
 	if (sc == NULL)
 		return ENXIO;
 
-	mutex_spin_enter(sc-sc_lock);
-	if (sc-sc_rd_cnt == 0  (flags  IO_NDELAY))
-		return EWOULDBLOCK;
+	mutex_enter(sc-sc_lock);
+	if (sc-sc_rd_cnt == 0  (flags  IO_NDELAY)) {
+		error = EWOULDBLOCK;
+		goto out;
+	}
 	error = 0;
 	while (sc-sc_rd_cnt == 0) {
-		error = tsleep(sc-sc_rd_buf, PZERO|PCATCH, satrd, 0);
+		error = cv_wait_sig(sc-sc_rdcv, sc-sc_lock);
 		if (error)
 			goto out;
 	}
@@ -366,7 +374,7 @@
 			sc-sc_rd_ptr = sc-sc_rd_buf[0];
 	}
  out:
-	mutex_spin_exit(sc-sc_lock);
+	mutex_exit(sc-sc_lock);
 	return error;
 }
 
@@ -381,12 +389,14 @@
 	if (sc == NULL)
 		return ENXIO;
 
-	mutex_spin_enter(sc-sc_lock);
-	if (sc-sc_wr_cnt == sizeof(sc-sc_wr_buf)  (flags  IO_NDELAY))
-		return EWOULDBLOCK;
+	mutex_enter(sc-sc_lock);
+	if (sc-sc_wr_cnt == sizeof(sc-sc_wr_buf)  (flags  IO_NDELAY)) {
+		error = EWOULDBLOCK;
+		goto out;
+	}
 	error = 0;
 	while (sc-sc_wr_cnt == sizeof(sc-sc_wr_buf)) {
-		error = tsleep(sc-sc_wr_buf, PZERO|PCATCH, satwr, 0);
+		error = cv_wait_sig(sc-sc_wrcv, sc-sc_lock);
 		if (error)
 			goto out;
 	}
@@ -403,7 +413,7 @@
 	}
 	startoutput(sc); /* start xmit */
  out:
-	mutex_spin_exit(sc-sc_lock);
+	mutex_exit(sc-sc_lock);
 	return error;
 }
 
@@ -448,7 +458,7 @@
 static const struct filterops read_filtops =
 	{ 1, NULL, filt_rdetach, filt_read };			
 
-int
+static int
 satkqfilter(dev_t dev, struct knote *kn)
 {
 	struct satmgr_softc *sc = device_lookup_private(satmgr_cd, 0);
@@ -493,7 +503,7 @@
 			rxintr(sc);
 			break;
 		case IIR_TXRDY: /* TxFIFO is ready to swallow data */
-			startoutput(sc);
+			txintr(sc);
 			break;
 		case IIR_MLSC:	/* MSR updated */
 			break;
@@ -534,6 +544,14 @@
 }
 
 static void
+txintr(struct satmgr_softc *sc)
+{
+
+	cv_signal(sc-sc_wrcv);
+	startoutput(sc);
+}
+
+static void
 startoutput(struct satmgr_softc *sc)
 {
 	int n, ch;
@@ -555,6 +573,7 @@
 	int n;
 
 	/* we're now in softint(9) context */
+	mutex_spin_enter(sc-sc_lock);
 	ptr = sc-sc_rd_ptr;
 	for (n = 0; n  sc-sc_rd_cnt; n++) {
 		(*satmgr_msg-dispatch)(sc, *ptr);
@@ -564,13 +583,15 @@
 	if (sc-sc_open == 0) {
 		sc-sc_rd_cnt = 0;
 		sc-sc_rd_ptr = ptr;
+		mutex_spin_exit(sc-sc_lock);
 		return; /* drop characters down to floor */
 	

CVS commit: src/sys/arch/sandpoint/sandpoint

2010-06-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jun  3 10:44:21 UTC 2010

Modified Files:
src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
Applied a patch by Toru Nishimura:
Fixed kmutex usage error and replaced tsleep by cv_waitsig.
Now cat /dev/satmgr no longer panics when pressing a button.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/sandpoint/satmgr.c

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