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

2019-05-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Tue May 28 05:08:47 UTC 2019

Modified Files:
src/sys/arch/arm/amlogic: meson_uart.c

Log Message:
- since ttyinput (t_linesw->l_rint) should not be called from interrupt context,
  it has been modified to use softint like other serial drivers.
- add spinlock for interrupt.

ok jmcneill@. thanks


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

2019-05-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue May 28 05:07:13 UTC 2019

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

Log Message:
 Fix typos. From OpenBSD r1.52.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_jme.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/if_jme.c
diff -u src/sys/dev/pci/if_jme.c:1.41 src/sys/dev/pci/if_jme.c:1.42
--- src/sys/dev/pci/if_jme.c:1.41	Thu May 23 13:10:52 2019
+++ src/sys/dev/pci/if_jme.c	Tue May 28 05:07:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_jme.c,v 1.41 2019/05/23 13:10:52 msaitoh Exp $	*/
+/*	$NetBSD: if_jme.c,v 1.42 2019/05/28 05:07:13 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.41 2019/05/23 13:10:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.42 2019/05/28 05:07:13 msaitoh Exp $");
 
 
 #include 
@@ -583,7 +583,7 @@ jme_stop_rx(jme_softc_t *sc)
 			break;
 	}
 	if (i == 0)
-		aprint_error_dev(sc->jme_dev, "stopping recevier timeout!\n");
+		aprint_error_dev(sc->jme_dev, "stopping receiver timeout!\n");
 
 }
 
@@ -1527,7 +1527,7 @@ jme_encap(struct jme_softc *sc, struct m
 #endif
 	/*
 	 * Finally request interrupt and give the first descriptor
-	 * owenership to hardware.
+	 * ownership to hardware.
 	 */
 	desc = >jme_txring[headdsc];
 	desc->flags |= htole32(JME_TD_OWN | JME_TD_INTR);
@@ -1605,7 +1605,7 @@ jme_txeof(struct jme_softc *sc)
 		/*
 		 * Only the first descriptor of multi-descriptor
 		 * transmission is updated so driver have to skip entire
-		 * chained buffers for the transmiited frame. In other
+		 * chained buffers for the transmitted frame. In other
 		 * words, JME_TD_OWN bit is valid only at the first
 		 * descriptor of a multi-descriptor transmission.
 		 */



CVS commit: src/sys/dev/pci

2019-05-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue May 28 05:07:13 UTC 2019

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

Log Message:
 Fix typos. From OpenBSD r1.52.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_jme.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/acpica/dist/include

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 04:04:11 UTC 2019

Modified Files:
src/sys/external/bsd/acpica/dist/include: amlresrc.h

Log Message:
Use pack attribute for AML_RESOURCE in acpica

This fixes kUBSan warnings.

Patch by Akul Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.10 -r1.2 \
src/sys/external/bsd/acpica/dist/include/amlresrc.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/acpica/dist/include

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 04:04:11 UTC 2019

Modified Files:
src/sys/external/bsd/acpica/dist/include: amlresrc.h

Log Message:
Use pack attribute for AML_RESOURCE in acpica

This fixes kUBSan warnings.

Patch by Akul Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.10 -r1.2 \
src/sys/external/bsd/acpica/dist/include/amlresrc.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/acpica/dist/include/amlresrc.h
diff -u src/sys/external/bsd/acpica/dist/include/amlresrc.h:1.1.1.10 src/sys/external/bsd/acpica/dist/include/amlresrc.h:1.2
--- src/sys/external/bsd/acpica/dist/include/amlresrc.h:1.1.1.10	Mon Apr 29 00:29:54 2019
+++ src/sys/external/bsd/acpica/dist/include/amlresrc.h	Tue May 28 04:04:11 2019
@@ -642,10 +642,6 @@ typedef struct aml_resource_pin_group_co
 
 #define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION1   /* ACPI 6.2 */
 
-/* restore default alignment */
-
-#pragma pack()
-
 /* Union of all resource descriptors, so we can allocate the worst case */
 
 typedef union aml_resource
@@ -700,6 +696,9 @@ typedef union aml_resource
 
 } AML_RESOURCE;
 
+/* restore default alignment */
+
+#pragma pack()
 
 /* Interfaces used by both the disassembler and compiler */
 



CVS commit: src/sys/netinet6

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:56:46 UTC 2019

Modified Files:
src/sys/netinet6: in6.h

Log Message:
Decorate struct in6_addr with the __packed attribute

This avoids undefined behavior when accessing misaligned pointers.

Detected by kUBSan.

Patch by Akul Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/netinet6/in6.h

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



CVS commit: src/sys/netinet6

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:56:46 UTC 2019

Modified Files:
src/sys/netinet6: in6.h

Log Message:
Decorate struct in6_addr with the __packed attribute

This avoids undefined behavior when accessing misaligned pointers.

Detected by kUBSan.

Patch by Akul Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/netinet6/in6.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/netinet6/in6.h
diff -u src/sys/netinet6/in6.h:1.94 src/sys/netinet6/in6.h:1.95
--- src/sys/netinet6/in6.h:1.94	Mon Dec 10 16:28:52 2018
+++ src/sys/netinet6/in6.h	Tue May 28 03:56:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.h,v 1.94 2018/12/10 16:28:52 christos Exp $	*/
+/*	$NetBSD: in6.h,v 1.95 2019/05/28 03:56:46 kamil Exp $	*/
 /*	$KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $	*/
 
 /*
@@ -126,7 +126,7 @@ struct in6_addr {
 		__uint16_t  __u6_addr16[8];
 		uint32_t  __u6_addr32[4];
 	} __u6_addr;			/* 128-bit IP6 address */
-};
+} __packed;
 
 #define s6_addr   __u6_addr.__u6_addr8
 #ifdef _KERNEL	/* XXX nonstandard */



CVS commit: src/sys/ufs/ffs

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:53:29 UTC 2019

Modified Files:
src/sys/ufs/ffs: ffs_subr.c

Log Message:
Avoid unportable shift base -1 in ffs_subr.c

Cast the start variable before the modulo opration to unsigned int.

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_subr.c
diff -u src/sys/ufs/ffs/ffs_subr.c:1.50 src/sys/ufs/ffs/ffs_subr.c:1.51
--- src/sys/ufs/ffs/ffs_subr.c:1.50	Wed Jul  4 02:02:15 2018
+++ src/sys/ufs/ffs/ffs_subr.c	Tue May 28 03:53:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $	*/
+/*	$NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $");
 
 #include 
 
@@ -313,7 +313,7 @@ ffs_clusteracct(struct fs *fs, struct cg
 		end = ufs_rw32(cgp->cg_nclusterblks, needswap);
 	mapp = [start / NBBY];
 	map = *mapp++;
-	bit = 1U << (start % NBBY);
+	bit = 1U << ((unsigned int)start % NBBY);
 	for (i = start; i < end; i++) {
 		if ((map & bit) == 0)
 			break;
@@ -334,7 +334,7 @@ ffs_clusteracct(struct fs *fs, struct cg
 		end = -1;
 	mapp = [start / NBBY];
 	map = *mapp--;
-	bit = 1U << (start % NBBY);
+	bit = 1U << ((unsigned int)start % NBBY);
 	for (i = start; i > end; i--) {
 		if ((map & bit) == 0)
 			break;



CVS commit: src/sys/ufs/ffs

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:53:29 UTC 2019

Modified Files:
src/sys/ufs/ffs: ffs_subr.c

Log Message:
Avoid unportable shift base -1 in ffs_subr.c

Cast the start variable before the modulo opration to unsigned int.

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ffs/ffs_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/arch/amd64/amd64

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:52:09 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: kobj_machdep.c

Log Message:
Replace misaligned operations with memcpy() calls in kobj_machdep.c

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/amd64/kobj_machdep.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/kobj_machdep.c
diff -u src/sys/arch/amd64/amd64/kobj_machdep.c:1.7 src/sys/arch/amd64/amd64/kobj_machdep.c:1.8
--- src/sys/arch/amd64/amd64/kobj_machdep.c:1.7	Mon Dec 24 21:48:52 2018
+++ src/sys/arch/amd64/amd64/kobj_machdep.c	Tue May 28 03:52:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.7 2018/12/24 21:48:52 christos Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.7 2018/12/24 21:48:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $");
 
 #define	ELFSIZE		ARCH_ELFSIZE
 
@@ -115,7 +115,7 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 		if (error)
 			return -1;
 		val = addr + addend;
-		*where = val;
+		memcpy(where, , sizeof(val));
 		break;
 
 	case R_X86_64_PC32:	/* S + A - P */
