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

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:10:40 UTC 2023

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

Log Message:
avoid potentially uninitialised variable that likely won't happen.

GCC 12 can't tell that hardware / platform design means it won't happen.


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_ccu_display.c
diff -u src/sys/arch/arm/sunxi/sunxi_ccu_display.c:1.2 src/sys/arch/arm/sunxi/sunxi_ccu_display.c:1.3
--- src/sys/arch/arm/sunxi/sunxi_ccu_display.c:1.2	Mon Apr  2 20:55:49 2018
+++ src/sys/arch/arm/sunxi/sunxi_ccu_display.c	Thu Aug  3 08:10:40 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_display.c,v 1.2 2018/04/02 20:55:49 bouyer Exp $ */
+/* $NetBSD: sunxi_ccu_display.c,v 1.3 2023/08/03 08:10:40 mrg Exp $ */
 
 /*-
  * Copyright (c) 2018 Manuel Bouyer 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_display.c,v 1.2 2018/04/02 20:55:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_display.c,v 1.3 2023/08/03 08:10:40 mrg Exp $");
 
 #include 
 #include 
@@ -102,7 +102,7 @@ sunxi_ccu_lcdxch1_set_rate(struct sunxi_
 {
 	struct clk *clkp, *pllclkp;
 	int best_diff;
-	int parent_rate, best_parent_rate;
+	int parent_rate, best_parent_rate = 0;
 	uint32_t best_m, best_d;
 	int error;
 



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

2023-08-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Aug  3 08:10:40 UTC 2023

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

Log Message:
avoid potentially uninitialised variable that likely won't happen.

GCC 12 can't tell that hardware / platform design means it won't happen.


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

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



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

2023-05-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  2 23:08:59 UTC 2023

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

Log Message:
Cleanup previous: Try new bindings first, document old with DTCOMPAT, KNF


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sunxi_thermal.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_thermal.c
diff -u src/sys/arch/arm/sunxi/sunxi_thermal.c:1.15 src/sys/arch/arm/sunxi/sunxi_thermal.c:1.16
--- src/sys/arch/arm/sunxi/sunxi_thermal.c:1.15	Tue May  2 10:18:54 2023
+++ src/sys/arch/arm/sunxi/sunxi_thermal.c	Tue May  2 23:08:58 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_thermal.c,v 1.15 2023/05/02 10:18:54 macallan Exp $ */
+/* $NetBSD: sunxi_thermal.c,v 1.16 2023/05/02 23:08:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.15 2023/05/02 10:18:54 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.16 2023/05/02 23:08:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -520,16 +520,22 @@ sunxi_thermal_init_clocks(struct sunxi_t
 	struct clk *clk;
 	int error;
 
-	clk = fdtbus_clock_get(sc->phandle, "ahb");
-	if (clk == 0) clk = fdtbus_clock_get(sc->phandle, "bus");
+	clk = fdtbus_clock_get(sc->phandle, "bus");
+	if (clk == NULL) {
+		/* DTCOMPAT */
+		clk = fdtbus_clock_get(sc->phandle, "ahb");
+	}
 	if (clk) {
 		error = clk_enable(clk);
 		if (error != 0)
 			return error;
 	}
 
