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

2023-11-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov 11 17:35:45 UTC 2023

Modified Files:
src/sys/arch/arm/cortex: gicv3_its.c

Log Message:
gicv3_its: assorted minor improvements

- KASSERT that the command queue is not stalled due to async error
  before issuing more commands.
- implement gits_command_int under #if 0 (useful for troubleshooting)
- protect command queue with its_lock consistently
- KASSERT for 32-bit MSI that upper bits are 0
- KASSERT return value of gicv3_its_msi_alloc_lpi
- KASSERT that safe conditions for writing to CBASER are met
- move CWRITER initialization to before CBASER
- fix alignment of tables for the 16KB page size case


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/cortex/gicv3_its.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/arm/cortex

2023-11-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov 11 17:35:45 UTC 2023

Modified Files:
src/sys/arch/arm/cortex: gicv3_its.c

Log Message:
gicv3_its: assorted minor improvements

- KASSERT that the command queue is not stalled due to async error
  before issuing more commands.
- implement gits_command_int under #if 0 (useful for troubleshooting)
- protect command queue with its_lock consistently
- KASSERT for 32-bit MSI that upper bits are 0
- KASSERT return value of gicv3_its_msi_alloc_lpi
- KASSERT that safe conditions for writing to CBASER are met
- move CWRITER initialization to before CBASER
- fix alignment of tables for the 16KB page size case


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/cortex/gicv3_its.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/cortex/gicv3_its.c
diff -u src/sys/arch/arm/cortex/gicv3_its.c:1.34 src/sys/arch/arm/cortex/gicv3_its.c:1.35
--- src/sys/arch/arm/cortex/gicv3_its.c:1.34	Sun Oct 31 17:24:11 2021
+++ src/sys/arch/arm/cortex/gicv3_its.c	Sat Nov 11 17:35:45 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.34 2021/10/31 17:24:11 skrll Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.35 2023/11/11 17:35:45 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.34 2021/10/31 17:24:11 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.35 2023/11/11 17:35:45 tnn Exp $");
 
 #include 
 #include 
