Re: CVS commit: xsrc/external/mit/xterm/dist

2021-05-15 Thread Roland Illig


16.05.2021 04:30:06 Simon Burge :

> Hi Roland,
>
> "Roland Illig" wrote:
>
>> Module Name:  xsrc
>> Committed By: rillig
>> Date:   Sat May 15 19:30:15 UTC 2021
>>
>> Modified Files:
>>
>>   xsrc/external/mit/xterm/dist: misc.c
>>
>> Log Message:
>>
>> xterm: fix Clang build on i386
>>
>> xsrc/external/mit/xterm/dist/misc.c:3250:47: error: format specifies
>> type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned
>> int') [-Werror,-Wformat]
>
> -   printf("color  (ignored, length %lu)\n", have);
> +   printf("color  (ignored, length %lu)\n", (unsigned long)have);
>
> Would using "%zu" and reverting the cast be a better fix here?

I had considered this as well but found another instance in the same file where 
a size_t was fed to printf by casting it to unsigned long, therefore I did it 
this way, for consistency.


CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 16 05:16:21 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: spdmem_i2c.c

Log Message:
SPD stands for "Serial Presence Detect".  This implies that
if we're using direct configuration that we should treat
that as a *hint*... it's entirely possible that a device
tree lists locations where SPD memory can be found, not
necessarily where memory is known to be present.

Accordingly, if we get a direct configuration match based
on compatible data or device name, we still check to see
if the device is there.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/dev/i2c/spdmem_i2c.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/dev/i2c/spdmem_i2c.c
diff -u src/sys/dev/i2c/spdmem_i2c.c:1.21 src/sys/dev/i2c/spdmem_i2c.c:1.21.4.1
--- src/sys/dev/i2c/spdmem_i2c.c:1.21	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/spdmem_i2c.c	Sun May 16 05:16:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem_i2c.c,v 1.21 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: spdmem_i2c.c,v 1.21.4.1 2021/05/16 05:16:21 thorpej Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.21 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.21.4.1 2021/05/16 05:16:21 thorpej Exp $");
 
 #include 
 #include 
