CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Fri Feb 24 11:19:15 UTC 2023 Modified Files: src/sys/arch/arm/apple: apple_dart.c Log Message: #define for consistency with the rest of the file To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_dart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_dart.c diff -u src/sys/arch/arm/apple/apple_dart.c:1.4 src/sys/arch/arm/apple/apple_dart.c:1.5 --- src/sys/arch/arm/apple/apple_dart.c:1.4 Wed Apr 27 07:53:24 2022 +++ src/sys/arch/arm/apple/apple_dart.c Fri Feb 24 11:19:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $ */ +/* $NetBSD: apple_dart.c,v 1.5 2023/02/24 11:19:15 jmcneill Exp $ */ /* $OpenBSD: apldart.c,v 1.10 2022/02/27 17:36:52 kettenis Exp $ */ /*- @@ -21,7 +21,7 @@ //#define APPLE_DART_DEBUG #include -__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.5 2023/02/24 11:19:15 jmcneill Exp $"); #include #include @@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: apple_dart.c * access. To make sure this doesn't fault, round the subpage limits * down and up accordingly. */ -#define DART_OFFSET_MASK 7 +#define DART_OFFSET_MASK 7 #define DART_L1_TABLE 0x3 #define DART_L2_INVAL 0x0
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Fri Feb 24 11:19:15 UTC 2023 Modified Files: src/sys/arch/arm/apple: apple_dart.c Log Message: #define for consistency with the rest of the file To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_dart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Tue Jun 28 10:42:22 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: appleintc: update ci_cpl in pic_set_priority callback To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.8 src/sys/arch/arm/apple/apple_intc.c:1.9 --- src/sys/arch/arm/apple/apple_intc.c:1.8 Mon May 2 04:39:29 2022 +++ src/sys/arch/arm/apple/apple_intc.c Tue Jun 28 10:42:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.8 2022/05/02 04:39:29 ryo Exp $ */ +/* $NetBSD: apple_intc.c,v 1.9 2022/06/28 10:42:22 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.8 2022/05/02 04:39:29 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.9 2022/06/28 10:42:22 jmcneill Exp $"); #include #include @@ -150,6 +150,7 @@ apple_intc_establish_irq(struct pic_soft static void apple_intc_set_priority(struct pic_softc *pic, int ipl) { + curcpu()->ci_cpl = ipl; } static void
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Tue Jun 28 10:42:22 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: appleintc: update ci_cpl in pic_set_priority callback To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Tue May 10 08:10:28 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_pmgr.c Log Message: Add aprints To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_pmgr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_pmgr.c diff -u src/sys/arch/arm/apple/apple_pmgr.c:1.1 src/sys/arch/arm/apple/apple_pmgr.c:1.2 --- src/sys/arch/arm/apple/apple_pmgr.c:1.1 Wed Apr 27 07:55:42 2022 +++ src/sys/arch/arm/apple/apple_pmgr.c Tue May 10 08:10:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_pmgr.c,v 1.1 2022/04/27 07:55:42 skrll Exp $ */ +/* $NetBSD: apple_pmgr.c,v 1.2 2022/05/10 08:10:28 skrll Exp $ */ /*- * Copyright (c) 2022 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_pmgr.c,v 1.1 2022/04/27 07:55:42 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_pmgr.c,v 1.2 2022/05/10 08:10:28 skrll Exp $"); #include @@ -132,6 +132,9 @@ apple_pmgr_attach(device_t parent, devic return; } + aprint_naive("\n"); + aprint_normal(": Apple PMGR\n"); + for (int node = OF_child(phandle); node; node = OF_peer(node)) { static const struct device_compatible_entry compat_ps[] = { { .compat = "apple,pmgr-pwrstate" },
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Tue May 10 08:10:28 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_pmgr.c Log Message: Add aprints To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_pmgr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: ryo Date: Mon May 2 04:39:29 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: fix non-MULTIPROCESSOR build To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.7 src/sys/arch/arm/apple/apple_intc.c:1.8 --- src/sys/arch/arm/apple/apple_intc.c:1.7 Mon Mar 28 19:59:26 2022 +++ src/sys/arch/arm/apple/apple_intc.c Mon May 2 04:39:29 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $ */ +/* $NetBSD: apple_intc.c,v 1.8 2022/05/02 04:39:29 ryo Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.8 2022/05/02 04:39:29 ryo Exp $"); #include #include @@ -503,16 +503,20 @@ apple_intc_attach(device_t parent, devic pc->pc_sc = sc; pc->pc_cpuid = cpuno; +#ifdef MULTIPROCESSOR pic->pic_cpus = ci->ci_kcpuset; +#endif pic->pic_ops = &apple_intc_localpicops; pic->pic_maxsources = 2; snprintf(pic->pic_name, sizeof(pic->pic_name), "AIC/%lu", cpuno); pic_add(pic, PIC_IRQBASE_ALLOC); +#ifdef MULTIPROCESSOR intr_establish_xname(pic->pic_irqbase + LOCALPIC_SOURCE_IPI, IPL_HIGH, IST_LEVEL | IST_MPSAFE, apple_intc_ipi_handler, pc, "ipi"); +#endif } apple_intc_cpu_init(&sc->sc_pic, curcpu());
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: ryo Date: Mon May 2 04:39:29 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: fix non-MULTIPROCESSOR build To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Wed Apr 27 08:03:06 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: Sync with OpenBSD - port initialisation and device power up. Latter requires the SMC GPIO controller which is WIP. While here - improve the MSI vector search algorithm; and - spinkle some BITS(3) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Wed Apr 27 08:03:06 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: Sync with OpenBSD - port initialisation and device power up. Latter requires the SMC GPIO controller which is WIP. While here - improve the MSI vector search algorithm; and - spinkle some BITS(3) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_pcie.c diff -u src/sys/arch/arm/apple/apple_pcie.c:1.5 src/sys/arch/arm/apple/apple_pcie.c:1.6 --- src/sys/arch/arm/apple/apple_pcie.c:1.5 Tue Sep 14 01:33:19 2021 +++ src/sys/arch/arm/apple/apple_pcie.c Wed Apr 27 08:03:06 2022 @@ -1,4 +1,5 @@ -/* $NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $ */ +/* $NetBSD: apple_pcie.c,v 1.6 2022/04/27 08:03:06 skrll Exp $ */ +/* $OpenBSD: aplpcie.c,v 1.13 2022/04/06 18:59:26 naddy Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -26,8 +27,25 @@ * SUCH DAMAGE. */ +/* + * Copyright (c) 2021 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + #include -__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.6 2022/04/27 08:03:06 skrll Exp $"); #include #include @@ -46,17 +64,44 @@ __KERNEL_RCSID(0, "$NetBSD: apple_pcie.c #include #include -#define PCIE_MSI_CTRL 0x0124 -#define PCIE_MSI_CTRL_EN (1U << 0) -#define PCIE_MSI_CTRL_32 (5U << 4) -#define PCIE_MSI_REMAP 0x0128 -#define PCIE_MSI_DOORBELL 0x0168 +#define PCIE_CORE_LANE_CONF(port) (0x84000 + (port) * 0x4000) +#define PCIE_CORE_LANE_CONF_REFCLK0REQ __BIT(0) +#define PCIE_CORE_LANE_CONF_REFCLK1REQ __BIT(1) +#define PCIE_CORE_LANE_CONF_REFCLK0ACK __BIT(2) +#define PCIE_CORE_LANE_CONF_REFCLK1ACK __BIT(3) +#define PCIE_CORE_LANE_CONF_REFCLK0EN __BIT(9) +#define PCIE_CORE_LANE_CONF_REFCLK1EN __BIT(10) +#define PCIE_CORE_LANE_CTRL(port) (0x84004 + (port) * 0x4000) +#define PCIE_CORE_LANE_CTRL_CFGACC __BIT(15) + +#define PCIE_PORT_LTSSM_CTRL 0x0080 +#define PCIE_PORT_LTSSM_CTRL_START __BIT(0) +#define PCIE_PORT_MSI_CTRL 0x0124 +#define PCIE_PORT_MSI_CTRL_EN __BIT(0) +#define PCIE_PORT_MSI_CTRL_32 __SHIFTIN(5U, __BITS(7,4)) +#define PCIE_PORT_MSI_REMAP 0x0128 +#define PCIE_PORT_MSI_DOORBELL 0x0168 +#define PCIE_PORT_LINK_STAT 0x0208 +#define PCIE_PORT_LINK_STAT_UP __BIT(0) +#define PCIE_PORT_APPCLK 0x0800 +#define PCIE_PORT_APPCLK_EN __BIT(0) +#define PCIE_PORT_APPCLK_CGDIS __BIT(8) +#define PCIE_PORT_STAT 0x0804 +#define PCIE_PORT_STAT_READY __BIT(0) +#define PCIE_PORT_REFCLK 0x0810 +#define PCIE_PORT_REFCLK_EN __BIT(0) +#define PCIE_PORT_REFCLK_CGDIS __BIT(8) +#define PCIE_PORT_PERST 0x0814 +#define PCIE_PORT_PERST_DIS __BIT(0) extern struct bus_space arm_generic_bs_tag; struct apple_pcie_softc { struct pcihost_softc sc_pcihost; + bus_space_tag_t sc_rc_bst; + bus_space_handle_t sc_rc_bsh; + int sc_phandle; struct arm_pci_msi sc_msi; u_int sc_msi_start; @@ -81,6 +126,176 @@ static const struct device_compatible_en DEVICE_COMPAT_EOL }; +#define RREAD4(sc, reg) \ +(bus_space_read_4((sc)->sc_rc_bst, (sc)->sc_rc_bsh, (reg))) +#define RWRITE4(sc, reg, val) \ +bus_space_write_4((sc)->sc_rc_bst, (sc)->sc_rc_bsh, (reg), (val)) +#define RSET4(sc, reg, bits)\ +RWRITE4((sc), (reg), RREAD4((sc), (reg)) | (bits)) +#define RCLR4(sc, reg, bits)\ +RWRITE4((sc), (reg), RREAD4((sc), (reg)) & ~(bits)) + + +static void +apple_pcie_setup_port(struct apple_pcie_softc *sc, int phandle) +{ + const bus_space_tag_t bst = sc->sc_pcihost.sc_bst; + const device_t dev = sc->sc_pcihost.sc_dev; + const int parent = sc->sc_pcihost.sc_phandle; + char regname[sizeof("portX")]; + bus_space_handle_t bsh; + bus_addr_t addr; + bus_size_t size; + int error; + int timo; + int len; + + const u_int *reg = fdtbus_get_prop(phandle, "reg", &len); + if (len != 5 * sizeof(uint32_t)) { + aprint_error(": couldn't get port number\n"); + } + + u_int portno = __SHIFTOUT(be32toh(reg[0]), __BITS(13,11)); + snprintf(regname, sizeof(regname), "port%
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Wed Apr 27 07:53:24 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_dart.c Log Message: Sync with OpenBSD - Use subpage feature - Catch up with new device tree bindings - Skip locked DARTs - Use bypass mode for USB3 DARTs Other changes from me - Sprinkle BITS(3) - Improve interrupt error handling To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_dart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_dart.c diff -u src/sys/arch/arm/apple/apple_dart.c:1.3 src/sys/arch/arm/apple/apple_dart.c:1.4 --- src/sys/arch/arm/apple/apple_dart.c:1.3 Mon Sep 6 14:03:17 2021 +++ src/sys/arch/arm/apple/apple_dart.c Wed Apr 27 07:53:24 2022 @@ -1,4 +1,5 @@ -/* $NetBSD: apple_dart.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $ */ +/* $NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $ */ +/* $OpenBSD: apldart.c,v 1.10 2022/02/27 17:36:52 kettenis Exp $ */ /*- * Copyright (c) 2021 Mark Kettenis @@ -20,7 +21,7 @@ //#define APPLE_DART_DEBUG #include -__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $"); #include #include @@ -34,37 +35,78 @@ __KERNEL_RCSID(0, "$NetBSD: apple_dart.c #include #include +/* + * This driver largely ignores stream IDs and simply uses a single + * translation table for all the devices that it serves. This is good + * enough for the PCIe host bridge that serves the on-board devices on + * the current generation Apple Silicon Macs as these only have a + * single PCIe device behind each DART. + */ /* * DART registers */ +#define DART_PARAMS2 0x0004 +#define DART_PARAMS2_BYPASS_SUPPORT __BIT(0) #define DART_TLB_OP 0x0020 -#define DART_TLB_OP_FLUSH __BIT(20) -#define DART_TLB_OP_BUSY __BIT(2) +#define DART_TLB_OP_BUSY __BIT(2) +#define DART_TLB_OP_FLUSH __BIT(20) #define DART_TLB_OP_SIDMASK 0x0034 #define DART_ERR_STATUS 0x0040 +#define DART_ERR_FLAG __BIT(31) +#define DART_ERR_STREAM_MASK __BITS(27, 24) +#define DART_ERR_CODE_MASK __BITS(11, 0) +#define DART_ERR_READ_FAULT __BIT(4) +#define DART_ERR_WRITE_FAULT __BIT(3) +#define DART_ERR_NOPTE __BIT(2) +#define DART_ERR_NOPMD __BIT(1) +#define DART_ERR_NOTTBR __BIT(0) #define DART_ERR_ADDRL 0x0050 #define DART_ERR_ADDRH 0x0054 -#define DART_CONFIG(sid) (0x0100 + (sid) * 0x4) -#define DART_CONFIG_TXEN __BIT(7) +#define DART_CONFIG 0x0060 +#define DART_CONFIG_LOCK __BIT(15) +#define DART_TCR(sid) (0x0100 + (sid) * 0x4) +#define DART_TCR_TRANSLATE_ENABLE __BIT(7) +#define DART_TCR_BYPASS_DART __BIT(8) +#define DART_TCR_BYPASS_DAPF __BIT(12) #define DART_TTBR(sid, idx) (0x0200 + (sid) * 0x10 + (idx) * 0x4) -#define DART_TTBR_VALID __BIT(31) -#define DART_TTBR_SHIFT 12 +#define DART_TTBR_VALID __BIT(31) +#define DART_TTBR_SHIFT 12 + +#define DART_NUM_STREAMS 16 +#define DART_ALL_STREAMS ((1 << DART_NUM_STREAMS) - 1) #define DART_APERTURE_START 0x0010 #define DART_APERTURE_SIZE 0x3fe0 #define DART_PAGE_SIZE 16384 #define DART_PAGE_MASK (DART_PAGE_SIZE - 1) -#define DART_L1_TABLE 0xb +/* + * Some hardware (e.g. bge(4)) will always use (aligned) 64-bit memory + * access. To make sure this doesn't fault, round the subpage limits + * down and up accordingly. + */ +#define DART_OFFSET_MASK 7 + +#define DART_L1_TABLE 0x3 #define DART_L2_INVAL 0x0 -#define DART_L2_PAGE 0x3 +#define DART_L2_VALID __BIT(0) +#define DART_L2_FULL_PAGE __BIT(1) + +#define DART_L2_START_MASK __BITS(63, 52) +#define DART_L2_END_MASK __BITS(51, 40) +#define DART_L2_SUBPAGE(addr) __SHIFTOUT((addr), __BITS(13, 2)) +#define DART_L2_START(addr) __SHIFTIN(DART_L2_SUBPAGE(addr), DART_L2_START_MASK) +#define DART_L2_END(addr) __SHIFTIN(DART_L2_SUBPAGE(addr), DART_L2_END_MASK) #define DART_ROUND_PAGE(pa) (((pa) + DART_PAGE_MASK) & ~DART_PAGE_MASK) #define DART_TRUNC_PAGE(pa) ((pa) & ~DART_PAGE_MASK) +#define DART_ROUND_OFFSET(pa) (((pa) + DART_OFFSET_MASK) & ~DART_OFFSET_MASK) +#define DART_TRUNC_OFFSET(pa) ((pa) & ~DART_OFFSET_MASK) static const struct device_compatible_entry compat_data[] = { { .compat = "apple,dart-m1", .value = 16 }, + { .compat = "apple,t8103-dart", .value = 16 }, DEVICE_COMPAT_EOL }; @@ -188,14 +230,42 @@ apple_dart_intr(void *priv) uint32_t status; status = DART_READ(sc, DART_ERR_STATUS); - addr = DART_READ(sc, DART_ERR_ADDRL); - addr |= (uint64_t)DART_READ(sc, DART_ERR_ADDRH) << 32; + addr = __SHIFTIN(DART_READ(sc, DART_ERR_ADDRL), __BITS(31, 0)); + addr |= __SHIFTIN(DART_READ(sc, DART_ERR_ADDRH), __BITS(63, 32)); DART_WRITE(sc, DART_ERR_STATUS, status); + if ((status & DART_ERR_FLAG) == 0) + return 1; + +#ifdef APPLE_DART_DEBUG + printf("%s: status %#"PRIx32"\n", __func__, status); + printf("%s: addrl
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Wed Apr 27 07:53:24 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_dart.c Log Message: Sync with OpenBSD - Use subpage feature - Catch up with new device tree bindings - Skip locked DARTs - Use bypass mode for USB3 DARTs Other changes from me - Sprinkle BITS(3) - Improve interrupt error handling To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_dart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Tue Apr 5 05:04:04 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_wdog.c Log Message: Sync with new DTS To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_wdog.c diff -u src/sys/arch/arm/apple/apple_wdog.c:1.2 src/sys/arch/arm/apple/apple_wdog.c:1.3 --- src/sys/arch/arm/apple/apple_wdog.c:1.2 Mon Sep 6 14:03:17 2021 +++ src/sys/arch/arm/apple/apple_wdog.c Tue Apr 5 05:04:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_wdog.c,v 1.2 2021/09/06 14:03:17 jmcneill Exp $ */ +/* $NetBSD: apple_wdog.c,v 1.3 2022/04/05 05:04:04 skrll Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_wdog.c,v 1.2 2021/09/06 14:03:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_wdog.c,v 1.3 2022/04/05 05:04:04 skrll Exp $"); #include #include @@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: apple_wdog.c #define WDOG_SYS_CTL_ENABLE __BIT(2) static const struct device_compatible_entry compat_data[] = { + { .compat = "apple,wdt" }, { .compat = "apple,reboot-v0" }, DEVICE_COMPAT_EOL };
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Tue Apr 5 05:04:04 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_wdog.c Log Message: Sync with new DTS To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: riastradh Date: Mon Mar 28 19:59:26 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: arm/apple: Use container_of, not bespoke offsetof arithmetic. Better type-safety this way. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: riastradh Date: Mon Mar 28 19:59:26 UTC 2022 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: arm/apple: Use container_of, not bespoke offsetof arithmetic. Better type-safety this way. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.6 src/sys/arch/arm/apple/apple_intc.c:1.7 --- src/sys/arch/arm/apple/apple_intc.c:1.6 Fri Nov 26 19:39:58 2021 +++ src/sys/arch/arm/apple/apple_intc.c Mon Mar 28 19:59:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $ */ +/* $NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $"); #include #include @@ -112,10 +112,8 @@ struct apple_intc_softc { static struct apple_intc_softc *intc_softc; -#define PICTOSOFTC(pic) \ - ((void *)((uintptr_t)(pic) - offsetof(struct apple_intc_softc, sc_pic))) -#define PICTOPERCPU(pic) \ - ((void *)((uintptr_t)(pic) - offsetof(struct apple_intc_percpu, pc_pic))) +#define PICTOSOFTC(pic) container_of(pic, struct apple_intc_softc, sc_pic) +#define PICTOPERCPU(pic) container_of(pic, struct apple_intc_percpu, pc_pic) #define AIC_READ(sc, reg) \ bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Mon Jan 3 08:44:11 UTC 2022 Modified Files: src/sys/arch/arm/apple: files.apple Log Message: sort To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/files.apple Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/files.apple diff -u src/sys/arch/arm/apple/files.apple:1.1 src/sys/arch/arm/apple/files.apple:1.2 --- src/sys/arch/arm/apple/files.apple:1.1 Mon Aug 30 23:26:26 2021 +++ src/sys/arch/arm/apple/files.apple Mon Jan 3 08:44:10 2022 @@ -1,4 +1,4 @@ -# $NetBSD: files.apple,v 1.1 2021/08/30 23:26:26 jmcneill Exp $ +# $NetBSD: files.apple,v 1.2 2022/01/03 08:44:10 skrll Exp $ # # Configuration info for Apple Silicon SoCs # @@ -6,25 +6,25 @@ file arch/arm/apple/apple_platform.c soc_apple +# IOMMU +device appledart +attach appledart at fdt with apple_dart +file arch/arm/apple/apple_dart.c apple_dart + # Interrupt controller device appleintc: pic, pic_splfuncs attach appleintc at fdt with apple_intc file arch/arm/apple/apple_intc.c apple_intc -# Watchdog timer -device applewdog: sysmon_wdog -attach applewdog at fdt with apple_wdog -file arch/arm/apple/apple_wdog.c apple_wdog - # PCIe controller device applepcie: pcibus, pcihost_fdt attach applepcie at fdt with apple_pcie file arch/arm/apple/apple_pcie.c apple_pcie -# IOMMU -device appledart -attach appledart at fdt with apple_dart -file arch/arm/apple/apple_dart.c apple_dart +# Watchdog timer +device applewdog: sysmon_wdog +attach applewdog at fdt with apple_wdog +file arch/arm/apple/apple_wdog.c apple_wdog # SOC parameters defflag opt_soc.hSOC_APPLE
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Mon Jan 3 08:44:11 UTC 2022 Modified Files: src/sys/arch/arm/apple: files.apple Log Message: sort To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/files.apple Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Fri Nov 26 19:39:58 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: Mask the bottom 5 bits in the standard pic way. NFC. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.5 src/sys/arch/arm/apple/apple_intc.c:1.6 --- src/sys/arch/arm/apple/apple_intc.c:1.5 Fri Nov 26 19:36:17 2021 +++ src/sys/arch/arm/apple/apple_intc.c Fri Nov 26 19:39:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.5 2021/11/26 19:36:17 skrll Exp $ */ +/* $NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.5 2021/11/26 19:36:17 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $"); #include #include @@ -291,9 +291,9 @@ static const struct fdtbus_interrupt_con static void apple_intc_mark_pending(struct pic_softc *pic, u_int intno) { - const int group = intno / 32; + const int base = intno & ~0x1f; const uint32_t pending = __BIT(intno & 0x1f); - pic_mark_pending_sources(pic, group * 32, pending); + pic_mark_pending_sources(pic, base, pending); } static void
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Fri Nov 26 19:39:58 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: Mask the bottom 5 bits in the standard pic way. NFC. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Fri Nov 26 19:36:17 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: no need to shout To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: skrll Date: Fri Nov 26 19:36:17 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: no need to shout To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.4 src/sys/arch/arm/apple/apple_intc.c:1.5 --- src/sys/arch/arm/apple/apple_intc.c:1.4 Sun Oct 31 16:23:47 2021 +++ src/sys/arch/arm/apple/apple_intc.c Fri Nov 26 19:36:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.4 2021/10/31 16:23:47 skrll Exp $ */ +/* $NetBSD: apple_intc.c,v 1.5 2021/11/26 19:36:17 skrll Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.4 2021/10/31 16:23:47 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.5 2021/11/26 19:36:17 skrll Exp $"); #include #include @@ -277,7 +277,7 @@ apple_intc_fdt_intrstr(device_t dev, u_i /* 2nd cell is the interrupt number */ const u_int intno = be32toh(specifier[1]); - snprintf(buf, buflen, "%s %u", type == 0 ? "IRQ" : "FIQ", intno); + snprintf(buf, buflen, "%s %u", type == 0 ? "irq" : "fiq", intno); return true; }
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: ryo Date: Sat Oct 16 06:37:43 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: fix non-MULTIPROCESSOR build Build tested only. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.2 src/sys/arch/arm/apple/apple_intc.c:1.3 --- src/sys/arch/arm/apple/apple_intc.c:1.2 Mon Sep 6 14:03:17 2021 +++ src/sys/arch/arm/apple/apple_intc.c Sat Oct 16 06:37:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.2 2021/09/06 14:03:17 jmcneill Exp $ */ +/* $NetBSD: apple_intc.c,v 1.3 2021/10/16 06:37:43 ryo Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,11 +27,12 @@ */ #include "opt_ddb.h" +#include "opt_multiprocessor.h" #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.2 2021/09/06 14:03:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.3 2021/10/16 06:37:43 ryo Exp $"); #include #include @@ -167,7 +168,9 @@ static const struct pic_ops apple_intc_p .pic_block_irqs = apple_intc_block_irqs, .pic_establish_irq = apple_intc_establish_irq, .pic_set_priority = apple_intc_set_priority, +#ifdef MULTIPROCESSOR .pic_cpu_init = apple_intc_cpu_init, +#endif }; static void @@ -199,6 +202,7 @@ apple_intc_local_establish_irq(struct pi { } +#ifdef MULTIPROCESSOR static void apple_intc_local_ipi_send(struct pic_softc *pic, const kcpuset_t *kcp, u_long ipi) { @@ -209,12 +213,15 @@ apple_intc_local_ipi_send(struct pic_sof atomic_or_32(&pc->pc_ipimask, __BIT(ipi)); AIC_WRITE(sc, AIC_IPI_SEND, __BIT(target)); } +#endif /* MULTIPROCESSOR */ static const struct pic_ops apple_intc_localpicops = { .pic_unblock_irqs = apple_intc_local_unblock_irqs, .pic_block_irqs = apple_intc_local_block_irqs, .pic_establish_irq = apple_intc_local_establish_irq, +#ifdef MULTIPROCESSOR .pic_ipi_send = apple_intc_local_ipi_send, +#endif }; static void * @@ -366,6 +373,7 @@ apple_intc_fiq_handler(void *frame) } } +#ifdef MULTIPROCESSOR static int apple_intc_ipi_handler(void *priv) { @@ -411,6 +419,7 @@ apple_intc_ipi_handler(void *priv) return 1; } +#endif /* MULTIPROCESSOR */ static void apple_intc_percpu_init(void *priv, struct cpu_info *ci) @@ -420,10 +429,13 @@ apple_intc_percpu_init(void *priv, struc struct apple_intc_percpu * const pc = &sc->sc_pc[cpuno]; struct pic_softc * const pic = &pc->pc_pic; +#ifdef MULTIPROCESSOR pic->pic_cpus = ci->ci_kcpuset; +#endif pic_add(pic, PIC_IRQBASE_ALLOC); +#ifdef MULTIPROCESSOR if (cpuno != 0) { struct intrsource * const is = sc->sc_pc[0].pc_pic.pic_sources[LOCALPIC_SOURCE_TIMER]; @@ -436,7 +448,7 @@ apple_intc_percpu_init(void *priv, struc intr_establish_xname(pic->pic_irqbase + LOCALPIC_SOURCE_IPI, IPL_HIGH, IST_LEVEL | IST_MPSAFE, apple_intc_ipi_handler, pc, "ipi"); - +#endif } static int
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: ryo Date: Sat Oct 16 06:37:43 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: fix non-MULTIPROCESSOR build Build tested only. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Tue Sep 14 01:33:19 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: Support new style msi-ranges from U-Boot To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_pcie.c diff -u src/sys/arch/arm/apple/apple_pcie.c:1.4 src/sys/arch/arm/apple/apple_pcie.c:1.5 --- src/sys/arch/arm/apple/apple_pcie.c:1.4 Mon Sep 13 23:30:05 2021 +++ src/sys/arch/arm/apple/apple_pcie.c Tue Sep 14 01:33:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_pcie.c,v 1.4 2021/09/13 23:30:05 jmcneill Exp $ */ +/* $NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.4 2021/09/13 23:30:05 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $"); #include #include @@ -504,13 +504,22 @@ apple_pcie_msi_init(struct apple_pcie_so int len; const u_int *data = fdtbus_get_prop(phandle, "msi-ranges", &len); - if (len != 8) { + switch (len) { + case 8: + /* two cells: start and count */ + sc->sc_msi_start = be32toh(data[0]); + sc->sc_nmsi = be32toh(data[1]); + break; + case 20: + /* 5 cells: xref, specifier (3 cells), and count */ + sc->sc_msi_start = be32toh(data[2]); + sc->sc_nmsi = be32toh(data[4]); + break; + default: aprint_error_dev(sc->sc_pcihost.sc_dev, "WARNING: bad msi-ranges property, MSI not enabled!\n"); return ENXIO; } - sc->sc_msi_start = be32toh(data[0]); - sc->sc_nmsi = be32toh(data[1]); sc->sc_msi_pa = kmem_zalloc(sizeof(*sc->sc_msi_pa) * sc->sc_nmsi, KM_SLEEP); sc->sc_msi_ih = kmem_zalloc(sizeof(*sc->sc_msi_ih) * sc->sc_nmsi,
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Tue Sep 14 01:33:19 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: Support new style msi-ranges from U-Boot To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Mon Sep 13 23:30:52 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: apple: provide a non-posted bs tag by default This tag is still used for early console attachment. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_platform.c diff -u src/sys/arch/arm/apple/apple_platform.c:1.3 src/sys/arch/arm/apple/apple_platform.c:1.4 --- src/sys/arch/arm/apple/apple_platform.c:1.3 Thu Sep 2 20:57:57 2021 +++ src/sys/arch/arm/apple/apple_platform.c Mon Sep 13 23:30:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_platform.c,v 1.3 2021/09/02 20:57:57 jmcneill Exp $ */ +/* $NetBSD: apple_platform.c,v 1.4 2021/09/13 23:30:52 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.3 2021/09/02 20:57:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.4 2021/09/13 23:30:52 jmcneill Exp $"); #include #include @@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: apple_platfo extern struct bus_space arm_generic_bs_tag; +static struct bus_space apple_nonposted_bs_tag; + struct arm32_bus_dma_tag apple_coherent_dma_tag; static struct arm32_dma_range apple_coherent_ranges[] = { [0] = { @@ -70,11 +72,25 @@ static struct arm32_dma_range apple_cohe } }; +static int +apple_nonposted_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, +bus_space_handle_t *bshp) +{ + if (flag == 0) { + flag |= _ARM_BUS_SPACE_MAP_STRONGLY_ORDERED; + } + + return bus_space_map(&arm_generic_bs_tag, bpa, size, flag, bshp); +} + static void apple_platform_bootstrap(void) { extern struct arm32_bus_dma_tag arm_generic_dma_tag; + apple_nonposted_bs_tag = arm_generic_bs_tag; + apple_nonposted_bs_tag.bs_map = apple_nonposted_bs_map; + apple_coherent_dma_tag = arm_generic_dma_tag; apple_coherent_dma_tag._ranges = apple_coherent_ranges; apple_coherent_dma_tag._nranges = __arraycount(apple_coherent_ranges); @@ -85,7 +101,7 @@ apple_platform_bootstrap(void) static void apple_platform_init_attach_args(struct fdt_attach_args *faa) { - faa->faa_bst = &arm_generic_bs_tag; + faa->faa_bst = &apple_nonposted_bs_tag; faa->faa_dmat = &apple_coherent_dma_tag; }
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Mon Sep 13 23:30:52 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: apple: provide a non-posted bs tag by default This tag is still used for early console attachment. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Mon Sep 13 23:30:05 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: applepcie: Explicitly use posted BS tag for PCI devices. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_pcie.c diff -u src/sys/arch/arm/apple/apple_pcie.c:1.3 src/sys/arch/arm/apple/apple_pcie.c:1.4 --- src/sys/arch/arm/apple/apple_pcie.c:1.3 Mon Sep 6 14:03:17 2021 +++ src/sys/arch/arm/apple/apple_pcie.c Mon Sep 13 23:30:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_pcie.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $ */ +/* $NetBSD: apple_pcie.c,v 1.4 2021/09/13 23:30:05 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.4 2021/09/13 23:30:05 jmcneill Exp $"); #include #include @@ -52,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: apple_pcie.c #define PCIE_MSI_REMAP 0x0128 #define PCIE_MSI_DOORBELL 0x0168 +extern struct bus_space arm_generic_bs_tag; + struct apple_pcie_softc { struct pcihost_softc sc_pcihost; @@ -110,7 +112,7 @@ apple_pcie_attach(device_t parent, devic * Create a new bus tag for PCIe devices that does not inherit the * nonposted MMIO flag from the host controller. */ - sc->sc_pci_bst = fdtbus_bus_tag_create(phandle, 0); + sc->sc_pci_bst = &arm_generic_bs_tag; sc->sc_phandle = phandle; error = bus_space_map(faa->faa_bst, cs_addr, cs_size, 0, &sc->sc_bsh); if (error) {
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Mon Sep 13 23:30:05 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_pcie.c Log Message: applepcie: Explicitly use posted BS tag for PCI devices. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Sat Sep 4 12:35:31 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_dart.c apple_pcie.c Log Message: Use fdt_iommu instead of calling appledart directly from applepcie To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_dart.c \ src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_dart.c diff -u src/sys/arch/arm/apple/apple_dart.c:1.1 src/sys/arch/arm/apple/apple_dart.c:1.2 --- src/sys/arch/arm/apple/apple_dart.c:1.1 Mon Aug 30 23:26:26 2021 +++ src/sys/arch/arm/apple/apple_dart.c Sat Sep 4 12:35:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_dart.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $ */ +/* $NetBSD: apple_dart.c,v 1.2 2021/09/04 12:35:31 jmcneill Exp $ */ /*- * Copyright (c) 2021 Mark Kettenis @@ -20,7 +20,7 @@ //#define APPLE_DART_DEBUG #include -__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.2 2021/09/04 12:35:31 jmcneill Exp $"); #include #include @@ -36,46 +36,6 @@ __KERNEL_RCSID(0, "$NetBSD: apple_dart.c #include /* - * DT node to bus_dma tag mappings - */ - -bus_dma_tag_t apple_dart_iommu_lookup(int); - -struct apple_dart_iommu { - int phandle; - bus_dma_tag_t dmat; - LIST_ENTRY(apple_dart_iommu) next; -}; - -static LIST_HEAD(, apple_dart_iommu) apple_dart_iommus = -LIST_HEAD_INITIALIZER(apple_dart_iommus); - -static void -apple_dart_iommu_register(int phandle, bus_dma_tag_t dmat) -{ - struct apple_dart_iommu *iommu; - - iommu = kmem_alloc(sizeof(*iommu), KM_SLEEP); - iommu->phandle = phandle; - iommu->dmat = dmat; - LIST_INSERT_HEAD(&apple_dart_iommus, iommu, next); -} - -bus_dma_tag_t -apple_dart_iommu_lookup(int phandle) -{ - struct apple_dart_iommu *iommu; - - LIST_FOREACH(iommu, &apple_dart_iommus, next) { - if (iommu->phandle == phandle) { - return iommu->dmat; - } - } - - panic("Couldn't find IOMMU for node 0x%x", phandle); -} - -/* * DART registers */ #define DART_TLB_OP 0x0020 @@ -473,6 +433,18 @@ apple_dart_dmamap_unload(bus_dma_tag_t t sc->sc_dmat->_dmamap_unload(sc->sc_dmat, map); } +static bus_dma_tag_t +apple_dart_iommu_map(device_t dev, const u_int *data, bus_dma_tag_t dmat) +{ + struct apple_dart_softc * const sc = device_private(dev); + + return &sc->sc_bus_dmat; +} + +const struct fdtbus_iommu_func apple_dart_iommu_funcs = { + .map = apple_dart_iommu_map, +}; + static int apple_dart_match(device_t parent, cfdata_t cf, void *aux) { @@ -623,7 +595,7 @@ apple_dart_attach(device_t parent, devic sc->sc_bus_dmat._dmamap_load_raw = apple_dart_dmamap_load_raw; sc->sc_bus_dmat._dmamap_unload = apple_dart_dmamap_unload; - apple_dart_iommu_register(phandle, &sc->sc_bus_dmat); + fdtbus_register_iommu(self, phandle, &apple_dart_iommu_funcs); } CFATTACH_DECL_NEW(apple_dart, sizeof(struct apple_dart_softc), Index: src/sys/arch/arm/apple/apple_pcie.c diff -u src/sys/arch/arm/apple/apple_pcie.c:1.1 src/sys/arch/arm/apple/apple_pcie.c:1.2 --- src/sys/arch/arm/apple/apple_pcie.c:1.1 Mon Aug 30 23:26:26 2021 +++ src/sys/arch/arm/apple/apple_pcie.c Sat Sep 4 12:35:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_pcie.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $ */ +/* $NetBSD: apple_pcie.c,v 1.2 2021/09/04 12:35:31 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.2 2021/09/04 12:35:31 jmcneill Exp $"); #include #include @@ -52,9 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: apple_pcie.c #define PCIE_MSI_REMAP 0x0128 #define PCIE_MSI_DOORBELL 0x0168 -/* XXX apple_dart.c */ -extern bus_dma_tag_t apple_dart_iommu_lookup(int); - struct apple_pcie_softc { struct pcihost_softc sc_pcihost; @@ -174,36 +171,15 @@ apple_pcie_attach_hook(device_t parent, { struct apple_pcie_softc *sc = pba->pba_pc->pc_conf_v; const int phandle = sc->sc_pcihost.sc_phandle; - const u_int *iommu_map; - int len; + bus_dma_tag_t dmat; KASSERT(device_is_a(sc->sc_pcihost.sc_dev, "applepcie")); - iommu_map = fdtbus_get_prop(phandle, "iommu-map", &len); - if (iommu_map == NULL) { - panic("%s: no iommu-map?!", - device_xname(sc->sc_pcihost.sc_dev)); - return; - } - - while (len >= 16) { - const u_int ridbase = be32toh(iommu_map[0]); - const u_int xref = fdtbus_get_phandle_from_native( - be32toh(iommu_map[1])); - - const int bus = (ridbase >> 8) & 0xff; - if (bus == pba->pba_bus) { - pba->pba_dmat = apple_dart_iommu_lookup(xref); - pba->pba_dmat64 = pba->pba_dmat; - return; - } - - iommu_map += 4; - len -= 16; - } + /* XXX this should be per-device, not per-bus */ + const uint32_t rid = pba->pba_bus << 8; - //panic("no io
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Sat Sep 4 12:35:31 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_dart.c apple_pcie.c Log Message: Use fdt_iommu instead of calling appledart directly from applepcie To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_dart.c \ src/sys/arch/arm/apple/apple_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Thu Sep 2 20:57:57 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: apple: derive CPU speed from mpidr_el1 According to https://github.com/AsahiLinux/docs/wiki/HW%3AARM-System-Registers, MPIDR_EL1 Aff2 determines whether a core is an efficiency or performance core. Replace the compat data table with code that uses the aff2 value for fake DMIPS/MHz value, to hopefully maintain compatibility with future cores. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_platform.c diff -u src/sys/arch/arm/apple/apple_platform.c:1.2 src/sys/arch/arm/apple/apple_platform.c:1.3 --- src/sys/arch/arm/apple/apple_platform.c:1.2 Wed Sep 1 23:05:03 2021 +++ src/sys/arch/arm/apple/apple_platform.c Thu Sep 2 20:57:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_platform.c,v 1.2 2021/09/01 23:05:03 jmcneill Exp $ */ +/* $NetBSD: apple_platform.c,v 1.3 2021/09/02 20:57:57 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.2 2021/09/01 23:05:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.3 2021/09/02 20:57:57 jmcneill Exp $"); #include #include @@ -58,18 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: apple_platfo #include -/* - * Faux DMIPS/MHz values for known CPU types. The values themselves are - * unimportant except as relative comparisons between different CPUs on - * the same system. - */ -static const struct device_compatible_entry cpu_capacity_compat_data[] = { - /* Apple M1 */ - { .compat = "apple,icestorm", .value = 0 }, /* efficiency core */ - { .compat = "apple,firestorm", .value = 1 }, /* performance core */ - DEVICE_COMPAT_EOL -}; - extern struct bus_space arm_generic_bs_tag; struct arm32_bus_dma_tag apple_coherent_dma_tag; @@ -198,14 +186,21 @@ apple_platform_device_register(device_t if (device_is_a(self, "cpu")) { struct fdt_attach_args * const faa = aux; - const int phandle = faa->faa_phandle; - const struct device_compatible_entry *dce; + bus_addr_t cpuid; - dce = of_compatible_lookup(phandle, cpu_capacity_compat_data); - if (dce != NULL) { - prop_dictionary_set_uint32(prop, "capacity_dmips_mhz", - dce->value); + if (fdtbus_get_reg(faa->faa_phandle, 0, &cpuid, NULL) != 0) { + cpuid = 0; } + + /* + * On Apple M1 (and hopefully later models), AFF2 is 0 for + * efficiency and 1 for performance cores. Use this value + * to provide a fake DMIPS/MHz value -- the actual number + * only matters in relation to the value presented by other + * cores. + */ + const u_int aff2 = __SHIFTOUT(cpuid, MPIDR_AFF2); + prop_dictionary_set_uint32(prop, "capacity_dmips_mhz", aff2); return; }
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Thu Sep 2 20:57:57 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: apple: derive CPU speed from mpidr_el1 According to https://github.com/AsahiLinux/docs/wiki/HW%3AARM-System-Registers, MPIDR_EL1 Aff2 determines whether a core is an efficiency or performance core. Replace the compat data table with code that uses the aff2 value for fake DMIPS/MHz value, to hopefully maintain compatibility with future cores. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Wed Sep 1 23:05:03 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: Make the scheduler aware of the differences between efficiency and performance cores. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/apple/apple_platform.c diff -u src/sys/arch/arm/apple/apple_platform.c:1.1 src/sys/arch/arm/apple/apple_platform.c:1.2 --- src/sys/arch/arm/apple/apple_platform.c:1.1 Mon Aug 30 23:26:26 2021 +++ src/sys/arch/arm/apple/apple_platform.c Wed Sep 1 23:05:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_platform.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $ */ +/* $NetBSD: apple_platform.c,v 1.2 2021/09/01 23:05:03 jmcneill Exp $ */ /*- * Copyright (c) 2021 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.1 2021/08/30 23:26:26 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_platform.c,v 1.2 2021/09/01 23:05:03 jmcneill Exp $"); #include #include @@ -58,6 +58,18 @@ __KERNEL_RCSID(0, "$NetBSD: apple_platfo #include +/* + * Faux DMIPS/MHz values for known CPU types. The values themselves are + * unimportant except as relative comparisons between different CPUs on + * the same system. + */ +static const struct device_compatible_entry cpu_capacity_compat_data[] = { + /* Apple M1 */ + { .compat = "apple,icestorm", .value = 0 }, /* efficiency core */ + { .compat = "apple,firestorm", .value = 1 }, /* performance core */ + DEVICE_COMPAT_EOL +}; + extern struct bus_space arm_generic_bs_tag; struct arm32_bus_dma_tag apple_coherent_dma_tag; @@ -184,6 +196,19 @@ apple_platform_device_register(device_t uint8_t eaddr[ETHER_ADDR_LEN]; int len; + if (device_is_a(self, "cpu")) { + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + const struct device_compatible_entry *dce; + + dce = of_compatible_lookup(phandle, cpu_capacity_compat_data); + if (dce != NULL) { + prop_dictionary_set_uint32(prop, "capacity_dmips_mhz", + dce->value); + } + return; + } + if (device_is_a(self, "bge") && device_is_a(device_parent(self), "pci")) { struct pci_attach_args * const pa = aux;
CVS commit: src/sys/arch/arm/apple
Module Name:src Committed By: jmcneill Date: Wed Sep 1 23:05:03 UTC 2021 Modified Files: src/sys/arch/arm/apple: apple_platform.c Log Message: Make the scheduler aware of the differences between efficiency and performance cores. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/apple/apple_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.