Re: CVS commit: src/sys/arch/sparc64/dev

2020-10-24 Thread Tobias Nygren
On Sat, 24 Oct 2020 15:16:39 +
Julian Coleman  wrote:

> Module Name:  src
> Committed By: jdc
> Date: Sat Oct 24 15:16:39 UTC 2020
> 
> Modified Files:
>   src/sys/arch/sparc64/dev: pcf8591_envctrl.c
> 
> Log Message:
> Add support for automatically changing the CPU fan speed on the E250 in a
> similar way to the SB1000/SB2000.
> The fan control information was determined by experiment, as it's only
> partially available in OFW.
> Hardcode the missing information for E250 fan control into the driver
> (it should be possible to support the E450 in future too).

If you're interested there is an older version[1] of envctrl in the
Attic that might be relevant to use for reference. It supported fan
speed controls on E450. IIRC I got some of the magic constants from
OpenSolaris. Sadly I don't own an E450 any more.

[1] 
cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/sparc64/dev/Attic/envctrl.c?rev=1.11=text/plain_with_tag=MAIN


Re: CVS commit: src

2020-09-22 Thread Tobias Nygren
On Tue, 22 Sep 2020 23:52:38 +
Taylor R Campbell  wrote:

> > Date: Wed, 23 Sep 2020 01:46:14 +0200
> > From: Tobias Nygren 
> > 
> > > Modified Files:
> > >   src/include: unistd.h
> > >   src/lib/libc/gen: Makefile.inc
> > > Removed Files:
> > >   src/lib/libc/gen: getentropy.3 getentropy.c
> > > 
> > > Log Message:
> > > remove getentropy bits
> > 
> > I know it is -current but undiscussed ABI breakage in libc still does
> > make me raise an eyebrow. A heads-up including a summary of the reason
> > for the change would have been nice.
> 
> This change does not break any ABI because getentropy.c was not
> included in the build.  All that is being removed here is the man page
> and the unused source code.

Cool, then I don't have any concerns. Thanks!


Re: CVS commit: src

2020-09-22 Thread Tobias Nygren
Hi,

On Tue, 22 Sep 2020 21:37:47 +
Nia Alarie  wrote:

> Module Name:  src
> Committed By: nia
> Date: Tue Sep 22 21:37:47 UTC 2020
> 
> Modified Files:
>   src/include: unistd.h
>   src/lib/libc/gen: Makefile.inc
> Removed Files:
>   src/lib/libc/gen: getentropy.3 getentropy.c
> 
> Log Message:
> remove getentropy bits

I know it is -current but undiscussed ABI breakage in libc still does
make me raise an eyebrow. A heads-up including a summary of the reason
for the change would have been nice.

Kind regards,
-Tobias



Re: CVS commit: src/external/bsd/ntp/bin/ntpd

2020-05-29 Thread Tobias Nygren
On Fri, 29 May 2020 16:08:30 +0200
Joerg Sonnenberger  wrote:

> On Fri, May 29, 2020 at 10:53:02AM +, Kamil Rytarowski wrote:
> > Module Name:src
> > Committed By:   kamil
> > Date:   Fri May 29 10:53:02 UTC 2020
> > 
> > Modified Files:
> > src/external/bsd/ntp/bin/ntpd: Makefile
> > 
> > Log Message:
> > Fix the ntpd build with Clang/LLVM
> > 
> > Set -Wno-format-nonliteral for ntp_refclock.c
> 
> Please fix this properly by adding the appropiate format string
> annotation.

I have these in my local tree. Can't reach cvs.
Feel free to commit them if appropriate.