@@ -117,6 +117,11 @@ gits_command(struct gicv3_its *its, cons
 
 	cwriter = gits_read_8(its, GITS_CWRITER);
 	woff = cwriter & GITS_CWRITER_Offset;
+#ifdef DIAGNOSTIC
+	uint64_t creadr = gits_read_8(its, GITS_CREADR);
+	KASSERT(!ISSET(creadr, GITS_CREADR_Stalled));
+	KASSERT(((woff + sizeof(cmd->dw)) & (its->its_cmd.len - 1)) != (creadr & GITS_CREADR_Offset));
+#endif
 
 	uint64_t *dw = (uint64_t *)(its->its_cmd.base + woff);
 	for (int i = 0; i < __arraycount(cmd->dw); i++)
@@ -256,6 +261,26 @@ gits_command_sync(struct gicv3_its *its,
 	gits_command(its, &cmd);
 }
 
+#if 0
+static inline void
+gits_command_int(struct gicv3_its *its, uint32_t deviceid, uint32_t eventid)
+{
+	struct gicv3_its_command cmd;
+
+	/*
+	 * Translate the deviceid and eventid into an icid and pintid through
+	 * the device table and ITT. Mark the pintid as pending
+	 * on the redistributor.
+	 * If the interrupt is not configured the command queue stalls.
+	 */
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.dw[0] = GITS_CMD_INT | ((uint64_t)deviceid << 32);
+	cmd.dw[1] = eventid;
+
+	gits_command(its, &cmd);
+}
+#endif
+
 static inline int
 gits_wait(struct gicv3_its *its)
 {
@@ -358,8 +383,10 @@ gicv3_its_device_map(struct gicv3_its *i
 	 * Map the device to the ITT
 	 */
 	const u_int id_bits = __SHIFTOUT(typer, GITS_TYPER_ID_bits) + 1;
+	mutex_enter(its->its_lock);
 	gits_command_mapd(its, devid, dev->dev_itt.segs[0].ds_addr, id_bits - 1, true);
 	gits_wait(its);
+	mutex_exit(its->its_lock);
 
 	return 0;
 }
@@ -391,6 +418,7 @@ gicv3_its_msi_enable(struct gicv3_its *i
 		pci_conf_write(pc, tag, off + PCI_MSI_MDATA64,
 		lpi - its->its_pic->pic_irqbase);
 	} else {
+		KASSERT((addr >> 32) == 0);
 		pci_conf_write(pc, tag, off + PCI_MSI_MADDR,
 		addr & 0x);
 		pci_conf_write(pc, tag, off + PCI_MSI_MDATA,
@@ -485,8 +513,10 @@ gicv3_its_msi_alloc(struct arm_pci_msi *
 		return NULL;
 
 	vectors = kmem_alloc(sizeof(*vectors) * *count, KM_SLEEP);
+	mutex_enter(its->its_lock);
 	for (n = 0; n < *count; n++) {
 		const int lpi = gicv3_its_msi_alloc_lpi(its, pa);
+		KASSERT(lpi >= 0);
 		vectors[n] = ARM_PCI_INTR_MSI |
 		__SHIFTIN(lpi, ARM_PCI_INTR_IRQ) |
 		__SHIFTIN(n, ARM_PCI_INTR_MSI_VEC) |
@@ -508,6 +538,7 @@ gicv3_its_msi_alloc(struct arm_pci_msi *
 		gits_command_sync(its, its->its_rdbase[cpu_index(ci)]);
 	}
 	gits_wait(its);
+	mutex_exit(its->its_lock);
 
 	return vectors;
 }
@@ -555,8 +586,10 @@ gicv3_its_msix_alloc(struct arm_pci_msi 
 	}
 
 	vectors = kmem_alloc(sizeof(*vectors) * *count, KM_SLEEP);
+	mutex_enter(its->its_lock);
 	for (n = 0; n < *count; n++) {
 		const int lpi = gicv3_its_msi_alloc_lpi(its, pa);
+		KASSERT(lpi >= 0);
 		const int msix_vec = table_indexes ? table_indexes[n] : n;
 		vectors[msix_vec] = ARM_PCI_INTR_MSIX |
 		__SHIFTIN(lpi, ARM_PCI_INTR_IRQ) |
@@ -578,6 +611,7 @@ gicv3_its_msix_alloc(struct arm_pci_msi 
 		gits_command_sync(its, its->its_rdbase[cpu_index(ci)]);
 	}
 	gits_wait(its);
+	mutex_exit(its->its_lock);
 
 	bus_space_unmap(bst, bsh, bsz);
 
@@ -638,14 +672,17 @@ gicv3_its_command_init(struct gicv3_soft
 
 	gicv3_dma_alloc(sc, &its->its_cmd, GITS_COMMANDS_SIZE, GITS_COMMANDS_ALIGN);
 
+	KASSERT((gits_read_4(its, GITS_CTLR) & GITS_CTLR_Enabled) == 0);
+	KASSERT((gits_read_4(its, GITS_CTLR) & GITS_CTLR_Quiescent) != 0);
+
 	cbaser = its->its_cmd.segs[0].ds_addr;
 	cbaser |= 

CVS commit: src/sys/uvm

2024-01-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan 13 09:44:42 UTC 2024

Modified Files:
src/sys/uvm: uvm_pglist.c uvm_physseg.c uvm_physseg.h

Log Message:
uvm: change type of uvm_physseg.start_hint from u_int to u_long

Avoids assertion failure in uvm_pglistalloc_s_ps() with large paddrs.
PR kern/57683.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/uvm/uvm_pglist.c
cvs rdiff -u -r1.19 -r1.20 src/sys/uvm/uvm_physseg.c
cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/uvm_physseg.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/uvm/uvm_pglist.c
diff -u src/sys/uvm/uvm_pglist.c:1.90 src/sys/uvm/uvm_pglist.c:1.91
--- src/sys/uvm/uvm_pglist.c:1.90	Tue Dec 21 08:27:49 2021
+++ src/sys/uvm/uvm_pglist.c	Sat Jan 13 09:44:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pglist.c,v 1.90 2021/12/21 08:27:49 skrll Exp $	*/
+/*	$NetBSD: uvm_pglist.c,v 1.91 2024/01/13 09:44:42 tnn Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.90 2021/12/21 08:27:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.91 2024/01/13 09:44:42 tnn Exp $");
 
 #include 
 #include 
@@ -112,8 +112,9 @@ static int
 uvm_pglistalloc_c_ps(uvm_physseg_t psi, int num, paddr_t low, paddr_t high,
 paddr_t alignment, paddr_t boundary, struct pglist *rlist)
 {
-	signed int candidate, limit, candidateidx, end, idx, skip;
-	int pagemask;
+	long candidate, limit, candidateidx, end, idx;
+	int skip;
+	long pagemask;
 	bool second_pass;
 #ifdef DEBUG
 	paddr_t idxpa, lastidxpa;
@@ -138,9 +139,9 @@ uvm_pglistalloc_c_ps(uvm_physseg_t psi, 
 	 * succeeded.
 	 */
 	alignment = atop(alignment);
-	candidate = roundup2(uimax(low, uvm_physseg_get_avail_start(psi) +
+	candidate = roundup2(ulmax(low, uvm_physseg_get_avail_start(psi) +
 		uvm_physseg_get_start_hint(psi)), alignment);
-	limit = uimin(high, uvm_physseg_get_avail_end(psi));
+	limit = ulmin(high, uvm_physseg_get_avail_end(psi));
 	pagemask = ~((boundary >> PAGE_SHIFT) - 1);
 	skip = 0;
 	second_pass = false;
@@ -162,8 +163,8 @@ uvm_pglistalloc_c_ps(uvm_physseg_t psi, 
 			 * is were we started.
 			 */
 			second_pass = true;
-			candidate = roundup2(uimax(low, uvm_physseg_get_avail_start(psi)), alignment);
-			limit = uimin(limit, uvm_physseg_get_avail_start(psi) +
+			candidate = roundup2(ulmax(low, uvm_physseg_get_avail_start(psi)), alignment);
+			limit = ulmin(limit, uvm_physseg_get_avail_start(psi) +
 			uvm_physseg_get_start_hint(psi));
 			skip = 0;
 			continue;
@@ -200,7 +201,7 @@ uvm_pglistalloc_c_ps(uvm_physseg_t psi, 
 		 * Found a suitable starting page.  See if the range is free.
 		 */
 #ifdef PGALLOC_VERBOSE
-		printf("%s: psi=%d candidate=%#x end=%#x skip=%#x, align=%#"PRIxPADDR,
+		printf("%s: psi=%d candidate=%#lx end=%#lx skip=%#x, align=%#"PRIxPADDR,
 		__func__, psi, candidateidx, end, skip, alignment);
 #endif
 		/*
@@ -283,7 +284,7 @@ uvm_pglistalloc_c_ps(uvm_physseg_t psi, 
 	uvm_physseg_get_avail_start(psi));
 	KASSERTMSG(uvm_physseg_get_start_hint(psi) <=
 	uvm_physseg_get_avail_end(psi) - uvm_physseg_get_avail_start(psi),
-	"%x %u (%#x) <= %#"PRIxPADDR" - %#"PRIxPADDR" (%#"PRIxPADDR")",
+	"%lx %lu (%#lx) <= %#"PRIxPADDR" - %#"PRIxPADDR" (%#"PRIxPADDR")",
 	candidate + num,
 	uvm_physseg_get_start_hint(psi), uvm_physseg_get_start_hint(psi),
 	uvm_physseg_get_avail_end(psi), uvm_physseg_get_avail_start(psi),
@@ -523,7 +524,8 @@ static int
 uvm_pglistalloc_s_ps(uvm_physseg_t psi, int num, paddr_t low, paddr_t high,
 struct pglist *rlist)
 {
-	int todo, limit, candidate;
+	int todo;
+	long limit, candidate;
 	struct vm_page *pg;
 	bool second_pass;
 #ifdef PGALLOC_VERBOSE
@@ -546,9 +548,9 @@ uvm_pglistalloc_s_ps(uvm_physseg_t psi, 
 		return -1;
 
 	todo = num;
-	candidate = uimax(low, uvm_physseg_get_avail_start(psi) +
+	candidate = ulmax(low, uvm_physseg_get_avail_start(psi) +
 	uvm_physseg_get_start_hint(psi));
-	limit = uimin(high, uvm_physseg_get_avail_end(psi));
+	limit = ulmin(high, uvm_physseg_get_avail_end(psi));
 	pg = uvm_physseg_get_pg(psi, candidate - uvm_physseg_get_start(psi));
 	second_pass = false;
 
@@ -560,8 +562,8 @@ again:
 break;
 			}
 			second_pass = true;
-			candidate = uimax(low, uvm_physseg_get_avail_start(psi));
-			limit = uimin(limit, uvm_physseg_get_avail_start(psi) +
+			candidate = ulmax(low, uvm_physseg_get_avail_start(psi));
+			limit = ulmin(limit, uvm_physseg_get_avail_start(psi) +
 			uvm_physseg_get_start_hint(psi));
 			pg = uvm_physseg_get_pg(psi, candidate - uvm_physseg_get_start(psi));
 			goto again;
@@ -571,10 +573,10 @@ again:
 			paddr_t cidx = 0;
 			const uvm_physseg_t bank = uvm_physseg_find(candidate, &cidx);
 			KDASSERTMSG(bank == psi,
-			"uvm_physseg_find(%#x) (%"PRIxPHYSSEG ") != psi %"PRIxPHYSSEG,
+			"uvm_physseg_find(%#lx

CVS commit: src/sys/uvm

2024-01-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan 13 09:44:42 UTC 2024

Modified Files:
src/sys/uvm: uvm_pglist.c uvm_physseg.c uvm_physseg.h

Log Message:
uvm: change type of uvm_physseg.start_hint from u_int to u_long

Avoids assertion failure in uvm_pglistalloc_s_ps() with large paddrs.
PR kern/57683.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/uvm/uvm_pglist.c
cvs rdiff -u -r1.19 -r1.20 src/sys/uvm/uvm_physseg.c
cvs rdiff -u -r1.8 -r1.9 src/sys/uvm/uvm_physseg.h

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



CVS commit: src/sys/uvm

2024-01-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Jan 14 10:38:47 UTC 2024

Modified Files:
src/sys/uvm: uvm_pglist.c

Log Message:
fix DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/uvm/uvm_pglist.c

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



CVS commit: src/sys/uvm

2024-01-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Jan 14 10:38:47 UTC 2024

Modified Files:
src/sys/uvm: uvm_pglist.c

Log Message:
fix DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/uvm/uvm_pglist.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/uvm/uvm_pglist.c
diff -u src/sys/uvm/uvm_pglist.c:1.91 src/sys/uvm/uvm_pglist.c:1.92
--- src/sys/uvm/uvm_pglist.c:1.91	Sat Jan 13 09:44:42 2024
+++ src/sys/uvm/uvm_pglist.c	Sun Jan 14 10:38:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pglist.c,v 1.91 2024/01/13 09:44:42 tnn Exp $	*/
+/*	$NetBSD: uvm_pglist.c,v 1.92 2024/01/14 10:38:47 tnn Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.91 2024/01/13 09:44:42 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pglist.c,v 1.92 2024/01/14 10:38:47 tnn Exp $");
 
 #include 
 #include 
@@ -577,7 +577,7 @@ again:
 			 candidate, bank, psi);
 			KDASSERTMSG(cidx == candidate - uvm_physseg_get_start(psi),
 			"uvm_physseg_find(%#lx): %#"PRIxPADDR" != off %"PRIxPADDR,
-			 candidate, cidx, candidate - uvm_physseg_get_start(psi));
+			 candidate, cidx, (paddr_t)candidate - uvm_physseg_get_start(psi));
 		}
 #endif
 		if (VM_PAGE_IS_FREE(pg) == 0)



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

2019-08-01 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Aug  1 22:23:16 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_a10_ccu.c

Log Message:
sun4i: enable clocks for SPI[0-3], needed by sun4i_spi


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

2019-08-01 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Aug  1 22:23:16 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_a10_ccu.c

Log Message:
sun4i: enable clocks for SPI[0-3], needed by sun4i_spi


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sun4i_a10_ccu.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/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.10 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.11
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.10	Tue Jan 22 23:06:49 2019
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Thu Aug  1 22:23:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $");
 
 #include 
 #include 
@@ -59,8 +59,12 @@ __KERNEL_RCSID(1, "$NetBSD: sun4i_a10_cc
 #define	SD1_SCLK_CFG_REG0x08c
 #define	SD2_SCLK_CFG_REG0x090
 #define	SD3_SCLK_CFG_REG	0x094
+#define	SPI0_CLK_CFG_REG	0x0a0
+#define	SPI1_CLK_CFG_REG	0x0a4
+#define	SPI2_CLK_CFG_REG	0x0a8
 #define	SATA_CFG_REG		0x0c8
 #define	USBPHY_CFG_REG		0x0cc
+#define	SPI3_CLK_CFG_REG	0x0d4
 #define	DRAM_GATING_REG		0x100
 #define	BE0_CFG_REG		0x104
 #define	BE1_CFG_REG		0x108
@@ -270,6 +274,38 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 	__BIT(31),			/* enable */
 	SUNXI_CCU_NM_POWER_OF_TWO),
 
+	SUNXI_CCU_NM(A10_CLK_SPI0, "spi0", mod_parents,
+	SPI0_CLK_CFG_REG,		/* reg */
+	__BITS(17,16),		/* n */
+	__BITS(3,0),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A10_CLK_SPI1, "spi1", mod_parents,
+	SPI1_CLK_CFG_REG,		/* reg */
+	__BITS(17,16),		/* n */
+	__BITS(3,0),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A10_CLK_SPI2, "spi2", mod_parents,
+	SPI2_CLK_CFG_REG,		/* reg */
+	__BITS(17,16),		/* n */
+	__BITS(3,0),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A10_CLK_SPI3, "spi3", mod_parents,
+	SPI3_CLK_CFG_REG,		/* reg */
+	__BITS(17,16),		/* n */
+	__BITS(3,0),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
 	SUNXI_CCU_NM(A10_CLK_MMC0, "mmc0", mod_parents,
 	SD0_SCLK_CFG_REG,		/* reg */
 	__BITS(17,16),		/* n */



CVS commit: src/sys/dev/spi

2019-08-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 00:46:02 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: print vendor & device id before bailing out on unknown devices


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/spi/m25p.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.6 src/sys/dev/spi/m25p.c:1.7
--- src/sys/dev/spi/m25p.c:1.6	Wed Jan 31 16:00:03 2018
+++ src/sys/dev/spi/m25p.c	Sat Aug  3 00:46:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.6 2018/01/31 16:00:03 jakllsch Exp $ */
+/* $NetBSD: m25p.c,v 1.7 2019/08/03 00:46:02 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.6 2018/01/31 16:00:03 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.7 2019/08/03 00:46:02 tnn Exp $");
 
 #include 
 #include 
@@ -168,7 +168,8 @@ m25p_doattach(device_t self)
 	}
 
 	if (info->name == NULL) {
-		aprint_error(": unknown or unsupported device\n");
+		aprint_error(": vendor 0x%02X dev 0x%04X sig 0x%02X not supported\n",
+			 mfgid, devid, sig);
 		return;
 	}
 



CVS commit: src/sys/dev/spi

2019-08-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 00:46:02 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: print vendor & device id before bailing out on unknown devices


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/spi/m25p.c

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



CVS commit: src/sys/dev/spi

2019-08-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 02:22:06 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add some ~2010 vintage parts found in junk drawer


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/m25p.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.7 src/sys/dev/spi/m25p.c:1.8
--- src/sys/dev/spi/m25p.c:1.7	Sat Aug  3 00:46:02 2019
+++ src/sys/dev/spi/m25p.c	Sat Aug  3 02:22:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.7 2019/08/03 00:46:02 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.8 2019/08/03 02:22:06 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.7 2019/08/03 00:46:02 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.8 2019/08/03 02:22:06 tnn Exp $");
 
 #include 
 #include 
@@ -94,10 +94,18 @@ static const struct m25p_info {
 } m25p_infos[] = {
 	{ 0x16, 0x20, 0x2017, "STMicro M25P64", 8192, 64 },	/* 64Mbit */
 	{ 0x14, 0x20, 0x2015, "STMicro M25P16", 2048, 64 },	/* 16Mbit */
-	{ 0x12,	0x20, 0x2013, "STMicro M25P40", 512, 64 },	/* 4Mbit */
+	{ 0x12, 0x20, 0x2013, "STMicro M25P40", 512, 64 },	/* 4Mbit */
 	{ 0xc0, 0x20, 0x7117, "STMicro M25PX64", 8192, 64 },	/* 64Mbit */
 	{ 0x00, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 },	/* 128Mbit */
 	{ 0x00, 0xBF, 0x2541, "Microchip SST25VF016B", 2048, 64 }, /* 16Mbit */
+	{ 0x00, 0xC2, 0x2011, "Macronix MX25L10", 128, 4 },	/* 1Mbit */
+	{ 0x00, 0xC2, 0x2012, "Macronix MX25L20", 256, 4 },	/* 2Mbit */
+	{ 0x00, 0xC2, 0x2013, "Macronix MX25L40", 512, 4 },	/* 4Mbit */
+	{ 0x00, 0xC2, 0x2014, "Macronix MX25L80", 1024, 4 },	/* 8Mbit */
+	{ 0x00, 0xEF, 0x3011, "Winbond W25X10", 128, 4 },	/* 1Mbit */
+	{ 0x00, 0xEF, 0x3012, "Winbond W25X20", 256, 4 },	/* 2Mbit */
+	{ 0x00, 0xEF, 0x3013, "Winbond W25X40", 512, 4 },	/* 4Mbit */
+	{ 0x00, 0xEF, 0x3014, "Winbond W25X80", 1024, 4 },	/* 8Mbit */
 	{ 0x13, 0xEF, 0x4014, "Winbond W25Q80.V", 1024, 64 },	/* 8Mbit */
 	{ 0x14, 0xEF, 0x4015, "Winbond W25Q16.V", 2048, 64 },	/* 16Mbit */
 	{ 0x15, 0xEF, 0x4016, "Winbond W25Q32.V", 4096, 64 },	/* 32Mbit */



CVS commit: src/sys/dev/spi

2019-08-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 02:22:06 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add some ~2010 vintage parts found in junk drawer


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/m25p.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/arm/sunxi

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 13:28:43 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
Added Files:
src/sys/arch/arm/sunxi: sun4i_spi.c sun4i_spireg.h

Log Message:
sun4i_spi: spi(4) driver for Allwinner A10/A20 platform


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun4i_spi.c \
src/sys/arch/arm/sunxi/sun4i_spireg.h

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

Modified files:

Index: src/sys/arch/arm/sunxi/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.65 src/sys/arch/arm/sunxi/files.sunxi:1.66
--- src/sys/arch/arm/sunxi/files.sunxi:1.65	Fri Jun 14 21:26:36 2019
+++ src/sys/arch/arm/sunxi/files.sunxi	Sat Aug  3 13:28:42 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.65 2019/06/14 21:26:36 tnn Exp $
+#	$NetBSD: files.sunxi,v 1.66 2019/08/03 13:28:42 tnn Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -306,7 +306,10 @@ device	sunxinand: nandbus
 attach	sunxinand at fdt with sunxi_nand
 file	arch/arm/sunxi/sunxi_nand.c		sunxi_nand
 
-# SPI Controller (sun6i-compatible)
+# SPI Controller
+device	sun4ispi: spibus
+attach	sun4ispi at fdt with sun4i_spi
+file	arch/arm/sunxi/sun4i_spi.c		sun4i_spi
 device	sun6ispi: spibus
 attach	sun6ispi at fdt with sun6i_spi
 file	arch/arm/sunxi/sun6i_spi.c		sun6i_spi

Added files:

Index: src/sys/arch/arm/sunxi/sun4i_spi.c
diff -u /dev/null src/sys/arch/arm/sunxi/sun4i_spi.c:1.1
--- /dev/null	Sat Aug  3 13:28:43 2019
+++ src/sys/arch/arm/sunxi/sun4i_spi.c	Sat Aug  3 13:28:42 2019
@@ -0,0 +1,417 @@
+/*	$NetBSD: sun4i_spi.c,v 1.1 2019/08/03 13:28:42 tnn Exp $	*/
+
+/*
+ * Copyright (c) 2019 Tobias Nygren
+ * Copyright (c) 2018 Jonathan A. Kollasch
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.1 2019/08/03 13:28:42 tnn Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char * const compatible[] = {
+	"allwinner,sun4i-a10-spi",
+	NULL
+};
+
+struct sun4ispi_softc {
+	device_t		sc_dev;
+	bus_space_tag_t		sc_bst;
+	bus_space_handle_t	sc_bsh;
+	void			*sc_intrh;
+	struct spi_controller	sc_spi;
+	SIMPLEQ_HEAD(,spi_transfer) sc_q;
+	struct spi_transfer	*sc_transfer;
+	struct spi_chunk	*sc_rchunk, *sc_wchunk;
+	uint32_t		sc_CTL;
+	u_int			sc_modclkrate;
+	volatile bool		sc_running;
+};
+
+#define SPIREG_READ(sc, reg) \
+bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define SPIREG_WRITE(sc, reg, val) \
+bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+
+static int sun4ispi_match(device_t, cfdata_t, void *);
+static void sun4ispi_attach(device_t, device_t, void *);
+
+static int sun4ispi_configure(void *, int, int, int);
+static int sun4ispi_transfer(void *, struct spi_transfer *);
+
+static void sun4ispi_txfifo_fill(struct sun4ispi_softc * const, size_t);
+static void sun4ispi_rxfifo_drain(struct sun4ispi_softc * const, size_t);
+static void sun4ispi_rxtx(struct sun4ispi_softc *);
+static void sun4ispi_set_interrupt_mask(struct sun4ispi_softc * const);
+static void sun4ispi_start(struct sun4ispi_softc * const);
+static int sun4ispi_intr(void *);
+
+CFATTACH_DECL_NEW(sun4i_spi, sizeof(struct sun4ispi_softc),
+sun4ispi_match, sun4ispi_attach, NULL, NULL);
+
+static int
+sun4ispi_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, co

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

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 13:28:43 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
Added Files:
src/sys/arch/arm/sunxi: sun4i_spi.c sun4i_spireg.h

Log Message:
sun4i_spi: spi(4) driver for Allwinner A10/A20 platform


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun4i_spi.c \
src/sys/arch/arm/sunxi/sun4i_spireg.h

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



CVS commit: src/sys/arch/evbarm/conf

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 13:33:10 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC

Log Message:
sun4ispi* at fdt?


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/evbarm/conf/GENERIC

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/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.48 src/sys/arch/evbarm/conf/GENERIC:1.49
--- src/sys/arch/evbarm/conf/GENERIC:1.48	Thu Jul 25 20:27:45 2019
+++ src/sys/arch/evbarm/conf/GENERIC	Sat Aug  3 13:33:10 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.48 2019/07/25 20:27:45 skrll Exp $
+#	$NetBSD: GENERIC,v 1.49 2019/08/03 13:33:10 tnn Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -469,6 +469,7 @@ pseudo-device 	canloop			# CAN loopback 
 sunxican* 	at fdt?			# A10/A20 CAN controller
 
 # SPI
+sun4ispi* 	at fdt?
 sun6ispi* 	at fdt?
 spi* 		at spibus?
 



CVS commit: src/sys/arch/evbarm/conf

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 13:33:10 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC

Log Message:
sun4ispi* at fdt?


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/evbarm/conf/GENERIC

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/sunxi

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 14:42:24 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun6i_spi.c

Log Message:
sun6i_spi: bring over non-intrusive improvements from sun4i_spi

- simplify attach error handling
- calculate minfreq & maxfreq instead of hardcoding
- print configured value of SPI_SCLK
- add convenience macro for reading/writing SPI register
- clean up commented out debug printfs


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun6i_spi.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/arm/sunxi

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 14:42:24 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun6i_spi.c

Log Message:
sun6i_spi: bring over non-intrusive improvements from sun4i_spi

- simplify attach error handling
- calculate minfreq & maxfreq instead of hardcoding
- print configured value of SPI_SCLK
- add convenience macro for reading/writing SPI register
- clean up commented out debug printfs


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun6i_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/sunxi/sun6i_spi.c
diff -u src/sys/arch/arm/sunxi/sun6i_spi.c:1.2 src/sys/arch/arm/sunxi/sun6i_spi.c:1.3
--- src/sys/arch/arm/sunxi/sun6i_spi.c:1.2	Thu Feb  1 14:50:36 2018
+++ src/sys/arch/arm/sunxi/sun6i_spi.c	Sat Aug  3 14:42:24 2019
@@ -1,6 +1,7 @@
-/*	$NetBSD: sun6i_spi.c,v 1.2 2018/02/01 14:50:36 jakllsch Exp $	*/
+/*	$NetBSD: sun6i_spi.c,v 1.3 2019/08/03 14:42:24 tnn Exp $	*/
 
 /*
+ * Copyright (c) 2019 Tobias Nygren
  * Copyright (c) 2018 Jonathan A. Kollasch
  * All rights reserved.
  *
@@ -27,12 +28,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.2 2018/02/01 14:50:36 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.3 2019/08/03 14:42:24 tnn Exp $");
 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -64,6 +64,11 @@ struct sun6ispi_softc {
 	volatile bool		sc_running;
 };
 
+#define SPIREG_READ(sc, reg) \
+bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))
+#define SPIREG_WRITE(sc, reg, val) \
+bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
+
 static int sun6ispi_match(device_t, cfdata_t, void *);
 static void sun6ispi_attach(device_t, device_t, void *);
 
@@ -97,52 +102,37 @@ sun6ispi_attach(device_t parent, device_
 	struct sun6ispi_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
 	struct spibus_attach_args sba;
+	const int phandle = faa->faa_phandle;
+	bus_addr_t addr;
+	bus_size_t size;
 	struct fdtbus_reset *rst;
 	struct clk *clk, *modclk;
 	uint32_t gcr, isr;
 	char intrstr[128];
 
-	aprint_naive("\n");
-	aprint_normal(": SPI\n");
-
 	sc->sc_dev = self;
 	sc->sc_iot = faa->faa_bst;
 	SIMPLEQ_INIT(&sc->sc_q);
 
-	const int phandle = faa->faa_phandle;
-	bus_addr_t addr;
-	bus_size_t size;
-
-	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
-		aprint_error_dev(sc->sc_dev, "missing 'reg' property\n");
+	if ((clk = fdtbus_clock_get_index(phandle, 0)) == NULL
+	|| clk_enable(clk) != 0) {
+		aprint_error(": couldn't enable clock\n");
 		return;
 	}
 
-	if (bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_ioh) != 0) {
-		aprint_error_dev(sc->sc_dev, "unable to map device\n");
+	/* 200MHz max on H3,H5 */
+	if ((modclk = fdtbus_clock_get(phandle, "mod")) == NULL
+	|| clk_set_rate(modclk, 2) != 0
+	|| clk_enable(modclk) != 0) {
+		aprint_error(": couldn't enable module clock\n");
 		return;
 	}
+	sc->sc_modclkrate = clk_get_rate(modclk);
 
-	if ((clk = fdtbus_clock_get_index(phandle, 0)) != NULL) {
-		if (clk_enable(clk) != 0) {
-			aprint_error_dev(sc->sc_dev, "couldn't enable clock\n");
-			return;
-		}
-		device_printf(self, "%s ahb @ %uHz\n", __func__, clk_get_rate(clk));
-	}
-
-	if ((modclk = fdtbus_clock_get(phandle, "mod")) != NULL) {
-		/* 200MHz max on H3,H5 */
-		if (clk_set_rate(modclk, 2) != 0) {
-			aprint_error_dev(sc->sc_dev, "couldn't configure module clock\n");
-			return;
-		}
-		if (clk_enable(modclk) != 0) {
-			aprint_error_dev(sc->sc_dev, "couldn't enable module clock\n");
-			return;
-		}
-		sc->sc_modclkrate = clk_get_rate(modclk);
-		device_printf(self, "%s %uHz\n", __func__, sc->sc_modclkrate);
+	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0
+	|| bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_ioh) != 0) {
+		aprint_error(": couldn't map registers\n");
+		return;
 	}
 
 	if ((rst = fdtbus_reset_get_index(phandle, 0)) != NULL)
@@ -151,8 +141,8 @@ sun6ispi_attach(device_t parent, device_
 			return;
 		}
 
-	isr = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SPI_INT_STA);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_INT_STA, isr);
+	isr = SPIREG_READ(sc, SPI_INT_STA);
+	SPIREG_WRITE(sc, SPI_INT_STA, isr);
 
 	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
 		aprint_error(": failed to decode interrupt\n");
@@ -162,13 +152,17 @@ sun6ispi_attach(device_t parent, device_
 	sc->sc_intrh = fdtbus_intr_establish(phandle, 0, IPL_VM, 0,
 	sun6ispi_intr, sc);
 	if (sc->sc_intrh == NULL) {
-		apr

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

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 19:56:42 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_spi.c

Log Message:
make function prototype consistent


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

2019-08-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  3 19:56:42 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_spi.c

Log Message:
make function prototype consistent


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun4i_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/sunxi/sun4i_spi.c
diff -u src/sys/arch/arm/sunxi/sun4i_spi.c:1.1 src/sys/arch/arm/sunxi/sun4i_spi.c:1.2
--- src/sys/arch/arm/sunxi/sun4i_spi.c:1.1	Sat Aug  3 13:28:42 2019
+++ src/sys/arch/arm/sunxi/sun4i_spi.c	Sat Aug  3 19:56:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun4i_spi.c,v 1.1 2019/08/03 13:28:42 tnn Exp $	*/
+/*	$NetBSD: sun4i_spi.c,v 1.2 2019/08/03 19:56:42 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.1 2019/08/03 13:28:42 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.2 2019/08/03 19:56:42 tnn Exp $");
 
 #include 
 #include 
@@ -73,7 +73,7 @@ static int sun4ispi_transfer(void *, str
 
 static void sun4ispi_txfifo_fill(struct sun4ispi_softc * const, size_t);
 static void sun4ispi_rxfifo_drain(struct sun4ispi_softc * const, size_t);
-static void sun4ispi_rxtx(struct sun4ispi_softc *);
+static void sun4ispi_rxtx(struct sun4ispi_softc * const);
 static void sun4ispi_set_interrupt_mask(struct sun4ispi_softc * const);
 static void sun4ispi_start(struct sun4ispi_softc * const);
 static int sun4ispi_intr(void *);
@@ -139,7 +139,7 @@ sun4ispi_attach(device_t parent, device_
 
 	sc->sc_intrh = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, sun4ispi_intr, sc);
 	if (sc->sc_intrh == NULL) {
-		aprint_error("unable to establish interrupt\n");
+		aprint_error(": unable to establish interrupt\n");
 		return;
 	}
 



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

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 17:09:07 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
rk3399_cru: add definitions for SPI clocks


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

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 17:09:07 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
rk3399_cru: add definitions for SPI clocks


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/rockchip/rk3399_cru.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/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.8 src/sys/arch/arm/rockchip/rk3399_cru.c:1.9
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.8	Sun Jun  9 16:14:53 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Sun Aug  4 17:09:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.8 2019/06/09 16:14:53 jmcneill Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.9 2019/08/04 17:09:07 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.8 2019/06/09 16:14:53 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.9 2019/08/04 17:09:07 tnn Exp $");
 
 #include 
 #include 
@@ -760,6 +760,50 @@ static struct rk_cru_clk rk3399_cru_clks
 	RK_GATE(RK3399_PCLK_I2C2, "pclk_rki2c2", "pclk_perilp1", CLKGATE_CON(22), 9),
 	RK_GATE(RK3399_PCLK_I2C3, "pclk_rki2c3", "pclk_perilp1", CLKGATE_CON(22), 10),
 
+	/*
+	 * SPI
+	 */
+	RK_COMPOSITE(RK3399_SCLK_SPI0, "clk_spi0", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(59),	/* muxdiv_reg */
+		 __BIT(7),		/* mux_mask */
+		 __BITS(6,0),	/* div_mask */
+		 CLKGATE_CON(9),	/* gate_reg */
+		 __BIT(12),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3399_SCLK_SPI1, "clk_spi1", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(59),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(14,8),	/* div_mask */
+		 CLKGATE_CON(9),	/* gate_reg */
+		 __BIT(13),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3399_SCLK_SPI2, "clk_spi2", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(60),	/* muxdiv_reg */
+		 __BIT(7),		/* mux_mask */
+		 __BITS(6,0),	/* div_mask */
+		 CLKGATE_CON(9),	/* gate_reg */
+		 __BIT(14),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3399_SCLK_SPI4, "clk_spi4", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(60),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(14,8),	/* div_mask */
+		 CLKGATE_CON(9),	/* gate_reg */
+		 __BIT(15),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3399_SCLK_SPI5, "clk_spi5", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(58),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(14,8),	/* div_mask */
+		 CLKGATE_CON(13),	/* gate_reg */
+		 __BIT(13),		/* gate_mask */
+		 0),
+	RK_GATE(RK3399_PCLK_SPI0, "pclk_rkspi0", "pclk_perilp1", CLKGATE_CON(23), 10),
+	RK_GATE(RK3399_PCLK_SPI1, "pclk_rkspi1", "pclk_perilp1", CLKGATE_CON(23), 11),
+	RK_GATE(RK3399_PCLK_SPI2, "pclk_rkspi2", "pclk_perilp1", CLKGATE_CON(23), 12),
+	RK_GATE(RK3399_PCLK_SPI4, "pclk_rkspi4", "pclk_perilp1", CLKGATE_CON(23), 13),
+	RK_GATE(RK3399_PCLK_SPI5, "pclk_rkspi5", "hclk_perilp1", CLKGATE_CON(34), 5),
+
 	/* PCIe */
 	RK_GATE(RK3399_ACLK_PERF_PCIE, "aclk_perf_pcie", "aclk_perihp", CLKGATE_CON(20), 2),
 	RK_GATE(RK3399_ACLK_PCIE, "aclk_pcie", "aclk_perihp", CLKGATE_CON(20), 10),



CVS commit: src/sys/dev/spi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 20:49:54 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add GigaDevice 25Q127CSIG

(This is the boot ROM found on ROCKPro64.)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/m25p.c

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



CVS commit: src/sys/dev/spi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 20:49:54 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add GigaDevice 25Q127CSIG

(This is the boot ROM found on ROCKPro64.)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/m25p.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.8 src/sys/dev/spi/m25p.c:1.9
--- src/sys/dev/spi/m25p.c:1.8	Sat Aug  3 02:22:06 2019
+++ src/sys/dev/spi/m25p.c	Sun Aug  4 20:49:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.8 2019/08/03 02:22:06 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.9 2019/08/04 20:49:54 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.8 2019/08/03 02:22:06 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.9 2019/08/04 20:49:54 tnn Exp $");
 
 #include 
 #include 
@@ -102,6 +102,7 @@ static const struct m25p_info {
 	{ 0x00, 0xC2, 0x2012, "Macronix MX25L20", 256, 4 },	/* 2Mbit */
 	{ 0x00, 0xC2, 0x2013, "Macronix MX25L40", 512, 4 },	/* 4Mbit */
 	{ 0x00, 0xC2, 0x2014, "Macronix MX25L80", 1024, 4 },	/* 8Mbit */
+	{ 0x00, 0xC8, 0x4018, "GigaDevice 25Q127CSIG", 16384, 4 },	/* 128Mbit */
 	{ 0x00, 0xEF, 0x3011, "Winbond W25X10", 128, 4 },	/* 1Mbit */
 	{ 0x00, 0xEF, 0x3012, "Winbond W25X20", 256, 4 },	/* 2Mbit */
 	{ 0x00, 0xEF, 0x3013, "Winbond W25X40", 512, 4 },	/* 4Mbit */



CVS commit: src/sys/dev/spi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 22:13:24 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: change devices recently added from 4kB "sector size" to 64kB ...

... even though it is wrong and these devices really use 4kB sector size.
Despite the struct member being named sector size it is actually used as
block size. Our spiflash driver doesn't issue sector erase commands.
Stopgap measure to fix data corruption until the driver is fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/spi/m25p.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.9 src/sys/dev/spi/m25p.c:1.10
--- src/sys/dev/spi/m25p.c:1.9	Sun Aug  4 20:49:54 2019
+++ src/sys/dev/spi/m25p.c	Sun Aug  4 22:13:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.9 2019/08/04 20:49:54 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.9 2019/08/04 20:49:54 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $");
 
 #include 
 #include 
@@ -98,15 +98,15 @@ static const struct m25p_info {
 	{ 0xc0, 0x20, 0x7117, "STMicro M25PX64", 8192, 64 },	/* 64Mbit */
 	{ 0x00, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 },	/* 128Mbit */
 	{ 0x00, 0xBF, 0x2541, "Microchip SST25VF016B", 2048, 64 }, /* 16Mbit */
-	{ 0x00, 0xC2, 0x2011, "Macronix MX25L10", 128, 4 },	/* 1Mbit */
-	{ 0x00, 0xC2, 0x2012, "Macronix MX25L20", 256, 4 },	/* 2Mbit */
-	{ 0x00, 0xC2, 0x2013, "Macronix MX25L40", 512, 4 },	/* 4Mbit */
-	{ 0x00, 0xC2, 0x2014, "Macronix MX25L80", 1024, 4 },	/* 8Mbit */
-	{ 0x00, 0xC8, 0x4018, "GigaDevice 25Q127CSIG", 16384, 4 },	/* 128Mbit */
-	{ 0x00, 0xEF, 0x3011, "Winbond W25X10", 128, 4 },	/* 1Mbit */
-	{ 0x00, 0xEF, 0x3012, "Winbond W25X20", 256, 4 },	/* 2Mbit */
-	{ 0x00, 0xEF, 0x3013, "Winbond W25X40", 512, 4 },	/* 4Mbit */
-	{ 0x00, 0xEF, 0x3014, "Winbond W25X80", 1024, 4 },	/* 8Mbit */
+	{ 0x00, 0xC2, 0x2011, "Macronix MX25L10", 128, 64 },	/* 1Mbit */
+	{ 0x00, 0xC2, 0x2012, "Macronix MX25L20", 256, 64 },	/* 2Mbit */
+	{ 0x00, 0xC2, 0x2013, "Macronix MX25L40", 512, 64 },	/* 4Mbit */
+	{ 0x00, 0xC2, 0x2014, "Macronix MX25L80", 1024, 64 },	/* 8Mbit */
+	{ 0x00, 0xC8, 0x4018, "GigaDevice 25Q127CSIG", 16384, 64 },	/* 128Mbit */
+	{ 0x00, 0xEF, 0x3011, "Winbond W25X10", 128, 64 },	/* 1Mbit */
+	{ 0x00, 0xEF, 0x3012, "Winbond W25X20", 256, 64 },	/* 2Mbit */
+	{ 0x00, 0xEF, 0x3013, "Winbond W25X40", 512, 64 },	/* 4Mbit */
+	{ 0x00, 0xEF, 0x3014, "Winbond W25X80", 1024, 64 },	/* 8Mbit */
 	{ 0x13, 0xEF, 0x4014, "Winbond W25Q80.V", 1024, 64 },	/* 8Mbit */
 	{ 0x14, 0xEF, 0x4015, "Winbond W25Q16.V", 2048, 64 },	/* 16Mbit */
 	{ 0x15, 0xEF, 0x4016, "Winbond W25Q32.V", 4096, 64 },	/* 32Mbit */



CVS commit: src/sys/dev/spi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 22:13:24 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: change devices recently added from 4kB "sector size" to 64kB ...

... even though it is wrong and these devices really use 4kB sector size.
Despite the struct member being named sector size it is actually used as
block size. Our spiflash driver doesn't issue sector erase commands.
Stopgap measure to fix data corruption until the driver is fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/spi/m25p.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/arm/sunxi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 22:26:40 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_spi.c sun6i_spi.c

Log Message:
remove useless splbio() in sunxispi_start

We raised spl already in sunxispi_transfer.
XXX spi(4) should be made MPSAFE


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun4i_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun6i_spi.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/arm/sunxi

2019-08-04 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Aug  4 22:26:40 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sun4i_spi.c sun6i_spi.c

Log Message:
remove useless splbio() in sunxispi_start

We raised spl already in sunxispi_transfer.
XXX spi(4) should be made MPSAFE


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun4i_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun6i_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/sunxi/sun4i_spi.c
diff -u src/sys/arch/arm/sunxi/sun4i_spi.c:1.2 src/sys/arch/arm/sunxi/sun4i_spi.c:1.3
--- src/sys/arch/arm/sunxi/sun4i_spi.c:1.2	Sat Aug  3 19:56:42 2019
+++ src/sys/arch/arm/sunxi/sun4i_spi.c	Sun Aug  4 22:26:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun4i_spi.c,v 1.2 2019/08/03 19:56:42 tnn Exp $	*/
+/*	$NetBSD: sun4i_spi.c,v 1.3 2019/08/04 22:26:40 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.2 2019/08/03 19:56:42 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.3 2019/08/04 22:26:40 tnn Exp $");
 
 #include 
 #include 
@@ -337,7 +337,6 @@ sun4ispi_start(struct sun4ispi_softc * c
 {
 	struct spi_transfer *st;
 	uint32_t ctl;
-	int s;
 	struct spi_chunk *chunk;
 	size_t burstcount;
 
@@ -368,13 +367,11 @@ sun4ispi_start(struct sun4ispi_softc * c
 		if (!cold)
 			return;
 
-		s = splbio();
 		for (;;) {
 			(void) sun4ispi_intr(sc);
 			if (ISSET(st->st_flags, SPI_F_DONE))
 break;
 		}
-		splx(s);
 	}
 	sc->sc_running = false;
 }

Index: src/sys/arch/arm/sunxi/sun6i_spi.c
diff -u src/sys/arch/arm/sunxi/sun6i_spi.c:1.3 src/sys/arch/arm/sunxi/sun6i_spi.c:1.4
--- src/sys/arch/arm/sunxi/sun6i_spi.c:1.3	Sat Aug  3 14:42:24 2019
+++ src/sys/arch/arm/sunxi/sun6i_spi.c	Sun Aug  4 22:26:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun6i_spi.c,v 1.3 2019/08/03 14:42:24 tnn Exp $	*/
+/*	$NetBSD: sun6i_spi.c,v 1.4 2019/08/04 22:26:40 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.3 2019/08/03 14:42:24 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.4 2019/08/04 22:26:40 tnn Exp $");
 
 #include 
 #include 
@@ -308,13 +308,11 @@ sun6ispi_start(struct sun6ispi_softc * c
 		if (!cold)
 			return;
 
-		int s = splbio();
 		for (;;) {
 			sun6ispi_intr(sc);
 			if (ISSET(st->st_flags, SPI_F_DONE))
 break;
 		}
-		splx(s);
 	}
 
 	sc->sc_running = false;



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

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 15:22:59 UTC 2019

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

Log Message:
rk_spi: Rockchip SPI driver

Match only on RK3399 for now, but should work on RK3328 as well with
the proper CRU support. If you can, please test and enable for RK3328.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/rockchip/files.rockchip
cvs rdiff -u -r0 -r1.1 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.



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

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 15:22:59 UTC 2019

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

Log Message:
rk_spi: Rockchip SPI driver

Match only on RK3399 for now, but should work on RK3328 as well with
the proper CRU support. If you can, please test and enable for RK3328.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/rockchip/files.rockchip
cvs rdiff -u -r0 -r1.1 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/files.rockchip
diff -u src/sys/arch/arm/rockchip/files.rockchip:1.19 src/sys/arch/arm/rockchip/files.rockchip:1.20
--- src/sys/arch/arm/rockchip/files.rockchip:1.19	Wed May  1 10:41:33 2019
+++ src/sys/arch/arm/rockchip/files.rockchip	Mon Aug  5 15:22:59 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.rockchip,v 1.19 2019/05/01 10:41:33 jmcneill Exp $
+#	$NetBSD: files.rockchip,v 1.20 2019/08/05 15:22:59 tnn Exp $
 #
 # Configuration info for Rockchip family SoCs
 #
@@ -42,6 +42,11 @@ device	rkiic: i2cbus, i2cexec
 attach	rkiic at fdt with rk_i2c
 file	arch/arm/rockchip/rk_i2c.c		rk_i2c
 
+# SPI
+device	rkspi: spibus
+attach	rkspi at fdt with rk_spi
+file	arch/arm/rockchip/rk_spi.c		rk_spi
+
 # USB PHY
 device	rkusb { }
 attach	rkusb at fdt with rk_usb

Added files:

Index: src/sys/arch/arm/rockchip/rk_spi.c
diff -u /dev/null src/sys/arch/arm/rockchip/rk_spi.c:1.1
--- /dev/null	Mon Aug  5 15:22:59 2019
+++ src/sys/arch/arm/rockchip/rk_spi.c	Mon Aug  5 15:22:59 2019
@@ -0,0 +1,517 @@
+/*	$NetBSD: rk_spi.c,v 1.1 2019/08/05 15:22:59 tnn Exp $	*/
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tobias Nygren.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.1 2019/08/05 15:22:59 tnn Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SPI_CTRLR0		0x00
+#define SPI_CTRLR0_MTM		__BIT(21)
+#define SPI_CTRLR0_OPM		__BIT(20)
+#define SPI_CTRLR0_XFM		__BITS(19, 18)
+#define SPI_CTRLR0_FRF		__BITS(17, 16)
+#define SPI_CTRLR0_RSD		__BITS(15, 14)
+#define SPI_CTRLR0_BHT		__BIT(13)
+#define SPI_CTRLR0_FBM		__BIT(12)
+#define SPI_CTRLR0_EM		__BIT(11)
+#define SPI_CTRLR0_RW		__BIT(10)
+#define SPI_CTRLR0_CSM		__BITS(9, 8)
+#define SPI_CTRLR0_SCPOL	__BIT(7)
+#define SPI_CTRLR0_SCPH		__BIT(6)
+#define SPI_CTRLR0_CFS		__BITS(5, 2)
+#define SPI_CTRLR0_DFS		__BITS(1, 0)
+#define SPI_CTRLR0_DFS_4BIT	0x0
+#define SPI_CTRLR0_DFS_8BIT	0x1
+#define SPI_CTRLR0_DFS_16BIT	0x2
+
+#define SPI_CTRLR1		0x04
+#define SPI_CTRLR1_NDM		__BITS(15, 0)
+
+#define SPI_ENR			0x08
+#define SPI_ENR_ENR		__BIT(0)
+
+#define SPI_SER			0x0c
+#define SPI_SER_SER1		__BIT(1)
+#define SPI_SER_SER0		__BIT(0)
+
+#define SPI_BAUDR		0x10
+#define SPI_BAUDR_BAUDR		__BITS(15, 0)
+
+#define SPI_TXFTLR		0x14
+#define SPI_TXFTLR_TXFLTR	__BITS(4, 0)
+
+#define SPI_RXFTLR		0x18
+#define SPI_RXFLTR_RXFLTR	__BITS(4, 0)
+
+#define SPI_TXFLR		0x1c
+#define SPI_TXFLR_TXFLR		__BITS(5, 0)
+
+#define SPI_RXFLR		0x20
+#define SPI_RXFLR_RXFLR		__BITS(5, 0)
+
+#define SPI_SR			0x24
+#define SPI_SR_RFF		__BIT(4)
+#define SPI_SR_RFE		__BIT(3)
+#define SPI_SR_TFE		__BIT(2)
+#define SPI_SR_TFF		__BIT(1)
+#define SPI_SR_BSF		__BIT(0)
+
+#define SPI_IPR			0x28
+#define SPI_IPR_IPR		__BIT(0)
+
+#define SPI_IMR			0x2c
+#define SPI_IMR_RFFIM		__BIT(4)
+#define 

CVS commit: src/sys/arch/evbarm/conf

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 15:30:37 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
rkspi* at fdt?


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/evbarm/conf/GENERIC64

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



CVS commit: src/sys/arch/evbarm/conf

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 15:30:37 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
rkspi* at fdt?


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.103 src/sys/arch/evbarm/conf/GENERIC64:1.104
--- src/sys/arch/evbarm/conf/GENERIC64:1.103	Thu Jul 25 00:30:45 2019
+++ src/sys/arch/evbarm/conf/GENERIC64	Mon Aug  5 15:30:37 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.103 2019/07/25 00:30:45 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.104 2019/08/05 15:30:37 tnn Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -399,6 +399,7 @@ ld*		at nvme? nsid ?
 
 # SPI controllers
 bcmspi*		at fdt?			# Broadcom BCM283x SPI
+rkspi*		at fdt?			# Rockchip SPI
 spi*		at spibus?
 
 # Audio support



CVS commit: src/sys/dev/spi

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 23:42:48 UTC 2019

Modified Files:
src/sys/dev/spi: files.spi

Log Message:
spi: make the "slave" config(5) locator optional

needed to be able to support FDT direct attachment of SPI slaves


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/spi/files.spi

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



CVS commit: src/sys/dev/spi

2019-08-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  5 23:42:48 UTC 2019

Modified Files:
src/sys/dev/spi: files.spi

Log Message:
spi: make the "slave" config(5) locator optional

needed to be able to support FDT direct attachment of SPI slaves


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/spi/files.spi

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/spi/files.spi
diff -u src/sys/dev/spi/files.spi:1.5 src/sys/dev/spi/files.spi:1.6
--- src/sys/dev/spi/files.spi:1.5	Tue Aug 18 15:54:20 2015
+++ src/sys/dev/spi/files.spi	Mon Aug  5 23:42:48 2019
@@ -1,8 +1,8 @@
-#	$NetBSD: files.spi,v 1.5 2015/08/18 15:54:20 phx Exp $
+#	$NetBSD: files.spi,v 1.6 2019/08/05 23:42:48 tnn Exp $
 
 define	spibus { }
 
-device	spi { slave }
+device	spi { [slave = -1] }
 attach	spi at spibus
 file	dev/spi/spi.c			spi | spibus
 



CVS commit: src/sys/dev/ofw

2019-08-06 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug  6 18:17:52 UTC 2019

Modified Files:
src/sys/dev/ofw: ofw_subr.c openfirm.h

Log Message:
ofw: add of_enter_spi_devs helper method

For translating OFW child nodes of SPI controller into "spi-child-devices"
property. In similar spirit to the existing of_enter_i2c_devs method.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ofw/ofw_subr.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ofw/openfirm.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/ofw

2019-08-06 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug  6 18:17:52 UTC 2019

Modified Files:
src/sys/dev/ofw: ofw_subr.c openfirm.h

Log Message:
ofw: add of_enter_spi_devs helper method

For translating OFW child nodes of SPI controller into "spi-child-devices"
property. In similar spirit to the existing of_enter_i2c_devs method.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ofw/ofw_subr.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ofw/openfirm.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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.33 src/sys/dev/ofw/ofw_subr.c:1.34
--- src/sys/dev/ofw/ofw_subr.c:1.33	Wed Sep 26 20:03:36 2018
+++ src/sys/dev/ofw/ofw_subr.c	Tue Aug  6 18:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.33 2018/09/26 20:03:36 jakllsch Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.34 2019/08/06 18:17:52 tnn Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.33 2018/09/26 20:03:36 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.34 2019/08/06 18:17:52 tnn Exp $");
 
 #include 
 #include 
@@ -503,6 +503,64 @@ of_enter_i2c_devs(prop_dictionary_t prop
 	}
 }
 
+void
+of_enter_spi_devs(prop_dictionary_t props, int ofnode, size_t cell_size)
+{
+	int node, len;
+	char name[32];
+	uint64_t reg64;
+	uint32_t reg32;
+	uint32_t slave;
+	u_int32_t maxfreq;
+	prop_array_t array = NULL;
+	prop_dictionary_t dev;
+	int mode;
+
+	for (node = OF_child(ofnode); node; node = OF_peer(node)) {
+		if (OF_getprop(node, "name", name, sizeof(name)) <= 0)
+			continue;
+		len = OF_getproplen(node, "reg");
+		slave = 0;
+		if (cell_size == 8 && len >= sizeof(reg64)) {
+			if (OF_getprop(node, "reg", ®64, sizeof(reg64))
+			< sizeof(reg64))
+continue;
+			slave = be64toh(reg64);
+		} else if (cell_size == 4 && len >= sizeof(reg32)) {
+			if (OF_getprop(node, "reg", ®32, sizeof(reg32))
+			< sizeof(reg32))
+continue;
+			slave = be32toh(reg32);
+		} else {
+			continue;
+		}
+		if (of_getprop_uint32(node, "spi-max-frequency", &maxfreq)) {
+			maxfreq = 0;
+		}
+		mode = ((int)of_hasprop(node, "cpol") << 1) | (int)of_hasprop(node, "cpha");
+
+		if (array == NULL)
+			array = prop_array_create();
+
+		dev = prop_dictionary_create();
+		prop_dictionary_set_cstring(dev, "name", name);
+		prop_dictionary_set_uint32(dev, "slave", slave);
+		prop_dictionary_set_uint32(dev, "mode", mode);
+		if (maxfreq > 0)
+			prop_dictionary_set_uint32(dev, "spi-max-frequency", maxfreq);
+		prop_dictionary_set_uint64(dev, "cookie", node);
+		of_to_dataprop(dev, node, "compatible", "compatible");
+		prop_array_add(array, dev);
+		prop_object_release(dev);
+	}
+
+	if (array != NULL) {
+		prop_dictionary_set(props, "spi-child-devices", array);
+		prop_object_release(array);
+	}
+}
+
+
 /*
  * Returns true if the specified property is present.
  */

Index: src/sys/dev/ofw/openfirm.h
diff -u src/sys/dev/ofw/openfirm.h:1.37 src/sys/dev/ofw/openfirm.h:1.38
--- src/sys/dev/ofw/openfirm.h:1.37	Thu Aug 23 13:24:44 2018
+++ src/sys/dev/ofw/openfirm.h	Tue Aug  6 18:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.h,v 1.37 2018/08/23 13:24:44 jmcneill Exp $	*/
+/*	$NetBSD: openfirm.h,v 1.38 2019/08/06 18:17:52 tnn Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -126,6 +126,7 @@ int	*of_network_decode_media(int, int *,
 char	*of_get_mode_string(char *, int);
 
 void	of_enter_i2c_devs(prop_dictionary_t, int, size_t, int);
+void	of_enter_spi_devs(prop_dictionary_t, int, size_t);
 
 bool	of_hasprop(int, const char *);
 #define of_getprop_bool	of_hasprop



CVS commit: src/sys/dev/spi

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 16:37:15 UTC 2019

Modified Files:
src/sys/dev/spi: spi.c spivar.h

Log Message:
spi: prepare for fdt direct attachment of spi slaves

Introduce sba_child_devices array in spibus_attach_args. If the parent has
populated sba_child_devices then attach them first. Then do any devices
devices the user has wired in the kernel config, if any.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/spi/spi.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/spivar.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/spi/spi.c
diff -u src/sys/dev/spi/spi.c:1.11 src/sys/dev/spi/spi.c:1.12
--- src/sys/dev/spi/spi.c:1.11	Sat Mar  9 07:53:12 2019
+++ src/sys/dev/spi/spi.c	Tue Aug 13 16:37:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: spi.c,v 1.11 2019/03/09 07:53:12 mlelstv Exp $ */
+/* $NetBSD: spi.c,v 1.12 2019/08/13 16:37:15 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.11 2019/03/09 07:53:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.12 2019/08/13 16:37:15 tnn Exp $");
 
 #include "locators.h"
 
@@ -102,6 +102,8 @@ struct spi_handle {
 	int			sh_slave;
 	int			sh_mode;
 	int			sh_speed;
+	int			sh_flags;
+#define SPIH_ATTACHED		1
 };
 
 #define SPI_MAXDATA 4096
@@ -151,15 +153,123 @@ spi_search(device_t parent, cfdata_t cf,
 		return -1;
 	}
 
+	memset(&sa, 0, sizeof sa);
 	sa.sa_handle = &sc->sc_slaves[addr];
+	if (ISSET(sa.sa_handle->sh_flags, SPIH_ATTACHED))
+		return -1;
 
-	if (config_match(parent, cf, &sa) > 0)
+	if (config_match(parent, cf, &sa) > 0) {
+		SET(sa.sa_handle->sh_flags, SPIH_ATTACHED);
 		config_attach(parent, cf, &sa, spi_print);
+	}
 
 	return 0;
 }
 
 /*
+ * XXX this is the same as i2c_fill_compat. It could be refactored into a
+ * common fill_compat function with pointers to compat & ncompat instead
+ * of attach_args as the first parameter.
+ */
+static void
+spi_fill_compat(struct spi_attach_args *sa, const char *compat, size_t len,
+	char **buffer)
+{
+	int count, i;
+	const char *c, *start, **ptr;
+
+	*buffer = NULL;
+	for (i = count = 0, c = compat; i < len; i++, c++)
+		if (*c == 0)
+			count++;
+	count += 2;
+	ptr = malloc(sizeof(char*)*count, M_TEMP, M_WAITOK);
+	if (!ptr)
+		return;
+
+	for (i = count = 0, start = c = compat; i < len; i++, c++) {
+		if (*c == 0) {
+			ptr[count++] = start;
+			start = c + 1;
+		}
+	}
+	if (start < compat + len) {
+		/* last string not 0 terminated */
+		size_t l = c - start;
+		*buffer = malloc(l + 1, M_TEMP, M_WAITOK);
+		memcpy(*buffer, start, l);
+		(*buffer)[l] = 0;
+		ptr[count++] = *buffer;
+	}
+	ptr[count] = NULL;
+
+	sa->sa_compat = ptr;
+	sa->sa_ncompat = count;
+}
+
+static void
+spi_direct_attach_child_devices(device_t parent, struct spi_softc *sc,
+prop_array_t child_devices)
+{
+	unsigned int count;
+	prop_dictionary_t child;
+	prop_data_t cdata;
+	uint32_t slave;
+	uint64_t cookie;
+	struct spi_attach_args sa;
+	int loc[SPICF_NLOCS];
+	char *buf;
+	int i;
+
+	memset(loc, 0, sizeof loc);
+	count = prop_array_count(child_devices);
+	for (i = 0; i < count; i++) {
+		child = prop_array_get(child_devices, i);
+		if (!child)
+			continue;
+		if (!prop_dictionary_get_uint32(child, "slave", &slave))
+			continue;
+		if(slave >= sc->sc_controller.sct_nslaves)
+			continue;
+		if (!prop_dictionary_get_uint64(child, "cookie", &cookie))
+			continue;
+		if (!(cdata = prop_dictionary_get(child, "compatible")))
+			continue;
+		loc[SPICF_SLAVE] = slave;
+
+		memset(&sa, 0, sizeof sa);
+		sa.sa_handle = &sc->sc_slaves[i];
+		if (ISSET(sa.sa_handle->sh_flags, SPIH_ATTACHED))
+			continue;
+		SET(sa.sa_handle->sh_flags, SPIH_ATTACHED);
+
+		buf = NULL;
+		spi_fill_compat(&sa,
+prop_data_data_nocopy(cdata),
+prop_data_size(cdata), &buf);
+		(void) config_found_sm_loc(parent, "spi",
+	   loc, &sa, spi_print,
+	   NULL);
+
+		if (sa.sa_compat)
+			free(sa.sa_compat, M_TEMP);
+		if (buf)
+			free(buf, M_TEMP);
+	}
+}
+
+int
+spi_compatible_match(const struct spi_attach_args *sa, const cfdata_t cf,
+		 const struct device_compatible_entry *compats)
+{
+	if (sa->sa_ncompat > 0)
+		return device_compatible_match(sa->sa_compat, sa->sa_ncompat,
+	   compats, NULL);
+
+	return 1;
+}
+
+/*
  * API for device drivers.
  *
  * We provide wrapper routines to decouple the ABI for the SPI
@@ -197,9 +307,11 @@ spi_attach(device_t parent, device_t sel
 		sc->sc_slaves[i].sh_controller = &sc->sc_controller;
 	}
 
-	/*
-	 * Locate and attach child devices
-	 */
+	/* First attach devices known to be present via fdt */
+	if (sba->sba_child_devices) {
+		spi_direct_attach_child_devices(self, sc, sba->sba_child_devices);
+	}
+	/* Then do any other devices the user may have manually wired */
 	config_search_ia(spi_search, self, "spi", NULL);
 }
 

CVS commit: src/sys/dev/spi

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 16:37:15 UTC 2019

Modified Files:
src/sys/dev/spi: spi.c spivar.h

Log Message:
spi: prepare for fdt direct attachment of spi slaves

Introduce sba_child_devices array in spibus_attach_args. If the parent has
populated sba_child_devices then attach them first. Then do any devices
devices the user has wired in the kernel config, if any.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/spi/spi.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/spi/spivar.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/fdt

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 16:46:49 UTC 2019

Modified Files:
src/sys/dev/fdt: fdtvar.h files.fdt
Added Files:
src/sys/dev/fdt: fdt_spi.c

Log Message:
fdt: add SPI controller frontend


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_spi.c
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/fdt/fdtvar.h
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/fdt/files.fdt

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/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.52 src/sys/dev/fdt/fdtvar.h:1.53
--- src/sys/dev/fdt/fdtvar.h:1.52	Fri Jun 14 11:08:18 2019
+++ src/sys/dev/fdt/fdtvar.h	Tue Aug 13 16:46:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.52 2019/06/14 11:08:18 hkenken Exp $ */
+/* $NetBSD: fdtvar.h,v 1.53 2019/08/13 16:46:49 tnn Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -82,6 +82,10 @@ struct fdtbus_i2c_controller_func {
 	i2c_tag_t (*get_tag)(device_t);
 };
 
+struct fdtbus_spi_controller_func {
+	struct spi_controller *	(*get_controller)(device_t);
+};
+
 struct fdtbus_gpio_controller;
 
 struct fdtbus_gpio_pin {
@@ -253,6 +257,8 @@ int		fdtbus_register_interrupt_controlle
 		const struct fdtbus_interrupt_controller_func *);
 int		fdtbus_register_i2c_controller(device_t, int,
 		const struct fdtbus_i2c_controller_func *);
+int		fdtbus_register_spi_controller(device_t, int,
+		const struct fdtbus_spi_controller_func *);
 int		fdtbus_register_gpio_controller(device_t, int,
 		const struct fdtbus_gpio_controller_func *);
 int		fdtbus_register_pinctrl_config(device_t, int,
@@ -370,6 +376,7 @@ void		fdtbus_power_reset(void);
 void		fdtbus_power_poweroff(void);
 
 device_t	fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t);
+device_t	fdtbus_attach_spibus(device_t, int, cfprint_t);
 
 bool		fdtbus_set_data(const void *);
 const void *	fdtbus_get_data(void);

Index: src/sys/dev/fdt/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.44 src/sys/dev/fdt/files.fdt:1.45
--- src/sys/dev/fdt/files.fdt:1.44	Wed Mar 13 12:17:45 2019
+++ src/sys/dev/fdt/files.fdt	Tue Aug 13 16:46:49 2019
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.44 2019/03/13 12:17:45 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.45 2019/08/13 16:46:49 tnn Exp $
 
 include	"external/bsd/libfdt/conf/files.libfdt"
 
@@ -64,6 +64,7 @@ file	dev/fdt/fdt_pwm.c			fdt
 file	dev/fdt/fdt_regulator.c			fdt
 file	dev/fdt/fdt_reset.c			fdt
 file	dev/fdt/fdt_rtc.c			fdt
+file	dev/fdt/fdt_spi.c			fdt
 file	dev/fdt/fdt_syscon.c			fdt
 file	dev/fdt/fdt_pinctrl.c			fdt
 

Added files:

Index: src/sys/dev/fdt/fdt_spi.c
diff -u /dev/null src/sys/dev/fdt/fdt_spi.c:1.1
--- /dev/null	Tue Aug 13 16:46:50 2019
+++ src/sys/dev/fdt/fdt_spi.c	Tue Aug 13 16:46:49 2019
@@ -0,0 +1,114 @@
+/* $NetBSD: fdt_spi.c,v 1.1 2019/08/13 16:46:49 tnn Exp $ */
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tobias Nygren.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: fdt_spi.c,v 1.1 2019/08/13 16:46:49 tnn Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct fdtbus_spi_controller {
+	device_t spi_dev;
+	int spi_phandle;
+	const struct fdtbus_spi_controller_func *spi_funcs;
+	LIST_ENTRY(fdtbus_spi_controller) spi_next;
+};
+
+static LIST_HEAD(, fdtbus_spi_controller) fdtbus_spi_controllers =
+LIST_HEAD_INITIALIZER(fdtbus_spi_controllers);
+
+int
+fdtbus_register_spi_controller(device_

CVS commit: src/sys/dev/fdt

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 16:46:49 UTC 2019

Modified Files:
src/sys/dev/fdt: fdtvar.h files.fdt
Added Files:
src/sys/dev/fdt: fdt_spi.c

Log Message:
fdt: add SPI controller frontend


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_spi.c
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/fdt/fdtvar.h
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/fdt/files.fdt

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



CVS commit: src/sys/arch/evbarm/conf

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:21:01 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
include the spiflash driver in the stock 64-bit kernel

As it can be attached via fdt now. For Rockpro64.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.104 src/sys/arch/evbarm/conf/GENERIC64:1.105
--- src/sys/arch/evbarm/conf/GENERIC64:1.104	Mon Aug  5 15:30:37 2019
+++ src/sys/arch/evbarm/conf/GENERIC64	Tue Aug 13 17:21:01 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.104 2019/08/05 15:30:37 tnn Exp $
+#	$NetBSD: GENERIC64,v 1.105 2019/08/13 17:21:01 tnn Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -401,6 +401,8 @@ ld*		at nvme? nsid ?
 bcmspi*		at fdt?			# Broadcom BCM283x SPI
 rkspi*		at fdt?			# Rockchip SPI
 spi*		at spibus?
+m25p*		at spi?
+spiflash*	at spiflashbus?
 
 # Audio support
 hdaudio*	at fdt?			# Intel HDA



CVS commit: src/sys/dev/spi

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:11:32 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add compatible entry for "jedec,spi-nor" and match on it


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/spi/m25p.c

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



CVS commit: src/sys

2019-08-13 Thread Tobias Nygren
 $");
 
 #include 
 #include 
@@ -253,6 +253,7 @@ rk_spi_attach(device_t parent, device_t 
 	sc->sc_spi.sct_transfer = rk_spi_transfer;
 	sc->sc_spi.sct_nslaves = 2;
 
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 
 	(void) config_found_ia(self, "spibus", &sba, spibus_print);

Index: src/sys/arch/arm/sunxi/sun4i_spi.c
diff -u src/sys/arch/arm/sunxi/sun4i_spi.c:1.3 src/sys/arch/arm/sunxi/sun4i_spi.c:1.4
--- src/sys/arch/arm/sunxi/sun4i_spi.c:1.3	Sun Aug  4 22:26:40 2019
+++ src/sys/arch/arm/sunxi/sun4i_spi.c	Tue Aug 13 17:03:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun4i_spi.c,v 1.3 2019/08/04 22:26:40 tnn Exp $	*/
+/*	$NetBSD: sun4i_spi.c,v 1.4 2019/08/13 17:03:10 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.3 2019/08/04 22:26:40 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun4i_spi.c,v 1.4 2019/08/13 17:03:10 tnn Exp $");
 
 #include 
 #include 
@@ -151,6 +151,7 @@ sun4ispi_attach(device_t parent, device_
 	sc->sc_spi.sct_configure = sun4ispi_configure;
 	sc->sc_spi.sct_transfer = sun4ispi_transfer;
 	(void) of_getprop_uint32(phandle, "num-cs", &sc->sc_spi.sct_nslaves);
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 
 	(void) config_found_ia(self, "spibus", &sba, spibus_print);

Index: src/sys/arch/arm/sunxi/sun6i_spi.c
diff -u src/sys/arch/arm/sunxi/sun6i_spi.c:1.4 src/sys/arch/arm/sunxi/sun6i_spi.c:1.5
--- src/sys/arch/arm/sunxi/sun6i_spi.c:1.4	Sun Aug  4 22:26:40 2019
+++ src/sys/arch/arm/sunxi/sun6i_spi.c	Tue Aug 13 17:03:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun6i_spi.c,v 1.4 2019/08/04 22:26:40 tnn Exp $	*/
+/*	$NetBSD: sun6i_spi.c,v 1.5 2019/08/13 17:03:10 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.4 2019/08/04 22:26:40 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.5 2019/08/13 17:03:10 tnn Exp $");
 
 #include 
 #include 
@@ -184,6 +184,7 @@ sun6ispi_attach(device_t parent, device_
 	sc->sc_spi.sct_transfer = sun6ispi_transfer;
 	sc->sc_spi.sct_nslaves = 4;
 
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 
 	(void) config_found_ia(self, "spibus", &sba, spibus_print);

Index: src/sys/arch/mips/alchemy/dev/auspi.c
diff -u src/sys/arch/mips/alchemy/dev/auspi.c:1.8 src/sys/arch/mips/alchemy/dev/auspi.c:1.9
--- src/sys/arch/mips/alchemy/dev/auspi.c:1.8	Wed Jan  4 02:36:26 2012
+++ src/sys/arch/mips/alchemy/dev/auspi.c	Tue Aug 13 17:03:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: auspi.c,v 1.8 2012/01/04 02:36:26 kiyohara Exp $ */
+/* $NetBSD: auspi.c,v 1.9 2019/08/13 17:03:10 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.8 2012/01/04 02:36:26 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.9 2019/08/13 17:03:10 tnn Exp $");
 
 #include "locators.h"
 
@@ -147,6 +147,7 @@ auspi_attach(device_t parent, device_t s
 	/* fix this! */
 	sc->sc_spi.sct_nslaves = sc->sc_md.am_nslaves;
 
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 
 	/* enable SPI mode */

Index: src/sys/arch/mips/atheros/dev/arspi.c
diff -u src/sys/arch/mips/atheros/dev/arspi.c:1.11 src/sys/arch/mips/atheros/dev/arspi.c:1.12
--- src/sys/arch/mips/atheros/dev/arspi.c:1.11	Mon Sep  3 16:29:25 2018
+++ src/sys/arch/mips/atheros/dev/arspi.c	Tue Aug 13 17:03:11 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: arspi.c,v 1.11 2018/09/03 16:29:25 riastradh Exp $ */
+/* $NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.11 2018/09/03 16:29:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $");
 
 #include "locators.h"
 
@@ -191,6 +191,7 @@ arspi_attach(device_t parent, device_t s
 	/*
 	 * Initialize and attach bus attach.
 	 */
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 	(void) config_found_ia(self, "spibus", &sba, spibus_print);
 }

Index: src/sys/dev/marvell/mvspi.c
diff -u src/sys/dev/marvell/mvspi.c:1.4 src/sys/dev/marvell/mvspi.c:1.5
--- src/sys/dev/marvell/mvspi.c:1.4	Sun Oct  9 14:49:51 2016
+++ src/sys/dev/marvell/mvspi.c	Tue Aug 13 17:03:10 2019
@@ -148,6 +148,7 @@ mvspi_attach(struct device *parent, stru
 	/*
 	 * Initialize and attach bus attach.
 	 */
+	memset(&sba, 0, sizeof(sba));
 	sba.sba_controller = &sc->sc_spi;
 	(void) config_found_ia(self, "spibus", &sba, spibus_print);
 }



CVS commit: src/sys/dev/spi

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:11:32 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
m25p: add compatible entry for "jedec,spi-nor" and match on it


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/spi/m25p.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.10 src/sys/dev/spi/m25p.c:1.11
--- src/sys/dev/spi/m25p.c:1.10	Sun Aug  4 22:13:24 2019
+++ src/sys/dev/spi/m25p.c	Tue Aug 13 17:11:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.11 2019/08/13 17:11:32 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.11 2019/08/13 17:11:32 tnn Exp $");
 
 #include 
 #include 
@@ -114,16 +114,26 @@ static const struct m25p_info {
 	{ 0 }
 };
 
+static const struct device_compatible_entry compat_data[] = {
+	{ "jedec,spi-nor",	0 },
+	{ NULL,			0 }
+};
+
 static int
 m25p_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct spi_attach_args *sa = aux;
+	int res;
+
+	res = spi_compatible_match(sa, cf, compat_data);
+	if (!res)
+		return res;
 
 	/* configure for 20MHz, which is the max for normal reads */
 	if (spi_configure(sa->sa_handle, SPI_MODE_0, 2000))
-		return 0;
+		res = 0;
 
-	return 1;
+	return res;
 }
 
 static void



CVS commit: src/sys/arch/evbarm/conf

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:21:01 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
include the spiflash driver in the stock 64-bit kernel

As it can be attached via fdt now. For Rockpro64.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/evbarm/conf/GENERIC64

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/dts

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:24:25 UTC 2019

Modified Files:
src/sys/arch/arm/dts: rk3399-rockpro64.dts

Log Message:
rk3399-rockpro64.dts: enable spi1 and add spiflash as a child node


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/dts/rk3399-rockpro64.dts

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/dts/rk3399-rockpro64.dts
diff -u src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.7 src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.8
--- src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.7	Sun Jul 28 10:03:56 2019
+++ src/sys/arch/arm/dts/rk3399-rockpro64.dts	Tue Aug 13 17:24:25 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399-rockpro64.dts,v 1.7 2019/07/28 10:03:56 jmcneill Exp $ */
+/* $NetBSD: rk3399-rockpro64.dts,v 1.8 2019/08/13 17:24:25 tnn Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -79,3 +79,12 @@
 	vpcie3v3-supply = <&vcc3v3_pcie>;
 	status = "okay";
 };
+
+&spi1 {
+	status = "okay";
+	spiflash {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		status = "okay";
+	};
+};



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

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:24:25 UTC 2019

Modified Files:
src/sys/arch/arm/dts: rk3399-rockpro64.dts

Log Message:
rk3399-rockpro64.dts: enable spi1 and add spiflash as a child node


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/dts/rk3399-rockpro64.dts

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

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:15:55 UTC 2019

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

Log Message:
rk_spi: register controller with fdt


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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/rk_spi.c
diff -u src/sys/arch/arm/rockchip/rk_spi.c:1.2 src/sys/arch/arm/rockchip/rk_spi.c:1.3
--- src/sys/arch/arm/rockchip/rk_spi.c:1.2	Tue Aug 13 17:03:10 2019
+++ src/sys/arch/arm/rockchip/rk_spi.c	Tue Aug 13 17:15:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rk_spi.c,v 1.2 2019/08/13 17:03:10 tnn Exp $	*/
+/*	$NetBSD: rk_spi.c,v 1.3 2019/08/13 17:15:55 tnn Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.2 2019/08/13 17:03:10 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.3 2019/08/13 17:15:55 tnn Exp $");
 
 #include 
 #include 
@@ -170,6 +170,7 @@ struct rk_spi_softc {
 #define SPIREG_WRITE(sc, reg, val) \
 bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
 
+static struct spi_controller *rk_spi_get_controller(device_t);
 static int rk_spi_match(device_t, cfdata_t, void *);
 static void rk_spi_attach(device_t, device_t, void *);
 
@@ -186,6 +187,18 @@ static int rk_spi_intr(void *);
 CFATTACH_DECL_NEW(rk_spi, sizeof(struct rk_spi_softc),
 rk_spi_match, rk_spi_attach, NULL, NULL);
 
+static const struct fdtbus_spi_controller_func rk_spi_funcs = {
+	.get_controller = rk_spi_get_controller
+};
+
+static struct spi_controller *
+rk_spi_get_controller(device_t dev)
+{
+	struct rk_spi_softc * const sc = device_private(dev);
+
+	return &sc->sc_spi;
+}
+
 static int
 rk_spi_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -204,8 +217,7 @@ rk_spi_attach(device_t parent, device_t 
 	bus_size_t size;
 	struct clk *sclk, *pclk;
 	char intrstr[128];
-	struct spibus_attach_args sba;
-	
+
 	sc->sc_dev = self;
 	sc->sc_bst = faa->faa_bst;
 	SIMPLEQ_INIT(&sc->sc_q);
@@ -253,10 +265,8 @@ rk_spi_attach(device_t parent, device_t 
 	sc->sc_spi.sct_transfer = rk_spi_transfer;
 	sc->sc_spi.sct_nslaves = 2;
 
-	memset(&sba, 0, sizeof(sba));
-	sba.sba_controller = &sc->sc_spi;
-
-	(void) config_found_ia(self, "spibus", &sba, spibus_print);
+	fdtbus_register_spi_controller(self, phandle, &rk_spi_funcs);
+	(void) fdtbus_attach_spibus(self, phandle, spibus_print);
 }
 
 static int



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

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:15:55 UTC 2019

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

Log Message:
rk_spi: register controller with fdt


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.



CVS commit: src/sys

2019-08-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 13 17:03:11 UTC 2019

Modified Files:
src/sys/arch/arm/at91: at91spi.c
src/sys/arch/arm/broadcom: bcm2835_spi.c
src/sys/arch/arm/imx: imxspi.c
src/sys/arch/arm/rockchip: rk_spi.c
src/sys/arch/arm/sunxi: sun4i_spi.c sun6i_spi.c
src/sys/arch/mips/alchemy/dev: auspi.c
src/sys/arch/mips/atheros/dev: arspi.c
src/sys/dev/marvell: mvspi.c

Log Message:
ensure spibus_attach_args is zero'ed


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/at91/at91spi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/broadcom/bcm2835_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun4i_spi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sun6i_spi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/alchemy/dev/auspi.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/atheros/dev/arspi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/marvell/mvspi.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/arm/rockchip

2019-08-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 20 23:32:33 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_iomux.c

Log Message:
rk3399_iomux: add some #ifdef'd out code to enable the on-chip debug port


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk3399_iomux.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/rk3399_iomux.c
diff -u src/sys/arch/arm/rockchip/rk3399_iomux.c:1.4 src/sys/arch/arm/rockchip/rk3399_iomux.c:1.5
--- src/sys/arch/arm/rockchip/rk3399_iomux.c:1.4	Tue Apr 30 22:42:32 2019
+++ src/sys/arch/arm/rockchip/rk3399_iomux.c	Tue Aug 20 23:32:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_iomux.c,v 1.4 2019/04/30 22:42:32 jmcneill Exp $ */
+/* $NetBSD: rk3399_iomux.c,v 1.5 2019/08/20 23:32:33 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -29,7 +29,7 @@
 //#define RK3399_IOMUX_DEBUG
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.4 2019/04/30 22:42:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.5 2019/08/20 23:32:33 tnn Exp $");
 
 #include 
 #include 
@@ -450,6 +450,36 @@ rk3399_iomux_match(device_t parent, cfda
 	return of_match_compat_data(faa->faa_phandle, compat_data);
 }
 
+#ifdef RK3399_IOMUX_FORCE_ENABLE_SWJ_DP
+/*
+ * This enables the SWJ-DP (Serial Wire JTAG Debug Port).
+ * If you enable this you must also disable sdhc due to pin conflicts.
+ */
+static void
+rk3399_iomux_force_enable_swj_dp(struct rk3399_iomux_softc * const sc)
+{
+	struct syscon * const syscon = sc->sc_syscon[RK_IOMUX_REGS_GRF];
+	uint32_t val;
+
+	aprint_normal_dev(sc->sc_dev, "enabling on-chip debugging\n");
+#define GRF_GPIO4B_IOMUX	0xe024
+#define GRF_GPIO4B_IOMUX_TCK	__BITS(5,4)
+#define GRF_GPIO4B_IOMUX_TMS	__BITS(7,6)
+#define GRF_SOC_CON7		0xe21c
+#define GRF_SOC_CON7_FORCE_JTAG	__BIT(12)
+	LOCK(syscon);
+	val = RD4(syscon, GRF_GPIO4B_IOMUX);
+	val &= ~(GRF_GPIO4B_IOMUX_TCK | GRF_GPIO4B_IOMUX_TMS);
+	val |= __SHIFTIN(0x2, GRF_GPIO4B_IOMUX_TCK);
+	val |= __SHIFTIN(0x2, GRF_GPIO4B_IOMUX_TMS);
+	WR4(syscon, GRF_GPIO4B_IOMUX, val);
+	val = RD4(syscon, GRF_SOC_CON7);
+	val |= GRF_SOC_CON7_FORCE_JTAG;
+	WR4(syscon, GRF_SOC_CON7, val);
+	UNLOCK(syscon);
+}
+#endif
+
 static void
 rk3399_iomux_attach(device_t parent, device_t self, void *aux)
 {
@@ -492,4 +522,8 @@ rk3399_iomux_attach(device_t parent, dev
 
 		config_found(self, &cfaa, NULL);
 	}
+
+#ifdef RK3399_IOMUX_FORCE_ENABLE_SWJ_DP
+	rk3399_iomux_force_enable_swj_dp(sc);
+#endif
 }



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

2019-08-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Aug 20 23:32:33 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_iomux.c

Log Message:
rk3399_iomux: add some #ifdef'd out code to enable the on-chip debug port


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

2019-09-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep  7 19:42:42 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: cpu.c
src/sys/arch/arm/include: cputypes.h vfpreg.h
src/sys/arch/arm/vfp: vfp_init.c

Log Message:
Cortex A12 is marketed as A17 but has a distinct part number

observed on Rockchip RK3288


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/arm/arm32/cpu.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/include/cputypes.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/include/vfpreg.h
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/vfp/vfp_init.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/arm

2019-09-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep  7 19:42:42 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: cpu.c
src/sys/arch/arm/include: cputypes.h vfpreg.h
src/sys/arch/arm/vfp: vfp_init.c

Log Message:
Cortex A12 is marketed as A17 but has a distinct part number

observed on Rockchip RK3288


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/arm/arm32/cpu.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/include/cputypes.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/include/vfpreg.h
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/vfp/vfp_init.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/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.129 src/sys/arch/arm/arm32/cpu.c:1.130
--- src/sys/arch/arm/arm32/cpu.c:1.129	Sun Mar 17 08:37:55 2019
+++ src/sys/arch/arm/arm32/cpu.c	Sat Sep  7 19:42:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.129 2019/03/17 08:37:55 skrll Exp $	*/
+/*	$NetBSD: cpu.c,v 1.130 2019/09/07 19:42:42 tnn Exp $	*/
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.129 2019/03/17 08:37:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2019/09/07 19:42:42 tnn Exp $");
 
 #include 
 #include 
@@ -518,6 +518,8 @@ const struct cpuidtab cpuids[] = {
 	  pN_steppings, "7A" },
 	{ CPU_ID_CORTEXA9R4,	CPU_CLASS_CORTEX,	"Cortex-A9 r4",
 	  pN_steppings, "7A" },
+	{ CPU_ID_CORTEXA12R0,	CPU_CLASS_CORTEX,	"Cortex-A12 r0",
+	  pN_steppings, "7A" },
 	{ CPU_ID_CORTEXA15R2,	CPU_CLASS_CORTEX,	"Cortex-A15 r2",
 	  pN_steppings, "7A" },
 	{ CPU_ID_CORTEXA15R3,	CPU_CLASS_CORTEX,	"Cortex-A15 r3",

Index: src/sys/arch/arm/include/cputypes.h
diff -u src/sys/arch/arm/include/cputypes.h:1.8 src/sys/arch/arm/include/cputypes.h:1.9
--- src/sys/arch/arm/include/cputypes.h:1.8	Tue Jul 16 10:37:12 2019
+++ src/sys/arch/arm/include/cputypes.h	Sat Sep  7 19:42:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cputypes.h,v 1.8 2019/07/16 10:37:12 jmcneill Exp $	*/
+/*	$NetBSD: cputypes.h,v 1.9 2019/09/07 19:42:42 tnn Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Ben Harris
@@ -153,6 +153,7 @@
 #define CPU_ID_CORTEXA9R2	0x412fc090
 #define CPU_ID_CORTEXA9R3	0x413fc090
 #define CPU_ID_CORTEXA9R4	0x414fc090
+#define CPU_ID_CORTEXA12R0	0x410fc0d0
 #define CPU_ID_CORTEXA15R2	0x412fc0f0
 #define CPU_ID_CORTEXA15R3	0x413fc0f0
 #define CPU_ID_CORTEXA15R4	0x414fc0f0

Index: src/sys/arch/arm/include/vfpreg.h
diff -u src/sys/arch/arm/include/vfpreg.h:1.16 src/sys/arch/arm/include/vfpreg.h:1.17
--- src/sys/arch/arm/include/vfpreg.h:1.16	Fri May 26 21:17:46 2017
+++ src/sys/arch/arm/include/vfpreg.h	Sat Sep  7 19:42:42 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: vfpreg.h,v 1.16 2017/05/26 21:17:46 jmcneill Exp $ */
+/*  $NetBSD: vfpreg.h,v 1.17 2019/09/07 19:42:42 tnn Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -63,8 +63,10 @@
 #define FPU_VFP_CORTEXA7	0x41023070
 #define FPU_VFP_CORTEXA8	0x410330c0
 #define FPU_VFP_CORTEXA9	0x41033090
+#define FPU_VFP_CORTEXA12	0x410330d0
 #define FPU_VFP_CORTEXA15	0x410330f0
 #define FPU_VFP_CORTEXA15_QEMU	0x410430f0
+#define FPU_VFP_CORTEXA17	0x410330e0
 #define FPU_VFP_CORTEXA53	0x41034030
 #define FPU_VFP_CORTEXA57	0x41034070
 #define FPU_VFP_MV88SV58XX	0x56022090

Index: src/sys/arch/arm/vfp/vfp_init.c
diff -u src/sys/arch/arm/vfp/vfp_init.c:1.62 src/sys/arch/arm/vfp/vfp_init.c:1.63
--- src/sys/arch/arm/vfp/vfp_init.c:1.62	Sat Apr  6 08:48:53 2019
+++ src/sys/arch/arm/vfp/vfp_init.c	Sat Sep  7 19:42:42 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: vfp_init.c,v 1.62 2019/04/06 08:48:53 skrll Exp $ */
+/*  $NetBSD: vfp_init.c,v 1.63 2019/09/07 19:42:42 tnn Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -32,7 +32,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.62 2019/04/06 08:48:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.63 2019/09/07 19:42:42 tnn Exp $");
 
 #include 
 #include 
@@ -332,8 +332,10 @@ vfp_attach(struct cpu_info *ci)
 	case FPU_VFP_CORTEXA7:
 	case FPU_VFP_CORTEXA8:
 	case FPU_VFP_CORTEXA9:
+	case FPU_VFP_CORTEXA12:
 	case FPU_VFP_CORTEXA15:
 	case FPU_VFP_CORTEXA15_QEMU:
+	case FPU_VFP_CORTEXA17:
 	case FPU_VFP_CORTEXA53:
 	case FPU_VFP_CORTEXA57:
 		if (armreg_cpacr_read() & CPACR_V7_ASEDIS) {



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

2019-09-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  8 07:59:44 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: cpu.c

Log Message:
report A12 as A17 to the user. A12 is retcon'ed by ARM.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/arm/arm32/cpu.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/arm/arm32

2019-09-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  8 07:59:44 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: cpu.c

Log Message:
report A12 as A17 to the user. A12 is retcon'ed by ARM.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/arm/arm32/cpu.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/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.130 src/sys/arch/arm/arm32/cpu.c:1.131
--- src/sys/arch/arm/arm32/cpu.c:1.130	Sat Sep  7 19:42:42 2019
+++ src/sys/arch/arm/arm32/cpu.c	Sun Sep  8 07:59:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130 2019/09/07 19:42:42 tnn Exp $	*/
+/*	$NetBSD: cpu.c,v 1.131 2019/09/08 07:59:43 tnn Exp $	*/
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2019/09/07 19:42:42 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.131 2019/09/08 07:59:43 tnn Exp $");
 
 #include 
 #include 
@@ -518,7 +518,7 @@ const struct cpuidtab cpuids[] = {
 	  pN_steppings, "7A" },
 	{ CPU_ID_CORTEXA9R4,	CPU_CLASS_CORTEX,	"Cortex-A9 r4",
 	  pN_steppings, "7A" },
-	{ CPU_ID_CORTEXA12R0,	CPU_CLASS_CORTEX,	"Cortex-A12 r0",
+	{ CPU_ID_CORTEXA12R0,	CPU_CLASS_CORTEX,	"Cortex-A17(A12) r0",	/* A12 was rebranded A17 */
 	  pN_steppings, "7A" },
 	{ CPU_ID_CORTEXA15R2,	CPU_CLASS_CORTEX,	"Cortex-A15 r2",
 	  pN_steppings, "7A" },



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

2019-09-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  8 08:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/include: cputypes.h

Log Message:
cpu identification macros for A17


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/cputypes.h

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



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

2019-09-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  8 08:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/include: cputypes.h

Log Message:
cpu identification macros for A17


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/cputypes.h

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

Modified files:

Index: src/sys/arch/arm/include/cputypes.h
diff -u src/sys/arch/arm/include/cputypes.h:1.9 src/sys/arch/arm/include/cputypes.h:1.10
--- src/sys/arch/arm/include/cputypes.h:1.9	Sat Sep  7 19:42:42 2019
+++ src/sys/arch/arm/include/cputypes.h	Sun Sep  8 08:10:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cputypes.h,v 1.9 2019/09/07 19:42:42 tnn Exp $	*/
+/*	$NetBSD: cputypes.h,v 1.10 2019/09/08 08:10:13 tnn Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Ben Harris
@@ -180,7 +180,9 @@
 #define CPU_ID_CORTEX_A7_P(n)	((n & 0xff0ff0f0) == 0x410fc070)
 #define CPU_ID_CORTEX_A8_P(n)	((n & 0xff0ff0f0) == 0x410fc080)
 #define CPU_ID_CORTEX_A9_P(n)	((n & 0xff0ff0f0) == 0x410fc090)
+#define CPU_ID_CORTEX_A12_P(n)	((n & 0xff0ff0f0) == 0x410fc0d0)
 #define CPU_ID_CORTEX_A15_P(n)	((n & 0xff0ff0f0) == 0x410fc0f0)
+#define CPU_ID_CORTEX_A17_P(n)	((n & 0xff0ff0f0) == 0x410fc0e0)
 #define CPU_ID_CORTEX_A32_P(n)	((n & 0xff0ff0f0) == 0x410fd010)
 #define CPU_ID_CORTEX_A35_P(n)	((n & 0xff0ff0f0) == 0x410fd040)
 #define CPU_ID_CORTEX_A53_P(n)	((n & 0xff0ff0f0) == 0x410fd030)



CVS commit: src/sys/external/bsd/gnu-efi/dist/inc

2019-09-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Sep 13 20:56:29 UTC 2019

Modified Files:
src/sys/external/bsd/gnu-efi/dist/inc: efidef.h
src/sys/external/bsd/gnu-efi/dist/inc/ia32: efibind.h
src/sys/external/bsd/gnu-efi/dist/inc/x86_64: efibind.h

Log Message:
resolve typedef conflicts between efi and acpica headers

needed for exec_multiboot2.c which includes headers from both projects


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/gnu-efi/dist/inc/efidef.h
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.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/external/bsd/gnu-efi/dist/inc/efidef.h
diff -u src/sys/external/bsd/gnu-efi/dist/inc/efidef.h:1.3 src/sys/external/bsd/gnu-efi/dist/inc/efidef.h:1.4
--- src/sys/external/bsd/gnu-efi/dist/inc/efidef.h:1.3	Thu Aug 16 18:22:05 2018
+++ src/sys/external/bsd/gnu-efi/dist/inc/efidef.h	Fri Sep 13 20:56:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidef.h,v 1.3 2018/08/16 18:22:05 jmcneill Exp $	*/
+/*	$NetBSD: efidef.h,v 1.4 2019/09/13 20:56:29 tnn Exp $	*/
 
 #ifndef _EFI_DEF_H
 #define _EFI_DEF_H
@@ -24,7 +24,9 @@ Revision History
 
 typedef UINT16  CHAR16;
 typedef UINT8   CHAR8;
+#ifndef __ACTYPES_H__
 typedef UINT8   BOOLEAN;
+#endif /* __ACTYPES_H__ */
 #ifndef CONST
#define CONST const
 #endif

Index: src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h
diff -u src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h:1.3 src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h:1.4
--- src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h:1.3	Thu Aug 16 18:22:05 2018
+++ src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h	Fri Sep 13 20:56:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibind.h,v 1.3 2018/08/16 18:22:05 jmcneill Exp $	*/
+/*	$NetBSD: efibind.h,v 1.4 2019/09/13 20:56:29 tnn Exp $	*/
 
 /*++
 
@@ -91,6 +91,7 @@ Revision History
 # define __WCHAR_TYPE__ short
 #endif
 
+#ifndef __ACTYPES_H__
 typedef uint64_t   UINT64;
 typedef int64_tINT64;
 
@@ -103,6 +104,7 @@ typedef uint16_t   UINT16;
 typedef int16_tINT16;
 typedef uint8_tUINT8;
 typedef int8_t INT8;
+#endif /* __ACTYPES_H__ */
 typedef __WCHAR_TYPE__ WCHAR;
 
 #undef VOID

Index: src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h
diff -u src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h:1.3 src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h:1.4
--- src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h:1.3	Thu Aug 16 18:22:05 2018
+++ src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h	Fri Sep 13 20:56:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibind.h,v 1.3 2018/08/16 18:22:05 jmcneill Exp $	*/
+/*	$NetBSD: efibind.h,v 1.4 2019/09/13 20:56:29 tnn Exp $	*/
 
 /*++
 
@@ -100,6 +100,7 @@ Revision History
 # define __WCHAR_TYPE__ short
 #endif
 
+#ifndef __ACTYPES_H__
 typedef uint64_t   UINT64;
 typedef int64_tINT64;
 
@@ -112,6 +113,7 @@ typedef uint16_t   UINT16;
 typedef int16_tINT16;
 typedef uint8_tUINT8;
 typedef int8_t INT8;
+#endif /* __ACTYPES_H__ */
 typedef __WCHAR_TYPE__ WCHAR;
 
 #undef VOID



CVS commit: src/sys/external/bsd/gnu-efi/dist/inc

2019-09-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Sep 13 20:56:29 UTC 2019

Modified Files:
src/sys/external/bsd/gnu-efi/dist/inc: efidef.h
src/sys/external/bsd/gnu-efi/dist/inc/ia32: efibind.h
src/sys/external/bsd/gnu-efi/dist/inc/x86_64: efibind.h

Log Message:
resolve typedef conflicts between efi and acpica headers

needed for exec_multiboot2.c which includes headers from both projects


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/gnu-efi/dist/inc/efidef.h
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h

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



CVS commit: src/share/man/man4

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 11:19:38 UTC 2019

Modified Files:
src/share/man/man4: ugen.4

Log Message:
add SYNOPSIS for how to make ugen capture specific vendor & product


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/share/man/man4/ugen.4

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

Modified files:

Index: src/share/man/man4/ugen.4
diff -u src/share/man/man4/ugen.4:1.36 src/share/man/man4/ugen.4:1.37
--- src/share/man/man4/ugen.4:1.36	Mon Mar  5 10:23:44 2018
+++ src/share/man/man4/ugen.4	Sat Sep 14 11:19:38 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: ugen.4,v 1.36 2018/03/05 10:23:44 wiz Exp $
+.\" $NetBSD: ugen.4,v 1.37 2019/09/14 11:19:38 tnn Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 5, 2018
+.Dd September 14, 2019
 .Dt UGEN 4
 .Os
 .Sh NAME
@@ -35,6 +35,7 @@
 .Nd USB generic device support
 .Sh SYNOPSIS
 .Cd "ugen* at uhub? flags N"
+.Cd "ugen* at uhub? vendor V product P flags 1"
 .Cd "ugenif* at uhub? vendor V product P configuration C interface I"
 .Sh DESCRIPTION
 The



CVS commit: src/share/man/man4

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 11:19:38 UTC 2019

Modified Files:
src/share/man/man4: ugen.4

Log Message:
add SYNOPSIS for how to make ugen capture specific vendor & product


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/share/man/man4/ugen.4

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



CVS commit: src/sys/dev/spi

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 14:41:23 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c spiflash.c

Log Message:
KB -> kB


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/spi/m25p.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/spi/spiflash.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.12 src/sys/dev/spi/m25p.c:1.13
--- src/sys/dev/spi/m25p.c:1.12	Thu Sep  5 16:17:48 2019
+++ src/sys/dev/spi/m25p.c	Sat Sep 14 14:41:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.12 2019/09/05 16:17:48 bouyer Exp $ */
+/* $NetBSD: m25p.c,v 1.13 2019/09/14 14:41:23 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.12 2019/09/05 16:17:48 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.13 2019/09/14 14:41:23 tnn Exp $");
 
 #include 
 #include 
@@ -88,8 +88,8 @@ static const struct m25p_info {
 	uint8_t		mfgid;
 	uint16_t	devid;
 	const char	*name;
-	uint16_t	size;	/* in KB */
-	uint16_t	sector;	/* in KB */
+	uint16_t	size;	/* in kB */
+	uint16_t	sector;	/* in kB */
 	uint16_t	mhz;
 } m25p_infos[] = {
 	{ 0x16, 0x20, 0x2017, "STMicro M25P64", 8192, 64 },	/* 64Mbit */

Index: src/sys/dev/spi/spiflash.c
diff -u src/sys/dev/spi/spiflash.c:1.21 src/sys/dev/spi/spiflash.c:1.22
--- src/sys/dev/spi/spiflash.c:1.21	Mon Sep  3 16:29:33 2018
+++ src/sys/dev/spi/spiflash.c	Sat Sep 14 14:41:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: spiflash.c,v 1.21 2018/09/03 16:29:33 riastradh Exp $ */
+/* $NetBSD: spiflash.c,v 1.22 2019/09/14 14:41:23 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.21 2018/09/03 16:29:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.22 2019/09/14 14:41:23 tnn Exp $");
 
 #include 
 #include 
@@ -224,7 +224,7 @@ spiflash_attach(device_t parent, device_
 	aprint_naive(": SPI flash\n");
 	aprint_normal(": %s SPI flash\n", sc->sc_name);
 	/* XXX: note that this has to change for boot-sectored flash */
-	aprint_normal_dev(self, "%d KB, %d sectors of %d KB each\n",
+	aprint_normal_dev(self, "%d kB, %d sectors of %d kB each\n",
 	sc->sc_device_size / 1024,
 	sc->sc_device_size / sc->sc_erase_size,
 	sc->sc_erase_size / 1024);



CVS commit: src/sys/dev/spi

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 14:41:23 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c spiflash.c

Log Message:
KB -> kB


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/spi/m25p.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/spi/spiflash.c

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



CVS commit: src/sys/dev/spi

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 15:12:12 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c spiflash.c

Log Message:
On second thought revert that. Let's open this can of worms some other day.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/spi/m25p.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/spi/spiflash.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/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.13 src/sys/dev/spi/m25p.c:1.14
--- src/sys/dev/spi/m25p.c:1.13	Sat Sep 14 14:41:23 2019
+++ src/sys/dev/spi/m25p.c	Sat Sep 14 15:12:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.13 2019/09/14 14:41:23 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.14 2019/09/14 15:12:12 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.13 2019/09/14 14:41:23 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.14 2019/09/14 15:12:12 tnn Exp $");
 
 #include 
 #include 
@@ -88,8 +88,8 @@ static const struct m25p_info {
 	uint8_t		mfgid;
 	uint16_t	devid;
 	const char	*name;
-	uint16_t	size;	/* in kB */
-	uint16_t	sector;	/* in kB */
+	uint16_t	size;	/* in KB */
+	uint16_t	sector;	/* in KB */
 	uint16_t	mhz;
 } m25p_infos[] = {
 	{ 0x16, 0x20, 0x2017, "STMicro M25P64", 8192, 64 },	/* 64Mbit */

Index: src/sys/dev/spi/spiflash.c
diff -u src/sys/dev/spi/spiflash.c:1.22 src/sys/dev/spi/spiflash.c:1.23
--- src/sys/dev/spi/spiflash.c:1.22	Sat Sep 14 14:41:23 2019
+++ src/sys/dev/spi/spiflash.c	Sat Sep 14 15:12:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: spiflash.c,v 1.22 2019/09/14 14:41:23 tnn Exp $ */
+/* $NetBSD: spiflash.c,v 1.23 2019/09/14 15:12:12 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.22 2019/09/14 14:41:23 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.23 2019/09/14 15:12:12 tnn Exp $");
 
 #include 
 #include 
@@ -224,7 +224,7 @@ spiflash_attach(device_t parent, device_
 	aprint_naive(": SPI flash\n");
 	aprint_normal(": %s SPI flash\n", sc->sc_name);
 	/* XXX: note that this has to change for boot-sectored flash */
-	aprint_normal_dev(self, "%d kB, %d sectors of %d kB each\n",
+	aprint_normal_dev(self, "%d KB, %d sectors of %d KB each\n",
 	sc->sc_device_size / 1024,
 	sc->sc_device_size / sc->sc_erase_size,
 	sc->sc_erase_size / 1024);



CVS commit: src/sys/dev/spi

2019-09-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 14 15:12:12 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c spiflash.c

Log Message:
On second thought revert that. Let's open this can of worms some other day.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/spi/m25p.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/spi/spiflash.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

2019-09-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep 15 15:16:30 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c
src/sys/arch/aarch64/include: armreg.h

Log Message:
report A72 errata #859971 workaround status during boot


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/aarch64/include/armreg.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.20 src/sys/arch/aarch64/aarch64/cpu.c:1.21
--- src/sys/arch/aarch64/aarch64/cpu.c:1.20	Tue Jul 16 20:29:53 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Sep 15 15:16:30 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.20 2019/07/16 20:29:53 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.21 2019/09/15 15:16:30 tnn Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.20 2019/07/16 20:29:53 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.21 2019/09/15 15:16:30 tnn Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -432,6 +432,14 @@ cpu_identify2(device_t self, struct cpu_
 	}
 
 	aprint_normal("\n");
+
+	if ((id->ac_midr & CPU_PARTMASK) == (CPU_ID_CORTEXA72R0 & CPU_PARTMASK)
+	&& __SHIFTOUT(id->ac_midr, CPU_ID_REVISION_MASK) <= 3) {
+		aprint_normal_dev(self, "A72 errata #859971 present"
+		", workaround %s\n",
+		ISSET(reg_a72_cpuactlr_el1_read(), __BIT(32))
+		? "enabled" : "NOT enabled (U-Boot update needed)");
+	}
 }
 
 /*

Index: src/sys/arch/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.27 src/sys/arch/aarch64/include/armreg.h:1.28
--- src/sys/arch/aarch64/include/armreg.h:1.27	Wed Sep 11 18:19:35 2019
+++ src/sys/arch/aarch64/include/armreg.h	Sun Sep 15 15:16:30 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.27 2019/09/11 18:19:35 skrll Exp $ */
+/* $NetBSD: armreg.h,v 1.28 2019/09/15 15:16:30 tnn Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -260,6 +260,7 @@ AARCH64REG_READ_INLINE(id_aa64mmfr0_el1)
 #define	 ID_AA64MMFR0_EL1_PARANGE_16T	 4
 #define	 ID_AA64MMFR0_EL1_PARANGE_256T	 5
 
+AARCH64REG_READ_INLINE2(a72_cpuactlr_el1, s3_1_c15_c2_0)
 AARCH64REG_READ_INLINE(id_aa64mmfr1_el1)
 AARCH64REG_READ_INLINE(id_aa64mmfr2_el1)
 AARCH64REG_READ_INLINE(id_aa64pfr0_el1)



CVS commit: src/sys/arch/aarch64

2019-09-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep 15 15:16:30 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c
src/sys/arch/aarch64/include: armreg.h

Log Message:
report A72 errata #859971 workaround status during boot


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/aarch64/include/armreg.h

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



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

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 12:49:35 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk_i2c.c

Log Message:
rkiic: coalesce smbus-style writes into a single transaction

There seems to be a hw controller bug. Split cmd/data writes caused corrupt
transfers, with junk bytes witten into the rk808 pmic registers.
This may have caused us to operate with out-of-spec core voltage.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk_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/arch/arm/rockchip/rk_i2c.c
diff -u src/sys/arch/arm/rockchip/rk_i2c.c:1.4 src/sys/arch/arm/rockchip/rk_i2c.c:1.5
--- src/sys/arch/arm/rockchip/rk_i2c.c:1.4	Sun Sep  2 10:07:17 2018
+++ src/sys/arch/arm/rockchip/rk_i2c.c	Wed Sep 18 12:49:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_i2c.c,v 1.4 2018/09/02 10:07:17 jmcneill Exp $ */
+/* $NetBSD: rk_i2c.c,v 1.5 2019/09/18 12:49:34 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.4 2018/09/02 10:07:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.5 2019/09/18 12:49:34 tnn Exp $");
 
 #include 
 #include 
@@ -244,8 +244,8 @@ rk_i2c_stop(struct rk_i2c_softc *sc)
 }
 
 static int
-rk_i2c_write(struct rk_i2c_softc *sc, i2c_addr_t addr, const uint8_t *buf,
-size_t buflen, int flags, bool send_start)
+rk_i2c_write(struct rk_i2c_softc *sc, i2c_addr_t addr, const uint8_t *cmd,
+size_t cmdlen, const uint8_t *buf, size_t buflen, int flags, bool send_start)
 {
 	union {
 		uint8_t data8[32];
@@ -254,8 +254,10 @@ rk_i2c_write(struct rk_i2c_softc *sc, i2
 	uint32_t con;
 	u_int mode;
 	int error;
+	size_t len;
 
-	if (buflen > 31)
+	len = cmdlen + buflen;
+	if (len > 31)
 		return EINVAL;
 
 	mode = RKI2C_CON_I2C_MODE_TX;
@@ -267,10 +269,11 @@ rk_i2c_write(struct rk_i2c_softc *sc, i2
 
 	/* Transmit data. Slave address goes in the lower 8 bits of TXDATA0 */
 	txdata.data8[0] = addr << 1;
-	memcpy(&txdata.data8[1], buf, buflen);
+	memcpy(&txdata.data8[1], cmd, cmdlen);
+	memcpy(&txdata.data8[1 + cmdlen], buf, buflen);
 	bus_space_write_region_4(sc->sc_bst, sc->sc_bsh, RKI2C_TXDATA(0),
-	txdata.data32, howmany(buflen + 1, 4));
-	WR4(sc, RKI2C_MTXCNT, __SHIFTIN(buflen + 1, RKI2C_MTXCNT_MTXCNT));
+	txdata.data32, howmany(len + 1, 4));
+	WR4(sc, RKI2C_MTXCNT, __SHIFTIN(len + 1, RKI2C_MTXCNT_MTXCNT));
 
 	if ((error = rk_i2c_wait(sc, RKI2C_IPD_MBTFIPD)) != 0)
 		return error;
@@ -338,16 +341,9 @@ rk_i2c_exec(void *priv, i2c_op_t op, i2c
 	if (I2C_OP_READ_P(op)) {
 		error = rk_i2c_read(sc, addr, cmdbuf, cmdlen, buf, buflen, flags, send_start);
 	} else {
-		if (cmdlen > 0) {
-			error = rk_i2c_write(sc, addr, cmdbuf, cmdlen, flags, send_start);
-			if (error != 0)
-goto done;
-			send_start = false;
-		}
-		error = rk_i2c_write(sc, addr, buf, buflen, flags, send_start);
+		error = rk_i2c_write(sc, addr, cmdbuf, cmdlen, buf, buflen, flags, send_start);
 	}
 
-done:
 	if (error != 0 || I2C_OP_STOP_P(op))
 		rk_i2c_stop(sc);
 



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

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 12:49:35 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk_i2c.c

Log Message:
rkiic: coalesce smbus-style writes into a single transaction

There seems to be a hw controller bug. Split cmd/data writes caused corrupt
transfers, with junk bytes witten into the rk808 pmic registers.
This may have caused us to operate with out-of-spec core voltage.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk_i2c.c

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



CVS commit: src/sys/dev/i2c

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 14:07:38 UTC 2019

Modified Files:
src/sys/dev/i2c: rkpmic.c

Log Message:
rkpmic: add RTC support; register w/ todr(9)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/rkpmic.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/rkpmic.c
diff -u src/sys/dev/i2c/rkpmic.c:1.3 src/sys/dev/i2c/rkpmic.c:1.4
--- src/sys/dev/i2c/rkpmic.c:1.3	Wed Jul  3 10:21:41 2019
+++ src/sys/dev/i2c/rkpmic.c	Wed Sep 18 14:07:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rkpmic.c,v 1.3 2019/07/03 10:21:41 jmcneill Exp $ */
+/* $NetBSD: rkpmic.c,v 1.4 2019/09/18 14:07:38 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.3 2019/07/03 10:21:41 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.4 2019/09/18 14:07:38 tnn Exp $");
 
 #include 
 #include 
@@ -37,10 +37,33 @@ __KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
 
+#define	SECONDS_REG		0x00
+#define	MINUTES_REG		0x01
+#define	HOURS_REG		0x02
+#define	DAYS_REG		0x03
+#define	MONTHS_REG		0x04
+#define	YEARS_REG		0x05
+#define	WEEKS_REG		0x06
+
+#define	RTC_CTRL_REG		0x10
+#define	RTC_CTRL_READSEL	__BIT(7)
+#define	RTC_CTRL_GET_TIME	__BIT(6)
+#define	RTC_CTRL_SET_32_COUNTER	__BIT(5)
+#define	RTC_CTRL_TEST_MODE	__BIT(4)
+#define	RTC_CTRL_AMPM_MODE	__BIT(3)
+#define	RTC_CTRL_AUTO_COMP	__BIT(2)
+#define	RTC_CTRL_ROUND_30S	__BIT(1)
+#define	RTC_CTRL_STOP_RTC	__BIT(0)
+
+#define	RTC_INT_REG		0x12
+#define	RTC_COMP_LSB_REG	0x13
+#define	RTC_COMP_MSB_REG	0x14
 #define	CHIP_NAME_REG		0x17
 #define	CHIP_VER_REG		0x18
 
@@ -169,7 +192,7 @@ struct rkpmic_softc {
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
 	int		sc_phandle;
-
+	struct todr_chip_handle sc_todr;
 	struct rkpmic_config *sc_conf;
 };
 
@@ -198,7 +221,7 @@ rkpmic_read(struct rkpmic_softc *sc, uin
 
 	error = iic_smbus_read_byte(sc->sc_i2c, sc->sc_addr, reg, &val, flags);
 	if (error != 0)
-		aprint_error_dev(sc->sc_dev, "error reading reg %#x: %d\n", reg, error);
+		device_printf(sc->sc_dev, "error reading reg %#x: %d\n", reg, error);
 
 	return val;
 }
@@ -210,7 +233,7 @@ rkpmic_write(struct rkpmic_softc *sc, ui
 
 	error = iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr, reg, val, flags);
 	if (error != 0)
-		aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
+		device_printf(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
 }
 
 #define	I2C_READ(sc, reg)	rkpmic_read((sc), (reg), I2C_F_POLL)
@@ -219,6 +242,82 @@ rkpmic_write(struct rkpmic_softc *sc, ui
 #define	I2C_UNLOCK(sc)		iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
 
 static int
+rkpmic_todr_settime(todr_chip_handle_t ch, struct clock_ymdhms *dt)
+{
+	struct rkpmic_softc * const sc = ch->cookie;
+	uint8_t val;
+
+	if (dt->dt_year < 2000 || dt->dt_year >= 2100) {
+		device_printf(sc->sc_dev, "year out of range\n");
+		return EINVAL;
+	}
+
+	if (I2C_LOCK(sc))
+		return EBUSY;
+
+	val = I2C_READ(sc, RTC_CTRL_REG);
+	I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_STOP_RTC);
+	I2C_WRITE(sc, SECONDS_REG, bintobcd(dt->dt_sec));
+	I2C_WRITE(sc, MINUTES_REG, bintobcd(dt->dt_min));
+	I2C_WRITE(sc, HOURS_REG, bintobcd(dt->dt_hour));
+	I2C_WRITE(sc, DAYS_REG, bintobcd(dt->dt_day));
+	I2C_WRITE(sc, MONTHS_REG, bintobcd(dt->dt_mon));
+	I2C_WRITE(sc, YEARS_REG, bintobcd(dt->dt_year % 100));
+	I2C_WRITE(sc, WEEKS_REG, bintobcd(dt->dt_wday == 0 ? 7 : dt->dt_wday));
+	I2C_WRITE(sc, RTC_CTRL_REG, val);
+	I2C_UNLOCK(sc);
+
+	return 0;
+}
+
+static int
+rkpmic_todr_gettime(todr_chip_handle_t ch, struct clock_ymdhms *dt)
+{
+	struct rkpmic_softc * const sc = ch->cookie;
+	uint8_t val;
+
+	if (I2C_LOCK(sc))
+		return EBUSY;
+
+	val = I2C_READ(sc, RTC_CTRL_REG);
+	I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_GET_TIME | RTC_CTRL_READSEL);
+	delay(1); /* need to wait 1/32768 seconds for shadow regs to latch */
+	I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_READSEL);
+	dt->dt_sec = bcdtobin(I2C_READ(sc, SECONDS_REG));
+	dt->dt_min = bcdtobin(I2C_READ(sc, MINUTES_REG));
+	dt->dt_hour = bcdtobin(I2C_READ(sc, HOURS_REG));
+	dt->dt_day = bcdtobin(I2C_READ(sc, DAYS_REG));
+	dt->dt_mon = bcdtobin(I2C_READ(sc, MONTHS_REG));
+	dt->dt_year = 2000 + bcdtobin(I2C_READ(sc, YEARS_REG));
+	dt->dt_wday = bcdtobin(I2C_READ(sc, WEEKS_REG));
+	if (dt->dt_wday == 7)
+		dt->dt_wday = 0;
+	I2C_WRITE(sc, RTC_CTRL_REG, val);
+	I2C_UNLOCK(sc);
+
+	/*
+	 * RK808 has a hw bug which makes the 31st of November a valid day.
+	 * If we detect the 31st of November we skip ahead one day.
+	 * If the system has been turned off during the crossover the clock
+	 * will have lost a day. No easy way to detect this. Oh well.
+	 */
+	if (dt->dt_mon == 11 && dt->dt_day == 31) {
+		dt->dt_day--;
+		clock_secs_to_ymdhms(clock_ymdhms_to_secs(dt) + 86400, dt);
+		rkpmic_todr_settime(ch,

CVS commit: src/sys/dev/i2c

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 14:07:38 UTC 2019

Modified Files:
src/sys/dev/i2c: rkpmic.c

Log Message:
rkpmic: add RTC support; register w/ todr(9)


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

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



CVS commit: src/sys/dev/i2c

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 15:12:37 UTC 2019

Modified Files:
src/sys/dev/i2c: rkpmic.c

Log Message:
rkpmic: correct delay


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

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



CVS commit: src/sys/dev/i2c

2019-09-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Sep 18 15:12:37 UTC 2019

Modified Files:
src/sys/dev/i2c: rkpmic.c

Log Message:
rkpmic: correct delay


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/rkpmic.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/rkpmic.c
diff -u src/sys/dev/i2c/rkpmic.c:1.4 src/sys/dev/i2c/rkpmic.c:1.5
--- src/sys/dev/i2c/rkpmic.c:1.4	Wed Sep 18 14:07:38 2019
+++ src/sys/dev/i2c/rkpmic.c	Wed Sep 18 15:12:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rkpmic.c,v 1.4 2019/09/18 14:07:38 tnn Exp $ */
+/* $NetBSD: rkpmic.c,v 1.5 2019/09/18 15:12:37 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.4 2019/09/18 14:07:38 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.5 2019/09/18 15:12:37 tnn Exp $");
 
 #include 
 #include 
@@ -281,7 +281,7 @@ rkpmic_todr_gettime(todr_chip_handle_t c
 
 	val = I2C_READ(sc, RTC_CTRL_REG);
 	I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_GET_TIME | RTC_CTRL_READSEL);
-	delay(1); /* need to wait 1/32768 seconds for shadow regs to latch */
+	delay(100 / 32768); /* wait one cycle for shadow regs to latch */
 	I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_READSEL);
 	dt->dt_sec = bcdtobin(I2C_READ(sc, SECONDS_REG));
 	dt->dt_min = bcdtobin(I2C_READ(sc, MINUTES_REG));



CVS commit: src/lib/libedit

2022-04-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Apr 11 19:37:20 UTC 2022

Modified Files:
src/lib/libedit: chartype.h

Log Message:
libedit/chartype.h: portability fix for OSF/1


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/chartype.h

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

Modified files:

Index: src/lib/libedit/chartype.h
diff -u src/lib/libedit/chartype.h:1.36 src/lib/libedit/chartype.h:1.37
--- src/lib/libedit/chartype.h:1.36	Sun Sep 15 21:09:11 2019
+++ src/lib/libedit/chartype.h	Mon Apr 11 19:37:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: chartype.h,v 1.36 2019/09/15 21:09:11 christos Exp $	*/
+/*	$NetBSD: chartype.h,v 1.37 2022/04/11 19:37:20 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -35,6 +35,7 @@
  * been around since 2001... */
 #if	!defined(__NetBSD__) && \
 	!defined(__sun) && \
+	!defined(__osf__) && \
 	!(defined(__APPLE__) && defined(__MACH__)) && \
 	!defined(__OpenBSD__) && \
 	!defined(__FreeBSD__) && \



CVS commit: src/lib/libedit

2022-04-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Apr 11 19:37:20 UTC 2022

Modified Files:
src/lib/libedit: chartype.h

Log Message:
libedit/chartype.h: portability fix for OSF/1


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libedit/chartype.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/nvmm/x86

2022-05-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri May 13 19:34:47 UTC 2022

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
nvmm_x86_vmx.c: remove an #ifdef DIAGNOSTIC, it is wrong since r1.66


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.82 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.83
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.82	Fri Mar 26 15:59:53 2021
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Fri May 13 19:34:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.82 2021/03/26 15:59:53 reinoud Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.83 2022/05/13 19:34:47 tnn Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.82 2021/03/26 15:59:53 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.83 2022/05/13 19:34:47 tnn Exp $");
 
 #include 
 #include 
@@ -134,7 +134,6 @@ vmx_vmwrite(uint64_t field, uint64_t val
 	);
 }
 
-#ifdef DIAGNOSTIC
 static inline paddr_t
 vmx_vmptrst(void)
 {
@@ -149,7 +148,6 @@ vmx_vmptrst(void)
 
 	return pa;
 }
-#endif
 
 static inline void
 vmx_vmptrld(paddr_t *pa)



CVS commit: src/sys/dev/nvmm/x86

2022-05-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri May 13 19:34:47 UTC 2022

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
nvmm_x86_vmx.c: remove an #ifdef DIAGNOSTIC, it is wrong since r1.66


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: src/sys/external/bsd/drm2/dist/include/drm

2022-05-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat May 21 23:42:13 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drm_cache.h

Log Message:
drm_cache.h: fix a merge error

this reverts revision 1.3 which should have been reverted when it got
introduced by upstream through revision 1.5.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/include/drm/drm_cache.h

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



CVS commit: src/sys/external/bsd/drm2/dist/include/drm

2022-05-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat May 21 23:42:13 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drm_cache.h

Log Message:
drm_cache.h: fix a merge error

this reverts revision 1.3 which should have been reverted when it got
introduced by upstream through revision 1.5.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/include/drm/drm_cache.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/external/bsd/drm2/dist/include/drm/drm_cache.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_cache.h:1.10 src/sys/external/bsd/drm2/dist/include/drm/drm_cache.h:1.11
--- src/sys/external/bsd/drm2/dist/include/drm/drm_cache.h:1.10	Sun Dec 19 11:33:30 2021
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_cache.h	Sat May 21 23:42:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_cache.h,v 1.10 2021/12/19 11:33:30 riastradh Exp $	*/
+/*	$NetBSD: drm_cache.h,v 1.11 2022/05/21 23:42:13 tnn Exp $	*/
 
 /**
  *
@@ -69,8 +69,6 @@ static inline bool drm_arch_can_wc_memor
 	 * optimization entirely for ARM and arm64.
 	 */
 	return false;
-#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
-	return false;
 #else
 	return true;
 #endif



CVS commit: src/sys/external/bsd/drm2/drm

2022-05-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun May 22 00:10:56 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/drm: files.drmkms

Log Message:
rename CONFIG_AARCH64 to CONFIG_ARM64 which is what upstream code expects


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/external/bsd/drm2/drm/files.drmkms

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



CVS commit: src/sys/external/bsd/drm2/drm

2022-05-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun May 22 00:10:56 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/drm: files.drmkms

Log Message:
rename CONFIG_AARCH64 to CONFIG_ARM64 which is what upstream code expects


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/external/bsd/drm2/drm/files.drmkms

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

Modified files:

Index: src/sys/external/bsd/drm2/drm/files.drmkms
diff -u src/sys/external/bsd/drm2/drm/files.drmkms:1.72 src/sys/external/bsd/drm2/drm/files.drmkms:1.73
--- src/sys/external/bsd/drm2/drm/files.drmkms:1.72	Tue Dec 21 12:55:23 2021
+++ src/sys/external/bsd/drm2/drm/files.drmkms	Sun May 22 00:10:56 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.drmkms,v 1.72 2021/12/21 12:55:23 tnn Exp $
+#	$NetBSD: files.drmkms,v 1.73 2022/05/22 00:10:56 tnn Exp $
 
 version	20180827
 
@@ -39,7 +39,7 @@ makeoptions	drmkms	CPPFLAGS+="-DCONFIG_X
 elifdef arm
 makeoptions	drmkms	CPPFLAGS+="-DCONFIG_ARM"
 elifdef aarch64
-makeoptions	drmkms	CPPFLAGS+="-DCONFIG_AARCH64"
+makeoptions	drmkms	CPPFLAGS+="-DCONFIG_ARM64"
 endif
 
 makeoptions	drmkms	CPPFLAGS+="-DCONFIG_BACKLIGHT_CLASS_DEVICE=0"



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 11:44:18 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_drv.c

Log Message:
i915_drm_resume_early: initialize ret

clang -Wsometimes-uninitialized says uninitialized use
on line 2043 when if statement on line 2037 is false


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.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/external/bsd/drm2/dist/drm/i915/i915_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.46 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.47
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.46	Sun Dec 19 12:40:43 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c	Tue Dec 21 11:44:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_drv.c,v 1.46 2021/12/19 12:40:43 riastradh Exp $	*/
+/*	$NetBSD: i915_drv.c,v 1.47 2021/12/21 11:44:18 tnn Exp $	*/
 
 /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
  */
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_drv.c,v 1.46 2021/12/19 12:40:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_drv.c,v 1.47 2021/12/21 11:44:18 tnn Exp $");
 
 #include 
 #include 
@@ -1983,7 +1983,7 @@ int i915_drm_resume_early(struct drm_dev
 #ifndef __NetBSD__
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 #endif
-	int ret;
+	int ret = 0;
 
 	/*
 	 * We have a resume ordering issue with the snd-hda driver also



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 11:44:18 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_drv.c

Log Message:
i915_drm_resume_early: initialize ret

clang -Wsometimes-uninitialized says uninitialized use
on line 2043 when if statement on line 2037 is false


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:00:40 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_shmem.c

Log Message:
i915_gem_shmem.c: shmem_get_pages: fix uninitialize use of "noreclaim"


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/gem

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:00:40 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gem: i915_gem_shmem.c

Log Message:
i915_gem_shmem.c: shmem_get_pages: fix uninitialize use of "noreclaim"


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.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/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c:1.10 src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c:1.11
--- src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c:1.10	Sun Dec 19 12:25:56 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_shmem.c	Tue Dec 21 12:00:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_shmem.c,v 1.10 2021/12/19 12:25:56 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_shmem.c,v 1.11 2021/12/21 12:00:40 tnn Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.10 2021/12/19 12:25:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_shmem.c,v 1.11 2021/12/21 12:00:40 tnn Exp $");
 
 #include 
 #include 
@@ -89,12 +89,13 @@ rebuild_st:
 	 */
 #ifdef __NetBSD__
 	mapping = obj->base.filp;
+	noreclaim = GFP_KERNEL;
 #else
 	mapping = obj->base.filp->f_mapping;
 	mapping_set_unevictable(mapping);
 	noreclaim = mapping_gfp_constraint(mapping, ~__GFP_RECLAIM);
-	noreclaim |= __GFP_NORETRY | __GFP_NOWARN;
 #endif
+	noreclaim |= __GFP_NORETRY | __GFP_NOWARN;
 
 	sg = st->sgl;
 	st->nents = 0;



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:06:30 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_scheduler.c

Log Message:
i915_scheduler.c: node_to_request: duplicate 'const' declaration specifier


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:06:30 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_scheduler.c

Log Message:
i915_scheduler.c: node_to_request: duplicate 'const' declaration specifier


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.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/external/bsd/drm2/dist/drm/i915/i915_scheduler.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.7 src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.8
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c:1.7	Sun Dec 19 12:12:47 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_scheduler.c	Tue Dec 21 12:06:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_scheduler.c,v 1.7 2021/12/19 12:12:47 riastradh Exp $	*/
+/*	$NetBSD: i915_scheduler.c,v 1.8 2021/12/21 12:06:29 tnn Exp $	*/
 
 /*
  * SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.7 2021/12/19 12:12:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_scheduler.c,v 1.8 2021/12/21 12:06:29 tnn Exp $");
 
 #include 
 
@@ -34,7 +34,7 @@ static DEFINE_SPINLOCK(schedule_lock);
 static const struct i915_request *
 node_to_request(const struct i915_sched_node *node)
 {
-	return const_container_of(node, const struct i915_request, sched);
+	return const_container_of(node, struct i915_request, sched);
 }
 
 static inline bool node_started(const struct i915_sched_node *node)



CVS commit: src/sys/external/bsd/drm2/dist/include/drm

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:28:34 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drm_device.h

Log Message:
drm_device.h: don't redefine vmem_t


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/include/drm/drm_device.h

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



CVS commit: src/sys/external/bsd/drm2/dist/include/drm

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:28:34 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drm_device.h

Log Message:
drm_device.h: don't redefine vmem_t


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/include/drm/drm_device.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/external/bsd/drm2/dist/include/drm/drm_device.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_device.h:1.8 src/sys/external/bsd/drm2/dist/include/drm/drm_device.h:1.9
--- src/sys/external/bsd/drm2/dist/include/drm/drm_device.h:1.8	Sun Dec 19 12:05:09 2021
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_device.h	Tue Dec 21 12:28:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_device.h,v 1.8 2021/12/19 12:05:09 riastradh Exp $	*/
+/*	$NetBSD: drm_device.h,v 1.9 2021/12/21 12:28:34 tnn Exp $	*/
 
 #ifndef _DRM_DEVICE_H_
 #define _DRM_DEVICE_H_
@@ -29,7 +29,11 @@ struct drm_fb_helper;
 struct pci_dev;
 struct pci_controller;
 
+#if defined(__NetBSD__)
+#include 
+#else
 typedef struct vmem vmem_t;
+#endif
 
 /**
  * enum drm_switch_power - power state of drm device



CVS commit: src/sys/external/bsd/drm2

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:55:24 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/drm: files.drmkms
src/sys/external/bsd/drm2/i915drm: files.i915drmkms
src/sys/external/bsd/drm2/nouveau: files.nouveau

Log Message:
drm: sprinkle some -Wno-unused-function for clang

915_sw_fence.c: for debug_fence_init_onstack
drm_mm.c: for rb_hole_size_to_node
intel_hdmi.c: for intel_hdmi_hdcp2_protocol
intel_guc_submission.c: for rq_prio
nouveau_nvkm_subdev_instmem_base.c: for fake_ioread32_native
nouveau_nvkm_subdev_mmu_vmmnv04.c: for nv04_vmm_pgt_pte


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/external/bsd/drm2/drm/files.drmkms
cvs rdiff -u -r1.84 -r1.85 src/sys/external/bsd/drm2/i915drm/files.i915drmkms
cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/drm2/nouveau/files.nouveau

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



CVS commit: src/sys/external/bsd/drm2

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 12:55:24 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/drm: files.drmkms
src/sys/external/bsd/drm2/i915drm: files.i915drmkms
src/sys/external/bsd/drm2/nouveau: files.nouveau

Log Message:
drm: sprinkle some -Wno-unused-function for clang

915_sw_fence.c: for debug_fence_init_onstack
drm_mm.c: for rb_hole_size_to_node
intel_hdmi.c: for intel_hdmi_hdcp2_protocol
intel_guc_submission.c: for rq_prio
nouveau_nvkm_subdev_instmem_base.c: for fake_ioread32_native
nouveau_nvkm_subdev_mmu_vmmnv04.c: for nv04_vmm_pgt_pte


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/external/bsd/drm2/drm/files.drmkms
cvs rdiff -u -r1.84 -r1.85 src/sys/external/bsd/drm2/i915drm/files.i915drmkms
cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/drm2/nouveau/files.nouveau

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

Modified files:

Index: src/sys/external/bsd/drm2/drm/files.drmkms
diff -u src/sys/external/bsd/drm2/drm/files.drmkms:1.71 src/sys/external/bsd/drm2/drm/files.drmkms:1.72
--- src/sys/external/bsd/drm2/drm/files.drmkms:1.71	Sun Dec 19 12:39:48 2021
+++ src/sys/external/bsd/drm2/drm/files.drmkms	Tue Dec 21 12:55:23 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.drmkms,v 1.71 2021/12/19 12:39:48 riastradh Exp $
+#	$NetBSD: files.drmkms,v 1.72 2021/12/21 12:55:23 tnn Exp $
 
 version	20180827
 
@@ -79,6 +79,7 @@ makeoptions 	drmkms 	"CWARNFLAGS.drm_dp_
 makeoptions 	drmkms 	"CWARNFLAGS.drm_fb_helper.c"+="-Wno-shadow"
 makeoptions 	drmkms 	"CWARNFLAGS.drm_edid.c"+="-Wno-shadow"
 makeoptions 	drmkms 	"CWARNFLAGS.drm_ioctl.c"+="-Wno-shadow"
+makeoptions	drmkms	"CWARNFLAGS.drm_mm.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 makeoptions 	drmkms 	"CWARNFLAGS.drm_modes.c"+="-Wno-shadow"
 
 # Legacy user-mode setting

Index: src/sys/external/bsd/drm2/i915drm/files.i915drmkms
diff -u src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.84 src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.85
--- src/sys/external/bsd/drm2/i915drm/files.i915drmkms:1.84	Sun Dec 19 11:57:42 2021
+++ src/sys/external/bsd/drm2/i915drm/files.i915drmkms	Tue Dec 21 12:55:23 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i915drmkms,v 1.84 2021/12/19 11:57:42 riastradh Exp $
+#	$NetBSD: files.i915drmkms,v 1.85 2021/12/21 12:55:23 tnn Exp $
 
 version	20180827
 
@@ -45,11 +45,14 @@ makeoptions	i915drmkms	"CWARNFLAGS.i915d
 
 makeoptions 	i915drmkms 	"CWARNFLAGS.i915_pci.c"+="${${ACTIVE_CC} == gcc:? -Wno-override-init :}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.i915_pci.c"+="${${ACTIVE_CC} == clang:? -Wno-initializer-overrides :}"
+makeoptions	i915drmkms	"CWARNFLAGS.i915_sw_fence.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sprite.c"+="${${ACTIVE_CC} == gcc:? -Wno-maybe-uninitialized :}"
 
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_ddi.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 10:? -Wno-maybe-uninitialized :} ${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_display.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}"
+makeoptions	i915drmkms	"CWARNFLAGS.intel_guc_submission.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
+makeoptions	i915drmkms	"CWARNFLAGS.intel_hdmi.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 makeoptions 	i915drmkms 	"CWARNFLAGS.intel_sdvo.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}"
 
 makeoptions	intelfb		"CPPFLAGS.intelfb"+="${CPPFLAGS.i915drmkms}"

Index: src/sys/external/bsd/drm2/nouveau/files.nouveau
diff -u src/sys/external/bsd/drm2/nouveau/files.nouveau:1.36 src/sys/external/bsd/drm2/nouveau/files.nouveau:1.37
--- src/sys/external/bsd/drm2/nouveau/files.nouveau:1.36	Sun Dec 19 10:55:37 2021
+++ src/sys/external/bsd/drm2/nouveau/files.nouveau	Tue Dec 21 12:55:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.nouveau,v 1.36 2021/12/19 10:55:37 riastradh Exp $
+#	$NetBSD: files.nouveau,v 1.37 2021/12/21 12:55:24 tnn Exp $
 
 version	20180827
 
@@ -37,6 +37,8 @@ makeoptions	nouveau	"CWARNFLAGS.nouveau"
 makeoptions	nouveau	"CWARNFLAGS.nouveau"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_nvkm_subdev_bios_timing.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=int-in-bool-context :}"
 makeoptions	nouveau	"CWARNFLAGS.nouveau_nvkm_subdev_clk_gt215.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=int-in-bool-context :}"
+makeoptions	nouveau	"CWARNFLAGS.nouveau_nvkm_subdev_instmem_base.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
+makeoptions	nouveau	"CWARNFLAGS.nouveau_nvkm_subdev_mmu_vmmnv04.c"+="${${ACTIVE_CC} == clang :? -Wno-unused-function :}"
 
 file	external/bsd/drm2/nouveau/nouveau_module.c	nouveau
 



CVS commit: src/sys/external/bsd/drm2/radeon

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 13:56:58 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/radeon: files.radeon

Log Message:
files.radeon: add clang -Wno-format for radeon_uvd.c

int vs. short mismatch in UVD firmware version printf.
Also change some makeoptions conditional copypasta i915drmkms -> radeon.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/external/bsd/drm2/radeon/files.radeon

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



CVS commit: src/sys/external/bsd/drm2/radeon

2021-12-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Dec 21 13:56:58 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/radeon: files.radeon

Log Message:
files.radeon: add clang -Wno-format for radeon_uvd.c

int vs. short mismatch in UVD firmware version printf.
Also change some makeoptions conditional copypasta i915drmkms -> radeon.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/external/bsd/drm2/radeon/files.radeon

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

Modified files:

Index: src/sys/external/bsd/drm2/radeon/files.radeon
diff -u src/sys/external/bsd/drm2/radeon/files.radeon:1.35 src/sys/external/bsd/drm2/radeon/files.radeon:1.36
--- src/sys/external/bsd/drm2/radeon/files.radeon:1.35	Sun Dec 19 10:55:37 2021
+++ src/sys/external/bsd/drm2/radeon/files.radeon	Tue Dec 21 13:56:58 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.radeon,v 1.35 2021/12/19 10:55:37 riastradh Exp $
+#	$NetBSD: files.radeon,v 1.36 2021/12/21 13:56:58 tnn Exp $
 
 version	20180827
 
@@ -34,10 +34,11 @@ makeoptions	radeon	"CWARNFLAGS.radeon"+=
 
 makeoptions	radeon	"CWARNFLAGS.radeon"+="${${ACTIVE_CC} == gcc:? -Wno-maybe-uninitialized :}"
 
-#makeoptions 	i915drmkms 	"CWARNFLAGS.radeon_cs.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
-makeoptions 	i915drmkms 	"CWARNFLAGS.radeon_evergreen_cs.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
-makeoptions 	i915drmkms 	"CWARNFLAGS.radeon_r300.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
-makeoptions 	i915drmkms 	"CWARNFLAGS.radeon_r420.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
+#makeoptions 	radeon 	"CWARNFLAGS.radeon_cs.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
+makeoptions 	radeon 	"CWARNFLAGS.radeon_evergreen_cs.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
+makeoptions 	radeon 	"CWARNFLAGS.radeon_r300.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
+makeoptions 	radeon 	"CWARNFLAGS.radeon_r420.c"+="${${ACTIVE_CC} == gcc && ${HAVE_GCC:U0} >= 7:? -Wno-error=implicit-fallthrough :}"
+makeoptions	radeon	"CWARNFLAGS.radeon_uvd.c"+="${${ACTIVE_CC} == clang:? -Wno-format :}"
 
 file	external/bsd/drm2/radeon/radeon_module.c		radeon
 file	external/bsd/drm2/radeon/radeon_pci.c			radeon



Re: CVS commit: src

2021-12-30 Thread Tobias Nygren
On Fri, 31 Dec 2021 01:44:19 +0900
Ryo ONODERA  wrote:

> #  link  LOCKDEBUG/netbsd
> /usr/world/9.99/amd64/tools/bin/x86_64--netbsd-ld -Map netbsd.map --cref -T 
> netbsd.ldscript -Ttext 0x8020 -e start -z max-page-size=0x20 
> -X -o netbsd ${SYSTEM_OBJ:[@]:Nswapnetbsd.o} ${EXTRA_OBJ} vers.o swapnetbsd.o
> NetBSD 9.99.93 (LOCKDEBUG) #0: Fri Dec 31 01:31:35 JST 2021
>textdata bss dec hex filename
> 21646842 728976 1368064 2374388216a4d8a netbsd
> + mv -f netbsd netbsd.gdb
> + /usr/world/9.99/amd64/tools/bin/x86_64--netbsd-objcopy --only-keep-debug 
> netbsd.gdb netbsd-/usr/src/sys/arch/amd64/conf/LOCKDEBUG.debug
> /usr/world/9.99/amd64/tools/bin/x86_64--netbsd-objcopy: 
> netbsd-/usr/src/sys/arch/amd64/conf/LOCKDEBUG.debug: No such file or directory

Hi,

Changing ${KERNEL_BUILD} to ${KERNEL_BUILD:T} mostly fixes the
above problem. But this change is still incompatible with MKUNPRIVED:

aarch64--netbsd-install: 
/work/src/../obj/destdir.evbarm/usr/libdata/debug/netbsd-GENERIC.lx2k.debug.inst.xOfGh2:
 chown/chgrp: Operation not permitted

Additionally, it produces new noisy output that does not respect
MAKEVERBOSE level 0 or 1 in the final link stage.

-Tobias





CVS commit: src/sys/dev/pci

2022-01-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan  8 12:59:34 UTC 2022

Modified Files:
src/sys/dev/pci: pci_subr.c

Log Message:
place additional parens around multiline string constant to appease clang


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/dev/pci/pci_subr.c

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

2022-01-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan  8 12:59:34 UTC 2022

Modified Files:
src/sys/dev/pci: pci_subr.c

Log Message:
place additional parens around multiline string constant to appease clang


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/dev/pci/pci_subr.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/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.238 src/sys/dev/pci/pci_subr.c:1.239
--- src/sys/dev/pci/pci_subr.c:1.238	Fri Jan  7 06:57:57 2022
+++ src/sys/dev/pci/pci_subr.c	Sat Jan  8 12:59:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.238 2022/01/07 06:57:57 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.239 2022/01/08 12:59:34 tnn Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.238 2022/01/07 06:57:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.239 2022/01/08 12:59:34 tnn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -4369,8 +4369,8 @@ pci_conf_print_pl16g_cap(const pcireg_t 
 }
 
 static const char * const pcie_receive_number_dp[] = {
-	[0] = "Broadcast "
-	"(Downstream Port Receiver and all Retimer Pseudo Port Receiver)",
+	[0] = ("Broadcast "
+	"(Downstream Port Receiver and all Retimer Pseudo Port Receiver)"),
 	[1] =  "Rx(A) (Downstream Port Receiver)",
 	[2] = "Rx(B) (Retimer X or Z Upstream Pseudo Port Receiver)",
 	[3] = "Rx(C) (Retimer X or Z Downstream Pseudo Port Receiver)",



CVS commit: src/lib/libedit/readline

2022-01-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Jan 14 12:48:31 UTC 2022

Modified Files:
src/lib/libedit/readline: readline.h

Log Message:
libedit: rl_message: annotate __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libedit/readline/readline.h

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



CVS commit: src/lib/libedit/readline

2022-01-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Jan 14 12:48:31 UTC 2022

Modified Files:
src/lib/libedit/readline: readline.h

Log Message:
libedit: rl_message: annotate __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libedit/readline/readline.h

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

Modified files:

Index: src/lib/libedit/readline/readline.h
diff -u src/lib/libedit/readline/readline.h:1.48 src/lib/libedit/readline/readline.h:1.49
--- src/lib/libedit/readline/readline.h:1.48	Tue Jan 11 18:30:15 2022
+++ src/lib/libedit/readline/readline.h	Fri Jan 14 12:48:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.h,v 1.48 2022/01/11 18:30:15 christos Exp $	*/
+/*	$NetBSD: readline.h,v 1.49 2022/01/14 12:48:30 tnn Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -229,7 +229,7 @@ int		 rl_crlf(void);
 int		 rl_ding(void);
 char 		*rl_copy_text(int, int);
 void		 rl_replace_line(const char *, int);
-void 		 rl_message(const char *format, ...);
+void 		 rl_message(const char *format, ...) __printflike(1, 2);
 void		 rl_save_prompt(void);
 void		 rl_restore_prompt(void);
 



CVS commit: src/lib/librefuse

2022-01-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jan 29 00:03:42 UTC 2022

Modified Files:
src/lib/librefuse: refuse_log.c

Log Message:
librefuse: default_log_func is __printflike


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librefuse/refuse_log.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/librefuse/refuse_log.c
diff -u src/lib/librefuse/refuse_log.c:1.1 src/lib/librefuse/refuse_log.c:1.2
--- src/lib/librefuse/refuse_log.c:1.1	Sat Jan 22 07:39:22 2022
+++ src/lib/librefuse/refuse_log.c	Sat Jan 29 00:03:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $ */
+/* $NetBSD: refuse_log.c,v 1.2 2022/01/29 00:03:41 tnn Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: refuse_log.c,v 1.1 2022/01/22 07:39:22 pho Exp $");
+__RCSID("$NetBSD: refuse_log.c,v 1.2 2022/01/29 00:03:41 tnn Exp $");
 #endif /* !lint */
 
 #include 
@@ -41,7 +41,7 @@ __RCSID("$NetBSD: refuse_log.c,v 1.1 202
 #endif
 #include 
 
-static void
+static void  __printflike(2, 0)
 default_log_func(enum fuse_log_level level __attribute__((__unused__)),
  const char *fmt, va_list ap) {
 /* This function needs to be thread-safe. Calling vfprintf(3)



  1   2   3   >