CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Feb 9 08:50:52 UTC 2024 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: Limit DMA to below 4GB - the supported controllers are limited this way. Thanks to jmcneill for a version of this patch. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwcmmc_fdt.c diff -u src/sys/dev/fdt/dwcmmc_fdt.c:1.21 src/sys/dev/fdt/dwcmmc_fdt.c:1.22 --- src/sys/dev/fdt/dwcmmc_fdt.c:1.21 Fri Feb 9 06:28:50 2024 +++ src/sys/dev/fdt/dwcmmc_fdt.c Fri Feb 9 08:50:52 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dwcmmc_fdt.c,v 1.21 2024/02/09 06:28:50 skrll Exp $ */ +/* $NetBSD: dwcmmc_fdt.c,v 1.22 2024/02/09 08:50:52 skrll Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.21 2024/02/09 06:28:50 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.22 2024/02/09 08:50:52 skrll Exp $"); #include #include @@ -149,7 +149,16 @@ dwcmmc_fdt_attach(device_t parent, devic sc->sc_dev = self; sc->sc_bst = faa->faa_bst; - sc->sc_dmat = faa->faa_dmat; + if (sizeof(bus_addr_t) > 4) { + error = bus_dmatag_subregion(faa->faa_dmat, 0, __MASK(32), + >sc_dmat, BUS_DMA_WAITOK); + if (error != 0) { + aprint_error(": couldn't create DMA tag: %d\n", error); + return; + } + } else { + sc->sc_dmat = faa->faa_dmat; + } error = bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh); if (error) { aprint_error(": couldn't map %#" PRIx64 ": %d\n",
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Feb 9 08:50:52 UTC 2024 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: Limit DMA to below 4GB - the supported controllers are limited this way. Thanks to jmcneill for a version of this patch. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Feb 9 06:28:50 UTC 2024 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: spaces to tabs To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwcmmc_fdt.c diff -u src/sys/dev/fdt/dwcmmc_fdt.c:1.20 src/sys/dev/fdt/dwcmmc_fdt.c:1.21 --- src/sys/dev/fdt/dwcmmc_fdt.c:1.20 Fri Dec 29 08:02:47 2023 +++ src/sys/dev/fdt/dwcmmc_fdt.c Fri Feb 9 06:28:50 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dwcmmc_fdt.c,v 1.20 2023/12/29 08:02:47 skrll Exp $ */ +/* $NetBSD: dwcmmc_fdt.c,v 1.21 2024/02/09 06:28:50 skrll Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.20 2023/12/29 08:02:47 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.21 2024/02/09 06:28:50 skrll Exp $"); #include #include @@ -236,7 +236,7 @@ static int dwcmmc_fdt_bus_clock(struct dwc_mmc_softc *sc, int rate) { struct dwcmmc_fdt_softc *esc = device_private(sc->sc_dev); -const u_int ciu_div = sc->sc_ciu_div > 0 ? sc->sc_ciu_div : 1; + const u_int ciu_div = sc->sc_ciu_div > 0 ? sc->sc_ciu_div : 1; int error; error = clk_set_rate(esc->sc_clk_ciu, 1000 * rate * ciu_div);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Feb 9 06:28:50 UTC 2024 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: spaces to tabs To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: kre Date: Sun Jan 21 15:10:08 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_boot.c Log Message: Include for struct mbr_sector To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_boot.c diff -u src/sys/dev/fdt/fdt_boot.c:1.5 src/sys/dev/fdt/fdt_boot.c:1.6 --- src/sys/dev/fdt/fdt_boot.c:1.5 Fri Jan 19 09:09:04 2024 +++ src/sys/dev/fdt/fdt_boot.c Sun Jan 21 15:10:07 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_boot.c,v 1.5 2024/01/19 09:09:04 skrll Exp $ */ +/* $NetBSD: fdt_boot.c,v 1.6 2024/01/21 15:10:07 kre Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -56,13 +56,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.5 2024/01/19 09:09:04 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.6 2024/01/21 15:10:07 kre Exp $"); #include "opt_efi.h" #include "opt_md.h" #include +#include #include #include #include
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: kre Date: Sun Jan 21 15:10:08 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_boot.c Log Message: Include for struct mbr_sector To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Sun Jan 14 07:53:38 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Handle multiple memory nodes by type, but still allow an untyped (non-standard) node named /memory. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Sun Jan 14 07:53:38 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Handle multiple memory nodes by type, but still allow an untyped (non-standard) node named /memory. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.9 src/sys/dev/fdt/fdt_memory.c:1.10 --- src/sys/dev/fdt/fdt_memory.c:1.9 Fri Jan 12 18:06:18 2024 +++ src/sys/dev/fdt/fdt_memory.c Sun Jan 14 07:53:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $"); #include #include @@ -77,26 +77,43 @@ fdt_memory_range_free(struct fdt_memory_ void fdt_memory_get(uint64_t *pstart, uint64_t *pend) { - const int memory = OF_finddevice("/memory"); + const void *fdt_data = fdtbus_get_data(); uint64_t cur_addr, cur_size; - int index, nadd; + int index, nadd = 0, off, memory; - for (index = 0, nadd = 0; - fdtbus_get_reg64(memory, index, _addr, _size) == 0; - index++) { - if (cur_size == 0) - continue; - fdt_memory_add_range(cur_addr, cur_size); + off = fdt_node_offset_by_prop_value(fdt_data, -1, + "device_type", "memory", sizeof("memory")); - if (nadd++ == 0) { - *pstart = cur_addr; - *pend = cur_addr + cur_size; - continue; + /* + * Device Tree Specification 3.2 says that memory + * nodes are named "memory" and have device_type + * "memory", but if the device_type is missing, try + * to find the (then single) node by name. + */ + if (off == -FDT_ERR_NOTFOUND) + off = fdt_path_offset(fdt_data, "/memory"); + + while (off != -FDT_ERR_NOTFOUND) { + memory = fdtbus_offset2phandle(off); + for (index = 0; + fdtbus_get_reg64(memory, index, _addr, _size) == 0; + index++) { + if (cur_size == 0) +continue; + fdt_memory_add_range(cur_addr, cur_size); + + if (nadd++ == 0) { +*pstart = cur_addr; +*pend = cur_addr + cur_size; +continue; + } + if (cur_addr < *pstart) +*pstart = cur_addr; + if (cur_addr + cur_size > *pend) +*pend = cur_addr + cur_size; } - if (cur_addr < *pstart) - *pstart = cur_addr; - if (cur_addr + cur_size > *pend) - *pend = cur_addr + cur_size; + off = fdt_node_offset_by_prop_value(fdt_data, off, + "device_type", "memory", sizeof("memory")); } if (nadd == 0) panic("Cannot determine memory size");
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Jan 12 18:06:18 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Cache the result from fdtbus_get_data() in fdt_memory_remove_reserved NFCI. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.8 src/sys/dev/fdt/fdt_memory.c:1.9 --- src/sys/dev/fdt/fdt_memory.c:1.8 Fri Nov 4 10:51:16 2022 +++ src/sys/dev/fdt/fdt_memory.c Fri Jan 12 18:06:18 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.8 2022/11/04 10:51:16 jmcneill Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.8 2022/11/04 10:51:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $"); #include #include @@ -110,15 +110,16 @@ fdt_memory_remove_reserved(uint64_t min_ { uint64_t lstart = 0, lend = 0; int index, error, phandle, child; + const void *fdt_data = fdtbus_get_data(); + const int num = fdt_num_mem_rsv(fdt_data); - const int num = fdt_num_mem_rsv(fdtbus_get_data()); for (index = 0; index <= num; index++) { uint64_t addr, size; - error = fdt_get_mem_rsv(fdtbus_get_data(), index, - , ); + error = fdt_get_mem_rsv(fdt_data, index, , ); if (error != 0) continue; + if (lstart <= addr && addr <= lend) { size -= (lend - addr); addr = lend;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Jan 12 18:06:18 UTC 2024 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Cache the result from fdtbus_get_data() in fdt_memory_remove_reserved NFCI. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: thorpej Date: Tue Jan 2 07:34:27 UTC 2024 Modified Files: src/sys/dev/fdt: gfrtc_fdt.c Log Message: Adapt to changes in the generic gfrtc code. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/gfrtc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: thorpej Date: Tue Jan 2 07:34:27 UTC 2024 Modified Files: src/sys/dev/fdt: gfrtc_fdt.c Log Message: Adapt to changes in the generic gfrtc code. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/gfrtc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/gfrtc_fdt.c diff -u src/sys/dev/fdt/gfrtc_fdt.c:1.2 src/sys/dev/fdt/gfrtc_fdt.c:1.3 --- src/sys/dev/fdt/gfrtc_fdt.c:1.2 Fri Dec 29 23:31:44 2023 +++ src/sys/dev/fdt/gfrtc_fdt.c Tue Jan 2 07:34:27 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: gfrtc_fdt.c,v 1.2 2023/12/29 23:31:44 thorpej Exp $ */ +/* $NetBSD: gfrtc_fdt.c,v 1.3 2024/01/02 07:34:27 thorpej Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gfrtc_fdt.c,v 1.2 2023/12/29 23:31:44 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gfrtc_fdt.c,v 1.3 2024/01/02 07:34:27 thorpej Exp $"); #include @@ -79,10 +79,7 @@ gfrtc_fdt_attach(device_t parent, device return; } - aprint_naive("\n"); - aprint_normal(": Google Goldfish RTC\n"); - - gfrtc_attach(sc); + gfrtc_attach(sc, true); } CFATTACH_DECL_NEW(gfrtc_fdt, sizeof(struct gfrtc_softc),
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Dec 29 08:02:47 UTC 2023 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: dwcmmc_fdt_bus_clock: fix an aprint_debug_dev frequency units botch. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwcmmc_fdt.c diff -u src/sys/dev/fdt/dwcmmc_fdt.c:1.19 src/sys/dev/fdt/dwcmmc_fdt.c:1.20 --- src/sys/dev/fdt/dwcmmc_fdt.c:1.19 Sun Feb 6 15:47:06 2022 +++ src/sys/dev/fdt/dwcmmc_fdt.c Fri Dec 29 08:02:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dwcmmc_fdt.c,v 1.19 2022/02/06 15:47:06 jmcneill Exp $ */ +/* $NetBSD: dwcmmc_fdt.c,v 1.20 2023/12/29 08:02:47 skrll Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.19 2022/02/06 15:47:06 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.20 2023/12/29 08:02:47 skrll Exp $"); #include #include @@ -249,7 +249,7 @@ dwcmmc_fdt_bus_clock(struct dwc_mmc_soft sc->sc_clock_freq = clk_get_rate(esc->sc_clk_ciu); aprint_debug_dev(sc->sc_dev, "set clock rate to %u kHz (target %u kHz)\n", - sc->sc_clock_freq, rate); + sc->sc_clock_freq / 1000, rate); return 0; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Dec 29 08:02:47 UTC 2023 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: dwcmmc_fdt_bus_clock: fix an aprint_debug_dev frequency units botch. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: rin Date: Mon Jul 31 04:59:47 UTC 2023 Modified Files: src/sys/dev/fdt: dwc2_fdt.c Log Message: dw2c_fdt: Terminate statements by ; instead of , (from Mori Hiroki) No binary changes. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/dwc2_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: rin Date: Mon Jul 31 04:59:47 UTC 2023 Modified Files: src/sys/dev/fdt: dwc2_fdt.c Log Message: dw2c_fdt: Terminate statements by ; instead of , (from Mori Hiroki) No binary changes. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/dwc2_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwc2_fdt.c diff -u src/sys/dev/fdt/dwc2_fdt.c:1.12 src/sys/dev/fdt/dwc2_fdt.c:1.13 --- src/sys/dev/fdt/dwc2_fdt.c:1.12 Sat Aug 7 16:19:10 2021 +++ src/sys/dev/fdt/dwc2_fdt.c Mon Jul 31 04:59:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_fdt.c,v 1.12 2021/08/07 16:19:10 thorpej Exp $ */ +/* $NetBSD: dwc2_fdt.c,v 1.13 2023/07/31 04:59:47 rin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc2_fdt.c,v 1.12 2021/08/07 16:19:10 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_fdt.c,v 1.13 2023/07/31 04:59:47 rin Exp $"); #include #include @@ -215,13 +215,13 @@ dwc2_fdt_amlogic_params(struct dwc2_fdt_ params->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE; params->speed = DWC2_SPEED_PARAM_HIGH; params->dma_enable = 1; - params->enable_dynamic_fifo = 1, + params->enable_dynamic_fifo = 1; params->host_rx_fifo_size = 512; params->host_nperio_tx_fifo_size = 500; params->host_perio_tx_fifo_size = 500; params->host_channels = 16; params->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; - params->reload_ctl = 1, + params->reload_ctl = 1; params->ahbcfg = GAHBCFG_HBSTLEN_INCR8 << GAHBCFG_HBSTLEN_SHIFT; #ifdef DWC2_POWER_DOWN_PARAM_NONE params->power_down = DWC2_POWER_DOWN_PARAM_NONE;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Tue Jul 11 05:57:44 UTC 2023 Modified Files: src/sys/dev/fdt: fdt_boot.c Log Message: G/C some #if 0 / #endif code To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_boot.c diff -u src/sys/dev/fdt/fdt_boot.c:1.3 src/sys/dev/fdt/fdt_boot.c:1.4 --- src/sys/dev/fdt/fdt_boot.c:1.3 Mon Jul 10 07:01:48 2023 +++ src/sys/dev/fdt/fdt_boot.c Tue Jul 11 05:57:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_boot.c,v 1.3 2023/07/10 07:01:48 rin Exp $ */ +/* $NetBSD: fdt_boot.c,v 1.4 2023/07/11 05:57:44 skrll Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.3 2023/07/10 07:01:48 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v 1.4 2023/07/11 05:57:44 skrll Exp $"); #include "opt_efi.h" #include "opt_md.h" @@ -82,9 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_boot.c,v #include #include -#if 0 -#include -#endif #include #ifndef FDT_MAX_BOOT_STRING
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Tue Jul 11 05:57:44 UTC 2023 Modified Files: src/sys/dev/fdt: fdt_boot.c Log Message: G/C some #if 0 / #endif code To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon May 8 10:18:03 UTC 2023 Modified Files: src/sys/dev/fdt: files.fdt Log Message: Google goldfish config goop To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon May 8 10:18:03 UTC 2023 Modified Files: src/sys/dev/fdt: files.fdt Log Message: Google goldfish config goop To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.69 src/sys/dev/fdt/files.fdt:1.70 --- src/sys/dev/fdt/files.fdt:1.69 Sat Apr 22 09:53:45 2023 +++ src/sys/dev/fdt/files.fdt Mon May 8 10:18:03 2023 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.69 2023/04/22 09:53:45 skrll Exp $ +# $NetBSD: files.fdt,v 1.70 2023/05/08 10:18:03 skrll Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -215,3 +215,8 @@ file dev/fdt/genet_fdt.c genet_fdt # VMware Tools driver attach vmt at fdt with vmt_fdt file dev/fdt/vmt_fdt.c vmt_fdt + +# Google Goldfish RTC +device gfrtc +attach gfrtc at fdt with gfrtc_fdt +file dev/fdt/gfrtc_fdt.c gfrtc_fdt
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon May 8 07:51:44 UTC 2023 Added Files: src/sys/dev/fdt: gfrtc_fdt.c Log Message: Add a Google Goldfish RTC driver To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/gfrtc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon May 8 07:51:44 UTC 2023 Added Files: src/sys/dev/fdt: gfrtc_fdt.c Log Message: Add a Google Goldfish RTC driver To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/gfrtc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/dev/fdt/gfrtc_fdt.c diff -u /dev/null src/sys/dev/fdt/gfrtc_fdt.c:1.1 --- /dev/null Mon May 8 07:51:44 2023 +++ src/sys/dev/fdt/gfrtc_fdt.c Mon May 8 07:51:44 2023 @@ -0,0 +1,141 @@ +/* $NetBSD: gfrtc_fdt.c,v 1.1 2023/05/08 07:51:44 skrll Exp $ */ + +/*- + * Copyright (c) 2023 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: gfrtc_fdt.c,v 1.1 2023/05/08 07:51:44 skrll Exp $"); + +#include + +#include +#include + +#include + +/* + * https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT + */ + +static const struct device_compatible_entry compat_data[] = { + { .compat = "google,goldfish-rtc" }, + DEVICE_COMPAT_EOL +}; + +struct gfrtc_fdt_softc { + device_t sc_dev; + bus_space_tag_t sc_bst; + bus_space_handle_t sc_bsh; + + struct todr_chip_handle sc_todr; +}; + +#define GOLDFISH_RTC_READ(sc, reg) \ + bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) +#define GOLDFISH_RTC_WRITE(sc, reg, val) \ + bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val)) + + +#define GOLDFISH_RTC_TIME_LOW 0x00 +#define GOLDFISH_RTC_TIME_HIGH 0x04 + + +static int +gfrtc_gettime(struct todr_chip_handle *ch, struct timeval *tv) +{ + struct gfrtc_fdt_softc *sc = ch->cookie; + const uint64_t lo = GOLDFISH_RTC_READ(sc, GOLDFISH_RTC_TIME_LOW); + const uint64_t hi = GOLDFISH_RTC_READ(sc, GOLDFISH_RTC_TIME_HIGH); + + uint64_t nsec = (hi << 32) | lo; + + tv->tv_sec = nsec / 10; + tv->tv_usec = (nsec - tv->tv_sec) / 1000; // Always 0? + + return 0; +} + +static int +gfrtc_settime(struct todr_chip_handle *ch, struct timeval *tv) +{ + struct gfrtc_fdt_softc *sc = ch->cookie; + + uint64_t nsec = (tv->tv_sec * 100 + tv->tv_usec) * 1000; + uint32_t hi = nsec >> 32; + uint32_t lo = nsec; + + GOLDFISH_RTC_WRITE(sc, GOLDFISH_RTC_TIME_HIGH, hi); + GOLDFISH_RTC_WRITE(sc, GOLDFISH_RTC_TIME_HIGH, lo); + + return 0; +} + + +static int +gfrtc_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_compatible_match(faa->faa_phandle, compat_data); +} + +static void +gfrtc_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct gfrtc_fdt_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + bus_addr_t addr; + bus_size_t size; + + if (fdtbus_get_reg(phandle, 0, , ) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } + + sc->sc_dev = self; + sc->sc_bst = faa->faa_bst; + if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) { + aprint_error(": couldn't map registers\n"); + return; + } + + aprint_naive("\n"); + aprint_normal(": Google Goldfish RTC\n"); + + sc->sc_todr.cookie = sc; + sc->sc_todr.todr_gettime = gfrtc_gettime; + sc->sc_todr.todr_settime = gfrtc_settime; + sc->sc_todr.todr_setwen = NULL; + + todr_attach(>sc_todr); +} + +CFATTACH_DECL_NEW(gfrtc_fdt, sizeof(struct gfrtc_fdt_softc), + gfrtc_fdt_match, gfrtc_fdt_attach, NULL, NULL);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sat Nov 5 10:04:35 UTC 2022 Modified Files: src/sys/dev/fdt: cpus.c Log Message: Fix inverted result when status is "okay" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/cpus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/cpus.c diff -u src/sys/dev/fdt/cpus.c:1.5 src/sys/dev/fdt/cpus.c:1.6 --- src/sys/dev/fdt/cpus.c:1.5 Wed Jan 2 14:54:54 2019 +++ src/sys/dev/fdt/cpus.c Sat Nov 5 10:04:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cpus.c,v 1.5 2019/01/02 14:54:54 jmcneill Exp $ */ +/* $NetBSD: cpus.c,v 1.6 2022/11/05 10:04:35 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.5 2019/01/02 14:54:54 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.6 2022/11/05 10:04:35 skrll Exp $"); #include #include @@ -85,7 +85,7 @@ cpus_cpu_enabled(int child) s = fdtbus_get_string(child, "status"); if (s) { if (strcmp(s, "okay") == 0) - return false; + return true; if (strcmp(s, "disabled") == 0) return of_hasprop(child, "enable-method"); return false;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sat Nov 5 10:04:35 UTC 2022 Modified Files: src/sys/dev/fdt: cpus.c Log Message: Fix inverted result when status is "okay" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/cpus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 2 11:04:02 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Re-enable ADMA2 support for arasan,sdhci-8.9a To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 2 11:04:02 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Re-enable ADMA2 support for arasan,sdhci-8.9a To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/arasan_sdhc_fdt.c diff -u src/sys/dev/fdt/arasan_sdhc_fdt.c:1.12 src/sys/dev/fdt/arasan_sdhc_fdt.c:1.13 --- src/sys/dev/fdt/arasan_sdhc_fdt.c:1.12 Tue Nov 1 00:57:39 2022 +++ src/sys/dev/fdt/arasan_sdhc_fdt.c Wed Nov 2 11:04:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arasan_sdhc_fdt.c,v 1.12 2022/11/01 00:57:39 jmcneill Exp $ */ +/* $NetBSD: arasan_sdhc_fdt.c,v 1.13 2022/11/02 11:04:02 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.12 2022/11/01 00:57:39 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.13 2022/11/02 11:04:02 jmcneill Exp $"); #include #include @@ -53,8 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_ #define RK3399_CORECFG_CLOCKMULTIPLIER __BITS(7,0) enum arasan_sdhc_type { - AS_TYPE_RK3399 = 1, - AS_TYPE_SDHCI_8_9A, + AS_TYPE_GENERIC, + AS_TYPE_RK3399, }; struct arasan_sdhc_softc { @@ -78,7 +78,7 @@ static const struct device_compatible_en .value = AS_TYPE_RK3399 }, { .compat = "arasan,sdhci-8.9a", - .value = AS_TYPE_SDHCI_8_9A }, + .value = AS_TYPE_GENERIC }, DEVICE_COMPAT_EOL }; @@ -296,13 +296,6 @@ arasan_sdhc_attach(device_t parent, devi SDHC_FLAG_32BIT_ACCESS | SDHC_FLAG_USE_DMA | SDHC_FLAG_STOP_WITH_TC; - if (sc->sc_type == AS_TYPE_SDHCI_8_9A) { - /* - * Workaround for sporadic transfer errors on the Arasan SDHCI - * found in the Xilinx Zynq-7000 SoC. - */ - sc->sc_base.sc_flags |= SDHC_FLAG_BROKEN_ADMA; - } if (bus_width == 8) { sc->sc_base.sc_flags |= SDHC_FLAG_8BIT_MODE; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Nov 1 00:57:39 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Disable ADMA2 on the Arasan SDHCI 8.9A found in the Xilinx Zinq-7000 due to sporadic transfer errors until the root cause for the errors is found. In the meantime, SDMA works fine on this platform. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/arasan_sdhc_fdt.c diff -u src/sys/dev/fdt/arasan_sdhc_fdt.c:1.11 src/sys/dev/fdt/arasan_sdhc_fdt.c:1.12 --- src/sys/dev/fdt/arasan_sdhc_fdt.c:1.11 Wed Oct 26 20:54:52 2022 +++ src/sys/dev/fdt/arasan_sdhc_fdt.c Tue Nov 1 00:57:39 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arasan_sdhc_fdt.c,v 1.11 2022/10/26 20:54:52 jmcneill Exp $ */ +/* $NetBSD: arasan_sdhc_fdt.c,v 1.12 2022/11/01 00:57:39 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.11 2022/10/26 20:54:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.12 2022/11/01 00:57:39 jmcneill Exp $"); #include #include @@ -53,8 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_ #define RK3399_CORECFG_CLOCKMULTIPLIER __BITS(7,0) enum arasan_sdhc_type { - AS_TYPE_GENERIC = 0, AS_TYPE_RK3399 = 1, + AS_TYPE_SDHCI_8_9A, }; struct arasan_sdhc_softc { @@ -78,7 +78,7 @@ static const struct device_compatible_en .value = AS_TYPE_RK3399 }, { .compat = "arasan,sdhci-8.9a", - .value = AS_TYPE_GENERIC }, + .value = AS_TYPE_SDHCI_8_9A }, DEVICE_COMPAT_EOL }; @@ -296,8 +296,16 @@ arasan_sdhc_attach(device_t parent, devi SDHC_FLAG_32BIT_ACCESS | SDHC_FLAG_USE_DMA | SDHC_FLAG_STOP_WITH_TC; - if (bus_width == 8) + if (sc->sc_type == AS_TYPE_SDHCI_8_9A) { + /* + * Workaround for sporadic transfer errors on the Arasan SDHCI + * found in the Xilinx Zynq-7000 SoC. + */ + sc->sc_base.sc_flags |= SDHC_FLAG_BROKEN_ADMA; + } + if (bus_width == 8) { sc->sc_base.sc_flags |= SDHC_FLAG_8BIT_MODE; + } sc->sc_base.sc_clkbase = clk_get_rate(sc->sc_clk_xin) / 1000; sc->sc_base.sc_vendor_bus_clock = arasan_sdhc_bus_clock_pre; sc->sc_base.sc_vendor_bus_clock_post = arasan_sdhc_bus_clock_post;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Nov 1 00:57:39 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Disable ADMA2 on the Arasan SDHCI 8.9A found in the Xilinx Zinq-7000 due to sporadic transfer errors until the root cause for the errors is found. In the meantime, SDMA works fine on this platform. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 26 20:54:53 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: No need to constrain DMA tag to 32-bits on 32-bit platforms. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 26 20:54:53 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: No need to constrain DMA tag to 32-bits on 32-bit platforms. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/arasan_sdhc_fdt.c diff -u src/sys/dev/fdt/arasan_sdhc_fdt.c:1.10 src/sys/dev/fdt/arasan_sdhc_fdt.c:1.11 --- src/sys/dev/fdt/arasan_sdhc_fdt.c:1.10 Wed Oct 26 10:55:23 2022 +++ src/sys/dev/fdt/arasan_sdhc_fdt.c Wed Oct 26 20:54:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arasan_sdhc_fdt.c,v 1.10 2022/10/26 10:55:23 jmcneill Exp $ */ +/* $NetBSD: arasan_sdhc_fdt.c,v 1.11 2022/10/26 20:54:52 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.10 2022/10/26 10:55:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.11 2022/10/26 20:54:52 jmcneill Exp $"); #include #include @@ -234,7 +234,6 @@ arasan_sdhc_attach(device_t parent, devi bus_addr_t addr; bus_size_t size; u_int bus_width; - int error; void *ih; fdtbus_clock_assign(phandle); @@ -274,9 +273,10 @@ arasan_sdhc_attach(device_t parent, devi sc->sc_bsz = size; sc->sc_type = of_compatible_lookup(phandle, compat_data)->value; +#ifdef _LP64 const uint32_t caps = bus_space_read_4(sc->sc_bst, sc->sc_bsh, SDHC_CAPABILITIES); if ((caps & (SDHC_ADMA2_SUPP|SDHC_64BIT_SYS_BUS)) == SDHC_ADMA2_SUPP) { - error = bus_dmatag_subregion(faa->faa_dmat, 0, __MASK(32), + int error = bus_dmatag_subregion(faa->faa_dmat, 0, __MASK(32), >sc_base.sc_dmat, BUS_DMA_WAITOK); if (error != 0) { aprint_error(": couldn't create DMA tag: %d\n", error); @@ -285,6 +285,9 @@ arasan_sdhc_attach(device_t parent, devi } else { sc->sc_base.sc_dmat = faa->faa_dmat; } +#else + sc->sc_base.sc_dmat = faa->faa_dmat; +#endif sc->sc_base.sc_dev = self; sc->sc_base.sc_host = sc->sc_host;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Thu Oct 20 11:38:21 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Do what the comment says and reserve ranges that do and do not have the "no-map" property. Required for qemu/riscv To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Thu Oct 20 11:38:21 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Do what the comment says and reserve ranges that do and do not have the "no-map" property. Required for qemu/riscv To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.6 src/sys/dev/fdt/fdt_memory.c:1.7 --- src/sys/dev/fdt/fdt_memory.c:1.6 Sat Aug 6 20:16:42 2022 +++ src/sys/dev/fdt/fdt_memory.c Thu Oct 20 11:38:21 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.7 2022/10/20 11:38:21 skrll Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.7 2022/10/20 11:38:21 skrll Exp $"); #include #include @@ -154,9 +154,6 @@ fdt_memory_remove_reserved(uint64_t min_ bus_addr_t addr; bus_size_t size; - if (!of_hasprop(child, "no-map")) -continue; - if (fdtbus_get_reg(child, 0, , ) != 0) continue; if (size == 0)
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: ryo Date: Sat Aug 6 20:16:43 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: In my previous change, it was necessary to consider the case where the first block size is zero. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.5 src/sys/dev/fdt/fdt_memory.c:1.6 --- src/sys/dev/fdt/fdt_memory.c:1.5 Thu Aug 4 11:58:55 2022 +++ src/sys/dev/fdt/fdt_memory.c Sat Aug 6 20:16:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $"); #include #include @@ -83,16 +83,16 @@ fdt_memory_get(uint64_t *pstart, uint64_ { const int memory = OF_finddevice("/memory"); uint64_t cur_addr, cur_size; - int index; + int index, nadd; - for (index = 0; + for (index = 0, nadd = 0; fdtbus_get_reg64(memory, index, _addr, _size) == 0; index++) { if (cur_size == 0) continue; fdt_memory_add_range(cur_addr, cur_size); - if (index == 0) { + if (nadd++ == 0) { *pstart = cur_addr; *pend = cur_addr + cur_size; continue; @@ -102,7 +102,7 @@ fdt_memory_get(uint64_t *pstart, uint64_ if (cur_addr + cur_size > *pend) *pend = cur_addr + cur_size; } - if (index == 0) + if (nadd == 0) panic("Cannot determine memory size"); }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: ryo Date: Sat Aug 6 20:16:43 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: In my previous change, it was necessary to consider the case where the first block size is zero. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: ryo Date: Thu Aug 4 11:58:55 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Don't pass a block of size 0 to fdt_memory_add_range(). There are some environments where size 0 blocks are passed from the loader. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.4 src/sys/dev/fdt/fdt_memory.c:1.5 --- src/sys/dev/fdt/fdt_memory.c:1.4 Fri Jan 7 07:25:37 2022 +++ src/sys/dev/fdt/fdt_memory.c Thu Aug 4 11:58:55 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $"); #include #include @@ -88,6 +88,8 @@ fdt_memory_get(uint64_t *pstart, uint64_ for (index = 0; fdtbus_get_reg64(memory, index, _addr, _size) == 0; index++) { + if (cur_size == 0) + continue; fdt_memory_add_range(cur_addr, cur_size); if (index == 0) {
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: ryo Date: Thu Aug 4 11:58:55 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Don't pass a block of size 0 to fdt_memory_add_range(). There are some environments where size 0 blocks are passed from the loader. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Jun 12 08:04:07 UTC 2022 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Attach when dr_mode is "otg" and the controller has the "usb-role-switch" and "role-switch-default-mode" as seen in the Apple M1 dts. This assumes the controller is properly setup for host mode already. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwc3_fdt.c diff -u src/sys/dev/fdt/dwc3_fdt.c:1.19 src/sys/dev/fdt/dwc3_fdt.c:1.20 --- src/sys/dev/fdt/dwc3_fdt.c:1.19 Sun Nov 7 17:14:20 2021 +++ src/sys/dev/fdt/dwc3_fdt.c Sun Jun 12 08:04:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $ */ +/* $NetBSD: dwc3_fdt.c,v 1.20 2022/06/12 08:04:07 skrll Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.20 2022/06/12 08:04:07 skrll Exp $"); #include #include @@ -256,9 +256,30 @@ dwc3_fdt_attach(device_t parent, device_ return; } - /* Only host mode is supported */ + /* + * Only host mode is supported, but this includes otg devices + * that have 'usb-role-switch' and 'role-switch-default-mode' of + * 'host' + */ const char *dr_mode = fdtbus_get_string(dwc3_phandle, "dr_mode"); - if (dr_mode == NULL || strcmp(dr_mode, "host") != 0) { + if (dr_mode == NULL || strcmp(dr_mode, "otg") == 0) { + bool ok = false; + if (of_hasprop(dwc3_phandle, "usb-role-switch")) { + const char *rsdm = fdtbus_get_string(dwc3_phandle, + "role-switch-default-mode"); + if (rsdm != NULL && strcmp(rsdm, "host") == 0) +ok = true; + + if (!ok) { +aprint_error(": host is not default mode\n"); +return; + } + } + if (!ok) { + aprint_error(": cannot switch 'otg' mode to host\n"); + return; + } + } else if (strcmp(dr_mode, "host") != 0) { aprint_error(": '%s' not supported\n", dr_mode); return; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Jun 12 08:04:07 UTC 2022 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Attach when dr_mode is "otg" and the controller has the "usb-role-switch" and "role-switch-default-mode" as seen in the Apple M1 dts. This assumes the controller is properly setup for host mode already. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Fri Mar 25 21:23:51 UTC 2022 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: fdt_userconf.c Log Message: fdt: add support for USERCONF option To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_userconf.c cvs rdiff -u -r1.63 -r1.64 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.63 src/sys/dev/fdt/files.fdt:1.64 --- src/sys/dev/fdt/files.fdt:1.63 Fri Mar 4 08:19:06 2022 +++ src/sys/dev/fdt/files.fdt Fri Mar 25 21:23:51 2022 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.63 2022/03/04 08:19:06 skrll Exp $ +# $NetBSD: files.fdt,v 1.64 2022/03/25 21:23:51 jmcneill Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -13,6 +13,8 @@ device simplebus: fdt attach simplebus at fdt file dev/fdt/fdtbus.c fdt +file dev/fdt/fdt_userconf.c fdt & userconf + device fregulator attach fregulator at fdt file dev/fdt/fixedregulator.c fregulator Added files: Index: src/sys/dev/fdt/fdt_userconf.c diff -u /dev/null src/sys/dev/fdt/fdt_userconf.c:1.1 --- /dev/null Fri Mar 25 21:23:51 2022 +++ src/sys/dev/fdt/fdt_userconf.c Fri Mar 25 21:23:51 2022 @@ -0,0 +1,67 @@ +/* $NetBSD: fdt_userconf.c,v 1.1 2022/03/25 21:23:51 jmcneill Exp $ */ + +/*- + * Copyright (c) 2022 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: fdt_userconf.c,v 1.1 2022/03/25 21:23:51 jmcneill Exp $"); + +#include +#include +#include + +#include +#include + +#define FDT_CHOSEN_PATH "/chosen" +#define FDT_CHOSEN_USERCONF_PROP "netbsd,userconf" + +void +userconf_bootinfo(void) +{ + const void *fdt = fdtbus_get_data(); + const char *cmd; + int chosen, index; + + if (fdt == NULL) { + return; + } + + chosen = fdt_path_offset(fdt, FDT_CHOSEN_PATH); + if (chosen < 0) { + return; + } + + index = 0; + do { + cmd = fdt_stringlist_get(fdt, chosen, FDT_CHOSEN_USERCONF_PROP, + index++, NULL); + if (cmd != NULL) { + aprint_debug("Processing userconf command: %s\n", cmd); + userconf_parse(__UNCONST(cmd)); + } + } while (cmd != NULL); +}
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Fri Mar 25 21:23:51 UTC 2022 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: fdt_userconf.c Log Message: fdt: add support for USERCONF option To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_userconf.c cvs rdiff -u -r1.63 -r1.64 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Mar 4 08:19:07 UTC 2022 Modified Files: src/sys/dev/fdt: fdtbus.c fdtvar.h files.fdt Added Files: src/sys/dev/fdt: fdt_mbox.c fdt_powerdomain.c Log Message: Add mailbox and power-domain support. power-domain support is very rudimentary. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_mbox.c \ src/sys/dev/fdt/fdt_powerdomain.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/fdt/fdtbus.c cvs rdiff -u -r1.76 -r1.77 src/sys/dev/fdt/fdtvar.h cvs rdiff -u -r1.62 -r1.63 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Mar 4 08:19:07 UTC 2022 Modified Files: src/sys/dev/fdt: fdtbus.c fdtvar.h files.fdt Added Files: src/sys/dev/fdt: fdt_mbox.c fdt_powerdomain.c Log Message: Add mailbox and power-domain support. power-domain support is very rudimentary. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_mbox.c \ src/sys/dev/fdt/fdt_powerdomain.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/fdt/fdtbus.c cvs rdiff -u -r1.76 -r1.77 src/sys/dev/fdt/fdtvar.h cvs rdiff -u -r1.62 -r1.63 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdtbus.c diff -u src/sys/dev/fdt/fdtbus.c:1.45 src/sys/dev/fdt/fdtbus.c:1.46 --- src/sys/dev/fdt/fdtbus.c:1.45 Sat Jan 22 11:49:17 2022 +++ src/sys/dev/fdt/fdtbus.c Fri Mar 4 08:19:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $ */ +/* $NetBSD: fdtbus.c,v 1.46 2022/03/04 08:19:06 skrll Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.46 2022/03/04 08:19:06 skrll Exp $"); #include #include @@ -468,6 +468,8 @@ fdt_pre_attach(struct fdt_node *node) aprint_debug_dev(node->n_bus, "failed to set %s config on %s: %d\n", cfgname, node->n_name, error); + + fdtbus_powerdomain_enable(node->n_phandle); } static void Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.76 src/sys/dev/fdt/fdtvar.h:1.77 --- src/sys/dev/fdt/fdtvar.h:1.76 Wed Feb 23 08:56:11 2022 +++ src/sys/dev/fdt/fdtvar.h Fri Mar 4 08:19:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.76 2022/02/23 08:56:11 skrll Exp $ */ +/* $NetBSD: fdtvar.h,v 1.77 2022/03/04 08:19:06 skrll Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -157,6 +157,20 @@ struct fdtbus_iommu_func { }; +struct fdtbus_mbox_channel { + struct fdtbus_mbox_controller *mb_ctlr; + void *mb_priv; +}; + +struct fdtbus_mbox_controller_func { + void * (*mc_acquire)(device_t, const void *, size_t, void (*)(void *), + void *); + void (*mc_release)(device_t, void *); + int (*mc_recv)(device_t, void *, void *, size_t); + int (*mc_send)(device_t, void *, const void *, size_t); +}; + + struct fdtbus_mmc_pwrseq; struct fdtbus_mmc_pwrseq_func { @@ -201,6 +215,13 @@ struct fdtbus_power_controller_func { }; +struct fdtbus_powerdomain_controller; + +struct fdtbus_powerdomain_controller_func { + void (*pdc_enable)(device_t, const uint32_t *, bool); +}; + + struct fdtbus_pwm_controller_func { pwm_tag_t (*get_tag)(device_t, const void *, size_t); }; @@ -306,12 +327,16 @@ int fdtbus_register_interrupt_controlle const struct fdtbus_interrupt_controller_func *); int fdtbus_register_iommu(device_t, int, const struct fdtbus_iommu_func *); +int fdtbus_register_mbox_controller(device_t, int, + const struct fdtbus_mbox_controller_func *); int fdtbus_register_mmc_pwrseq(device_t, int, const struct fdtbus_mmc_pwrseq_func *); int fdtbus_register_pinctrl_config(device_t, int, const struct fdtbus_pinctrl_controller_func *); int fdtbus_register_power_controller(device_t, int, const struct fdtbus_power_controller_func *); +int fdtbus_register_powerdomain_controller(device_t, int, + const struct fdtbus_powerdomain_controller_func *); int fdtbus_register_phy_controller(device_t, int, const struct fdtbus_phy_controller_func *); int fdtbus_register_pwm_controller(device_t, int, @@ -392,6 +417,15 @@ int fdtbus_intr_parent(int); bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); +struct fdtbus_mbox_channel * + fdtbus_mbox_get(int, const char *, void (*)(void *), void *); +struct fdtbus_mbox_channel * + fdtbus_mbox_get_index(int, u_int, void (*)(void *), + void *); +int fdtbus_mbox_send(struct fdtbus_mbox_channel *, const void *, size_t); +int fdtbus_mbox_recv(struct fdtbus_mbox_channel *, void *, size_t); +void fdtbus_mbox_put(struct fdtbus_mbox_channel *); + struct fdtbus_mmc_pwrseq * fdtbus_mmc_pwrseq_get(int); void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); @@ -447,6 +481,11 @@ int fdtbus_todr_attach(device_t, int, t void fdtbus_power_reset(void); void fdtbus_power_poweroff(void); +int fdtbus_powerdomain_enable(int); +int fdtbus_powerdomain_enable_index(int, int); +int fdtbus_powerdomain_disable(int); +int fdtbus_powerdomain_disable_index(int, int); + struct syscon * fdtbus_syscon_acquire(int, const char *); struct syscon * fdtbus_syscon_lookup(int); Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.62 src/sys/dev/fdt/files.fdt:1.63 --- src/sys/dev/fdt/files.fdt:1.62 Sat Sep 4 12:34:39
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Wed Feb 23 08:56:11 UTC 2022 Modified Files: src/sys/dev/fdt: fdtvar.h Log Message: Sort a bit. NFC To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Wed Feb 23 08:56:11 UTC 2022 Modified Files: src/sys/dev/fdt: fdtvar.h Log Message: Sort a bit. NFC To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.75 src/sys/dev/fdt/fdtvar.h:1.76 --- src/sys/dev/fdt/fdtvar.h:1.75 Wed Feb 23 07:55:55 2022 +++ src/sys/dev/fdt/fdtvar.h Wed Feb 23 08:56:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.75 2022/02/23 07:55:55 skrll Exp $ */ +/* $NetBSD: fdtvar.h,v 1.76 2022/02/23 08:56:11 skrll Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -59,95 +59,17 @@ struct fdt_attach_args { int faa_quiet; }; -/* flags for fdtbus_intr_establish */ -#define FDT_INTR_MPSAFE __BIT(0) - -/* Interrupt trigger types defined by the FDT "interrupts" bindings. */ -#define FDT_INTR_TYPE_POS_EDGE __BIT(0) -#define FDT_INTR_TYPE_NEG_EDGE __BIT(1) -#define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ - FDT_INTR_TYPE_NEG_EDGE) -#define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) -#define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) - -struct fdtbus_interrupt_controller_func { - void * (*establish)(device_t, u_int *, int, int, - int (*)(void *), void *, const char *); - void (*disestablish)(device_t, void *); - bool (*intrstr)(device_t, u_int *, char *, size_t); - void (*mask)(device_t, void *); - void (*unmask)(device_t, void *); -}; - -struct fdtbus_spi_controller_func { - struct spi_controller * (*get_controller)(device_t); -}; - -struct fdtbus_gpio_controller; - -struct fdtbus_gpio_pin { - struct fdtbus_gpio_controller *gp_gc; - void *gp_priv; -}; - -struct fdtbus_gpio_controller_func { - void * (*acquire)(device_t, const void *, size_t, int); - void (*release)(device_t, void *); - int (*read)(device_t, void *, bool); - void (*write)(device_t, void *, int, bool); -}; - -struct fdtbus_pinctrl_controller; - -struct fdtbus_pinctrl_pin { - struct fdtbus_pinctrl_controller *pp_pc; - void *pp_priv; -}; - -struct fdtbus_pinctrl_controller_func { - int (*set_config)(device_t, const void *, size_t); -}; - -struct fdtbus_iommu_func { - bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); -}; - -struct fdtbus_regulator_controller; - -struct fdtbus_regulator { - struct fdtbus_regulator_controller *reg_rc; -}; - -struct fdtbus_regulator_controller_func { - int (*acquire)(device_t); - void (*release)(device_t); - int (*enable)(device_t, bool); - int (*set_voltage)(device_t, u_int, u_int); - int (*get_voltage)(device_t, u_int *); -}; struct fdtbus_clock_controller_func { struct clk * (*decode)(device_t, int, const void *, size_t); }; -struct fdtbus_reset_controller; - -struct fdtbus_reset { - struct fdtbus_reset_controller *rst_rc; - void *rst_priv; -}; - -struct fdtbus_reset_controller_func { - void * (*acquire)(device_t, const void *, size_t); - void (*release)(device_t, void *); - int (*reset_assert)(device_t, void *); - int (*reset_deassert)(device_t, void *); -}; struct fdtbus_dai_controller_func { audio_dai_tag_t (*get_tag)(device_t, const void *, size_t); }; + struct fdtbus_dma_controller; struct fdtbus_dma { @@ -193,13 +115,58 @@ struct fdtbus_dma_controller_func { void (*halt)(device_t, void *); }; -struct fdtbus_power_controller; -struct fdtbus_power_controller_func { - void (*reset)(device_t); - void (*poweroff)(device_t); +struct fdtbus_gpio_controller; + +struct fdtbus_gpio_pin { + struct fdtbus_gpio_controller *gp_gc; + void *gp_priv; +}; + +struct fdtbus_gpio_controller_func { + void * (*acquire)(device_t, const void *, size_t, int); + void (*release)(device_t, void *); + int (*read)(device_t, void *, bool); + void (*write)(device_t, void *, int, bool); +}; + + +/* flags for fdtbus_intr_establish */ +#define FDT_INTR_MPSAFE __BIT(0) + +/* Interrupt trigger types defined by the FDT "interrupts" bindings. */ +#define FDT_INTR_TYPE_POS_EDGE __BIT(0) +#define FDT_INTR_TYPE_NEG_EDGE __BIT(1) +#define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ + FDT_INTR_TYPE_NEG_EDGE) +#define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) +#define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) + +struct fdtbus_interrupt_controller_func { + void * (*establish)(device_t, u_int *, int, int, + int (*)(void *), void *, const char *); + void (*disestablish)(device_t, void *); + bool (*intrstr)(device_t, u_int *, char *, size_t); + void (*mask)(device_t, void *); + void (*unmask)(device_t, void *); +}; + + +struct fdtbus_iommu_func { + bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); +}; + + +struct fdtbus_mmc_pwrseq; + +struct fdtbus_mmc_pwrseq_func { + void (*pre_power_on)(device_t); + void (*post_power_on)(device_t); + void (*power_off)(device_t); + void (*reset)(device_t); }; + struct fdtbus_phy_controller; struct fdtbus_phy { @@ -213,21
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Feb 6 15:47:06 UTC 2022 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: fdt: dwcmmc: Honour broken-cd and non-removable DT properties To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwcmmc_fdt.c diff -u src/sys/dev/fdt/dwcmmc_fdt.c:1.18 src/sys/dev/fdt/dwcmmc_fdt.c:1.19 --- src/sys/dev/fdt/dwcmmc_fdt.c:1.18 Wed Mar 24 18:19:31 2021 +++ src/sys/dev/fdt/dwcmmc_fdt.c Sun Feb 6 15:47:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dwcmmc_fdt.c,v 1.18 2021/03/24 18:19:31 skrll Exp $ */ +/* $NetBSD: dwcmmc_fdt.c,v 1.19 2022/02/06 15:47:06 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.18 2021/03/24 18:19:31 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.19 2022/02/06 15:47:06 jmcneill Exp $"); #include #include @@ -167,6 +167,12 @@ dwcmmc_fdt_attach(device_t parent, devic sc->sc_intr_cardmask = esc->sc_conf->intr_cardmask; sc->sc_ciu_div = esc->sc_conf->ciu_div; sc->sc_flags = esc->sc_conf->flags; + if (of_getprop_bool(phandle, "non-removable")) { + sc->sc_flags |= DWC_MMC_F_NON_REMOVABLE; + } + if (of_getprop_bool(phandle, "broken-cd")) { + sc->sc_flags |= DWC_MMC_F_BROKEN_CD; + } sc->sc_pre_power_on = dwcmmc_fdt_pre_power_on; sc->sc_post_power_on = dwcmmc_fdt_post_power_on; sc->sc_bus_clock = dwcmmc_fdt_bus_clock;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Feb 6 15:47:06 UTC 2022 Modified Files: src/sys/dev/fdt: dwcmmc_fdt.c Log Message: fdt: dwcmmc: Honour broken-cd and non-removable DT properties To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/fdt/dwcmmc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Jan 23 08:01:33 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Use __MASK(4) in bus_dmatag_subregion. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/arasan_sdhc_fdt.c diff -u src/sys/dev/fdt/arasan_sdhc_fdt.c:1.7 src/sys/dev/fdt/arasan_sdhc_fdt.c:1.8 --- src/sys/dev/fdt/arasan_sdhc_fdt.c:1.7 Mon Jan 17 14:00:47 2022 +++ src/sys/dev/fdt/arasan_sdhc_fdt.c Sun Jan 23 08:01:33 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arasan_sdhc_fdt.c,v 1.7 2022/01/17 14:00:47 skrll Exp $ */ +/* $NetBSD: arasan_sdhc_fdt.c,v 1.8 2022/01/23 08:01:33 skrll Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.7 2022/01/17 14:00:47 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.8 2022/01/23 08:01:33 skrll Exp $"); #include #include @@ -272,7 +272,7 @@ arasan_sdhc_attach(device_t parent, devi const uint32_t caps = bus_space_read_4(sc->sc_bst, sc->sc_bsh, SDHC_CAPABILITIES); if ((caps & (SDHC_ADMA2_SUPP|SDHC_64BIT_SYS_BUS)) == SDHC_ADMA2_SUPP) { - error = bus_dmatag_subregion(faa->faa_dmat, 0, UINT32_MAX, + error = bus_dmatag_subregion(faa->faa_dmat, 0, __MASK(32), >sc_base.sc_dmat, BUS_DMA_WAITOK); if (error != 0) { aprint_error(": couldn't create DMA tag: %d\n", error);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Jan 23 08:01:33 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: Use __MASK(4) in bus_dmatag_subregion. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/fdt/arasan_sdhc_fdt.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/dev/fdt
Should fix PR 56650 > Module Name: src > Committed By: macallan > Date: Fri Jan 21 21:00:26 UTC 2022 > > Modified Files: > src/sys/dev/fdt: fdt_port.c > > Log Message: > when enumerating ports and endpoints treat missing 'reg' properties as zero > ok jmcneill: > Looking at Linux. If port or endpoint are missing a 'reg' property it > defaults to 0. > Please make our code do the same. > > see > https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/graph.yaml > > with this my pinebook has a usable console again > > > To generate a diff of this commit: > cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/fdt_port.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. >
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: macallan Date: Fri Jan 21 21:00:26 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: when enumerating ports and endpoints treat missing 'reg' properties as zero ok jmcneill: Looking at Linux. If port or endpoint are missing a 'reg' property it defaults to 0. Please make our code do the same. see https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/graph.yaml with this my pinebook has a usable console again To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_port.c diff -u src/sys/dev/fdt/fdt_port.c:1.6 src/sys/dev/fdt/fdt_port.c:1.7 --- src/sys/dev/fdt/fdt_port.c:1.6 Wed Jan 1 12:46:44 2020 +++ src/sys/dev/fdt/fdt_port.c Fri Jan 21 21:00:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_port.c,v 1.6 2020/01/01 12:46:44 jmcneill Exp $ */ +/* $NetBSD: fdt_port.c,v 1.7 2022/01/21 21:00:26 macallan Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.6 2020/01/01 12:46:44 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.7 2022/01/21 21:00:26 macallan Exp $"); #include #include @@ -298,10 +298,10 @@ again: continue; if (fdtbus_get_reg(child, 0, , NULL) != 0) { if (ports->dp_nports > 1) -aprint_error_dev(self, +aprint_debug_dev(self, "%s: missing reg property", fdtbus_get_string(child, "name")); - id = i; + id = 0; } ports->dp_port[i].port_id = id; ports->dp_port[i].port_phandle = child; @@ -349,10 +349,10 @@ fdt_endpoints_register(int phandle, stru continue; if (fdtbus_get_reg64(child, 0, , NULL) != 0) { if (port->port_nep > 1) -aprint_error_dev(port->port_dp->dp_dev, +aprint_debug_dev(port->port_dp->dp_dev, "%s: missing reg property", fdtbus_get_string(child, "name")); - id = i; + id = 0; } ep = >port_ep[i]; ep->ep_id = id;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: macallan Date: Fri Jan 21 21:00:26 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: when enumerating ports and endpoints treat missing 'reg' properties as zero ok jmcneill: Looking at Linux. If port or endpoint are missing a 'reg' property it defaults to 0. Please make our code do the same. see https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/graph.yaml with this my pinebook has a usable console again To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon Jan 17 14:00:47 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: s/0x/UINT32_MAX/ in bus_dmatag_subregion call To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/arasan_sdhc_fdt.c diff -u src/sys/dev/fdt/arasan_sdhc_fdt.c:1.6 src/sys/dev/fdt/arasan_sdhc_fdt.c:1.7 --- src/sys/dev/fdt/arasan_sdhc_fdt.c:1.6 Wed Jan 27 03:10:21 2021 +++ src/sys/dev/fdt/arasan_sdhc_fdt.c Mon Jan 17 14:00:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arasan_sdhc_fdt.c,v 1.6 2021/01/27 03:10:21 thorpej Exp $ */ +/* $NetBSD: arasan_sdhc_fdt.c,v 1.7 2022/01/17 14:00:47 skrll Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.6 2021/01/27 03:10:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.7 2022/01/17 14:00:47 skrll Exp $"); #include #include @@ -272,7 +272,7 @@ arasan_sdhc_attach(device_t parent, devi const uint32_t caps = bus_space_read_4(sc->sc_bst, sc->sc_bsh, SDHC_CAPABILITIES); if ((caps & (SDHC_ADMA2_SUPP|SDHC_64BIT_SYS_BUS)) == SDHC_ADMA2_SUPP) { - error = bus_dmatag_subregion(faa->faa_dmat, 0, 0x, + error = bus_dmatag_subregion(faa->faa_dmat, 0, UINT32_MAX, >sc_base.sc_dmat, BUS_DMA_WAITOK); if (error != 0) { aprint_error(": couldn't create DMA tag: %d\n", error);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Mon Jan 17 14:00:47 UTC 2022 Modified Files: src/sys/dev/fdt: arasan_sdhc_fdt.c Log Message: s/0x/UINT32_MAX/ in bus_dmatag_subregion call To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/fdt/arasan_sdhc_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Jan 14 07:40:52 UTC 2022 Modified Files: src/sys/dev/fdt: fdtvar.h Log Message: Formatting. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.73 src/sys/dev/fdt/fdtvar.h:1.74 --- src/sys/dev/fdt/fdtvar.h:1.73 Sun Nov 7 17:13:53 2021 +++ src/sys/dev/fdt/fdtvar.h Fri Jan 14 07:40:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.73 2021/11/07 17:13:53 jmcneill Exp $ */ +/* $NetBSD: fdtvar.h,v 1.74 2022/01/14 07:40:52 skrll Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -60,7 +60,7 @@ struct fdt_attach_args { }; /* flags for fdtbus_intr_establish */ -#define FDT_INTR_MPSAFE __BIT(0) +#define FDT_INTR_MPSAFE __BIT(0) /* Interrupt trigger types defined by the FDT "interrupts" bindings. */ #define FDT_INTR_TYPE_POS_EDGE __BIT(0) @@ -321,8 +321,10 @@ int fdtbus_get_phandle(int, const char int fdtbus_get_phandle_with_data(int, const char *, const char *, int, struct fdt_phandle_data *); int fdtbus_get_phandle_from_native(int); + i2c_tag_t fdtbus_get_i2c_tag(int); i2c_tag_t fdtbus_i2c_acquire(int, const char *); + void * fdtbus_intr_establish(int, u_int, int, int, int (*func)(void *), void *arg); void * fdtbus_intr_establish_xname(int, u_int, int, int, @@ -337,18 +339,24 @@ void fdtbus_intr_disestablish(int, void bool fdtbus_intr_str(int, u_int, char *, size_t); bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); int fdtbus_intr_parent(int); + int fdtbus_gpio_count(int, const char *); -struct fdtbus_gpio_pin *fdtbus_gpio_acquire(int, const char *, int); -struct fdtbus_gpio_pin *fdtbus_gpio_acquire_index(int, const char *, int, int); +struct fdtbus_gpio_pin * + fdtbus_gpio_acquire(int, const char *, int); +struct fdtbus_gpio_pin * + fdtbus_gpio_acquire_index(int, const char *, int, int); void fdtbus_gpio_release(struct fdtbus_gpio_pin *); int fdtbus_gpio_read(struct fdtbus_gpio_pin *); void fdtbus_gpio_write(struct fdtbus_gpio_pin *, int); int fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *); void fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int); + audio_dai_tag_t fdtbus_dai_acquire(int, const char *); audio_dai_tag_t fdtbus_dai_acquire_index(int, const char *, int); + pwm_tag_t fdtbus_pwm_acquire(int, const char *); pwm_tag_t fdtbus_pwm_acquire_index(int, const char *, int); + int fdtbus_pinctrl_set_config_index(int, u_int); int fdtbus_pinctrl_set_config(int, const char *); bool fdtbus_pinctrl_has_config(int, const char *); @@ -360,7 +368,9 @@ int fdtbus_pinctrl_parse_bias(int, int int fdtbus_pinctrl_parse_drive(int); int fdtbus_pinctrl_parse_drive_strength(int); int fdtbus_pinctrl_parse_input_output(int, int *); -struct fdtbus_regulator *fdtbus_regulator_acquire(int, const char *); + +struct fdtbus_regulator * + fdtbus_regulator_acquire(int, const char *); void fdtbus_regulator_release(struct fdtbus_regulator *); int fdtbus_regulator_enable(struct fdtbus_regulator *); int fdtbus_regulator_disable(struct fdtbus_regulator *); @@ -370,13 +380,17 @@ int fdtbus_regulator_get_voltage(struct u_int *); int fdtbus_regulator_supports_voltage(struct fdtbus_regulator *, u_int, u_int); + struct syscon * fdtbus_syscon_acquire(int, const char *); struct syscon * fdtbus_syscon_lookup(int); + bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); -struct fdtbus_dma *fdtbus_dma_get(int, const char *, void (*)(void *), void *); -struct fdtbus_dma *fdtbus_dma_get_index(int, u_int, void (*)(void *), +struct fdtbus_dma * + fdtbus_dma_get(int, const char *, void (*)(void *), void *); +struct fdtbus_dma * + fdtbus_dma_get_index(int, u_int, void (*)(void *), void *); void fdtbus_dma_put(struct fdtbus_dma *); int fdtbus_dma_transfer(struct fdtbus_dma *, @@ -391,19 +405,24 @@ u_int fdtbus_clock_count(int, const cha int fdtbus_clock_enable(int, const char *, bool); int fdtbus_clock_enable_index(int, u_int, bool); -struct fdtbus_reset *fdtbus_reset_get(int, const char *); -struct fdtbus_reset *fdtbus_reset_get_index(int, u_int); +struct fdtbus_reset * + fdtbus_reset_get(int, const char *); +struct fdtbus_reset * + fdtbus_reset_get_index(int, u_int); void fdtbus_reset_put(struct fdtbus_reset *); int fdtbus_reset_assert(struct fdtbus_reset *); int fdtbus_reset_deassert(struct fdtbus_reset *); -struct fdtbus_phy *fdtbus_phy_get(int, const char *); -struct fdtbus_phy *fdtbus_phy_get_index(int, u_int); +struct fdtbus_phy * + fdtbus_phy_get(int, const char *); +struct fdtbus_phy * + fdtbus_phy_get_index(int, u_int); void fdtbus_phy_put(struct fdtbus_phy *); device_t fdtbus_phy_device(struct fdtbus_phy *);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Fri Jan 14 07:40:52 UTC 2022 Modified Files: src/sys/dev/fdt: fdtvar.h Log Message: Formatting. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Fri Jan 7 07:25:37 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Calculate the minimum address, don't assume the first entry is the start. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.3 src/sys/dev/fdt/fdt_memory.c:1.4 --- src/sys/dev/fdt/fdt_memory.c:1.3 Sat Jun 26 10:43:52 2021 +++ src/sys/dev/fdt/fdt_memory.c Fri Jan 7 07:25:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_memory.c,v 1.3 2021/06/26 10:43:52 jmcneill Exp $ */ +/* $NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "opt_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.3 2021/06/26 10:43:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.4 2022/01/07 07:25:37 mlelstv Exp $"); #include #include @@ -90,12 +90,13 @@ fdt_memory_get(uint64_t *pstart, uint64_ index++) { fdt_memory_add_range(cur_addr, cur_size); - /* Assume the first entry is the start of memory */ if (index == 0) { *pstart = cur_addr; *pend = cur_addr + cur_size; continue; } + if (cur_addr < *pstart) + *pstart = cur_addr; if (cur_addr + cur_size > *pend) *pend = cur_addr + cur_size; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Fri Jan 7 07:25:37 UTC 2022 Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: Calculate the minimum address, don't assume the first entry is the start. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Fri Nov 12 21:57:44 UTC 2021 Modified Files: src/sys/dev/fdt: dw_apb_uart.c Log Message: dw_apb_uart: Honour reg-io-width property To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/fdt/dw_apb_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dw_apb_uart.c diff -u src/sys/dev/fdt/dw_apb_uart.c:1.10 src/sys/dev/fdt/dw_apb_uart.c:1.11 --- src/sys/dev/fdt/dw_apb_uart.c:1.10 Wed Jan 27 03:10:21 2021 +++ src/sys/dev/fdt/dw_apb_uart.c Fri Nov 12 21:57:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_apb_uart.c,v 1.10 2021/01/27 03:10:21 thorpej Exp $ */ +/* $NetBSD: dw_apb_uart.c,v 1.11 2021/11/12 21:57:44 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.10 2021/01/27 03:10:21 thorpej Exp $"); +__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.11 2021/11/12 21:57:44 jmcneill Exp $"); #include #include @@ -76,27 +76,32 @@ dw_apb_uart_attach(device_t parent, devi struct dw_apb_uart_softc * const ssc = device_private(self); struct com_softc * const sc = >ssc_sc; struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; bus_space_tag_t bst = faa->faa_bst; bus_space_handle_t bsh; char intrstr[128]; bus_addr_t addr; bus_size_t size; - u_int reg_shift; + u_int reg_shift, reg_iowidth; int error; - if (fdtbus_get_reg(faa->faa_phandle, 0, , ) != 0) { + if (fdtbus_get_reg(phandle, 0, , ) != 0) { aprint_error(": couldn't get registers\n"); return; } - if (of_getprop_uint32(faa->faa_phandle, "reg-shift", _shift)) { + if (of_getprop_uint32(phandle, "reg-shift", _shift)) { /* missing or bad reg-shift property, assume 2 */ reg_shift = 2; } + if (of_getprop_uint32(phandle, "reg-io-width", _iowidth)) { + /* missing or bad reg-io-width propery, assume 1 */ + reg_iowidth = 1; + } sc->sc_dev = self; - ssc->ssc_clk = fdtbus_clock_get_index(faa->faa_phandle, 0); + ssc->ssc_clk = fdtbus_clock_get_index(phandle, 0); if (ssc->ssc_clk == NULL) { aprint_error(": couldn't get clock\n"); return; @@ -106,13 +111,13 @@ dw_apb_uart_attach(device_t parent, devi return; } - ssc->ssc_pclk = fdtbus_clock_get(faa->faa_phandle, "apb_pclk"); + ssc->ssc_pclk = fdtbus_clock_get(phandle, "apb_pclk"); if (ssc->ssc_pclk != NULL && clk_enable(ssc->ssc_pclk) != 0) { aprint_error(": couldn't enable peripheral clock\n"); return; } - ssc->ssc_rst = fdtbus_reset_get_index(faa->faa_phandle, 0); + ssc->ssc_rst = fdtbus_reset_get_index(phandle, 0); if (ssc->ssc_rst && fdtbus_reset_deassert(ssc->ssc_rst) != 0) { aprint_error(": couldn't de-assert reset\n"); return; @@ -127,16 +132,16 @@ dw_apb_uart_attach(device_t parent, devi return; } - com_init_regs_stride(>sc_regs, bst, bsh, addr, reg_shift); + com_init_regs_stride_width(>sc_regs, bst, bsh, addr, reg_shift, reg_iowidth); com_attach_subr(sc); - if (!fdtbus_intr_str(faa->faa_phandle, 0, intrstr, sizeof(intrstr))) { + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { aprint_error_dev(self, "failed to decode interrupt\n"); return; } - ssc->ssc_ih = fdtbus_intr_establish_xname(faa->faa_phandle, 0, + ssc->ssc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_SERIAL, FDT_INTR_MPSAFE, comintr, sc, device_xname(self)); if (ssc->ssc_ih == NULL) { aprint_error_dev(self, "failed to establish interrupt on %s\n", @@ -164,7 +169,7 @@ dw_apb_uart_console_consinit(struct fdt_ struct com_regs regs; bus_addr_t addr; tcflag_t flags; - u_int reg_shift; + u_int reg_shift, reg_iowidth; int speed; fdtbus_get_reg(phandle, 0, , NULL); @@ -177,9 +182,13 @@ dw_apb_uart_console_consinit(struct fdt_ /* missing or bad reg-shift property, assume 2 */ reg_shift = 2; } + if (of_getprop_uint32(phandle, "reg-io-width", _iowidth)) { + /* missing or bad reg-io-width propery, assume 1 */ + reg_iowidth = 1; + } memset(_bsh, 0, sizeof(dummy_bsh)); - com_init_regs_stride(, bst, dummy_bsh, addr, reg_shift); + com_init_regs_stride_width(, bst, dummy_bsh, addr, reg_shift, reg_iowidth); if (comcnattach1(, speed, uart_freq, COM_TYPE_DW_APB, flags)) panic("Cannot initialize dw-apb-uart console");
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Fri Nov 12 21:57:44 UTC 2021 Modified Files: src/sys/dev/fdt: dw_apb_uart.c Log Message: dw_apb_uart: Honour reg-io-width property To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/fdt/dw_apb_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:14:20 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Look for child node by compat string snps,dwc3 instead of by name. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwc3_fdt.c diff -u src/sys/dev/fdt/dwc3_fdt.c:1.18 src/sys/dev/fdt/dwc3_fdt.c:1.19 --- src/sys/dev/fdt/dwc3_fdt.c:1.18 Tue Sep 14 22:00:11 2021 +++ src/sys/dev/fdt/dwc3_fdt.c Sun Nov 7 17:14:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc3_fdt.c,v 1.18 2021/09/14 22:00:11 jmcneill Exp $ */ +/* $NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.18 2021/09/14 22:00:11 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.19 2021/11/07 17:14:20 jmcneill Exp $"); #include #include @@ -244,7 +244,10 @@ dwc3_fdt_attach(device_t parent, device_ /* Find dwc3 sub-node */ if (of_compatible_lookup(phandle, compat_data_dwc3) == NULL) { - dwc3_phandle = of_find_firstchild_byname(phandle, "dwc3"); + dwc3_phandle = of_find_bycompat(phandle, "snps,dwc3"); + if (dwc3_phandle <= 0) { + dwc3_phandle = of_find_firstchild_byname(phandle, "dwc3"); + } } else { dwc3_phandle = phandle; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:14:20 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Look for child node by compat string snps,dwc3 instead of by name. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:14:09 UTC 2021 Modified Files: src/sys/dev/fdt: pwm_backlight.c Log Message: pwm_backlight: pick defaults if none are provided To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/pwm_backlight.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/pwm_backlight.c diff -u src/sys/dev/fdt/pwm_backlight.c:1.9 src/sys/dev/fdt/pwm_backlight.c:1.10 --- src/sys/dev/fdt/pwm_backlight.c:1.9 Wed Jan 27 03:10:21 2021 +++ src/sys/dev/fdt/pwm_backlight.c Sun Nov 7 17:14:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pwm_backlight.c,v 1.9 2021/01/27 03:10:21 thorpej Exp $ */ +/* $NetBSD: pwm_backlight.c,v 1.10 2021/11/07 17:14:09 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.9 2021/01/27 03:10:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.10 2021/11/07 17:14:09 jmcneill Exp $"); #include #include @@ -86,7 +86,7 @@ pwm_backlight_attach(device_t parent, de struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; const u_int *levels; - u_int default_level; + u_int default_level = 0; u_int n; int len; @@ -107,14 +107,18 @@ pwm_backlight_attach(device_t parent, de } levels = fdtbus_get_prop(phandle, "brightness-levels", ); - if (len < 4) { - aprint_error(": couldn't get 'brightness-levels' property\n"); - return; + if (levels != NULL) { + sc->sc_nlevels = len / 4; + sc->sc_levels = kmem_alloc(len, KM_SLEEP); + for (n = 0; n < sc->sc_nlevels; n++) + sc->sc_levels[n] = be32toh(levels[n]); + } else { + sc->sc_nlevels = 256; + sc->sc_levels = kmem_alloc(sc->sc_nlevels * 4, KM_SLEEP); + for (n = 0; n < sc->sc_nlevels; n++) + sc->sc_levels[n] = n; + default_level = 200; } - sc->sc_levels = kmem_alloc(len, KM_SLEEP); - sc->sc_nlevels = len / 4; - for (n = 0; n < sc->sc_nlevels; n++) - sc->sc_levels[n] = be32toh(levels[n]); aprint_naive("\n"); aprint_normal(": PWM Backlight"); @@ -127,7 +131,8 @@ pwm_backlight_attach(device_t parent, de sc->sc_lid_state = true; - if (of_getprop_uint32(phandle, "default-brightness-level", _level) == 0) { + of_getprop_uint32(phandle, "default-brightness-level", _level); + if (default_level != 0) { /* set the default level now */ pwm_backlight_set(sc, default_level, true); }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:14:09 UTC 2021 Modified Files: src/sys/dev/fdt: pwm_backlight.c Log Message: pwm_backlight: pick defaults if none are provided To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/pwm_backlight.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:13:53 UTC 2021 Modified Files: src/sys/dev/fdt: fdt_intr.c fdtvar.h Log Message: fdt: add helper for finding intr parent phandle To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/fdt/fdt_intr.c cvs rdiff -u -r1.72 -r1.73 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_intr.c diff -u src/sys/dev/fdt/fdt_intr.c:1.29 src/sys/dev/fdt/fdt_intr.c:1.30 --- src/sys/dev/fdt/fdt_intr.c:1.29 Fri Jan 15 22:59:49 2021 +++ src/sys/dev/fdt/fdt_intr.c Sun Nov 7 17:13:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.c,v 1.29 2021/01/15 22:59:49 jmcneill Exp $ */ +/* $NetBSD: fdt_intr.c,v 1.30 2021/11/07 17:13:53 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.29 2021/01/15 22:59:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.30 2021/11/07 17:13:53 jmcneill Exp $"); #include #include @@ -177,6 +177,12 @@ fdtbus_put_interrupt_cookie(struct fdtbu mutex_exit(_interrupt_cookie_mutex); } +int +fdtbus_intr_parent(int phandle) +{ + return fdtbus_get_interrupt_parent(phandle); +} + void * fdtbus_intr_establish(int phandle, u_int index, int ipl, int flags, int (*func)(void *), void *arg) Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.72 src/sys/dev/fdt/fdtvar.h:1.73 --- src/sys/dev/fdt/fdtvar.h:1.72 Mon Sep 6 14:03:18 2021 +++ src/sys/dev/fdt/fdtvar.h Sun Nov 7 17:13:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.72 2021/09/06 14:03:18 jmcneill Exp $ */ +/* $NetBSD: fdtvar.h,v 1.73 2021/11/07 17:13:53 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -336,6 +336,7 @@ void fdtbus_intr_unmask(int, void *); void fdtbus_intr_disestablish(int, void *); bool fdtbus_intr_str(int, u_int, char *, size_t); bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); +int fdtbus_intr_parent(int); int fdtbus_gpio_count(int, const char *); struct fdtbus_gpio_pin *fdtbus_gpio_acquire(int, const char *, int); struct fdtbus_gpio_pin *fdtbus_gpio_acquire_index(int, const char *, int, int);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:13:53 UTC 2021 Modified Files: src/sys/dev/fdt: fdt_intr.c fdtvar.h Log Message: fdt: add helper for finding intr parent phandle To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/fdt/fdt_intr.c cvs rdiff -u -r1.72 -r1.73 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:12:26 UTC 2021 Modified Files: src/sys/dev/fdt: pinctrl_single.c Log Message: pinctrl-single: support #pinctrl-cells 2 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/pinctrl_single.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/pinctrl_single.c diff -u src/sys/dev/fdt/pinctrl_single.c:1.5 src/sys/dev/fdt/pinctrl_single.c:1.6 --- src/sys/dev/fdt/pinctrl_single.c:1.5 Wed Jan 27 03:10:21 2021 +++ src/sys/dev/fdt/pinctrl_single.c Sun Nov 7 17:12:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pinctrl_single.c,v 1.5 2021/01/27 03:10:21 thorpej Exp $ */ +/* $NetBSD: pinctrl_single.c,v 1.6 2021/11/07 17:12:25 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pinctrl_single.c,v 1.5 2021/01/27 03:10:21 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pinctrl_single.c,v 1.6 2021/11/07 17:12:25 jmcneill Exp $"); #include #include @@ -110,7 +110,7 @@ pinctrl_single_pins_set_config(device_t const u_int *pins; int pinslen; - if (len != 4) + if (len != 4 && len != 8) return -1; const int phandle = fdtbus_get_phandle_from_native(be32dec(data)); @@ -119,13 +119,14 @@ pinctrl_single_pins_set_config(device_t if (pins == NULL) return -1; - while (pinslen >= 8) { + while (pinslen >= 4 + len) { const int off = be32toh(pins[0]); const int val = be32toh(pins[1]); + const int mux = len == 4 ? 0 : be32toh(pins[2]); - pinctrl_single_pins_write(sc, off, val); - pins += 2; - pinslen -= 8; + pinctrl_single_pins_write(sc, off, val | mux); + pins += 1 + (len / 4); + pinslen -= (4 + len); } return 0;
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:12:26 UTC 2021 Modified Files: src/sys/dev/fdt: pinctrl_single.c Log Message: pinctrl-single: support #pinctrl-cells 2 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/pinctrl_single.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:12:16 UTC 2021 Modified Files: src/sys/dev/fdt: fdtbus.c Log Message: fdtbus: match simple-pm-bus To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/fdt/fdtbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdtbus.c diff -u src/sys/dev/fdt/fdtbus.c:1.43 src/sys/dev/fdt/fdtbus.c:1.44 --- src/sys/dev/fdt/fdtbus.c:1.43 Mon Sep 6 14:03:18 2021 +++ src/sys/dev/fdt/fdtbus.c Sun Nov 7 17:12:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtbus.c,v 1.43 2021/09/06 14:03:18 jmcneill Exp $ */ +/* $NetBSD: fdtbus.c,v 1.44 2021/11/07 17:12:15 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.43 2021/09/06 14:03:18 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.44 2021/11/07 17:12:15 jmcneill Exp $"); #include #include @@ -89,6 +89,7 @@ static void fdt_post_attach(struct fdt_n static const struct device_compatible_entry compat_data[] = { { .compat = "simple-bus" }, + { .compat = "simple-pm-bus" }, DEVICE_COMPAT_EOL };
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 7 17:12:16 UTC 2021 Modified Files: src/sys/dev/fdt: fdtbus.c Log Message: fdtbus: match simple-pm-bus To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/fdt/fdtbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Sep 14 22:00:11 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Remove "no IOMMU" hack. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwc3_fdt.c diff -u src/sys/dev/fdt/dwc3_fdt.c:1.17 src/sys/dev/fdt/dwc3_fdt.c:1.18 --- src/sys/dev/fdt/dwc3_fdt.c:1.17 Mon Aug 30 22:49:42 2021 +++ src/sys/dev/fdt/dwc3_fdt.c Tue Sep 14 22:00:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc3_fdt.c,v 1.17 2021/08/30 22:49:42 jmcneill Exp $ */ +/* $NetBSD: dwc3_fdt.c,v 1.18 2021/09/14 22:00:11 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.17 2021/08/30 22:49:42 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.18 2021/09/14 22:00:11 jmcneill Exp $"); #include #include @@ -242,12 +242,6 @@ dwc3_fdt_attach(device_t parent, device_ void *ih; u_int n; - /* XXX IOMMUs not supported yet */ - if (of_hasprop(phandle, "iommus")) { - aprint_error(": devices behind IOMMUs not supported\n"); - return; - } - /* Find dwc3 sub-node */ if (of_compatible_lookup(phandle, compat_data_dwc3) == NULL) { dwc3_phandle = of_find_firstchild_byname(phandle, "dwc3");
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Sep 14 22:00:11 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Remove "no IOMMU" hack. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Sep 4 12:34:39 UTC 2021 Modified Files: src/sys/dev/fdt: fdtvar.h files.fdt Added Files: src/sys/dev/fdt: fdt_iommu.c Log Message: Add facility for registering iommus. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_iommu.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/fdt/fdtvar.h cvs rdiff -u -r1.61 -r1.62 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.70 src/sys/dev/fdt/fdtvar.h:1.71 --- src/sys/dev/fdt/fdtvar.h:1.70 Sat Apr 24 23:36:53 2021 +++ src/sys/dev/fdt/fdtvar.h Sat Sep 4 12:34:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.70 2021/04/24 23:36:53 thorpej Exp $ */ +/* $NetBSD: fdtvar.h,v 1.71 2021/09/04 12:34:39 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -108,6 +108,10 @@ struct fdtbus_pinctrl_controller_func { int (*set_config)(device_t, const void *, size_t); }; +struct fdtbus_iommu_func { + bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); +}; + struct fdtbus_regulator_controller; struct fdtbus_regulator { @@ -299,6 +303,8 @@ int fdtbus_register_pwm_controller(devi int fdtbus_register_mmc_pwrseq(device_t, int, const struct fdtbus_mmc_pwrseq_func *); int fdtbus_register_syscon(device_t, int, struct syscon *); +int fdtbus_register_iommu(device_t, int, + const struct fdtbus_iommu_func *); void fdtbus_set_decoderegprop(bool); @@ -363,6 +369,8 @@ int fdtbus_regulator_supports_voltage(s u_int, u_int); struct syscon * fdtbus_syscon_acquire(int, const char *); struct syscon * fdtbus_syscon_lookup(int); +bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); +bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); struct fdtbus_dma *fdtbus_dma_get(int, const char *, void (*)(void *), void *); struct fdtbus_dma *fdtbus_dma_get_index(int, u_int, void (*)(void *), Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.61 src/sys/dev/fdt/files.fdt:1.62 --- src/sys/dev/fdt/files.fdt:1.61 Mon Apr 26 15:02:29 2021 +++ src/sys/dev/fdt/files.fdt Sat Sep 4 12:34:39 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.61 2021/04/26 15:02:29 thorpej Exp $ +# $NetBSD: files.fdt,v 1.62 2021/09/04 12:34:39 jmcneill Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -72,6 +72,7 @@ file dev/fdt/fdt_dma.c fdt file dev/fdt/fdt_ddb.c fdt & ddb file dev/fdt/fdt_gpio.c fdt file dev/fdt/fdt_i2c.c fdt +file dev/fdt/fdt_iommu.c fdt file dev/fdt/fdt_intr.c fdt file dev/fdt/fdt_mmc_pwrseq.c fdt file dev/fdt/fdt_phy.c fdt Added files: Index: src/sys/dev/fdt/fdt_iommu.c diff -u /dev/null src/sys/dev/fdt/fdt_iommu.c:1.1 --- /dev/null Sat Sep 4 12:34:39 2021 +++ src/sys/dev/fdt/fdt_iommu.c Sat Sep 4 12:34:39 2021 @@ -0,0 +1,206 @@ +/* $NetBSD: fdt_iommu.c,v 1.1 2021/09/04 12:34:39 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: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: fdt_iommu.c,v 1.1 2021/09/04 12:34:39 jmcneill Exp $"); + +#include +#include +#include +#include + +#include +#include + +struct fdtbus_iommu { + device_t iommu_dev; + intiommu_phandle; + const struct fdtbus_iommu_func *iommu_funcs; + u_intiommu_cells; + LIST_ENTRY(fdtbus_iommu) iommu_next; +}; + +static LIST_HEAD(, fdtbus_iommu) fdtbus_iommus = +LIST_HEAD_INITIALIZER(fdtbus_iommus); + +/* + * fdtbus_get_iommu -- + * + * Return the iommu registered with the specified node, or NULL if + * not found. + */ +static struct
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Sep 4 12:34:39 UTC 2021 Modified Files: src/sys/dev/fdt: fdtvar.h files.fdt Added Files: src/sys/dev/fdt: fdt_iommu.c Log Message: Add facility for registering iommus. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/fdt_iommu.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/fdt/fdtvar.h cvs rdiff -u -r1.61 -r1.62 src/sys/dev/fdt/files.fdt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Aug 30 22:49:42 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Until we have proper FDT iommu support, refuse to attach when an iommu is required. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/fdt/dwc3_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/dwc3_fdt.c diff -u src/sys/dev/fdt/dwc3_fdt.c:1.16 src/sys/dev/fdt/dwc3_fdt.c:1.17 --- src/sys/dev/fdt/dwc3_fdt.c:1.16 Sat Aug 7 16:19:10 2021 +++ src/sys/dev/fdt/dwc3_fdt.c Mon Aug 30 22:49:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc3_fdt.c,v 1.16 2021/08/07 16:19:10 thorpej Exp $ */ +/* $NetBSD: dwc3_fdt.c,v 1.17 2021/08/30 22:49:42 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.16 2021/08/07 16:19:10 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.17 2021/08/30 22:49:42 jmcneill Exp $"); #include #include @@ -242,6 +242,12 @@ dwc3_fdt_attach(device_t parent, device_ void *ih; u_int n; + /* XXX IOMMUs not supported yet */ + if (of_hasprop(phandle, "iommus")) { + aprint_error(": devices behind IOMMUs not supported\n"); + return; + } + /* Find dwc3 sub-node */ if (of_compatible_lookup(phandle, compat_data_dwc3) == NULL) { dwc3_phandle = of_find_firstchild_byname(phandle, "dwc3");
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Aug 30 22:49:42 UTC 2021 Modified Files: src/sys/dev/fdt: dwc3_fdt.c Log Message: Until we have proper FDT iommu support, refuse to attach when an iommu is required. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/fdt/dwc3_fdt.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/dev/fdt
On 2020/10/02 22:42, Jonathan A. Kollasch wrote: On Sun, Jul 21, 2019 at 03:57:24PM +, Rin Okuyama wrote: Module Name:src Committed By: rin Date: Sun Jul 21 15:57:24 UTC 2019 Modified Files: src/sys/dev/fdt: dw_apb_uart.c Log Message: The device cannot recognize break signal. Use + (five plus signs) as cnmagic in the same manner with bcm2835_com.c. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/dw_apb_uart.c This does not appear to be needed on at least one SoC (Allwinner H5). Which SoC did you have this problem on? Oops, you are right. It seems that my device (Allwinner A20) did not accept break signal because of WSDISPLAY_MULTICONS option. At that time, kernel just ignored break signal, but today it panics instead. Anyway, by disabling wsdisplay, I can enter DDB from console by break signal. I will revert this commit, and request pullup to netbsd-9. Thank you for finding it out, and I'm sorry for bothering you. rin
Re: CVS commit: src/sys/dev/fdt
On Sun, Jul 21, 2019 at 03:57:24PM +, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Sun Jul 21 15:57:24 UTC 2019 > > Modified Files: > src/sys/dev/fdt: dw_apb_uart.c > > Log Message: > The device cannot recognize break signal. Use + (five plus signs) as > cnmagic in the same manner with bcm2835_com.c. > > > To generate a diff of this commit: > cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/dw_apb_uart.c > This does not appear to be needed on at least one SoC (Allwinner H5). Which SoC did you have this problem on? Jonathan
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Nov 24 09:34:38 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Fix build To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_port.c diff -u src/sys/dev/fdt/fdt_port.c:1.3 src/sys/dev/fdt/fdt_port.c:1.4 --- src/sys/dev/fdt/fdt_port.c:1.3 Sat Nov 23 18:53:05 2019 +++ src/sys/dev/fdt/fdt_port.c Sun Nov 24 09:34:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $ */ +/* $NetBSD: fdt_port.c,v 1.4 2019/11/24 09:34:38 skrll Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.4 2019/11/24 09:34:38 skrll Exp $"); #include #include @@ -257,7 +257,7 @@ fdt_ports_register(struct fdt_device_por int port_phandle, child; int i; char buf[20]; - uint64_t id; + bus_addr_t id; ports->dp_dev = self; SLIST_INSERT_HEAD(_port_devices, ports, dp_list);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: skrll Date: Sun Nov 24 09:34:38 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Fix build To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_port.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/dev/fdt
On Sat, 23 Nov 2019 19:53:05 +0100, "Jared D. McNeill" wrote: > > Module Name: src > Committed By: jmcneill > Date: Sat Nov 23 18:53:05 UTC 2019 > > Modified Files: > src/sys/dev/fdt: fdt_port.c > > Log Message: > Use fdtbus_get_reg to read "reg" property Hi, this change breaks the build (of earmv7hf) on FreeBSD: /usr/home/herbert/source/netbsd/current/src/sys/dev/fdt/fdt_port.c: In function 'fdt_ports_register': /usr/home/herbert/source/netbsd/current/src/sys/dev/fdt/fdt_port.c:299:32: error: passing argument 3 of 'fdtbus_get_reg' from incompatible pointer type [-Werror=incompatible-pointer-types] if (fdtbus_get_reg(child, 0, , NULL) != 0) { ^~~ In file included from /usr/home/herbert/source/netbsd/current/src/sys/dev/fdt/fdt_port.c:49: /usr/home/herbert/source/netbsd/current/src/sys/dev/fdt/fdtvar.h:303:33: note: expected 'bus_addr_t *' {aka 'long unsigned int *'} but argument is of type 'uint64_t *' {aka 'long long unsigned int *'} int fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *); ^~~~ -- Herbert
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:53:05 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Use fdtbus_get_reg to read "reg" property To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:53:05 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Use fdtbus_get_reg to read "reg" property To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_port.c diff -u src/sys/dev/fdt/fdt_port.c:1.2 src/sys/dev/fdt/fdt_port.c:1.3 --- src/sys/dev/fdt/fdt_port.c:1.2 Wed Jan 30 01:24:00 2019 +++ src/sys/dev/fdt/fdt_port.c Sat Nov 23 18:53:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_port.c,v 1.2 2019/01/30 01:24:00 jmcneill Exp $ */ +/* $NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.2 2019/01/30 01:24:00 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $"); #include #include @@ -296,7 +296,7 @@ again: } if (strcmp(buf, "port") != 0) continue; - if (fdtbus_get_reg64(child, 0, , NULL) != 0) { + if (fdtbus_get_reg(child, 0, , NULL) != 0) { if (ports->dp_nports > 1) aprint_error_dev(self, "%s: missing reg property",
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:43 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: spdif_tx.c Log Message: Add driver for dummy spdif transmitter bindings. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/spdif_tx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.47 src/sys/dev/fdt/files.fdt:1.48 --- src/sys/dev/fdt/files.fdt:1.47 Wed Oct 30 21:37:56 2019 +++ src/sys/dev/fdt/files.fdt Sun Nov 17 19:30:42 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.47 2019/10/30 21:37:56 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.48 2019/11/17 19:30:42 jmcneill Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -98,6 +98,10 @@ device ausoc: audiobus attach ausoc at fdt file dev/fdt/ausoc.causoc +device spdiftx +attach spdiftx at fdt +file dev/fdt/spdif_tx.c spdiftx + define fdt_display_timing file dev/fdt/display_timing.c fdt_display_timing Added files: Index: src/sys/dev/fdt/spdif_tx.c diff -u /dev/null src/sys/dev/fdt/spdif_tx.c:1.1 --- /dev/null Sun Nov 17 19:30:43 2019 +++ src/sys/dev/fdt/spdif_tx.c Sun Nov 17 19:30:42 2019 @@ -0,0 +1,114 @@ +/* $NetBSD: spdif_tx.c,v 1.1 2019/11/17 19:30:42 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: spdif_tx.c,v 1.1 2019/11/17 19:30:42 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include + +#include + +#include + +struct spdif_tx_softc { + device_t sc_dev; + struct audio_dai_device sc_dai; +}; + +static int spdif_tx_match(device_t, cfdata_t, void *); +static void spdif_tx_attach(device_t, device_t, void *); + +static const char *compatible[] = { + "linux,spdif-dit", + NULL +}; + +CFATTACH_DECL_NEW(spdiftx, sizeof(struct spdif_tx_softc), + spdif_tx_match, spdif_tx_attach, NULL, NULL); + +static int +spdif_tx_set_format(audio_dai_tag_t dai, u_int format) +{ + return 0; +} + +static int +spdif_tx_add_device(audio_dai_tag_t dai, audio_dai_tag_t aux) +{ + return 0; +} + +static const struct audio_hw_if spdif_tx_hw_if = { }; + +static audio_dai_tag_t +spdif_tx_dai_get_tag(device_t dev, const void *data, size_t len) +{ + struct spdif_tx_softc * const sc = device_private(dev); + + if (len != 4) + return NULL; + + return >sc_dai; +} + +static struct fdtbus_dai_controller_func spdif_tx_dai_funcs = { + .get_tag = spdif_tx_dai_get_tag +}; + +static int +spdif_tx_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +static void +spdif_tx_attach(device_t parent, device_t self, void *aux) +{ + struct spdif_tx_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + + sc->sc_dev = self; + + aprint_naive("\n"); + aprint_normal(": SPDIF transmitter\n"); + + sc->sc_dai.dai_set_format = spdif_tx_set_format; + sc->sc_dai.dai_add_device = spdif_tx_add_device; + sc->sc_dai.dai_hw_if = _tx_hw_if; + sc->sc_dai.dai_dev = self; + sc->sc_dai.dai_priv = sc; + fdtbus_register_dai_controller(self, phandle, _tx_dai_funcs); +}
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:43 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: spdif_tx.c Log Message: Add driver for dummy spdif transmitter bindings. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/spdif_tx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Sat Nov 16 21:53:38 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_intr.c Log Message: be more verbose about errors. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/fdt/fdt_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: mlelstv Date: Sat Nov 16 21:53:38 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_intr.c Log Message: be more verbose about errors. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/fdt/fdt_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_intr.c diff -u src/sys/dev/fdt/fdt_intr.c:1.22 src/sys/dev/fdt/fdt_intr.c:1.23 --- src/sys/dev/fdt/fdt_intr.c:1.22 Fri Jun 14 11:08:18 2019 +++ src/sys/dev/fdt/fdt_intr.c Sat Nov 16 21:53:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $ */ +/* $NetBSD: fdt_intr.c,v 1.23 2019/11/16 21:53:38 mlelstv Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.23 2019/11/16 21:53:38 mlelstv Exp $"); #include #include @@ -138,8 +138,10 @@ fdtbus_intr_establish(int phandle, u_int int ihandle; specifier = get_specifier_by_index(phandle, index, ); - if (specifier == NULL) + if (specifier == NULL) { + printf("%s: handle not found %u@%x\n",__func__,index,phandle); return NULL; + } return fdtbus_intr_establish_raw(ihandle, specifier, ipl, flags, func, arg); @@ -168,8 +170,10 @@ fdtbus_intr_establish_raw(int ihandle, c void *ih; ic = fdtbus_get_interrupt_controller(ihandle); - if (ic == NULL) + if (ic == NULL) { + printf("%s: ihandle %d is not a controller\n",__func__,ihandle); return NULL; + } ih = ic->ic_funcs->establish(ic->ic_dev, __UNCONST(specifier), ipl, flags, func, arg);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:47:47 UTC 2019 Modified Files: src/sys/dev/fdt: ausoc.c Log Message: Set sysclk rate at set_format time, so the link set_format callback can read the new sysclk To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/ausoc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:47:47 UTC 2019 Modified Files: src/sys/dev/fdt: ausoc.c Log Message: Set sysclk rate at set_format time, so the link set_format callback can read the new sysclk To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/ausoc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/ausoc.c diff -u src/sys/dev/fdt/ausoc.c:1.4 src/sys/dev/fdt/ausoc.c:1.5 --- src/sys/dev/fdt/ausoc.c:1.4 Wed May 8 13:40:18 2019 +++ src/sys/dev/fdt/ausoc.c Sat Nov 16 12:47:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ausoc.c,v 1.4 2019/05/08 13:40:18 isaki Exp $ */ +/* $NetBSD: ausoc.c,v 1.5 2019/11/16 12:47:47 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.4 2019/05/08 13:40:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.5 2019/11/16 12:47:47 jmcneill Exp $"); #include #include @@ -121,8 +121,22 @@ ausoc_set_format(void *priv, int setmode audio_filter_reg_t *pfil, audio_filter_reg_t *rfil) { struct ausoc_link * const link = priv; + const audio_params_t *params = (setmode & AUMODE_PLAY) != 0 ? + play : rec; int error; + if (link->link_mclk_fs) { + const u_int rate = params->sample_rate * link->link_mclk_fs; + error = audio_dai_set_sysclk(link->link_codec, rate, + AUDIO_DAI_CLOCK_IN); + if (error) + return error; + error = audio_dai_set_sysclk(link->link_cpu, rate, + AUDIO_DAI_CLOCK_OUT); + if (error) + return error; + } + error = audio_dai_mi_set_format(link->link_cpu, setmode, play, rec, pfil, rfil); if (error) @@ -246,20 +260,8 @@ ausoc_trigger_output(void *priv, void *s void (*intr)(void *), void *intrarg, const audio_params_t *params) { struct ausoc_link * const link = priv; - u_int n, rate; int error; - - if (link->link_mclk_fs) { - rate = params->sample_rate * link->link_mclk_fs; - error = audio_dai_set_sysclk(link->link_codec, rate, - AUDIO_DAI_CLOCK_IN); - if (error) - goto failed; - error = audio_dai_set_sysclk(link->link_cpu, rate, - AUDIO_DAI_CLOCK_OUT); - if (error) - goto failed; - } + u_int n; for (n = 0; n < link->link_naux; n++) { error = audio_dai_trigger(link->link_aux[n], start, end, @@ -285,20 +287,8 @@ ausoc_trigger_input(void *priv, void *st void (*intr)(void *), void *intrarg, const audio_params_t *params) { struct ausoc_link * const link = priv; - u_int n, rate; int error; - - if (link->link_mclk_fs) { - rate = params->sample_rate * link->link_mclk_fs; - error = audio_dai_set_sysclk(link->link_codec, rate, - AUDIO_DAI_CLOCK_IN); - if (error) - goto failed; - error = audio_dai_set_sysclk(link->link_cpu, rate, - AUDIO_DAI_CLOCK_OUT); - if (error) - goto failed; - } + u_int n; for (n = 0; n < link->link_naux; n++) { error = audio_dai_trigger(link->link_aux[n], start, end,
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:28:26 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_clock.c fdtvar.h Log Message: Add fdtbus_clock_enable and fdtbus_clock_enable_index shortcuts To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_clock.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_clock.c diff -u src/sys/dev/fdt/fdt_clock.c:1.9 src/sys/dev/fdt/fdt_clock.c:1.10 --- src/sys/dev/fdt/fdt_clock.c:1.9 Mon Oct 28 21:15:34 2019 +++ src/sys/dev/fdt/fdt_clock.c Sat Nov 9 23:28:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $ */ +/* $NetBSD: fdt_clock.c,v 1.10 2019/11/09 23:28:26 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.10 2019/11/09 23:28:26 jmcneill Exp $"); #include #include @@ -161,6 +161,30 @@ fdtbus_clock_get(int phandle, const char return fdtbus_clock_get_prop(phandle, clkname, "clock-names"); } +int +fdtbus_clock_enable(int phandle, const char *clkname, bool required) +{ + struct clk *clk; + + clk = fdtbus_clock_get(phandle, clkname); + if (clk == NULL) + return required ? ENOENT : 0; + + return clk_enable(clk); +} + +int +fdtbus_clock_enable_index(int phandle, u_int index, bool required) +{ + struct clk *clk; + + clk = fdtbus_clock_get_index(phandle, index); + if (clk == NULL) + return required ? ENOENT : 0; + + return clk_enable(clk); +} + /* * Search the DT for a clock by "clock-output-names" property. * Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.56 src/sys/dev/fdt/fdtvar.h:1.57 --- src/sys/dev/fdt/fdtvar.h:1.56 Mon Oct 28 21:15:34 2019 +++ src/sys/dev/fdt/fdtvar.h Sat Nov 9 23:28:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.56 2019/10/28 21:15:34 jmcneill Exp $ */ +/* $NetBSD: fdtvar.h,v 1.57 2019/11/09 23:28:26 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -367,6 +367,8 @@ struct clk * fdtbus_clock_get_index(int, struct clk * fdtbus_clock_byname(const char *); void fdtbus_clock_assign(int); u_int fdtbus_clock_count(int, const char *); +int fdtbus_clock_enable(int, const char *, bool); +int fdtbus_clock_enable_index(int, u_int, bool); struct fdtbus_reset *fdtbus_reset_get(int, const char *); struct fdtbus_reset *fdtbus_reset_get_index(int, u_int);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:28:26 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_clock.c fdtvar.h Log Message: Add fdtbus_clock_enable and fdtbus_clock_enable_index shortcuts To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_clock.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 30 21:37:56 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: usbnopphy.c Log Message: Add generic USB PHY driver To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/usbnopphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.46 src/sys/dev/fdt/files.fdt:1.47 --- src/sys/dev/fdt/files.fdt:1.46 Sun Oct 27 15:31:15 2019 +++ src/sys/dev/fdt/files.fdt Wed Oct 30 21:37:56 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.46 2019/10/27 15:31:15 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.47 2019/10/30 21:37:56 jmcneill Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -153,3 +153,8 @@ file dev/fdt/amdccp_fdt.c amdccp_fdt # Arasan SDHCI controller attach sdhc at fdt with arasan_sdhc_fdt file dev/fdt/arasan_sdhc_fdt.c arasan_sdhc_fdt + +# Generic USB PHY +device usbnopphy +attach usbnopphy at fdt +file dev/fdt/usbnopphy.c usbnopphy Added files: Index: src/sys/dev/fdt/usbnopphy.c diff -u /dev/null src/sys/dev/fdt/usbnopphy.c:1.1 --- /dev/null Wed Oct 30 21:37:56 2019 +++ src/sys/dev/fdt/usbnopphy.c Wed Oct 30 21:37:56 2019 @@ -0,0 +1,140 @@ +/* $NetBSD: usbnopphy.c,v 1.1 2019/10/30 21:37:56 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +__KERNEL_RCSID(0, "$NetBSD: usbnopphy.c,v 1.1 2019/10/30 21:37:56 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include + +#include + +static int usbnopphy_match(device_t, cfdata_t, void *); +static void usbnopphy_attach(device_t, device_t, void *); + +static const char * const compatible[] = { + "usb-nop-xceiv", + NULL +}; + +struct usbnopphy_softc { + device_t sc_dev; + + struct clk *sc_clk; + struct fdtbus_regulator *sc_reg; + struct fdtbus_gpio_pin *sc_pin_reset; + struct fdtbus_gpio_pin *sc_pin_vbus_det; +}; + +CFATTACH_DECL_NEW(usbnopphy, sizeof(struct usbnopphy_softc), + usbnopphy_match, usbnopphy_attach, NULL, NULL); + +static void * +usbnopphy_acquire(device_t dev, const void *data, size_t len) +{ + struct usbnopphy_softc * const sc = device_private(dev); + + return sc; +} + +static void +usbnopphy_release(device_t dev, void *priv) +{ +} + +static int +usbnopphy_enable(device_t dev, void *priv, bool enable) +{ + struct usbnopphy_softc * const sc = device_private(dev); + int error; + + if (enable) { + if (sc->sc_reg != NULL) { + error = fdtbus_regulator_enable(sc->sc_reg); + if (error != 0) +return error; + } + if (sc->sc_clk != NULL) { + error = clk_enable(sc->sc_clk); + if (error != 0) +return error; + } + if (sc->sc_pin_reset != NULL) { + fdtbus_gpio_write(sc->sc_pin_reset, 1); + delay(2); + fdtbus_gpio_write(sc->sc_pin_reset, 0); + } + } else { + if (sc->sc_pin_reset != NULL) + fdtbus_gpio_write(sc->sc_pin_reset, 1); + if (sc->sc_reg != NULL) + fdtbus_regulator_disable(sc->sc_reg); + if (sc->sc_clk != NULL) + clk_disable(sc->sc_clk); + } + + return 0; +} + +const struct fdtbus_phy_controller_func usbnopphy_funcs = { + .acquire = usbnopphy_acquire, + .release = usbnopphy_release, + .enable = usbnopphy_enable, +}; + +static int +usbnopphy_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +static void +usbnopphy_attach(device_t parent, device_t self, void *aux) +{ +
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 30 21:37:36 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_phy.c Log Message: Skip xref if it is 0 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_phy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 30 21:37:56 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: usbnopphy.c Log Message: Add generic USB PHY driver To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/usbnopphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 30 21:37:36 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_phy.c Log Message: Skip xref if it is 0 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_phy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_phy.c diff -u src/sys/dev/fdt/fdt_phy.c:1.5 src/sys/dev/fdt/fdt_phy.c:1.6 --- src/sys/dev/fdt/fdt_phy.c:1.5 Wed Feb 27 16:56:00 2019 +++ src/sys/dev/fdt/fdt_phy.c Wed Oct 30 21:37:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_phy.c,v 1.5 2019/02/27 16:56:00 jakllsch Exp $ */ +/* $NetBSD: fdt_phy.c,v 1.6 2019/10/30 21:37:36 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_phy.c,v 1.5 2019/02/27 16:56:00 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_phy.c,v 1.6 2019/10/30 21:37:36 jmcneill Exp $"); #include #include @@ -100,6 +100,10 @@ fdtbus_phy_get_index(int phandle, u_int p = phys; for (n = 0, resid = len; resid > 0; n++) { + if (p[0] == 0) { + phy_cells = 0; + goto next; + } const int pc_phandle = fdtbus_get_phandle_from_native(be32toh(p[0])); if (of_getprop_uint32(pc_phandle, "#phy-cells", _cells)) @@ -117,6 +121,7 @@ fdtbus_phy_get_index(int phandle, u_int } break; } +next: resid -= (phy_cells + 1) * 4; p += phy_cells + 1; }
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Oct 29 10:52:22 UTC 2019 Modified Files: src/sys/dev/fdt: cpufreq_dt.c Log Message: Add explicit FDT_OPP for operating-points-v2 so the link set won't be empty To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/cpufreq_dt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Tue Oct 29 10:52:22 UTC 2019 Modified Files: src/sys/dev/fdt: cpufreq_dt.c Log Message: Add explicit FDT_OPP for operating-points-v2 so the link set won't be empty To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/fdt/cpufreq_dt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/cpufreq_dt.c diff -u src/sys/dev/fdt/cpufreq_dt.c:1.12 src/sys/dev/fdt/cpufreq_dt.c:1.13 --- src/sys/dev/fdt/cpufreq_dt.c:1.12 Mon Oct 28 21:14:58 2019 +++ src/sys/dev/fdt/cpufreq_dt.c Tue Oct 29 10:52:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufreq_dt.c,v 1.12 2019/10/28 21:14:58 jmcneill Exp $ */ +/* $NetBSD: cpufreq_dt.c,v 1.13 2019/10/29 10:52:22 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.12 2019/10/28 21:14:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.13 2019/10/29 10:52:22 jmcneill Exp $"); #include #include @@ -377,6 +377,14 @@ cpufreq_dt_lookup_opp_info(const int opp } static bool +cpufreq_dt_opp_v2_supported(const int opp_table, const int opp_node) +{ + return true; +} + +FDT_OPP(opp_v2, "operating-points-v2", cpufreq_dt_opp_v2_supported); + +static bool cpufreq_dt_node_supported(const struct fdt_opp_info *opp_info, const int opp_table, const int opp_node) { if (!fdtbus_status_okay(opp_node)) @@ -387,7 +395,7 @@ cpufreq_dt_node_supported(const struct f if (opp_info != NULL) return opp_info->opp_supported(opp_table, opp_node); - return true; + return false; } static int
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Oct 28 21:15:34 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_clock.c fdtvar.h Log Message: Add fdtbus_clock_count to count the number of clock references on a given node To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_clock.c cvs rdiff -u -r1.55 -r1.56 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Oct 28 21:15:34 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_clock.c fdtvar.h Log Message: Add fdtbus_clock_count to count the number of clock references on a given node To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_clock.c cvs rdiff -u -r1.55 -r1.56 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_clock.c diff -u src/sys/dev/fdt/fdt_clock.c:1.8 src/sys/dev/fdt/fdt_clock.c:1.9 --- src/sys/dev/fdt/fdt_clock.c:1.8 Wed Feb 27 16:56:00 2019 +++ src/sys/dev/fdt/fdt_clock.c Mon Oct 28 21:15:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_clock.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $ */ +/* $NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $"); #include #include @@ -133,8 +133,8 @@ fdtbus_clock_get_prop(int phandle, const return fdtbus_clock_get_index(phandle, index); } -static u_int -fdtbus_clock_count_prop(int phandle, const char *prop) +u_int +fdtbus_clock_count(int phandle, const char *prop) { u_int n, clock_cells; int len, resid; @@ -207,8 +207,8 @@ fdtbus_clock_assign(int phandle) if (rates == NULL) rates_len = 0; - const u_int nclocks = fdtbus_clock_count_prop(phandle, "assigned-clocks"); - const u_int nparents = fdtbus_clock_count_prop(phandle, "assigned-clock-parents"); + const u_int nclocks = fdtbus_clock_count(phandle, "assigned-clocks"); + const u_int nparents = fdtbus_clock_count(phandle, "assigned-clock-parents"); const u_int nrates = rates_len / sizeof(*rates); for (index = 0; index < nclocks; index++) { Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.55 src/sys/dev/fdt/fdtvar.h:1.56 --- src/sys/dev/fdt/fdtvar.h:1.55 Mon Oct 28 21:14:58 2019 +++ src/sys/dev/fdt/fdtvar.h Mon Oct 28 21:15:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.55 2019/10/28 21:14:58 jmcneill Exp $ */ +/* $NetBSD: fdtvar.h,v 1.56 2019/10/28 21:15:34 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -366,6 +366,7 @@ struct clk * fdtbus_clock_get(int, const struct clk * fdtbus_clock_get_index(int, u_int); struct clk * fdtbus_clock_byname(const char *); void fdtbus_clock_assign(int); +u_int fdtbus_clock_count(int, const char *); struct fdtbus_reset *fdtbus_reset_get(int, const char *); struct fdtbus_reset *fdtbus_reset_get_index(int, u_int);
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Oct 28 21:14:58 UTC 2019 Modified Files: src/sys/dev/fdt: cpufreq_dt.c fdtvar.h Log Message: Add support for platform specific opp table filters. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/fdt/cpufreq_dt.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/cpufreq_dt.c diff -u src/sys/dev/fdt/cpufreq_dt.c:1.11 src/sys/dev/fdt/cpufreq_dt.c:1.12 --- src/sys/dev/fdt/cpufreq_dt.c:1.11 Mon Oct 28 10:43:08 2019 +++ src/sys/dev/fdt/cpufreq_dt.c Mon Oct 28 21:14:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufreq_dt.c,v 1.11 2019/10/28 10:43:08 jmcneill Exp $ */ +/* $NetBSD: cpufreq_dt.c,v 1.12 2019/10/28 21:14:58 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.11 2019/10/28 10:43:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.12 2019/10/28 21:14:58 jmcneill Exp $"); #include #include @@ -356,11 +356,46 @@ cpufreq_dt_parse_opp(struct cpufreq_dt_s return 0; } +static const struct fdt_opp_info * +cpufreq_dt_lookup_opp_info(const int opp_table) +{ + __link_set_decl(fdt_opps, struct fdt_opp_info); + struct fdt_opp_info * const *opp; + const struct fdt_opp_info *best_opp = NULL; + int match, best_match = 0; + + __link_set_foreach(opp, fdt_opps) { + const char * const compat[] = { (*opp)->opp_compat, NULL }; + match = of_match_compatible(opp_table, compat); + if (match > best_match) { + best_match = match; + best_opp = *opp; + } + } + + return best_opp; +} + +static bool +cpufreq_dt_node_supported(const struct fdt_opp_info *opp_info, const int opp_table, const int opp_node) +{ + if (!fdtbus_status_okay(opp_node)) + return false; + if (of_hasprop(opp_node, "opp-suspend")) + return false; + + if (opp_info != NULL) + return opp_info->opp_supported(opp_table, opp_node); + + return true; +} + static int cpufreq_dt_parse_opp_v2(struct cpufreq_dt_softc *sc) { const int phandle = sc->sc_phandle; struct cpufreq_dt_table *table; + const struct fdt_opp_info *opp_info; const u_int *opp_uv; uint64_t opp_hz; int opp_node, len, i, index; @@ -378,10 +413,10 @@ cpufreq_dt_parse_opp_v2(struct cpufreq_d TAILQ_INSERT_TAIL(_dt_tables, >sc_table, next); } + opp_info = cpufreq_dt_lookup_opp_info(opp_table); + for (opp_node = OF_child(opp_table); opp_node; opp_node = OF_peer(opp_node)) { - if (!fdtbus_status_okay(opp_node)) - continue; - if (of_hasprop(opp_node, "opp-suspend")) + if (!cpufreq_dt_node_supported(opp_info, opp_table, opp_node)) continue; sc->sc_nopp++; } @@ -392,9 +427,7 @@ cpufreq_dt_parse_opp_v2(struct cpufreq_d sc->sc_opp = kmem_zalloc(sizeof(*sc->sc_opp) * sc->sc_nopp, KM_SLEEP); index = sc->sc_nopp - 1; for (opp_node = OF_child(opp_table), i = 0; opp_node; opp_node = OF_peer(opp_node), i++) { - if (!fdtbus_status_okay(opp_node)) - continue; - if (of_hasprop(opp_node, "opp-suspend")) + if (!cpufreq_dt_node_supported(opp_info, opp_table, opp_node)) continue; if (of_getprop_uint64(opp_node, "opp-hz", _hz) != 0) return EINVAL; Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.54 src/sys/dev/fdt/fdtvar.h:1.55 --- src/sys/dev/fdt/fdtvar.h:1.54 Tue Oct 1 23:32:52 2019 +++ src/sys/dev/fdt/fdtvar.h Mon Oct 28 21:14:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.54 2019/10/01 23:32:52 jmcneill Exp $ */ +/* $NetBSD: fdtvar.h,v 1.55 2019/10/28 21:14:58 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -251,6 +251,21 @@ static const struct fdt_console_info __C }; \ _FDT_CONSOLE_REGISTER(_name) +struct fdt_opp_info { + const char * opp_compat; + bool (*opp_supported)(const int, const int); +}; + +#define _FDT_OPP_REGISTER(name) \ + __link_set_add_rodata(fdt_opps, __CONCAT(name,_oppinfo)); + +#define FDT_OPP(_name, _compat, _suppfn)\ +static const struct fdt_opp_info __CONCAT(_name,_oppinfo) = { \ + .opp_compat = (_compat), \ + .opp_supported = (_suppfn) \ +}; \ +_FDT_OPP_REGISTER(_name) + TAILQ_HEAD(fdt_conslist, fdt_console_info); int fdtbus_register_interrupt_controller(device_t, int,
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Mon Oct 28 21:14:58 UTC 2019 Modified Files: src/sys/dev/fdt: cpufreq_dt.c fdtvar.h Log Message: Add support for platform specific opp table filters. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/fdt/cpufreq_dt.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.