Index: external/bsd/ntp/dist/libntp/timexsup.c
===
RCS file: /cvsroot/src/external/bsd/ntp/dist/libntp/timexsup.c,v
retrieving revision 1.2
diff -p -u -r1.2 timexsup.c
--- external/bsd/ntp/dist/libntp/timexsup.c 25 May 2020 20:47:24 -  
1.2
+++ external/bsd/ntp/dist/libntp/timexsup.c 29 May 2020 14:13:35 -
@@ -30,8 +30,8 @@ clamp_rounded(
dval = floor(dval + 0.5);
 
/* clamp / saturate */
-   if (dval >= LONG_MAX)
-   return LONG_MAX;
+   if (dval >= (double)LONG_MAX)
+   return (double)LONG_MAX;
if (dval <= LONG_MIN)
return LONG_MIN;
return (long)dval;
Index: external/bsd/ntp/dist/ntpd/ntp_refclock.c
===
RCS file: /cvsroot/src/external/bsd/ntp/dist/ntpd/ntp_refclock.c,v
retrieving revision 1.13
diff -p -u -r1.13 ntp_refclock.c
--- external/bsd/ntp/dist/ntpd/ntp_refclock.c   25 May 2020 20:47:25 -  
1.13
+++ external/bsd/ntp/dist/ntpd/ntp_refclock.c   29 May 2020 14:13:37 -
@@ -1737,7 +1737,7 @@ refclock_save_lcode(
 }
 
 /* format data into a_lastcode */
-void
+void __printflike(2, 0)
 refclock_vformat_lcode(
struct refclockproc *   pp,
char const *fmt,
@@ -1757,7 +1757,7 @@ refclock_vformat_lcode(
/* !note! the NUL byte is needed in case vsnprintf() really fails */
 }
 
-void
+void __printflike(2, 0)
 refclock_format_lcode(
struct refclockproc *   pp,
char const *fmt,


Re: CVS commit: [netbsd-9] src/sys

2020-03-09 Thread Tobias Nygren
On Sun, 8 Mar 2020 10:54:43 +
Martin Husemann  wrote:

> Pull up following revision(s) (requested by pgoyette in ticket #762):
> cvs rdiff -u -r1.121 -r1.121.2.1 src/sys/arch/amd64/amd64/trap.c

Hi,

Someone reported on IRC that this seems to have become mismerged:

/usr/src/sys/arch/amd64/amd64/trap.c: In function 'trap':
/usr/src/sys/arch/amd64/amd64/trap.c:360:2: error: expected expression before 
'}' token

1.107 christos  356:
1.121.2.1! martin   357:MODULE_HOOK_CALL(amd64_oosyscall_hook, 
(p, frame),
!   358:ENOSYS, hook_ret);
!   359:if (hook_ret == 0)
1.107 christos  360:}
1.116 mrg   361:/* FALLTHROUGH */


Re: CVS commit: src [llvm]

2019-11-13 Thread Tobias Nygren
On Tue, 12 Nov 2019 23:10:45 +0100
Joerg Sonnenberger  wrote:

> On Tue, Nov 12, 2019 at 04:31:00PM +0100, Maxime Villard wrote:
> > Le 12/11/2019 à 16:06, Maxime Villard a écrit :
> > > Le 12/11/2019 à 14:37, Joerg Sonnenberger a écrit :
> > > > On Tue, Nov 12, 2019 at 11:39:09AM +0100, Maxime Villard wrote:
> > > > > Le 11/11/2019 à 23:45, Joerg Sonnenberger a écrit :
> > > > > > Module Name:    src
> > > > > > Committed By:    joerg
> > > > > > Date:    Mon Nov 11 22:45:32 UTC 2019
> > > > > > 
> > > > > > [...]
> > > > > > Log Message:
> > > > > > Update LLVM to 10.0.0git (01f3a59fb3e2542fce74c768718f594d0debd0da)
> > > > > 
> > > > > Since this change, I cannot cross-compile GENERIC amd64 from Linux:
> > > > 
> > > > What non-standard settings are you using? amd64 is certainly on my list
> > > > of architectures to test.
> > > 
> > > No particular settings. Just the latest src/ compiled unchanged with
> > > 
> > > ./build.sh -j4 -U -O ../obj -V MKLLVM=yes -V MKGCC=no -V HAVE_LLVM=yes -m 
> > > amd64 kernel=GENERIC
> > 
> > I'm also having the same issue on a NetBSD-amd64 host, with again an 
> > unchanged
> > src/ and the same command
> 
> Is that a clean build? I certainly do full release builds for all LLVM
> architectures and I don't get this.

I was able to reproduce the problem by building in a NetBSD-9 chroot
with a GCC host toolchain, but not with my -current LLVM host
toolchain. I wonder if GCC miscompiles something.


Re: CVS commit: src [llvm]

2019-11-13 Thread Tobias Nygren
On Wed, 13 Nov 2019 10:29:52 +0100
Maxime Villard  wrote:

> Am I the only one seeing this? It's hard to blame the configuration when the
> failure is seen on several hardware and several OSes.

FWIW I'm typing this from an x86_64 machine running today's LLVM
userland and kernel. I have some local patches but none that should be
relevant.


CVS commit: src/external/bsd/blacklist/lib

2019-11-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Nov 11 09:24:56 UTC 2019

Modified Files:
src/external/bsd/blacklist/lib: blacklist.c

Log Message:
silence sign-conversion warning from clang


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/blacklist/lib/blacklist.c

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



CVS commit: src/external/bsd/blacklist/lib

2019-11-11 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Nov 11 09:24:56 UTC 2019

Modified Files:
src/external/bsd/blacklist/lib: blacklist.c

Log Message:
silence sign-conversion warning from clang


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/blacklist/lib/blacklist.c

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

Modified files:

Index: src/external/bsd/blacklist/lib/blacklist.c
diff -u src/external/bsd/blacklist/lib/blacklist.c:1.6 src/external/bsd/blacklist/lib/blacklist.c:1.7
--- src/external/bsd/blacklist/lib/blacklist.c:1.6	Wed Nov  6 20:50:01 2019
+++ src/external/bsd/blacklist/lib/blacklist.c	Mon Nov 11 09:24:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: blacklist.c,v 1.6 2019/11/06 20:50:01 christos Exp $	*/
+/*	$NetBSD: blacklist.c,v 1.7 2019/11/11 09:24:56 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: blacklist.c,v 1.6 2019/11/06 20:50:01 christos Exp $");
+__RCSID("$NetBSD: blacklist.c,v 1.7 2019/11/11 09:24:56 tnn Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ int
 blacklist_sa_r(struct blacklist *bl, int action, int rfd,
 	const struct sockaddr *sa, socklen_t slen, const char *msg)
 {
-	int internal_action;
+	bl_type_t internal_action;
 
 	/* internal values are not the same as user application values */
 	switch (action) {



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

2019-11-09 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  9 17:21:48 UTC 2019

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

Log Message:
rk_gmac: clean up code for setting up clock delay lines a bit

- break long lines
- move toggle to enable it under a single #ifdef notyet

I've tested it and it works, but I'm keeping the #ifdef notyet for now
because it didn't solve the original problem I was debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk_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/rockchip/rk_gmac.c
diff -u src/sys/arch/arm/rockchip/rk_gmac.c:1.14 src/sys/arch/arm/rockchip/rk_gmac.c:1.15
--- src/sys/arch/arm/rockchip/rk_gmac.c:1.14	Sun Jul 21 08:24:32 2019
+++ src/sys/arch/arm/rockchip/rk_gmac.c	Sat Nov  9 17:21:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_gmac.c,v 1.14 2019/07/21 08:24:32 mrg Exp $ */
+/* $NetBSD: rk_gmac.c,v 1.15 2019/11/09 17:21:48 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: rk_gmac.c,v 1.14 2019/07/21 08:24:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_gmac.c,v 1.15 2019/11/09 17:21:48 tnn Exp $");
 
 #include 
 #include 
@@ -90,7 +90,7 @@ struct rk_gmac_softc {
 #define	 RK3328_GRF_MAC_CON1_TXDLY_EN	__BIT(0)
 
 static void
-rk3328_gmac_set_mode_rgmii(struct dwc_gmac_softc *sc, u_int tx_delay, u_int rx_delay)
+rk3328_gmac_set_mode_rgmii(struct dwc_gmac_softc *sc, u_int tx_delay, u_int rx_delay, bool set_delay)
 {
 	struct rk_gmac_softc * const rk_sc = (struct rk_gmac_softc *)sc;
 	uint32_t write_mask, write_val;
@@ -98,19 +98,30 @@ rk3328_gmac_set_mode_rgmii(struct dwc_gm
 	syscon_lock(rk_sc->sc_syscon);
 
 	write_mask = (RK3328_GRF_MAC_CON1_MODE | RK3328_GRF_MAC_CON1_SEL) << 16;
-	write_val = __SHIFTIN(RK3328_GRF_MAC_CON1_SEL_RGMII, RK3328_GRF_MAC_CON1_SEL);
-	syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON1, write_mask | write_val);
+	write_val = __SHIFTIN(RK3328_GRF_MAC_CON1_SEL_RGMII,
+	RK3328_GRF_MAC_CON1_SEL);
+	syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON1,
+	write_mask | write_val);
 
-#if notyet
-	write_mask = (RK3328_GRF_MAC_CON0_TXDLY | RK3328_GRF_MAC_CON0_RXDLY) << 16;
-	write_val = __SHIFTIN(tx_delay, RK3328_GRF_MAC_CON0_TXDLY) |
+	if (set_delay) {
+		write_mask = (
+		RK3328_GRF_MAC_CON0_TXDLY |
+		RK3328_GRF_MAC_CON0_RXDLY) << 16;
+		write_val =
+		__SHIFTIN(tx_delay, RK3328_GRF_MAC_CON0_TXDLY) |
 		__SHIFTIN(rx_delay, RK3328_GRF_MAC_CON0_RXDLY);
-	syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON0, write_mask | write_val);
+		syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON0,
+		write_mask | write_val);
 
-	write_mask = (RK3328_GRF_MAC_CON1_RXDLY_EN | RK3328_GRF_MAC_CON1_TXDLY_EN) << 16;
-	write_val = RK3328_GRF_MAC_CON1_RXDLY_EN | RK3328_GRF_MAC_CON1_TXDLY_EN;
-	syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON1, write_mask | write_val);
-#endif
+		write_mask = (
+		RK3328_GRF_MAC_CON1_RXDLY_EN |
+		RK3328_GRF_MAC_CON1_TXDLY_EN) << 16;
+		write_val =
+		RK3328_GRF_MAC_CON1_RXDLY_EN |
+		RK3328_GRF_MAC_CON1_TXDLY_EN;
+		syscon_write_4(rk_sc->sc_syscon, RK3328_GRF_MAC_CON1,
+		write_mask | write_val);
+	}
 
 	syscon_unlock(rk_sc->sc_syscon);
 }
@@ -163,32 +174,34 @@ rk3328_gmac_set_speed_rgmii(struct dwc_g
 #define	 RK3399_GRF_SOC_CON6_GMAC_CLK_TX_DL_CFG	__BITS(6,0)
 
 static void
-rk3399_gmac_set_mode_rgmii(struct dwc_gmac_softc *sc, u_int tx_delay, u_int rx_delay)
+rk3399_gmac_set_mode_rgmii(struct dwc_gmac_softc *sc, u_int tx_delay,
+u_int rx_delay, bool set_delay)
 {
 	struct rk_gmac_softc * const rk_sc = (struct rk_gmac_softc *)sc;
-
-	const uint32_t con5_mask =
-	(RK3399_GRF_SOC_CON5_RMII_MODE | RK3399_GRF_SOC_CON5_GMAC_PHY_INTF_SEL) << 16;
-	const uint32_t con5 = __SHIFTIN(1, RK3399_GRF_SOC_CON5_GMAC_PHY_INTF_SEL);
-
-#if notyet
-	const uint32_t con6_mask =
-	(RK3399_GRF_SOC_CON6_GMAC_RXCLK_DLY_ENA |
-		RK3399_GRF_SOC_CON6_GMAC_TXCLK_DLY_ENA |
-		RK3399_GRF_SOC_CON6_GMAC_CLK_RX_DL_CFG |
-		RK3399_GRF_SOC_CON6_GMAC_CLK_TX_DL_CFG) << 16;
-	const uint32_t con6 =
-	(tx_delay ? RK3399_GRF_SOC_CON6_GMAC_TXCLK_DLY_ENA : 0) |
-	(rx_delay ? RK3399_GRF_SOC_CON6_GMAC_RXCLK_DLY_ENA : 0) |
-	__SHIFTIN(rx_delay, RK3399_GRF_SOC_CON6_GMAC_CLK_RX_DL_CFG) |
-	__SHIFTIN(tx_delay, RK3399_GRF_SOC_CON6_GMAC_CLK_TX_DL_CFG);
-#endif
+	uint32_t write_mask, write_val;
 
 	syscon_lock(rk_sc->sc_syscon);
-	syscon_write_4(rk_sc->sc_syscon, RK3399_GRF_SOC_CON5, con5 | con5_mask);
-#if notyet
-	syscon_write_4(rk_sc->sc_syscon, RK3399_GRF_SOC_CON6, con6 | con6_mask);
-#endif
+
+	write_mask = (
+	RK3399_GRF_SOC_CON5_RMII_MODE |
+	RK3399_GRF_SOC_CON5_GMAC_PHY_INTF_SEL) << 16;
+	write_val = __SHIFTIN(1, RK3399_GRF_SOC_CON5_GMAC_PHY_INTF_SEL);
+	syscon_write_4(rk_sc->sc_syscon, RK3399_GRF_SOC_CON5,
+	write_mask | write_val);

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

2019-11-09 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  9 17:21:48 UTC 2019

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

Log Message:
rk_gmac: clean up code for setting up clock delay lines a bit

- break long lines
- move toggle to enable it under a single #ifdef notyet

I've tested it and it works, but I'm keeping the #ifdef notyet for now
because it didn't solve the original problem I was debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk_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/dev/i2c

2019-11-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Nov  5 19:59:35 UTC 2019

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

Log Message:
ssdfb: fix i2c transfer error with some controllers

If the controller doesn't support the full 128 byte transfer size we need,
then split the write across multiple transactions.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/ssdfb_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-11-05 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Nov  5 19:59:35 UTC 2019

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

Log Message:
ssdfb: fix i2c transfer error with some controllers

If the controller doesn't support the full 128 byte transfer size we need,
then split the write across multiple transactions.


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

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

Modified files:

Index: src/sys/dev/i2c/ssdfb_i2c.c
diff -u src/sys/dev/i2c/ssdfb_i2c.c:1.4 src/sys/dev/i2c/ssdfb_i2c.c:1.5
--- src/sys/dev/i2c/ssdfb_i2c.c:1.4	Sat Nov  2 14:23:59 2019
+++ src/sys/dev/i2c/ssdfb_i2c.c	Tue Nov  5 19:59:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $ */
+/* $NetBSD: ssdfb_i2c.c,v 1.5 2019/11/05 19:59:35 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.5 2019/11/05 19:59:35 tnn Exp $");
 
 #include 
 #include 
@@ -43,12 +43,16 @@ struct ssdfb_i2c_softc {
 	struct		ssdfb_softc sc;
 	i2c_tag_t	sc_i2c_tag;
 	i2c_addr_t	sc_i2c_addr;
+	size_t		sc_transfer_size;
 };
 
 static int	ssdfb_i2c_match(device_t, cfdata_t, void *);
 static void	ssdfb_i2c_attach(device_t, device_t, void *);
 static int	ssdfb_i2c_detach(device_t, int);
 
+static int	ssdfb_i2c_probe_transfer_size(struct ssdfb_i2c_softc *, bool);
+static int	ssdfb_i2c_transfer(struct ssdfb_i2c_softc *, uint8_t, uint8_t *,
+size_t, int);
 static int	ssdfb_i2c_cmd(void *, uint8_t *, size_t, bool);
 static int	ssdfb_i2c_transfer_rect(void *, uint8_t, uint8_t, uint8_t,
 uint8_t, uint8_t *, size_t, bool);
@@ -132,6 +136,61 @@ ssdfb_i2c_detach(device_t self, int flag
 }
 
 static int
+ssdfb_i2c_probe_transfer_size(struct ssdfb_i2c_softc *sc, bool usepoll)
+{
+	int flags = usepoll ? I2C_F_POLL : 0;
+	uint8_t cb = SSDFB_I2C_CTRL_BYTE_DATA_MASK;
+	int error;
+	uint8_t buf[128];
+	size_t len;
+
+	error = iic_acquire_bus(sc->sc_i2c_tag, flags);
+	if (error)
+		return error;
+	len = sizeof(buf);
+	memset(buf, 0, len);
+	while (len > 0) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), buf, len, flags);
+		if (!error) {
+			break;
+		}
+		len >>= 1;
+	}
+	if (!error && len < 2) {
+		error = E2BIG;
+	} else {
+		sc->sc_transfer_size = len;
+	}
+	(void) iic_release_bus(sc->sc_i2c_tag, flags);
+
+	return error;
+}
+
+static int
+ssdfb_i2c_transfer(struct ssdfb_i2c_softc *sc, uint8_t cb, uint8_t *data,
+		   size_t len, int flags)
+{
+	int error;
+	size_t xfer_size = sc->sc_transfer_size;
+
+	while (len >= xfer_size) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), data, xfer_size, flags);
+		if (error)
+			return error;
+		len -= xfer_size;
+		data += xfer_size;
+	}
+	if (len > 0) {
+		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
+		sc->sc_i2c_addr, , sizeof(cb), data, len, flags);
+	}
+
+	return error;
+}
+
+static int
 ssdfb_i2c_cmd(void *cookie, uint8_t *cmd, size_t len, bool usepoll)
 {
 	struct ssdfb_i2c_softc *sc = (struct ssdfb_i2c_softc *)cookie;
@@ -154,9 +213,6 @@ ssdfb_i2c_transfer_rect(void *cookie, ui
 uint8_t frompage, uint8_t topage, uint8_t *p, size_t stride, bool usepoll)
 {
 	struct ssdfb_i2c_softc *sc = (struct ssdfb_i2c_softc *)cookie;
-	int flags = usepoll ? I2C_F_POLL : 0;
-	uint8_t cb = SSDFB_I2C_CTRL_BYTE_DATA_MASK;
-	uint8_t data[] = {0, 0, 0};
 	uint8_t cmd[2];
 	int error;
 
@@ -177,13 +233,12 @@ ssdfb_i2c_transfer_rect(void *cookie, ui
 	}
 
 	if (sc->sc.sc_transfer_rect != ssdfb_smbus_transfer_rect) {
-		error = iic_acquire_bus(sc->sc_i2c_tag, flags);
+		error = ssdfb_i2c_probe_transfer_size(sc, usepoll);
 		if (error)
 			return error;
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), data, sizeof(data), flags);
-		(void) iic_release_bus(sc->sc_i2c_tag, flags);
-		if (error) {
+		aprint_verbose_dev(sc->sc.sc_dev, "%zd-byte transfers\n",
+		sc->sc_transfer_size);
+		if (sc->sc_transfer_size == 2) {
 			sc->sc.sc_transfer_rect = ssdfb_smbus_transfer_rect;
 		}
 	}
@@ -238,8 +293,7 @@ ssdfb_i2c_transfer_rect_ssd1306(void *co
 	if (error)
 		goto out;
 	while (frompage <= topage) {
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), p, len, flags);
+		error = ssdfb_i2c_transfer(sc, cb, p, len, flags);
 		if (error)
 			goto out;
 		frompage++;
@@ -278,8 +332,7 @@ ssdfb_i2c_transfer_rect_sh1106(void *coo
 		sc->sc_i2c_addr, , sizeof(cc), cmds, sizeof(cmds), flags);
 		if (error)
 			goto out;
-		error = iic_exec(sc->sc_i2c_tag, I2C_OP_WRITE_WITH_STOP,
-		sc->sc_i2c_addr, , sizeof(cb), p, len, flags);
+		error = ssdfb_i2c_transfer(sc, cb, p, len, 

CVS commit: src/sys/dev/spi

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 22:55:58 UTC 2019

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

Log Message:
add fdt device_compatible_entry


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/spi/ssdfb_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/dev/spi/ssdfb_spi.c
diff -u src/sys/dev/spi/ssdfb_spi.c:1.2 src/sys/dev/spi/ssdfb_spi.c:1.3
--- src/sys/dev/spi/ssdfb_spi.c:1.2	Sat Nov  2 17:13:20 2019
+++ src/sys/dev/spi/ssdfb_spi.c	Sat Nov  2 22:55:57 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_spi.c,v 1.2 2019/11/02 17:13:20 tnn Exp $ */
+/* $NetBSD: ssdfb_spi.c,v 1.3 2019/11/02 22:55:57 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.2 2019/11/02 17:13:20 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.3 2019/11/02 22:55:57 tnn Exp $");
 
 #include 
 #include 
@@ -73,18 +73,28 @@ static void	ssdfb_bitstream_final(struct
 CFATTACH_DECL_NEW(ssdfb_spi, sizeof(struct ssdfb_spi_softc),
 ssdfb_spi_match, ssdfb_spi_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+	{ "solomon,ssd1322",	0 },
+	{ NULL,			0 }
+};
+
 static int
 ssdfb_spi_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct spi_attach_args *sa = aux;
+	int res;
+
+	res = spi_compatible_match(sa, match, compat_data);
+	if (!res)
+		return res;
 
 	/*
 	 * SSD1306 and SSD1322 data sheets specify 100ns cycle time.
 	 */
 	if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000))
-		return 0;
+		res = 0;
 
-	return 1;
+	return res;
 }
 
 static void



CVS commit: src/sys/dev/spi

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 22:55:58 UTC 2019

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

Log Message:
add fdt device_compatible_entry


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/spi/ssdfb_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/dev/pci

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 21:11:55 UTC 2019

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

Log Message:
cast away unused return value


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/if_ste.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_ste.c
diff -u src/sys/dev/pci/if_ste.c:1.57 src/sys/dev/pci/if_ste.c:1.58
--- src/sys/dev/pci/if_ste.c:1.57	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/pci/if_ste.c	Sat Nov  2 21:11:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ste.c,v 1.57 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.57 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $");
 
 
 #include 
@@ -1100,7 +1100,7 @@ ste_stats_update(struct ste_softc *sc)
 	ifp->if_opackets +=
 	(u_int) bus_space_read_2(st, sh, STE_FramesTransmittedOK);
 
-	(u_int) bus_space_read_2(st, sh, STE_FramesReceivedOK);
+	(void) bus_space_read_2(st, sh, STE_FramesReceivedOK);
 
 	ifp->if_collisions +=
 	(u_int) bus_space_read_1(st, sh, STE_LateCollisions) +



CVS commit: src/share/man/man4

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 19:22:37 UTC 2019

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

Log Message:
documentation for WSDISPLAYIO_FBINFO


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/share/man/man4/wsdisplay.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/wsdisplay.4
diff -u src/share/man/man4/wsdisplay.4:1.47 src/share/man/man4/wsdisplay.4:1.48
--- src/share/man/man4/wsdisplay.4:1.47	Mon Aug 12 11:11:28 2019
+++ src/share/man/man4/wsdisplay.4	Sat Nov  2 19:22:36 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: wsdisplay.4,v 1.47 2019/08/12 11:11:28 nia Exp $
+.\" $NetBSD: wsdisplay.4,v 1.48 2019/11/02 19:22:36 tnn Exp $
 .\"
 .\" Copyright (c) 1999 Matthias Drochner.
 .\" Copyright (c) 2002 Ben Harris.
@@ -26,7 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 25, 2015
+.Dd November 2, 2019
 .Dt WSDISPLAY 4
 .Os
 .Sh NAME
@@ -192,6 +192,52 @@ Their definitions are found in
 Retrieve the type of the display.
 The list of types is in
 .In dev/wscons/wsconsio.h .
+.It Dv WSDISPLAYIO_FBINFO Pq Li "struct wsdisplayio_fbinfo"
+Retrieve extended information about a framebuffer display,
+including the framebuffer's pixel packing layout.
+The returned structure is as follows:
+.Bd -literal -offset indent
+struct wsdisplayio_fbinfo {
+	uint64_t fbi_fbsize;
+	uint64_t fbi_fboffset;
+	uint32_t fbi_width;
+	uint32_t fbi_height;
+	uint32_t fbi_stride;
+	uint32_t fbi_bitsperpixel;
+	uint32_t fbi_pixeltype;
+	union _fbi_subtype {
+		struct _fbi_rgbmasks {
+			uint32_t red_offset;
+			uint32_t red_size;
+			uint32_t green_offset;
+			uint32_t green_size;
+			uint32_t blue_offset;
+			uint32_t blue_size;
+			uint32_t alpha_offset;
+			uint32_t alpha_size;
+		} fbi_rgbmasks;
+		struct _fbi_cmapinfo {
+			uint32_t cmap_entries;
+		} fbi_cmapinfo;
+	} fbi_subtype;
+	uint32_t fbi_flags;
+};
+.Ed
+.Pp
+For a "true colour" display, the
+.Va fbi_pixeltype
+field contains
+.Dv WSFB_RGB
+and the
+.Va fbi_rgbmasks
+field contains the pixel packing layout.
+For a colour indexed display, the
+.Va fbi_pixeltype
+field contains
+.Dv WSFB_CI
+and the
+.Va fbi_cmapinfo
+field contains the number of color map entries.
 .It Dv WSDISPLAYIO_GINFO Pq Li "struct wsdisplay_fbinfo"
 Retrieve basic information about a framebuffer display.
 The returned structure is as follows:



CVS commit: src/share/man/man4

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 19:22:37 UTC 2019

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

Log Message:
documentation for WSDISPLAYIO_FBINFO


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/share/man/man4/wsdisplay.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-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 18:56:41 UTC 2019

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

Log Message:
expand section on GPIOREAD


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/share/man/man4/gpio.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/gpio.4
diff -u src/share/man/man4/gpio.4:1.33 src/share/man/man4/gpio.4:1.34
--- src/share/man/man4/gpio.4:1.33	Sat May 19 13:59:06 2018
+++ src/share/man/man4/gpio.4	Sat Nov  2 18:56:41 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpio.4,v 1.33 2018/05/19 13:59:06 thorpej Exp $
+.\" $NetBSD: gpio.4,v 1.34 2019/11/02 18:56:41 tnn Exp $
 .\"	$OpenBSD: gpio.4,v 1.5 2004/11/23 09:39:29 reyk Exp $
 .\"
 .\" Copyright (c) 2004 Alexander Yurchenko 
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd February 20, 2018
+.Dd November 2, 2019
 .Dt GPIO 4
 .Os
 .Sh NAME
@@ -102,6 +102,12 @@ The
 or
 .Fa gp_pin
 field must be set before calling.
+If both are set, gp_name takes precedence.
+On return, the
+.Fa gp_name
+field contains the current name of the pin, if set by the controller driver
+or an earlier call to
+.Dv GPIOSET .
 .Pp
 .It Dv GPIOWRITE ( struct gpio_req )
 Writes the output value to the pin.



CVS commit: src/share/man/man4

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 18:56:41 UTC 2019

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

Log Message:
expand section on GPIOREAD


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/share/man/man4/gpio.4

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



CVS commit: src/lib/libpuffs

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 18:14:36 UTC 2019

Modified Files:
src/lib/libpuffs: null.c

Log Message:
puffs_null_node_fsync: don't leak directory handle

Directory handles returned by opendir must be closed by closedir.
Also directory(3) says we mustn't close(2) descriptors returned by dirfd(3)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libpuffs/null.c

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



CVS commit: src/lib/libpuffs

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 18:14:36 UTC 2019

Modified Files:
src/lib/libpuffs: null.c

Log Message:
puffs_null_node_fsync: don't leak directory handle

Directory handles returned by opendir must be closed by closedir.
Also directory(3) says we mustn't close(2) descriptors returned by dirfd(3)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libpuffs/null.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/libpuffs/null.c
diff -u src/lib/libpuffs/null.c:1.34 src/lib/libpuffs/null.c:1.35
--- src/lib/libpuffs/null.c:1.34	Mon Sep 23 12:00:57 2019
+++ src/lib/libpuffs/null.c	Sat Nov  2 18:14:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: null.c,v 1.34 2019/09/23 12:00:57 christos Exp $	*/
+/*	$NetBSD: null.c,v 1.35 2019/11/02 18:14:36 tnn Exp $	*/
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: null.c,v 1.34 2019/09/23 12:00:57 christos Exp $");
+__RCSID("$NetBSD: null.c,v 1.35 2019/11/02 18:14:36 tnn Exp $");
 #endif /* !lint */
 
 /*
@@ -412,20 +412,25 @@ puffs_null_node_fsync(struct puffs_userm
 	int fd, rv;
 	int fflags;
 	struct stat sb;
+	DIR *dirp;
 
 	rv = 0;
 	if (stat(PNPATH(pn), ) == -1)
 		return errno;
 	if (S_ISDIR(sb.st_mode)) {
-		DIR *dirp;
-		if ((dirp = opendir(PNPATH(pn))) == 0)
+		if ((dirp = opendir(PNPATH(pn))) == NULL)
 			return errno;
 		fd = dirfd(dirp);
-		if (fd == -1)
-			return errno;
+		if (fd == -1) {
+			rv = errno;
+			closedir(dirp);
+			return rv;
+		}
 
 		if (fsync(fd) == -1)
 			rv = errno;
+
+		closedir(dirp);
 	} else {
 		fd = writeableopen(PNPATH(pn));
 		if (fd == -1)
@@ -440,9 +445,9 @@ puffs_null_node_fsync(struct puffs_userm
 
 		if (fsync_range(fd, fflags, offlo, offhi - offlo) == -1)
 			rv = errno;
-	}
 
-	close(fd);
+		close(fd);
+	}
 
 	return rv;
 }



CVS commit: src/sys/dev

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 17:13:20 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c
src/sys/dev/spi: ssdfb_spi.c

Log Message:
fix hang when SSDFB_ATTACH_FLAG_CONSOLE used with spi


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/spi/ssdfb_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/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.9 src/sys/dev/ic/ssdfb.c:1.10
--- src/sys/dev/ic/ssdfb.c:1.9	Sat Nov  2 14:18:36 2019
+++ src/sys/dev/ic/ssdfb.c	Sat Nov  2 17:13:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.10 2019/11/02 17:13:20 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.10 2019/11/02 17:13:20 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -331,7 +331,8 @@ ssdfb_attach(struct ssdfb_softc *sc, int
 	if (sc->sc_is_console)
 		ssdfb_set_usepoll(sc, true);
 
-	mutex_init(>sc_cond_mtx, MUTEX_DEFAULT, IPL_SCHED);
+	mutex_init(>sc_cond_mtx, MUTEX_DEFAULT,
+	ISSET(flags, SSDFB_ATTACH_FLAG_MPSAFE) ? IPL_SCHED : IPL_BIO);
 	cv_init(>sc_cond, "ssdfb");
 	kt_flags = KTHREAD_MUSTJOIN;
 	/* XXX spi(4) is not MPSAFE yet. */

Index: src/sys/dev/spi/ssdfb_spi.c
diff -u src/sys/dev/spi/ssdfb_spi.c:1.1 src/sys/dev/spi/ssdfb_spi.c:1.2
--- src/sys/dev/spi/ssdfb_spi.c:1.1	Sat Nov  2 14:33:27 2019
+++ src/sys/dev/spi/ssdfb_spi.c	Sat Nov  2 17:13:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_spi.c,v 1.1 2019/11/02 14:33:27 tnn Exp $ */
+/* $NetBSD: ssdfb_spi.c,v 1.2 2019/11/02 17:13:20 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.1 2019/11/02 14:33:27 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.2 2019/11/02 17:13:20 tnn Exp $");
 
 #include 
 #include 
@@ -170,7 +170,7 @@ ssdfb_spi_xfer_rect_3wire_ssd1322(void *
 	/*
 	 * Unlike iic(4), there is no way to force spi(4) to use polling.
 	 */
-	if (usepoll || cold)
+	if (usepoll && !cold)
 		return 0;
 
 	ssdfb_bitstream_init(, bitstream);
@@ -294,7 +294,7 @@ ssdfb_spi_xfer_rect_4wire_ssd1322(void *
 	/*
 	 * Unlike iic(4), there is no way to force spi(4) to use polling.
 	 */
-	if (usepoll || cold)
+	if (usepoll && !cold)
 		return 0;
 
 	ssdfb_spi_4wire_set_dc(sc, 0);



CVS commit: src/sys/dev

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 17:13:20 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c
src/sys/dev/spi: ssdfb_spi.c

Log Message:
fix hang when SSDFB_ATTACH_FLAG_CONSOLE used with spi


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/spi/ssdfb_spi.c

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-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:47:35 UTC 2019

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

Log Message:
ssdfb: update manpage


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/ssdfb.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/ssdfb.4
diff -u src/share/man/man4/ssdfb.4:1.3 src/share/man/man4/ssdfb.4:1.4
--- src/share/man/man4/ssdfb.4:1.3	Sun Mar 17 11:20:36 2019
+++ src/share/man/man4/ssdfb.4	Sat Nov  2 14:47:35 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ssdfb.4,v 1.3 2019/03/17 11:20:36 wiz Exp $
+.\"	$NetBSD: ssdfb.4,v 1.4 2019/11/02 14:47:35 tnn Exp $
 .\"
 .\" Copyright (c) 2019 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 17, 2019
+.Dd November 2, 2019
 .Dt SSDFB 4
 .Os
 .Sh NAME
@@ -38,6 +38,7 @@
 .Cd "ssdfb* at iic? addr ?"
 .Cd "ssdfb* at iic? addr 0x3c"
 .Cd "ssdfb* at iic? addr 0x3d flags 0x102"
+.Cd "ssdfb* at spi? slave ? flags 0x105"
 .Cd "wsdisplay* at ssdfb?"
 .Sh DESCRIPTION
 The
@@ -51,6 +52,8 @@ of the following controller chips:
 Solomon Systech Ltd SSD1306
 .It
 Sino Wealth Electronic Ltd SH1106
+.It
+Solomon Systech Ltd SSD1322
 .El
 .Pp
 The following products (controller + panel assemblies) are supported:
@@ -67,6 +70,9 @@ Adafruit Industries, LLC product 938 (12
 .It
 .Em 0x04 :
 Adafruit Industries, LLC product 931 (128x32)
+.It
+.Em 0x05 :
+Generic SSD1322 modules using default settings
 .El
 .Pp
 The flags value can contain one or more of the following, bitwise OR'ed:
@@ -108,7 +114,6 @@ driver written by
 .An Patrick Wildt Aq Mt patr...@blueri.se
 but does not share any code.
 .Sh BUGS
-Some modules can be reconfigured to attach via
-.Xr spi 4 ,
-typically by moving surface mount zero ohm resistors.
-This is currently not supported.
+The "4-wire SPI" MCU interface which requires an auxiliary
+.Xr gpio 4
+pin for the D/C# signal is currently not supported.



CVS commit: src/share/man/man4

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:47:35 UTC 2019

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

Log Message:
ssdfb: update manpage


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/ssdfb.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-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:33:27 UTC 2019

Modified Files:
src/sys/dev/spi: files.spi
Added Files:
src/sys/dev/spi: ssdfb_spi.c

Log Message:
add spi(4) bus frontend for ssdfb(4)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/spi/files.spi
cvs rdiff -u -r0 -r1.1 src/sys/dev/spi/ssdfb_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/dev/spi

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:33:27 UTC 2019

Modified Files:
src/sys/dev/spi: files.spi
Added Files:
src/sys/dev/spi: ssdfb_spi.c

Log Message:
add spi(4) bus frontend for ssdfb(4)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/spi/files.spi
cvs rdiff -u -r0 -r1.1 src/sys/dev/spi/ssdfb_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/dev/spi/files.spi
diff -u src/sys/dev/spi/files.spi:1.6 src/sys/dev/spi/files.spi:1.7
--- src/sys/dev/spi/files.spi:1.6	Mon Aug  5 23:42:48 2019
+++ src/sys/dev/spi/files.spi	Sat Nov  2 14:33:27 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.spi,v 1.6 2019/08/05 23:42:48 tnn Exp $
+#	$NetBSD: files.spi,v 1.7 2019/11/02 14:33:27 tnn Exp $
 
 define	spibus { }
 
@@ -36,6 +36,10 @@ device	mcp23s17gpio: gpiobus
 attach	mcp23s17gpio at spi
 file	dev/spi/mcp23s17.c		mcp23s17gpio
 
+# Solomon Systech SSD13xx PLED/OLED display
+attach	ssdfb at spi with ssdfb_spi
+file	dev/spi/ssdfb_spi.c		ssdfb_spi
+
 # MCP3x0x ADC
 device	mcp3kadc: sysmon_envsys
 attach	mcp3kadc at spi

Added files:

Index: src/sys/dev/spi/ssdfb_spi.c
diff -u /dev/null src/sys/dev/spi/ssdfb_spi.c:1.1
--- /dev/null	Sat Nov  2 14:33:27 2019
+++ src/sys/dev/spi/ssdfb_spi.c	Sat Nov  2 14:33:27 2019
@@ -0,0 +1,339 @@
+/* $NetBSD: ssdfb_spi.c,v 1.1 2019/11/02 14:33:27 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: ssdfb_spi.c,v 1.1 2019/11/02 14:33:27 tnn Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct bs_state {
+	uint8_t	*base;
+	uint8_t	*cur;
+	uint8_t	mask;
+};
+
+struct ssdfb_spi_softc {
+	struct ssdfb_softc	sc;
+	struct spi_handle	*sc_sh;
+	bool			sc_3wiremode;
+};
+
+static int	ssdfb_spi_match(device_t, cfdata_t, void *);
+static void	ssdfb_spi_attach(device_t, device_t, void *);
+
+static int	ssdfb_spi_cmd_3wire(void *, uint8_t *, size_t, bool);
+static int	ssdfb_spi_xfer_rect_3wire_ssd1322(void *, uint8_t, uint8_t,
+		uint8_t, uint8_t, uint8_t *, size_t, bool);
+
+static int	ssdfb_spi_cmd_4wire(void *, uint8_t *, size_t, bool);
+static int	ssdfb_spi_xfer_rect_4wire_ssd1322(void *, uint8_t, uint8_t,
+		uint8_t, uint8_t, uint8_t *, size_t, bool);
+
+static void	ssdfb_bitstream_init(struct bs_state *, uint8_t *);
+static void	ssdfb_bitstream_append(struct bs_state *, uint8_t, uint8_t);
+static void	ssdfb_bitstream_append_cmd(struct bs_state *, uint8_t);
+static void	ssdfb_bitstream_append_data(struct bs_state *, uint8_t *,
+		size_t);
+static void	ssdfb_bitstream_final(struct bs_state *);
+
+CFATTACH_DECL_NEW(ssdfb_spi, sizeof(struct ssdfb_spi_softc),
+ssdfb_spi_match, ssdfb_spi_attach, NULL, NULL);
+
+static int
+ssdfb_spi_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct spi_attach_args *sa = aux;
+
+	/*
+	 * SSD1306 and SSD1322 data sheets specify 100ns cycle time.
+	 */
+	if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000))
+		return 0;
+
+	return 1;
+}
+
+static void
+ssdfb_spi_attach(device_t parent, device_t self, void *aux)
+{
+	struct ssdfb_spi_softc *sc = device_private(self);
+	struct cfdata *cf = device_cfdata(self);
+	struct spi_attach_args *sa = aux;
+	int flags = cf->cf_flags;
+
+	sc->sc.sc_dev = self;
+	sc->sc_sh = sa->sa_handle;
+	sc->sc.sc_cookie = (void *)sc;
+	if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) ==

