CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: macallan Date: Mon Sep 16 23:37:13 UTC 2024 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu.h Log Message: set CLK_SET_RATE_PARENT for mux type clocks so clk_set_rate() can work with this my pinebook can change cpu speed again ok jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sunxi_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/sunxi_ccu.h diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.23 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.24 --- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.23 Sun Nov 7 17:13:12 2021 +++ src/sys/arch/arm/sunxi/sunxi_ccu.h Mon Sep 16 23:37:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu.h,v 1.23 2021/11/07 17:13:12 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu.h,v 1.24 2024/09/16 23:37:13 macallan Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -432,6 +432,7 @@ const char *sunxi_ccu_mux_get_parent(str [_id] = { \ .type = SUNXI_CCU_MUX,\ .base.name = (_name),\ + .base.flags = CLK_SET_RATE_PARENT, \ .u.mux.reg = (_reg),\ .u.mux.parents = (_parents), \ .u.mux.nparents = __arraycount(_parents), \
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: macallan Date: Mon Sep 16 23:37:13 UTC 2024 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu.h Log Message: set CLK_SET_RATE_PARENT for mux type clocks so clk_set_rate() can work with this my pinebook can change cpu speed again ok jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sunxi_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
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
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
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
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
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
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
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
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
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->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->sc_dai; + } + + if (sound_dai_cells == 2) { + const u_int iface = be32dec((const u_int *)data + 1); + if (iface == 0) { + return &sc->sc_dai; + } + } + + return NULL; } static struct fdtbus_dai_controller_func sun8i_codec_dai_funcs = {
CVS commit: src/sys/arch/arm/sunxi
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
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->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
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
> 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
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->sc_attach_task, &sunxi_fb_init); sunxi_task_schedule(parent, &sc->sc_attach_task); }
CVS commit: src/sys/arch/arm/sunxi
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
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->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->sc_rnd_source, irq); - } mutex_exit(&sc->sc_intr_lock);
CVS commit: src/sys/arch/arm/sunxi
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
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
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
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(&ifp->if_snd, m); +m_freem(m); +continue; + } break; } IFQ_DEQUEUE(&ifp->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(&sc->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
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
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
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->sc_intr_lock); - if (ifp->if_flags & IFF_OACTIVE) + if (sc->sc_m_transmit != NULL) goto out; IF_DEQUEUE(&ifp->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
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->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->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
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
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->sc_polling, true); + atomic_store_relaxed(&sc->sc_polling, false); /* Attach the sysctl. */ sun8i_crypto_sysctl_attach(sc);
CVS commit: src/sys/arch/arm/sunxi
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
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->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), + SUN8I_CRYPTO_I
CVS commit: src/sys/arch/arm/sunxi
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
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(&rng->cr_rndsource, sun8i_crypto_rng_get, sc); rnd_attach_source(&rng->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
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
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, &sun8i_crypto_task_ctor, &sun8i_crypto_task_dtor, sc); sc->sc_cfg = of_compatible_lookup(phandle, compat_data)->data; - mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM); callout_init(&sc->sc_timeout, CALLOUT_MPSAFE); callout_setfunc(&sc->sc_timeout, &sun8i_crypto_timeout, sc); if (workqueue_create(&sc->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->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->sc_intr_lock); sun8i_crypto_schedule_worker(sc); - callout_schedule(&sc->sc_timeout, SUN8I_CRYPTO_TIMEOUT); - -out: mutex_exit(&sc->sc_lock); + mutex_exit(&sc->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->sc_lock); + mutex_enter(&sc->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->sc_lock); + mutex_exit(&sc->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->sc_lock)); + KASSERT(mutex_owned(&sc->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->sc_lock); - - /* Acknowledge the work. */ + mutex_enter(&sc->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. - */ do
CVS commit: src/sys/arch/arm/sunxi
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
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->sc_tasks); + if (workqueue_create(&sc->sc_task_wq, "sunxidrm", + &sunxi_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 = &sunxi_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->sc_tasks)) { + struct sunxi_drm_task *const task = + SIMPLEQ_FIRST(&sc->sc_tasks); + + SIMPLEQ_REMOVE_HEAD(&sc->sc_tasks, sdt_u.queue); + (*task->sdt_fn)(task); + } + +out: /* Cause any subesquent tasks to be processed by the workqueue. */ + atomic_store_relaxed(&sc->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->sc_task_thread) == curlwp) + SIMPLEQ_INSERT_TAIL(&sc->sc_tasks, task, sdt_u.queue); + else + workqueue_enqueue(sc->sc_task_wq, &task->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; + s
CVS commit: src/sys/arch/arm/sunxi
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
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->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->sfa_fb_sizes, .da_fb_vaddr = sc->sc_fb->obj->vaddr, @@ -105,13 +115,14 @@ sunxi_fb_attach(device_t parent, device_ .da_params = &sunxifb_drmfb_params, }; + error = drmfb_attach(&sc->sc_drmfb, &da); 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
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
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, &fb->base, cmd); error = drm_framebuffer_init(ddev, &fb->base, &sunxi_drm_framebuffer_funcs); if (error != 0)
CVS commit: src/sys/arch/arm/sunxi
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
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, &sunxi_drm_framebuffer_funcs); if (error != 0) {
CVS commit: src/sys/arch/arm/sunxi
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
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
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
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
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
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, &addr, &size) != 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->sc_intr_cells); + interrupts = fdtbus_get_prop(phandle, "interrupts", &len); + 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); + ap
CVS commit: src/sys/arch/arm/sunxi
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
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
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
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
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.
Re: CVS commit: src/sys/arch/arm/sunxi
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
Re: CVS commit: src/sys/arch/arm/sunxi
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->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@1e6000
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 12:21:14 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reclaim bootloader FB memory for CMA pool. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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.8 src/sys/arch/arm/sunxi/sunxi_drm.c:1.9 --- src/sys/arch/arm/sunxi/sunxi_drm.c:1.8 Tue Nov 5 23:31:23 2019 +++ src/sys/arch/arm/sunxi/sunxi_drm.c Sun Nov 24 12:21:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $ */ +/* $NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $"); #include #include @@ -296,6 +296,27 @@ static struct drm_mode_config_funcs sunx }; static int +sunxi_drm_simplefb_lookup(bus_addr_t *paddr, bus_size_t *psize) +{ + static const char * compat[] = { "simple-framebuffer", NULL }; + int chosen, child; + + chosen = OF_finddevice("/chosen"); + if (chosen == -1) + return ENOENT; + + for (child = OF_child(chosen); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) + continue; + if (!of_match_compatible(child, compat)) + continue; + return fdtbus_get_reg(child, 0, paddr, psize); + } + + return ENOENT; +} + +static int sunxi_drm_fb_probe(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes) { struct sunxi_drm_softc * const sc = sunxi_drm_private(helper->dev); @@ -303,6 +324,8 @@ sunxi_drm_fb_probe(struct drm_fb_helper struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb); struct drm_framebuffer *fb = helper->fb; struct sunxi_drmfb_attach_args sfa; + bus_addr_t sfb_addr; + bus_size_t sfb_size; size_t cma_size; int error; @@ -312,14 +335,31 @@ sunxi_drm_fb_probe(struct drm_fb_helper const size_t size = roundup(height * pitch, PAGE_SIZE); - /* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */ - cma_size = size; - cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4); + if (sunxi_drm_simplefb_lookup(&sfb_addr, &sfb_size) != 0) + sfb_size = 0; + + /* Reserve enough memory for a 4K plane, rounded to 1MB */ + cma_size = (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4); + if (sfb_size == 0) { + /* Add memory for FB console if we cannot reclaim bootloader memory */ + cma_size += size; + } cma_size = roundup(cma_size, 1024 * 1024); sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size); - if (sc->sc_ddev->cma_pool != NULL) - aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n", - (u_int)(cma_size / (1024 * 1024))); + if (sc->sc_ddev->cma_pool != NULL) { + if (sfb_size != 0) { + error = vmem_add(sc->sc_ddev->cma_pool, sfb_addr, + sfb_size, VM_SLEEP); + if (error != 0) +sfb_size = 0; + } + aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA", + (u_int)((cma_size + sfb_size) / (1024 * 1024))); + if (sfb_size != 0) + aprint_normal(" (%u MB reclaimed from bootloader)", + (u_int)(sfb_size / (1024 * 1024))); + aprint_normal("\n"); + } sfb->obj = drm_gem_cma_create(ddev, size); if (sfb->obj == NULL) {
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 12:21:14 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reclaim bootloader FB memory for CMA pool. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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
Module Name:src Committed By: jmcneill Date: Sun Nov 24 10:27:37 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c sunxi_platform.c Log Message: Try to avoid changing hardware settings when the "nomodeset" kernel arg is present. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.37 -r1.38 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
Module Name:src Committed By: jmcneill Date: Sun Nov 24 10:27:37 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c sunxi_platform.c Log Message: Try to avoid changing hardware settings when the "nomodeset" kernel arg is present. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.37 -r1.38 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/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.20 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 Sat Nov 23 22:46:53 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $"); #include #include @@ -601,6 +601,8 @@ sun50i_a64_ccu_attach(device_t parent, d { struct sunxi_ccu_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + prop_dictionary_t prop = device_properties(self); + bool nomodeset; sc->sc_dev = self; sc->sc_phandle = faa->faa_phandle; @@ -618,19 +620,23 @@ sun50i_a64_ccu_attach(device_t parent, d aprint_naive("\n"); aprint_normal(": A64 CCU\n"); - /* Set DE parent to PLL_DE */ - clk_set_parent(&sc->sc_clks[A64_CLK_DE].base, &sc->sc_clks[A64_CLK_PLL_DE].base); - clk_set_rate(&sc->sc_clks[A64_CLK_PLL_DE].base, 42000); - - /* Set video PLLs to 297 MHz */ - clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); - clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); - - /* Set TCON1 parent to PLL_VIDEO1(1X) */ - clk_set_parent(&sc->sc_clks[A64_CLK_TCON1].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); - - /* Set HDMI parent to PLL_VIDEO1(1X) */ - clk_set_parent(&sc->sc_clks[A64_CLK_HDMI].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); + nomodeset = false; + prop_dictionary_get_bool(prop, "nomodeset", &nomodeset); + if (!nomodeset) { + /* Set DE parent to PLL_DE */ + clk_set_parent(&sc->sc_clks[A64_CLK_DE].base, &sc->sc_clks[A64_CLK_PLL_DE].base); + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_DE].base, 42000); + + /* Set video PLLs to 297 MHz */ + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + + /* Set TCON1 parent to PLL_VIDEO1(1X) */ + clk_set_parent(&sc->sc_clks[A64_CLK_TCON1].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); + + /* Set HDMI parent to PLL_VIDEO1(1X) */ + clk_set_parent(&sc->sc_clks[A64_CLK_HDMI].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); + } sunxi_ccu_print(sc); } Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 Sat Nov 23 18:55:08 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $"); #include #include @@ -228,12 +228,20 @@ sunxi_dwhdmi_attach(device_t parent, dev { struct sunxi_dwhdmi_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + prop_dictionary_t prop = device_properties(self); const int phandle = faa->faa_phandle; struct clk *clk_iahb, *clk_isfr, *clk_tmds; struct fdtbus_reset *rst; + bool is_disabled; bus_addr_t addr; bus_size_t size; + if (prop_dictionary_get_bool(prop, "disabled", &is_disabled) && is_disabled) { + aprint_naive("\n"); + aprint_normal(": HDMI TX (disabled)\n"); + return; + } + if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) { aprint_error(": couldn't get registers\n"); return; Index: src/sys/arch/arm/sunxi/sunxi_platform.c diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.37 src/sys/arch/arm/sunxi/sunxi_platform.c:1.38 --- src/sys/arch/arm/sunxi/sunxi_platform.c:1.37 Mon Jun 17 05:27:01 2019 +++ src/sys/arch/arm/sunxi/sunxi_platform.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_platform.c,v 1.37 2019/06/17 05:27:01 mrg Exp $ */ +/* $NetBSD: sunxi_platform.c,v 1.38
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 23:47:57 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume the cursor pitch is the same as the primary fb To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.10 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 Sat Nov 23 21:40:57 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 23:47:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $"); #include #include @@ -373,7 +373,7 @@ sunxi_mixer_cursor_set(struct drm_crtc * /* Set UI overlay offset */ OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset); /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]); + OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 23:47:57 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume the cursor pitch is the same as the primary fb To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 22:46:53 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set video PLLs to 297MHz To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 22:46:53 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set video PLLs to 297MHz To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 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.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 Sat Nov 23 18:57:36 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 22:46:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $"); #include #include @@ -622,9 +622,15 @@ sun50i_a64_ccu_attach(device_t parent, d clk_set_parent(&sc->sc_clks[A64_CLK_DE].base, &sc->sc_clks[A64_CLK_PLL_DE].base); clk_set_rate(&sc->sc_clks[A64_CLK_PLL_DE].base, 42000); + /* Set video PLLs to 297 MHz */ + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + /* Set TCON1 parent to PLL_VIDEO1(1X) */ clk_set_parent(&sc->sc_clks[A64_CLK_TCON1].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); - clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + + /* Set HDMI parent to PLL_VIDEO1(1X) */ + clk_set_parent(&sc->sc_clks[A64_CLK_HDMI].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); sunxi_ccu_print(sc); }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:40:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Support non-zero fb start pixels. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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.8 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 Sat Nov 23 20:24:12 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 21:40:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $"); #include #include @@ -252,6 +252,9 @@ sunxi_mixer_mode_do_set_base(struct drm_ uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr; + paddr += y * sfb->base.pitches[0]; + paddr += x * drm_format_plane_cpp(sfb->base.pixel_format, 0); + uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0; uint32_t laddr = paddr & 0x; @@ -461,7 +464,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr const uint32_t size = ((adjusted_mode->vdisplay - 1) << 16) | (adjusted_mode->hdisplay - 1); - const uint32_t offset = (y << 16) | x; /* Set global size */ GLB_WRITE(sc, GLB_SIZE, size); @@ -474,7 +476,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr /* Set blender 0 input size */ BLD_WRITE(sc, BLD_CH_ISIZE(0), size); /* Set blender 0 offset */ - BLD_WRITE(sc, BLD_CH_OFFSET(0), offset); + BLD_WRITE(sc, BLD_CH_OFFSET(0), 0); /* Route channel 1 to pipe 0 */ val = BLD_READ(sc, BLD_CH_RTCTL); val &= ~BLD_CH_RTCTL_P0; @@ -493,7 +495,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr /* Set UI overlay layer size */ OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size); /* Set UI overlay offset */ - OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset); + OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), 0); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:40:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Support non-zero fb start pixels. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:30:41 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by jak. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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_fractional.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 Sat Nov 23 18:52:09 2019 +++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Sat Nov 23 21:30:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $"); #include #include @@ -137,6 +137,7 @@ sunxi_ccu_fractional_set_rate(struct sun for (i = 0; i < __arraycount(fractional->frac); i++) { if (fractional->frac[i] == new_rate) { + val &= ~fractional->prediv; val &= ~fractional->div_en; val &= ~fractional->frac_sel; val |= __SHIFTIN(i, fractional->frac_sel);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:30:41 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by jak. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:28:04 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_lcdc.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_lcdc.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_lcdc.c diff -u src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6 src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6 Sat Jul 6 00:23:38 2019 +++ src/sys/arch/arm/sunxi/sunxi_lcdc.c Sat Nov 23 20:28:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $ */ +/* $NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $"); #include #include @@ -81,7 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c #define TCON1_CTL_REG 0x090 #define TCON1_CTL_TCON1_EN __BIT(31) #define TCON1_CTL_START_DELAY __BITS(8,4) -#define TCON1_CTL_TCON1_SRC_SEL __BIT(1) +#define TCON1_CTL_TCON1_SRC_SEL __BITS(1,0) #define TCON1_BASIC0_REG 0x094 #define TCON1_BASIC1_REG 0x098 #define TCON1_BASIC2_REG 0x09c @@ -185,6 +185,7 @@ sunxi_lcdc_tcon0_prepare(struct drm_enco val = TCON_READ(sc, TCON_GCTL_REG); val |= TCON_GCTL_TCON_EN; + val &= ~TCON_GCTL_IO_MAP_SEL; TCON_WRITE(sc, TCON_GCTL_REG, val); TCON_WRITE(sc, TCON0_IO_TRI_REG, 0); @@ -215,20 +216,20 @@ sunxi_lcdc_tcon0_commit(struct drm_encod int error; const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0; - const u_int hspw = mode->hsync_end - mode->hsync_start; - const u_int hbp = mode->htotal - mode->hsync_start; - const u_int vspw = mode->vsync_end - mode->vsync_start; - const u_int vbp = mode->vtotal - mode->vsync_start; - const u_int vblank_len = (mode->vtotal - mode->vdisplay) >> interlace_p; + const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start; + const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start; + const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start; + const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start; + const u_int vblank_len = (mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p; const u_int start_delay = uimin(vblank_len, 30); val = TCON0_CTL_TCON0_EN | __SHIFTIN(start_delay, TCON0_CTL_START_DELAY); TCON_WRITE(sc, TCON0_CTL_REG, val); - TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->htotal - 1) << 16) | (hbp - 1)); - TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->vtotal * 2) << 16) | (vbp - 1)); + TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->crtc_vdisplay - 1)); + TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->crtc_htotal - 1) << 16) | (hbp - 1)); + TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->crtc_vtotal * 2) << 16) | (vbp - 1)); TCON_WRITE(sc, TCON0_BASIC3_REG, ((hspw - 1) << 16) | (vspw - 1)); val = TCON_READ(sc, TCON0_IO_POL_REG); @@ -268,24 +269,22 @@ sunxi_lcdc_tcon1_commit(struct drm_encod int error; const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0; - const u_int hspw = mode->hsync_end - mode->hsync_start; - const u_int hbp = mode->htotal - mode->hsync_start; - const u_int vspw = mode->vsync_end - mode->vsync_start; - const u_int vbp = mode->vtotal - mode->vsync_start; - const u_int vblank_len = - ((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2; - const u_int start_delay = - vblank_len >= 32 ? 30 : vblank_len - 2; + const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start; + const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start; + const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start; + const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start; + const u_int vblank_len = ((mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p) - 2; + const u_int start_delay = uimin(vblank_len, 30); val = TCON1_CTL_TCON1_EN | __SHIFTIN(start_delay, TCON1_CTL_START_DELAY); TCON_WRITE(sc, TCON1_CTL_REG, val); - TCON_WRITE(sc, TCON1_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC1_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC2_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC3_REG, ((mode->htotal - 1) << 16) | (hbp - 1)); - TCON_WRITE(sc, TCON1_BASIC4_REG, ((mode->vtotal * 2) << 16) | (vbp - 1)); + TCON_WRITE(sc, TCON1_BASIC0_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->crtc_vdisplay - 1)); + TCON_WRITE(sc, TCON1_BASIC1_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->c
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:28:04 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_lcdc.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_lcdc.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:24:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume that an fb's pitch is width * 4 bytes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:24:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume that an fb's pitch is width * 4 bytes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7 Sat Feb 16 16:20:50 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 20:24:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $"); #include #include @@ -255,6 +255,9 @@ sunxi_mixer_mode_do_set_base(struct drm_ uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0; uint32_t laddr = paddr & 0x; + /* Set UI overlay line size */ + OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), sfb->base.pitches[0]); + /* Framebuffer start address */ val = OVL_UI_READ(sc, 0, OVL_UI_TOP_HADD); val &= ~OVL_UI_TOP_HADD_LAYER0; @@ -367,7 +370,7 @@ sunxi_mixer_cursor_set(struct drm_crtc * /* Set UI overlay offset */ OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset); /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4); + OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size); @@ -491,8 +494,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size); /* Set UI overlay offset */ OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset); - /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), adjusted_mode->hdisplay * 4); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:57:36 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set TCON1 parent to PLL_VIDEO1(1X) To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 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.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 Sat Nov 23 12:29:20 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 18:57:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $"); #include #include @@ -622,5 +622,9 @@ sun50i_a64_ccu_attach(device_t parent, d clk_set_parent(&sc->sc_clks[A64_CLK_DE].base, &sc->sc_clks[A64_CLK_PLL_DE].base); clk_set_rate(&sc->sc_clks[A64_CLK_PLL_DE].base, 42000); + /* Set TCON1 parent to PLL_VIDEO1(1X) */ + clk_set_parent(&sc->sc_clks[A64_CLK_TCON1].base, &sc->sc_clks[A64_CLK_PLL_VIDEO1].base); + clk_set_rate(&sc->sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + sunxi_ccu_print(sc); }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:57:36 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set TCON1 parent to PLL_VIDEO1(1X) To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:55:08 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Set pixel clock on mode set To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 Sat Nov 23 12:30:45 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sat Nov 23 18:55:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $"); #include #include @@ -62,6 +62,7 @@ struct sunxi_dwhdmi_softc { int sc_phandle; struct fdtbus_phy *sc_phy; struct fdtbus_regulator *sc_regulator; + struct clk *sc_clk; struct fdt_device_ports sc_ports; struct drm_display_mode sc_curmode; @@ -186,6 +187,15 @@ sunxi_dwhdmi_mode_set(struct dwhdmi_soft struct drm_display_mode *adjusted_mode) { struct sunxi_dwhdmi_softc * const sc = to_sunxi_dwhdmi_softc(dsc); + int error; + + if (sc->sc_clk != NULL) { + error = clk_set_rate(sc->sc_clk, adjusted_mode->clock * 1000); + if (error != 0) + device_printf(sc->sc_base.sc_dev, + "couldn't set pixel clock to %u Hz: %d\n", + adjusted_mode->clock * 1000, error); + } sc->sc_curmode = *adjusted_mode; } @@ -229,12 +239,6 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } - rst = fdtbus_reset_get(phandle, "ctrl"); - if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { - aprint_error(": couldn't de-assert reset\n"); - return; - } - clk_iahb = fdtbus_clock_get(phandle, "iahb"); if (clk_iahb == NULL || clk_enable(clk_iahb) != 0) { aprint_error(": couldn't enable iahb clock\n"); @@ -267,6 +271,7 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_base.sc_scl_hcnt = 0xd8; sc->sc_base.sc_scl_lcnt = 0xfe; sc->sc_phandle = faa->faa_phandle; + sc->sc_clk = clk_tmds; aprint_naive("\n"); aprint_normal(": HDMI TX\n"); @@ -281,6 +286,12 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } + rst = fdtbus_reset_get(phandle, "ctrl"); + if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { + aprint_error_dev(self, "couldn't de-assert reset\n"); + return; + } + sunxi_hdmiphy_init(sc->sc_phy); if (dwhdmi_attach(&sc->sc_base) != 0) {
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:55:08 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Set pixel clock on mode set To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:54:26 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_hdmiphy.c Log Message: Need to initialize the PHY before HPD sense and DDC will work To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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_hdmiphy.c diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.4 --- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 Sat Nov 23 12:30:45 2019 +++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Sat Nov 23 18:54:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */ +/* $NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $"); #include #include @@ -128,6 +128,7 @@ struct sunxi_hdmiphy_softc { const struct sunxi_hdmiphy_data *sc_data; + struct fdtbus_reset *sc_rst; struct clk *sc_clk_bus; struct clk *sc_clk_mod; struct clk *sc_clk_pll0; @@ -173,14 +174,6 @@ sunxi_hdmiphy_release(device_t dev, void static int sunxi_hdmiphy_enable(device_t dev, void *priv, bool enable) { - struct sunxi_hdmiphy_softc * const sc = priv; - - if (enable) { - sc->sc_data->init(sc); - } else { - sc->sc_data->config(sc, 0); - } - return 0; } @@ -421,11 +414,10 @@ sunxi_hdmiphy_attach(device_t parent, de } rst = fdtbus_reset_get(phandle, "phy"); - if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { - aprint_error(": couldn't de-assert reset\n"); + if (rst == NULL) { + aprint_error(": couldn't get reset\n"); return; } - clk_bus = fdtbus_clock_get(phandle, "bus"); clk_mod = fdtbus_clock_get(phandle, "mod"); clk_pll0 = fdtbus_clock_get(phandle, "pll-0"); @@ -441,6 +433,7 @@ sunxi_hdmiphy_attach(device_t parent, de aprint_error(": couldn't map registers\n"); return; } + sc->sc_rst = rst; sc->sc_clk_bus = clk_bus; sc->sc_clk_mod = clk_mod; sc->sc_clk_pll0 = clk_pll0; @@ -461,6 +454,10 @@ sunxi_hdmiphy_init(struct fdtbus_phy *ph clk_enable(sc->sc_clk_mod); clk_enable(sc->sc_clk_pll0); + fdtbus_reset_deassert(sc->sc_rst); + + sc->sc_data->init(sc); + PHY_WRITE(sc, READ_EN, READ_EN_MAGIC); PHY_WRITE(sc, UNSCRAMBLE, UNSCRAMBLE_MAGIC);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:54:26 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_hdmiphy.c Log Message: Need to initialize the PHY before HPD sense and DDC will work To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:52:09 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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_fractional.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 --- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4 Wed Jan 30 01:24:00 2019 +++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Sat Nov 23 18:52:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $"); #include #include @@ -140,6 +140,8 @@ sunxi_ccu_fractional_set_rate(struct sun val &= ~fractional->div_en; val &= ~fractional->frac_sel; val |= __SHIFTIN(i, fractional->frac_sel); + if (fractional->flags & SUNXI_CCU_FRACTIONAL_SET_ENABLE) +val |= fractional->enable; CCU_WRITE(sc, fractional->reg, val); return 0; }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:52:09 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:30:45 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h Log Message: HDMI PHY and TX share the same clocks. Do not enable clocks until both reset resources have been deasserted. Explicitly set DDC clock dividers. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 Fri Nov 22 19:48:58 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sat Nov 23 12:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $"); #include #include @@ -101,13 +101,6 @@ sunxi_dwhdmi_ep_activate(device_t dev, s if (encoder == NULL) return EINVAL; - sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy"); - if (sc->sc_phy == NULL) { - device_printf(dev, "couldn't find hdmi-phy\n"); - return ENXIO; - } - - sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply"); if (sc->sc_regulator != NULL) { error = fdtbus_regulator_enable(sc->sc_regulator); if (error != 0) { @@ -271,11 +264,25 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_base.sc_enable = sunxi_dwhdmi_enable; sc->sc_base.sc_disable = sunxi_dwhdmi_disable; sc->sc_base.sc_mode_set = sunxi_dwhdmi_mode_set; + sc->sc_base.sc_scl_hcnt = 0xd8; + sc->sc_base.sc_scl_lcnt = 0xfe; sc->sc_phandle = faa->faa_phandle; aprint_naive("\n"); aprint_normal(": HDMI TX\n"); + sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply"); + + sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy"); + if (sc->sc_phy == NULL) + sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "phy"); + if (sc->sc_phy == NULL) { + device_printf(self, "couldn't find PHY\n"); + return; + } + + sunxi_hdmiphy_init(sc->sc_phy); + if (dwhdmi_attach(&sc->sc_base) != 0) { aprint_error_dev(self, "failed to attach driver\n"); return; Index: src/sys/arch/arm/sunxi/sunxi_hdmiphy.c diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 --- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2 Thu Jan 31 01:49:28 2019 +++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Sat Nov 23 12:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $ */ +/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $"); #include #include @@ -128,6 +128,8 @@ struct sunxi_hdmiphy_softc { const struct sunxi_hdmiphy_data *sc_data; + struct clk *sc_clk_bus; + struct clk *sc_clk_mod; struct clk *sc_clk_pll0; u_int sc_rcalib; @@ -425,20 +427,10 @@ sunxi_hdmiphy_attach(device_t parent, de } clk_bus = fdtbus_clock_get(phandle, "bus"); - if (clk_bus == NULL || clk_enable(clk_bus) != 0) { - aprint_error(": couldn't enable bus clock\n"); - return; - } - clk_mod = fdtbus_clock_get(phandle, "mod"); - if (clk_mod == NULL || clk_enable(clk_mod) != 0) { - aprint_error(": couldn't enable mod clock\n"); - return; - } - clk_pll0 = fdtbus_clock_get(phandle, "pll-0"); - if (clk_pll0 == NULL || clk_enable(clk_pll0) != 0) { - aprint_error(": couldn't enable pll-0 clock\n"); + if (clk_bus == NULL || clk_mod == NULL || clk_pll0 == NULL) { + aprint_error(": couldn't get clocks\n"); return; } @@ -449,12 +441,25 @@ sunxi_hdmiphy_attach(device_t parent, de aprint_error(": couldn't map registers\n"); return; } + sc->sc_clk_bus = clk_bus; + sc->sc_clk_mod = clk_mod; sc->sc_clk_pll0 = clk_pll0; aprint_naive("\n"); aprint_normal(": HDMI PHY\n"); fdtbus_register_phy_controller(self, phandle, &sunxi_hdmiphy_funcs); +} + +void +sunxi_hdmiphy_init(struct fdtbus_phy *phy) +{ + device_t dev = fdtbus_phy_device(phy); + struct sunxi_hdmiphy_softc * const sc = device_private(dev); + + clk_enable(sc->sc_clk_bus); + clk_enable(sc->sc_clk_mod); + clk_enable(sc->sc_clk_pll0); PHY_WRITE(sc, READ_EN, READ_EN_MAGIC); PHY_WRITE(sc, UNSCRAMBLE, UNSCRAMBLE_MAGIC); I
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:30:45 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h Log Message: HDMI PHY and TX share the same clocks. Do not enable clocks until both reset resources have been deasserted. Explicitly set DDC clock dividers. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:29:20 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add TCON0 clock To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 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
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:29:20 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add TCON0 clock To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 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.16 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 Fri Nov 22 19:46:38 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 12:29:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $"); #include #include @@ -69,6 +69,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define DRAM_CFG_REG 0x0f4 #define MBUS_RST_REG 0x0fc #define DE_CLK_REG 0x104 +#define TCON0_CLK_REG 0x118 #define TCON1_CLK_REG 0x11c #define AC_DIG_CLK_REG 0x140 #define HDMI_CLK_REG 0x150 @@ -161,6 +162,7 @@ static const char *de_parents[] = { "pll static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL }; +static const char *tcon0_parents[] = { "pll_mipi", NULL, "pll_video0_2x", NULL }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -459,6 +461,13 @@ static struct sunxi_ccu_clk sun50i_a64_c __BIT(31), /* enable */ SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), + SUNXI_CCU_DIV_GATE(A64_CLK_TCON0, "tcon0", tcon0_parents, + TCON0_CLK_REG, /* reg */ + 0, /* div */ + __BITS(26,24), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */ __BITS(3,0), /* div */
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jakllsch Date: Sat Nov 23 03:59:39 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu.h Log Message: Store the flags passed to SUNXI_CCU_FRACTIONAL macro. Previously the macro dropped the flags argument entirely, and did not initialize the structure with it. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_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/sunxi_ccu.h diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.21 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.22 --- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.21 Wed Jan 30 01:24:00 2019 +++ src/sys/arch/arm/sunxi/sunxi_ccu.h Sat Nov 23 03:59:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu.h,v 1.21 2019/01/30 01:24:00 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu.h,v 1.22 2019/11/23 03:59:39 jakllsch Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -405,6 +405,7 @@ const char *sunxi_ccu_fractional_get_par .u.fractional.frac[0] = (_frac0), \ .u.fractional.frac[1] = (_frac1), \ .u.fractional.enable = (_enable), \ + .u.fractional.flags = (_flags),\ .enable = sunxi_ccu_fractional_enable, \ .get_rate = sunxi_ccu_fractional_get_rate, \ .set_rate = sunxi_ccu_fractional_set_rate, \
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jakllsch Date: Sat Nov 23 03:59:39 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu.h Log Message: Store the flags passed to SUNXI_CCU_FRACTIONAL macro. Previously the macro dropped the flags argument entirely, and did not initialize the structure with it. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sunxi/sunxi_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
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:48:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Enable TMDS clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 Sun Nov 17 17:33:34 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Fri Nov 22 19:48:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $"); #include #include @@ -226,7 +226,7 @@ sunxi_dwhdmi_attach(device_t parent, dev struct sunxi_dwhdmi_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - struct clk *clk_iahb, *clk_isfr; + struct clk *clk_iahb, *clk_isfr, *clk_tmds; struct fdtbus_reset *rst; bus_addr_t addr; bus_size_t size; @@ -254,6 +254,12 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } + clk_tmds = fdtbus_clock_get(phandle, "tmds"); + if (clk_tmds == NULL || clk_enable(clk_tmds) != 0) { + aprint_error(": couldn't enable tmds clock\n"); + return; + } + sc->sc_base.sc_dev = self; sc->sc_base.sc_reg_width = 1; sc->sc_base.sc_bst = faa->faa_bst;
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:48:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Enable TMDS clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.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
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:46:38 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Fix CLK_BUS_HDMI bit To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 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
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:46:38 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Fix CLK_BUS_HDMI bit To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 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.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 Sun Nov 17 19:51:12 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Fri Nov 22 19:46:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $"); #include #include @@ -521,7 +521,7 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_GATE(A64_CLK_BUS_CSI, "bus-csi", "ahb1", BUS_CLK_GATING_REG1, 8), SUNXI_CCU_GATE(A64_CLK_BUS_HDMI, "bus-hdmi", "ahb1", - BUS_CLK_GATING_REG1, 10), + BUS_CLK_GATING_REG1, 11), SUNXI_CCU_GATE(A64_CLK_BUS_DE, "bus-de", "ahb1", BUS_CLK_GATING_REG1, 12), SUNXI_CCU_GATE(A64_CLK_BUS_GPU, "bus-gpu", "ahb1",
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add SPI clocks To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 Sun Nov 17 17:33:17 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 17 19:51:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $"); #include #include @@ -60,6 +60,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define SDMMC0_CLK_REG 0x088 #define SDMMC1_CLK_REG 0x08c #define SDMMC2_CLK_REG 0x090 +#define SPI0_CLK_REG 0x0a0 +#define SPI1_CLK_REG 0x0a4 #define I2SPCM0_CLK_REG 0x0b0 #define I2SPCM1_CLK_REG 0x0b4 #define I2SPCM2_CLK_REG 0x0b8 @@ -158,6 +160,7 @@ static const char *ths_parents[] = { "ho static const char *de_parents[] = { "pll_periph0_2x", "pll_de" }; static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; +static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -260,6 +263,16 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_NKMP_DIVIDE_BY_TWO), SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH0_2X, "pll_periph0_2x", "pll_periph0", 1, 2), + SUNXI_CCU_NKMP(A64_CLK_PLL_PERIPH1, "pll_periph1", "hosc", + PLL_PERIPH1_CTRL_REG, /* reg */ + __BITS(12,8), /* n */ + __BITS(5,4), /* k */ + 0,/* m */ + __BITS(17,16), /* p */ + __BIT(31), /* enable */ + SUNXI_CCU_NKMP_DIVIDE_BY_TWO), + SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH1_2X, "pll_periph1_2x", "pll_periph1", 1, 2), + SUNXI_CCU_NKMP_TABLE(A64_CLK_PLL_AUDIO_BASE, "pll_audio_base", "hosc", PLL_AUDIO_CTRL_REG, /* reg */ __BITS(14,8), /* n */ @@ -430,6 +443,21 @@ static struct sunxi_ccu_clk sun50i_a64_c __BIT(31), /* enable */ 0), + SUNXI_CCU_NM(A64_CLK_SPI0, "spi0", spi_parents, + SPI0_CLK_REG, /* reg */ + __BITS(17,16), /* n */ + __BITS(3,0), /* m */ + __BITS(25,24), /* sel */ + __BIT(31), /* enable */ + SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), + + SUNXI_CCU_NM(A64_CLK_SPI1, "spi1", spi_parents, + SPI1_CLK_REG, /* reg */ + __BITS(17,16), /* n */ + __BITS(3,0), /* m */ + __BITS(25,24), /* sel */ + __BIT(31), /* enable */ + SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add SPI clocks To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 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
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:34 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_i2s.c Log Message: Add A64 HDMI audio support. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_i2s.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_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.3 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.3 Sat Feb 2 17:35:16 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sun Nov 17 17:33:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $"); #include #include @@ -197,6 +197,21 @@ sunxi_dwhdmi_mode_set(struct dwhdmi_soft sc->sc_curmode = *adjusted_mode; } +static audio_dai_tag_t +sunxi_dwhdmi_dai_get_tag(device_t dev, const void *data, size_t len) +{ + struct sunxi_dwhdmi_softc * const sc = device_private(dev); + + if (len != 4) + return NULL; + + return &sc->sc_base.sc_dai; +} + +static struct fdtbus_dai_controller_func sunxi_dwhdmi_dai_funcs = { + .get_tag = sunxi_dwhdmi_dai_get_tag +}; + static int sunxi_dwhdmi_match(device_t parent, cfdata_t cf, void *aux) { @@ -263,6 +278,8 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_ports.dp_ep_activate = sunxi_dwhdmi_ep_activate; sc->sc_ports.dp_ep_get_data = sunxi_dwhdmi_ep_get_data; fdt_ports_register(&sc->sc_ports, self, phandle, EP_DRM_BRIDGE); + + fdtbus_register_dai_controller(self, phandle, &sunxi_dwhdmi_dai_funcs); } CFATTACH_DECL_NEW(sunxi_dwhdmi, sizeof(struct sunxi_dwhdmi_softc), Index: src/sys/arch/arm/sunxi/sunxi_i2s.c diff -u src/sys/arch/arm/sunxi/sunxi_i2s.c:1.6 src/sys/arch/arm/sunxi/sunxi_i2s.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_i2s.c:1.6 Sat Jun 8 08:02:37 2019 +++ src/sys/arch/arm/sunxi/sunxi_i2s.c Sun Nov 17 17:33:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_i2s.c,v 1.6 2019/06/08 08:02:37 isaki Exp $ */ +/* $NetBSD: sunxi_i2s.c,v 1.7 2019/11/17 17:33:34 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.6 2019/06/08 08:02:37 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.7 2019/11/17 17:33:34 jmcneill Exp $"); #include #include @@ -42,16 +42,24 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c, #include -#define SUNXI_I2S_CLK_RATE 24576000 +#define SUNXI_I2S_CLK_RATE 24576000 +#define SUNXI_I2S_SAMPLE_RATE 48000 #define DA_CTL 0x00 +#define DA_CTL_BCLK_OUT __BIT(18) /* sun8i */ +#define DA_CLK_LRCK_OUT __BIT(17) /* sun8i */ #define DA_CTL_SDO_EN __BIT(8) -#define DA_CTL_MS __BIT(5) -#define DA_CTL_PCM __BIT(4) +#define DA_CTL_MS __BIT(5) /* sun4i */ +#define DA_CTL_PCM __BIT(4) /* sun4i */ +#define DA_CTL_MODE_SEL __BITS(5,4) /* sun8i */ +#define DA_CTL_MODE_SEL_PCM 0 +#define DA_CTL_MODE_SEL_LJ 1 +#define DA_CTL_MODE_SEL_RJ 2 #define DA_CTL_TXEN __BIT(2) #define DA_CTL_RXEN __BIT(1) #define DA_CTL_GEN __BIT(0) #define DA_FAT0 0x04 +#define DA_FAT0_LRCK_PERIOD __BITS(17,8) /* sun8i */ #define DA_FAT0_LRCP __BIT(7) #define DA_LRCP_NORMAL 0 #define DA_LRCP_INVERTED 1 @@ -79,20 +87,34 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c, #define DA_INT_RX_DRQ __BIT(3) #define DA_TXFIFO 0x20 #define DA_CLKD 0x24 -#define DA_CLKD_MCLKO_EN __BIT(7) -#define DA_CLKD_BCLKDIV __BITS(6,4) +#define DA_CLKD_MCLKO_EN_SUN8I __BIT(8) +#define DA_CLKD_MCLKO_EN_SUN4I __BIT(7) +#define DA_CLKD_BCLKDIV_SUN8I __BITS(7,4) +#define DA_CLKD_BCLKDIV_SUN4I __BITS(6,4) #define DA_CLKD_BCLKDIV_8 3 #define DA_CLKD_BCLKDIV_16 5 #define DA_CLKD_MCLKDIV __BITS(3,0) #define DA_CLKD_MCLKDIV_1 0 #define DA_TXCNT 0x28 #define DA_RXCNT 0x2c +#define DA_CHCFG 0x30 /* sun8i */ +#define DA_CHCFG_TX_SLOT_HIZ __BIT(9) +#define DA_CHCFG_TXN_STATE __BIT(8) +#define DA_CHCFG_RX_SLOT_NUM __BITS(6,4) +#define DA_CHCFG_TX_SLOT_NUM __BITS(2,0) +#define DA_CHSEL_OFFSET __BITS(13,12) /* sun8i */ #define DA_CHSEL_EN __BITS(11,4) #define DA_CHSEL_SEL __BITS(2,0) +enum sunxi_i2s_type { + SUNXI_I2S_SUN4I, + SUNXI_I2S_SUN8I, +}; + struct sunxi_i2s_config { const char *name; + enum sunxi_i2s_type type; bus_size_t txchsel; bus_size_t txchmap; bus_size_t rxchsel; @@ -101,15 +123,27 @@ struct sunxi_i2s_config { static const struct sunxi_i2s_config sun50i_a64_codec_config = { .name = "Audio Codec (digital part)", + .type = SUNXI_I2S_SUN4I, .txchsel = 0
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:17 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_ccu_div.c Log Message: Add support for A64 I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_div.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
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:17 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_ccu_div.c Log Message: Add support for A64 I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_div.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.13 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.13 Mon Jul 1 21:06:47 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 17 17:33:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.13 2019/07/01 21:06:47 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.13 2019/07/01 21:06:47 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $"); #include #include @@ -60,6 +60,9 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define SDMMC0_CLK_REG 0x088 #define SDMMC1_CLK_REG 0x08c #define SDMMC2_CLK_REG 0x090 +#define I2SPCM0_CLK_REG 0x0b0 +#define I2SPCM1_CLK_REG 0x0b4 +#define I2SPCM2_CLK_REG 0x0b8 #define USBPHY_CFG_REG 0x0cc #define DRAM_CFG_REG 0x0f4 #define MBUS_RST_REG 0x0fc @@ -154,6 +157,7 @@ static const char *mmc_parents[] = { "ho static const char *ths_parents[] = { "hosc", NULL, NULL, NULL }; static const char *de_parents[] = { "pll_periph0_2x", "pll_de" }; static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; +static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -407,6 +411,26 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_GATE(A64_CLK_HDMI_DDC, "hdmi-ddc", "hosc", HDMI_SLOW_CLK_REG, 31), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S0, "i2s0", i2s_parents, + I2SPCM0_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S1, "i2s1", i2s_parents, + I2SPCM1_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S2, "i2s2", i2s_parents, + I2SPCM2_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + + SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */ __BITS(3,0), /* div */ Index: src/sys/arch/arm/sunxi/sunxi_ccu_div.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.5 src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.5 Mon Mar 19 16:19:17 2018 +++ src/sys/arch/arm/sunxi/sunxi_ccu_div.c Sun Nov 17 17:33:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $ */ +/* $NetBSD: sunxi_ccu_div.c,v 1.6 2019/11/17 17:33:17 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.6 2019/11/17 17:33:17 jmcneill Exp $"); #include #include @@ -98,6 +98,38 @@ sunxi_ccu_div_get_rate(struct sunxi_ccu_ return rate / ratio; } +static int +sunxi_ccu_div_select_parent(struct sunxi_ccu_softc *sc, +struct sunxi_ccu_clk *clk, u_int new_rate) +{ + struct sunxi_ccu_div *div = &clk->u.div; + struct sunxi_ccu_clk *clk_parent; + struct clk *best_parent; + u_int index, best_diff; + const char *pname; + + best_parent = NULL; + best_diff = ~0u; + for (index = 0; index < div->nparents; index++) { + pname = div->parents[index]; + if (pname == NULL) + continue; + clk_parent = sunxi_ccu_clock_find(sc, pname); + if (clk_parent == NULL) + continue; + const u_int rate = clk_get_rate(&clk_parent->base); + const u_int diff = abs((int)rate - (int)new_rate); + if (diff < best_diff) { + best_diff = diff; + best_parent = &clk_parent->base; + } + } + if (best_diff == ~0u) + return EINVAL; + + return clk_set_parent(&clk->base, best_parent); +} + int sunxi_ccu_div_set_rate(struct sunxi_ccu_softc *sc, struct sunxi_ccu_clk *clk, u_int new_rate) @@ -119,7 +151,7 @@ sunxi_ccu_div_set_rate(struct sunxi_ccu_ if ((div->flags & SUNXI_CCU_DIV_SET_RATE_PARENT) != 0) return clk_set_rate(clkp_parent, new_rate); else - return ENXIO; + return sunxi_ccu_div_select_parent(sc, clk, new_rate); } val = CCU_READ(sc, div->reg);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:34 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_i2s.c Log Message: Add A64 HDMI audio support. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_i2s.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
Module Name:src Committed By: jmcneill Date: Tue Nov 5 23:31:23 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reserve enough memory at boot to support the drmfb buffer plus a 4K buffer for Xorg. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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
Module Name:src Committed By: jmcneill Date: Tue Nov 5 23:31:23 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reserve enough memory at boot to support the drmfb buffer plus a 4K buffer for Xorg. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/arch/arm/sunxi/sunxi_drm.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_drm.c:1.7 Wed Feb 6 03:07:08 2019 +++ src/sys/arch/arm/sunxi/sunxi_drm.c Tue Nov 5 23:31:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_drm.c,v 1.7 2019/02/06 03:07:08 jmcneill Exp $ */ +/* $NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.7 2019/02/06 03:07:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $"); #include #include @@ -50,6 +50,9 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c, #include +#define SUNXI_DRM_MAX_WIDTH 3840 +#define SUNXI_DRM_MAX_HEIGHT 2160 + static TAILQ_HEAD(, sunxi_drm_endpoint) sunxi_drm_endpoints = TAILQ_HEAD_INITIALIZER(sunxi_drm_endpoints); @@ -68,6 +71,7 @@ static int sunxi_drm_match(device_t, cfd static void sunxi_drm_attach(device_t, device_t, void *); static void sunxi_drm_init(device_t); +static vmem_t *sunxi_drm_alloc_cma_pool(struct drm_device *, size_t); static int sunxi_drm_set_busid(struct drm_device *, struct drm_master *); @@ -176,6 +180,25 @@ sunxi_drm_init(device_t dev) driver->date, sc->sc_ddev->primary->index); } +static vmem_t * +sunxi_drm_alloc_cma_pool(struct drm_device *ddev, size_t cma_size) +{ + struct sunxi_drm_softc * const sc = sunxi_drm_private(ddev); + bus_dma_segment_t segs[1]; + int nsegs; + int error; + + error = bus_dmamem_alloc(sc->sc_dmat, cma_size, PAGE_SIZE, 0, + segs, 1, &nsegs, BUS_DMA_NOWAIT); + if (error) { + aprint_error_dev(sc->sc_dev, "couldn't allocate CMA pool\n"); + return NULL; + } + + return vmem_create("sunxidrm", segs[0].ds_addr, segs[0].ds_len, + PAGE_SIZE, NULL, NULL, NULL, 0, VM_SLEEP, IPL_NONE); +} + static int sunxi_drm_set_busid(struct drm_device *ddev, struct drm_master *master) { @@ -280,6 +303,7 @@ sunxi_drm_fb_probe(struct drm_fb_helper struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb); struct drm_framebuffer *fb = helper->fb; struct sunxi_drmfb_attach_args sfa; + size_t cma_size; int error; const u_int width = sizes->surface_width; @@ -288,6 +312,15 @@ sunxi_drm_fb_probe(struct drm_fb_helper const size_t size = roundup(height * pitch, PAGE_SIZE); + /* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */ + cma_size = size; + cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4); + cma_size = roundup(cma_size, 1024 * 1024); + sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size); + if (sc->sc_ddev->cma_pool != NULL) + aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n", + (u_int)(cma_size / (1024 * 1024))); + sfb->obj = drm_gem_cma_create(ddev, size); if (sfb->obj == NULL) { DRM_ERROR("failed to allocate memory for framebuffer\n"); @@ -340,8 +373,8 @@ sunxi_drm_load(struct drm_device *ddev, drm_mode_config_init(ddev); ddev->mode_config.min_width = 0; ddev->mode_config.min_height = 0; - ddev->mode_config.max_width = 3840; - ddev->mode_config.max_height = 2160; + ddev->mode_config.max_width = SUNXI_DRM_MAX_WIDTH; + ddev->mode_config.max_height = SUNXI_DRM_MAX_HEIGHT; ddev->mode_config.funcs = &sunxi_drm_mode_config_funcs; num_crtc = 0;
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: bad Date: Fri Nov 1 13:30:02 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_gmac.c Log Message: fetch PHY id from FDT. same as sunxi_emac.c. prevents PHY 0 of RTL8211E from wrongly attaching on e.g. Bananpi M1. requested by jmcneill@, patch by martin@. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_gmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: bad Date: Fri Nov 1 13:30:02 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_gmac.c Log Message: fetch PHY id from FDT. same as sunxi_emac.c. prevents PHY 0 of RTL8211E from wrongly attaching on e.g. Bananpi M1. requested by jmcneill@, patch by martin@. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_gmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_gmac.c diff -u src/sys/arch/arm/sunxi/sunxi_gmac.c:1.6 src/sys/arch/arm/sunxi/sunxi_gmac.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_gmac.c:1.6 Sun Jul 21 08:24:32 2019 +++ src/sys/arch/arm/sunxi/sunxi_gmac.c Fri Nov 1 13:30:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_gmac.c,v 1.6 2019/07/21 08:24:32 mrg Exp $ */ +/* $NetBSD: sunxi_gmac.c,v 1.7 2019/11/01 13:30:02 bad Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.6 2019/07/21 08:24:32 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_gmac.c,v 1.7 2019/11/01 13:30:02 bad Exp $"); #include #include @@ -94,6 +94,24 @@ sunxi_gmac_intr(void *arg) } static int +sunxi_gmac_get_phyid(int phandle) +{ + bus_addr_t addr; + int phy_phandle; + + phy_phandle = fdtbus_get_phandle(phandle, "phy"); + if (phy_phandle == -1) + phy_phandle = fdtbus_get_phandle(phandle, "phy-handle"); + if (phy_phandle == -1) + return MII_PHY_ANY; + + if (fdtbus_get_reg(phy_phandle, 0, &addr, NULL) != 0) + return MII_PHY_ANY; + + return (int)addr; +} + +static int sunxi_gmac_match(device_t parent, cfdata_t cf, void *aux) { struct fdt_attach_args * const faa = aux; @@ -192,7 +210,8 @@ sunxi_gmac_attach(device_t parent, devic if (sunxi_gmac_reset(phandle) != 0) aprint_error_dev(self, "PHY reset failed\n"); - dwc_gmac_attach(sc, MII_PHY_ANY, GMAC_MII_CLK_150_250M_DIV102); + dwc_gmac_attach(sc, sunxi_gmac_get_phyid(phandle), + GMAC_MII_CLK_150_250M_DIV102); } CFATTACH_DECL_NEW(sunxi_gmac, sizeof(struct dwc_gmac_softc),
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: msaitoh Date: Mon Oct 21 08:00:59 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_can.c Log Message: if_ipackets is incremented in can_input(), so don't increment it in sunxi_can_rx_intr to prevent double count. OK'd by bouyer@. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 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.