-	clk = fdtbus_clock_get(sc->phandle, "ths");
-	if (clk == 0) clk = fdtbus_clock_get(sc->phandle, "mod");
+	clk = fdtbus_clock_get(sc->phandle, "mod");
+	if (clk == NULL) {
+		/* DTCOMPAT */
+		clk = fdtbus_clock_get(sc->phandle, "ths");
+	}
 	if (clk) {
 		error = clk_set_rate(clk, sc->conf->clk_rate);
 		if (error != 0)



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

2023-05-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  2 23:08:59 UTC 2023

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

Log Message:
Cleanup previous: Try new bindings first, document old with DTCOMPAT, KNF


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sunxi_thermal.c

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



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

2023-05-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  2 10:18:54 UTC 2023

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

Log Message:
apparently the 'ahb' and 'ths' clocks were renamed to 'bus' and 'mod' in the
fdt at some point, so look for those as well
with this my pinebook's sensors work again


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sunxi_thermal.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_thermal.c
diff -u src/sys/arch/arm/sunxi/sunxi_thermal.c:1.14 src/sys/arch/arm/sunxi/sunxi_thermal.c:1.15
--- src/sys/arch/arm/sunxi/sunxi_thermal.c:1.14	Sun Nov  7 17:11:58 2021
+++ src/sys/arch/arm/sunxi/sunxi_thermal.c	Tue May  2 10:18:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_thermal.c,v 1.14 2021/11/07 17:11:58 jmcneill Exp $ */
+/* $NetBSD: sunxi_thermal.c,v 1.15 2023/05/02 10:18:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.14 2021/11/07 17:11:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.15 2023/05/02 10:18:54 macallan Exp $");
 
 #include 
 #include 
@@ -521,6 +521,7 @@ sunxi_thermal_init_clocks(struct sunxi_t
 	int error;
 
 	clk = fdtbus_clock_get(sc->phandle, "ahb");
+	if (clk == 0) clk = fdtbus_clock_get(sc->phandle, "bus");
 	if (clk) {
 		error = clk_enable(clk);
 		if (error != 0)
@@ -528,6 +529,7 @@ sunxi_thermal_init_clocks(struct sunxi_t
 	}
 
 	clk = fdtbus_clock_get(sc->phandle, "ths");
+	if (clk == 0) clk = fdtbus_clock_get(sc->phandle, "mod");
 	if (clk) {
 		error = clk_set_rate(clk, sc->conf->clk_rate);
 		if (error != 0)



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

2023-05-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  2 10:18:54 UTC 2023

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

Log Message:
apparently the 'ahb' and 'ths' clocks were renamed to 'bus' and 'mod' in the
fdt at some point, so look for those as well
with this my pinebook's sensors work again


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sunxi_thermal.c

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



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

2022-11-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Nov 19 09:05:42 UTC 2022

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

Log Message:
sunxi_can.c: fix build with MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sunxi_can.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.12 src/sys/arch/arm/sunxi/sunxi_can.c:1.13
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.12	Tue Sep 27 06:14:13 2022
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Sat Nov 19 09:05:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.12 2022/09/27 06:14:13 skrll Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.13 2022/11/19 09:05:42 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,13 +36,14 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.12 2022/09/27 06:14:13 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.13 2022/11/19 09:05:42 yamt Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



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

2022-11-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Nov 19 09:05:42 UTC 2022

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

Log Message:
sunxi_can.c: fix build with MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sunxi_can.c

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



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

2022-10-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 29 19:07:39 UTC 2022

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

Log Message:
sun8icodec: Update for binding spec changes.

The allwinner,sun8i-a33-codec binding spec has changed[1] to allow for
#sound-dai-cells to be either 0 or 1, to allow exporting multiple DAIs
from the codec.

This change updates the driver to allow #sound-dai-cells of either 0 or 1
while still only supporting AIF1 for the time being.

[1] 
https://github.com/torvalds/linux/commit/880e007f15a31f446b9e1713720c6ae5a539f3f4


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun8i_codec.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_codec.c:1.9 src/sys/arch/arm/sunxi/sun8i_codec.c:1.10
--- src/sys/arch/arm/sunxi/sun8i_codec.c:1.9	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sun8i_codec.c	Sat Oct 29 19:07:39 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.10 2022/10/29 19:07:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.9 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.10 2022/10/29 19:07:39 jmcneill Exp $");
 
 #include 
 #include 
@@ -174,11 +174,31 @@ static audio_dai_tag_t
 sun8i_codec_dai_get_tag(device_t dev, const void *data, size_t len)
 {
 	struct sun8i_codec_softc * const sc = device_private(dev);
+	const u_int sound_dai_cells = len / 4;
 
-	if (len != 4)
-		return NULL;
+	KASSERT(sound_dai_cells > 0);
 
-	return >sc_dai;
+	/*
+	 * This driver only supports AIF1 with CPU DAI at the moment.
+	 * When #sound-dai-cells is 0, return this tag. When #sound-dai-cells
+	 * is 1, return this tag only when the second cell contains the
+	 * value 0.
+	 *
+	 * Update this when support for multiple interfaces is added to
+	 * this driver.
+	 */
+	if (sound_dai_cells == 1) {
+		return >sc_dai;
+	}
+
+	if (sound_dai_cells == 2) {
+		const u_int iface = be32dec((const u_int *)data + 1);
+		if (iface == 0) {
+			return >sc_dai;
+		}
+	}
+
+	return NULL;
 }
 
 static struct fdtbus_dai_controller_func sun8i_codec_dai_funcs = {



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

2022-10-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 29 19:07:39 UTC 2022

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

Log Message:
sun8icodec: Update for binding spec changes.

The allwinner,sun8i-a33-codec binding spec has changed[1] to allow for
#sound-dai-cells to be either 0 or 1, to allow exporting multiple DAIs
from the codec.

This change updates the driver to allow #sound-dai-cells of either 0 or 1
while still only supporting AIF1 for the time being.

[1] 
https://github.com/torvalds/linux/commit/880e007f15a31f446b9e1713720c6ae5a539f3f4


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun8i_codec.c

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



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

2022-09-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep 27 06:14:13 UTC 2022

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

Log Message:
malloc -> kmem


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_can.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.11 src/sys/arch/arm/sunxi/sunxi_can.c:1.12
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.11	Wed Sep 21 20:21:16 2022
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Tue Sep 27 06:14:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.11 2022/09/21 20:21:16 bouyer Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.12 2022/09/27 06:14:13 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.11 2022/09/21 20:21:16 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.12 2022/09/27 06:14:13 skrll Exp $");
 
 #include 
 #include 
@@ -232,8 +232,7 @@ sunxi_can_attach(device_t parent, device
 	rnd_attach_source(>sc_rnd_source, device_xname(self),
 	RND_TYPE_NET, RND_FLAG_DEFAULT);
 #ifdef MBUFTRACE
-	ifp->if_mowner = malloc(sizeof(struct mowner), M_DEVBUF,
-	M_WAITOK | M_ZERO);
+	ifp->if_mowner = kmem_zalloc(sizeof(*ifp->if_mowner), KM_SLEEP);
 	strlcpy(ifp->if_mowner->mo_name, ifp->if_xname,
 		sizeof(ifp->if_mowner->mo_name));
 	MOWNER_ATTACH(ifp->if_mowner);



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

2022-09-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep 27 06:14:13 UTC 2022

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

Log Message:
malloc -> kmem


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_can.c

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



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

2022-09-25 Thread Taylor R Campbell
> Module Name:src
> Committed By:   riastradh
> Date:   Sun Sep 25 07:50:23 UTC 2022
> 
> Modified Files:
> src/sys/arch/arm/sunxi: sunxi_drm.c sunxi_fb.c
> 
> Log Message:
> sunxidrm: Set is_console on the drm device, not the fb child.
> 
> The drm device is represented by a rockchip,display-subsystem node in
> the device tree.  The fb child is a purely software abstraction used
> by drm.

This was supposed to read:

The drm device is represented by an
allwinner,sun*i-*-display-engine node in the device tree.  The
fb child is a purely software abstraction used by drm.


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

2022-09-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 25 07:50:23 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c sunxi_fb.c

Log Message:
sunxidrm: Set is_console on the drm device, not the fb child.

The drm device is represented by a rockchip,display-subsystem node in
the device tree.  The fb child is a purely software abstraction used
by drm.

The is_console property is used by MD firmware logic to mark which
actual device in hardware bus enumeration like PCI or FDT the system
has chosen for the console early at boot, so hanging it on the node
for the real hardware device makes more sense than hanging it on the
software abstraction, and is consistent with recent changes to drmfb
to respect its setting on other platforms for hardware devices.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/sunxi/sunxi_drm.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_fb.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.25 src/sys/arch/arm/sunxi/sunxi_drm.c:1.26
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.25	Tue Jun 28 05:19:03 2022
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Sun Sep 25 07:50:23 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.25 2022/06/28 05:19:03 skrll Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.26 2022/09/25 07:50:23 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.25 2022/06/28 05:19:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.26 2022/09/25 07:50:23 riastradh Exp $");
 
 #include 
 #include 
@@ -149,6 +149,11 @@ sunxi_drm_attach(device_t parent, device
 
 	aprint_normal(": Display Engine Pipeline\n");
 
+#ifdef WSDISPLAY_MULTICONS
+	const bool is_console = true;
+	prop_dictionary_set_bool(dict, "is_console", is_console);
+#endif
+
 	sc->sc_dev = self;
 	sc->sc_dmat = faa->faa_dmat;
 	sc->sc_bst = faa->faa_bst;

Index: src/sys/arch/arm/sunxi/sunxi_fb.c
diff -u src/sys/arch/arm/sunxi/sunxi_fb.c:1.7 src/sys/arch/arm/sunxi/sunxi_fb.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_fb.c:1.7	Sun Dec 19 12:28:20 2021
+++ src/sys/arch/arm/sunxi/sunxi_fb.c	Sun Sep 25 07:50:23 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_fb.c,v 1.7 2021/12/19 12:28:20 riastradh Exp $ */
+/* $NetBSD: sunxi_fb.c,v 1.8 2022/09/25 07:50:23 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_fb.c,v 1.7 2021/12/19 12:28:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_fb.c,v 1.8 2022/09/25 07:50:23 riastradh Exp $");
 
 #include 
 #include 
@@ -92,11 +92,6 @@ sunxi_fb_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-#ifdef WSDISPLAY_MULTICONS
-	prop_dictionary_t dict = device_properties(self);
-	const bool is_console = true;
-	prop_dictionary_set_bool(dict, "is_console", is_console);
-#endif
 	sunxi_task_init(>sc_attach_task, _fb_init);
 	sunxi_task_schedule(parent, >sc_attach_task);
 }



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

2022-09-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Sep 25 07:50:23 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c sunxi_fb.c

Log Message:
sunxidrm: Set is_console on the drm device, not the fb child.

The drm device is represented by a rockchip,display-subsystem node in
the device tree.  The fb child is a purely software abstraction used
by drm.

The is_console property is used by MD firmware logic to mark which
actual device in hardware bus enumeration like PCI or FDT the system
has chosen for the console early at boot, so hanging it on the node
for the real hardware device makes more sense than hanging it on the
software abstraction, and is consistent with recent changes to drmfb
to respect its setting on other platforms for hardware devices.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/sunxi/sunxi_drm.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_fb.c

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



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

2022-09-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Sep 21 20:21:16 UTC 2022

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

Log Message:
Just skipping sunxi_can_rx_intr() if the DATA_OR flag is set isn't enough
to properly recover from overrrun in all case. So go the linux way and reset
the hardware.

Don't write SUNXI_CAN_INT_RX_FLAG to SUNXI_CAN_INT_REG, this could race
with hardware and clear the interrupt while there are new packets received.
SUNXI_CAN_INT_RX_FLAG clears automatically when all pending packets have been
read, so when no more packets are pending just read SUNXI_CAN_INT_REG again
and process other interrupts, if any (or RX if there are new packets pending).
With this change it seems I get overruns less often in my use case.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_can.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.10 src/sys/arch/arm/sunxi/sunxi_can.c:1.11
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.10	Mon Sep 19 11:21:36 2022
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Wed Sep 21 20:21:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.10 2022/09/19 11:21:36 bouyer Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.11 2022/09/21 20:21:16 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.10 2022/09/19 11:21:36 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.11 2022/09/21 20:21:16 bouyer Exp $");
 
 #include 
 #include 
@@ -101,6 +101,8 @@ static void sunxi_can_ifwatchdog(struct 
 
 static void sunxi_can_enter_reset(struct sunxi_can_softc *);
 static void sunxi_can_exit_reset(struct sunxi_can_softc *);
+static void sunxi_can_ifdown(struct sunxi_can_softc * const);
+static int sunxi_can_ifup(struct sunxi_can_softc * const);
 
 CFATTACH_DECL_NEW(sunxi_can, sizeof(struct sunxi_can_softc),
 	sunxi_can_match, sunxi_can_attach, NULL, NULL);
@@ -344,7 +346,9 @@ sunxi_can_err_intr(struct sunxi_can_soft
 
 	if (irq & SUNXI_CAN_INT_DATA_OR) {
 		if_statinc(ifp, if_ierrors);
+		sunxi_can_ifdown(sc);
 		sunxi_can_write(sc, SUNXI_CAN_CMD_REG, SUNXI_CAN_CMD_CLR_OR);
+		sunxi_can_ifup(sc);
 	}
 	if (irq & SUNXI_CAN_INT_ERR) {
 		reg = sunxi_can_read(sc, SUNXI_CAN_REC_REG);
@@ -383,23 +387,31 @@ sunxi_can_intr(void *arg)
 	while ((irq = sunxi_can_read(sc, SUNXI_CAN_INT_REG)) != 0) {
 		uint32_t sts = sunxi_can_read(sc, SUNXI_CAN_STA_REG);
 		rv = 1;
+rnd_add_uint32(>sc_rnd_source, irq);
 
-		if (irq & SUNXI_CAN_INT_TX_FLAG) {
-			sunxi_can_tx_intr(sc);
-		}
 		if ((irq & (SUNXI_CAN_INT_RX_FLAG | SUNXI_CAN_INT_DATA_OR)) ==
 		SUNXI_CAN_INT_RX_FLAG) {
 			while (sts & SUNXI_CAN_STA_RX_RDY) {
 sunxi_can_rx_intr(sc);
 sts = sunxi_can_read(sc, SUNXI_CAN_STA_REG);
 			}
+			/*
+			 * Don't write SUNXI_CAN_INT_RX_FLAG to the interrupt
+			 * register, this may clear the RX pending flag
+			 * while there is indeed a packet pending.
+			 * Reading packets should have cleared the RX interrupt,
+			 * so just restart the loop and re-read the interrupt
+			 * register. In the common case irq will now be 0.
+			 */
+			continue;
+		}
+		if (irq & SUNXI_CAN_INT_TX_FLAG) {
+			sunxi_can_tx_intr(sc);
 		}
 		if (irq & SUNXI_CAN_INT_ALLERRS) {
 			sunxi_can_err_intr(sc, irq, sts);
 		}
 		sunxi_can_write(sc, SUNXI_CAN_INT_REG, irq);
-rnd_add_uint32(>sc_rnd_source, irq);
-
 	}
 	mutex_exit(>sc_intr_lock);
 



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

2022-09-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Sep 21 20:21:16 UTC 2022

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

Log Message:
Just skipping sunxi_can_rx_intr() if the DATA_OR flag is set isn't enough
to properly recover from overrrun in all case. So go the linux way and reset
the hardware.

Don't write SUNXI_CAN_INT_RX_FLAG to SUNXI_CAN_INT_REG, this could race
with hardware and clear the interrupt while there are new packets received.
SUNXI_CAN_INT_RX_FLAG clears automatically when all pending packets have been
read, so when no more packets are pending just read SUNXI_CAN_INT_REG again
and process other interrupts, if any (or RX if there are new packets pending).
With this change it seems I get overruns less often in my use case.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_can.c

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



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

2022-09-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Sep 19 11:21:36 UTC 2022

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

Log Message:
Don't process RX if SUNXI_CAN_INT_DATA_OR is pending. Seems to fix occasional
RX stalls


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_can.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.9 src/sys/arch/arm/sunxi/sunxi_can.c:1.10
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.9	Sun Sep 18 15:28:01 2022
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Mon Sep 19 11:21:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.9 2022/09/18 15:28:01 thorpej Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.10 2022/09/19 11:21:36 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.9 2022/09/18 15:28:01 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.10 2022/09/19 11:21:36 bouyer Exp $");
 
 #include 
 #include 
@@ -387,7 +387,8 @@ sunxi_can_intr(void *arg)
 		if (irq & SUNXI_CAN_INT_TX_FLAG) {
 			sunxi_can_tx_intr(sc);
 		}
-		if (irq & SUNXI_CAN_INT_RX_FLAG) {
+		if ((irq & (SUNXI_CAN_INT_RX_FLAG | SUNXI_CAN_INT_DATA_OR)) ==
+		SUNXI_CAN_INT_RX_FLAG) {
 			while (sts & SUNXI_CAN_STA_RX_RDY) {
 sunxi_can_rx_intr(sc);
 sts = sunxi_can_read(sc, SUNXI_CAN_STA_REG);



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

2022-09-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Sep 19 11:21:36 UTC 2022

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

Log Message:
Don't process RX if SUNXI_CAN_INT_DATA_OR is pending. Seems to fix occasional
RX stalls


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_can.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:44:29 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.

While here, fix a use-after-free bug in the "too many segments" error path in
sunxi_emac_setup_txbuf().


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/sunxi/sunxi_emac.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_emac.c
diff -u src/sys/arch/arm/sunxi/sunxi_emac.c:1.36 src/sys/arch/arm/sunxi/sunxi_emac.c:1.37
--- src/sys/arch/arm/sunxi/sunxi_emac.c:1.36	Tue Jun 28 05:19:03 2022
+++ src/sys/arch/arm/sunxi/sunxi_emac.c	Sun Sep 18 15:44:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_emac.c,v 1.36 2022/06/28 05:19:03 skrll Exp $ */
+/* $NetBSD: sunxi_emac.c,v 1.37 2022/09/18 15:44:29 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill 
@@ -33,7 +33,7 @@
 #include "opt_net_mpsafe.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.36 2022/06/28 05:19:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.37 2022/09/18 15:44:29 thorpej Exp $");
 
 #include 
 #include 
@@ -351,8 +351,8 @@ sunxi_emac_setup_txbuf(struct sunxi_emac
 	if (error == EFBIG) {
 		device_printf(sc->dev,
 		"TX packet needs too many DMA segments, dropping...\n");
-		m_freem(m);
-		return 0;
+		/* Caller will dequeue and free packet. */
+		return -1;
 	}
 	if (error != 0)
 		return 0;
@@ -447,12 +447,11 @@ sunxi_emac_start_locked(struct sunxi_ema
 
 	EMAC_ASSERT_LOCKED(sc);
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
 	for (cnt = 0, start = sc->tx.cur; ; cnt++) {
 		if (sc->tx.queued >= TX_DESC_COUNT - TX_MAX_SEGS) {
-			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
 
@@ -461,8 +460,16 @@ sunxi_emac_start_locked(struct sunxi_ema
 			break;
 
 		nsegs = sunxi_emac_setup_txbuf(sc, sc->tx.cur, m);
-		if (nsegs == 0) {
-			ifp->if_flags |= IFF_OACTIVE;
+		if (__predict_false(nsegs <= 0)) {
+			if (nsegs == -1) {
+/*
+ * We're being asked to discard this packet,
+ * but we can try to continue.
+ */
+IFQ_DEQUEUE(>if_snd, m);
+m_freem(m);
+continue;
+			}
 			break;
 		}
 		IFQ_DEQUEUE(>if_snd, m);
@@ -702,7 +709,6 @@ sunxi_emac_init_locked(struct sunxi_emac
 	WR4(sc, EMAC_RX_CTL_0, val | RX_EN | CHECK_CRC);
 
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
 
 	mii_mediachg(mii);
 	callout_schedule(>stat_ch, hz);
@@ -760,7 +766,7 @@ sunxi_emac_stop_locked(struct sunxi_emac
 	val = RD4(sc, EMAC_RX_CTL_1);
 	WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN);
 
-	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	ifp->if_flags &= ~IFF_RUNNING;
 }
 
 static void
@@ -876,7 +882,6 @@ sunxi_emac_txintr(struct sunxi_emac_soft
 		i, i + 1, TX_DESC_COUNT,
 		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
-		ifp->if_flags &= ~IFF_OACTIVE;
 		if_statinc(ifp, if_opackets);
 	}
 



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:44:29 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.

While here, fix a use-after-free bug in the "too many segments" error path in
sunxi_emac_setup_txbuf().


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/sunxi/sunxi_emac.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:28:01 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_can.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 15:28:01 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_can.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.8 src/sys/arch/arm/sunxi/sunxi_can.c:1.9
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.8	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Sun Sep 18 15:28:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.8 2021/01/27 03:10:20 thorpej Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.9 2022/09/18 15:28:01 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.8 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.9 2022/09/18 15:28:01 thorpej Exp $");
 
 #include 
 #include 
@@ -313,7 +313,6 @@ sunxi_can_tx_intr(struct sunxi_can_softc
 		sc->sc_m_transmit = NULL;
 		ifp->if_timer = 0;
 	}
-	ifp->if_flags &= ~IFF_OACTIVE;
 	if_schedule_deferred_start(ifp);
 }
 
@@ -327,8 +326,7 @@ sunxi_can_tx_abort(struct sunxi_can_soft
 		sc->sc_ifp->if_timer = 0;
 		/*
 		 * the transmit abort will trigger a TX interrupt
-		 * which will restart the queue or cleae OACTIVE,
-		 * as appropriate
+		 * which will restart the queue as appropriate.
 		 */
 		sunxi_can_write(sc, SUNXI_CAN_CMD_REG, SUNXI_CAN_CMD_ABT_REQ);
 		return 1;
@@ -418,7 +416,7 @@ sunxi_can_ifstart(struct ifnet *ifp)
 	int i;
 
 	mutex_enter(>sc_intr_lock);
-	if (ifp->if_flags & IFF_OACTIVE)
+	if (sc->sc_m_transmit != NULL)
 		goto out;
 
 	IF_DEQUEUE(>if_snd, m);
@@ -467,7 +465,6 @@ sunxi_can_ifstart(struct ifnet *ifp)
 	} else {
 		sunxi_can_write(sc, SUNXI_CAN_CMD_REG, SUNXI_CAN_CMD_TANS_REQ);
 	}
-	ifp->if_flags |= IFF_OACTIVE;
 	ifp->if_timer = 5;
 	can_bpf_mtap(ifp, m, 0);
 out:
@@ -536,7 +533,7 @@ sunxi_can_ifup(struct sunxi_can_softc * 
 static void
 sunxi_can_ifdown(struct sunxi_can_softc * const sc)
 {
-	sc->sc_ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	sc->sc_ifp->if_flags &= ~IFF_RUNNING;
 	sc->sc_ifp->if_timer = 0;
 	sunxi_can_enter_reset(sc);
 	sunxi_can_write(sc, SUNXI_CAN_INTE_REG, 0);



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

2022-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 02:32:14 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun4i_emac.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun4i_emac.c
diff -u src/sys/arch/arm/sunxi/sun4i_emac.c:1.14 src/sys/arch/arm/sunxi/sun4i_emac.c:1.15
--- src/sys/arch/arm/sunxi/sun4i_emac.c:1.14	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sun4i_emac.c	Sun Sep 18 02:32:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_emac.c,v 1.14 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sun4i_emac.c,v 1.15 2022/09/18 02:32:14 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2013-2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_emac.c,v 1.14 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_emac.c,v 1.15 2022/09/18 02:32:14 thorpej Exp $");
 
 #include 
 #include 
@@ -630,10 +630,7 @@ sun4i_emac_tx_enqueue(struct sun4i_emac_
 static void
 sun4i_emac_tx_intr(struct sun4i_emac_softc *sc, u_int slot)
 {
-	struct ifnet * const ifp = >sc_ec.ec_if;
-
 	sc->sc_tx_active &= ~__BIT(slot);
-	ifp->if_flags &= ~IFF_OACTIVE;
 }
 
 int
@@ -697,9 +694,6 @@ sun4i_emac_ifstart(struct ifnet *ifp)
 		sc->sc_tx_active |= 2;
 	}
 
-	if (sc->sc_tx_active == 3)
-		ifp->if_flags |= IFF_OACTIVE;
-
 	ifp->if_timer = 5;
 
 	mutex_exit(>sc_intr_lock);
@@ -753,7 +747,7 @@ sun4i_emac_ifstop(struct ifnet *ifp, int
 	sun4i_emac_clear_set(sc, EMAC_CTL_REG,
 	EMAC_CTL_RST | EMAC_CTL_TX_EN | EMAC_CTL_RX_EN, 0);
 
-	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+	ifp->if_flags &= ~IFF_RUNNING;
 	ifp->if_timer = 0;
 }
 
@@ -812,7 +806,6 @@ sun4i_emac_ifinit(struct ifnet *ifp)
 	sun4i_emac_int_enable(sc);
 
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
 
 	/* Enable RX/TX */
 	sun4i_emac_clear_set(sc, EMAC_CTL_REG,



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

2022-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 02:32:14 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun4i_emac.c

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



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

2022-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 15 16:58:28 UTC 2022

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

Log Message:
sun8icrypto(4): Switch off polling when ready for interrupts.

When I introduced logic to do polling and then interrupts, I
accidentally made it switch polling from on to...still on, which had
the effect of breaking the logic after sun8i_crypto_attach because
only sun8i_crypto_attach actually did polling.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.30 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.31
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.30	Sat Mar 19 11:37:05 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sun May 15 16:58:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.30 2022/03/19 11:37:05 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.31 2022/05/15 16:58:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.30 2022/03/19 11:37:05 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.31 2022/05/15 16:58:28 riastradh Exp $");
 
 #include 
 #include 
@@ -494,7 +494,7 @@ sun8i_crypto_attach(device_t parent, dev
 	 * be from us because we've kept ICR set to 0 to mask all
 	 * interrupts, but in case the interrupt vector is shared.
 	 */
-	atomic_store_relaxed(>sc_polling, true);
+	atomic_store_relaxed(>sc_polling, false);
 
 	/* Attach the sysctl.  */
 	sun8i_crypto_sysctl_attach(sc);



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

2022-05-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 15 16:58:28 UTC 2022

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

Log Message:
sun8icrypto(4): Switch off polling when ready for interrupts.

When I introduced logic to do polling and then interrupts, I
accidentally made it switch polling from on to...still on, which had
the effect of breaking the logic after sun8i_crypto_attach because
only sun8i_crypto_attach actually did polling.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:57 UTC 2022

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

Log Message:
sun8icrypto(4): Do self-test and first RNG draw synchronously.

If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.29
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28	Fri Mar 18 23:36:42 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:36:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $");
 
 #include 
 #include 
@@ -113,6 +113,7 @@ struct sun8i_crypto_softc {
 
 	struct workqueue		*sc_wq;
 	void*sc_ih;
+	boolsc_polling;
 
 	kmutex_t			sc_lock;
 	struct sun8i_crypto_chan {
@@ -138,6 +139,8 @@ struct sun8i_crypto_softc {
 		struct sun8i_crypto_buf		cs_key;
 		struct sun8i_crypto_buf		cs_out;
 		struct sun8i_crypto_task	*cs_task;
+		boolcs_pending;
+		boolcs_passed;
 	}sc_selftest;
 	struct sun8i_crypto_sysctl {
 		struct sysctllog		*cy_log;
@@ -215,6 +218,11 @@ static void	sun8i_crypto_timeout(void *)
 static int	sun8i_crypto_intr(void *);
 static void	sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_worker(struct work *, void *);
+
+static bool	sun8i_crypto_poll(struct sun8i_crypto_softc *, uint32_t *,
+		uint32_t *);
+static bool	sun8i_crypto_done(struct sun8i_crypto_softc *, uint32_t,
+		uint32_t, unsigned);
 static bool	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
 		int);
 
@@ -228,7 +236,7 @@ static void	sun8i_crypto_rng_get(size_t,
 static void	sun8i_crypto_rng_done(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, void *, int);
 
-static void	sun8i_crypto_selftest(device_t);
+static bool	sun8i_crypto_selftest(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_selftest_done(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, void *, int);
 
@@ -450,9 +458,13 @@ sun8i_crypto_attach(device_t parent, dev
 	aprint_normal(": Crypto Engine\n");
 	aprint_debug_dev(self, ": clock freq %d\n", clk_get_rate(clk));
 
-	/* Disable and clear interrupts.  */
+	/*
+	 * Disable and clear interrupts.  Start in polling mode for
+	 * synchronous self-tests and the first RNG draw.
+	 */
 	sun8i_crypto_write(sc, SUN8I_CRYPTO_ICR, 0);
 	sun8i_crypto_write(sc, SUN8I_CRYPTO_ISR, 0);
+	sc->sc_polling = true;
 
 	/* Establish an interrupt handler.  */
 	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_VM,
@@ -464,15 +476,29 @@ sun8i_crypto_attach(device_t parent, dev
 	}
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
-	/* Set up the RNG.  */
+	/* Perform self-tests.  If they fail, stop here.  */
+	if (!sun8i_crypto_selftest(sc))
+		return;
+
+	/*
+	 * Set up the RNG.  This will try to synchronously draw the
+	 * first sample by polling, so do this before we establish
+	 * the interrupt handler.
+	 */
 	sun8i_crypto_rng_attach(sc);
 
+	/*
+	 * Self-test has passed and first RNG draw has finished.  Use
+	 * interrupts, not polling, for all subsequent tasks.  Set this
+	 * atomically in case the interrupt handler has fired -- can't
+	 * be from us because we've kept ICR set to 0 to mask all
+	 * interrupts, but in case the interrupt vector is shared.
+	 */
+	atomic_store_relaxed(>sc_polling, true);
+
 	/* Attach the sysctl.  */
 	sun8i_crypto_sysctl_attach(sc);
 
-	/* Perform self-tests.  */
-	config_interrupts(self, sun8i_crypto_selftest);
-
 	/* Register opencrypto handlers.  */
 	sun8i_crypto_register(sc);
 }
@@ -896,11 +922,16 @@ sun8i_crypto_submit(struct sun8i_crypto_
 		goto out;
 	}
 
-	/* Enable interrupts for this channel.  */
-	icr = sun8i_crypto_read(sc, SUN8I_CRYPTO_ICR);
-	icr |= __SHIFTIN(SUN8I_CRYPTO_ICR_INTR_EN_CHAN(i),
-	SUN8I_CRYPTO_ICR_INTR_EN);
-	sun8i_crypto_write(sc, SUN8I_CRYPTO_ICR, icr);
+	/*
+	 * Enable interrupts for this channel, unless we're still
+	 * polling.
+	 */
+	if (!sc->sc_polling) {
+		icr = sun8i_crypto_read(sc, SUN8I_CRYPTO_ICR);
+		icr |= __SHIFTIN(SUN8I_CRYPTO_ICR_INTR_EN_CHAN(i),
+		

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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:57 UTC 2022

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

Log Message:
sun8icrypto(4): Do self-test and first RNG draw synchronously.

If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).


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

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:42 UTC 2022

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

Log Message:
sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.

Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27	Fri Mar 18 23:35:48 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:36:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $");
 
 #include 
 #include 
@@ -1284,14 +1284,12 @@ sun8i_crypto_rng_attach(struct sun8i_cry
 	}
 
 	/*
-	 * Attach the rndsource.  This is _not_ marked as RND_TYPE_RNG
-	 * because the output is not uniformly distributed.  The bits
-	 * are heavily weighted toward 0 or 1, at different times, and
-	 * I haven't scienced a satisfactory story out of it yet.
+	 * Attach the rndsource.  This will trigger an initial call to
+	 * it since we have RND_FLAG_HASCB.
 	 */
 	rndsource_setcb(>cr_rndsource, sun8i_crypto_rng_get, sc);
 	rnd_attach_source(>cr_rndsource, device_xname(self),
-	RND_TYPE_UNKNOWN,
+	RND_TYPE_RNG,
 	RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_VALUE|RND_FLAG_HASCB);
 
 	/* Success!  */



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:42 UTC 2022

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

Log Message:
sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.

Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:48 UTC 2022

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

Log Message:
sun8icrypto(4): Split out interrupt and thread locks.

No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26	Sat Aug  7 15:41:00 2021
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:35:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $");
 
 #include 
 #include 
@@ -111,18 +111,22 @@ struct sun8i_crypto_softc {
 
 	const struct sun8i_crypto_config *sc_cfg;
 
+	struct workqueue		*sc_wq;
+	void*sc_ih;
+
 	kmutex_t			sc_lock;
 	struct sun8i_crypto_chan {
 		struct sun8i_crypto_task	*cc_task;
 		unsigned			cc_starttime;
 	}sc_chan[SUN8I_CRYPTO_NCHAN];
 	struct callout			sc_timeout;
-	struct workqueue		*sc_wq;
-	struct work			sc_work;
-	void*sc_ih;
+
+	kmutex_t			sc_intr_lock;
 	uint32_t			sc_done;
 	uint32_t			sc_esr;
+	struct work			sc_work;
 	boolsc_work_pending;
+
 	struct sun8i_crypto_rng {
 		struct sun8i_crypto_buf		cr_buf;
 		struct sun8i_crypto_task	*cr_task;
@@ -381,7 +385,8 @@ sun8i_crypto_attach(device_t parent, dev
 	0, 0, 0, "sun8icry", NULL, IPL_VM,
 	_crypto_task_ctor, _crypto_task_dtor, sc);
 	sc->sc_cfg = of_compatible_lookup(phandle, compat_data)->data;
-	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM);
+	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 	callout_init(>sc_timeout, CALLOUT_MPSAFE);
 	callout_setfunc(>sc_timeout, _crypto_timeout, sc);
 	if (workqueue_create(>sc_wq, device_xname(self),
@@ -948,34 +953,16 @@ out:	/* Done!  */
  *
  *	Timeout handler.  Schedules work in a thread to cancel all
  *	pending tasks that were started long enough ago we're bored of
- *	waiting for them, and reschedules another timeout unless the
- *	channels are all idle.
+ *	waiting for them.
  */
 static void
 sun8i_crypto_timeout(void *cookie)
 {
 	struct sun8i_crypto_softc *sc = cookie;
-	unsigned i;
-
-	mutex_enter(>sc_lock);
 
-	/* Check whether there are any tasks pending.  */
-	for (i = 0; i < SUN8I_CRYPTO_NCHAN; i++) {
-		if (sc->sc_chan[i].cc_task)
-			break;
-	}
-	if (i == SUN8I_CRYPTO_NCHAN)
-		/* None pending, so nothing to do.  */
-		goto out;
-
-	/*
-	 * Schedule the worker to check for timeouts, and schedule
-	 * another timeout in case we need it.
-	 */
+	mutex_enter(>sc_intr_lock);
 	sun8i_crypto_schedule_worker(sc);
-	callout_schedule(>sc_timeout, SUN8I_CRYPTO_TIMEOUT);
-
-out:	mutex_exit(>sc_lock);
+	mutex_exit(>sc_intr_lock);
 }
 
 /*
@@ -991,7 +978,7 @@ sun8i_crypto_intr(void *cookie)
 	struct sun8i_crypto_softc *sc = cookie;
 	uint32_t isr, esr;
 
-	mutex_enter(>sc_lock);
+	mutex_enter(>sc_intr_lock);
 
 	/*
 	 * Get and acknowledge the interrupts and error status.
@@ -1014,7 +1001,7 @@ sun8i_crypto_intr(void *cookie)
 	sc->sc_done |= __SHIFTOUT(isr, SUN8I_CRYPTO_ISR_DONE);
 	sc->sc_esr |= esr;
 
-	mutex_exit(>sc_lock);
+	mutex_exit(>sc_intr_lock);
 
 	return __SHIFTOUT(isr, SUN8I_CRYPTO_ISR_DONE) != 0;
 }
@@ -1029,7 +1016,7 @@ static void
 sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *sc)
 {
 
-	KASSERT(mutex_owned(>sc_lock));
+	KASSERT(mutex_owned(>sc_intr_lock));
 
 	/* Start the worker if necessary.  */
 	if (!sc->sc_work_pending) {
@@ -1052,41 +1039,40 @@ sun8i_crypto_worker(struct work *wk, voi
 	uint32_t done, esr, esr_chan;
 	unsigned i, now;
 	bool unblock = false;
+	bool schedtimeout = false;
 	int error;
 
 	/*
-	 * Acquire the lock.  Note: We will be releasing and
-	 * reacquiring it throughout the loop.
+	 * Under the interrupt lock, acknowledge our work and claim the
+	 * done mask and error status.
 	 */
-	mutex_enter(>sc_lock);
-
-	/* Acknowledge the work.  */
+	mutex_enter(>sc_intr_lock);
 	KASSERT(sc->sc_work_pending);
 	sc->sc_work_pending = false;
-
-	/*
-	 * Claim the done mask and error status once; we will be
-	 * releasing and reacquiring the lock for the callbacks, so
-	 * they may change.
-	 */
 	done = sc->sc_done;
 	esr = sc->sc_esr;
 	sc->sc_done = 0;
 	sc->sc_esr = 0;
+	

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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:48 UTC 2022

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

Log Message:
sun8icrypto(4): Split out interrupt and thread locks.

No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:28:20 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c sunxi_drm.h sunxi_fb.c

Log Message:
sunxi/drm: Use an explicit task queue to avoid config_defer pitfalls.

Same as the other drm drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_drm.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_drm.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_fb.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.21 src/sys/arch/arm/sunxi/sunxi_drm.c:1.22
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.21	Sun Dec 19 11:25:48 2021
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Sun Dec 19 12:28:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.21 2021/12/19 11:25:48 riastradh Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.22 2021/12/19 12:28:20 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.21 2021/12/19 11:25:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.22 2021/12/19 12:28:20 riastradh Exp $");
 
 #include 
 #include 
@@ -91,6 +91,8 @@ static void	sunxi_drm_disable_vblank(str
 static int	sunxi_drm_load(struct drm_device *, unsigned long);
 static void	sunxi_drm_unload(struct drm_device *);
 
+static void	sunxi_drm_task_work(struct work *, void *);
+
 static struct drm_driver sunxi_drm_driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM,
 	.dev_priv_size = 0,
@@ -140,6 +142,14 @@ sunxi_drm_attach(device_t parent, device
 	sc->sc_dmat = faa->faa_dmat;
 	sc->sc_bst = faa->faa_bst;
 	sc->sc_phandle = faa->faa_phandle;
+	sc->sc_task_thread = NULL;
+	SIMPLEQ_INIT(>sc_tasks);
+	if (workqueue_create(>sc_task_wq, "sunxidrm",
+		_drm_task_work, NULL, PRI_NONE, IPL_NONE, WQ_MPSAFE)) {
+		aprint_error_dev(self, "unable to create workqueue\n");
+		sc->sc_task_wq = NULL;
+		return;
+	}
 
 	aprint_naive("\n");
 
@@ -173,16 +183,41 @@ sunxi_drm_init(device_t dev)
 	struct drm_driver * const driver = _drm_driver;
 	int error;
 
+	/*
+	 * Cause any tasks issued synchronously during attach to be
+	 * processed at the end of this function.
+	 */
+	sc->sc_task_thread = curlwp;
+
 	error = -drm_dev_register(sc->sc_ddev, 0);
 	if (error) {
 		aprint_error_dev(dev, "couldn't register DRM device: %d\n",
 		error);
-		return;
+		goto out;
 	}
+	sc->sc_dev_registered = true;
 
 	aprint_normal_dev(dev, "initialized %s %d.%d.%d %s on minor %d\n",
 	driver->name, driver->major, driver->minor, driver->patchlevel,
 	driver->date, sc->sc_ddev->primary->index);
+
+	/*
+	 * Process asynchronous tasks queued synchronously during
+	 * attach.  This will be for display detection to attach a
+	 * framebuffer, so we have the opportunity for a console device
+	 * to attach before autoconf has completed, in time for init(8)
+	 * to find that console without panicking.
+	 */
+	while (!SIMPLEQ_EMPTY(>sc_tasks)) {
+		struct sunxi_drm_task *const task =
+		SIMPLEQ_FIRST(>sc_tasks);
+
+		SIMPLEQ_REMOVE_HEAD(>sc_tasks, sdt_u.queue);
+		(*task->sdt_fn)(task);
+	}
+
+out:	/* Cause any subesquent tasks to be processed by the workqueue.  */
+	atomic_store_relaxed(>sc_task_thread, NULL);
 }
 
 static vmem_t *
@@ -532,3 +567,31 @@ sunxi_drm_endpoint_device(struct fdt_end
 
 	return NULL;
 }
+
+static void
+sunxi_drm_task_work(struct work *work, void *cookie)
+{
+	struct sunxi_drm_task *task = container_of(work, struct sunxi_drm_task,
+	sdt_u.work);
+
+	(*task->sdt_fn)(task);
+}
+
+void
+sunxi_task_init(struct sunxi_drm_task *task,
+void (*fn)(struct sunxi_drm_task *))
+{
+
+	task->sdt_fn = fn;
+}
+
+void
+sunxi_task_schedule(device_t self, struct sunxi_drm_task *task)
+{
+	struct sunxi_drm_softc *sc = device_private(self);
+
+	if (atomic_load_relaxed(>sc_task_thread) == curlwp)
+		SIMPLEQ_INSERT_TAIL(>sc_tasks, task, sdt_u.queue);
+	else
+		workqueue_enqueue(sc->sc_task_wq, >sdt_u.work, NULL);
+}

Index: src/sys/arch/arm/sunxi/sunxi_drm.h
diff -u src/sys/arch/arm/sunxi/sunxi_drm.h:1.2 src/sys/arch/arm/sunxi/sunxi_drm.h:1.3
--- src/sys/arch/arm/sunxi/sunxi_drm.h:1.2	Mon Feb  4 12:10:13 2019
+++ src/sys/arch/arm/sunxi/sunxi_drm.h	Sun Dec 19 12:28:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.h,v 1.2 2019/02/04 12:10:13 jmcneill Exp $ */
+/* $NetBSD: sunxi_drm.h,v 1.3 2021/12/19 12:28:20 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -29,6 +29,9 @@
 #ifndef _ARM_SUNXI_DRM_H
 #define _ARM_SUNXI_DRM_H
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -62,6 +65,12 @@ struct sunxi_drm_softc {
 
 	int			sc_phandle;
 
+	struct lwp			*sc_task_thread;
+	SIMPLEQ_HEAD(, sunxi_drm_task)	sc_tasks;
+	struct workqueue		*sc_task_wq;
+
+	bool			sc_dev_registered;
+
 	struct sunxi_drm_vblank	

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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 12:28:20 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_drm.c sunxi_drm.h sunxi_fb.c

Log Message:
sunxi/drm: Use an explicit task queue to avoid config_defer pitfalls.

Same as the other drm drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_drm.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_drm.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_fb.c

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



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:25 UTC 2021

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

Log Message:
Defer call to drmfb_attach, otherwise we lock against ourselves

Mutex error: mutex_vector_enter,542: locking against myself

lockdebug_abort() at ffc0004ba3ec netbsd:lockdebug_abort+0xcc
mutex_enter() at ffc000476af4 netbsd:mutex_enter+0x3d4
drm_fb_helper_restore_fbdev_mode_unlocked() at ffc0003432a8
netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60
drmfb_genfb_setmode() at ffc00031c428
netbsd:drmfb_genfb_setmode+0x18
genfb_attach() at ffc000377b04 netbsd:genfb_attach+0x10c
drmfb_attach() at ffc00031c808 netbsd:drmfb_attach+0x1d0
sunxi_fb_attach() at ffc5a648 netbsd:sunxi_fb_attach+0xd0
config_attach_loc() at ffc0004a7174 netbsd:config_attach_loc+0x184
config_found_sm_loc() at ffc0004a72a0
netbsd:config_found_sm_loc+0x58
sunxi_drm_fb_probe() at ffc5a078 netbsd:sunxi_drm_fb_probe+0x250
__drm_fb_helper_initial_config_and_unlock() at ffc000342bdc
netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4
sunxi_drm_load() at ffc5a384 netbsd:sunxi_drm_load+0x154
drm_dev_register() at ffc00033b728 netbsd:drm_dev_register+0xe0
sunxi_drm_init() at ffc59d40 netbsd:sunxi_drm_init+0x20
config_process_deferred() at ffc0004a6efc
netbsd:config_process_deferred+0xac
config_attach_loc() at ffc0004a7190 netbsd:config_attach_loc+0x1a0
config_found_sm_loc() at ffc0004a72a0
netbsd:config_found_sm_loc+0x58
arm_fdt_attach() at ffc61e34 netbsd:arm_fdt_attach+0x64
config_attach_loc() at ffc0004a7174 netbsd:config_attach_loc+0x184
cpu_configure() at ffc5dab4 netbsd:cpu_configure+0x44
main() at ffc000605284 netbsd:main+0x2b4
aarch64_start() at ffc01854 netbsd:aarch64_start+0x1054

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_fb.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_fb.c
diff -u src/sys/arch/arm/sunxi/sunxi_fb.c:1.5 src/sys/arch/arm/sunxi/sunxi_fb.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_fb.c:1.5	Sun Dec 19 11:01:10 2021
+++ src/sys/arch/arm/sunxi/sunxi_fb.c	Sun Dec 19 11:25:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_fb.c,v 1.5 2021/12/19 11:01:10 riastradh Exp $ */
+/* $NetBSD: sunxi_fb.c,v 1.6 2021/12/19 11:25:25 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_fb.c,v 1.5 2021/12/19 11:01:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_fb.c,v 1.6 2021/12/19 11:25:25 riastradh Exp $");
 
 #include 
 #include 
@@ -45,6 +45,8 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_fb.c,v
 static int	sunxi_fb_match(device_t, cfdata_t, void *);
 static void	sunxi_fb_attach(device_t, device_t, void *);
 
+static void	sunxi_fb_init(device_t);
+
 static bool	sunxi_fb_shutdown(device_t, int);
 
 struct sunxi_fb_softc {
@@ -80,7 +82,6 @@ sunxi_fb_attach(device_t parent, device_
 	struct sunxi_fb_softc * const sc = device_private(self);
 	struct sunxi_drm_softc * const drmsc = device_private(parent);
 	struct sunxi_drmfb_attach_args * const sfa = aux;
-	int error;
 
 	sc->sc_dev = self;
 	sc->sc_drm = drmsc;
@@ -95,9 +96,18 @@ sunxi_fb_attach(device_t parent, device_
 	const bool is_console = true;
 	prop_dictionary_set_bool(dict, "is_console", is_console);
 #endif
+	config_defer(self, sunxi_fb_init);
+}
+
+static void
+sunxi_fb_init(device_t dev)
+{
+	struct sunxi_fb_softc * const sc = device_private(dev);
+	struct sunxi_drmfb_attach_args * const sfa = >sc_sfa;
+	int error;
 
 	const struct drmfb_attach_args da = {
-		.da_dev = self,
+		.da_dev = dev,
 		.da_fb_helper = sfa->sfa_fb_helper,
 		.da_fb_sizes = >sfa_fb_sizes,
 		.da_fb_vaddr = sc->sc_fb->obj->vaddr,
@@ -105,13 +115,14 @@ sunxi_fb_attach(device_t parent, device_
 		.da_params = _drmfb_params,
 	};
 
+
 	error = drmfb_attach(>sc_drmfb, );
 	if (error) {
-		aprint_error_dev(self, "failed to attach drmfb: %d\n", error);
+		aprint_error_dev(dev, "failed to attach drmfb: %d\n", error);
 		return;
 	}
 
-	pmf_device_register1(self, NULL, NULL, sunxi_fb_shutdown);
+	pmf_device_register1(dev, NULL, NULL, sunxi_fb_shutdown);
 }
 
 static bool



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:25 UTC 2021

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

Log Message:
Defer call to drmfb_attach, otherwise we lock against ourselves

Mutex error: mutex_vector_enter,542: locking against myself

lockdebug_abort() at ffc0004ba3ec netbsd:lockdebug_abort+0xcc
mutex_enter() at ffc000476af4 netbsd:mutex_enter+0x3d4
drm_fb_helper_restore_fbdev_mode_unlocked() at ffc0003432a8
netbsd:drm_fb_helper_restore_fbdev_mode_unlocked+0x60
drmfb_genfb_setmode() at ffc00031c428
netbsd:drmfb_genfb_setmode+0x18
genfb_attach() at ffc000377b04 netbsd:genfb_attach+0x10c
drmfb_attach() at ffc00031c808 netbsd:drmfb_attach+0x1d0
sunxi_fb_attach() at ffc5a648 netbsd:sunxi_fb_attach+0xd0
config_attach_loc() at ffc0004a7174 netbsd:config_attach_loc+0x184
config_found_sm_loc() at ffc0004a72a0
netbsd:config_found_sm_loc+0x58
sunxi_drm_fb_probe() at ffc5a078 netbsd:sunxi_drm_fb_probe+0x250
__drm_fb_helper_initial_config_and_unlock() at ffc000342bdc
netbsd:__drm_fb_helper_initial_config_and_unlock+0x2a4
sunxi_drm_load() at ffc5a384 netbsd:sunxi_drm_load+0x154
drm_dev_register() at ffc00033b728 netbsd:drm_dev_register+0xe0
sunxi_drm_init() at ffc59d40 netbsd:sunxi_drm_init+0x20
config_process_deferred() at ffc0004a6efc
netbsd:config_process_deferred+0xac
config_attach_loc() at ffc0004a7190 netbsd:config_attach_loc+0x1a0
config_found_sm_loc() at ffc0004a72a0
netbsd:config_found_sm_loc+0x58
arm_fdt_attach() at ffc61e34 netbsd:arm_fdt_attach+0x64
config_attach_loc() at ffc0004a7174 netbsd:config_attach_loc+0x184
cpu_configure() at ffc5dab4 netbsd:cpu_configure+0x44
main() at ffc000605284 netbsd:main+0x2b4
aarch64_start() at ffc01854 netbsd:aarch64_start+0x1054

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_fb.c

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



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:17 UTC 2021

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

Log Message:
Use helper to fill fb struct

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sunxi_drm.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.19 src/sys/arch/arm/sunxi/sunxi_drm.c:1.20
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.19	Sun Dec 19 11:25:09 2021
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Sun Dec 19 11:25:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.19 2021/12/19 11:25:09 riastradh Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.20 2021/12/19 11:25:17 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.19 2021/12/19 11:25:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.20 2021/12/19 11:25:17 riastradh Exp $");
 
 #include 
 #include 
@@ -266,15 +266,7 @@ sunxi_drm_fb_create(struct drm_device *d
 
 	fb = kmem_zalloc(sizeof(*fb), KM_SLEEP);
 	fb->obj = to_drm_gem_cma_obj(gem_obj);
-	fb->base.pitches[0] = cmd->pitches[0];
-	fb->base.pitches[1] = cmd->pitches[1];
-	fb->base.pitches[2] = cmd->pitches[2];
-	fb->base.offsets[0] = cmd->offsets[0];
-	fb->base.offsets[1] = cmd->offsets[2];
-	fb->base.offsets[2] = cmd->offsets[1];
-	fb->base.width = cmd->width;
-	fb->base.height = cmd->height;
-	fb->base.format = drm_format_info(cmd->pixel_format);
+	drm_helper_mode_fill_fb_struct(ddev, >base, cmd);
 
 	error = drm_framebuffer_init(ddev, >base, _drm_framebuffer_funcs);
 	if (error != 0)



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:17 UTC 2021

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

Log Message:
Use helper to fill fb struct

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sunxi_drm.c

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



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:09 UTC 2021

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

Log Message:
Fill fb->dev.

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sunxi_drm.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.18 src/sys/arch/arm/sunxi/sunxi_drm.c:1.19
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.18	Sun Dec 19 11:01:21 2021
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Sun Dec 19 11:25:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.18 2021/12/19 11:01:21 riastradh Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.19 2021/12/19 11:25:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.18 2021/12/19 11:01:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.19 2021/12/19 11:25:09 riastradh Exp $");
 
 #include 
 #include 
@@ -383,6 +383,7 @@ sunxi_drm_fb_probe(struct drm_fb_helper 
 	fb->width = width;
 	fb->height = height;
 	fb->format = drm_format_info(DRM_FORMAT_XRGB);
+	fb->dev = ddev;
 
 	error = drm_framebuffer_init(ddev, fb, _drm_framebuffer_funcs);
 	if (error != 0) {



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

2021-12-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Dec 19 11:25:09 UTC 2021

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

Log Message:
Fill fb->dev.

Author: Maya Rashish 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sunxi_drm.c

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



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

2021-11-10 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Nov 10 17:38:11 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun50i_h6_gpio.c sun50i_h6_r_ccu.c
sun50i_h6_r_ccu.h

Log Message:
add clock and reset for APB2 RSB on Allwinner H6


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun50i_h6_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun50i_h6_gpio.c
diff -u src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.3 src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.4
--- src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.3	Mon Nov  8 17:58:27 2021
+++ src/sys/arch/arm/sunxi/sun50i_h6_gpio.c	Wed Nov 10 17:38:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_h6_gpio.c,v 1.3 2021/11/08 17:58:27 jakllsch Exp $ */
+/* $NetBSD: sun50i_h6_gpio.c,v 1.4 2021/11/10 17:38:11 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2016 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun50i_h6_gpio.c,v 1.3 2021/11/08 17:58:27 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_h6_gpio.c,v 1.4 2021/11/10 17:38:11 jakllsch Exp $");
 
 #include 
 #include 
@@ -121,8 +121,8 @@ static const struct sunxi_gpio_pins h6_p
 };
 
 static const struct sunxi_gpio_pins h6_r_pins[] = {
-	{ "PL0",   0, 0,  { "gpio_in", "gpio_out", NULL, "s_i2c", NULL, NULL, "irq" }, 6, 0 },
-	{ "PL1",   0, 1,  { "gpio_in", "gpio_out", NULL, "s_i2c", NULL, NULL, "irq" }, 6, 1 },
+	{ "PL0",   0, 0,  { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "irq" }, 6, 0 },
+	{ "PL1",   0, 1,  { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "irq" }, 6, 1 },
 	{ "PL2",   0, 2,  { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "irq" }, 6, 2 },
 	{ "PL3",   0, 3,  { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "irq" }, 6, 3 },
 	{ "PL4",   0, 4,  { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "irq" }, 6, 4 },

Index: src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c:1.2 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c:1.3
--- src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c:1.2	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c	Wed Nov 10 17:38:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_h6_r_ccu.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sun50i_h6_r_ccu.c,v 1.3 2021/11/10 17:38:11 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_h6_r_ccu.c,v 1.2 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_h6_r_ccu.c,v 1.3 2021/11/10 17:38:11 jakllsch Exp $");
 
 #include 
 #include 
@@ -63,6 +63,7 @@ static struct sunxi_ccu_reset sun50i_h6_
 	SUNXI_CCU_RESET(H6_R_RST_APB1_PWM, 0x13c, 16),
 	SUNXI_CCU_RESET(H6_R_RST_APB2_UART, 0x18c, 16),
 	SUNXI_CCU_RESET(H6_R_RST_APB2_I2C, 0x19c, 16),
+	SUNXI_CCU_RESET(H6_R_RST_APB2_RSB, 0x1bc, 16),
 	SUNXI_CCU_RESET(H6_R_RST_APB1_IR, 0x1cc, 16),
 	SUNXI_CCU_RESET(H6_R_RST_APB1_W1, 0x1ec, 16),
 };
@@ -102,6 +103,7 @@ static struct sunxi_ccu_clk sun50i_h6_r_
 	SUNXI_CCU_GATE(H6_R_CLK_APB1_PWM, "apb1-pwm", "apb1", 0x13c, 0),
 	SUNXI_CCU_GATE(H6_R_CLK_APB2_UART, "apb2-uart", "apb2", 0x18c, 0),
 	SUNXI_CCU_GATE(H6_R_CLK_APB2_I2C, "apb2-i2c", "apb2", 0x19c, 0),
+	SUNXI_CCU_GATE(H6_R_CLK_APB2_RSB, "apb2-rsb", "apb2", 0x1bc, 0),
 	SUNXI_CCU_GATE(H6_R_CLK_APB1_IR, "apb1-ir", "apb1", 0x1cc, 0),
 	SUNXI_CCU_GATE(H6_R_CLK_APB1_W1, "apb1-w1", "apb1", 0x1ec, 0),
 

Index: src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h
diff -u src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h:1.1 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h:1.2
--- src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h:1.1	Wed May  2 11:02:21 2018
+++ src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h	Wed Nov 10 17:38:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_h6_r_ccu.h,v 1.1 2018/05/02 11:02:21 jmcneill Exp $ */
+/* $NetBSD: sun50i_h6_r_ccu.h,v 1.2 2021/11/10 17:38:11 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -36,6 +36,7 @@
 #define	H6_R_RST_APB2_I2C	4
 #define	H6_R_RST_APB1_IR	5
 #define	H6_R_RST_APB1_W1	6
+#define	H6_R_RST_APB2_RSB	7
 
 #define	H6_R_CLK_AR100		0
 #define	H6_R_CLK_AHB		1
@@ -50,5 +51,6 @@
 #define	H6_R_CLK_APB1_W1	10
 #define	H6_R_CLK_IR		11
 #define	H6_R_CLK_W1		12
+#define	H6_R_CLK_APB2_RSB	13
 
 #endif /* !_SUN50I_H6_R_CCU_H */



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

2021-11-10 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Nov 10 17:38:11 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun50i_h6_gpio.c sun50i_h6_r_ccu.c
sun50i_h6_r_ccu.h

Log Message:
add clock and reset for APB2 RSB on Allwinner H6


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun50i_h6_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun50i_h6_r_ccu.h

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



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

2021-11-08 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Nov  8 17:58:27 UTC 2021

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

Log Message:
This H6 pin (PL9) function is called s_cir_rx, not s_cir.


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun50i_h6_gpio.c
diff -u src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.2 src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.3
--- src/sys/arch/arm/sunxi/sun50i_h6_gpio.c:1.2	Tue Apr  3 16:01:25 2018
+++ src/sys/arch/arm/sunxi/sun50i_h6_gpio.c	Mon Nov  8 17:58:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_h6_gpio.c,v 1.2 2018/04/03 16:01:25 bouyer Exp $ */
+/* $NetBSD: sun50i_h6_gpio.c,v 1.3 2021/11/08 17:58:27 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2016 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun50i_h6_gpio.c,v 1.2 2018/04/03 16:01:25 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_h6_gpio.c,v 1.3 2021/11/08 17:58:27 jakllsch Exp $");
 
 #include 
 #include 
@@ -130,7 +130,7 @@ static const struct sunxi_gpio_pins h6_r
 	{ "PL6",   0, 6,  { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "irq" }, 6, 6 },
 	{ "PL7",   0, 7,  { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "irq" }, 6, 7 },
 	{ "PL8",   0, 8,  { "gpio_in", "gpio_out", "s_i2s", NULL, NULL, NULL, "irq" }, 6, 8 },
-	{ "PL9",   0, 9,  { "gpio_in", "gpio_out", "s_cir", NULL, NULL, NULL, "irq" }, 6, 9 },
+	{ "PL9",   0, 9,  { "gpio_in", "gpio_out", "s_cir_rx", NULL, NULL, NULL, "irq" }, 6, 9 },
 	{ "PL10",  0, 10, { "gpio_in", "gpio_out", "s_spdif", NULL, NULL, NULL, "irq" }, 6, 10 },
 
 	{ "PM0",   1, 0,  { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "irq" }, 6, 0 },



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

2021-11-08 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Nov  8 17:58:27 UTC 2021

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

Log Message:
This H6 pin (PL9) function is called s_cir_rx, not s_cir.


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

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



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:38 UTC 2021

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

Log Message:
sunxi: nmi: add support for #interrupt-cells 3 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_nmi.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_nmi.c
diff -u src/sys/arch/arm/sunxi/sunxi_nmi.c:1.11 src/sys/arch/arm/sunxi/sunxi_nmi.c:1.12
--- src/sys/arch/arm/sunxi/sunxi_nmi.c:1.11	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sunxi_nmi.c	Sun Nov  7 17:13:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_nmi.c,v 1.11 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sunxi_nmi.c,v 1.12 2021/11/07 17:13:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -29,7 +29,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_nmi.c,v 1.11 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_nmi.c,v 1.12 2021/11/07 17:13:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -105,6 +105,9 @@ struct sunxi_nmi_softc {
 	bus_space_handle_t sc_bsh;
 	int sc_phandle;
 
+	u_int sc_intr_nmi;
+	u_int sc_intr_cells;
+
 	kmutex_t sc_intr_lock;
 
 	const struct sunxi_nmi_config *sc_config;
@@ -177,22 +180,54 @@ sunxi_nmi_fdt_establish(device_t dev, u_
 int (*func)(void *), void *arg, const char *xname)
 {
 	struct sunxi_nmi_softc * const sc = device_private(dev);
-	u_int irq_type;
+	u_int irq_type, irq, pol;
 	int ist;
 
-	/* 1st cell is the interrupt number */
-	const u_int irq = be32toh(specifier[0]);
-	/* 2nd cell is polarity */
-	const u_int pol = be32toh(specifier[1]);
+	if (sc->sc_intr_cells == 2) {
+		/* 1st cell is the interrupt number */
+		irq = be32toh(specifier[0]);
+		/* 2nd cell is polarity */
+		pol = be32toh(specifier[1]);
+	} else {
+		/* 1st cell is the GIC interrupt type and must be GIC_SPI */
+		if (be32toh(specifier[0]) != 0) {
+#ifdef DIAGNOSTIC
+			device_printf(dev, "GIC intr type %u is invalid\n",
+			be32toh(specifier[0]));
+#endif
+			return NULL;
+		}
+		/* 2nd cell is the interrupt number */
+		irq = be32toh(specifier[1]);
+		/* 3rd cell is polarity */
+		pol = be32toh(specifier[2]);
+	}
 
-	if (irq != 0) {
+	if (sc->sc_intr_cells == 3 && irq != sc->sc_intr_nmi) {
+		/*
+		 * Driver is requesting a wakeup irq, which we don't
+		 * support today. Just pass it through to the parent
+		 * interrupt controller.
+		 */
+		const int ihandle = fdtbus_intr_parent(sc->sc_phandle);
+		if (ihandle == -1) {
+#ifdef DIAGNOSTIC
+			device_printf(dev, "couldn't find interrupt parent\n");
+#endif
+			return NULL;
+		}
+		return fdtbus_intr_establish_raw(ihandle, specifier, ipl,
+		flags, func, arg, xname);
+	}
+
+	if (sc->sc_intr_cells == 2 && irq != 0) {
 #ifdef DIAGNOSTIC
 		device_printf(dev, "IRQ %u is invalid\n", irq);
 #endif
 		return NULL;
 	}
 
-	switch (pol & 0x7) {
+	switch (pol & 0xf) {
 	case 1:	/* IRQ_TYPE_EDGE_RISING */
 		irq_type = NMI_CTRL_IRQ_HIGH_EDGE;
 		ist = IST_EDGE;
@@ -201,11 +236,11 @@ sunxi_nmi_fdt_establish(device_t dev, u_
 		irq_type = NMI_CTRL_IRQ_LOW_EDGE;
 		ist = IST_EDGE;
 		break;
-	case 3:	/* IRQ_TYPE_LEVEL_HIGH */
+	case 4:	/* IRQ_TYPE_LEVEL_HIGH */
 		irq_type = NMI_CTRL_IRQ_HIGH_LEVEL;
 		ist = IST_LEVEL;
 		break;
-	case 4:	/* IRQ_TYPE_LEVEL_LOW */
+	case 8:	/* IRQ_TYPE_LEVEL_LOW */
 		irq_type = NMI_CTRL_IRQ_LOW_LEVEL;
 		ist = IST_LEVEL;
 		break;
@@ -296,6 +331,18 @@ sunxi_nmi_fdt_intrstr(device_t dev, u_in
 {
 	struct sunxi_nmi_softc * const sc = device_private(dev);
 
+	if (sc->sc_intr_cells == 3) {
+		const u_int irq = be32toh(specifier[1]);
+		if (irq != sc->sc_intr_nmi) {
+			const int ihandle = fdtbus_intr_parent(sc->sc_phandle);
+			if (ihandle == -1) {
+return false;
+			}
+			return fdtbus_intr_str_raw(ihandle, specifier, buf,
+			buflen);
+		}
+	}
+
 	snprintf(buf, buflen, "%s", sc->sc_config->name);
 
 	return true;
@@ -323,9 +370,10 @@ sunxi_nmi_attach(device_t parent, device
 	struct sunxi_nmi_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
+	const u_int *interrupts;
 	bus_addr_t addr;
 	bus_size_t size;
-	int error;
+	int error, len;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
@@ -341,8 +389,18 @@ sunxi_nmi_attach(device_t parent, device
 		return;
 	}
 
+	of_getprop_uint32(phandle, "#interrupt-cells", >sc_intr_cells);
+	interrupts = fdtbus_get_prop(phandle, "interrupts", );
+	if (interrupts == NULL || len != 12 ||
+	be32toh(interrupts[0]) != 0 /* GIC_SPI */ ||
+	be32toh(interrupts[2]) != 4 /* IRQ_TYPE_LEVEL_HIGH */) {
+		aprint_error(": couldn't find GIC SPI for NMI\n");
+		return;
+	}
+	sc->sc_intr_nmi = be32toh(interrupts[1]);
+
 	aprint_naive("\n");
-	aprint_normal(": %s\n", sc->sc_config->name);
+	aprint_normal(": 

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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:38 UTC 2021

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

Log Message:
sunxi: nmi: add support for #interrupt-cells 3 bindings


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_nmi.c

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



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:26 UTC 2021

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

Log Message:
sunxi: sun50i-a64: add support for A64_CLK_CPUX clock


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.23 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.24
--- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.23	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c	Sun Nov  7 17:13:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_ccu.c,v 1.23 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sun50i_a64_ccu.c,v 1.24 2021/11/07 17:13:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.23 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.24 2021/11/07 17:13:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -48,6 +48,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c
 #define	PLL_VIDEO1_CTRL_REG	0x030
 #define	PLL_GPU_CTRL_REG	0x038
 #define	PLL_DE_CTRL_REG		0x048
+#define	CPUX_AXI_CFG_REG	0x050
 #define	AHB1_APB1_CFG_REG	0x054
 #define	APB2_CFG_REG		0x058
 #define	AHB2_CFG_REG		0x05c
@@ -153,6 +154,7 @@ static struct sunxi_ccu_reset sun50i_a64
 	SUNXI_CCU_RESET(A64_RST_BUS_UART3, BUS_SOFT_RST_REG4, 19),
 };
 
+static const char *cpux_parents[] = { "losc", "hosc", "pll_cpux", "pll_cpux" };
 static const char *ahb1_parents[] = { "losc", "hosc", "axi", "pll_periph0" };
 static const char *ahb2_parents[] = { "ahb1", "pll_periph0" };
 static const char *apb1_parents[] = { "ahb1" };
@@ -347,6 +349,11 @@ static struct sunxi_ccu_clk sun50i_a64_c
 	__BIT(31),			/* enable */
 	SUNXI_CCU_FRACTIONAL_PLUSONE | SUNXI_CCU_FRACTIONAL_SET_ENABLE),
 
+	SUNXI_CCU_MUX(A64_CLK_CPUX, "cpux", cpux_parents,
+	CPUX_AXI_CFG_REG,	/* reg */
+	__BITS(17,16),	/* sel */
+	0),
+
 	SUNXI_CCU_PREDIV(A64_CLK_AHB1, "ahb1", ahb1_parents,
 	AHB1_APB1_CFG_REG,	/* reg */
 	__BITS(7,6),	/* prediv */



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:26 UTC 2021

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

Log Message:
sunxi: sun50i-a64: add support for A64_CLK_CPUX clock


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c

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



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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:12 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi sunxi_ccu.c sunxi_ccu.h
Added Files:
src/sys/arch/arm/sunxi: sunxi_ccu_mux.c

Log Message:
sunxi: ccu: add support for basic "mux" clocks


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sunxi_ccu.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sunxi/sunxi_ccu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sunxi_ccu_mux.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.69 src/sys/arch/arm/sunxi/files.sunxi:1.70
--- src/sys/arch/arm/sunxi/files.sunxi:1.69	Wed May  5 10:24:04 2021
+++ src/sys/arch/arm/sunxi/files.sunxi	Sun Nov  7 17:13:12 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.69 2021/05/05 10:24:04 jmcneill Exp $
+#	$NetBSD: files.sunxi,v 1.70 2021/11/07 17:13:12 jmcneill Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -16,6 +16,7 @@ file	arch/arm/sunxi/sunxi_ccu_div.c		sun
 file	arch/arm/sunxi/sunxi_ccu_fixed_factor.c	sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_fractional.c	sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_gate.c		sunxi_ccu
+file	arch/arm/sunxi/sunxi_ccu_mux.c		sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_nm.c		sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_nkmp.c		sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_phase.c	sunxi_ccu

Index: src/sys/arch/arm/sunxi/sunxi_ccu.c
diff -u src/sys/arch/arm/sunxi/sunxi_ccu.c:1.13 src/sys/arch/arm/sunxi/sunxi_ccu.c:1.14
--- src/sys/arch/arm/sunxi/sunxi_ccu.c:1.13	Thu Nov 29 20:33:09 2018
+++ src/sys/arch/arm/sunxi/sunxi_ccu.c	Sun Nov  7 17:13:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.c,v 1.13 2018/11/29 20:33:09 jakllsch Exp $ */
+/* $NetBSD: sunxi_ccu.c,v 1.14 2021/11/07 17:13:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu.c,v 1.13 2018/11/29 20:33:09 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu.c,v 1.14 2021/11/07 17:13:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -359,6 +359,7 @@ sunxi_ccu_print(struct sunxi_ccu_softc *
 		case SUNXI_CCU_PHASE:		type = "phase"; break;
 		case SUNXI_CCU_FIXED_FACTOR:	type = "fixed-factor"; break;
 		case SUNXI_CCU_FRACTIONAL:	type = "fractional"; break;
+		case SUNXI_CCU_MUX:		type = "mux"; break;
 		default:			type = "???"; break;
 		}
 

Index: src/sys/arch/arm/sunxi/sunxi_ccu.h
diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.22 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.23
--- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.22	Sat Nov 23 03:59:39 2019
+++ src/sys/arch/arm/sunxi/sunxi_ccu.h	Sun Nov  7 17:13:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.22 2019/11/23 03:59:39 jakllsch Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.23 2021/11/07 17:13:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -64,6 +64,7 @@ enum sunxi_ccu_clktype {
 	SUNXI_CCU_PHASE,
 	SUNXI_CCU_FIXED_FACTOR,
 	SUNXI_CCU_FRACTIONAL,
+	SUNXI_CCU_MUX,
 };
 
 struct sunxi_ccu_gate {
@@ -413,6 +414,34 @@ const char *sunxi_ccu_fractional_get_par
 		.get_parent = sunxi_ccu_fractional_get_parent,		\
 	}
 
+struct sunxi_ccu_mux {
+	bus_size_t	reg;
+	const char	**parents;
+	u_int		nparents;
+	uint32_t	sel;
+	uint32_t	flags;
+};
+
+int	sunxi_ccu_mux_set_parent(struct sunxi_ccu_softc *,
+ struct sunxi_ccu_clk *,
+ const char *);
+const char *sunxi_ccu_mux_get_parent(struct sunxi_ccu_softc *,
+ struct sunxi_ccu_clk *);
+
+#define	SUNXI_CCU_MUX(_id, _name, _parents, _reg, _sel, _flags)	\
+	[_id] = {		\
+		.type = SUNXI_CCU_MUX,\
+		.base.name = (_name),\
+		.u.mux.reg = (_reg),\
+		.u.mux.parents = (_parents),			\
+		.u.mux.nparents = __arraycount(_parents),	\
+		.u.mux.sel = (_sel),\
+		.u.mux.flags = (_flags),			\
+		.set_parent = sunxi_ccu_mux_set_parent,		\
+		.get_parent = sunxi_ccu_mux_get_parent,		\
+	}
+
+
 struct sunxi_ccu_clk {
 	struct clk	base;
 	enum sunxi_ccu_clktype type;
@@ -425,6 +454,7 @@ struct sunxi_ccu_clk {
 		struct sunxi_ccu_phase phase;
 		struct sunxi_ccu_fixed_factor fixed_factor;
 		struct sunxi_ccu_fractional fractional;
+		struct sunxi_ccu_mux mux;
 	} u;
 
 	int		(*enable)(struct sunxi_ccu_softc *,

Added files:

Index: src/sys/arch/arm/sunxi/sunxi_ccu_mux.c
diff -u /dev/null src/sys/arch/arm/sunxi/sunxi_ccu_mux.c:1.1
--- /dev/null	Sun Nov  7 17:13:12 2021
+++ src/sys/arch/arm/sunxi/sunxi_ccu_mux.c	Sun Nov  7 17:13:12 2021
@@ -0,0 +1,82 @@
+/* $NetBSD: sunxi_ccu_mux.c,v 1.1 2021/11/07 17:13:12 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ 

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

2021-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  7 17:13:12 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi sunxi_ccu.c sunxi_ccu.h
Added Files:
src/sys/arch/arm/sunxi: sunxi_ccu_mux.c

Log Message:
sunxi: ccu: add support for basic "mux" clocks


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sunxi_ccu.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sunxi/sunxi_ccu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sunxi_ccu_mux.c

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



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

2021-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  7 15:41:01 UTC 2021

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

Log Message:
sun8icrypto(4): Call crypto_unblock when a task completes.

Otherwise under load this would presumably just hang after returning
ERESTART to opencrypto.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.25 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.25	Wed Apr 28 16:57:05 2021
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sat Aug  7 15:41:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.25 2021/04/28 16:57:05 bad Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.25 2021/04/28 16:57:05 bad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $");
 
 #include 
 #include 
@@ -211,7 +211,7 @@ static void	sun8i_crypto_timeout(void *)
 static int	sun8i_crypto_intr(void *);
 static void	sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_worker(struct work *, void *);
-static void	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
+static bool	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
 		int);
 
 static int	sun8i_crypto_allocbuf(struct sun8i_crypto_softc *, size_t,
@@ -1051,6 +1051,7 @@ sun8i_crypto_worker(struct work *wk, voi
 	struct sun8i_crypto_softc *sc = cookie;
 	uint32_t done, esr, esr_chan;
 	unsigned i, now;
+	bool unblock = false;
 	int error;
 
 	/*
@@ -1084,7 +1085,8 @@ sun8i_crypto_worker(struct work *wk, voi
 			if ((sc->sc_chan[i].cc_task != NULL) &&
 			((now - sc->sc_chan[i].cc_starttime) >=
 SUN8I_CRYPTO_TIMEOUT))
-sun8i_crypto_chan_done(sc, i, ETIMEDOUT);
+unblock |= sun8i_crypto_chan_done(sc, i,
+ETIMEDOUT);
 			continue;
 		}
 
@@ -1112,11 +1114,23 @@ sun8i_crypto_worker(struct work *wk, voi
 		 * Notify the task of completion.  May release the lock
 		 * to invoke a callback.
 		 */
-		sun8i_crypto_chan_done(sc, i, error);
+		unblock |= sun8i_crypto_chan_done(sc, i, error);
 	}
 
 	/* All one; release the lock one last time.  */
 	mutex_exit(>sc_lock);
+
+	/*
+	 * If we cleared any channels, it is time to allow opencrypto
+	 * to issue new operations.  Asymmetric operations (which we
+	 * don't support, at the moment, but we could) and symmetric
+	 * operations (which we do) use the same task channels, so we
+	 * unblock both kinds.
+	 */
+	if (unblock) {
+		crypto_unblock(sc->sc_opencrypto.co_driverid,
+		CRYPTO_SYMQ|CRYPTO_ASYMQ);
+	}
 }
 
 /*
@@ -1125,7 +1139,7 @@ sun8i_crypto_worker(struct work *wk, voi
  *	Notify the callback for the task on channel i, if there is one,
  *	of the specified error, or 0 for success.
  */
-static void
+static bool
 sun8i_crypto_chan_done(struct sun8i_crypto_softc *sc, unsigned i, int error)
 {
 	struct sun8i_crypto_task *task;
@@ -1140,7 +1154,8 @@ sun8i_crypto_chan_done(struct sun8i_cryp
 	if ((task = sc->sc_chan[i].cc_task) == NULL) {
 		device_printf(sc->sc_dev, "channel %u: no task but error=%d\n",
 		i, error);
-		return;
+		/* We did not clear a channel.  */
+		return false;
 	}
 	sc->sc_chan[i].cc_task = NULL;
 
@@ -1183,6 +1198,9 @@ sun8i_crypto_chan_done(struct sun8i_cryp
 	SDT_PROBE2(sdt, sun8i_crypto, task, done,  task, error);
 	(*task->ct_callback)(sc, task, task->ct_cookie, error);
 	mutex_enter(>sc_lock);
+
+	/* We cleared a channel.  */
+	return true;
 }
 
 /*
@@ -1811,7 +1829,7 @@ sun8i_crypto_register1(struct sun8i_cryp
  *	Called by opencrypto to allocate a new session.  We don't keep
  *	track of sessions, since there are no persistent keys in the
  *	hardware that we take advantage of, so this only validates the
- *	crypto operations and returns a zero session id.
+ *	crypto operations and returns a dummy session id of 1.
  */
 static int
 sun8i_crypto_newsession(void *cookie, uint32_t *sidp, struct cryptoini *cri)
@@ -1823,7 +1841,7 @@ sun8i_crypto_newsession(void *cookie, ui
 
 	/*
 	 * No variation of rounds is supported here.  (XXX Unused and
-	 * unimplemented in opencrypto(9) altogether?
+	 * unimplemented in opencrypto(9) altogether?)
 	 */
 	if (cri->cri_rnd)
 		return EINVAL;



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

2021-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  7 15:41:01 UTC 2021

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

Log Message:
sun8icrypto(4): Call crypto_unblock when a task completes.

Otherwise under load this would presumably just hang after returning
ERESTART to opencrypto.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2021-07-31 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jul 31 11:34:40 UTC 2021

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

Log Message:
sunxi_platform: declare UART FIFO sizes for SoCs we support


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/sunxi/sunxi_platform.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.44 src/sys/arch/arm/sunxi/sunxi_platform.c:1.45
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.44	Fri Jul 30 12:46:46 2021
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Sat Jul 31 11:34:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.45 2021/07/31 11:34:40 tnn Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.45 2021/07/31 11:34:40 tnn Exp $");
 
 #include 
 #include 
@@ -241,11 +241,23 @@ sunxi_platform_device_register(device_t 
 
 	if (device_is_a(self, "com")) {
 		static const struct device_compatible_entry compat_data[] = {
-			{ .compat = "allwinner,sun7i-a20" },
+			{ .compat = "allwinner,sun4i-a10",	.value = 64 },
+			{ .compat = "allwinner,sun5i-a13",	.value = 64 },
+			{ .compat = "allwinner,sun6i-a31",	.value = 64 },
+			{ .compat = "allwinner,sun7i-a20",	.value = 64 },
+			{ .compat = "allwinner,sun8i-h2-plus",	.value = 64 },
+			{ .compat = "allwinner,sun8i-h3",	.value = 64 },
+			{ .compat = "allwinner,sun8i-a83t",	.value = 64 },
+			{ .compat = "allwinner,sun9i-a80",	.value = 64 },
+			{ .compat = "allwinner,sun50i-a64",	.value = 64 },
+			{ .compat = "allwinner,sun50i-h5",	.value = 64 },
+			{ .compat = "allwinner,sun50i-h6",	.value = 256 },
 			DEVICE_COMPAT_EOL
 		};
-		if (of_compatible_match(OF_finddevice("/"), compat_data))
-			prop_dictionary_set_uint(prop, "fifolen", 64);
+		const struct device_compatible_entry *dce =
+		of_compatible_lookup(OF_finddevice("/"), compat_data);
+		if (dce != NULL)
+			prop_dictionary_set_uint(prop, "fifolen", dce->value);
 	}
 }
 



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

2021-07-31 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jul 31 11:34:40 UTC 2021

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

Log Message:
sunxi_platform: declare UART FIFO sizes for SoCs we support


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/sunxi/sunxi_platform.c

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



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

2021-05-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  5 20:58:03 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_codec.c sunxi_codec.h

Log Message:
Fix GENERIC64 build


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sunxi_codec.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_codec.h

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



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

2021-05-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  5 20:58:03 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_codec.c sunxi_codec.h

Log Message:
Fix GENERIC64 build


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sunxi_codec.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_codec.h

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_codec.c
diff -u src/sys/arch/arm/sunxi/sunxi_codec.c:1.13 src/sys/arch/arm/sunxi/sunxi_codec.c:1.14
--- src/sys/arch/arm/sunxi/sunxi_codec.c:1.13	Wed May  5 10:24:04 2021
+++ src/sys/arch/arm/sunxi/sunxi_codec.c	Wed May  5 20:58:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.c,v 1.13 2021/05/05 10:24:04 jmcneill Exp $ */
+/* $NetBSD: sunxi_codec.c,v 1.14 2021/05/05 20:58:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.13 2021/05/05 10:24:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.14 2021/05/05 20:58:03 jmcneill Exp $");
 
 #include 
 #include 
@@ -89,10 +89,10 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_codec.
 #define	AC_ADC_CNT(_sc)		((_sc)->sc_cfg->ADC_CNT)
 
 static const struct device_compatible_entry compat_data[] = {
-	A10_CODEC_COMPATDATA,
-	A31_CODEC_COMPATDATA,
-	H3_CODEC_COMPATDATA,
-	V3S_CODEC_COMPATDATA,
+	A10_CODEC_COMPATDATA
+	A31_CODEC_COMPATDATA
+	H3_CODEC_COMPATDATA
+	V3S_CODEC_COMPATDATA
 
 	DEVICE_COMPAT_EOL
 };

Index: src/sys/arch/arm/sunxi/sunxi_codec.h
diff -u src/sys/arch/arm/sunxi/sunxi_codec.h:1.7 src/sys/arch/arm/sunxi/sunxi_codec.h:1.8
--- src/sys/arch/arm/sunxi/sunxi_codec.h:1.7	Wed May  5 10:24:04 2021
+++ src/sys/arch/arm/sunxi/sunxi_codec.h	Wed May  5 20:58:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.h,v 1.7 2021/05/05 10:24:04 jmcneill Exp $ */
+/* $NetBSD: sunxi_codec.h,v 1.8 2021/05/05 20:58:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -121,7 +121,7 @@ struct sunxi_codec_softc {
 extern const struct sunxi_codec_conf sun8i_h3_codecconf;
 #define	H3_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun8i-h3-codec",\
-	  .data = _h3_codecconf }
+	  .data = _h3_codecconf },
 #else
 #define	H3_CODEC_COMPATDATA
 #endif
@@ -130,7 +130,7 @@ extern const struct sunxi_codec_conf sun
 extern const struct sunxi_codec_conf sun8i_v3s_codecconf;
 #define V3S_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun8i-v3s-codec",			\
-	  .data = _v3s_codecconf }
+	  .data = _v3s_codecconf },
 #else
 #define V3S_CODEC_COMPATDATA
 #endif
@@ -140,11 +140,11 @@ extern const struct sunxi_codec_conf sun
 	{ .compat = "allwinner,sun4i-a10-codec",			\
 	  .data = _a10_codecconf }, \
 	{ .compat = "allwinner,sun7i-a20-codec",			\
-	  .data = _a10_codecconf }
+	  .data = _a10_codecconf },
 
 extern const struct sunxi_codec_conf sun6i_a31_codecconf;
 #define	A31_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun6i-a31-codec",			\
-	  .data = _a31_codecconf }
+	  .data = _a31_codecconf },
 
 #endif /* !_ARM_SUNXI_CODEC_H */



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

2021-02-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb 21 16:07:43 UTC 2021

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

Log Message:
Align descriptors to 64 bytes instead of CACHE_LINE_SIZE (128) as all known
Allwinner SoCs with this part use 64-byte cache lines.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_emac.h

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_emac.h
diff -u src/sys/arch/arm/sunxi/sunxi_emac.h:1.4 src/sys/arch/arm/sunxi/sunxi_emac.h:1.5
--- src/sys/arch/arm/sunxi/sunxi_emac.h:1.4	Sun Oct  1 15:05:09 2017
+++ src/sys/arch/arm/sunxi/sunxi_emac.h	Sun Feb 21 16:07:43 2021
@@ -203,8 +203,8 @@ struct sunxi_emac_desc {
 	uint32_t	addr;
 
 	uint32_t	next;
-} __packed __aligned(CACHE_LINE_SIZE);
+} __packed __aligned(64);
 
-__CTASSERT(sizeof(struct sunxi_emac_desc) == CACHE_LINE_SIZE);
+__CTASSERT(sizeof(struct sunxi_emac_desc) == 64);
 
 #endif /* !__SUNXI_EMAC_H__ */



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

2021-02-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb 21 16:07:43 UTC 2021

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

Log Message:
Align descriptors to 64 bytes instead of CACHE_LINE_SIZE (128) as all known
Allwinner SoCs with this part use 64-byte cache lines.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_emac.h

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



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

2021-01-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jan 29 06:24:19 UTC 2021

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

Log Message:
Fix previous; sunxidrm(4) couldn't be probed on Allwinner A64 due to
trailing whitespace in compat string.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sunxi_drm.c

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



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

2021-01-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jan 29 06:24:19 UTC 2021

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

Log Message:
Fix previous; sunxidrm(4) couldn't be probed on Allwinner A64 due to
trailing whitespace in compat string.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sunxi_drm.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_drm.c
diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.12 src/sys/arch/arm/sunxi/sunxi_drm.c:1.13
--- src/sys/arch/arm/sunxi/sunxi_drm.c:1.12	Wed Jan 27 03:10:20 2021
+++ src/sys/arch/arm/sunxi/sunxi_drm.c	Fri Jan 29 06:24:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.12 2021/01/27 03:10:20 thorpej Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.13 2021/01/29 06:24:18 rin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.12 2021/01/27 03:10:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.13 2021/01/29 06:24:18 rin Exp $");
 
 #include 
 #include 
@@ -66,7 +66,7 @@ static TAILQ_HEAD(, sunxi_drm_endpoint) 
 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "allwinner,sun8i-h3-display-engine" },
-	{ .compat = "allwinner,sun50i-a64-display-engine " },
+	{ .compat = "allwinner,sun50i-a64-display-engine" },
 	DEVICE_COMPAT_EOL
 };
 



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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:09:39 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun4i_a10_ccu.c sun4i_dma.c sun6i_dma.c
sun8i_crypto.c sunxi_can.c sunxi_codec.c sunxi_de2_ccu.c
sunxi_dep.c sunxi_emac.c sunxi_gpio.c sunxi_hdmi.c sunxi_hdmiphy.c
sunxi_i2s.c sunxi_lcdc.c sunxi_lradc.c sunxi_mixer.c sunxi_mmc.c
sunxi_musb.c sunxi_nmi.c sunxi_pwm.c sunxi_rsb.c sunxi_rtc.c
sunxi_sid.c sunxi_sramc.c sunxi_tcon.c sunxi_thermal.c sunxi_ts.c
sunxi_twi.c sunxi_usb3phy.c sunxi_usbphy.c sunxi_wdt.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c \
src/sys/arch/arm/sunxi/sunxi_mixer.c \
src/sys/arch/arm/sunxi/sunxi_usbphy.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sun4i_dma.c \
src/sys/arch/arm/sunxi/sunxi_can.c src/sys/arch/arm/sunxi/sunxi_hdmiphy.c \
src/sys/arch/arm/sunxi/sunxi_ts.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sun6i_dma.c \
src/sys/arch/arm/sunxi/sunxi_hdmi.c src/sys/arch/arm/sunxi/sunxi_rsb.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_codec.c \
src/sys/arch/arm/sunxi/sunxi_i2s.c src/sys/arch/arm/sunxi/sunxi_lcdc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_de2_ccu.c \
src/sys/arch/arm/sunxi/sunxi_dep.c src/sys/arch/arm/sunxi/sunxi_pwm.c \
src/sys/arch/arm/sunxi/sunxi_sid.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sunxi_emac.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_lradc.c \
src/sys/arch/arm/sunxi/sunxi_wdt.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/sunxi/sunxi_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_musb.c \
src/sys/arch/arm/sunxi/sunxi_rtc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_nmi.c \
src/sys/arch/arm/sunxi/sunxi_sramc.c src/sys/arch/arm/sunxi/sunxi_tcon.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_thermal.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sunxi_twi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_usb3phy.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.14 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.15
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.14	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Wed Jan 27 02:09:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.15 2021/01/27 02:09:39 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.15 2021/01/27 02:09:39 thorpej Exp $");
 
 #include 
 #include 
@@ -96,7 +96,7 @@ enum sun4i_a10_ccu_type {
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "allwinner,sun4i-a10-ccu",	.value = CCU_A10 },
 	{ .compat = "allwinner,sun7i-a20-ccu",	.value = CCU_A20 },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 CFATTACH_DECL_NEW(sunxi_a10_ccu, sizeof(struct sunxi_ccu_softc),
Index: src/sys/arch/arm/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.14 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.15
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.14	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Wed Jan 27 02:09:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.15 2021/01/27 02:09:39 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.15 2021/01/27 02:09:39 thorpej Exp $");
 
 #include 
 #include 
@@ -206,7 +206,7 @@ static const struct device_compatible_en
 	{ .compat = "allwinner,sun50i-a64-de2-mixer-1",
 	  .data = _data },
 
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 struct sunxi_mixer_softc;
Index: src/sys/arch/arm/sunxi/sunxi_usbphy.c
diff -u src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.14 src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.15
--- src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.14	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/arm/sunxi/sunxi_usbphy.c	Wed Jan 27 02:09:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_usbphy.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: sunxi_usbphy.c,v 1.15 2021/01/27 02:09:39 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy.c,v 1.14 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, 

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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:09:39 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun4i_a10_ccu.c sun4i_dma.c sun6i_dma.c
sun8i_crypto.c sunxi_can.c sunxi_codec.c sunxi_de2_ccu.c
sunxi_dep.c sunxi_emac.c sunxi_gpio.c sunxi_hdmi.c sunxi_hdmiphy.c
sunxi_i2s.c sunxi_lcdc.c sunxi_lradc.c sunxi_mixer.c sunxi_mmc.c
sunxi_musb.c sunxi_nmi.c sunxi_pwm.c sunxi_rsb.c sunxi_rtc.c
sunxi_sid.c sunxi_sramc.c sunxi_tcon.c sunxi_thermal.c sunxi_ts.c
sunxi_twi.c sunxi_usb3phy.c sunxi_usbphy.c sunxi_wdt.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c \
src/sys/arch/arm/sunxi/sunxi_mixer.c \
src/sys/arch/arm/sunxi/sunxi_usbphy.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sun4i_dma.c \
src/sys/arch/arm/sunxi/sunxi_can.c src/sys/arch/arm/sunxi/sunxi_hdmiphy.c \
src/sys/arch/arm/sunxi/sunxi_ts.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sun6i_dma.c \
src/sys/arch/arm/sunxi/sunxi_hdmi.c src/sys/arch/arm/sunxi/sunxi_rsb.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_codec.c \
src/sys/arch/arm/sunxi/sunxi_i2s.c src/sys/arch/arm/sunxi/sunxi_lcdc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_de2_ccu.c \
src/sys/arch/arm/sunxi/sunxi_dep.c src/sys/arch/arm/sunxi/sunxi_pwm.c \
src/sys/arch/arm/sunxi/sunxi_sid.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sunxi_emac.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_lradc.c \
src/sys/arch/arm/sunxi/sunxi_wdt.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/sunxi/sunxi_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_musb.c \
src/sys/arch/arm/sunxi/sunxi_rtc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_nmi.c \
src/sys/arch/arm/sunxi/sunxi_sramc.c src/sys/arch/arm/sunxi/sunxi_tcon.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_thermal.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sunxi_twi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_usb3phy.c

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



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

2021-01-20 Thread Martin Husemann
On Tue, Jan 19, 2021 at 07:19:51PM +0100, Martin Husemann wrote:
> On Tue, Jan 19, 2021 at 12:35:10AM +, Jason R Thorpe wrote:
> > Module Name:src
> > Committed By:   thorpej
> > Date:   Tue Jan 19 00:35:10 UTC 2021
> > 
> > Modified Files:
> > src/sys/arch/arm/sunxi: sunxi_sramc.c
> > 
> > Log Message:
> > Use device_compatible_entry / of_search_compatible() rather than matching
> > against multiple sets of compatibility strings.
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c
> 
> This breaks cubietruck (fdt is: sun7i-a20-cubietruck.dtb):

And it was fixed with

$NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $

Martin


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

2021-01-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 20 00:48:49 UTC 2021

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

Log Message:
Fix previous; of_search_compatible returns the sentinel when there is no
match, so we need to test ->data for NULL, not the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_sramc.c

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



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

2021-01-19 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jan 20 00:48:49 UTC 2021

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

Log Message:
Fix previous; of_search_compatible returns the sentinel when there is no
match, so we need to test ->data for NULL, not the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_sramc.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_sramc.c
diff -u src/sys/arch/arm/sunxi/sunxi_sramc.c:1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_sramc.c:1.6	Tue Jan 19 00:35:10 2021
+++ src/sys/arch/arm/sunxi/sunxi_sramc.c	Wed Jan 20 00:48:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $ */
+/* $NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.7 2021/01/20 00:48:49 jmcneill Exp $");
 
 #include 
 #include 
@@ -127,7 +127,7 @@ sunxi_sramc_init_mmio(struct sunxi_sramc
 
 	for (child = OF_child(phandle); child; child = OF_peer(child)) {
 		dce = of_search_compatible(child, sunxi_sramc_areas);
-		if (dce != NULL) {
+		if (dce->data != NULL) {
 			node = kmem_alloc(sizeof(*node), KM_SLEEP);
 			node->phandle = child;
 			node->area = dce->data;



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

2021-01-19 Thread Martin Husemann
On Tue, Jan 19, 2021 at 12:35:10AM +, Jason R Thorpe wrote:
> Module Name:  src
> Committed By: thorpej
> Date: Tue Jan 19 00:35:10 UTC 2021
> 
> Modified Files:
>   src/sys/arch/arm/sunxi: sunxi_sramc.c
> 
> Log Message:
> Use device_compatible_entry / of_search_compatible() rather than matching
> against multiple sets of compatibility strings.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c

This breaks cubietruck (fdt is: sun7i-a20-cubietruck.dtb):


[   1.000] fclock0 at simplebus2: 2500 Hz fixed clock (mii_phy_tx)
[   1.000] fclock1 at simplebus2: 12500 Hz fixed clock (gmac_int_tx)
[   1.000] fclock2 at simplebus2: 2400 Hz fixed clock (osc24M)
[   1.000] fclock3 at simplebus2: 32768 Hz fixed clock (osc32k)
[   1.000] gtmr0 at simplebus0: Generic Timer
[   1.000] gtmr0: interrupting on GIC irq 27
[   1.000] armgtmr0 at gtmr0: Generic Timer (24000 kHz, virtual)
[   1.030] sun4ia10ccu0 at simplebus1: A20 CCU
[   1.030] sunxinmi0 at simplebus1: NMI
[   1.030] sunxigmacclk0 at simplebus2: GMAC MII/RGMII clock mux
[   1.030] sunxigpio0 at simplebus1: PIO
[   1.030] gpio0 at sunxigpio0: 175 pins
[   1.030] sunxigpio0: interrupting on GIC irq 60
[   1.030] sun4idma0 at simplebus1: DMA controller
[   1.030] sun4idma0: interrupting on GIC irq 59
[   1.030] sunxisramc0 at simplebus1: SRAM Controller

[   1.030] uvm_fault(0x80b92d68, 0, 1) -> e
[   1.030] Fatal kernel mode data abort: 'Translation Fault (S)'
[   1.030] trapframe: 0x80bc8cf0
[   1.030] FSR=0005, FAR=, spsr=6353
[   1.030] r0 =92cfd200, r1 =806b0910, r2 =, r3 =
[   1.030] r4 =92a0cd00, r5 =10c4, r6 =92cfd200, r7 =0dd0
[   1.030] r8 =806b0910, r9 =114c, r10=80634a80, r11=80bc8d94
[   1.030] r12=92cf3988, ssp=80bc8d40, slr=804bc688, pc =80061fac

Stopped in pid 0.0 (system) at  netbsd:sunxi_sramc_attach+0x16c:ldr 
r2, [r2]


(gdb) list *(sunxi_sramc_attach+0x16c)
0x80061fac is in sunxi_sramc_attach 
(../../../../arch/arm/sunxi/sunxi_sramc.c:135).
130 if (dce != NULL) {
131 node = kmem_alloc(sizeof(*node), KM_SLEEP);
132 node->phandle = child;
133 node->area = dce->data;
134 TAILQ_INSERT_TAIL(>sc_nodes, node, nodes);
135 aprint_verbose_dev(sc->sc_dev, "area: %s\n",
136 node->area->desc);
137 }
138 }
139 }


With the change backed out it boots fine (dmesg below).

Martin

--8<--

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
2018, 2019, 2020, 2021 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.

NetBSD 9.99.78 (GENERIC) #117: Tue Jan 19 19:14:10 CET 2021

mar...@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/evbarm/compile/GENERIC
total memory = 2045 MB
avail memory = 1989 MB
entropy: no seed from bootloader
timecounter: Timecounters tick every 10.000 msec
Kernelized RAIDframe activated
armfdt0 (root)
simplebus0 at armfdt0: Cubietech Cubietruck
simplebus1 at simplebus0
cpus0 at simplebus0
simplebus2 at simplebus0
simplebus3 at simplebus0
cpu0 at cpus0: Cortex-A7 r0p4 (Cortex V7A core)
cpu0: DC enabled IC enabled WB enabled LABT branch prediction enabled
cpu0: 32KB/32B 2-way L1 VIPT Instruction cache
cpu0: 32KB/64B 4-way write-back-locking-C L1 PIPT Data cache
cpu0: 256KB/64B 8-way write-through L2 PIPT Unified cache
vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
cpufreqdt0 at cpu0
cpu1 at cpus0
cpufreqdt1 at cpu1
gic0 at simplebus1: GIC
armgic0 at gic0: Generic Interrupt Controller, 160 sources (150 valid)
armgic0: 16 Priorities, 128 SPIs, 7 PPIs, 15 SGIs
fclock0 at simplebus2: 2500 Hz fixed clock (mii_phy_tx)
fclock1 at simplebus2: 12500 Hz fixed clock (gmac_int_tx)
fclock2 at simplebus2: 2400 Hz fixed clock (osc24M)
fclock3 at simplebus2: 32768 Hz fixed clock (osc32k)
gtmr0 at simplebus0: Generic Timer
gtmr0: interrupting on GIC irq 27
armgtmr0 at gtmr0: Generic Timer (24000 kHz, virtual)
timecounter: Timecounter "armgtmr0" frequency 2400 Hz quality 500
sun4ia10ccu0 at simplebus1: A20 CCU
sunxinmi0 at simplebus1: NMI
sunxigmacclk0 at simplebus2: GMAC MII/RGMII clock mux
sunxigpio0 at simplebus1: PIO
gpio0 at sunxigpio0: 175 pins
sunxigpio0: interrupting on GIC irq 60
sun4idma0 at simplebus1: DMA controller
sun4idma0: interrupting on GIC irq 59
sunxisramc0 at simplebus1: SRAM Controller
sunxisramc0: area: SRAM A3/A4
sunxisramc0: area: SRAM D
sunxidebe0 at simplebus1: Display Engine Backend (display-backend@1e6)

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

2021-01-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan 19 00:35:10 UTC 2021

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

Log Message:
Use device_compatible_entry / of_search_compatible() rather than matching
against multiple sets of compatibility strings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_sramc.c
diff -u src/sys/arch/arm/sunxi/sunxi_sramc.c:1.5 src/sys/arch/arm/sunxi/sunxi_sramc.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_sramc.c:1.5	Thu Jul 11 18:22:14 2019
+++ src/sys/arch/arm/sunxi/sunxi_sramc.c	Tue Jan 19 00:35:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_sramc.c,v 1.5 2019/07/11 18:22:14 macallan Exp $ */
+/* $NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.5 2019/07/11 18:22:14 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.c,v 1.6 2021/01/19 00:35:10 thorpej Exp $");
 
 #include 
 #include 
@@ -42,33 +42,57 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_sramc.
 
 #include 
 
-static const char * compatible[] = {
-	"allwinner,sun4i-a10-sram-controller",	/* old compat string */
-	"allwinner,sun4i-a10-system-control",
-	"allwinner,sun8i-h3-system-control",
-	"allwinner,sun50i-a64-system-control",
-	"allwinner,sun50i-h5-system-control",
-	"allwinner,sun50i-h6-system-control",
-	NULL
+static const struct device_compatible_entry compat_data[] = {
+		/* old compat string */
+	{ .compat = "allwinner,sun4i-a10-sram-controller" },
+	{ .compat = "allwinner,sun4i-a10-system-control" },
+	{ .compat = "allwinner,sun8i-h3-system-control" },
+	{ .compat = "allwinner,sun50i-a64-system-control" },
+	{ .compat = "allwinner,sun50i-h5-system-control" },
+	{ .compat = "allwinner,sun50i-h6-system-control" },
+	{ 0 }
 };
 
-static const struct sunxi_sramc_area {
-	const char			*compatible;
+struct sunxi_sramc_area {
 	const char			*desc;
 	bus_size_t			reg;
 	uint32_t			mask;
 	u_intflags;
 #define	SUNXI_SRAMC_F_SWAP		__BIT(0)
-} sunxi_sramc_areas[] = {
-	{ "allwinner,sun4i-a10-sram-a3-a4",
-	  "SRAM A3/A4",
-	  0x04, __BITS(5,4), 0 },
-	{ "allwinner,sun4i-a10-sram-d",
-	  "SRAM D",
-	  0x04, __BIT(0), 0 },
-	{ "allwinner,sun50i-a64-sram-c",
-	  "SRAM C",
-	  0x04, __BIT(24), SUNXI_SRAMC_F_SWAP },
+};
+
+static const struct sunxi_sramc_area sunxi_sramc_area_a3_a4 = {
+	.desc = "SRAM A3/A4",
+	.reg = 0x04,
+	.mask = __BITS(5,4),
+	.flags = 0,
+};
+
+static const struct sunxi_sramc_area sunxi_sramc_area_d = {
+	.desc = "SRAM D",
+	.reg = 0x04,
+	.mask = __BIT(0),
+	.flags = 0,
+};
+
+static const struct sunxi_sramc_area sunxi_sramc_area_c = {
+	.desc = "SRAM C",
+	.reg = 0x04,
+	.mask = __BIT(24),
+	.flags = SUNXI_SRAMC_F_SWAP,
+};
+
+static const struct device_compatible_entry sunxi_sramc_areas[] = {
+	{ .compat = "allwinner,sun4i-a10-sram-a3-a4",
+	  .data = _sramc_area_a3_a4 },
+
+	{ .compat = "allwinner,sun4i-a10-sram-d",
+	  .data = _sramc_area_d },
+
+	{ .compat = "allwinner,sun50i-a64-sram-c",
+	  .data = _sramc_area_c },
+
+	{ 0 }
 };
 
 struct sunxi_sramc_node {
@@ -97,31 +121,34 @@ static struct sunxi_sramc_softc *sramc_s
 static void
 sunxi_sramc_init_mmio(struct sunxi_sramc_softc *sc, int phandle)
 {
+	const struct device_compatible_entry *dce;
 	struct sunxi_sramc_node *node;
-	int child, i;
+	int child;
 
-	for (child = OF_child(phandle); child; child = OF_peer(child))
-		for (i = 0; i < __arraycount(sunxi_sramc_areas); i++) {
-			const char * area_compatible[] = { sunxi_sramc_areas[i].compatible, NULL };
-			if (of_match_compatible(child, area_compatible)) {
-node = kmem_alloc(sizeof(*node), KM_SLEEP);
-node->phandle = child;
-node->area = _sramc_areas[i];
-TAILQ_INSERT_TAIL(>sc_nodes, node, nodes);
-aprint_verbose_dev(sc->sc_dev, "area: %s\n", node->area->desc);
-break;
-			}
+	for (child = OF_child(phandle); child; child = OF_peer(child)) {
+		dce = of_search_compatible(child, sunxi_sramc_areas);
+		if (dce != NULL) {
+			node = kmem_alloc(sizeof(*node), KM_SLEEP);
+			node->phandle = child;
+			node->area = dce->data;
+			TAILQ_INSERT_TAIL(>sc_nodes, node, nodes);
+			aprint_verbose_dev(sc->sc_dev, "area: %s\n",
+			node->area->desc);
 		}
+	}
 }
 
 static void
 sunxi_sramc_init(struct sunxi_sramc_softc *sc)
 {
-	const char * mmio_compatible[] = { "mmio-sram", NULL };
+	const struct device_compatible_entry mmio_compat_data[] = {
+		{ .compat = "mmio-sram" },
+		{ 0 }
+	};
 	int child;
 
 	for (child = OF_child(sc->sc_phandle); child; child = OF_peer(child)) {
-		if (!of_match_compatible(child, mmio_compatible))
+		if (!of_match_compat_data(child, mmio_compat_data))
 			continue;
 		sunxi_sramc_init_mmio(sc, child);
 	}
@@ -168,7 +195,7 @@ sunxi_sramc_match(device_t parent, cfdat
 

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

2021-01-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan 19 00:35:10 UTC 2021

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

Log Message:
Use device_compatible_entry / of_search_compatible() rather than matching
against multiple sets of compatibility strings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_sramc.c

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



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

2021-01-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 18 13:29:37 UTC 2021

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sunxi_gpio.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_gpio.c
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.c:1.31 src/sys/arch/arm/sunxi/sunxi_gpio.c:1.32
--- src/sys/arch/arm/sunxi/sunxi_gpio.c:1.31	Mon Jan 18 02:35:49 2021
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c	Mon Jan 18 13:29:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.31 2021/01/18 02:35:49 thorpej Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.32 2021/01/18 13:29:37 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.31 2021/01/18 02:35:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.32 2021/01/18 13:29:37 skrll Exp $");
 
 #include 
 #include 
@@ -86,7 +86,7 @@ static const struct device_compatible_en
 #ifdef SOC_SUN5I_A13
 	{ .compat = "allwinner,sun5i-a13-pinctrl",
 	  .data = _a13_padconf },
-	{ .compat = "nextthing,gr8-pinctrl",	
+	{ .compat = "nextthing,gr8-pinctrl",
 	  .data = _a13_padconf },
 #endif
 #ifdef SOC_SUN6I_A31
@@ -469,7 +469,7 @@ sunxi_intr_enable(struct sunxi_gpio_soft
 {
 	uint32_t val;
 	struct sunxi_gpio_eint *eint;
-	
+
 	if (pin_def->functions[pin_def->eint_func] == NULL ||
 	strcmp(pin_def->functions[pin_def->eint_func], "irq") != 0)
 		return NULL;



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

2021-01-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 18 13:29:37 UTC 2021

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sunxi_gpio.c

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



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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:02:38 UTC 2021

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

Log Message:
trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sun6i_spi.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun6i_spi.c
diff -u src/sys/arch/arm/sunxi/sun6i_spi.c:1.6 src/sys/arch/arm/sunxi/sun6i_spi.c:1.7
--- src/sys/arch/arm/sunxi/sun6i_spi.c:1.6	Fri Jan 15 23:02:07 2021
+++ src/sys/arch/arm/sunxi/sun6i_spi.c	Fri Jan 15 23:02:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun6i_spi.c,v 1.6 2021/01/15 23:02:07 jmcneill Exp $	*/
+/*	$NetBSD: sun6i_spi.c,v 1.7 2021/01/15 23:02:38 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.6 2021/01/15 23:02:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.7 2021/01/15 23:02:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -158,7 +158,7 @@ sun6ispi_attach(device_t parent, device_
 
 	aprint_naive("\n");
 	aprint_normal(": SPI\n");
-	
+
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	gcr = SPI_GCR_SRST;
@@ -205,7 +205,7 @@ sun6ispi_configure(void *cookie, int sla
 
 	if (slave >= sc->sc_spi.sct_nslaves)
 		return EINVAL;
-	
+
 	tcr = SPI_TCR_SS_LEVEL | SPI_TCR_SPOL;
 
 	switch (mode) {



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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:02:38 UTC 2021

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

Log Message:
trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sun6i_spi.c

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



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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:02:07 UTC 2021

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

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sun6i_spi.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun6i_spi.c
diff -u src/sys/arch/arm/sunxi/sun6i_spi.c:1.5 src/sys/arch/arm/sunxi/sun6i_spi.c:1.6
--- src/sys/arch/arm/sunxi/sun6i_spi.c:1.5	Tue Aug 13 17:03:10 2019
+++ src/sys/arch/arm/sunxi/sun6i_spi.c	Fri Jan 15 23:02:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun6i_spi.c,v 1.5 2019/08/13 17:03:10 tnn Exp $	*/
+/*	$NetBSD: sun6i_spi.c,v 1.6 2021/01/15 23:02:07 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2019 Tobias Nygren
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.5 2019/08/13 17:03:10 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.6 2021/01/15 23:02:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -149,8 +149,8 @@ sun6ispi_attach(device_t parent, device_
 		return;
 	}
 
-	sc->sc_intrh = fdtbus_intr_establish(phandle, 0, IPL_VM, 0,
-	sun6ispi_intr, sc);
+	sc->sc_intrh = fdtbus_intr_establish_xname(phandle, 0, IPL_VM, 0,
+	sun6ispi_intr, sc, device_xname(self));
 	if (sc->sc_intrh == NULL) {
 		aprint_error(": unable to establish interrupt\n");
 		return;



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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 23:02:07 UTC 2021

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

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sun6i_spi.c

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



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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 22:47:33 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun4i_dma.c sun4i_emac.c sun4i_spi.c
sun6i_dma.c sun8i_codec.c sun8i_crypto.c sunxi_can.c sunxi_emac.c
sunxi_gmac.c sunxi_gpio.c sunxi_hstimer.c sunxi_lcdc.c
sunxi_lradc.c sunxi_mmc.c sunxi_musb.c sunxi_nand.c sunxi_nmi.c
sunxi_rsb.c sunxi_sata.c sunxi_thermal.c sunxi_timer.c sunxi_ts.c
sunxi_twi.c

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun4i_dma.c \
src/sys/arch/arm/sunxi/sunxi_can.c src/sys/arch/arm/sunxi/sunxi_ts.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sun4i_emac.c \
src/sys/arch/arm/sunxi/sunxi_twi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sun4i_spi.c \
src/sys/arch/arm/sunxi/sunxi_musb.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun6i_dma.c \
src/sys/arch/arm/sunxi/sunxi_rsb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sun8i_codec.c \
src/sys/arch/arm/sunxi/sunxi_gmac.c src/sys/arch/arm/sunxi/sunxi_lcdc.c \
src/sys/arch/arm/sunxi/sunxi_timer.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/sunxi/sunxi_emac.c \
src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hstimer.c \
src/sys/arch/arm/sunxi/sunxi_sata.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_lradc.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/sunxi/sunxi_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_nand.c \
src/sys/arch/arm/sunxi/sunxi_thermal.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_nmi.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun4i_dma.c
diff -u src/sys/arch/arm/sunxi/sun4i_dma.c:1.3 src/sys/arch/arm/sunxi/sun4i_dma.c:1.4
--- src/sys/arch/arm/sunxi/sun4i_dma.c:1.3	Fri Apr 20 18:04:12 2018
+++ src/sys/arch/arm/sunxi/sun4i_dma.c	Fri Jan 15 22:47:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_dma.c,v 1.3 2018/04/20 18:04:12 bouyer Exp $ */
+/* $NetBSD: sun4i_dma.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun4i_dma.c,v 1.3 2018/04/20 18:04:12 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun4i_dma.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -408,8 +408,8 @@ sun4idma_attach(device_t parent, device_
 		}
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_SCHED,
-	FDT_INTR_MPSAFE, sun4idma_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_SCHED,
+	FDT_INTR_MPSAFE, sun4idma_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(sc->sc_dev,
 		"couldn't establish interrupt on %s\n", intrstr);
Index: src/sys/arch/arm/sunxi/sunxi_can.c
diff -u src/sys/arch/arm/sunxi/sunxi_can.c:1.3 src/sys/arch/arm/sunxi/sunxi_can.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_can.c:1.3	Wed Jan 29 06:05:31 2020
+++ src/sys/arch/arm/sunxi/sunxi_can.c	Fri Jan 15 22:47:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunxi_can.c,v 1.3 2020/01/29 06:05:31 thorpej Exp $	*/
+/*	$NetBSD: sunxi_can.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2017,2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.3 2020/01/29 06:05:31 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sunxi_can.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -202,8 +202,8 @@ sunxi_can_attach(device_t parent, device
 	sunxi_can_write(sc, SUNXI_CAN_INT_REG,
 	sunxi_can_read(sc, SUNXI_CAN_INT_REG));
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0,
-	sunxi_can_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_NET, 0,
+	sunxi_can_intr, sc, device_xname(self));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);
Index: src/sys/arch/arm/sunxi/sunxi_ts.c
diff -u src/sys/arch/arm/sunxi/sunxi_ts.c:1.3 src/sys/arch/arm/sunxi/sunxi_ts.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_ts.c:1.3	Tue Jun  4 03:03:34 2019
+++ src/sys/arch/arm/sunxi/sunxi_ts.c	Fri Jan 15 22:47:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ts.c,v 1.3 2019/06/04 03:03:34 thorpej Exp $ */
+/* $NetBSD: sunxi_ts.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ts.c,v 1.3 2019/06/04 03:03:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ts.c,v 1.4 2021/01/15 22:47:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -388,7 +388,8 @@ sunxi_ts_attach(device_t parent, device_
 
 	sunxi_ts_init(sc);
 
-	ih = fdtbus_intr_establish(phandle, 0, 

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

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 22:47:33 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun4i_dma.c sun4i_emac.c sun4i_spi.c
sun6i_dma.c sun8i_codec.c sun8i_crypto.c sunxi_can.c sunxi_emac.c
sunxi_gmac.c sunxi_gpio.c sunxi_hstimer.c sunxi_lcdc.c
sunxi_lradc.c sunxi_mmc.c sunxi_musb.c sunxi_nand.c sunxi_nmi.c
sunxi_rsb.c sunxi_sata.c sunxi_thermal.c sunxi_timer.c sunxi_ts.c
sunxi_twi.c

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun4i_dma.c \
src/sys/arch/arm/sunxi/sunxi_can.c src/sys/arch/arm/sunxi/sunxi_ts.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sunxi/sun4i_emac.c \
src/sys/arch/arm/sunxi/sunxi_twi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sun4i_spi.c \
src/sys/arch/arm/sunxi/sunxi_musb.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sun6i_dma.c \
src/sys/arch/arm/sunxi/sunxi_rsb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sun8i_codec.c \
src/sys/arch/arm/sunxi/sunxi_gmac.c src/sys/arch/arm/sunxi/sunxi_lcdc.c \
src/sys/arch/arm/sunxi/sunxi_timer.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/sunxi/sunxi_emac.c \
src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hstimer.c \
src/sys/arch/arm/sunxi/sunxi_sata.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_lradc.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/sunxi/sunxi_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_nand.c \
src/sys/arch/arm/sunxi/sunxi_thermal.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_nmi.c

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



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

2020-10-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 19 01:13:41 UTC 2020

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

Log Message:
sunxi_debe_set_videomode(): As byte-swapped framebuffer is now handled by
FDT override, do not configure FB to little-endian format for __ARMEB__.

XXX
This function is not actually called at the moment. IIRC, it worked in
the pre-FDT era. Something went wrong since then...


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_debe.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_debe.c
diff -u src/sys/arch/arm/sunxi/sunxi_debe.c:1.9 src/sys/arch/arm/sunxi/sunxi_debe.c:1.10
--- src/sys/arch/arm/sunxi/sunxi_debe.c:1.9	Fri Jun  1 17:18:44 2018
+++ src/sys/arch/arm/sunxi/sunxi_debe.c	Mon Oct 19 01:13:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_debe.c,v 1.9 2018/06/01 17:18:44 bouyer Exp $ */
+/* $NetBSD: sunxi_debe.c,v 1.10 2020/10/19 01:13:41 rin Exp $ */
 
 /*-
  * Copyright (c) 2018 Manuel Bouyer 
@@ -38,7 +38,7 @@
 #define SUNXI_DEBE_CURMAX	64
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_debe.c,v 1.9 2018/06/01 17:18:44 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_debe.c,v 1.10 2020/10/19 01:13:41 rin Exp $");
 
 #include 
 #include 
@@ -560,6 +560,10 @@ sunxi_debe_ep_enable(device_t dev, struc
 	return 0;
 }
 
+/*
+ * FIXME 2020/10/19
+ * This function is not called actually at the moment.
+ */
 void
 sunxi_debe_set_videomode(device_t dev, const struct videomode *mode)
 {
@@ -613,7 +617,12 @@ sunxi_debe_set_videomode(device_t dev, c
  SUNXI_DEBE_ATTCTL1_LAY_FBFMT);
 		val &= ~SUNXI_DEBE_ATTCTL1_LAY_BRSWAPEN;
 		val &= ~SUNXI_DEBE_ATTCTL1_LAY_FBPS;
-#if __ARMEB__
+#if 0 /* __ARMEB__ */
+		/*
+		 * For big endian, we dynamically override FDT to let
+		 * genfb(4) know that framebuffer is byte-swapped.
+		 * See fdt_update_fb_format() in fdt_machdep.c.
+		 */
 		val |= __SHIFTIN(SUNXI_DEBE_ATTCTL1_LAY_FBPS_32BPP_BGRA,
  SUNXI_DEBE_ATTCTL1_LAY_FBPS);
 #else



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

2020-10-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Oct 19 01:13:41 UTC 2020

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

Log Message:
sunxi_debe_set_videomode(): As byte-swapped framebuffer is now handled by
FDT override, do not configure FB to little-endian format for __ARMEB__.

XXX
This function is not actually called at the moment. IIRC, it worked in
the pre-FDT era. Something went wrong since then...


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_debe.c

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



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

2020-10-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 18 14:00:08 UTC 2020

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

Log Message:
Treat ARGB/XRGB as BGRA/BGRX on big endian kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_mixer.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.11 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.12
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.11	Sun Feb  9 15:22:25 2020
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Sun Oct 18 14:00:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.11 2020/02/09 15:22:25 jakllsch Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.12 2020/10/18 14:00:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.11 2020/02/09 15:22:25 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.12 2020/10/18 14:00:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -99,8 +99,13 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.
 #define	  OVL_V_ATTCTL_LAY_FBFMT_YUV422		0x06
 #define	  OVL_V_ATTCTL_LAY_FBFMT_YUV420		0x0a
 #define	  OVL_V_ATTCTL_LAY_FBFMT_YUV411		0x0e
+#if BYTE_ORDER == BIG_ENDIAN
+#define	  OVL_V_ATTCTL_LAY_FBFMT_ARGB_	0x03
+#define	  OVL_V_ATTCTL_LAY_FBFMT_XRGB_	0x07
+#else
 #define	  OVL_V_ATTCTL_LAY_FBFMT_ARGB_	0x00
 #define	  OVL_V_ATTCTL_LAY_FBFMT_XRGB_	0x04
+#endif
 #define	 OVL_V_ATTCTL_LAY0_EN			__BIT(0)
 #define	OVL_V_MBSIZE(n)		(0x004 + (n) * 0x30)
 #define	OVL_V_COOR(n)		(0x008 + (n) * 0x30)
@@ -124,8 +129,13 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.
 /* OVL_UI registers */
 #define	OVL_UI_ATTR_CTL(n)	(0x000 + (n) * 0x20)
 #define	 OVL_UI_ATTR_CTL_LAY_FBFMT		__BITS(12,8)
+#if BYTE_ORDER == BIG_ENDIAN
+#define	  OVL_UI_ATTR_CTL_LAY_FBFMT_ARGB_	0x03
+#define	  OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_	0x07
+#else
 #define	  OVL_UI_ATTR_CTL_LAY_FBFMT_ARGB_	0x00
 #define	  OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_	0x04
+#endif
 #define	 OVL_UI_ATTR_CTL_LAY_EN			__BIT(0)
 #define	OVL_UI_MBSIZE(n)	(0x004 + (n) * 0x20)
 #define	OVL_UI_COOR(n)		(0x008 + (n) * 0x20)



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

2020-10-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 18 14:00:08 UTC 2020

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

Log Message:
Treat ARGB/XRGB as BGRA/BGRX on big endian kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_mixer.c

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



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

2020-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug 27 16:35:13 UTC 2020

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

Log Message:
Avoid undefined behaviour as detected by KUBSAN


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sunxi_gpio.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_gpio.c
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.c:1.27 src/sys/arch/arm/sunxi/sunxi_gpio.c:1.28
--- src/sys/arch/arm/sunxi/sunxi_gpio.c:1.27	Tue Oct  1 23:32:52 2019
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c	Thu Aug 27 16:35:13 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.27 2019/10/01 23:32:52 jmcneill Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.28 2020/08/27 16:35:13 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.27 2019/10/01 23:32:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.28 2020/08/27 16:35:13 skrll Exp $");
 
 #include 
 #include 
@@ -54,17 +54,17 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c
 
 #define	SUNXI_GPIO_PORT(port)		(0x24 * (port))
 #define SUNXI_GPIO_CFG(port, pin)	(SUNXI_GPIO_PORT(port) + 0x00 + (0x4 * ((pin) / 8)))
-#define  SUNXI_GPIO_CFG_PINMASK(pin)	(0x7 << (((pin) % 8) * 4))
+#define  SUNXI_GPIO_CFG_PINMASK(pin)	(0x7U << (((pin) % 8) * 4))
 #define	SUNXI_GPIO_DATA(port)		(SUNXI_GPIO_PORT(port) + 0x10)
 #define	SUNXI_GPIO_DRV(port, pin)	(SUNXI_GPIO_PORT(port) + 0x14 + (0x4 * ((pin) / 16)))
-#define  SUNXI_GPIO_DRV_PINMASK(pin)	(0x3 << (((pin) % 16) * 2))
+#define  SUNXI_GPIO_DRV_PINMASK(pin)	(0x3U << (((pin) % 16) * 2))
 #define	SUNXI_GPIO_PULL(port, pin)	(SUNXI_GPIO_PORT(port) + 0x1c + (0x4 * ((pin) / 16)))
 #define	 SUNXI_GPIO_PULL_DISABLE	0
 #define	 SUNXI_GPIO_PULL_UP		1
 #define	 SUNXI_GPIO_PULL_DOWN		2
-#define  SUNXI_GPIO_PULL_PINMASK(pin)	(0x3 << (((pin) % 16) * 2))
+#define  SUNXI_GPIO_PULL_PINMASK(pin)	(0x3U << (((pin) % 16) * 2))
 #define	SUNXI_GPIO_INT_CFG(bank, eint)	(0x200 + (0x20 * (bank)) + (0x4 * ((eint) / 8)))
-#define	 SUNXI_GPIO_INT_MODEMASK(eint)	(0xf << (((eint) % 8) * 4))
+#define	 SUNXI_GPIO_INT_MODEMASK(eint)	(0xfU << (((eint) % 8) * 4))
 #define	  SUNXI_GPIO_INT_MODE_POS_EDGE		0x0
 #define	  SUNXI_GPIO_INT_MODE_NEG_EDGE		0x1
 #define	  SUNXI_GPIO_INT_MODE_HIGH_LEVEL	0x2



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

2020-08-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug 27 16:35:13 UTC 2020

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

Log Message:
Avoid undefined behaviour as detected by KUBSAN


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sunxi_gpio.c

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



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

2020-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Aug 24 07:42:02 UTC 2020

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

Log Message:
Appease gcc when building with KASAN which gave this error before

error: stack usage might be unbounded [-Werror=stack-usage=]


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

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



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

2020-08-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Aug 24 07:42:02 UTC 2020

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

Log Message:
Appease gcc when building with KASAN which gave this error before

error: stack usage might be unbounded [-Werror=stack-usage=]


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_nand.c
diff -u src/sys/arch/arm/sunxi/sunxi_nand.c:1.7 src/sys/arch/arm/sunxi/sunxi_nand.c:1.8
--- src/sys/arch/arm/sunxi/sunxi_nand.c:1.7	Sun Jul  5 05:16:50 2020
+++ src/sys/arch/arm/sunxi/sunxi_nand.c	Mon Aug 24 07:42:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_nand.c,v 1.7 2020/07/05 05:16:50 skrll Exp $ */
+/* $NetBSD: sunxi_nand.c,v 1.8 2020/08/24 07:42:02 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_nand.c,v 1.7 2020/07/05 05:16:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_nand.c,v 1.8 2020/08/24 07:42:02 skrll Exp $");
 
 #include 
 #include 
@@ -592,7 +592,7 @@ sunxi_nand_attach_chip(struct sunxi_nand
 
 	mtdparts = get_bootconf_string(boot_args, "mtdparts");
 	if (mtdparts != NULL) {
-		char mtd_id[strlen("sunxi-nand.X") + 1];
+		char mtd_id[] = "sunxi-nand.XX";
 		snprintf(mtd_id, sizeof(mtd_id), "sunxi-nand.%u",
 		device_unit(sc->sc_dev));
 



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

2020-07-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul  5 05:16:51 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_nand.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_nand.c
diff -u src/sys/arch/arm/sunxi/sunxi_nand.c:1.6 src/sys/arch/arm/sunxi/sunxi_nand.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_nand.c:1.6	Mon Sep  3 16:29:24 2018
+++ src/sys/arch/arm/sunxi/sunxi_nand.c	Sun Jul  5 05:16:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_nand.c,v 1.6 2018/09/03 16:29:24 riastradh Exp $ */
+/* $NetBSD: sunxi_nand.c,v 1.7 2020/07/05 05:16:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_nand.c,v 1.6 2018/09/03 16:29:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_nand.c,v 1.7 2020/07/05 05:16:50 skrll Exp $");
 
 #include 
 #include 
@@ -688,7 +688,7 @@ sunxi_nand_attach(device_t parent, devic
 
 	sunxi_nand_attach_chip(sc, >sc_chip, child);
 }
-	
+
 CFATTACH_DECL_NEW(sunxi_nand, sizeof(struct sunxi_nand_softc),
 	sunxi_nand_match, sunxi_nand_attach, NULL, NULL);
 



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

2020-07-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul  5 05:16:51 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_nand.c

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



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

2020-06-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Jun 14 16:29:47 UTC 2020

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

Log Message:
Fix !DIAGNOSTIC compile.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.17 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.18
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.17	Sat Jun 13 18:58:26 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sun Jun 14 16:29:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.17 2020/06/13 18:58:26 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.18 2020/06/14 16:29:47 ad Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.17 2020/06/13 18:58:26 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.18 2020/06/14 16:29:47 ad Exp $");
 
 #include 
 #include 
@@ -2393,7 +2393,7 @@ sun8i_crypto_callback(struct sun8i_crypt
 struct sun8i_crypto_task *task, void *cookie, int error)
 {
 	struct cryptop *crp = cookie;
-	struct cryptodesc *crd = crp->crp_desc;
+	struct cryptodesc *crd __diagused = crp->crp_desc;
 
 	KASSERT(error != ERESTART);
 	KASSERT(crd != NULL);



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

2020-06-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Jun 14 16:29:47 UTC 2020

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

Log Message:
Fix !DIAGNOSTIC compile.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:58:26 UTC 2020

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

Log Message:
Draft opencrypto support for Allwinner Crypto Engine.

XXX Can't handle nonzero crd_skip yet.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.16 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.17
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.16	Sat Jun 13 18:57:54 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sat Jun 13 18:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.16 2020/06/13 18:57:54 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.17 2020/06/13 18:58:26 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.16 2020/06/13 18:57:54 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.17 2020/06/13 18:58:26 riastradh Exp $");
 
 #include 
 #include 
@@ -51,16 +51,21 @@ __KERNEL_RCSID(1, "$NetBSD: sun8i_crypto
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
 
+#include 
+
 #include 
 
 #define	SUN8I_CRYPTO_TIMEOUT	hz
@@ -110,15 +115,22 @@ struct sun8i_crypto_softc {
 		const struct sysctlnode		*cy_root_node;
 		const struct sysctlnode		*cy_trng_node;
 	}sc_sysctl;
+	struct sun8i_crypto_opencrypto {
+		uint32_t			co_driverid;
+	}sc_opencrypto;
 };
 
 struct sun8i_crypto_task {
 	struct sun8i_crypto_buf	ct_descbuf;
 	struct sun8i_crypto_taskdesc *ct_desc;
+	struct sun8i_crypto_buf	ct_ivbuf;
+	void			*ct_iv;
+	struct sun8i_crypto_buf	ct_ctrbuf;
+	void			*ct_ctr;
 	bus_dmamap_t		ct_descmap;
 	bus_dmamap_t		ct_keymap;
-	bus_dmamap_t		ct_ivmap;
-	bus_dmamap_t		ct_ctrmap;
+	bus_dmamap_t		ct_ivmap;	/* IV input */
+	bus_dmamap_t		ct_ctrmap;	/* updated IV output */
 	bus_dmamap_t		ct_srcmap;
 	bus_dmamap_t		ct_dstmap;
 	uint32_t		ct_nbytes;
@@ -159,8 +171,8 @@ static void	sun8i_crypto_task_put(struct
 static int	sun8i_crypto_task_load(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, uint32_t,
 		uint32_t, uint32_t, uint32_t);
-static int	sun8i_crypto_task_scatter(struct sun8i_crypto_adrlen *,
-		bus_dmamap_t, uint32_t);
+static int	sun8i_crypto_task_scatter(struct sun8i_crypto_task *,
+		struct sun8i_crypto_adrlen *, bus_dmamap_t, uint32_t);
 
 static int	sun8i_crypto_task_load_trng(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, uint32_t);
@@ -196,19 +208,106 @@ static int	sun8i_crypto_sysctl_rng(SYSCT
 static void	sun8i_crypto_sysctl_rng_done(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, void *, int);
 
+static void	sun8i_crypto_register(struct sun8i_crypto_softc *);
+static void	sun8i_crypto_register1(struct sun8i_crypto_softc *, uint32_t);
+static int	sun8i_crypto_newsession(void *, uint32_t *,
+		struct cryptoini *);
+static int	sun8i_crypto_freesession(void *, uint64_t);
+static u_int	sun8i_crypto_ivlen(const struct cryptodesc *);
+static int	sun8i_crypto_process(void *, struct cryptop *, int);
+static void	sun8i_crypto_callback(struct sun8i_crypto_softc *,
+		struct sun8i_crypto_task *, void *, int);
+
+/*
+ * Probes
+ */
+
+SDT_PROBE_DEFINE2(sdt, sun8i_crypto, register, read,
+"bus_size_t"/*reg*/,
+"uint32_t"/*value*/);
+SDT_PROBE_DEFINE2(sdt, sun8i_crypto, register, write,
+"bus_size_t"/*reg*/,
+"uint32_t"/*write*/);
+
+SDT_PROBE_DEFINE1(sdt, sun8i_crypto, task, ctor__success,
+"struct sun8i_crypto_task *"/*task*/);
+SDT_PROBE_DEFINE1(sdt, sun8i_crypto, task, ctor__failure,
+"int"/*error*/);
+SDT_PROBE_DEFINE1(sdt, sun8i_crypto, task, dtor,
+"struct sun8i_crypto_task *"/*task*/);
+SDT_PROBE_DEFINE1(sdt, sun8i_crypto, task, get,
+"struct sun8i_crypto_task *"/*task*/);
+SDT_PROBE_DEFINE1(sdt, sun8i_crypto, task, put,
+"struct sun8i_crypto_task *"/*task*/);
+
+SDT_PROBE_DEFINE6(sdt, sun8i_crypto, task, load,
+"struct sun8i_crypto_task *"/*task*/,
+"uint32_t"/*tdqc*/,
+"uint32_t"/*tdqs*/,
+"uint32_t"/*tdqa*/,
+"struct sun8i_crypto_taskdesc *"/*desc*/,
+"int"/*error*/);
+SDT_PROBE_DEFINE3(sdt, sun8i_crypto, task, misaligned,
+"struct sun8i_crypto_task *"/*task*/,
+"bus_addr_t"/*ds_addr*/,
+"bus_size_t"/*ds_len*/);
+SDT_PROBE_DEFINE2(sdt, sun8i_crypto, task, done,
+"struct sun8i_crypto_task *"/*task*/,
+"int"/*error*/);
+
+SDT_PROBE_DEFINE3(sdt, sun8i_crypto, engine, submit__failure,
+"struct sun8i_crypto_softc *"/*sc*/,
+"struct sun8i_crypto_task *"/*task*/,
+"int"/*error*/);
+SDT_PROBE_DEFINE3(sdt, sun8i_crypto, engine, submit__success,
+"struct sun8i_crypto_softc 

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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:58:26 UTC 2020

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

Log Message:
Draft opencrypto support for Allwinner Crypto Engine.

XXX Can't handle nonzero crd_skip yet.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:57:54 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c sun8i_crypto.h

Log Message:
Rework sun8i crypto.

- Preallocate tasks and DMA maps together for now, for 4k transfers.
- Confine setup of the task descriptor to a single function, without
  bus_dmamap_t as an input; just use the preallocated DMA maps.
- Take the DMA map part out of sun8i_crypto_buf.
  => Not much left here, just a dmamem segment and kva mapping.

This should make it easier to use with opencrypto.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun8i_crypto.h

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.15 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.16
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.15	Sat Jun 13 18:54:38 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sat Jun 13 18:57:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.16 2020/06/13 18:57:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.16 2020/06/13 18:57:54 riastradh Exp $");
 
 #include 
 #include 
@@ -72,7 +72,6 @@ struct sun8i_crypto_task;
 struct sun8i_crypto_buf {
 	bus_dma_segment_t	cb_seg[1];
 	int			cb_nsegs;
-	bus_dmamap_t		cb_map;
 	void			*cb_kva;
 };
 
@@ -81,6 +80,7 @@ struct sun8i_crypto_softc {
 	bus_space_tag_t			sc_bst;
 	bus_space_handle_t		sc_bsh;
 	bus_dma_tag_t			sc_dmat;
+	struct pool_cache		*sc_taskpool;
 	kmutex_t			sc_lock;
 	struct sun8i_crypto_chan {
 		struct sun8i_crypto_task	*cc_task;
@@ -113,13 +113,32 @@ struct sun8i_crypto_softc {
 };
 
 struct sun8i_crypto_task {
-	struct sun8i_crypto_buf	ct_buf;
+	struct sun8i_crypto_buf	ct_descbuf;
 	struct sun8i_crypto_taskdesc *ct_desc;
+	bus_dmamap_t		ct_descmap;
+	bus_dmamap_t		ct_keymap;
+	bus_dmamap_t		ct_ivmap;
+	bus_dmamap_t		ct_ctrmap;
+	bus_dmamap_t		ct_srcmap;
+	bus_dmamap_t		ct_dstmap;
+	uint32_t		ct_nbytes;
+	int			ct_flags;
+#define	TASK_KEY		__BIT(0)
+#define	TASK_IV			__BIT(1)
+#define	TASK_CTR		__BIT(2)
+#define	TASK_SRC		__BIT(3)
+#define	TASK_BYTES		__BIT(4) /* datalen is in bytes, not words */
 	void			(*ct_callback)(struct sun8i_crypto_softc *,
 struct sun8i_crypto_task *, void *, int);
 	void			*ct_cookie;
 };
 
+#define	SUN8I_CRYPTO_MAXDMASIZE		PAGE_SIZE
+#define	SUN8I_CRYPTO_MAXDMASEGSIZE	PAGE_SIZE
+
+CTASSERT(SUN8I_CRYPTO_MAXDMASIZE <= SUN8I_CRYPTO_MAXDATALEN);
+CTASSERT(SUN8I_CRYPTO_MAXDMASEGSIZE <= SUN8I_CRYPTO_MAXSEGLEN);
+
 /*
  * Forward declarations
  */
@@ -127,33 +146,27 @@ struct sun8i_crypto_task {
 static int	sun8i_crypto_match(device_t, cfdata_t, void *);
 static void	sun8i_crypto_attach(device_t, device_t, void *);
 
+static int	sun8i_crypto_task_ctor(void *, void *, int);
+static void	sun8i_crypto_task_dtor(void *, void *);
 static struct sun8i_crypto_task *
 		sun8i_crypto_task_get(struct sun8i_crypto_softc *,
 		void (*)(struct sun8i_crypto_softc *,
 			struct sun8i_crypto_task *, void *, int),
-		void *);
+		void *, int);
 static void	sun8i_crypto_task_put(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *);
-static void	sun8i_crypto_task_reset(struct sun8i_crypto_task *);
 
-static void	sun8i_crypto_task_set_key(struct sun8i_crypto_task *,
-		bus_dmamap_t);
-static void	sun8i_crypto_task_set_iv(struct sun8i_crypto_task *,
-		bus_dmamap_t);
-static void	sun8i_crypto_task_set_ctr(struct sun8i_crypto_task *,
-		bus_dmamap_t);
-static void	sun8i_crypto_task_set_input(struct sun8i_crypto_task *,
-		bus_dmamap_t);
-static void	sun8i_crypto_task_set_output(struct sun8i_crypto_task *,
-		bus_dmamap_t);
+static int	sun8i_crypto_task_load(struct sun8i_crypto_softc *,
+		struct sun8i_crypto_task *, uint32_t,
+		uint32_t, uint32_t, uint32_t);
+static int	sun8i_crypto_task_scatter(struct sun8i_crypto_adrlen *,
+		bus_dmamap_t, uint32_t);
 
-static void	sun8i_crypto_task_scatter(struct sun8i_crypto_adrlen *,
-		bus_dmamap_t);
-
-static int	sun8i_crypto_submit_trng(struct sun8i_crypto_softc *,
+static int	sun8i_crypto_task_load_trng(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, uint32_t);
-static int	sun8i_crypto_submit_aesecb(struct sun8i_crypto_softc *,
+static int	sun8i_crypto_task_load_aesecb(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, uint32_t, uint32_t, uint32_t);
+
 static int	sun8i_crypto_submit(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *);
 
@@ -165,7 +178,7 @@ static void	

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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:57:54 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c sun8i_crypto.h

Log Message:
Rework sun8i crypto.

- Preallocate tasks and DMA maps together for now, for 4k transfers.
- Confine setup of the task descriptor to a single function, without
  bus_dmamap_t as an input; just use the preallocated DMA maps.
- Take the DMA map part out of sun8i_crypto_buf.
  => Not much left here, just a dmamem segment and kva mapping.

This should make it easier to use with opencrypto.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun8i_crypto.h

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



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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:54:38 UTC 2020

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

Log Message:
Truncate hw.sun8icryptoN.rng queries to 4096 bytes.

...rather than fail entirely.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2020-06-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jun 13 18:54:38 UTC 2020

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

Log Message:
Truncate hw.sun8icryptoN.rng queries to 4096 bytes.

...rather than fail entirely.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.15
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14	Fri May 15 19:28:09 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sat Jun 13 18:54:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.14 2020/05/15 19:28:09 maxv Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.14 2020/05/15 19:28:09 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $");
 
 #include 
 #include 
@@ -1203,10 +1203,8 @@ sun8i_crypto_sysctl_rng(SYSCTLFN_ARGS)
 		return 0;
 	}
 
-	/* Verify the output buffer size is reasonable.  */
-	size = *oldlenp;
-	if (size > 4096)	/* size_t, so never negative */
-		return E2BIG;
+	/* Truncate to 4096 bytes.  */
+	size = MIN(4096, *oldlenp);
 	if (size == 0)
 		return 0;	/* nothing to do */
 



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

2020-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May  7 11:24:47 UTC 2020

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

Log Message:
Add A20 CLK_OUT_A and CLK_OUT_B clocks


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c

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



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

2020-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May  7 11:24:47 UTC 2020

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

Log Message:
Add A20 CLK_OUT_A and CLK_OUT_B clocks


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.11 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.12
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.11	Thu Aug  1 22:23:16 2019
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Thu May  7 11:24:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.12 2020/05/07 11:24:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.12 2020/05/07 11:24:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -82,6 +82,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun4i_a10_cc
 #define	HDMI_CLOCK_CFG_REG	0x150
 #define	MALI_CLOCK_CFG_REG	0x154
 #define	IEP_SCLK_CFG_REG	0x160
+#define	CLK_OUTA_REG		0x1f0
+#define	CLK_OUTB_REG		0x1f4
 
 static int sun4i_a10_ccu_match(device_t, cfdata_t, void *);
 static void sun4i_a10_ccu_attach(device_t, device_t, void *);
@@ -123,6 +125,7 @@ static const char *mod_parents[] = { "os
 static const char *sata_parents[] = { "pll6_periph_sata", "external" };
 static const char *de_parents[] = { "pll_video0", "pll_video1", "pll_ddr_other" };
 static const char *lcd_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
+static const char *out_parents[] = { "losc" /* really OSC24MHz/750 */, "losc", "osc24m" };
 
 static const struct sunxi_ccu_nkmp_tbl sun4i_a10_pll1_table[] = {
 	{ 100800, 21, 1, 0, 0 },
@@ -484,6 +487,23 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 	0/* flags */
 	),
 
+	/* A20 specific */
+	SUNXI_CCU_NM(A20_CLK_OUT_A, "outa", out_parents,
+	CLK_OUTA_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A20_CLK_OUT_B, "outb", out_parents,
+	CLK_OUTB_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
 	/* AHB_GATING_REG0 */
 	SUNXI_CCU_GATE(A10_CLK_AHB_OTG, "ahb-otg", "ahb",
 	AHB_GATING_REG0, 0),



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

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 01:42:11 UTC 2020

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

Log Message:
Add the clock providers for the sun6i_a31, sun8i_a23, sun8i_r40, sun8i_v3,
sun8i_h3, sun50i_h5 (same as H3), and sun50i_h6 RTC blocks.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_rtc.c

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



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

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 01:42:11 UTC 2020

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

Log Message:
Add the clock providers for the sun6i_a31, sun8i_a23, sun8i_r40, sun8i_v3,
sun8i_h3, sun50i_h5 (same as H3), and sun50i_h6 RTC blocks.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_rtc.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_rtc.c
diff -u src/sys/arch/arm/sunxi/sunxi_rtc.c:1.5 src/sys/arch/arm/sunxi/sunxi_rtc.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_rtc.c:1.5	Thu Sep  5 23:42:26 2019
+++ src/sys/arch/arm/sunxi/sunxi_rtc.c	Fri Mar 27 01:42:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_rtc.c,v 1.5 2019/09/05 23:42:26 thorpej Exp $ */
+/* $NetBSD: sunxi_rtc.c,v 1.6 2020/03/27 01:42:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,v 1.5 2019/09/05 23:42:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,v 1.6 2020/03/27 01:42:10 thorpej Exp $");
 
 #include 
 #include 
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -64,6 +65,18 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #define	 SUN7I_RTC_SECOND	__BITS(5,0)
 #define	SUN7I_RTC_BASE_YEAR	1970
 
+#define	SUN6I_LOSC_CTRL_REG	0x00
+#define	 SUN6I_LOSC_CTRL_KEY		(0x16aa << 16)
+#define	 SUN6I_LOSC_CTRL_AUTO_SWT_BYPASS __BIT(15)
+#define	 SUN6I_LOSC_CTRL_ALM_DHMS_ACC	__BIT(9)
+#define	 SUN6I_LOSC_CTRL_RTC_HMS_ACC	__BIT(8)
+#define	 SUN6I_LOSC_CTRL_RTC_YMD_ACC	__BIT(7)
+#define	 SUN6I_LOSC_CTRL_EXT_LOSC_EN	__BIT(4)
+#define	 SUN6I_LOSC_CTRL_EXT_OSC	__BIT(0)
+
+#define	SUN6I_INTOSC_CLK_PRESCAL_REG 0x08
+#define	 SUN6I_INTOSC_CLK_PRESCAL	__BITS(0,4)
+
 #define	SUN6I_RTC_YY_MM_DD_REG	0x10
 #define	 SUN6I_RTC_LEAP		__BIT(22)
 #define	 SUN6I_RTC_YEAR		__BITS(21,16)
@@ -76,14 +89,25 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #define	 SUN6I_RTC_SECOND	__BITS(5,0)
 #define	SUN6I_RTC_BASE_YEAR	2000
 
+#define	SUN6I_RTC_LOSC_OUT_GATING_REG 0x60
+#define	 SUN6I_RTC_LOSC_OUT_EN	__BIT(0)
+
 struct sunxi_rtc_config {
 	bus_size_t	yy_mm_dd_reg;
 	uint32_t	leap, year, month, day;
 	bus_size_t	hh_mm_ss_reg;
 	uint32_t	wk_no, hour, minute, second;
 	u_int		base_year;
+
+	u_int		iosc_rate;
+	u_int		fixed_prescaler;
+	uint32_t	ext_losc_en;
+	uint32_t	auto_swt_bypass;
+	u_int		flags;
 };
 
+#define	SUNXI_RTC_F_HAS_VAR_PRESCALER	__BIT(0)
+
 static const struct sunxi_rtc_config sun4i_rtc_config = {
 	.yy_mm_dd_reg = SUN4I_RTC_YY_MM_DD_REG,
 	.leap = SUN4I_RTC_LEAP,
@@ -98,7 +122,7 @@ static const struct sunxi_rtc_config sun
 	.base_year = SUN4I_RTC_BASE_YEAR,
 };
 
-static const struct sunxi_rtc_config sun6i_rtc_config = {
+static const struct sunxi_rtc_config sun6i_a31_rtc_config = {
 	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
 	.leap = SUN6I_RTC_LEAP,
 	.year = SUN6I_RTC_YEAR,
@@ -110,6 +134,9 @@ static const struct sunxi_rtc_config sun
 	.minute = SUN6I_RTC_MINUTE,
 	.second = SUN6I_RTC_SECOND,
 	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 667000,
+	.flags = SUNXI_RTC_F_HAS_VAR_PRESCALER,
 };
 
 static const struct sunxi_rtc_config sun7i_rtc_config = {
@@ -126,21 +153,142 @@ static const struct sunxi_rtc_config sun
 	.base_year = SUN7I_RTC_BASE_YEAR,
 };
 
+static const struct sunxi_rtc_config sun8i_a23_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 667000,
+	.flags = SUNXI_RTC_F_HAS_VAR_PRESCALER,
+};
+
+static const struct sunxi_rtc_config sun8i_r40_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 1600,
+	.fixed_prescaler = 512,
+};
+
+static const struct sunxi_rtc_config sun8i_v3_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 32000,
+};
+
+static const struct sunxi_rtc_config sun8i_h3_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = 

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

2020-03-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Mar  7 00:51:10 UTC 2020

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

Log Message:
enable DDR and HS200 modes only on boards which claim to support them
with this eMMC works on libretech,all-h3-cc-h5
also tested on pinebook
ok jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/sunxi/sunxi_mmc.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_mmc.c
diff -u src/sys/arch/arm/sunxi/sunxi_mmc.c:1.40 src/sys/arch/arm/sunxi/sunxi_mmc.c:1.41
--- src/sys/arch/arm/sunxi/sunxi_mmc.c:1.40	Sat Oct  5 12:09:01 2019
+++ src/sys/arch/arm/sunxi/sunxi_mmc.c	Sat Mar  7 00:51:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mmc.c,v 1.40 2019/10/05 12:09:01 jmcneill Exp $ */
+/* $NetBSD: sunxi_mmc.c,v 1.41 2020/03/07 00:51:10 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_sunximmc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.40 2019/10/05 12:09:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.41 2020/03/07 00:51:10 macallan Exp $");
 
 #include 
 #include 
@@ -547,6 +547,14 @@ sunxi_mmc_attach_i(device_t self)
 	const u_int flags = sc->sc_config->flags;
 	struct sdmmcbus_attach_args saa;
 	uint32_t width;
+	const bool supports_hs200 =
+		of_hasprop(sc->sc_phandle, "mmc-hs200-1_2v") |
+		of_hasprop(sc->sc_phandle, "mmc-hs200-1_8v");
+
+	const bool supports_ddr =
+		of_hasprop(sc->sc_phandle, "mmc-ddr-1_2v") |
+		of_hasprop(sc->sc_phandle, "mmc-ddr-1_8v") |
+		of_hasprop(sc->sc_phandle, "mmc-ddr-3_3v");
 
 	if (sc->sc_pwrseq)
 		fdtbus_mmc_pwrseq_pre_power_on(sc->sc_pwrseq);
@@ -577,10 +585,11 @@ sunxi_mmc_attach_i(device_t self)
 		   SMC_CAPS_SD_HIGHSPEED |
 		   SMC_CAPS_MMC_HIGHSPEED;
 
-	if (sc->sc_config->delays || (flags & SUNXI_MMC_FLAG_NEW_TIMINGS))
+	if ((sc->sc_config->delays || (flags & SUNXI_MMC_FLAG_NEW_TIMINGS)) &&
+	 supports_ddr)
 		saa.saa_caps |= SMC_CAPS_MMC_DDR52;
 
-	if (flags & SUNXI_MMC_FLAG_HS200)
+	if ((flags & SUNXI_MMC_FLAG_HS200) != 0 && supports_hs200)
 		saa.saa_caps |= SMC_CAPS_MMC_HS200;
 
 	if (width == 4)



  1   2   3   4   5   6   7   8   >