CVS commit: src/sys/dev/i2c

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:24:00 UTC 2019

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

Log Message:
set flag to indicate that worker thread should be created mpsafe

iic(4) is mpsafe, unlike spi(4) which hasn't been made mpsafe yet.


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

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

Modified files:

Index: src/sys/dev/i2c/ssdfb_i2c.c
diff -u src/sys/dev/i2c/ssdfb_i2c.c:1.3 src/sys/dev/i2c/ssdfb_i2c.c:1.4
--- src/sys/dev/i2c/ssdfb_i2c.c:1.3	Tue May 28 17:17:16 2019
+++ src/sys/dev/i2c/ssdfb_i2c.c	Sat Nov  2 14:23:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_i2c.c,v 1.3 2019/05/28 17:17:16 tnn Exp $ */
+/* $NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.3 2019/05/28 17:17:16 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.4 2019/11/02 14:23:59 tnn Exp $");
 
 #include 
 #include 
@@ -112,6 +112,7 @@ ssdfb_i2c_attach(device_t parent, device
 	if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN)
 		flags |= SSDFB_PRODUCT_SSD1306_GENERIC;
 
+	flags |= SSDFB_ATTACH_FLAG_MPSAFE;
 	sc->sc.sc_dev = self;
 	sc->sc_i2c_tag = ia->ia_tag;
 	sc->sc_i2c_addr = ia->ia_addr;



CVS commit: src/sys/dev/i2c

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:24:00 UTC 2019

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

Log Message:
set flag to indicate that worker thread should be created mpsafe

iic(4) is mpsafe, unlike spi(4) which hasn't been made mpsafe yet.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/ssdfb_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/ic

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:18:36 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
ssdfb: add support for SSD1322


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/ssdfbvar.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/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.8 src/sys/dev/ic/ssdfb.c:1.9
--- src/sys/dev/ic/ssdfb.c:1.8	Tue Oct 22 22:03:27 2019
+++ src/sys/dev/ic/ssdfb.c	Sat Nov  2 14:18:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -73,6 +73,7 @@ static void	ssdfb_cursor(void *, int, in
 
 /* hardware interface */
 static int	ssdfb_init_ssd1306(struct ssdfb_softc *);