@@ -185,31 +185,45 @@ spdmem_i2c_match(device_t parent, cfdata
 	struct spdmem_i2c_softc sc;
 	int match_result;
 
-	if (iic_use_direct_match(ia, match, compat_data, _result))
-		return match_result;
-
 	/*
-	 * XXXJRT
-	 * Should do this with "compatible" strings.  There are also
-	 * other problems with this "match" routine.  Specifically, if
-	 * we are doing direct-config, we know the device is already
-	 * there aren't do need to probe.  I'll leave the logic for
-	 * now and let someone who knows better clean it later.
+	 * SPD stands for "Serial Presence Detect".  This implies that
+	 * if we're using direct configuration that we should treat
+	 * that as a *hint*... it's entirely possible that a device
+	 * tree lists locations where SPD memory can be found, not
+	 * necessarily where memory is known to be present.
+	 *
+	 * Accordingly, if we get a direct configuration match based
+	 * on compatible data or device name, we still check to see
+	 * if the device is there.
 	 */
 
+	if (iic_use_direct_match(ia, match, compat_data, _result)) {
+		if (match_result != 0) {
+			goto do_probe;
+		}
+		return 0;
+	}
+
 	if (ia->ia_name) {
 		/* add other names as we find more firmware variations */
-		if (strcmp(ia->ia_name, "dimm-spd") &&
-		strcmp(ia->ia_name, "dimm"))
-			return 0;
+		if (strcmp(ia->ia_name, "dimm-spd") == 0 ||
+		strcmp(ia->ia_name, "dimm") == 0) {
+			match_result = I2C_MATCH_DIRECT_SPECIFIC;
+			goto do_probe;
+		}
+		return 0;
 	}
 
-	/* only do this lame test when not using direct config */
-	if (ia->ia_name == NULL) {
-		if ((ia->ia_addr & SPDMEM_I2C_ADDRMASK) != SPDMEM_I2C_ADDR)
-			return 0;
+	/* As a last resort, filter out invalid addresses. */
+	if ((ia->ia_addr & SPDMEM_I2C_ADDRMASK) == SPDMEM_I2C_ADDR) {
+		match_result = I2C_MATCH_ADDRESS_AND_PROBE;
+		goto do_probe;
 	}
+	
+	/* Not a candidate address. */
+	return 0;
 
+ do_probe:
 	sc.sc_tag = ia->ia_tag;
 	sc.sc_addr = ia->ia_addr;
 	sc.sc_page0 = SPDCTL_SPA0;
@@ -221,8 +235,7 @@ spdmem_i2c_match(device_t parent, cfdata
 		return 0;
 
 	if (spdmem_common_probe(_base)) {
-		return ia->ia_name ? I2C_MATCH_DIRECT_SPECIFIC
-   : I2C_MATCH_ADDRESS_AND_PROBE;
+		return match_result;
 	}
 	return 0;
 }



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 16 05:16:21 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: spdmem_i2c.c

Log Message:
SPD stands for "Serial Presence Detect".  This implies that
if we're using direct configuration that we should treat
that as a *hint*... it's entirely possible that a device
tree lists locations where SPD memory can be found, not
necessarily where memory is known to be present.

Accordingly, if we get a direct configuration match based
on compatible data or device name, we still check to see
if the device is there.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/dev/i2c/spdmem_i2c.c

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



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 16 04:40:08 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2c.c

Log Message:
Rather than allocating 8KB (!!) of space per i2c bus for a sparsely
populated array of child devices, use a sorted list instead, optimized
a bit for the common usage pattern.


To generate a diff of this commit:
cvs rdiff -u -r1.78.2.2 -r1.78.2.3 src/sys/dev/i2c/i2c.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/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.78.2.2 src/sys/dev/i2c/i2c.c:1.78.2.3
--- src/sys/dev/i2c/i2c.c:1.78.2.2	Sat May  8 11:34:38 2021
+++ src/sys/dev/i2c/i2c.c	Sun May 16 04:40:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.78.2.2 2021/05/08 11:34:38 thorpej Exp $	*/
+/*	$NetBSD: i2c.c,v 1.78.2.3 2021/05/16 04:40:08 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.78.2.2 2021/05/08 11:34:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.78.2.3 2021/05/16 04:40:08 thorpej Exp $");
 
 #include 
 #include 
@@ -95,10 +95,20 @@ __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.78
 #define I2C_MAX_ADDR	0x3ff	/* 10-bit address, max */
 #endif
 
+struct i2c_device_link {
+	TAILQ_ENTRY(i2c_device_link) l_list;
+	device_t		l_device;
+	i2c_addr_t		l_addr;
+};
+
+TAILQ_HEAD(i2c_devlist_head, i2c_device_link);
+
 struct iic_softc {
 	device_t sc_dev;
 	i2c_tag_t sc_tag;
-	device_t sc_devices[I2C_MAX_ADDR + 1];
+
+	kmutex_t sc_devlist_lock;
+	struct i2c_devlist_head sc_devlist;
 };
 
 static dev_type_open(iic_open);
@@ -129,6 +139,179 @@ const struct cdevsw iic_cdevsw = {
 
 static void	iic_smbus_intr_thread(void *);
 
+static struct i2c_device_link *
+iic_devslot_lookup(struct iic_softc *sc, i2c_addr_t addr)
+{
+	struct i2c_device_link *link;
+
+	KASSERT(mutex_owned(>sc_devlist_lock));
+
+	/*
+	 * A common pattern is "reserve then insert or delete", and
+	 * this is often done in increasing address order.  So check
+	 * if the last entry is the one we're looking for before we
+	 * search the list from the front.
+	 */
+	link = TAILQ_LAST(>sc_devlist, i2c_devlist_head);
+	if (link == NULL) {
+		/* List is empty. */
+		return NULL;
+	}
+	if (link->l_addr == addr) {
+		return link;
+	}
+
+	TAILQ_FOREACH(link, >sc_devlist, l_list) {
+		/*
+		 * The list is sorted, so if the current list element
+		 * has an address larger than the one we're looking
+		 * for, then it's not in the list.
+		 */
+		if (link->l_addr > addr) {
+			break;
+		}
+		if (link->l_addr == addr) {
+			return link;
+		}
+	}
+	return NULL;
+}
+
+static bool
+iic_devslot_reserve(struct iic_softc *sc, i2c_addr_t addr)
+{
+	struct i2c_device_link *link, *new_link;
+
+	new_link = kmem_zalloc(sizeof(*new_link), KM_SLEEP);
+	new_link->l_addr = addr;
+
+	mutex_enter(>sc_devlist_lock);
+
+	/* Optimize for reserving in increasing i2c address order. */
+	link = TAILQ_LAST(>sc_devlist, i2c_devlist_head);
+	if (link == NULL || link->l_addr < new_link->l_addr) {
+		TAILQ_INSERT_TAIL(>sc_devlist, new_link, l_list);
+		new_link = NULL;
+		goto done;
+	}
+	KASSERT(!TAILQ_EMPTY(>sc_devlist));
+
+	/* Sort the new entry into the list. */
+	TAILQ_FOREACH(link, >sc_devlist, l_list) {
+		if (link->l_addr < new_link->l_addr) {
+			continue;
+		}
+		if (link->l_addr == new_link->l_addr) {
+			/* Address is already reserved / in-use. */
+			goto done;
+		}
+		/*
+		 * If we get here, we know we should be inserted
+		 * before this element, because we checked to see
+		 * if we should be the last entry before entering
+		 * the loop.
+		 */
+		KASSERT(link->l_addr > new_link->l_addr);
+		TAILQ_INSERT_BEFORE(link, new_link, l_list);
+		new_link = NULL;
+		break;
+	}
+	/*
+	 * Because we checked for an empty list early, if we got
+	 * here it means we inserted before "link".
+	 */
+	KASSERT(link != NULL);
+	KASSERT(TAILQ_NEXT(new_link, l_list) == link);
+
+ done:
+	mutex_exit(>sc_devlist_lock);
+
+	if (new_link != NULL) {
+		kmem_free(new_link, sizeof(*new_link));
+		return false;
+	}
+	return true;
+}
+
+static bool
+iic_devslot_insert(struct iic_softc *sc, device_t dev, i2c_addr_t addr)
+{
+	struct i2c_device_link *link;
+	bool rv = false;
+
+	mutex_enter(>sc_devlist_lock);
+
+	link = iic_devslot_lookup(sc, addr);
+	if (link != NULL) {
+		if (link->l_device == NULL) {
+			link->l_device = dev;
+			rv = true;
+		}
+	}
+
+	mutex_exit(>sc_devlist_lock);
+
+	return rv;
+}
+
+static bool
+iic_devslot_remove(struct iic_softc *sc, device_t dev, i2c_addr_t addr)
+{
+	struct i2c_device_link *link;
+	bool rv = false;
+
+	mutex_enter(>sc_devlist_lock);
+
+	link = iic_devslot_lookup(sc, addr);
+	if (link != NULL) {
+		if (link->l_device == dev) {
+			TAILQ_REMOVE(>sc_devlist, link, l_list);
+			rv = true;
+		} else {
+			link = NULL;
+		}
+	}
+
+	mutex_exit(>sc_devlist_lock);
+
+	if (link != NULL) {
+		

CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 16 04:40:08 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2c.c

Log Message:
Rather than allocating 8KB (!!) of space per i2c bus for a sparsely
populated array of child devices, use a sorted list instead, optimized
a bit for the common usage pattern.


To generate a diff of this commit:
cvs rdiff -u -r1.78.2.2 -r1.78.2.3 src/sys/dev/i2c/i2c.c

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



Re: CVS commit: xsrc/external/mit/xterm/dist

2021-05-15 Thread Simon Burge
Hi Roland,

"Roland Illig" wrote:

> Module Name:  xsrc
> Committed By: rillig
> Date: Sat May 15 19:30:15 UTC 2021
>
> Modified Files:
>
>   xsrc/external/mit/xterm/dist: misc.c
>
> Log Message:
>
> xterm: fix Clang build on i386
>
> xsrc/external/mit/xterm/dist/misc.c:3250:47: error: format specifies
> type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned
> int') [-Werror,-Wformat]

-   printf("color  (ignored, length %lu)\n", have);
+   printf("color  (ignored, length %lu)\n", (unsigned long)have);

Would using "%zu" and reverting the cast be a better fix here?

Cheers,
Simon.


CVS commit: src

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 16 00:09:49 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
Added Files:
src/tests/usr.bin/xlint/lint1: expr_range.exp

Log Message:
tests/lint: add expected output for testing '&' in switch statement


To generate a diff of this commit:
cvs rdiff -u -r1.1050 -r1.1051 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_range.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1050 src/distrib/sets/lists/tests/mi:1.1051
--- src/distrib/sets/lists/tests/mi:1.1050	Fri May 14 21:14:55 2021
+++ src/distrib/sets/lists/tests/mi	Sun May 16 00:09:49 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1050 2021/05/14 21:14:55 rillig Exp $
+# $NetBSD: mi,v 1.1051 2021/05/16 00:09:49 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6190,6 +6190,7 @@
 ./usr/tests/usr.bin/xlint/lint1/emit.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/emit.lntests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_range.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_range.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c			tests-usr.bin-tests	compattestfile,atf

Added files:

Index: src/tests/usr.bin/xlint/lint1/expr_range.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_range.exp:1.1
--- /dev/null	Sun May 16 00:09:49 2021
+++ src/tests/usr.bin/xlint/lint1/expr_range.exp	Sun May 16 00:09:49 2021
@@ -0,0 +1,2 @@
+expr_range.c(30): warning: statement not reached [193]
+expr_range.c(39): warning: statement not reached [193]



CVS commit: src

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 16 00:09:49 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
Added Files:
src/tests/usr.bin/xlint/lint1: expr_range.exp

Log Message:
tests/lint: add expected output for testing '&' in switch statement


To generate a diff of this commit:
cvs rdiff -u -r1.1050 -r1.1051 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_range.exp

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



CVS commit: [thorpej-i2c-spi-conf] src/sys/arch/sparc64/sparc64

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 15 21:19:46 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64 [thorpej-i2c-spi-conf]: ofw_patch.c

Log Message:
Fix the path to the E450 envctrl DT node. Thanks, he@!


To generate a diff of this commit:
cvs rdiff -u -r1.7.4.1 -r1.7.4.2 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.4.1 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.4.2
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.4.1	Sat May 15 03:22:17 2021
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sat May 15 21:19:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.7.4.1 2021/05/15 03:22:17 thorpej Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.7.4.2 2021/05/15 21:19:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020, 2021 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7.4.1 2021/05/15 03:22:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7.4.2 2021/05/15 21:19:46 thorpej Exp $");
 
 #include 
 #include 
@@ -679,8 +679,7 @@ e450_envctrl_fixup(device_t dev, void *a
 }
 
 static const struct device_compatible_entry dtnode_fixup_table_e450[] = {
-	/* XXX Could make this into a special fixup, but dtnode is nicer. */
-	{ .compat = "/XXX/need/the/OFW/path",
+	{ .compat = "/pci/ebus@1/SUNW,envctrl@14,60",
 	  .data = e450_envctrl_fixup },
 
 	DEVICE_COMPAT_EOL



CVS commit: [thorpej-i2c-spi-conf] src/sys/arch/sparc64/sparc64

2021-05-15 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 15 21:19:46 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64 [thorpej-i2c-spi-conf]: ofw_patch.c

Log Message:
Fix the path to the E450 envctrl DT node. Thanks, he@!


To generate a diff of this commit:
cvs rdiff -u -r1.7.4.1 -r1.7.4.2 src/sys/arch/sparc64/sparc64/ofw_patch.c

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



CVS commit: xsrc/external/mit/xterm/dist

2021-05-15 Thread Roland Illig
Module Name:xsrc
Committed By:   rillig
Date:   Sat May 15 19:30:15 UTC 2021

Modified Files:
xsrc/external/mit/xterm/dist: misc.c

Log Message:
xterm: fix Clang build on i386

xsrc/external/mit/xterm/dist/misc.c:3250:47: error: format specifies
type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned
int') [-Werror,-Wformat]


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 xsrc/external/mit/xterm/dist/misc.c

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

Modified files:

Index: xsrc/external/mit/xterm/dist/misc.c
diff -u xsrc/external/mit/xterm/dist/misc.c:1.20 xsrc/external/mit/xterm/dist/misc.c:1.21
--- xsrc/external/mit/xterm/dist/misc.c:1.20	Mon May 10 12:29:11 2021
+++ xsrc/external/mit/xterm/dist/misc.c	Sat May 15 19:30:15 2021
@@ -3247,7 +3247,7 @@ xtermAllocColor(XtermWidget xw, XColor *
 
 if (have == 0 || have > MAX_U_STRING) {
 	if (resource.reportColors) {
-	printf("color  (ignored, length %lu)\n", have);
+	printf("color  (ignored, length %lu)\n", (unsigned long)have);
 	}
 } else if (XParseColor(screen->display, cmap, spec, def)) {
 	XColor save_def = *def;



CVS commit: xsrc/external/mit/xterm/dist

2021-05-15 Thread Roland Illig
Module Name:xsrc
Committed By:   rillig
Date:   Sat May 15 19:30:15 UTC 2021

Modified Files:
xsrc/external/mit/xterm/dist: misc.c

Log Message:
xterm: fix Clang build on i386

xsrc/external/mit/xterm/dist/misc.c:3250:47: error: format specifies
type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned
int') [-Werror,-Wformat]


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 xsrc/external/mit/xterm/dist/misc.c

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



CVS commit: src/external/bsd/wpa/dist/src/common

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May 15 19:19:55 UTC 2021

Modified Files:
src/external/bsd/wpa/dist/src/common: dpp.c

Log Message:
wpa: fix Clang build

src/external/bsd/wpa/bin/hostapd/../../dist/src/common/dpp.c:5377:7:
error: format specifies type 'unsigned long' but the argument has type
'os_time_t' (aka 'long long') [-Werror,-Wformat]


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/wpa/dist/src/common/dpp.c

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

Modified files:

Index: src/external/bsd/wpa/dist/src/common/dpp.c
diff -u src/external/bsd/wpa/dist/src/common/dpp.c:1.1.1.2 src/external/bsd/wpa/dist/src/common/dpp.c:1.2
--- src/external/bsd/wpa/dist/src/common/dpp.c:1.1.1.2	Mon Mar  1 01:37:55 2021
+++ src/external/bsd/wpa/dist/src/common/dpp.c	Sat May 15 19:19:55 2021
@@ -5373,8 +5373,9 @@ int dpp_key_expired(const char *timestam
 	}
 
 	if (now.sec > utime) {
-		wpa_printf(MSG_DEBUG, "DPP: Key has expired (%lu < %lu)",
-			   utime, now.sec);
+		wpa_printf(MSG_DEBUG, "DPP: Key has expired (%llu < %llu)",
+			   (unsigned long long)utime,
+			   (unsigned long long)now.sec);
 		return 1;
 	}
 



CVS commit: src/external/bsd/wpa/dist/src/common

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May 15 19:19:55 UTC 2021

Modified Files:
src/external/bsd/wpa/dist/src/common: dpp.c

Log Message:
wpa: fix Clang build

src/external/bsd/wpa/bin/hostapd/../../dist/src/common/dpp.c:5377:7:
error: format specifies type 'unsigned long' but the argument has type
'os_time_t' (aka 'long long') [-Werror,-Wformat]


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/wpa/dist/src/common/dpp.c

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



CVS commit: src

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May 15 19:12:15 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: Makefile expr_range.c
src/usr.bin/xlint/lint1: func.c lint1.h

Log Message:
lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/expr_range.c
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/xlint/lint1/lint1.h

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.56 src/tests/usr.bin/xlint/lint1/Makefile:1.57
--- src/tests/usr.bin/xlint/lint1/Makefile:1.56	Fri May 14 21:14:55 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sat May 15 19:12:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.56 2021/05/14 21:14:55 rillig Exp $
+# $NetBSD: Makefile,v 1.57 2021/05/15 19:12:14 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	343		# see lint1/err.c
@@ -104,6 +104,7 @@ FILES+=		emit.c
 FILES+=		emit.exp
 FILES+=		emit.ln
 FILES+=		expr_range.c
+FILES+=		expr_range.exp
 FILES+=		feat_stacktrace.c
 FILES+=		feat_stacktrace.exp
 FILES+=		gcc_attribute.c

Index: src/tests/usr.bin/xlint/lint1/expr_range.c
diff -u src/tests/usr.bin/xlint/lint1/expr_range.c:1.1 src/tests/usr.bin/xlint/lint1/expr_range.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_range.c:1.1	Fri May 14 21:14:55 2021
+++ src/tests/usr.bin/xlint/lint1/expr_range.c	Sat May 15 19:12:14 2021
@@ -1,37 +1,43 @@
-/*	$NetBSD: expr_range.c,v 1.1 2021/05/14 21:14:55 rillig Exp $	*/
+/*	$NetBSD: expr_range.c,v 1.2 2021/05/15 19:12:14 rillig Exp $	*/
 # 3 "expr_range.c"
 
 /*
- * Test whether lint can detect switch branches that are impossible to reach.
- * As of 2021-05-14, it cannot.  To do this, it would need to keep track of
- * the possible values of each variable or expression.  To do this reliably,
- * it would also need accurate control flow analysis, which as of 2021-05-14
- * works only for functions without 'goto'.
+ * In a switch statement that has (expr & constant) as the controlling
+ * expression, complain if one of the case branches is unreachable because
+ * the case label does can never match the controlling expression.
  *
- * GCC 10 does not complain the unreachable branch.  It knows that the branch
- * is unreachable though since it doesn't generate any code for it.  GCC once
- * had the option -Wunreachable-code, but that option was made a no-op in
- * 2011.
+ * GCC 10 does not complain about the unreachable branch.  It knows that the
+ * branch is unreachable though since it doesn't generate any code for it.
+ * GCC once had the option -Wunreachable-code, but that option was made a
+ * no-op in 2011.
  *
  * Clang 10 does not complain about this either, and just like GCC it doesn't
  * generate any code for this branch.  The code for tracking an expression's
  * possible values may be related to RangeConstraintManager, just guessing.
- *
- * There should be at least one static analysis tool that warns about this.
  */
 
 /* lint1-extra-flags: -chap */
 
+void println(const char *);
+
 void
 example(unsigned x)
 {
 	switch (x & 6) {
-	case 1:
-		/* This branch is unreachable. */
-		printf("one\n");
+	case 0:
+		println("0 is reachable");
+		break;
+	case 1:			/* expect: statement not reached */
+		println("1 is not reachable");
 		break;
 	case 2:
-		printf("two\n");
+		println("2 is reachable");
+		break;
+	case 6:
+		println("6 is reachable");
+		break;
+	case 7:			/* expect: statement not reached */
+		println("7 is not reachable");
 		break;
 	}
 }

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.107 src/usr.bin/xlint/lint1/func.c:1.108
--- src/usr.bin/xlint/lint1/func.c:1.107	Mon May  3 07:08:54 2021
+++ src/usr.bin/xlint/lint1/func.c	Sat May 15 19:12:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.107 2021/05/03 07:08:54 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.108 2021/05/15 19:12:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.107 2021/05/03 07:08:54 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.108 2021/05/15 19:12:14 rillig Exp $");
 #endif
 
 #include 
@@ -440,6 +440,25 @@ named_label(sym_t *sym)
 }
 
 static void
+check_case_label_bitand(const tnode_t *case_expr, const tnode_t *switch_expr)
+{
+	uint64_t case_value, mask;
+
+	if (switch_expr->tn_op != BITAND ||
+	switch_expr->tn_right->tn_op != CON)
+		return;
+
+	lint_assert(case_expr->tn_op == CON);
+	case_value = case_expr->tn_val->v_quad;
+	mask = 

CVS commit: src

2021-05-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May 15 19:12:15 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: Makefile expr_range.c
src/usr.bin/xlint/lint1: func.c lint1.h

Log Message:
lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/expr_range.c
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/xlint/lint1/lint1.h

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



CVS commit: src/sys/dev/pci

2021-05-15 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat May 15 13:00:45 UTC 2021

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to prevent
sign extension of product ID when shifted up into place in PCI_ID_CODE()

Should fix PR 56176.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/pci/pcireg.h

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



CVS commit: src/sys/dev/pci

2021-05-15 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat May 15 13:00:45 UTC 2021

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to prevent
sign extension of product ID when shifted up into place in PCI_ID_CODE()

Should fix PR 56176.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.153 src/sys/dev/pci/pcireg.h:1.154
--- src/sys/dev/pci/pcireg.h:1.153	Mon Dec 28 13:12:24 2020
+++ src/sys/dev/pci/pcireg.h	Sat May 15 13:00:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.153 2020/12/28 13:12:24 skrll Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.154 2021/05/15 13:00:45 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -54,12 +54,12 @@ typedef u_int16_t pci_vendor_id_t;
 typedef u_int16_t pci_product_id_t;
 
 #define	PCI_VENDOR_SHIFT		0
-#define	PCI_VENDOR_MASK			0x
+#define	PCI_VENDOR_MASK			0xU
 #define	PCI_VENDOR(id) \
 	(((id) >> PCI_VENDOR_SHIFT) & PCI_VENDOR_MASK)
 
 #define	PCI_PRODUCT_SHIFT		16
-#define	PCI_PRODUCT_MASK		0x
+#define	PCI_PRODUCT_MASK		0xU
 #define	PCI_PRODUCT(id) \
 	(((id) >> PCI_PRODUCT_SHIFT) & PCI_PRODUCT_MASK)
 



CVS commit: src/sys/arch/aarch64/aarch64

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:39:20 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch32_syscall.c

Log Message:
Wrap long line. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/aarch32_syscall.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/aarch64/aarch64/aarch32_syscall.c
diff -u src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4 src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.5
--- src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4	Sat May 15 11:38:26 2021
+++ src/sys/arch/aarch64/aarch64/aarch32_syscall.c	Sat May 15 11:39:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $	*/
+/*	$NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $");
 
 #include 
 #include 
@@ -151,7 +151,8 @@ EMULNAME(syscall)(struct trapframe *tf)
 	do_trace = p->p_trace_enabled &&
 	((callp->sy_flags & SYCALL_INDIRECT) == 0);
 	if (__predict_false(do_trace ||
-	KDTRACE_ENTRY(callp->sy_entry) || KDTRACE_ENTRY(callp->sy_return))) {
+	KDTRACE_ENTRY(callp->sy_entry) ||
+	KDTRACE_ENTRY(callp->sy_return))) {
 		/* build 64bit args for trace_enter()/trace_exit() */
 		int nargs = callp->sy_narg;
 		for (i = 0; i < nargs; i++)



CVS commit: src/sys/arch/aarch64/aarch64

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:39:20 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch32_syscall.c

Log Message:
Wrap long line. No binary changes.


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

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:38:26 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch32_syscall.c

Log Message:
Fix __syscall(2) for COMPAT_NETBSD32 on aarch64{,eb}.

The 1st argument for __syscall(2) is quad_t, which is stored in r0 and r1.

Now, tests/lib/libc/t_syscall:mmap___syscall passes for COMPAT_NETBSD32.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/aarch32_syscall.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/aarch64/aarch64/aarch32_syscall.c
diff -u src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.3 src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4
--- src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.3	Fri Apr 12 09:29:26 2019
+++ src/sys/arch/aarch64/aarch64/aarch32_syscall.c	Sat May 15 11:38:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: aarch32_syscall.c,v 1.3 2019/04/12 09:29:26 ryo Exp $	*/
+/*	$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.3 2019/04/12 09:29:26 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $");
 
 #include 
 #include 
@@ -91,9 +91,24 @@ EMULNAME(syscall)(struct trapframe *tf)
 	code %= EMULNAMEU(SYS_NSYSENT);
 	callp = p->p_emul->e_sysent + code;
 	if (__predict_false(callp->sy_flags & SYCALL_INDIRECT)) {
-		nargs_reg -= 1;
-		regstart = 1;	/* args start from r1 */
-		code = tf->tf_reg[0] % EMULNAMEU(SYS_NSYSENT);
+		int off = 1;
+#ifdef NETBSD32_SYS_netbsd32syscall /* XXX ugly: apply only for NETBSD32 */
+		/*
+		 * For __syscall(2), 1st argument is quad_t, which is
+		 * stored in r0 and r1.
+		 */
+		if (code == NETBSD32_SYS_netbsd32syscall)
+			off = 2;
+#endif
+		nargs_reg -= off;
+		regstart = off;	/* args start from r1 or r2 */
+#ifdef __AARCH64EB__
+		if (off == 2)
+			code = tf->tf_reg[1];
+		else
+#endif
+			code = tf->tf_reg[0];
+		code %= EMULNAMEU(SYS_NSYSENT);
 		callp = p->p_emul->e_sysent + code;
 
 		/* don't allow nested syscall */



CVS commit: src/sys/arch/aarch64/aarch64

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:38:26 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch32_syscall.c

Log Message:
Fix __syscall(2) for COMPAT_NETBSD32 on aarch64{,eb}.

The 1st argument for __syscall(2) is quad_t, which is stored in r0 and r1.

Now, tests/lib/libc/t_syscall:mmap___syscall passes for COMPAT_NETBSD32.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/aarch32_syscall.c

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



CVS commit: src/lib/libcurses

2021-05-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat May 15 11:06:08 UTC 2021

Modified Files:
src/lib/libcurses: newwin.c

Log Message:
__newwin - fix BGWCOL initialization.

>From Michael Forney in PR lib/56174


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/newwin.c

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



CVS commit: src/lib/libcurses

2021-05-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat May 15 11:06:08 UTC 2021

Modified Files:
src/lib/libcurses: newwin.c

Log Message:
__newwin - fix BGWCOL initialization.

>From Michael Forney in PR lib/56174


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/lib/libcurses/newwin.c

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

Modified files:

Index: src/lib/libcurses/newwin.c
diff -u src/lib/libcurses/newwin.c:1.58 src/lib/libcurses/newwin.c:1.59
--- src/lib/libcurses/newwin.c:1.58	Tue Jul 14 04:39:39 2020
+++ src/lib/libcurses/newwin.c	Sat May 15 11:06:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $	*/
+/*	$NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c	8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.58 2020/07/14 04:39:39 uwe Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $");
 #endif
 #endif/* not lint */
 
@@ -144,9 +144,7 @@ __newwin(SCREEN *screen, int nlines, int
 
 	win->bch = ' ';
 	if (__using_color)
-		win->battr = __default_color;
-	else
-		win->battr = 0;
+		win->battr |= __default_color;
 	win->nextp = win;
 	win->ch_off = 0;
 	win->orig = NULL;
@@ -386,6 +384,7 @@ __makenew(SCREEN *screen, int nlines, in
 	win->flags = (__IDLINE | __IDCHAR);
 	win->delay = -1;
 	win->wattr = 0;
+	win->battr = 0;
 #ifdef HAVE_WCHAR
 	win->bnsp = NULL;
 	SET_BGWCOL(*win, 1);



CVS commit: src/doc

2021-05-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 15 10:22:46 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
note spiflash(4) works on rk3328.


To generate a diff of this commit:
cvs rdiff -u -r1.2805 -r1.2806 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2805 src/doc/CHANGES:1.2806
--- src/doc/CHANGES:1.2805	Tue May 11 14:52:22 2021
+++ src/doc/CHANGES	Sat May 15 10:22:46 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2805 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2806 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -373,3 +373,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	aiomixer(1): Added aiomixer, a curses-based mixer for NetBSD's
 		audio API.
 	wskbd(4): Added German Neo 2 layout. [nia 20210511]
+	spiflash(4): Add support for Rockchip RK3328. [mrg 20210514]



CVS commit: src/doc

2021-05-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 15 10:22:46 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
note spiflash(4) works on rk3328.


To generate a diff of this commit:
cvs rdiff -u -r1.2805 -r1.2806 src/doc/CHANGES

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



CVS commit: src/sys/arch/arm/rockchip

2021-05-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 15 08:46:01 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk3328_cru.c rk_spi.c

Log Message:
add SPI support to rk3328, tested on rock64.

simply adding the SPI clocks (and pwm while here) and enabling
the config match was sufficient, though my first rock64 seems
to have a deal SPI now (does not probe in u-boot or netbsd.)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/rockchip/rk3328_cru.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk_spi.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/arm/rockchip/rk3328_cru.c
diff -u src/sys/arch/arm/rockchip/rk3328_cru.c:1.7 src/sys/arch/arm/rockchip/rk3328_cru.c:1.8
--- src/sys/arch/arm/rockchip/rk3328_cru.c:1.7	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk3328_cru.c	Sat May 15 08:46:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3328_cru.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: rk3328_cru.c,v 1.8 2021/05/15 08:46:00 mrg Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.8 2021/05/15 08:46:00 mrg Exp $");
 
 #include 
 #include 
@@ -218,6 +218,20 @@ static struct rk_cru_clk rk3328_cru_clks
 		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(2),		/* gate_mask */
 		 0),
+	RK_COMPOSITE(RK3328_SCLK_SPI, "clk_spi", mux_2plls_parents,
+		 CLKSEL_CON(24),	/* muxdiv_reg */
+		 __BIT(7),		/* mux_mask */
+		 __BITS(6,0),	/* div_mask */
+		 CLKGATE_CON(2),	/* gate_reg */
+		 __BIT(7),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3328_SCLK_PWM, "clk_pwm", mux_2plls_parents,
+		 CLKSEL_CON(24),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(14,8),	/* div_mask */
+		 CLKGATE_CON(2),	/* gate_reg */
+		 __BIT(8),		/* gate_mask */
+		 0),
 	RK_COMPOSITE(RK3328_ACLK_PERI_PRE, "aclk_peri_pre", aclk_peri_pre_parents,
 		 CLKSEL_CON(28),	/* muxdiv_reg */
 		 __BITS(7,6),	/* mux_mask */
@@ -239,7 +253,7 @@ static struct rk_cru_clk rk3328_cru_clks
 		 __BIT(1),		/* gate_mask */
 		 0),
 	RK_COMPOSITE(RK3328_SCLK_SDMMC, "clk_sdmmc", mmc_parents,
-		 CLKSEL_CON(30),		/* muxdiv_reg */
+		 CLKSEL_CON(30),	/* muxdiv_reg */
 		 __BITS(9,8),	/* mux_mask */
 		 __BITS(7,0),	/* div_mask */
 		 CLKGATE_CON(4),	/* gate_reg */
@@ -360,6 +374,8 @@ static struct rk_cru_clk rk3328_cru_clks
 	RK_GATE(RK3328_PCLK_I2C1, "pclk_i2c1", "pclk_bus", CLKGATE_CON(16), 0),
 	RK_GATE(RK3328_PCLK_I2C2, "pclk_i2c2", "pclk_bus", CLKGATE_CON(16), 1),
 	RK_GATE(RK3328_PCLK_I2C3, "pclk_i2c3", "pclk_bus", CLKGATE_CON(16), 2),
+	RK_GATE(RK3328_PCLK_SPI, "pclk_spi", "pclk_bus", CLKGATE_CON(16), 5),
+	RK_GATE(RK3328_PCLK_PWM, "pclk_rk_pwm", "pclk_bus", CLKGATE_CON(16), 6),
 	RK_GATE(RK3328_PCLK_GPIO0, "pclk_gpio0", "pclk_bus", CLKGATE_CON(16), 7),
 	RK_GATE(RK3328_PCLK_GPIO1, "pclk_gpio1", "pclk_bus", CLKGATE_CON(16), 8),
 	RK_GATE(RK3328_PCLK_GPIO2, "pclk_gpio2", "pclk_bus", CLKGATE_CON(16), 9),

Index: src/sys/arch/arm/rockchip/rk_spi.c
diff -u src/sys/arch/arm/rockchip/rk_spi.c:1.6 src/sys/arch/arm/rockchip/rk_spi.c:1.7
--- src/sys/arch/arm/rockchip/rk_spi.c:1.6	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk_spi.c	Sat May 15 08:46:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rk_spi.c,v 1.6 2021/01/27 03:10:19 thorpej Exp $	*/
+/*	$NetBSD: rk_spi.c,v 1.7 2021/05/15 08:46:00 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.6 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.7 2021/05/15 08:46:00 mrg Exp $");
 
 #include 
 #include 
@@ -144,10 +144,8 @@ __KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1
 #define SPI_FIFOLEN		32
 
 static const struct device_compatible_entry compat_data[] = {
-#if 0 /* should work on RK3328 but untested */
 	{ .compat = "rockchip,rk3066-spi" },
 	{ .compat = "rockchip,rk3328-spi" },
-#endif		
 	{ .compat = "rockchip,rk3399-spi" },
 	DEVICE_COMPAT_EOL
 };



CVS commit: src/sys/arch/arm/rockchip

2021-05-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 15 08:46:01 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk3328_cru.c rk_spi.c

Log Message:
add SPI support to rk3328, tested on rock64.

simply adding the SPI clocks (and pwm while here) and enabling
the config match was sufficient, though my first rock64 seems
to have a deal SPI now (does not probe in u-boot or netbsd.)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/rockchip/rk3328_cru.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk_spi.c

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