@@ -125,7 +125,7 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 			return -1;
 		where32 = (Elf32_Addr *)where;
 		val32 = (Elf32_Addr)(addr + addend - (Elf64_Addr)where);
-		*where32 = val32;
+		memcpy(where32, , sizeof(val32));
 		break;
 
 	case R_X86_64_32:	/* S + A */
@@ -135,7 +135,7 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 			return -1;
 		val32 = (Elf32_Addr)(addr + addend);
 		where32 = (Elf32_Addr *)where;
-		*where32 = val32;
+		memcpy(where32, , sizeof(val32));
 		break;
 
 	case R_X86_64_GLOB_DAT:	/* S */
@@ -143,13 +143,13 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 		error = kobj_sym_lookup(ko, symidx, );
 		if (error)
 			return -1;
-		*where = addr;
+		memcpy(where, , sizeof(addr));
 		break;
 
 	case R_X86_64_RELATIVE:	/* B + A */
 		addr = relocbase + addend;
 		val = addr;
-		*where = val;
+		memcpy(where, , sizeof(val));
 		break;
 
 	default:



CVS commit: src/sys/arch/amd64/amd64

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:52:09 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: kobj_machdep.c

Log Message:
Replace misaligned operations with memcpy() calls in kobj_machdep.c

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/amd64/kobj_machdep.c

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



CVS commit: src/external/gpl3/gdb.old/dist/gdb

2019-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 28 01:20:02 UTC 2019

Modified Files:
src/external/gpl3/gdb.old/dist/gdb: rust-exp.c

Log Message:
fix locally modified file.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl3/gdb.old/dist/gdb/rust-exp.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/sdmmc

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May 28 00:25:27 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_mem.c

Log Message:
If a mem function fails to initialize, set the error flag so sdmmc doesn't try 
to use it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/sdmmc/sdmmc_mem.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/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.66 src/sys/dev/sdmmc/sdmmc_mem.c:1.67
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.66	Fri Nov  9 14:38:36 2018
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Tue May 28 00:25:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_mem.c,v 1.66 2018/11/09 14:38:36 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.66 2018/11/09 14:38:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -589,6 +589,9 @@ sdmmc_mem_init(struct sdmmc_softc *sc, s
 	else
 		error = sdmmc_mem_mmc_init(sc, sf);
 
+	if (error != 0)
+		SET(sf->flags, SFF_ERROR);
+
 out:
 	SDMMC_UNLOCK(sc);
 



CVS commit: src/sys/dev/sdmmc

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May 28 00:25:27 UTC 2019

Modified Files:
src/sys/dev/sdmmc: sdmmc_mem.c

Log Message:
If a mem function fails to initialize, set the error flag so sdmmc doesn't try 
to use it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/sdmmc/sdmmc_mem.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May 28 00:02:32 UTC 2019

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

Log Message:
Enable parent clocks


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May 28 00:02:32 UTC 2019

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

Log Message:
Enable parent clocks


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.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/sun9i_a80_mmcclk.c
diff -u src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.c:1.1 src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.c:1.2
--- src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.c:1.1	Sun Oct  8 18:00:36 2017
+++ src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.c	Tue May 28 00:02:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun9i_a80_mmcclk.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
+/* $NetBSD: sun9i_a80_mmcclk.c,v 1.2 2019/05/28 00:02:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun9i_a80_mmcclk.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun9i_a80_mmcclk.c,v 1.2 2019/05/28 00:02:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,6 +79,9 @@ sun9i_a80_mmcclk_attach(device_t parent,
 {
 	struct sunxi_ccu_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
+	const int phandle = faa->faa_phandle;
+	struct fdtbus_reset *rst;
+	struct clk *clk;
 
 	sc->sc_dev = self;
 	sc->sc_phandle = faa->faa_phandle;
@@ -90,6 +93,17 @@ sun9i_a80_mmcclk_attach(device_t parent,
 	sc->sc_clks = sun9i_a80_mmcclk_clks;
 	sc->sc_nclks = __arraycount(sun9i_a80_mmcclk_clks);
 
+	clk = fdtbus_clock_get(phandle, "ahb");
+	if (clk == NULL || clk_enable(clk) != 0) {
+		aprint_error(": couldn't enable clock\n");
+		return;
+	}
+	rst = fdtbus_reset_get(phandle, "ahb");
+	if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
+		aprint_error(": couldn't de-assert reset\n");
+		return;
+	}
+
 	if (sunxi_ccu_attach(sc) != 0)
 		return;
 



CVS commit: src/sys/dev/i2c

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:28:41 UTC 2019

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

Log Message:
Add basic support for AXP809


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/axppmic.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/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.20 src/sys/dev/i2c/axppmic.c:1.21
--- src/sys/dev/i2c/axppmic.c:1.20	Mon May 27 21:36:07 2019
+++ src/sys/dev/i2c/axppmic.c	Mon May 27 23:28:41 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.21 2019/05/27 23:28:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.21 2019/05/27 23:28:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -208,6 +208,14 @@ static const struct axppmic_ctrl axp805_
 		0x11, __BIT(6), 0x26, __BITS(4,0)),
 };
 
+static const struct axppmic_ctrl axp809_ctrls[] = {
+	/* TODO: This list is incomplete */
+	AXP_CTRL("ldo_io0", 700, 3300, 100,
+		0x90, __BIT(0), 0x91, __BITS(4,0)),
+	AXP_CTRL("ldo_io1", 700, 3300, 100,
+		0x92, __BIT(0), 0x93, __BITS(4,0)),
+};
+
 static const struct axppmic_ctrl axp813_ctrls[] = {
 	AXP_CTRL("dldo1", 700, 3300, 100,
 		0x12, __BIT(3), 0x15, __BITS(4,0)),
@@ -364,6 +372,12 @@ static const struct axppmic_config axp80
 	.has_mode_set = true,
 };
 
+static const struct axppmic_config axp809_config = {
+	.name = "AXP809",
+	.controls = axp809_ctrls,
+	.ncontrols = __arraycount(axp809_ctrls),
+};
+
 static const struct axppmic_config axp813_config = {
 	.name = "AXP813",
 	.controls = axp813_ctrls,
@@ -388,6 +402,7 @@ static const struct device_compatible_en
 	{ "x-powers,axp803",		(uintptr_t)_config },
 	{ "x-powers,axp805",		(uintptr_t)_config },
 	{ "x-powers,axp806",		(uintptr_t)_config },
+	{ "x-powers,axp809",		(uintptr_t)_config },
 	{ "x-powers,axp813",		(uintptr_t)_config },
 	{ NULL,0 }
 };
@@ -911,6 +926,9 @@ axppmic_attach(device_t parent, device_t
 		}
 	}
 
+	/* Notify pinctrl drivers that regulators are available. */
+	fdtbus_pinctrl_configure();
+
 	if (c->has_battery)
 		axppmic_attach_sensors(sc);
 }



CVS commit: src/sys/dev/i2c

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:28:41 UTC 2019

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

Log Message:
Add basic support for AXP809


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/axppmic.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:26 UTC 2019

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