+static int	ssdfb_init_ssd1322(struct ssdfb_softc *);
 static int	ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool);
 static int	ssdfb_set_display_on(struct ssdfb_softc *, bool, bool);
 static int	ssdfb_set_mode(struct ssdfb_softc *, u_int);
@@ -85,8 +86,9 @@ static void	ssdfb_damage(struct ssdfb_so
 static void	ssdfb_thread(void *);
 static void	ssdfb_set_usepoll(struct ssdfb_softc *, bool);
 static int	ssdfb_sync(struct ssdfb_softc *, bool);
-static uint64_t	ssdfb_transpose_block_1bpp(uint8_t *, size_t);
-static uint64_t	ssdfb_transpose_block_8bpp(uint8_t *, size_t);
+static int	ssdfb_sync_ssd1306(struct ssdfb_softc *, bool);
+static int	ssdfb_sync_ssd1322(struct ssdfb_softc *, bool);
+static uint64_t	ssdfb_transpose_block(uint8_t *, size_t);
 
 /* misc helpers */
 static const struct ssdfb_product *
@@ -114,6 +116,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"generic",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -124,9 +127,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = SSD1306_VCOMH_DESELECT_LEVEL_0_77_VCC,
 		.p_default_contrast =	0x7f,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_SH1106_GENERIC,
@@ -134,6 +136,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"generic",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	2,
 		.p_fosc =		0x5,
 		.p_fosc_div =		0,
@@ -144,9 +147,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = SH1106_VCOMH_DESELECT_LEVEL_DEFAULT,
 		.p_default_contrast =	0x80,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SH1106_CMD_SET_CHARGE_PUMP_7V4,
-		.p_chargepump_arg =	SSDFB_CMD_NOP,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_938,
@@ -154,6 +156,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"Adafruit Industries, LLC product 938",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -163,9 +166,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = 0x40,
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_931,
@@ -173,6 +175,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"Adafruit Industries, LLC product 931",
 		.p_width =		128,
 		.p_height =		32,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -182,9 +185,24 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = 0x40,
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x1f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
+	},
+	{
+		.p_product_id =		SSDFB_PRODUCT_SSD1322_GENERIC,
+		.p_controller_id =	SSDFB_CONTROLLER_SSD1322,
+		.p_name =		"generic",
+		.p_width =		256,
+		.p_height =		64,
+		.p_bits_per_pixel =	4,
+		.p_panel_shift =	28,
+		.p_vcomh_deselect_level = SSD1322_DEFAULT_VCOMH,
+		.p_fosc =		SSD1322_DEFAULT_FREQUENCY,
+		.p_fosc_div =		SSD1322_DEFAULT_DIVIDER,
+		.p_default_contrast =	

CVS commit: src/sys/dev/ic

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:18:36 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
ssdfb: add support for SSD1322


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/ssdfbvar.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/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 22:03:27 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
allow to have a per-product init function


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/ssdfbvar.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/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 22:03:27 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
allow to have a per-product init function


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/ssdfbvar.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/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.7 src/sys/dev/ic/ssdfb.c:1.8
--- src/sys/dev/ic/ssdfb.c:1.7	Tue Oct 22 21:41:01 2019
+++ src/sys/dev/ic/ssdfb.c	Tue Oct 22 22:03:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -72,7 +72,7 @@ static void	ssdfb_eraserows(void *, int,
 static void	ssdfb_cursor(void *, int, int, int);
 
 /* hardware interface */
-static int	ssdfb_init(struct ssdfb_softc *);
+static int	ssdfb_init_ssd1306(struct ssdfb_softc *);
 static int	ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool);
 static int	ssdfb_set_display_on(struct ssdfb_softc *, bool, bool);
 static int	ssdfb_set_mode(struct ssdfb_softc *, u_int);
@@ -100,7 +100,8 @@ static void	ssdfb_ddb_trap_callback(int)
 static const char *ssdfb_controller_names[] = {
 	[SSDFB_CONTROLLER_UNKNOWN] =	"unknown",
 	[SSDFB_CONTROLLER_SSD1306] =	"Solomon Systech SSD1306",
-	[SSDFB_CONTROLLER_SH1106] =	"Sino Wealth SH1106"
+	[SSDFB_CONTROLLER_SH1106] =	"Sino Wealth SH1106",
+	[SSDFB_CONTROLLER_SSD1322] =	"Solomon Systech SSD1322"
 };
 
 /*
@@ -124,7 +125,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x7f,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_SH1106_GENERIC,
@@ -143,7 +145,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x80,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SH1106_CMD_SET_CHARGE_PUMP_7V4,
-		.p_chargepump_arg =	SSDFB_CMD_NOP
+		.p_chargepump_arg =	SSDFB_CMD_NOP,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_938,
@@ -161,7 +164,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_931,
@@ -179,7 +183,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x1f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	}
 };
 
@@ -294,7 +299,7 @@ ssdfb_attach(struct ssdfb_softc *sc, int
 	/*
 	 * Initialize hardware.
 	 */
-	error = ssdfb_init(sc);
+	error = p->p_init(sc);
 	if (error)
 		goto out;
 
@@ -581,7 +586,7 @@ ssdfb_cursor(void *cookie, int on, int r
 }
 
 static int
-ssdfb_init(struct ssdfb_softc *sc)
+ssdfb_init_ssd1306(struct ssdfb_softc *sc)
 {
 	int error;
 	uint8_t cmd[2];

Index: src/sys/dev/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.3 src/sys/dev/ic/ssdfbvar.h:1.4
--- src/sys/dev/ic/ssdfbvar.h:1.3	Tue Oct 22 21:40:10 2019
+++ src/sys/dev/ic/ssdfbvar.h	Tue Oct 22 22:03:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.3 2019/10/22 21:40:10 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.4 2019/10/22 22:03:27 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -209,6 +209,8 @@
 	#define SSD1322_COMMAND_UNLOCK_MAGIC		0x12
 	#define SSD1322_COMMAND_LOCK_MAGIC		0x16
 
+struct ssdfb_softc;
+
 typedef enum {
 	SSDFB_CONTROLLER_UNKNOWN=0,
 	SSDFB_CONTROLLER_SSD1306=1,
@@ -254,6 +256,7 @@ struct ssdfb_product {
 	uint8_tp_multiplex_ratio;
 	uint8_tp_chargepump_cmd;
 	uint8_tp_chargepump_arg;
+	int(*p_init)(struct ssdfb_softc *);
 };
 
 struct ssdfb_softc {



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:41:01 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c

Log Message:
use __SHIFTIN


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/ssdfb.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/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.6 src/sys/dev/ic/ssdfb.c:1.7
--- src/sys/dev/ic/ssdfb.c:1.6	Wed Jun  5 20:32:28 2019
+++ src/sys/dev/ic/ssdfb.c	Tue Oct 22 21:41:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.6 2019/06/05 20:32:28 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.6 2019/06/05 20:32:28 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -638,20 +638,16 @@ ssdfb_init(struct ssdfb_softc *sc)
 	 * Configure timing characteristics.
 	 */
 	SSDFB_CMD2(SSDFB_CMD_SET_DISPLAY_CLOCK_RATIO,
-	((sc->sc_p->p_fosc << SSDFB_DISPLAY_CLOCK_OSCILLATOR_SHIFT) &
-	 SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK) |
-	((sc->sc_p->p_fosc_div << SSDFB_DISPLAY_CLOCK_DIVIDER_SHIFT) &
-	 SSDFB_DISPLAY_CLOCK_DIVIDER_MASK));
+	__SHIFTIN(sc->sc_p->p_fosc, SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK) |
+	__SHIFTIN(sc->sc_p->p_fosc_div, SSDFB_DISPLAY_CLOCK_DIVIDER_MASK));
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_CONTRAST_CONTROL, sc->sc_contrast);
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_PRECHARGE_PERIOD,
-	((sc->sc_p->p_precharge << SSDFB_PRECHARGE_SHIFT) &
-	 SSDFB_PRECHARGE_MASK) |
-	((sc->sc_p->p_discharge << SSDFB_DISCHARGE_SHIFT) &
-	 SSDFB_DISCHARGE_MASK));
+	__SHIFTIN(sc->sc_p->p_precharge, SSDFB_PRECHARGE_MASK) |
+	__SHIFTIN(sc->sc_p->p_discharge, SSDFB_DISCHARGE_MASK));
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_VCOMH_DESELECT_LEVEL,



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:41:01 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c

Log Message:
use __SHIFTIN


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

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:40:10 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfbvar.h

Log Message:
define SSD1322 command set


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/ssdfbvar.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/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.2 src/sys/dev/ic/ssdfbvar.h:1.3
--- src/sys/dev/ic/ssdfbvar.h:1.2	Sun Mar 17 04:03:17 2019
+++ src/sys/dev/ic/ssdfbvar.h	Tue Oct 22 21:40:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.2 2019/03/17 04:03:17 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.3 2019/10/22 21:40:10 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -101,15 +101,11 @@
  * SH1106 Rev 0.1 p.24,25,26
  */
 #define SSDFB_CMD_SET_DISPLAY_CLOCK_RATIO		0xd5
-	#define SSDFB_DISPLAY_CLOCK_DIVIDER_MASK	0x0f
-	#define SSDFB_DISPLAY_CLOCK_DIVIDER_SHIFT	0
-	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK	0xf0
-	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_SHIFT	4
+	#define SSDFB_DISPLAY_CLOCK_DIVIDER_MASK	__BITS(3, 0)
+	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK	__BITS(7, 4)
 #define SSDFB_CMD_SET_PRECHARGE_PERIOD			0xd9
-	#define SSDFB_PRECHARGE_MASK			0x0f
-	#define SSDFB_PRECHARGE_SHIFT			0
-	#define SSDFB_DISCHARGE_MASK			0xf0
-	#define SSDFB_DISCHARGE_SHIFT			4
+	#define SSDFB_PRECHARGE_MASK			__BITS(3, 0)
+	#define SSDFB_DISCHARGE_MASK			__BITS(7, 4)
 #define SSDFB_CMD_SET_VCOMH_DESELECT_LEVEL		0xdb
 	#define SSD1306_VCOMH_DESELECT_LEVEL_0_65_VCC	0x00
 	#define SSD1306_VCOMH_DESELECT_LEVEL_0_77_VCC	0x20
@@ -146,10 +142,78 @@
 	#define SH1106_DC_DC_OFF			0x8a
 	#define SH1106_DC_DC_ON0x8b
 