Log Message:
Enable phy-supply if present


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_gmac.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/sunxi_gmac.c
diff -u src/sys/arch/arm/sunxi/sunxi_gmac.c:1.3 src/sys/arch/arm/sunxi/sunxi_gmac.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_gmac.c:1.3	Sat Feb 23 17:18:38 2019
+++ src/sys/arch/arm/sunxi/sunxi_gmac.c	Mon May 27 23:27:26 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gmac.c,v 1.3 2019/02/23 17:18:38 martin Exp $ */
+/* $NetBSD: sunxi_gmac.c,v 1.4 2019/05/27 23:27:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.3 2019/02/23 17:18:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.4 2019/05/27 23:27:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -108,6 +108,7 @@ sunxi_gmac_attach(device_t parent, devic
 	const int phandle = faa->faa_phandle;
 	struct clk *clk_gmac, *clk_gmac_tx;
 	struct fdtbus_reset *rst_gmac;
+	struct fdtbus_regulator *reg_phy;
 	const char *phy_mode;
 	char intrstr[128];
 	bus_addr_t addr;
@@ -145,6 +146,13 @@ sunxi_gmac_attach(device_t parent, devic
 		aprint_error(": missing 'phy-mode' property\n");
 		return;
 	}
+
+	reg_phy = fdtbus_regulator_acquire(phandle, "phy-supply");
+	if (reg_phy != NULL && fdtbus_regulator_enable(reg_phy) != 0) {
+		aprint_error(": couldn't enable PHY regualtor\n");
+		return;
+	}
+
 	if (strcmp(phy_mode, "mii") == 0) {
 		if (clk_set_rate(clk_gmac_tx, GMAC_TX_RATE_MII) != 0) {
 			aprint_error(": failed to set TX clock rate (MII)\n");



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:26 UTC 2019

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

Log Message:
Enable phy-supply if present


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_gmac.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:14 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_gpio.h

Log Message:
Add has_io_bias_config property to sunxi_gpio_padconf


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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:14 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_gpio.h

Log Message:
Add has_io_bias_config property to sunxi_gpio_padconf


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_gpio.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/sunxi_gpio.h
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.h:1.8 src/sys/arch/arm/sunxi/sunxi_gpio.h:1.9
--- src/sys/arch/arm/sunxi/sunxi_gpio.h:1.8	Sun Feb 18 10:28:37 2018
+++ src/sys/arch/arm/sunxi/sunxi_gpio.h	Mon May 27 23:27:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.h,v 1.8 2018/02/18 10:28:37 jmcneill Exp $ */
+/* $NetBSD: sunxi_gpio.h,v 1.9 2019/05/27 23:27:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -49,6 +49,7 @@ struct sunxi_gpio_pins {
 struct sunxi_gpio_padconf {
 	uint32_t npins;
 	const struct sunxi_gpio_pins *pins;
+	bool has_io_bias_config;
 };
 
 #ifdef SOC_SUN4I_A10



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:26:42 UTC 2019

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

Log Message:
Set has_io_bias_config flag


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun9i_a80_gpio.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/sun9i_a80_gpio.c
diff -u src/sys/arch/arm/sunxi/sun9i_a80_gpio.c:1.2 src/sys/arch/arm/sunxi/sun9i_a80_gpio.c:1.3
--- src/sys/arch/arm/sunxi/sun9i_a80_gpio.c:1.2	Tue Apr  3 16:01:25 2018
+++ src/sys/arch/arm/sunxi/sun9i_a80_gpio.c	Mon May 27 23:26:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun9i_a80_gpio.c,v 1.2 2018/04/03 16:01:25 bouyer Exp $ */
+/* $NetBSD: sun9i_a80_gpio.c,v 1.3 2019/05/27 23:26:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun9i_a80_gpio.c,v 1.2 2018/04/03 16:01:25 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun9i_a80_gpio.c,v 1.3 2019/05/27 23:26:42 jmcneill Exp $");
 
 #include 
 #include 
@@ -213,9 +213,11 @@ static const struct sunxi_gpio_pins a80_
 const struct sunxi_gpio_padconf sun9i_a80_padconf = {
 	.npins = __arraycount(a80_pins),
 	.pins = a80_pins,
+	.has_io_bias_config = true,
 };
 
 const struct sunxi_gpio_padconf sun9i_a80_r_padconf = {
 	.npins = __arraycount(a80_r_pins),
 	.pins = a80_r_pins,
+	.has_io_bias_config = true,
 };



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:01 UTC 2019

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

Log Message:
Enable vmmc-supply if present


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/sunxi/sunxi_mmc.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/sunxi_mmc.c
diff -u src/sys/arch/arm/sunxi/sunxi_mmc.c:1.32 src/sys/arch/arm/sunxi/sunxi_mmc.c:1.33
--- src/sys/arch/arm/sunxi/sunxi_mmc.c:1.32	Thu Jan  3 15:34:41 2019
+++ src/sys/arch/arm/sunxi/sunxi_mmc.c	Mon May 27 23:27:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mmc.c,v 1.32 2019/01/03 15:34:41 jmcneill Exp $ */
+/* $NetBSD: sunxi_mmc.c,v 1.33 2019/05/27 23:27:01 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_sunximmc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.32 2019/01/03 15:34:41 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.33 2019/05/27 23:27:01 jmcneill Exp $");
 
 #include 
 #include 
@@ -358,10 +358,15 @@ sunxi_mmc_attach(device_t parent, device
 		return;
 	}
 
+	sc->sc_reg_vmmc = fdtbus_regulator_acquire(phandle, "vmmc-supply");
+	if (sc->sc_reg_vmmc != NULL && fdtbus_regulator_enable(sc->sc_reg_vmmc)) {
+		aprint_error(": couldn't enable vmmc-supply\n");
+		return;
+	}
+
 	aprint_naive("\n");
 	aprint_normal(": SD/MMC controller\n");
 
-	sc->sc_reg_vmmc = fdtbus_regulator_acquire(phandle, "vmmc-supply");
 	sc->sc_reg_vqmmc = fdtbus_regulator_acquire(phandle, "vqmmc-supply");
 
 	sc->sc_gpio_cd = fdtbus_gpio_acquire(phandle, "cd-gpios",



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:27:01 UTC 2019

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

Log Message:
Enable vmmc-supply if present


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/sunxi/sunxi_mmc.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:26:20 UTC 2019

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

Log Message:
Fix support for Allwinner-specific pin bindings and add support for pink bank 
regulators


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sunxi_gpio.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:26:42 UTC 2019

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

Log Message:
Set has_io_bias_config flag


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun9i_a80_gpio.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:26:20 UTC 2019

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

Log Message:
Fix support for Allwinner-specific pin bindings and add support for pink bank 
regulators


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sunxi_gpio.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/sunxi_gpio.c
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.c:1.23 src/sys/arch/arm/sunxi/sunxi_gpio.c:1.24
--- src/sys/arch/arm/sunxi/sunxi_gpio.c:1.23	Sat Jan 26 14:38:30 2019
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c	Mon May 27 23:26:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.24 2019/05/27 23:26:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.24 2019/05/27 23:26:20 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,6 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c
 #define	SUNXI_GPIO_MAX_EINT_BANK	5
 #define	SUNXI_GPIO_MAX_EINT		32
 
+#define	SUNXI_GPIO_MAX_BANK		26
+
 #define	SUNXI_GPIO_PORT(port)		(0x24 * (port))
 #define SUNXI_GPIO_CFG(port, pin)	(SUNXI_GPIO_PORT(port) + 0x00 + (0x4 * ((pin) / 8)))
 #define  SUNXI_GPIO_CFG_PINMASK(pin)	(0x7 << (((pin) % 8) * 4))
@@ -70,6 +72,8 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c
 #define	  SUNXI_GPIO_INT_MODE_DOUBLE_EDGE	0x4
 #define	SUNXI_GPIO_INT_CTL(bank)	(0x210 + 0x20 * (bank))
 #define	SUNXI_GPIO_INT_STATUS(bank)	(0x214 + 0x20 * (bank))
+#define	SUNXI_GPIO_GRP_CONFIG(bank)	(0x300 + 0x4 * (bank))
+#define	 SUNXI_GPIO_GRP_IO_BIAS_CONFIGMASK	0xf
 
 static const struct of_compat_data compat_data[] = {
 #ifdef SOC_SUN4I_A10
@@ -125,6 +129,7 @@ struct sunxi_gpio_softc {
 	device_t sc_dev;
 	bus_space_tag_t sc_bst;
 	bus_space_handle_t sc_bsh;
+	int sc_phandle;
 	const struct sunxi_gpio_padconf *sc_padconf;
 	kmutex_t sc_lock;
 
@@ -132,6 +137,8 @@ struct sunxi_gpio_softc {
 	gpio_pin_t *sc_pins;
 	device_t sc_gpiodev;
 
+	struct fdtbus_regulator *sc_pin_supply[SUNXI_GPIO_MAX_BANK];
+
 	u_int sc_eint_bank_max;
 
 	void *sc_ih;
@@ -602,7 +609,7 @@ sunxi_pinctrl_parse_pins(int phandle, in
 	len = OF_getproplen(phandle, "allwinner,pins");
 	if (len > 0) {
 		*pins_len = len;
-		return fdtbus_get_string(phandle, "allwinner,pins");
+		return fdtbus_get_prop(phandle, "allwinner,pins", pins_len);
 	}
 
 	return NULL;
@@ -650,6 +657,64 @@ sunxi_pinctrl_parse_drive_strength(int p
 	return -1;
 }
 
+static void
+sunxi_pinctrl_enable_regulator(struct sunxi_gpio_softc *sc,
+const struct sunxi_gpio_pins *pin_def)
+{
+	char supply_prop[16];
+	uint32_t val;
+	u_int uvol;
+	int error;
+
+	const char c = tolower(pin_def->name[1]);
+	if (c < 'a' || c > 'z')
+		return;
+	const int index = c - 'a';
+
+	if (sc->sc_pin_supply[index] != NULL) {
+		/* Already enabled */
+		return;
+	}
+
+	snprintf(supply_prop, sizeof(supply_prop), "vcc-p%c-supply", c);
+	sc->sc_pin_supply[index] = fdtbus_regulator_acquire(sc->sc_phandle, supply_prop);
+	if (sc->sc_pin_supply[index] == NULL)
+		return;
+
+	aprint_debug_dev(sc->sc_dev, "enable \"%s\"\n", supply_prop);
+	error = fdtbus_regulator_enable(sc->sc_pin_supply[index]);
+	if (error != 0)
+		aprint_error_dev(sc->sc_dev, "failed to enable %s: %d\n", supply_prop, error);
+
+	if (sc->sc_padconf->has_io_bias_config) {
+		error = fdtbus_regulator_get_voltage(sc->sc_pin_supply[index], );
+		if (error != 0) {
+			aprint_error_dev(sc->sc_dev, "failed to get %s voltage: %d\n",
+			supply_prop, error);
+			uvol = 0;
+		}
+		if (uvol != 0) {
+			if (uvol <= 180)
+val = 0x0;	/* 1.8V */
+			else if (uvol <= 250)
+val = 0x6;	/* 2.5V */
+			else if (uvol <= 280)
+val = 0x9;	/* 2.8V */
+			else if (uvol <= 300)
+val = 0xa;	/* 3.0V */
+			else
+val = 0xd;	/* 3.3V */
+
+			aprint_debug_dev(sc->sc_dev, "set io bias config for port %d to 0x%x\n",
+			pin_def->port, val);
+			val = GPIO_READ(sc, SUNXI_GPIO_GRP_CONFIG(pin_def->port));
+			val &= ~SUNXI_GPIO_GRP_IO_BIAS_CONFIGMASK;
+			val |= __SHIFTIN(val, SUNXI_GPIO_GRP_IO_BIAS_CONFIGMASK);
+			GPIO_WRITE(sc, SUNXI_GPIO_GRP_CONFIG(pin_def->port), val);
+		}
+	}
+}
+
 static int
 sunxi_pinctrl_set_config(device_t dev, const void *data, size_t len)
 {
@@ -694,6 +759,8 @@ sunxi_pinctrl_set_config(device_t dev, c
 
 		if (drive_strength != -1)
 			sunxi_gpio_setdrv(sc, pin_def, drive_strength);
+
+		sunxi_pinctrl_enable_regulator(sc, pin_def);
 	}
 
 	mutex_exit(>sc_lock);
@@ -833,6 +900,7 @@ sunxi_gpio_attach(device_t parent, devic
 		}
 
 	sc->sc_dev = self;
+	sc->sc_phandle = phandle;
 	sc->sc_bst = faa->faa_bst;
 	if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) {
 		

CVS commit: src/sys/dev/fdt

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:18:33 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_regulator.c

Log Message:
Honour regulator-enable-ramp-delay


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/fdt/fdt_regulator.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/fdt/fdt_regulator.c
diff -u src/sys/dev/fdt/fdt_regulator.c:1.7 src/sys/dev/fdt/fdt_regulator.c:1.8
--- src/sys/dev/fdt/fdt_regulator.c:1.7	Wed Jan  2 18:38:43 2019
+++ src/sys/dev/fdt/fdt_regulator.c	Mon May 27 23:18:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_regulator.c,v 1.7 2019/01/02 18:38:43 jmcneill Exp $ */
+/* $NetBSD: fdt_regulator.c,v 1.8 2019/05/27 23:18:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.7 2019/01/02 18:38:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.8 2019/05/27 23:18:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ struct fdtbus_regulator_controller {
 	int rc_phandle;
 	const struct fdtbus_regulator_controller_func *rc_funcs;
 
+	u_int rc_enable_ramp_delay;
+
 	LIST_ENTRY(fdtbus_regulator_controller) rc_next;
 };
 
@@ -54,11 +56,13 @@ fdtbus_register_regulator_controller(dev
 {
 	struct fdtbus_regulator_controller *rc;
 
-	rc = kmem_alloc(sizeof(*rc), KM_SLEEP);
+	rc = kmem_zalloc(sizeof(*rc), KM_SLEEP);
 	rc->rc_dev = dev;
 	rc->rc_phandle = phandle;
 	rc->rc_funcs = funcs;
 
+	of_getprop_uint32(phandle, "regulator-enable-ramp-delay", >rc_enable_ramp_delay);
+
 	LIST_INSERT_HEAD(_regulator_controllers, rc, rc_next);
 
 	return 0;
@@ -121,8 +125,16 @@ int
 fdtbus_regulator_enable(struct fdtbus_regulator *reg)
 {
 	struct fdtbus_regulator_controller *rc = reg->reg_rc;
+	int error;
 
-	return rc->rc_funcs->enable(rc->rc_dev, true);
+	error = rc->rc_funcs->enable(rc->rc_dev, true);
+	if (error != 0)
+		return error;
+
+	if (rc->rc_enable_ramp_delay != 0)
+		delay(rc->rc_enable_ramp_delay);
+
+	return 0;
 }
 
 int



CVS commit: src/sys/dev/fdt

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 23:18:33 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_regulator.c

Log Message:
Honour regulator-enable-ramp-delay


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/fdt/fdt_regulator.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:36:08 UTC 2019

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

Log Message:
Adjust regulator voltage at attach time to be between the min and max values 
specified in the dts


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/i2c/axppmic.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/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.19 src/sys/dev/i2c/axppmic.c:1.20
--- src/sys/dev/i2c/axppmic.c:1.19	Mon May 27 21:10:44 2019
+++ src/sys/dev/i2c/axppmic.c	Mon May 27 21:36:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.20 2019/05/27 21:36:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -998,6 +998,7 @@ axpreg_attach(device_t parent, device_t 
 	struct axpreg_attach_args *aaa = aux;
 	const int phandle = aaa->reg_phandle;
 	const char *name;
+	u_int uvol, min_uvol, max_uvol;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = aaa->reg_i2c;
@@ -1013,6 +1014,15 @@ axpreg_attach(device_t parent, device_t 
 		aprint_normal(": %s\n", name);
 	else
 		aprint_normal("\n");
+
+	axpreg_get_voltage(self, );
+	if (of_getprop_uint32(phandle, "regulator-min-microvolt", _uvol) == 0 &&
+	of_getprop_uint32(phandle, "regulator-max-microvolt", _uvol) == 0) {
+		if (uvol < min_uvol || uvol > max_uvol) {
+			aprint_debug_dev(self, "fix voltage %u uV -> %u/%u uV\n", uvol, min_uvol, max_uvol);
+			axpreg_set_voltage(self, min_uvol, max_uvol);
+		}
+	}
 }
 
 CFATTACH_DECL_NEW(axppmic, sizeof(struct axppmic_softc),



CVS commit: src/share/man/man4

2019-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 27 21:19:55 UTC 2019

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

Log Message:
Use Mt for emails.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/userconf.4

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-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 27 21:19:55 UTC 2019

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

Log Message:
Use Mt for emails.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/userconf.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/userconf.4
diff -u src/share/man/man4/userconf.4:1.13 src/share/man/man4/userconf.4:1.14
--- src/share/man/man4/userconf.4:1.13	Mon Jul  3 21:30:58 2017
+++ src/share/man/man4/userconf.4	Mon May 27 21:19:55 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: userconf.4,v 1.13 2017/07/03 21:30:58 wiz Exp $
+.\" $NetBSD: userconf.4,v 1.14 2019/05/27 21:19:55 wiz Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -107,4 +107,4 @@ The
 .Nm
 framework was written by
 .An Mats O Jansson
-.Aq m...@stacken.kth.se .
+.Aq Mt m...@stacken.kth.se .



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:13:29 UTC 2019

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

Log Message:
Add sun8iapbclk, sun9icpusclk, ac100ic


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/sys/arch/evbarm/conf/GENERIC:1.34
--- src/sys/arch/evbarm/conf/GENERIC:1.33	Sun May 26 14:12:34 2019
+++ src/sys/arch/evbarm/conf/GENERIC	Mon May 27 21:13:29 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.33 2019/05/26 14:12:34 jmcneill Exp $
+#	$NetBSD: GENERIC,v 1.34 2019/05/27 21:13:29 jmcneill Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -251,6 +251,8 @@ sun9ia80ccu*	at fdt? pass 2		# Allwinner
 sunxiresets*	at fdt? pass 1		# Allwinner Misc. clock resets
 sunxigates*	at fdt? pass 1		# Allwinner Misc. clock gates
 sunxigmacclk*	at fdt? pass 2		# Allwinner GMAC MII/RGMII clock mux
+sun8iapbclk*	at fdt? pass 2		# Allwinner A23 APB0
+sun9icpusclk*	at fdt? pass 2		# Allwinner A80 CPUS
 sun9immcclk*	at fdt? pass 2		# Allwinner A80 SD/MMC-COMM
 tegra124car*	at fdt? pass 3		# NVIDIA Tegra CAR (T124)
 tegra210car*	at fdt? pass 3		# NVIDIA Tegra CAR (T210)
@@ -421,6 +423,7 @@ tegrai2c*	at fdt? pass 4		# NVIDIA Tegra
 iic*		at i2cbus?
 
 # I2C devices
+ac100ic*	at iic?			# AC100 integrated audio codec and RTC
 as3722pmic*	at iic?
 as3722reg*	at as3722pmic?
 axp20x*		at iic?			# AXP209 Power Management IC



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:13:29 UTC 2019

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

Log Message:
Add sun8iapbclk, sun9icpusclk, ac100ic


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:12:54 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
Added Files:
src/sys/arch/arm/sunxi: sun8i_a23_apbclk.c sun9i_a80_cpusclk.c

Log Message:
Add apb0 and cpus clock drivers for A80


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun8i_a23_apbclk.c \
src/sys/arch/arm/sunxi/sun9i_a80_cpusclk.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/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.62 src/sys/arch/arm/sunxi/files.sunxi:1.63
--- src/sys/arch/arm/sunxi/files.sunxi:1.62	Wed May  8 13:40:14 2019
+++ src/sys/arch/arm/sunxi/files.sunxi	Mon May 27 21:12:54 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.62 2019/05/08 13:40:14 isaki Exp $
+#	$NetBSD: files.sunxi,v 1.63 2019/05/27 21:12:54 jmcneill Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -97,6 +97,16 @@ device	sun9immcclk
 attach	sun9immcclk at fdt with sunxi_a80_mmcclk
 file	arch/arm/sunxi/sun9i_a80_mmcclk.c	sunxi_a80_mmcclk
 
+# CPUS clock driver (A80)
+device	sun9icpusclk
+attach	sun9icpusclk at fdt with sunxi_a80_cpusclk
+file	arch/arm/sunxi/sun9i_a80_cpusclk.c	sunxi_a80_cpusclk
+
+# APB0 clock driver (A80)
+device	sun8iapbclk
+attach	sun8iapbclk at fdt with sunxi_a23_apbclk
+file	arch/arm/sunxi/sun8i_a23_apbclk.c	sunxi_a23_apbclk
+
 # Interrupt controller
 device	sunxiintc: pic, pic_splfuncs
 attach	sunxiintc at fdt with sunxi_intc

Added files:

Index: src/sys/arch/arm/sunxi/sun8i_a23_apbclk.c
diff -u /dev/null src/sys/arch/arm/sunxi/sun8i_a23_apbclk.c:1.1
--- /dev/null	Mon May 27 21:12:54 2019
+++ src/sys/arch/arm/sunxi/sun8i_a23_apbclk.c	Mon May 27 21:12:54 2019
@@ -0,0 +1,182 @@
+/* $NetBSD: sun8i_a23_apbclk.c,v 1.1 2019/05/27 21:12:54 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 AUTHOR ``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 AUTHOR 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: sun8i_a23_apbclk.c,v 1.1 2019/05/27 21:12:54 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define	APB0_DIV	__BITS(1,0)
+
+static int	sun8i_a23_apbclk_match(device_t, cfdata_t, void *);
+static void	sun8i_a23_apbclk_attach(device_t, device_t, void *);
+
+static struct clk *sun8i_a23_apbclk_decode(device_t, int, const void *, size_t);
+
+static const struct fdtbus_clock_controller_func sun8i_a23_apbclk_fdt_funcs = {
+	.decode = sun8i_a23_apbclk_decode
+};
+
+static struct clk *sun8i_a23_apbclk_get(void *, const char *);
+static void	sun8i_a23_apbclk_put(void *, struct clk *);
+static int	sun8i_a23_apbclk_set_rate(void *, struct clk *, u_int);
+static u_int	sun8i_a23_apbclk_get_rate(void *, struct clk *);
+static struct clk *sun8i_a23_apbclk_get_parent(void *, struct clk *);
+
+static const struct clk_funcs sun8i_a23_apbclk_clk_funcs = {
+	.get = sun8i_a23_apbclk_get,
+	.put = sun8i_a23_apbclk_put,
+	.set_rate = sun8i_a23_apbclk_set_rate,
+	.get_rate = sun8i_a23_apbclk_get_rate,
+	.get_parent = sun8i_a23_apbclk_get_parent,
+};
+
+struct sun8i_a23_apbclk_softc {
+	device_t		sc_dev;
+	int			sc_phandle;
+	bus_space_tag_t		sc_bst;
+	bus_space_handle_t	sc_bsh;
+
+	struct clk_domain	sc_clkdom;
+	struct clk		sc_clk;
+	struct clk		*sc_parent;
+};
+
+#define	RD4(sc, reg)			\
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define	WR4(sc, reg, val)		\
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+
+CFATTACH_DECL_NEW(sunxi_a23_apbclk, sizeof(struct sun8i_a23_apbclk_softc),
+sun8i_a23_apbclk_match, 

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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:12:54 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
Added Files:
src/sys/arch/arm/sunxi: sun8i_a23_apbclk.c sun9i_a80_cpusclk.c

Log Message:
Add apb0 and cpus clock drivers for A80


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun8i_a23_apbclk.c \
src/sys/arch/arm/sunxi/sun9i_a80_cpusclk.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:11:13 UTC 2019

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

Log Message:
FDT-ize AC100 driver


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/ac100.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/ac100.c
diff -u src/sys/dev/i2c/ac100.c:1.2 src/sys/dev/i2c/ac100.c:1.3
--- src/sys/dev/i2c/ac100.c:1.2	Sat Jun 16 21:22:13 2018
+++ src/sys/dev/i2c/ac100.c	Mon May 27 21:11:13 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
+/* $NetBSD: ac100.c,v 1.3 2019/05/27 21:11:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -26,8 +26,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_fdt.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.3 2019/05/27 21:11:13 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.
 
 #include 
 
+#ifdef FDT
+#include 
+#endif
+
 #define AC100_CHIP_AUDIO_RST_REG	0x00
 #define AC100_PLL_CTRL1_REG		0x02
 #define AC100_PLL_CTRL2_REG		0x03
@@ -86,6 +92,11 @@ __KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.
 
 #define AC100_RTC_UPD_TRIG_WRITE	__BIT(15)
 
+static const struct device_compatible_entry compat_data[] = {
+	{ "x-powers,ac100",		0 },
+	{ NULL,0 }
+};
+
 struct ac100_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
@@ -109,7 +120,15 @@ CFATTACH_DECL_NEW(ac100ic, sizeof(struct
 static int
 ac100_match(device_t parent, cfdata_t match, void *aux)
 {
-	return I2C_MATCH_ADDRESS_ONLY;	/* XXX */
+	struct i2c_attach_args *ia = aux;
+	int match_result;
+
+	if (iic_use_direct_match(ia, match, compat_data, _result))
+		return match_result;
+
+	/* This device is direct-config only. */
+
+	return 0;
 }
 
 static void