+/*
+ * SSD1322 command set
+ */
+#define SSD1322_CMD_ENABLE_GRAY_SCALE_TABLE		0x00
+#define SSD1322_CMD_SET_COLUMN_ADDRESS			0x15
+#define SSD1322_CMD_WRITE_RAM0x5c
+#define SSD1322_CMD_READ_RAM0x5d
+#define SSD1322_CMD_SET_ROW_ADDRESS			0x75
+#define SSD1322_CMD_SET_REMAP_AND_DUAL_COM_LINE_MODE	0xa0
+#define SSD1322_CMD_SET_DISPLAY_START_LINE		0xa1
+#define SSD1322_CMD_SET_DISPLAY_OFFSET			0xa2
+
+/* These are the same as SSDFB generic commands */
+#define SSD1322_CMD_ENTIRE_DISPLAY_OFF			0xa4
+#define SSD1322_CMD_ENTIRE_DISPLAY_ON			0xa5
+#define SSD1322_CMD_NORMAL_DISPLAY			0xa6
+#define SSD1322_CMD_INVERSE_DISPLAY			0xa7
+
+#define SSD1322_CMD_ENABLE_PARTIAL_DISPLAY		0xa8
+#define SSD1322_CMD_EXIT_PARTIAL_DISPLAY		0xa9
+#define SSD1322_CMD_FUNCTION_SELECTION			0xab
+	#define SSD1322_FUNCTION_SELECTION_EXTERNAL_VDD	0
+	#define SSD1322_FUNCTION_SELECTION_INTERNAL_VDD	__BIT(0)
+#define SSD1322_CMD_SET_SLEEP_MODE_ON			0xae
+#define SSD1322_CMD_SET_SLEEP_MODE_OFF			0xaf
+#define SSD1322_CMD_SET_PHASE_LENGTH			0xb1
+	#define SSD1322_PHASE_LENGTH_PHASE_2_MASK	__BITS(7, 4)
+	#define SSD1322_DEFAULT_PHASE_2			7
+	#define SSD1322_PHASE_LENGTH_PHASE_1_MASK	__BITS(3, 0)
+	#define SSD1322_DEFAULT_PHASE_1			4
+#define SSD1322_CMD_SET_FRONT_CLOCK_DIVIDER		0xb3
+	#define SSD1322_FREQUENCY_MASK			__BITS(7, 4)
+	#define SSD1322_DEFAULT_FREQUENCY		5
+	#define SSD1322_DIVIDER_MASK			__BITS(3, 0)
+	#define SSD1322_DEFAULT_DIVIDER			0
+#define SSD1322_CMD_DISPLAY_ENHANCEMENT_A		0xb4
+	#define SSD1322_DISPLAY_ENHANCEMENT_A_MAGIC1	0xa2
+	#define SSD1322_DISPLAY_ENHANCEMENT_A_MAGIC2	0xb5
+#define SSD1322_CMD_SET_GPIO0xb5
+	#define SSD1322_GPIO0_DISABLED			0
+	#define SSD1322_GPIO0_TRISTATE			__BIT(0)
+	#define SSD1322_GPIO0_LOW			__BIT(1)
+	#define SSD1322_GPIO0_HIGH			__BITS(1, 0)
+	#define SSD1322_GPIO1_DISABLED			0
+	#define SSD1322_GPIO1_TRISTATE			__BIT(2)
+	#define SSD1322_GPIO1_LOW			__BIT(3)
+	#define SSD1322_GPIO1_HIGH			__BITS(3, 2)
+#define SSD1322_CMD_SET_SECOND_PRECHARGE_PERIOD		0xb6
+	#define SSD1322_DEFAULT_SECOND_PRECHARGE	8
+#define SSD1322_CMD_SET_GRAY_SCALE_TABLE		0xb8
+#define SSD1322_CMD_SET_DEFAULT_GRAY_SCALE_TABLE	0xb9
+#define SSD1322_CMD_SET_PRE_CHARGE_VOLTAGE_LEVEL	0xbb
+	#define SSD1322_DEFAULT_PRE_CHARGE_VOLTAGE_LEVEL	0x17
+#define SSD1322_CMD_SET_VCOMH0xbe
+	#define SSD1322_DEFAULT_VCOMH			0x04
+#define SSD1322_CMD_SET_CONTRAST_CURRENT		0xc1
+	#define SSD1322_DEFAULT_CONTRAST_CURRENT	0x7f
+#define SSD1322_CMD_MASTER_CONTRAST_CURRENT_CONTROL	0xc7
+	#define SSD1322_DEFAULT_MASTER_CONTRAST_CURRENT_CONTROL	0xf
+#define SSD1322_CMD_SET_MUX_RATIO			0xca
+#define SSD1322_CMD_DISPLAY_ENHANCEMENT_B		0xd1
+	#define SSD1322_DISPLAY_ENHANCEMENT_B_MAGIC1	0xa2
+	#define SSD1322_DISPLAY_ENHANCEMENT_B_MAGIC2	0x20
+#define SSD1322_CMD_SET_COMMAND_LOCK			0xfd
+	#define SSD1322_COMMAND_UNLOCK_MAGIC		0x12
+	#define SSD1322_COMMAND_LOCK_MAGIC		0x16
+
 typedef enum {
 	SSDFB_CONTROLLER_UNKNOWN=0,
 	SSDFB_CONTROLLER_SSD1306=1,
 	SSDFB_CONTROLLER_SH1106=2,
+	SSDFB_CONTROLLER_SSD1322=3,
 } ssdfb_controller_id_t;
 
 typedef enum {
@@ -158,6 +222,7 @@ typedef enum {
 	SSDFB_PRODUCT_SH1106_GENERIC=2,
 	SSDFB_PRODUCT_ADAFRUIT_931=3,
 	SSDFB_PRODUCT_ADAFRUIT_938=4,
+	

CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:40:10 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfbvar.h

Log Message:
define SSD1322 command set


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/ssdfbvar.h

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



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:41:53 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c

Log Message:
gpioctl: implement support for "gpioctl gpioN list". Like pcictl(8).

For drivers that name their pins, this can be used to determine how the
logical pins are mapped to physical pins. Example from sunxigpio(4):

# gpioctl gpio0 list
0: PA0
1: PA1
2: PA2
...


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/gpioctl/gpioctl.8
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/gpioctl/gpioctl.c

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

Modified files:

Index: src/usr.sbin/gpioctl/gpioctl.8
diff -u src/usr.sbin/gpioctl/gpioctl.8:1.22 src/usr.sbin/gpioctl/gpioctl.8:1.23
--- src/usr.sbin/gpioctl/gpioctl.8:1.22	Wed Feb 13 11:40:41 2019
+++ src/usr.sbin/gpioctl/gpioctl.8	Sun Oct 20 09:41:53 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpioctl.8,v 1.22 2019/02/13 11:40:41 wiz Exp $
+.\" $NetBSD: gpioctl.8,v 1.23 2019/10/20 09:41:53 tnn Exp $
 .\"
 .\" Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer 
 .\" Copyright (c) 2004 Alexander Yurchenko 
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd February 12, 2019
+.Dd October 20, 2019
 .Dt GPIOCTL 8
 .Os
 .Sh NAME
@@ -55,6 +55,10 @@
 .Ar device
 .Ar pin
 .Cm unset
+.Nm gpioctl
+.Op Fl q
+.Ar device
+.Ar list
 .Sh DESCRIPTION
 The
 .Nm
@@ -203,6 +207,10 @@ Configure pin 5 as output and name it er
 Toggle the error_led:
 .Pp
 .Dl # gpioctl gpio0 error_led 2
+.Pp
+Enumerate all pins and display their symbolic names:
+.Pp
+.Dl # gpioctl gpio0 list
 .Sh SEE ALSO
 .Xr gpio 4 ,
 .Xr drvctl 8

Index: src/usr.sbin/gpioctl/gpioctl.c
diff -u src/usr.sbin/gpioctl/gpioctl.c:1.26 src/usr.sbin/gpioctl/gpioctl.c:1.27
--- src/usr.sbin/gpioctl/gpioctl.c:1.26	Sun Jan 27 02:08:51 2019
+++ src/usr.sbin/gpioctl/gpioctl.c	Sun Oct 20 09:41:53 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioctl.c,v 1.26 2019/01/27 02:08:51 pgoyette Exp $ */
+/* $NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $ */
 
 /*
  * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer 
@@ -17,7 +17,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include 
-__RCSID("$NetBSD: gpioctl.c,v 1.26 2019/01/27 02:08:51 pgoyette Exp $");
+__RCSID("$NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $");
 
 /*
  * Program to control GPIO devices.
@@ -48,6 +48,7 @@ static void gpioread(int, char *);
 static void gpiowrite(int, char *, int);
 static void gpioset(int pin, char *name, int flags, char *alias);
 static void gpiounset(int pin, char *name);
+static void gpiolist(void);
 static void devattach(char *, int, uint32_t, uint32_t);
 __dead static void usage(void);
 
@@ -160,6 +161,9 @@ main(int argc, char *argv[])
 		}
 		devattach(driver, ga_offset, ga_mask, ga_flags);
 		return EXIT_SUCCESS;
+	} else if (!strcmp(argv[1], "list")) {
+		gpiolist();
+		return EXIT_SUCCESS;
 	} else {
 		char *nm = NULL;
 
@@ -345,6 +349,26 @@ gpiounset(int pin, char *name)
 }
 
 static void
+gpiolist()
+{
+	struct gpio_info info;
+	struct gpio_req req;
+	int i;
+
+	if (ioctl(devfd, GPIOINFO, ) == -1)
+		err(EXIT_FAILURE, "GPIOINFO");
+
+	for (i = 0; i < info.gpio_npins; i++) {
+		memset(, 0, sizeof(req));
+		req.gp_pin = i;
+		if (ioctl(devfd, GPIOREAD, ) == -1)
+			err(EXIT_FAILURE, "GPIOREAD");
+		if (!quiet)
+			printf("%d: %s\n", i, req.gp_name);
+	}
+}
+
+static void
 devattach(char *dvname, int offset, uint32_t mask, uint32_t flags)
 {
 	struct gpio_attach attach;
@@ -372,6 +396,7 @@ usage(void)
 	fprintf(stderr, "   %s [-q] device attach device offset mask "
 	"[flag]\n",
 	progname);
+	fprintf(stderr, "   %s [-q] device list\n", progname);
 
 	exit(EXIT_FAILURE);
 }



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:41:53 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c

Log Message:
gpioctl: implement support for "gpioctl gpioN list". Like pcictl(8).

For drivers that name their pins, this can be used to determine how the
logical pins are mapped to physical pins. Example from sunxigpio(4):

# gpioctl gpio0 list
0: PA0
1: PA1
2: PA2
...


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/gpioctl/gpioctl.8
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/gpioctl/gpioctl.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/gpio

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:35:18 UTC 2019

Modified Files:
src/sys/dev/gpio: gpio.c

Log Message:
gpio: make GPIOREAD return also the symbolic name of the pin, if it is set


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/gpio/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/dev/gpio

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:35:18 UTC 2019

Modified Files:
src/sys/dev/gpio: gpio.c

Log Message:
gpio: make GPIOREAD return also the symbolic name of the pin, if it is set


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/gpio/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/dev/gpio/gpio.c
diff -u src/sys/dev/gpio/gpio.c:1.63 src/sys/dev/gpio/gpio.c:1.64
--- src/sys/dev/gpio/gpio.c:1.63	Tue Oct 15 00:13:53 2019
+++ src/sys/dev/gpio/gpio.c	Sun Oct 20 09:35:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.63 2019/10/15 00:13:53 chs Exp $ */
+/* $NetBSD: gpio.c,v 1.64 2019/10/20 09:35:18 tnn Exp $ */
 /*	$OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.63 2019/10/15 00:13:53 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.64 2019/10/20 09:35:18 tnn Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -722,9 +722,8 @@ gpio_ioctl(struct gpio_softc *sc, u_long
 		req = data;
 
 		if (req->gp_name[0] != '\0')
-			pin = gpio_pinbyname(sc, req->gp_name);
-		else
-			pin = req->gp_pin;
+			req->gp_pin = gpio_pinbyname(sc, req->gp_name);
+		pin = req->gp_pin;
 
 		if (pin < 0 || pin >= sc->sc_npins)
 			return EINVAL;
@@ -736,6 +735,11 @@ gpio_ioctl(struct gpio_softc *sc, u_long
 
 		/* return read value */
 		req->gp_value = gpiobus_pin_read(gc, pin);
+		LIST_FOREACH(nm, >sc_names, gp_next)
+			if (nm->gp_pin == pin) {
+strlcpy(req->gp_name, nm->gp_name, GPIOMAXNAME);
+break;
+			}
 		break;
 	case GPIOWRITE:
 		if ((flag & FWRITE) == 0)



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

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 13:09:57 UTC 2019

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

Log Message:
evbarm: add dwcwdt(4) to GENERIC64


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 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.108 src/sys/arch/evbarm/conf/GENERIC64:1.109
--- src/sys/arch/evbarm/conf/GENERIC64:1.108	Tue Oct  1 10:08:05 2019
+++ src/sys/arch/evbarm/conf/GENERIC64	Sat Oct 19 13:09:57 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.108 2019/10/01 10:08:05 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.109 2019/10/19 13:09:57 tnn Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -202,6 +202,7 @@ tegratimer*	at fdt?			# Timers
 
 # Watchdog
 bcmpmwdog*	at fdt?			# Broadcom BCM283x watchdog
+dwcwdt* 	at fdt?			# DesignWare watchdog
 mesongxwdt*	at fdt?			# Amlogic Meson GX watchdog
 sbsawdt*	at acpi?		# ARM SBSA-compliant watchdog
 sunxiwdt*	at fdt?			# Allwinner watchdog



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

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 13:09:57 UTC 2019

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

Log Message:
evbarm: add dwcwdt(4) to GENERIC64


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 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/dev/fdt

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 13:08:52 UTC 2019

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

Log Message:
dwcwdt: make this work correctly

- sysmon_wdog.smw_period is seconds, not milliseconds
- tickle the watchdog before enabling it


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/dwcwdt_fdt.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/dwcwdt_fdt.c
diff -u src/sys/dev/fdt/dwcwdt_fdt.c:1.3 src/sys/dev/fdt/dwcwdt_fdt.c:1.4
--- src/sys/dev/fdt/dwcwdt_fdt.c:1.3	Sun Oct 28 15:06:10 2018
+++ src/sys/dev/fdt/dwcwdt_fdt.c	Sat Oct 19 13:08:52 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwcwdt_fdt.c,v 1.3 2018/10/28 15:06:10 aymeric Exp $ */
+/* $NetBSD: dwcwdt_fdt.c,v 1.4 2019/10/19 13:08:52 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwcwdt_fdt.c,v 1.3 2018/10/28 15:06:10 aymeric Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwcwdt_fdt.c,v 1.4 2019/10/19 13:08:52 tnn Exp $");
 
 #include 
 #include 
@@ -111,8 +111,8 @@ dwcwdt_map_period(struct dwcwdt_softc *s
 
 	for (i = 0; i < __arraycount(wdt_torr); i++) {
 		const u_int ms = (u_int)uint64_t)wdt_torr[i] + 1) * 1000) / sc->sc_clkrate);
-		if (ms >= period) {
-			*aperiod = ms;
+		if (ms >= period * 1000) {
+			*aperiod = ms / 1000;
 			return i;
 		}
 	}
@@ -121,14 +121,28 @@ dwcwdt_map_period(struct dwcwdt_softc *s
 }
 
 static int
+dwcwdt_tickle(struct sysmon_wdog *smw)
+{
+	struct dwcwdt_softc * const sc = smw->smw_cookie;
+	const uint32_t crr =
+	__SHIFTIN(WDT_CRR_CNT_RESTART_MAGIC, WDT_CRR_CNT_RESTART);
+
+	WR4(sc, WDT_CRR, crr);
+
+	return 0;
+}
+
+static int
 dwcwdt_setmode(struct sysmon_wdog *smw)
 {
 	struct dwcwdt_softc * const sc = smw->smw_cookie;
 	uint32_t cr, torr;
 	int intv;
 
-	if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED)
+	if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
+		/* Watchdog can only be disarmed by a reset */
 		return EIO;
+	}
 
 	if (smw->smw_period == WDOG_PERIOD_DEFAULT)
 		smw->smw_period = DWCWDT_PERIOD_DEFAULT;
@@ -140,7 +154,7 @@ dwcwdt_setmode(struct sysmon_wdog *smw)
 
 	torr = __SHIFTIN(intv, WDT_TORR_TIMEOUT_PERIOD);
 	WR4(sc, WDT_TORR, torr);
-
+	dwcwdt_tickle(smw);
 	cr = RD4(sc, WDT_CR);
 	cr &= ~WDT_CR_RESP_MODE;
 	cr |= WDT_CR_WDT_EN;
@@ -150,18 +164,6 @@ dwcwdt_setmode(struct sysmon_wdog *smw)
 }
 
 static int
-dwcwdt_tickle(struct sysmon_wdog *smw)
-{
-	struct dwcwdt_softc * const sc = smw->smw_cookie;
-	const uint32_t crr =
-	__SHIFTIN(WDT_CRR_CNT_RESTART_MAGIC, WDT_CRR_CNT_RESTART);
-
-	WR4(sc, WDT_CRR, crr);
-
-	return 0;
-}
-
-static int
 dwcwdt_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct fdt_attach_args * const faa = aux;



CVS commit: src/sys/dev/fdt

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 13:08:52 UTC 2019

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

Log Message:
dwcwdt: make this work correctly

- sysmon_wdog.smw_period is seconds, not milliseconds
- tickle the watchdog before enabling it


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/dwcwdt_fdt.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-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 12:55:21 UTC 2019

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

Log Message:
rk3399: add definition for the watchdog timer clock gate

The watchdog timer clock gate is a bit special because it's a secure
gate that can only be accessed from EL3. We still need a dummy gate
definition for it so that dwcwdt(4) can infer the frequency via the
parent clock. The gate is enabled by default by U-Boot.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/rockchip/rk3399_cru.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk_cru.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/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.9 src/sys/arch/arm/rockchip/rk3399_cru.c:1.10
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.9	Sun Aug  4 17:09:07 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Sat Oct 19 12:55:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.9 2019/08/04 17:09:07 tnn Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.10 2019/10/19 12:55:21 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.9 2019/08/04 17:09:07 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.10 2019/10/19 12:55:21 tnn Exp $");
 
 #include 
 #include 
@@ -804,6 +804,9 @@ static struct rk_cru_clk rk3399_cru_clks
 	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),
 
+	/* Watchdog */
+	RK_SECURE_GATE(RK3399_PCLK_WDT, "pclk_wdt", "pclk_alive" /*, SECURE_CLKGATE_CON(3), 8 */),
+
 	/* 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),

Index: src/sys/arch/arm/rockchip/rk_cru.h
diff -u src/sys/arch/arm/rockchip/rk_cru.h:1.4 src/sys/arch/arm/rockchip/rk_cru.h:1.5
--- src/sys/arch/arm/rockchip/rk_cru.h:1.4	Sat Sep  1 19:35:53 2018
+++ src/sys/arch/arm/rockchip/rk_cru.h	Sat Oct 19 12:55:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru.h,v 1.4 2018/09/01 19:35:53 jmcneill Exp $ */
+/* $NetBSD: rk_cru.h,v 1.5 2019/10/19 12:55:21 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -268,6 +268,15 @@ const char *rk_cru_gate_get_parent(struc
 		.get_parent = rk_cru_gate_get_parent,		\
 	}
 
+#define	RK_SECURE_GATE(_id, _name, _pname)			\
+	{			\
+		.id = (_id),	\
+		.type = RK_CRU_GATE,\
+		.base.name = (_name),\
+		.u.gate.parent = (_pname),			\
+		.get_parent = rk_cru_gate_get_parent,		\
+	}
+
 /* Mux clocks */
 
 struct rk_cru_mux {



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

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 12:55:21 UTC 2019

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

Log Message:
rk3399: add definition for the watchdog timer clock gate

The watchdog timer clock gate is a bit special because it's a secure
gate that can only be accessed from EL3. We still need a dummy gate
definition for it so that dwcwdt(4) can infer the frequency via the
parent clock. The gate is enabled by default by U-Boot.


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

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:40:20 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: drop redundant m_adj(). Handled via uipc_mbuf.c r1.235 instead.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/dwc_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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.67 src/sys/dev/ic/dwc_gmac.c:1.68
--- src/sys/dev/ic/dwc_gmac.c:1.67	Tue Oct 15 17:19:05 2019
+++ src/sys/dev/ic/dwc_gmac.c	Sat Oct 19 06:40:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.68 2019/10/19 06:40:20 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.68 2019/10/19 06:40:20 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -501,7 +501,6 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		}
 		data->rd_m->m_len = data->rd_m->m_pkthdr.len
 		= data->rd_m->m_ext.ext_size;
-		m_adj(data->rd_m, (-(uintptr_t)data->rd_m->m_data) & 0x3f);
 		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
 			data->rd_m->m_len = data->rd_m->m_pkthdr.len
 			= AWGE_MAX_PACKET;
@@ -1275,7 +1274,6 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			goto skip;
 		}
 		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
-		m_adj(mnew, (-(uintptr_t)mnew->m_data) & 0x3f);
 		if (mnew->m_len > AWGE_MAX_PACKET) {
 			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
 		}



CVS commit: src/sys/dev/ic

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:40:20 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: drop redundant m_adj(). Handled via uipc_mbuf.c r1.235 instead.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/dwc_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/kern

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:36:47 UTC 2019

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
mcl_cache: align items to COHERENCY_UNIT

Because we do cache incoherent DMA to/from mbufs we cannot safely share
share cache lines with adjacent items that may be concurrently accessed.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/kern/uipc_mbuf.c

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



CVS commit: src/sys/kern

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:36:47 UTC 2019

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
mcl_cache: align items to COHERENCY_UNIT

Because we do cache incoherent DMA to/from mbufs we cannot safely share
share cache lines with adjacent items that may be concurrently accessed.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/kern/uipc_mbuf.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/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.234 src/sys/kern/uipc_mbuf.c:1.235
--- src/sys/kern/uipc_mbuf.c:1.234	Sat Sep 28 16:02:12 2019
+++ src/sys/kern/uipc_mbuf.c	Sat Oct 19 06:36:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.234 2019/09/28 16:02:12 jmcneill Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.235 2019/10/19 06:36:47 tnn Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.234 2019/09/28 16:02:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.235 2019/10/19 06:36:47 tnn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -188,8 +188,8 @@ mbinit(void)
 	NULL, IPL_VM, mb_ctor, NULL, NULL);
 	KASSERT(mb_cache != NULL);
 
-	mcl_cache = pool_cache_init(mclbytes, 0, 0, 0, "mclpl", NULL,
-	IPL_VM, NULL, NULL, NULL);
+	mcl_cache = pool_cache_init(mclbytes, COHERENCY_UNIT, 0, 0, "mclpl",
+	NULL, IPL_VM, NULL, NULL, NULL);
 	KASSERT(mcl_cache != NULL);
 
 	pool_cache_set_drain_hook(mb_cache, mb_drain, NULL);



Re: CVS commit: src/sys/dev/pci

2019-10-18 Thread Tobias Nygren
On Fri, 18 Oct 2019 20:32:53 +0200
Tom Ivar Helbekkmo  wrote:

> Tobias Nygren  writes:
> 
> > Module Name:src
> > Committed By:   tnn
> > Date:   Fri Oct 18 17:16:50 UTC 2019
> >
> > Modified Files:
> > src/sys/dev/pci: ahcisata_pci.c
> >
> > Log Message:
> > ahcisata: make sure bus mastering and memory space are actually enabled
> >
> > This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.
> 
> Um.  I've been using that interface card for a while, on my Rockpro64,
> which is, in fact, running with root on a raidframe mirror of two SATA
> disks connected to it.  I did have to make a small change to make it
> work, though: I had to force it to not use MSI(X) interrupts.  Do you
> think I can revert that local modification with your change?

Yep, MSI works now. According to the PCI Express Base Specification,
Revision 3.0, table 7-3, having the bus master bit set to 0 disables
MSI. Asmedia chip seems to have a bug which makes DMA work regardless ...

-Tobias


CVS commit: src/sys/dev/pci

2019-10-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Oct 18 17:16:50 UTC 2019

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

Log Message:
ahcisata: make sure bus mastering and memory space are actually enabled