@@ -132,7 +151,15 @@ ac100_attach(device_t parent, device_t s
 	sc->sc_todr.todr_gettime_ymdhms = ac100_rtc_gettime;
 	sc->sc_todr.todr_settime_ymdhms = ac100_rtc_settime;
 	sc->sc_todr.cookie = sc;
+
+#ifdef FDT
+	const int phandle = ia->ia_cookie;
+	const int rtc_phandle = of_find_firstchild_byname(phandle, "rtc");
+	if (rtc_phandle > 0)
+		fdtbus_todr_attach(self, rtc_phandle, >sc_todr);
+#else
 	todr_attach(>sc_todr);
+#endif
 }
 
 static int



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:11:51 UTC 2019

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

Log Message:
Add A80 support


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_nmi.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/sunxi_nmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_nmi.c:1.1 src/sys/arch/arm/sunxi/sunxi_nmi.c:1.2
--- src/sys/arch/arm/sunxi/sunxi_nmi.c:1.1	Wed May  2 21:20:20 2018
+++ src/sys/arch/arm/sunxi/sunxi_nmi.c	Mon May 27 21:11:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_nmi.c,v 1.1 2018/05/02 21:20:20 jmcneill Exp $ */
+/* $NetBSD: sunxi_nmi.c,v 1.2 2019/05/27 21:11:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -29,7 +29,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_nmi.c,v 1.1 2018/05/02 21:20:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_nmi.c,v 1.2 2019/05/27 21:11:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -78,9 +78,17 @@ static const struct sunxi_nmi_config sun
 	.enable_reg = 0x40,
 };
 
+static const struct sunxi_nmi_config sun9i_a80_nmi_config = {
+	.name = "NMI",
+	.ctrl_reg = 0x00,
+	.pend_reg = 0x04,
+	.enable_reg = 0x08,
+};
+
 static const struct of_compat_data compat_data[] = {
 	{ "allwinner,sun7i-a20-sc-nmi",	(uintptr_t)_a20_sc_nmi_config },
 	{ "allwinner,sun6i-a31-r-intc",	(uintptr_t)_a31_r_intc_config },
+	{ "allwinner,sun9i-a80-nmi",	(uintptr_t)_a80_nmi_config },
 	{ NULL }
 };
 



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

2019-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:11:51 UTC 2019

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

Log Message:
Add A80 support


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_nmi.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:10:44 UTC 2019

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

Log Message:
Add support for AXP806


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/i2c/axppmic.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-05-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May 27 21:10:44 UTC 2019

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

Log Message:
Add support for AXP806


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/i2c/axppmic.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/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.18 src/sys/dev/i2c/axppmic.c:1.19
--- src/sys/dev/i2c/axppmic.c:1.18	Wed Jan  2 18:38:03 2019
+++ src/sys/dev/i2c/axppmic.c	Mon May 27 21:10:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.18 2019/01/02 18:38:03 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.18 2019/01/02 18:38:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.19 2019/05/27 21:10:44 jmcneill Exp $");
 
 #include 
 #include 
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 
 #define	 AXP_POWER_MODE_BATT_PRESENT	__BIT(5)
 #define	 AXP_POWER_MODE_BATT_CHARGING	__BIT(6)
 
+#define	AXP_CHIP_ID_REG		0x03
+
 #define AXP_POWER_DISABLE_REG	0x32
 #define	 AXP_POWER_DISABLE_CTRL	__BIT(7)
 
@@ -98,6 +100,10 @@ __KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 
 #define	 AXP_BATT_CAP_WARN_LV1	__BITS(7,4)
 #define	 AXP_BATT_CAP_WARN_LV2	__BITS(3,0)
 
+#define	AXP_ADDR_EXT_REG	0xff	/* AXP806 */
+#define	 AXP_ADDR_EXT_MASTER	0
+#define	 AXP_ADDR_EXT_SLAVE	__BIT(4)
+
 struct axppmic_ctrl {
 	device_t	c_dev;
 
@@ -258,6 +264,7 @@ struct axppmic_config {
 	u_int irq_regs;
 	bool has_battery;
 	bool has_fuel_gauge;
+	bool has_mode_set;
 	struct axppmic_irq poklirq;
 	struct axppmic_irq acinirq;
 	struct axppmic_irq vbusirq;
@@ -339,11 +346,22 @@ static const struct axppmic_config axp80
 };
 
 static const struct axppmic_config axp805_config = {
-	.name = "AXP805/806",
+	.name = "AXP805",
+	.controls = axp805_ctrls,
+	.ncontrols = __arraycount(axp805_ctrls),
+	.irq_regs = 2,
+	.poklirq = AXPPMIC_IRQ(2, __BIT(0)),
+};
+
+static const struct axppmic_config axp806_config = {
+	.name = "AXP806",
 	.controls = axp805_ctrls,
 	.ncontrols = __arraycount(axp805_ctrls),
+#if notyet
 	.irq_regs = 2,
 	.poklirq = AXPPMIC_IRQ(2, __BIT(0)),
+#endif
+	.has_mode_set = true,
 };
 
 static const struct axppmic_config axp813_config = {
@@ -369,7 +387,7 @@ static const struct axppmic_config axp81
 static const struct device_compatible_entry compat_data[] = {
 	{ "x-powers,axp803",		(uintptr_t)_config },
 	{ "x-powers,axp805",		(uintptr_t)_config },
-	{ "x-powers,axp806",		(uintptr_t)_config },
+	{ "x-powers,axp806",		(uintptr_t)_config },
 	{ "x-powers,axp813",		(uintptr_t)_config },
 	{ NULL,0 }
 };
@@ -808,7 +826,8 @@ axppmic_attach(device_t parent, device_t
 	struct axpreg_attach_args aaa;
 	struct i2c_attach_args *ia = aux;
 	int phandle, child, i;
-	uint32_t irq_mask;
+	uint8_t irq_mask, val;
+	int error;
 	void *ih;
 
 	(void) iic_compatible_match(ia, compat_data, );
@@ -824,33 +843,54 @@ axppmic_attach(device_t parent, device_t
 	aprint_naive("\n");
 	aprint_normal(": %s\n", c->name);
 
-	sc->sc_smpsw.smpsw_name = device_xname(self);
-	sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_POWER;
-	sysmon_pswitch_register(>sc_smpsw);
+	if (c->has_mode_set) {
+		const bool master_mode = of_hasprop(sc->sc_phandle, "x-powers,self-working-mode") ||
+		of_hasprop(sc->sc_phandle, "x-powers,master-mode");
+
+		iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+		axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_ADDR_EXT_REG,
+		master_mode ? AXP_ADDR_EXT_MASTER : AXP_ADDR_EXT_SLAVE, I2C_F_POLL);
+		iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+	}
 
 	iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
-	for (i = 1; i <= c->irq_regs; i++) {
-		irq_mask = 0;
-		if (i == c->poklirq.reg)
-			irq_mask |= c->poklirq.mask;
-		if (i == c->acinirq.reg)
-			irq_mask |= c->acinirq.mask;
-		if (i == c->vbusirq.reg)
-			irq_mask |= c->vbusirq.mask;
-		if (i == c->battirq.reg)
-			irq_mask |= c->battirq.mask;
-		if (i == c->chargeirq.reg)
-			irq_mask |= c->chargeirq.mask;
-		if (i == c->chargestirq.reg)
-			irq_mask |= c->chargestirq.mask;
-		axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_IRQ_ENABLE_REG(i), irq_mask, I2C_F_POLL);
-	}
+	error = axppmic_read(sc->sc_i2c, sc->sc_addr, AXP_CHIP_ID_REG, , I2C_F_POLL);
 	iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+	if (error != 0) {
+		aprint_error_dev(self, "couldn't read chipid\n");
+		return;
+	}
+	aprint_debug_dev(self, "chipid %#x\n", val);
 
-	ih = fdtbus_intr_establish(sc->sc_phandle, 0, IPL_VM, FDT_INTR_MPSAFE,
-	axppmic_intr, sc);
-	if (ih == NULL) {
-		aprint_error_dev(self, "WARNING: couldn't establish interrupt handler\n");
+	sc->sc_smpsw.smpsw_name = device_xname(self);
+	sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_POWER;
+	sysmon_pswitch_register(>sc_smpsw);
+
+	if (c->irq_regs > 0) {
+		iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+		for 

CVS commit: src/sys/arch/x86/x86

2019-05-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May 27 18:36:37 UTC 2019

Modified Files:
src/sys/arch/x86/x86: cpu.c pmap.c svs.c

Log Message:
Change the effect of SVS on the TLB. Keep CR4_PGE set when SVS is enabled,
but don't use PTE_G on the kernel PTEs in general.

Add PTE_G on only a few pages, that are already leaked to userland and do
not contain secrets.

This slightly improves syscall performance.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.332 -r1.333 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x86/x86/svs.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/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.169 src/sys/arch/x86/x86/cpu.c:1.170
--- src/sys/arch/x86/x86/cpu.c:1.169	Mon May 27 17:32:36 2019
+++ src/sys/arch/x86/x86/cpu.c	Mon May 27 18:36:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.169 2019/05/27 17:32:36 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.170 2019/05/27 18:36:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.169 2019/05/27 17:32:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.170 2019/05/27 18:36:37 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -586,9 +586,6 @@ cpu_init(struct cpu_info *ci)
 
 	/* If global TLB caching is supported, enable it */
 	if (cpu_feature[0] & CPUID_PGE)
-#ifdef SVS
-		if (!svs_enabled)
-#endif
 		cr4 |= CR4_PGE;
 
 	/*

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.332 src/sys/arch/x86/x86/pmap.c:1.333
--- src/sys/arch/x86/x86/pmap.c:1.332	Mon May 27 17:32:36 2019
+++ src/sys/arch/x86/x86/pmap.c	Mon May 27 18:36:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.332 2019/05/27 17:32:36 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.333 2019/05/27 18:36:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.332 2019/05/27 17:32:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.333 2019/05/27 18:36:37 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1117,12 +1117,17 @@ pmap_bootstrap(vaddr_t kva_start)
 #if !defined(XENPV)
 	/*
 	 * Begin to enable global TLB entries if they are supported: add PTE_G
-	 * attribute to already mapped kernel pages.
+	 * attribute to already mapped kernel pages. Do that only if SVS is
+	 * disabled.
 	 *
 	 * The G bit has no effect until the CR4_PGE bit is set in CR4, which
 	 * happens later in cpu_init().
 	 */
+#ifdef SVS
+	if (!svs_enabled && (cpu_feature[0] & CPUID_PGE)) {
+#else
 	if (cpu_feature[0] & CPUID_PGE) {
+#endif
 		pmap_pg_g = PTE_G;
 		pmap_remap_global();
 	}

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.27 src/sys/arch/x86/x86/svs.c:1.28
--- src/sys/arch/x86/x86/svs.c:1.27	Mon May 27 17:32:36 2019
+++ src/sys/arch/x86/x86/svs.c	Mon May 27 18:36:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.27 2019/05/27 17:32:36 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.28 2019/05/27 18:36:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.27 2019/05/27 17:32:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.28 2019/05/27 18:36:37 maxv Exp $");
 
 #include "opt_svs.h"
 
@@ -268,7 +268,7 @@ svs_tree_add(struct cpu_info *ci, vaddr_
 }
 
 static void
-svs_page_add(struct cpu_info *ci, vaddr_t va)
+svs_page_add(struct cpu_info *ci, vaddr_t va, bool global)
 {
 	pd_entry_t *srcpde, *dstpde, pde;
 	size_t idx, pidx;
@@ -289,9 +289,10 @@ svs_page_add(struct cpu_info *ci, vaddr_
 		panic("%s: L2 page not mapped", __func__);
 	}
 	if (srcpde[idx] & PTE_PS) {
+		KASSERT(!global);
 		pa = srcpde[idx] & PTE_2MFRAME;
 		pa += (paddr_t)(va % NBPD_L2);
-		pde = (srcpde[idx] & ~(PTE_G|PTE_PS|PTE_2MFRAME)) | pa;
+		pde = (srcpde[idx] & ~(PTE_PS|PTE_2MFRAME)) | pa;
 
 		if (pmap_valid_entry(dstpde[pidx])) {
 			panic("%s: L1 page already mapped", __func__);
@@ -311,7 +312,17 @@ svs_page_add(struct cpu_info *ci, vaddr_
 	if (pmap_valid_entry(dstpde[pidx])) {
 		panic("%s: L1 page already mapped", __func__);
 	}
-	dstpde[pidx] = srcpde[idx] & ~(PTE_G);
+	dstpde[pidx] = srcpde[idx];
+
+	/*
+	 * If we want a global translation, mark both the src and dst with
+	 * PTE_G.
+	 */
+	if (global) {
+		srcpde[idx] |= PTE_G;
+		dstpde[pidx] |= PTE_G;
+		tlbflushg();
+	}
 }
 
 static void
@@ -394,14 +405,14 @@ svs_utls_init(struct cpu_info *ci)
 }
 
 static void
-svs_range_add(struct cpu_info *ci, vaddr_t va, size_t size)
+svs_range_add(struct cpu_info *ci, vaddr_t va, size_t size, bool global)
 {
 	size_t i, n;
 
 	KASSERT(size % PAGE_SIZE == 0);
 	n = size / PAGE_SIZE;
 	for (i = 0; i < n; i++) {
-		

CVS commit: src/sys/arch/x86/x86

2019-05-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May 27 18:36:37 UTC 2019

Modified Files:
src/sys/arch/x86/x86: cpu.c pmap.c svs.c

Log Message:
Change the effect of SVS on the TLB. Keep CR4_PGE set when SVS is enabled,
but don't use PTE_G on the kernel PTEs in general.

Add PTE_G on only a few pages, that are already leaked to userland and do
not contain secrets.

This slightly improves syscall performance.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.332 -r1.333 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x86/x86/svs.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

2019-05-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May 27 17:32:36 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: genassym.cf
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: cpu.c pmap.c svs.c x86_tlb.c

Log Message:
Remove 'ci_svs_kpdirpa', unused. While here fix a few comments here and
there, reduces a future diff.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.168 -r1.169 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.331 -r1.332 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/x86/x86_tlb.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

2019-05-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May 27 17:32:36 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: genassym.cf
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: cpu.c pmap.c svs.c x86_tlb.c

Log Message:
Remove 'ci_svs_kpdirpa', unused. While here fix a few comments here and
there, reduces a future diff.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.168 -r1.169 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.331 -r1.332 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/x86/x86_tlb.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/amd64/amd64/genassym.cf
diff -u src/sys/arch/amd64/amd64/genassym.cf:1.74 src/sys/arch/amd64/amd64/genassym.cf:1.75
--- src/sys/arch/amd64/amd64/genassym.cf:1.74	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/amd64/amd64/genassym.cf	Mon May 27 17:32:36 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.74 2019/02/15 08:54:01 nonaka Exp $
+#	$NetBSD: genassym.cf,v 1.75 2019/05/27 17:32:36 maxv Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -236,7 +236,6 @@ define	CPU_INFO_PMAP		offsetof(struct cp
 define	CPU_INFO_TSS		offsetof(struct cpu_info, ci_tss)
 ifdef SVS
 define	CPU_INFO_UPDIRPA	offsetof(struct cpu_info, ci_svs_updirpa)
-define	CPU_INFO_KPDIRPA	offsetof(struct cpu_info, ci_svs_kpdirpa)
 define	CPU_INFO_RSP0		offsetof(struct cpu_info, ci_svs_rsp0)
 define	CPU_INFO_URSP0		offsetof(struct cpu_info, ci_svs_ursp0)
 define	CPU_INFO_KRSP0		offsetof(struct cpu_info, ci_svs_krsp0)

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.105 src/sys/arch/x86/include/cpu.h:1.106
--- src/sys/arch/x86/include/cpu.h:1.105	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/x86/include/cpu.h	Mon May 27 17:32:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.105 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: cpu.h,v 1.106 2019/05/27 17:32:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -245,7 +245,7 @@ struct cpu_info {
 #ifdef SVS
 	pd_entry_t *	ci_svs_updir;
 	paddr_t		ci_svs_updirpa;
-	paddr_t		ci_svs_kpdirpa;
+	paddr_t		ci_unused;
 	kmutex_t	ci_svs_mtx;
 	pd_entry_t *	ci_svs_rsp0_pte;
 	vaddr_t		ci_svs_rsp0;

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.168 src/sys/arch/x86/x86/cpu.c:1.169
--- src/sys/arch/x86/x86/cpu.c:1.168	Sat Mar  9 08:42:26 2019
+++ src/sys/arch/x86/x86/cpu.c	Mon May 27 17:32:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.168 2019/03/09 08:42:26 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.169 2019/05/27 17:32:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.168 2019/03/09 08:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.169 2019/05/27 17:32:36 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -584,15 +584,12 @@ cpu_init(struct cpu_info *ci)
 
 	lcr0(rcr0() | CR0_WP);
 
-	/*
-	 * On a P6 or above, enable global TLB caching if the
-	 * hardware supports it.
-	 */
+	/* If global TLB caching is supported, enable it */
 	if (cpu_feature[0] & CPUID_PGE)
 #ifdef SVS
 		if (!svs_enabled)
 #endif
-		cr4 |= CR4_PGE;	/* enable global TLB caching */
+		cr4 |= CR4_PGE;
 
 	/*
 	 * If we have FXSAVE/FXRESTOR, use them.

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.331 src/sys/arch/x86/x86/pmap.c:1.332
--- src/sys/arch/x86/x86/pmap.c:1.331	Tue Mar 12 08:29:52 2019
+++ src/sys/arch/x86/x86/pmap.c	Mon May 27 17:32:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.331 2019/03/12 08:29:52 gson Exp $	*/
+/*	$NetBSD: pmap.c,v 1.332 2019/05/27 17:32:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.331 2019/03/12 08:29:52 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.332 2019/05/27 17:32:36 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1116,15 +1116,14 @@ pmap_bootstrap(vaddr_t kva_start)
 
 #if !defined(XENPV)
 	/*
-	 * Begin to enable global TLB entries if they are supported.
-	 * The G bit has no effect until the CR4_PGE bit is set in CR4,
-	 * which happens in cpu_init(), which is run on each cpu
-	 * (and happens later)
+	 * Begin to enable global TLB entries if they are supported: add PTE_G
+	 * attribute to already mapped kernel pages.
+	 *
+	 * The G bit has no effect until the CR4_PGE bit is set in CR4, which
+	 * happens later in cpu_init().
 	 */
 	if (cpu_feature[0] & CPUID_PGE) {
-		pmap_pg_g = PTE_G;		/* enable software */
-
-		/* add PTE_G attribute to already mapped kernel pages */
+		

CVS commit: src/share/misc

2019-05-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon May 27 16:54:38 UTC 2019

Modified Files:
src/share/misc: acronyms

Log Message:
GCD


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/share/misc/acronyms

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



CVS commit: src/share/misc

2019-05-27 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon May 27 16:54:38 UTC 2019

Modified Files:
src/share/misc: acronyms

Log Message:
GCD


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/share/misc/acronyms

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

Modified files:

Index: src/share/misc/acronyms
diff -u src/share/misc/acronyms:1.282 src/share/misc/acronyms:1.283
--- src/share/misc/acronyms:1.282	Fri May 24 10:08:46 2019
+++ src/share/misc/acronyms	Mon May 27 16:54:38 2019
@@ -1,4 +1,4 @@
-$NetBSD: acronyms,v 1.282 2019/05/24 10:08:46 sevan Exp $
+$NetBSD: acronyms,v 1.283 2019/05/27 16:54:38 sevan Exp $
 10Q	thank you
 10X	thanks
 1337	elite ("leet")
@@ -186,6 +186,7 @@ GA	go ahead
 GAC	get a clue
 GAL	get a life
 GBTW	get back to work
+GCD	greatest common divisor
 GDPR	General Data Protection Regulation
 GF	girlfriend
 GFU	good for you



Re: audio2

2019-05-27 Thread Taylor R Campbell
> Date: Mon, 27 May 2019 22:28:37 +0900
> From: Tetsuya Isaki 
> 
> At Sat, 25 May 2019 18:01:11 +0300,
> Valery Ushakov wrote:
> > My point is exactly that you are confusing implementation detail that
> > uses right shift as a good enough implementation (which, I reiterate,
> > I don't object to here) and what is the meaning of the operation that
> > you are implementing/approximating (see my first paragraph above).
> 
> I'm sorry, I don't understand (I can't parse) this paragraph
> due to my poor English skill.  Would you write it again?
> 
> And anyway I don't understand your point well.  Can you show me
> your proposal patch?

Hi, Isaki-san!

As I understand it, uwe is just asking you to use a different name,
because `AUDIO_ASR' suggests only one particular approximation, and
it's not even the one that the code always uses.  Perhaps
`AUDIO_SCALEDOWN' would be clearer?


In more detail:

- Mathematically, the function is used to scale an amplitude x down by
  2^n:

f_n(x) = x/2^n.

  This function has the property that f_n(-x) = -f_n(x), i.e. f_n is
  an odd function.

- In digital audio, we approximate this real-valued function f_n(x)
  with integer arithmetic.  We have a couple choices for how to do
  this:

  . truncate(x/2^n), which is also an odd function.

  . floor(x/2^n), which is _not_ an odd function, and so is maybe not
as good an approximation.

  On platforms where floor(x/2^n) can be computed more efficiently, by
  doing x >> n, than truncate(x/2^n), i.e. x/(1 << n), then that's OK:
  being off by one in this approximation, under negation, is not very
  bad.

- Whichever approximation we choose, we should _name_ the function for
  the mathematical operation it approximates, which is scaling an
  amplitude down, not for one of the approximations it _might_ use.
  Calling it AUDIO_ASR seems wrong because:

  . the main purpose is to use _some_ approximation to scale an
amplitude down -- it is an implementation detail that it sometimes
approximates the mathematical function by a right shift;

  . the function doesn't necessarily always compute floor(x/2^n) --
that is, the function you have named AUDIO_ASR doesn't necessarily
shift right.

  Maybe we could call it AUDIO_SCALEDOWN or something instead?


Re: audio2

2019-05-27 Thread Tetsuya Isaki
At Sat, 25 May 2019 18:01:11 +0300,
Valery Ushakov wrote:
> Speaking in the abstract: The operation that happens here is
> rescaling, as far as I understand.  Yes, the two-complement ranges are
> lopsided with an extra value on the negative side, but that is far
> less important, I think, than commuting with negation.  If you negate
> all samples, you have basically the same audio
> https://manual.audacityteam.org/man/invert.html ("invert" is a bit
> unfortuante as a name b/c of the confusion with the bitwise
> operation), so it's nice to have:
> 
> -scaleN(sample) = scaleN(-sample)

Partially, yes.  If I make an userland offline waveform editing
software on modern arch, and the output wave can be used as another
input, I may do so.

But this is in-kernel online(realtime) processing including m68k and
the output is final stage that human hear.

> > The correct operation is not exist whenever rounding to integer
> > occurs.
> >
> > And in audio area, we need to understand that both rounding
> > are not correct but are acceptable.
> 
> I think you are confusing correctness and precision here.

What is your correctness and precision here?

> My point is exactly that you are confusing implementation detail that
> uses right shift as a good enough implementation (which, I reiterate,
> I don't object to here) and what is the meaning of the operation that
> you are implementing/approximating (see my first paragraph above).

I'm sorry, I don't understand (I can't parse) this paragraph
due to my poor English skill.  Would you write it again?

And anyway I don't understand your point well.  Can you show me
your proposal patch?

Thanks,
---
Tetsuya Isaki 


CVS commit: src/include

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 27 07:31:11 UTC 2019

Modified Files:
src/include: assert.h

Log Message:
As a _NETBSD_SOURCE extension define static_assert for pre-c11/c++99

Proposed on source-changes-d.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/include/assert.h

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



CVS commit: src/include

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 27 07:31:11 UTC 2019

Modified Files:
src/include: assert.h

Log Message:
As a _NETBSD_SOURCE extension define static_assert for pre-c11/c++99

Proposed on source-changes-d.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/include/assert.h

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

Modified files:

Index: src/include/assert.h
diff -u src/include/assert.h:1.23 src/include/assert.h:1.24
--- src/include/assert.h:1.23	Wed May 22 21:25:01 2019
+++ src/include/assert.h	Mon May 27 07:31:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: assert.h,v 1.23 2019/05/22 21:25:01 maya Exp $	*/
+/*	$NetBSD: assert.h,v 1.24 2019/05/27 07:31:11 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -105,8 +105,10 @@ void __diagassert13(const char *, int, c
 __END_DECLS
 #endif /* __ASSERT_DECLARED */
 
-#if defined(_ISOC11_SOURCE) || (__STDC_VERSION__ - 0) >= 201101L
 #ifndef static_assert
+#if defined(_ISOC11_SOURCE) || (__STDC_VERSION__ - 0) >= 201101L
 #define static_assert _Static_assert
+#elif defined(_NETBSD_SOURCE) && (__cplusplus - 0) < 201103L
+#define static_assert(x, y) __CTASSERT(x)
 #endif /* static_assert */
 #endif