This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/ahcisata_pci.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/ahcisata_pci.c
diff -u src/sys/dev/pci/ahcisata_pci.c:1.55 src/sys/dev/pci/ahcisata_pci.c:1.56
--- src/sys/dev/pci/ahcisata_pci.c:1.55	Sun Jan 27 02:08:42 2019
+++ src/sys/dev/pci/ahcisata_pci.c	Fri Oct 18 17:16:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $	*/
+/*	$NetBSD: ahcisata_pci.c,v 1.56 2019/10/18 17:16:50 tnn Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.55 2019/01/27 02:08:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.56 2019/10/18 17:16:50 tnn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ahcisata_pci.h"
@@ -394,6 +394,7 @@ ahci_pci_attach(device_t parent, device_
 	struct ahci_softc *sc = >ah_sc;
 	bool ahci_cap_64bit;
 	bool ahci_bad_64bit;
+	pcireg_t reg;
 
 	sc->sc_atac.atac_dev = self;
 
@@ -447,6 +448,10 @@ ahci_pci_attach(device_t parent, device_
 		AHCIDEBUG_PRINT(("%s: SATA mode\n", AHCINAME(sc)), DEBUG_PROBE);
 	}
 
+	reg = pci_conf_read(psc->sc_pc, psc->sc_pcitag, PCI_COMMAND_STATUS_REG);
+	reg |= (PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE);
+	pci_conf_write(psc->sc_pc, psc->sc_pcitag, PCI_COMMAND_STATUS_REG, reg);
+
 	ahci_attach(sc);
 
 	if (!pmf_device_register(self, NULL, ahci_pci_resume))



CVS commit: src/sys/dev/pci

2019-10-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Oct 18 17:16:50 UTC 2019

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

Log Message:
ahcisata: make sure bus mastering and memory space are actually enabled

This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/ahcisata_pci.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/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 17:19:05 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
correct pointer arithmetics


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/ic/dwc_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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.66 src/sys/dev/ic/dwc_gmac.c:1.67
--- src/sys/dev/ic/dwc_gmac.c:1.66	Tue Oct 15 16:30:49 2019
+++ src/sys/dev/ic/dwc_gmac.c	Tue Oct 15 17:19:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -501,8 +501,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		}
 		data->rd_m->m_len = data->rd_m->m_pkthdr.len
 		= data->rd_m->m_ext.ext_size;
-		m_adj(data->rd_m,
-		roundup((uintptr_t)data->rd_m->m_data & 0x3f, 0x40));
+		m_adj(data->rd_m, (-(uintptr_t)data->rd_m->m_data) & 0x3f);
 		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
 			data->rd_m->m_len = data->rd_m->m_pkthdr.len
 			= AWGE_MAX_PACKET;
@@ -1276,7 +1275,7 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			goto skip;
 		}
 		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
-		m_adj(mnew, roundup((uintptr_t)mnew->m_data & 0x3f, 0x40));
+		m_adj(mnew, (-(uintptr_t)mnew->m_data) & 0x3f);
 		if (mnew->m_len > AWGE_MAX_PACKET) {
 			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
 		}



CVS commit: src/sys/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 17:19:05 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
correct pointer arithmetics


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/ic/dwc_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/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 16:30:49 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: fix issue that caused rx packets to be corrupt with DIAGNOSTIC kernel

It seems the hardware can only reliably do rx DMA to addresses that are
dcache size aligned. This is hinted at by some GMAC data sheets but hard to
find an authoritative source.

on non-DIAGNOSTIC kernels we always implicitly get MCLBYTES-aligned mbuf
data pointers, but with the reintroduction of POOL_REDZONE for DIAGNOSTIC
we can get 8-byte alignment due to redzone padding. So align rx pointers to
64 bytes which should be good for both arm32 and aarch64.

While here change some bus_dmamap_load() to bus_dmamap_load_mbuf() and add
one missing bus_dmamap_sync(). Also fixes the code to not assume that
MCLBYTES == AWGE_MAX_PACKET. User may override MCLSHIFT in kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/ic/dwc_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/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 16:30:49 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: fix issue that caused rx packets to be corrupt with DIAGNOSTIC kernel

It seems the hardware can only reliably do rx DMA to addresses that are
dcache size aligned. This is hinted at by some GMAC data sheets but hard to
find an authoritative source.

on non-DIAGNOSTIC kernels we always implicitly get MCLBYTES-aligned mbuf
data pointers, but with the reintroduction of POOL_REDZONE for DIAGNOSTIC
we can get 8-byte alignment due to redzone padding. So align rx pointers to
64 bytes which should be good for both arm32 and aarch64.

While here change some bus_dmamap_load() to bus_dmamap_load_mbuf() and add
one missing bus_dmamap_sync(). Also fixes the code to not assume that
MCLBYTES == AWGE_MAX_PACKET. User may override MCLSHIFT in kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/ic/dwc_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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.65 src/sys/dev/ic/dwc_gmac.c:1.66
--- src/sys/dev/ic/dwc_gmac.c:1.65	Fri Sep 13 07:55:06 2019
+++ src/sys/dev/ic/dwc_gmac.c	Tue Oct 15 16:30:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.65 2019/09/13 07:55:06 msaitoh Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.65 2019/09/13 07:55:06 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -499,15 +499,24 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 			error = ENOMEM;
 			goto fail;
 		}
+		data->rd_m->m_len = data->rd_m->m_pkthdr.len
+		= data->rd_m->m_ext.ext_size;
+		m_adj(data->rd_m,
+		roundup((uintptr_t)data->rd_m->m_data & 0x3f, 0x40));
+		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
+			data->rd_m->m_len = data->rd_m->m_pkthdr.len
+			= AWGE_MAX_PACKET;
+		}
 
-		error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-		mtod(data->rd_m, void *), MCLBYTES, NULL,
-		BUS_DMA_READ | BUS_DMA_NOWAIT);
+		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+		data->rd_m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 		if (error != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"could not load rx buf DMA map #%d", i);
 			goto fail;
 		}
+		bus_dmamap_sync(sc->sc_dmat, data->rd_map, 0,
+		data->rd_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		physaddr = data->rd_map->dm_segs[0].ds_addr;
 
 		desc = >sc_rxq.r_desc[i];
@@ -516,7 +525,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		desc->ddesc_next = htole32(ring->r_physaddr
 		+ next * sizeof(*desc));
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		sc->sc_descm->rx_set_len(desc, data->rd_m->m_len);
 		sc->sc_descm->rx_set_owned_by_dev(desc);
 	}
 
@@ -538,13 +547,15 @@ dwc_gmac_reset_rx_ring(struct dwc_gmac_s
 	struct dwc_gmac_rx_ring *ring)
 {
 	struct dwc_gmac_dev_dmadesc *desc;
+	struct dwc_gmac_rx_data *data;
 	int i;
 
 	mutex_enter(>r_mtx);
 	for (i = 0; i < AWGE_RX_RING_COUNT; i++) {
 		desc = >sc_rxq.r_desc[i];
+		data = >sc_rxq.r_data[i];
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		sc->sc_descm->rx_set_len(desc, data->rd_m->m_len);
 		sc->sc_descm->rx_set_owned_by_dev(desc);
 	}
 
@@ -1264,6 +1275,11 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			ifp->if_ierrors++;
 			goto skip;
 		}
+		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
+		m_adj(mnew, roundup((uintptr_t)mnew->m_data & 0x3f, 0x40));
+		if (mnew->m_len > AWGE_MAX_PACKET) {
+			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
+		}
 
 		/* unload old DMA map */
 		bus_dmamap_sync(sc->sc_dmat, data->rd_map, 0,
@@ -1271,15 +1287,13 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 		bus_dmamap_unload(sc->sc_dmat, data->rd_map);
 
 		/* and reload with new mbuf */
-		error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-		mtod(mnew, void*), MCLBYTES, NULL,
-		BUS_DMA_READ | BUS_DMA_NOWAIT);
+		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+		mnew, BUS_DMA_READ | BUS_DMA_NOWAIT);
 		if (error != 0) {
 			m_freem(mnew);
 			/* try to reload old mbuf */
-			error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-			mtod(data->rd_m, void*), MCLBYTES, NULL,
-			BUS_DMA_READ | BUS_DMA_NOWAIT);
+			error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+			data->rd_m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 			if (error != 0) {
 panic("%s: could not load old rx mbuf",
 device_xname(sc->sc_dev));
@@ -1308,7 +1322,7 @@ skip:
 		data->rd_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		

CVS commit: src/lib/libutil

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 20:29:19 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
annotate __dead


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/efun.c

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



CVS commit: src/lib/libutil

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 20:29:19 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
annotate __dead


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/efun.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/libutil/efun.c
diff -u src/lib/libutil/efun.c:1.11 src/lib/libutil/efun.c:1.12
--- src/lib/libutil/efun.c:1.11	Thu Oct  3 18:12:44 2019
+++ src/lib/libutil/efun.c	Thu Oct  3 20:29:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $	*/
+/*	$NetBSD: efun.c,v 1.12 2019/10/03 20:29:19 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $");
+__RCSID("$NetBSD: efun.c,v 1.12 2019/10/03 20:29:19 tnn Exp $");
 #endif
 
 #include 
@@ -49,7 +49,7 @@ __RCSID("$NetBSD: efun.c,v 1.11 2019/10/
 
 static void (*efunc)(int, const char *, ...) = err;
 
-static void 
+static void __dead
 eexit(int e, const char *fmt __unused, ...)
 {
 	exit(e);



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

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 19:01:13 UTC 2019

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
also add mcx(4) to ALL


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/amd64/conf/ALL

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

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 19:01:13 UTC 2019

Modified Files:
src/sys/arch/amd64/conf: ALL

Log Message:
also add mcx(4) to ALL


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/amd64/conf/ALL

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/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.122 src/sys/arch/amd64/conf/ALL:1.123
--- src/sys/arch/amd64/conf/ALL:1.122	Mon Aug 19 03:25:40 2019
+++ src/sys/arch/amd64/conf/ALL	Thu Oct  3 19:01:13 2019
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.122 2019/08/19 03:25:40 ozaki-r Exp $
+# $NetBSD: ALL,v 1.123 2019/10/03 19:01:13 tnn Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.122 $"
+#ident		"ALL-$Revision: 1.123 $"
 
 maxusers	64		# estimated number of users
 
@@ -991,6 +991,7 @@ hme*	at pci? dev ? function ?	# Sun Micr
 le*	at pci? dev ? function ?	# PCnet-PCI Ethernet
 lii*	at pci? dev ? function ?	# Atheros L2 Fast-Ethernet
 malo*	at pci? dev ? function ?	# Marvell Libertas Wireless
+mcx*	at pci? dev ? function ?	# Mellanox 5th generation Ethernet
 mskc*	at pci? dev ? function ?	# Marvell Yukon 2 Gigabit Ethernet
 msk*	at mskc?			# Marvell Yukon 2 Gigabit Ethernet
 mtd*	at pci? dev ? function ?	# Myson MTD803 3-in-1 Ethernet



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

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 18:57:38 UTC 2019

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

Log Message:
add mcx(4) to GENERIC

Tested on dual-port ConnectX-4 with 25 Gbit/s AOC


To generate a diff of this commit:
cvs rdiff -u -r1.535 -r1.536 src/sys/arch/amd64/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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.535 src/sys/arch/amd64/conf/GENERIC:1.536
--- src/sys/arch/amd64/conf/GENERIC:1.535	Sat Sep 14 06:57:51 2019
+++ src/sys/arch/amd64/conf/GENERIC	Thu Oct  3 18:57:38 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.535 2019/09/14 06:57:51 maxv Exp $
+# $NetBSD: GENERIC,v 1.536 2019/10/03 18:57:38 tnn Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.535 $"
+#ident		"GENERIC-$Revision: 1.536 $"
 
 maxusers	64		# estimated number of users
 
@@ -789,6 +789,7 @@ hme*	at pci? dev ? function ?	# Sun Micr
 le*	at pci? dev ? function ?	# PCnet-PCI Ethernet
 lii*	at pci? dev ? function ?	# Atheros L2 Fast-Ethernet
 malo*	at pci? dev ? function ?	# Marvell Libertas Wireless
+mcx*	at pci? dev ? function ?	# Mellanox 5th generation Ethernet
 mskc*	at pci? dev ? function ?	# Marvell Yukon 2 Gigabit Ethernet
 msk*	at mskc?			# Marvell Yukon 2 Gigabit Ethernet
 mtd*	at pci? dev ? function ?	# Myson MTD803 3-in-1 Ethernet



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

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 18:57:38 UTC 2019

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

Log Message:
add mcx(4) to GENERIC

Tested on dual-port ConnectX-4 with 25 Gbit/s AOC


To generate a diff of this commit:
cvs rdiff -u -r1.535 -r1.536 src/sys/arch/amd64/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/x86/pci

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 18:53:08 UTC 2019

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.
Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/pci/msipic.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/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.17 src/sys/arch/x86/pci/msipic.c:1.18
--- src/sys/arch/x86/pci/msipic.c:1.17	Wed Jun 26 10:20:06 2019
+++ src/sys/arch/x86/pci/msipic.c	Thu Oct  3 18:53:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.18 2019/10/03 18:53:08 tnn Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.18 2019/10/03 18:53:08 tnn Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -711,7 +711,7 @@ msipic_construct_msix_pic(const struct p
 		flags &= ~BUS_SPACE_MAP_PREFETCHABLE;
 	}
 	bssize = roundup(table_size, PAGE_SIZE);
-	err = bus_space_map(pa->pa_memt, memaddr + table_offset, bssize, flags,
+	err = _x86_memio_map(pa->pa_memt, memaddr + table_offset, bssize, flags,
 	);
 	bstag = pa->pa_memt;
 #endif
@@ -739,8 +739,8 @@ msipic_destruct_msix_pic(struct pic *msi
 	KASSERT(msix_pic->pic_type == PIC_MSIX);
 
 	msipic = msix_pic->pic_msipic;
-	bus_space_unmap(msipic->mp_bstag, msipic->mp_bshandle,
-	msipic->mp_bssize);
+	_x86_memio_unmap(msipic->mp_bstag, msipic->mp_bshandle,
+	msipic->mp_bssize, NULL);
 
 	msipic_destruct_common_msi_pic(msix_pic);
 }



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

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 18:53:08 UTC 2019

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.
Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/pci/msipic.c

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



CVS commit: src/libexec/ld.elf_so

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 10:34:30 UTC 2019

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
improve error message


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/libexec/ld.elf_so/rtld.c

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

Modified files:

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.198 src/libexec/ld.elf_so/rtld.c:1.199
--- src/libexec/ld.elf_so/rtld.c:1.198	Sun Sep 15 13:40:46 2019
+++ src/libexec/ld.elf_so/rtld.c	Thu Oct  3 10:34:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.198 2019/09/15 13:40:46 kamil Exp $	 */
+/*	$NetBSD: rtld.c,v 1.199 2019/10/03 10:34:30 tnn Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.198 2019/09/15 13:40:46 kamil Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.199 2019/10/03 10:34:30 tnn Exp $");
 #endif /* not lint */
 
 #include 
@@ -1674,7 +1674,7 @@ _rtld_shared_enter(void)
 		if (cur == (self | RTLD_EXCLUSIVE_MASK)) {
 			if (_rtld_mutex_may_recurse)
 return;
-			_rtld_error("dead lock detected");
+			_rtld_error("%s: dead lock detected", __FUNCTION__);
 			_rtld_die();
 		}
 		waiter = atomic_swap_uint(&_rtld_waiter_shared, self);
@@ -1738,7 +1738,7 @@ _rtld_exclusive_enter(sigset_t *mask)
 		membar_sync();
 		cur = _rtld_mutex;
 		if (cur == locked_value) {
-			_rtld_error("dead lock detected");
+			_rtld_error("%s: dead lock detected", __FUNCTION__);
 			_rtld_die();
 		}
 		if (cur)



CVS commit: src/libexec/ld.elf_so

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 10:34:30 UTC 2019

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
improve error message


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/libexec/ld.elf_so/rtld.c

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



Re: CVS commit: src/sys/kern

2019-09-30 Thread Tobias Nygren
On Mon, 23 Sep 2019 05:39:59 +
Nick Hudson  wrote:

> Modified Files:
>   src/sys/kern: subr_pool.c
> 
> Log Message:
> Enable POOL_REDZONE with DIAGNOSTIC.
> 
> The bug in the arm pmap was fixed long ago.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.258 -r1.259 src/sys/kern/subr_pool.c

Hi,

I see 30% packet loss on my BananaPi evbarm system with -current.
I bisected it to the above change. It may have had unintended
side effects. What is the referenced pmap bug about?

Kind regards,
-Tobias


CVS commit: src/sys/dev/pci

2019-09-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 28 16:22:45 UTC 2019

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

Log Message:
len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_mcx.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_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.3 src/sys/dev/pci/if_mcx.c:1.4
--- src/sys/dev/pci/if_mcx.c:1.3	Sat Sep 28 16:20:43 2019
+++ src/sys/dev/pci/if_mcx.c	Sat Sep 28 16:22:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.3 2019/09/28 16:20:43 tnn Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.4 2019/09/28 16:22:45 tnn Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -5629,7 +5629,7 @@ mcx_rx_fill_slots(struct mcx_softc *sc, 
 		bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, ms->ms_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		ms->ms_m = m;
 
-		rqe[slot].rqe_byte_count = htobe32(m->len);
+		rqe[slot].rqe_byte_count = htobe32(m->m_len);
 		rqe[slot].rqe_addr = htobe64(ms->ms_map->dm_segs[0].ds_addr);
 		rqe[slot].rqe_lkey = htobe32(sc->sc_lkey);
 



CVS commit: src/sys/dev/pci

2019-09-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 28 16:22:45 UTC 2019

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

Log Message:
len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_mcx.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-09-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 28 16:20:43 UTC 2019

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

Log Message:
mcx(4): fix rx mbuf DMA overrun

pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_mcx.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-09-28 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Sep 28 16:20:43 UTC 2019

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

Log Message:
mcx(4): fix rx mbuf DMA overrun

pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_mcx.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_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.2 src/sys/dev/pci/if_mcx.c:1.3
--- src/sys/dev/pci/if_mcx.c:1.2	Tue Sep 24 14:39:38 2019
+++ src/sys/dev/pci/if_mcx.c	Sat Sep 28 16:20:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.2 2019/09/24 14:39:38 msaitoh Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.3 2019/09/28 16:20:43 tnn Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -5620,15 +5620,16 @@ mcx_rx_fill_slots(struct mcx_softc *sc, 
 #endif
 
 		m->m_data += ETHER_ALIGN;
-		m->m_len = m->m_pkthdr.len = bufsize;
+		m->m_len = m->m_pkthdr.len = m->m_ext.ext_size - ETHER_ALIGN;
 		if (bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
 		BUS_DMA_NOWAIT) != 0) {
 			m_freem(m);
 			break;
 		}
+		bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, ms->ms_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		ms->ms_m = m;
 
-		rqe[slot].rqe_byte_count = htobe32(bufsize);
+		rqe[slot].rqe_byte_count = htobe32(m->len);
 		rqe[slot].rqe_addr = htobe64(ms->ms_map->dm_segs[0].ds_addr);
 		rqe[slot].rqe_lkey = htobe32(sc->sc_lkey);
 



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/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 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 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, , 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/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/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([1], buf, buflen);
+	memcpy([1], cmd, cmdlen);
+	memcpy([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/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/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/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/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 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 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/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/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/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/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/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/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/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/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

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

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/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, , 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/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.



  1   2   >