diff --git a/lib/libc/gen/eventfd.c b/lib/libc/gen/eventfd.c index b757f82029a9..a9748fa54468 100644 --- a/lib/libc/gen/eventfd.c +++ b/lib/libc/gen/eventfd.c @@ -1,54 +1,54 @@ /*- * SPDX-License-Identifier: MIT * * Copyright (c) 2005-2020 Rich Felker, et al. - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include __FBSDID("$FreeBSD$"); #include "namespace.h" #include #include #include #include "un-namespace.h" #include "libc_private.h" int eventfd(unsigned int initval, int flags) { struct specialfd_eventfd args; args.initval = initval; args.flags = flags; return (__sys___specialfd(SPECIALFD_EVENTFD, &args, sizeof(args))); } int eventfd_read(int fd, eventfd_t *value) { return (sizeof(*value) == _read(fd, value, sizeof(*value)) ? 0 : -1); } int eventfd_write(int fd, eventfd_t value) { return (sizeof(value) == _write(fd, &value, sizeof(value)) ? 0 : -1); } diff --git a/lib/libc/sys/eventfd.2 b/lib/libc/sys/eventfd.2 index ae9e44efc853..ea0320db5e9b 100644 --- a/lib/libc/sys/eventfd.2 +++ b/lib/libc/sys/eventfd.2 @@ -1,208 +1,208 @@ .\" SPDX-License-Identifier: BSD-2-Clause .\" -.\" Copyright (c) 2020 Greg V +.\" Copyright (c) 2020 Val Packett .\" .\" 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 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd October 8, 2020 .Dt EVENTFD 2 .Os .Sh NAME .Nm eventfd .Nd create a file descriptor for event notification .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/eventfd.h .Ft int .Fn eventfd "unsigned int initval" "int flags" .Ft int .Fn eventfd_read "int fd" "eventfd_t *value" .Ft int .Fn eventfd_write "int fd" "eventfd_t value" .Sh DESCRIPTION .Fn eventfd creates a special file descriptor with event counter or semaphore semantics, designed for interprocess communication. The returned file descriptor refers to a kernel object containing an unsigned 64-bit integer counter, which is initialized with the value of the .Fa initval argument. .Pp The .Fa flags argument may contain the result of .Em or Ns 'ing the following values: .Pp .Bl -tag -width "EFD_SEMAPHORE" -compact .It Dv EFD_CLOEXEC set FD_CLOEXEC on the file descriptor .It Dv EFD_NONBLOCK do not block on read/write operations .It Dv EFD_SEMAPHORE use semaphore semantics .El .Pp File operations have the following semantics: .Bl -tag -width EFD_SEMAPHORE .It Xr read 2 If the counter is zero, the call blocks until the counter becomes non-zero, unless .Dv EFD_NONBLOCK was set, in which case it would fail with .Dv EAGAIN instead. .Pp If the counter is non-zero: .Bl -bullet .It If .Dv EFD_SEMAPHORE is not set, the current value of the counter is returned, and the value is reset to zero. .It If .Dv EFD_SEMAPHORE is set, the constant 1 is returned, and the value is decremented by 1. .El .Pp The numeric value is encoded as 64-bit (8 bytes) in host byte order. The .Xr read 2 call fails with .Dv EINVAL if there is less than 8 bytes available in the supplied buffer. .It Xr write 2 Adds the given value to the counter. The maximum value that can be stored in the counter is the maximum unsigned 64-bit integer value minus one (0xfffffffffffffffe). .Pp If the resulting value exceeds the maximum, the call would block until the value is reduced by .Xr read 2 , unless .Dv EFD_NONBLOCK was set, in which case it would fail with .Dv EAGAIN instead. .Pp The numeric value is encoded as 64-bit (8 bytes) in host byte order. The .Xr write 2 call fails with .Dv EINVAL if there is less than 8 bytes available in the supplied buffer, or if the value 0xffffffffffffffff is given. .It Xr poll 2 When receiving notifications via .Xr poll 2 / .Xr ppoll 2 / .Xr select 2 / .Xr pselect 2 / .Xr kqueue 2 , the following semantics apply: .Bl -bullet .It The file descriptor is readable when the counter is greater than zero. .It The file descriptor is writable when the counter is less than the maximum value. .El .El .Pp File descriptors created by .Fn eventfd are passable to other processes via .Xr sendmsg 2 and are preserved across .Xr fork 2 ; in both cases the descriptors refer to the same counter from both processes. Unless .Dv O_CLOEXEC flag was specified, the created file descriptor will remain open across .Xr execve 2 system calls; see .Xr close 2 , .Xr fcntl 2 and .Dv O_CLOEXEC description. .Pp .Fn eventfd_read and .Fn eventfd_write are thin wrappers around .Xr read 2 and .Xr write 2 system calls, provided for compatibility with glibc. .Sh RETURN VALUES If successful, .Fn eventfd returns a non-negative integer, termed a file descriptor. It returns \-1 on failure, and sets .Va errno to indicate the error. .Pp The .Fn eventfd_read and .Fn eventfd_write functions return 0 if the operation succeeded, -1 otherwise. .Sh ERRORS .Fn eventfd may fail with: .Bl -tag -width Er .It Bq Er EINVAL The .Fa flags argument given to .Fn eventfd has unknown bits set. .It Bq Er EMFILE The process has already reached its limit for open file descriptors. .It Bq Er ENFILE The system file table is full. .It Bq Er ENOMEM No memory was available to create the kernel object. .El .Sh SEE ALSO .Xr close 2 , .Xr kqueue 2 , .Xr poll 2 , .Xr read 2 , .Xr select 2 , .Xr write 2 .Sh STANDARDS The .Fn eventfd system call is non-standard. It is present in Linux. .Sh HISTORY The .Fn eventfd system call first appeared in .Fx 13.0 . diff --git a/share/man/man4/hgame.4 b/share/man/man4/hgame.4 index addf14d9f5c5..3eea4a285328 100644 --- a/share/man/man4/hgame.4 +++ b/share/man/man4/hgame.4 @@ -1,105 +1,105 @@ .\" Copyright (c) 2020 Vladimir Kondratyev .\" .\" 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 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd September 14, 2020 .Dt HGAME 4 .Os .Sh NAME .Nm hgame .Nd Generic HID game controller (joystick/gamepad) driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device hgame" .Cd "device hid" .Cd "device hidbus" .Cd "device hidmap" .Cd "device evdev" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent hgame_load="YES" .Ed .Sh DESCRIPTION The .Nm driver provides support for generic game controllers (joysticks/gamepads) that attach to the HID transport backend. See .Xr iichid 4 or .Xr usbhid 4 . .Pp The .Pa /dev/input/event* device presents the game controller as a .Ar evdev type device. .Sh SYSCTL VARIABLES The following variable is available as both .Xr sysctl 8 variable and .Xr loader 8 tunable: .Bl -tag -width indent .It Va dev.hgame.X.debug Debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is 0. .El .Pp It's default value is set with .Xr loader 8 tunable: .Bl -tag -width indent .It Va hw.hid.hgame.debug .El .Sh FILES .Bl -tag -width /dev/input/event* -compact .It Pa /dev/input/event* input event device node. .El .Sh SEE ALSO .Xr iichid 4 , .Xr usbhid 4 .Sh HISTORY The .Nm driver first appeared in .Fx 13.0. .Sh AUTHORS .An -nosplit The .Nm driver was written by -.An Greg V Aq Mt greg@unrelenting.technology . +.An Val Packett Aq Mt val@packett.cool . .Pp This manual page was written by .An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org . diff --git a/share/man/man4/hpen.4 b/share/man/man4/hpen.4 index a043169895ec..87e2439e64d9 100644 --- a/share/man/man4/hpen.4 +++ b/share/man/man4/hpen.4 @@ -1,112 +1,112 @@ .\" Copyright (c) 2020 Vladimir Kondratyev .\" .\" 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 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd September 14, 2020 .Dt HPEN 4 .Os .Sh NAME .Nm hpen .Nd MS Windows compatible HID pen tablet driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device hpen" .Cd "device hid" .Cd "device hidbus" .Cd "device hidmap" .Cd "device evdev" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent hpen_load="YES" .Ed .Sh DESCRIPTION The .Nm driver provides support for generic MS Windows compatible HID pen tablet and digitizer that attach to the HID transport backend. See .Xr iichid 4 or .Xr usbhid 4 . .Pp The .Pa /dev/input/event* device presents the pen as a .Ar evdev type device. .Sh SYSCTL VARIABLES The following variable is available as both .Xr sysctl 8 variable and .Xr loader 8 tunable: .Bl -tag -width indent .It Va dev.hpen.X.debug Debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is 0. .El .Pp It's default value is set with .Xr loader 8 tunable: .Bl -tag -width indent .It Va hw.hid.hpen.debug .El .Sh FILES .Bl -tag -width /dev/input/event* -compact .It Pa /dev/input/event* input event device node. .El .Sh SEE ALSO .Xr iichid 4 , .Xr usbhid 4 , .Xr xorg.conf 5 Pq Pa ports/x11/xorg .Sh BUGS .Nm cannot act like .Xr sysmouse 4 . .Pp Pen battery charge level reporting is not supported. .Sh HISTORY The .Nm driver first appeared in .Fx 13.0. .Sh AUTHORS .An -nosplit The .Nm driver was written by -.An Greg V Aq Mt greg@unrelenting.technology . +.An Val Packett Aq Mt val@packett.cool . .Pp This manual page was written by .An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org . diff --git a/share/man/man4/xb360gp.4 b/share/man/man4/xb360gp.4 index b19334cc3a0b..57afeb8fc949 100644 --- a/share/man/man4/xb360gp.4 +++ b/share/man/man4/xb360gp.4 @@ -1,98 +1,98 @@ .\" Copyright (c) 2020 Vladimir Kondratyev .\" .\" 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 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd September 16, 2020 .Dt XB360GP 4 .Os .Sh NAME .Nm xb360gp .Nd XBox 360 gamepad driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device xb360gp" .Cd "device hgame" .Cd "device hid" .Cd "device hidbus" .Cd "device hidmap" .Cd "device evdev" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent xb360gp_load="YES" .Ed .Sh DESCRIPTION The .Nm driver provides support for XBox 360 gamepad driver. .Pp The .Pa /dev/input/event* device presents the game controller as a .Ar evdev type device. .Sh SYSCTL VARIABLES The following variable is available as both .Xr sysctl 8 variable and .Xr loader 8 tunable: .Bl -tag -width indent .It Va dev.xb360gp.X.debug Debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is 0. .El .Pp It's default value is set with .Xr loader 8 tunable: .Bl -tag -width indent .It Va hw.hid.xb360gp.debug .El .Sh FILES .Bl -tag -width /dev/input/event* -compact .It Pa /dev/input/event* input event device node. .El .Sh HISTORY The .Nm driver first appeared in .Fx 13.0. .Sh AUTHORS .An -nosplit The .Nm driver was written by -.An Greg V Aq Mt greg@unrelenting.technology . +.An Val Packett Aq Mt val@packett.cool . .Pp This manual page was written by .An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org . diff --git a/sys/arm/arm/pmu_acpi.c b/sys/arm/arm/pmu_acpi.c index f11eacb5059d..c2aef28ab3d9 100644 --- a/sys/arm/arm/pmu_acpi.c +++ b/sys/arm/arm/pmu_acpi.c @@ -1,192 +1,192 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * Copyright (c) 2021 Ruslan Bukin * * 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 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 AUTHOR 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 #include #include #include #include #include #include #include #include "acpi_bus_if.h" #include "pmu.h" struct madt_ctx { struct pmu_softc *sc; int error; int i; }; static void madt_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) { ACPI_MADT_GENERIC_INTERRUPT *intr; struct intr_map_data_acpi *ad; struct intr_map_data *data; struct madt_ctx *ctx; struct pmu_softc *sc; struct pcpu *pcpu; int rid; int cpuid; int i; ctx = arg; sc = ctx->sc; rid = ctx->i; cpuid = -1; if (ctx->error) return; if (entry->Type != ACPI_MADT_TYPE_GENERIC_INTERRUPT) return; intr = (ACPI_MADT_GENERIC_INTERRUPT *)entry; for (i = 0; i < MAXCPU; i++) { pcpu = pcpu_find(i); if (pcpu != NULL && PCPU_GET_MPIDR(pcpu) == intr->ArmMpidr) { cpuid = i; break; } } if (cpuid == -1) { /* pcpu not found. */ device_printf(sc->dev, "MADT: could not find pcpu, " "ArmMpidr %lx\n", intr->ArmMpidr); return; } if (bootverbose) device_printf(sc->dev, "MADT: cpu %d (mpidr %lu) irq %d " "%s-triggered\n", cpuid, intr->ArmMpidr, intr->PerformanceInterrupt, (intr->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? "edge" : "level"); bus_set_resource(sc->dev, SYS_RES_IRQ, ctx->i, intr->PerformanceInterrupt, 1); sc->irq[ctx->i].res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); if (sc->irq[ctx->i].res == NULL) { device_printf(sc->dev, "Failed to allocate IRQ %d\n", ctx->i); ctx->error = ENXIO; return; } /* * BUS_CONFIG_INTR does nothing on arm64, so we manually set trigger * mode. */ data = rman_get_virtual(sc->irq[ctx->i].res); KASSERT(data->type == INTR_MAP_DATA_ACPI, ("Wrong data type")); ad = (struct intr_map_data_acpi *)data; ad->trig = (intr->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL; ad->pol = INTR_POLARITY_HIGH; if (!intr_is_per_cpu(sc->irq[ctx->i].res)) sc->irq[ctx->i].cpuid = cpuid; ctx->i++; } static void pmu_acpi_identify(driver_t *driver, device_t parent) { device_t dev; if (acpi_find_table(ACPI_SIG_MADT) == 0) return; dev = BUS_ADD_CHILD(parent, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST, "pmu", -1); if (dev == NULL) device_printf(parent, "pmu: Unable to add pmu child\n"); } static int pmu_acpi_probe(device_t dev) { device_set_desc(dev, "Performance Monitoring Unit"); return (BUS_PROBE_NOWILDCARD); } static int pmu_acpi_attach(device_t dev) { struct pmu_softc *sc; struct madt_ctx ctx; ACPI_TABLE_MADT *madt; int i; sc = device_get_softc(dev); sc->dev = dev; madt = acpi_map_table(acpi_find_table(ACPI_SIG_MADT), ACPI_SIG_MADT); if (madt == NULL) { device_printf(dev, "Unable to map the MADT table\n"); return (ENXIO); } /* We have to initialize cpuid to -1. */ for (i = 0; i < MAX_RLEN; i++) sc->irq[i].cpuid = -1; ctx.sc = sc; ctx.i = 0; ctx.error = 0; acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, madt_handler, &ctx); acpi_unmap_table(madt); if (ctx.error) return (ctx.error); return (pmu_attach(dev)); } static device_method_t pmu_acpi_methods[] = { DEVMETHOD(device_identify, pmu_acpi_identify), DEVMETHOD(device_probe, pmu_acpi_probe), DEVMETHOD(device_attach, pmu_acpi_attach), DEVMETHOD_END, }; DEFINE_CLASS_0(pmu, pmu_acpi_driver, pmu_acpi_methods, sizeof(struct pmu_softc)); DRIVER_MODULE(pmu, acpi, pmu_acpi_driver, 0, 0); diff --git a/sys/arm64/rockchip/clk/rk3399_cru.c b/sys/arm64/rockchip/clk/rk3399_cru.c index 296d68e1091a..7f6bf3824748 100644 --- a/sys/arm64/rockchip/clk/rk3399_cru.c +++ b/sys/arm64/rockchip/clk/rk3399_cru.c @@ -1,1276 +1,1276 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2018 Emmanuel Vadot - * Copyright (c) 2018 Greg V + * Copyright (c) 2018 Val Packett * * 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. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define CRU_CLKSEL_CON(x) (0x100 + (x) * 0x4) #define CRU_CLKGATE_CON(x) (0x300 + (x) * 0x4) /* GATES */ static struct rk_cru_gate rk3399_gates[] = { /* CRU_CLKGATE_CON0 */ /* 15-8 unused */ GATE(SCLK_PVTM_CORE_L, "clk_pvtm_core_l", "xin24m", 0, 7), GATE(0, "pclk_dbg_core_l", "pclk_dbg_core_l_c", 0, 6), GATE(0, "atclk_core_l", "atclk_core_l_c", 0, 5), GATE(0, "aclkm_core_l", "aclkm_core_l_c", 0, 4), GATE(0, "clk_core_l_gpll_src", "gpll", 0, 3), GATE(0, "clk_core_l_dpll_src", "dpll", 0, 2), GATE(0, "clk_core_l_bpll_src", "bpll", 0, 1), GATE(0, "clk_core_l_lpll_src", "lpll", 0, 0), /* CRU_CLKGATE_CON1 */ /* 15 - 8 unused */ GATE(SCLK_PVTM_CORE_B, "clk_pvtm_core_b", "xin24m", 1, 7), GATE(0, "pclk_dbg_core_b","pclk_dbg_core_b_c", 1, 6), GATE(0, "atclk_core_b", "atclk_core_b_c", 1, 5), GATE(0, "aclkm_core_b", "aclkm_core_b_c", 1, 4), GATE(0, "clk_core_b_gpll_src", "gpll", 1, 3), GATE(0, "clk_core_b_dpll_src", "dpll", 1, 2), GATE(0, "clk_core_b_bpll_src", "bpll", 1, 1), GATE(0, "clk_core_b_lpll_src", "lpll", 1, 0), /* CRU_CLKGATE_CON2 */ /* 15 - 11 unused */ GATE(0, "npll_cs", "npll", 2, 10), GATE(0, "gpll_cs", "gpll", 2, 9), GATE(0, "cpll_cs", "cpll", 2, 8), GATE(SCLK_CCI_TRACE, "clk_cci_trace", "clk_cci_trace_c", 2, 7), GATE(0, "gpll_cci_trace", "gpll", 2, 6), GATE(0, "cpll_cci_trace", "cpll", 2, 5), GATE(0, "aclk_cci_pre", "aclk_cci_pre_c", 2, 4), GATE(0, "vpll_aclk_cci_src", "vpll", 2, 3), GATE(0, "npll_aclk_cci_src", "npll", 2, 2), GATE(0, "gpll_aclk_cci_src", "gpll", 2, 1), GATE(0, "cpll_aclk_cci_src", "cpll", 2, 0), /* CRU_CLKGATE_CON3 */ /* 15 - 8 unused */ GATE(0, "aclk_center", "aclk_center_c", 3, 7), /* 6 unused */ /* 5 unused */ GATE(PCLK_DDR, "pclk_ddr", "pclk_ddr_c", 3, 4), GATE(0, "clk_ddrc_gpll_src", "gpll", 3, 3), GATE(0, "clk_ddrc_dpll_src", "dpll", 3, 2), GATE(0, "clk_ddrc_bpll_src", "bpll", 3, 1), GATE(0, "clk_ddrc_lpll_src", "lpll", 3, 0), /* CRU_CLKGATE_CON4 */ /* 15 - 12 unused */ GATE(SCLK_PVTM_DDR, "clk_pvtm_ddr", "xin24m", 4, 11), GATE(0, "clk_rga_core", "clk_rga_core_c", 4, 10), GATE(0, "hclk_rga_pre", "hclk_rga_pre_c", 4, 9), GATE(0, "aclk_rga_pre", "aclk_rga_pre_c", 4, 8), GATE(0, "hclk_iep_pre", "hclk_iep_pre_c", 4, 7), GATE(0, "aclk_iep_pre", "aclk_iep_pre_c", 4, 6), GATE(SCLK_VDU_CA, "clk_vdu_ca", "clk_vdu_ca_c", 4, 5), GATE(SCLK_VDU_CORE, "clk_vdu_core", "clk_vdu_core_c", 4, 4), GATE(0, "hclk_vdu_pre", "hclk_vdu_pre_c", 4, 3), GATE(0, "aclk_vdu_pre", "aclk_vdu_pre_c", 4, 2), GATE(0, "hclk_vcodec_pre", "hclk_vcodec_pre_c", 4, 1), GATE(0, "aclk_vcodec_pre", "aclk_vcodec_pre_c", 4, 0), /* CRU_CLKGATE_CON5 */ /* 15 - 10 unused */ GATE(SCLK_MAC_TX, "clk_rmii_tx", "clk_rmii_src", 5, 9), GATE(SCLK_MAC_RX, "clk_rmii_rx", "clk_rmii_src", 5, 8), GATE(SCLK_MACREF, "clk_mac_ref", "clk_rmii_src", 5, 7), GATE(SCLK_MACREF_OUT, "clk_mac_refout", "clk_rmii_src", 5, 6), GATE(SCLK_MAC, "clk_gmac", "clk_gmac_c", 5, 5), GATE(PCLK_PERIHP, "pclk_perihp", "pclk_perihp_c", 5, 4), GATE(HCLK_PERIHP, "hclk_perihp", "hclk_perihp_c", 5, 3), GATE(ACLK_PERIHP, "aclk_perihp", "aclk_perihp_c", 5, 2), GATE(0, "cpll_aclk_perihp_src", "cpll", 5, 1), GATE(0, "gpll_aclk_perihp_src", "gpll", 5, 0), /* CRU_CLKGATE_CON6 */ /* 15 unused */ GATE(SCLK_EMMC, "clk_emmc", "clk_emmc_c", 6, 14), GATE(0, "cpll_aclk_emmc_src", "cpll", 6, 13), GATE(0, "gpll_aclk_emmc_src", "gpll", 6, 12), GATE(0, "pclk_gmac_pre", "pclk_gmac_pre_c", 6, 11), GATE(0, "aclk_gmac_pre", "aclk_gmac_pre_c", 6, 10), GATE(0, "cpll_aclk_gmac_src", "cpll", 6, 9), GATE(0, "gpll_aclk_gmac_src", "gpll", 6, 8), /* 7 unused */ GATE(SCLK_USB2PHY1_REF, "clk_usb2phy1_ref", "xin24m", 6, 6), GATE(SCLK_USB2PHY0_REF, "clk_usb2phy0_ref", "xin24m", 6, 5), GATE(SCLK_HSICPHY, "clk_hsicphy", "clk_hsicphy_c", 6, 4), GATE(0, "clk_pcie_core_cru", "clk_pcie_core_cru_c", 6, 3), GATE(SCLK_PCIE_PM, "clk_pcie_pm", "clk_pcie_pm_c", 6, 2), GATE(SCLK_SDMMC, "clk_sdmmc", "clk_sdmmc_c", 6, 1), GATE(SCLK_SDIO, "clk_sdio", "clk_sdio_c", 6, 0), /* CRU_CLKGATE_CON7 */ /* 15 - 10 unused */ GATE(FCLK_CM0S, "fclk_cm0s", "fclk_cm0s_c", 7, 9), GATE(SCLK_CRYPTO1, "clk_crypto1", "clk_crypto1_c", 7, 8), GATE(SCLK_CRYPTO0, "clk_crypto0", "clk_crypto0_c", 7, 7), GATE(0, "cpll_fclk_cm0s_src", "cpll", 7, 6), GATE(0, "gpll_fclk_cm0s_src", "gpll", 7, 5), GATE(PCLK_PERILP0, "pclk_perilp0", "pclk_perilp0_c", 7, 4), GATE(HCLK_PERILP0, "hclk_perilp0", "hclk_perilp0_c", 7, 3), GATE(ACLK_PERILP0, "aclk_perilp0", "aclk_perilp0_c", 7, 2), GATE(0, "cpll_aclk_perilp0_src", "cpll", 7, 1), GATE(0, "gpll_aclk_perilp0_src", "gpll", 7, 0), /* CRU_CLKGATE_CON8 */ GATE(SCLK_SPDIF_8CH, "clk_spdif", "clk_spdif_mux", 8, 15), GATE(0, "clk_spdif_frac", "clk_spdif_frac_c", 8, 14), GATE(0, "clk_spdif_div", "clk_spdif_div_c", 8, 13), GATE(SCLK_I2S_8CH_OUT, "clk_i2sout", "clk_i2sout_c", 8, 12), GATE(SCLK_I2S2_8CH, "clk_i2s2", "clk_i2s2_mux", 8, 11), GATE(0, "clk_i2s2_frac", "clk_i2s2_frac_c", 8, 10), GATE(0, "clk_i2s2_div", "clk_i2s2_div_c", 8, 9), GATE(SCLK_I2S1_8CH, "clk_i2s1", "clk_i2s1_mux", 8, 8), GATE(0, "clk_i2s1_frac", "clk_i2s1_frac_c", 8, 7), GATE(0, "clk_i2s1_div", "clk_i2s1_div_c", 8, 6), GATE(SCLK_I2S0_8CH, "clk_i2s0", "clk_i2s0_mux", 8, 5), GATE(0, "clk_i2s0_frac","clk_i2s0_frac_c", 8, 4), GATE(0, "clk_i2s0_div","clk_i2s0_div_c", 8, 3), GATE(PCLK_PERILP1, "pclk_perilp1", "pclk_perilp1_c", 8, 2), GATE(HCLK_PERILP1, "cpll_hclk_perilp1_src", "cpll", 8, 1), GATE(0, "gpll_hclk_perilp1_src", "gpll", 8, 0), /* CRU_CLKGATE_CON9 */ GATE(SCLK_SPI4, "clk_spi4", "clk_spi4_c", 9, 15), GATE(SCLK_SPI2, "clk_spi2", "clk_spi2_c", 9, 14), GATE(SCLK_SPI1, "clk_spi1", "clk_spi1_c", 9, 13), GATE(SCLK_SPI0, "clk_spi0", "clk_spi0_c", 9, 12), GATE(SCLK_SARADC, "clk_saradc", "clk_saradc_c", 9, 11), GATE(SCLK_TSADC, "clk_tsadc", "clk_tsadc_c", 9, 10), /* 9 - 8 unused */ GATE(0, "clk_uart3_frac", "clk_uart3_frac_c", 9, 7), GATE(0, "clk_uart3_div", "clk_uart3_div_c", 9, 6), GATE(0, "clk_uart2_frac", "clk_uart2_frac_c", 9, 5), GATE(0, "clk_uart2_div", "clk_uart2_div_c", 9, 4), GATE(0, "clk_uart1_frac", "clk_uart1_frac_c", 9, 3), GATE(0, "clk_uart1_div", "clk_uart1_div_c", 9, 2), GATE(0, "clk_uart0_frac", "clk_uart0_frac_c", 9, 1), GATE(0, "clk_uart0_div", "clk_uart0_div_c", 9, 0), /* CRU_CLKGATE_CON10 */ GATE(SCLK_VOP1_PWM, "clk_vop1_pwm", "clk_vop1_pwm_c", 10, 15), GATE(SCLK_VOP0_PWM, "clk_vop0_pwm", "clk_vop0_pwm_c", 10, 14), GATE(DCLK_VOP0_DIV, "dclk_vop0_div", "dclk_vop0_div_c", 10, 12), GATE(DCLK_VOP1_DIV, "dclk_vop1_div", "dclk_vop1_div_c", 10, 13), GATE(0, "hclk_vop1_pre", "hclk_vop1_pre_c", 10, 11), GATE(ACLK_VOP1_PRE, "aclk_vop1_pre", "aclk_vop1_pre_c", 10, 10), GATE(0, "hclk_vop0_pre", "hclk_vop0_pre_c", 10, 9), GATE(ACLK_VOP0_PRE, "aclk_vop0_pre", "aclk_vop0_pre_c", 10, 8), GATE(0, "clk_cifout_src", "clk_cifout_src_c", 10, 7), GATE(SCLK_SPDIF_REC_DPTX, "clk_spdif_rec_dptx", "clk_spdif_rec_dptx_c", 10, 6), GATE(SCLK_I2C7, "clk_i2c7", "clk_i2c7_c", 10, 5), GATE(SCLK_I2C3, "clk_i2c3", "clk_i2c3_c", 10, 4), GATE(SCLK_I2C6, "clk_i2c6", "clk_i2c6_c", 10, 3), GATE(SCLK_I2C2, "clk_i2c2", "clk_i2c2_c", 10, 2), GATE(SCLK_I2C5, "clk_i2c5", "clk_i2c5_c", 10, 1), GATE(SCLK_I2C1, "clk_i2c1", "clk_i2c1_c", 10, 0), /* CRU_CLKGATE_CON11 */ GATE(SCLK_MIPIDPHY_CFG, "clk_mipidphy_cfg", "xin24m", 11, 15), GATE(SCLK_MIPIDPHY_REF, "clk_mipidphy_ref", "xin24m", 11, 14), /* 13-12 unused */ GATE(PCLK_EDP, "pclk_edp", "pclk_edp_c", 11, 11), GATE(PCLK_HDCP, "pclk_hdcp", "pclk_hdcp_c", 11, 10), /* 9 unuwsed */ GATE(SCLK_DP_CORE, "clk_dp_core", "clk_dp_core_c", 11, 8), GATE(SCLK_HDMI_CEC, "clk_hdmi_cec", "clk_hdmi_cec_c", 11, 7), GATE(SCLK_HDMI_SFR, "clk_hdmi_sfr", "xin24m", 11, 6), GATE(SCLK_ISP1, "clk_isp1", "clk_isp1_c", 11, 5), GATE(SCLK_ISP0, "clk_isp0", "clk_isp0_c", 11, 4), GATE(HCLK_HDCP, "hclk_hdcp", "hclk_hdcp_c", 11, 3), GATE(ACLK_HDCP, "aclk_hdcp", "aclk_hdcp_c", 11, 2), GATE(PCLK_VIO, "pclk_vio", "pclk_vio_c", 11, 1), GATE(ACLK_VIO, "aclk_vio", "aclk_vio_c", 11, 0), /* CRU_CLKGATE_CON12 */ /* 15 - 14 unused */ GATE(HCLK_SD, "hclk_sd", "hclk_sd_c", 12, 13), GATE(ACLK_GIC_PRE, "aclk_gic_pre", "aclk_gic_pre_c", 12, 12), GATE(HCLK_ISP1, "hclk_isp1", "hclk_isp1_c", 12, 11), GATE(ACLK_ISP1, "aclk_isp1", "aclk_isp1_c", 12, 10), GATE(HCLK_ISP0, "hclk_isp0", "hclk_isp0_c", 12, 9), GATE(ACLK_ISP0, "aclk_isp0", "aclk_isp0_c", 12, 8), /* 7 unused */ GATE(SCLK_PCIEPHY_REF100M, "clk_pciephy_ref100m", "clk_pciephy_ref100m_c", 12, 6), /* 5 unused */ GATE(SCLK_USB3OTG1_SUSPEND, "clk_usb3otg1_suspend", "clk_usb3otg1_suspend_c", 12, 4), GATE(SCLK_USB3OTG0_SUSPEND, "clk_usb3otg0_suspend", "clk_usb3otg0_suspend_c", 12, 3), GATE(SCLK_USB3OTG1_REF, "clk_usb3otg1_ref", "xin24m", 12, 2), GATE(SCLK_USB3OTG0_REF, "clk_usb3otg0_ref", "xin24m", 12, 1), GATE(ACLK_USB3, "aclk_usb3", "aclk_usb3_c", 12, 0), /* CRU_CLKGATE_CON13 */ GATE(SCLK_TESTCLKOUT2, "clk_testout2", "clk_testout2_c", 13, 15), GATE(SCLK_TESTCLKOUT1, "clk_testout1", "clk_testout1_c", 13, 14), GATE(SCLK_SPI5, "clk_spi5", "clk_spi5_c", 13, 13), GATE(0, "clk_usbphy0_480m_src", "clk_usbphy0_480m", 13, 12), GATE(0, "clk_usbphy1_480m_src", "clk_usbphy1_480m", 13, 12), GATE(0, "clk_test", "clk_test_c", 13, 11), /* 10 unused */ GATE(0, "clk_test_frac", "clk_test_frac_c", 13, 9), /* 8 unused */ GATE(SCLK_UPHY1_TCPDCORE, "clk_uphy1_tcpdcore", "clk_uphy1_tcpdcore_c", 13, 7), GATE(SCLK_UPHY1_TCPDPHY_REF, "clk_uphy1_tcpdphy_ref", "clk_uphy1_tcpdphy_ref_c", 13, 6), GATE(SCLK_UPHY0_TCPDCORE, "clk_uphy0_tcpdcore", "clk_uphy0_tcpdcore_c", 13, 5), GATE(SCLK_UPHY0_TCPDPHY_REF, "clk_uphy0_tcpdphy_ref", "clk_uphy0_tcpdphy_ref_c", 13, 4), /* 3 - 2 unused */ GATE(SCLK_PVTM_GPU, "aclk_pvtm_gpu", "xin24m", 13, 1), GATE(0, "aclk_gpu_pre", "aclk_gpu_pre_c", 13, 0), /* CRU_CLKGATE_CON14 */ /* 15 - 14 unused */ GATE(ACLK_PERF_CORE_L, "aclk_perf_core_l", "aclkm_core_l", 14, 13), GATE(ACLK_CORE_ADB400_CORE_L_2_CCI500, "aclk_core_adb400_core_l_2_cci500", "aclkm_core_l", 14, 12), GATE(ACLK_GIC_ADB400_CORE_L_2_GIC, "aclk_core_adb400_core_l_2_gic", "armclkl", 14, 11), GATE(ACLK_GIC_ADB400_GIC_2_CORE_L, "aclk_core_adb400_gic_2_core_l", "armclkl", 14, 10), GATE(0, "clk_dbg_pd_core_l", "armclkl", 14, 9), /* 8 - 7 unused */ GATE(ACLK_PERF_CORE_B, "aclk_perf_core_b", "aclkm_core_b", 14, 6), GATE(ACLK_CORE_ADB400_CORE_B_2_CCI500, "aclk_core_adb400_core_b_2_cci500", "aclkm_core_b", 14, 5), GATE(ACLK_GIC_ADB400_CORE_B_2_GIC, "aclk_core_adb400_core_b_2_gic", "armclkb", 14, 4), GATE(ACLK_GIC_ADB400_GIC_2_CORE_B, "aclk_core_adb400_gic_2_core_b", "armclkb", 14, 3), GATE(0, "pclk_dbg_cxcs_pd_core_b", "pclk_dbg_core_b", 14, 2), GATE(0, "clk_dbg_pd_core_b", "armclkb", 14, 1), /* 0 unused */ /* CRU_CLKGATE_CON15 */ /* 15 - 8 unused */ GATE(ACLK_CCI_GRF, "aclk_cci_grf", "aclk_cci_pre", 15, 7), GATE(0, "clk_dbg_noc", "clk_cs", 15, 6), GATE(0, "clk_dbg_cxcs", "clk_cs", 15, 5), GATE(ACLK_CCI_NOC1, "aclk_cci_noc1", "aclk_cci_pre", 15, 4), GATE(ACLK_CCI_NOC0, "aclk_cci_noc0", "aclk_cci_pre", 15, 3), GATE(ACLK_CCI, "aclk_cci", "aclk_cci_pre", 15, 2), GATE(ACLK_ADB400M_PD_CORE_B, "aclk_adb400m_pd_core_b", "aclk_cci_pre", 15, 1), GATE(ACLK_ADB400M_PD_CORE_L, "aclk_adb400m_pd_core_l", "aclk_cci_pre", 15, 0), /* CRU_CLKGATE_CON16 */ /* 15 - 12 unused */ GATE(HCLK_RGA_NOC, "hclk_rga_noc", "hclk_rga_pre", 16, 11), GATE(HCLK_RGA, "hclk_rga", "hclk_rga_pre", 16, 10), GATE(ACLK_RGA_NOC, "aclk_rga_noc", "aclk_rga_pre", 16, 9), GATE(ACLK_RGA, "aclk_rga", "aclk_rga_pre", 16, 8), /* 7 - 4 unused */ GATE(HCLK_IEP_NOC, "hclk_iep_noc", "hclk_iep_pre", 16, 3), GATE(HCLK_IEP, "hclk_iep", "hclk_iep_pre", 16, 2), GATE(ACLK_IEP_NOC, "aclk_iep_noc", "aclk_iep_pre", 16, 1), GATE(ACLK_IEP, "aclk_iep", "aclk_iep_pre", 16, 0), /* CRU_CLKGATE_CON17 */ /* 15 - 12 unused */ GATE(HCLK_VDU_NOC, "hclk_vdu_noc", "hclk_vdu_pre", 17, 11), GATE(HCLK_VDU, "hclk_vdu", "hclk_vdu_pre", 17, 10), GATE(ACLK_VDU_NOC, "aclk_vdu_noc", "aclk_vdu_pre", 17, 9), GATE(ACLK_VDU, "aclk_vdu", "aclk_vdu_pre", 17, 8), GATE(0, "hclk_vcodec_noc", "hclk_vcodec_pre", 17, 3), GATE(HCLK_VCODEC, "hclk_vcodec", "hclk_vcodec_pre", 17, 2), GATE(0, "aclk_vcodec_noc", "aclk_vcodec_pre", 17, 1), GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 17, 0), /* CRU_CLKGATE_CON18 */ GATE(PCLK_CIC, "pclk_cic", "pclk_ddr", 18, 15), GATE(0, "clk_ddr_mon_timer", "xin24m", 18, 14), GATE(0, "clk_ddr_mon", "clk_ddrc_div2", 18, 13), GATE(PCLK_DDR_MON, "pclk_ddr_mon", "pclk_ddr", 18, 12), GATE(0, "clk_ddr_cic", "clk_ddrc_div2", 18, 11), GATE(PCLK_CENTER_MAIN_NOC, "pclk_center_main_noc", "pclk_ddr", 18, 10), GATE(0, "clk_ddrcfg_msch1", "clk_ddrc_div2", 18, 9), GATE(0, "clk_ddrphy1", "clk_ddrc_div2", 18, 8), GATE(0, "clk_ddrphy_ctrl1", "clk_ddrc_div2", 18, 7), GATE(0, "clk_ddrc1", "clk_ddrc_div2", 18, 6), GATE(0, "clk_ddr1_msch", "clk_ddrc_div2", 18, 5), GATE(0, "clk_ddrcfg_msch0", "clk_ddrc_div2", 18, 4), GATE(0, "clk_ddrphy0", "clk_ddrc_div2", 18, 3), GATE(0, "clk_ddrphy_ctrl0", "clk_ddrc_div2", 18, 2), GATE(0, "clk_ddrc0", "clk_ddrc_div2", 18, 1), /* CRU_CLKGATE_CON19 */ /* 15 - 3 unused */ GATE(PCLK_DDR_SGRF, "pclk_ddr_sgrf", "pclk_ddr", 19, 2), GATE(ACLK_CENTER_PERI_NOC, "aclk_center_peri_noc", "aclk_center", 19, 1), GATE(ACLK_CENTER_MAIN_NOC, "aclk_center_main_noc", "aclk_center", 19, 0), /* CRU_CLKGATE_CON20 */ GATE(0, "hclk_ahb1tom", "hclk_perihp", 20, 15), GATE(0, "pclk_perihp_noc", "pclk_perihp", 20, 14), GATE(0, "hclk_perihp_noc", "hclk_perihp", 20, 13), GATE(0, "aclk_perihp_noc", "aclk_perihp", 20, 12), GATE(PCLK_PCIE, "pclk_pcie", "pclk_perihp", 20, 11), GATE(ACLK_PCIE, "aclk_pcie", "aclk_perihp", 20, 10), GATE(HCLK_HSIC, "hclk_hsic", "hclk_perihp", 20, 9), GATE(HCLK_HOST1_ARB, "hclk_host1_arb", "hclk_perihp", 20, 8), GATE(HCLK_HOST1, "hclk_host1", "hclk_perihp", 20, 7), GATE(HCLK_HOST0_ARB, "hclk_host0_arb", "hclk_perihp", 20, 6), GATE(HCLK_HOST0, "hclk_host0", "hclk_perihp", 20, 5), GATE(PCLK_PERIHP_GRF, "pclk_perihp_grf", "pclk_perihp", 20, 4), GATE(ACLK_PERF_PCIE, "aclk_perf_pcie", "aclk_perihp", 20, 2), /* 1 - 0 unused */ /* CRU_CLKGATE_CON21 */ /* 15 - 10 unused */ GATE(PCLK_UPHY1_TCPD_G, "pclk_uphy1_tcpd_g", "pclk_alive", 21, 9), GATE(PCLK_UPHY1_TCPHY_G, "pclk_uphy1_tcphy_g", "pclk_alive", 21, 8), /* 7 unused */ GATE(PCLK_UPHY0_TCPD_G, "pclk_uphy0_tcpd_g", "pclk_alive", 21, 6), GATE(PCLK_UPHY0_TCPHY_G, "pclk_uphy0_tcphy_g", "pclk_alive", 21, 5), GATE(PCLK_USBPHY_MUX_G, "pclk_usbphy_mux_g", "pclk_alive", 21, 4), GATE(SCLK_DPHY_RX0_CFG, "clk_dphy_rx0_cfg", "clk_mipidphy_cfg", 21, 3), GATE(SCLK_DPHY_TX1RX1_CFG, "clk_dphy_tx1rx1_cfg", "clk_mipidphy_cfg", 21, 2), GATE(SCLK_DPHY_TX0_CFG, "clk_dphy_tx0_cfg", "clk_mipidphy_cfg", 21, 1), GATE(SCLK_DPHY_PLL, "clk_dphy_pll", "clk_mipidphy_ref", 21, 0), /* CRU_CLKGATE_CON22 */ GATE(PCLK_EFUSE1024S, "pclk_efuse1024s", "pclk_perilp1", 22, 15), GATE(PCLK_EFUSE1024NS, "pclk_efuse1024ns", "pclk_perilp1", 22, 14), GATE(PCLK_TSADC, "pclk_tsadc", "pclk_perilp1", 22, 13), GATE(PCLK_SARADC, "pclk_saradc", "pclk_perilp1", 22, 12), GATE(PCLK_MAILBOX0, "pclk_mailbox0", "pclk_perilp1", 22, 11), GATE(PCLK_I2C3, "pclk_i2c3", "pclk_perilp1", 22, 10), GATE(PCLK_I2C2, "pclk_i2c2", "pclk_perilp1", 22, 9), GATE(PCLK_I2C6, "pclk_i2c6", "pclk_perilp1", 22, 8), GATE(PCLK_I2C5, "pclk_i2c5", "pclk_perilp1", 22, 7), GATE(PCLK_I2C1, "pclk_i2c1", "pclk_perilp1", 22, 6), GATE(PCLK_I2C7, "pclk_i2c7", "pclk_perilp1", 22, 5), GATE(PCLK_UART3, "pclk_uart3", "pclk_perilp1", 22, 3), GATE(PCLK_UART2, "pclk_uart2", "pclk_perilp1", 22, 2), GATE(PCLK_UART1, "pclk_uart1", "pclk_perilp1", 22, 1), GATE(PCLK_UART0, "pclk_uart0", "pclk_perilp1", 22, 0), /* CRU_CLKGATE_CON23 */ /* 15 - 14 unused */ GATE(PCLK_SPI4, "pclk_spi4", "pclk_perilp1", 23, 13), GATE(PCLK_SPI2, "pclk_spi2", "pclk_perilp1", 23, 12), GATE(PCLK_SPI1, "pclk_spi1", "pclk_perilp1", 23, 11), GATE(PCLK_SPI0, "pclk_spi0", "pclk_perilp1", 23, 10), GATE(PCLK_DCF, "pclk_dcf", "pclk_perilp0", 23, 9), GATE(ACLK_DCF, "aclk_dcf", "aclk_perilp0", 23, 8), GATE(SCLK_INTMEM5, "clk_intmem5", "aclk_perilp0", 23, 7), GATE(SCLK_INTMEM4, "clk_intmem4", "aclk_perilp0", 23, 6), GATE(SCLK_INTMEM3, "clk_intmem3", "aclk_perilp0", 23, 5), GATE(SCLK_INTMEM2, "clk_intmem2", "aclk_perilp0", 23, 4), GATE(SCLK_INTMEM1, "clk_intmem1", "aclk_perilp0", 23, 3), GATE(SCLK_INTMEM0, "clk_intmem0", "aclk_perilp0", 23, 2), GATE(ACLK_TZMA, "aclk_tzma", "aclk_perilp0", 23, 1), GATE(ACLK_INTMEM, "aclk_intmem", "aclk_perilp0", 23, 0), /* CRU_CLKGATE_CON24 */ GATE(HCLK_S_CRYPTO1, "hclk_s_crypto1", "hclk_perilp0", 24, 15), GATE(HCLK_M_CRYPTO1, "hclk_m_crypto1", "hclk_perilp0", 24, 14), GATE(PCLK_PERIHP_GRF, "pclk_perilp_sgrf", "pclk_perilp1", 24, 13), GATE(SCLK_M0_PERILP_DEC, "clk_m0_perilp_dec", "fclk_cm0s", 24, 11), GATE(DCLK_M0_PERILP, "dclk_m0_perilp", "fclk_cm0s", 24, 10), GATE(HCLK_M0_PERILP, "hclk_m0_perilp", "fclk_cm0s", 24, 9), GATE(SCLK_M0_PERILP, "sclk_m0_perilp", "fclk_cm0s", 24, 8), /* 7 - unused */ GATE(HCLK_S_CRYPTO0, "hclk_s_crypto0", "hclk_perilp0", 24, 6), GATE(HCLK_M_CRYPTO0, "hclk_m_crypto0", "hclk_perilp0", 24, 5), GATE(HCLK_ROM, "hclk_rom", "hclk_perilp0", 24, 4), /* 3 - 0 unused */ /* CRU_CLKGATE_CON25 */ /* 15 - 13 unused */ GATE(0, "hclk_sdio_noc", "hclk_perilp1", 25, 12), GATE(HCLK_M0_PERILP_NOC, "hclk_m0_perilp_noc", "fclk_cm0s", 25, 11), GATE(0, "pclk_perilp1_noc", "pclk_perilp1", 25, 10), GATE(0, "hclk_perilp1_noc", "hclk_perilp1", 25, 9), GATE(HCLK_PERILP0_NOC, "hclk_perilp0_noc", "hclk_perilp0", 25, 8), GATE(ACLK_PERILP0_NOC, "aclk_perilp0_noc", "aclk_perilp0", 25, 7), GATE(ACLK_DMAC1_PERILP, "aclk_dmac1_perilp", "aclk_perilp0", 25, 6), GATE(ACLK_DMAC0_PERILP, "aclk_dmac0_perilp", "aclk_perilp0", 25, 5), /* 4 - 0 unused */ /* CRU_CLKGATE_CON26 */ /* 15 - 12 unused */ GATE(SCLK_TIMER11, "clk_timer11", "xin24m", 26, 11), GATE(SCLK_TIMER10, "clk_timer10", "xin24m", 26, 10), GATE(SCLK_TIMER09, "clk_timer09", "xin24m", 26, 9), GATE(SCLK_TIMER08, "clk_timer08", "xin24m", 26, 8), GATE(SCLK_TIMER07, "clk_timer07", "xin24m", 26, 7), GATE(SCLK_TIMER06, "clk_timer06", "xin24m", 26, 6), GATE(SCLK_TIMER05, "clk_timer05", "xin24m", 26, 5), GATE(SCLK_TIMER04, "clk_timer04", "xin24m", 26, 4), GATE(SCLK_TIMER03, "clk_timer03", "xin24m", 26, 3), GATE(SCLK_TIMER02, "clk_timer02", "xin24m", 26, 2), GATE(SCLK_TIMER01, "clk_timer01", "xin24m", 26, 1), GATE(SCLK_TIMER00, "clk_timer00", "xin24m", 26, 0), /* CRU_CLKGATE_CON27 */ /* 15 - 9 unused */ GATE(ACLK_ISP1_WRAPPER, "aclk_isp1_wrapper", "hclk_isp1", 27, 8), GATE(HCLK_ISP1_WRAPPER, "hclk_isp1_wrapper", "aclk_isp0", 27, 7), GATE(PCLK_ISP1_WRAPPER, "pclkin_isp1_wrapper", "pclkin_cif", 27, 6), GATE(ACLK_ISP0_WRAPPER, "aclk_isp0_wrapper", "aclk_isp0", 27, 5), GATE(HCLK_ISP0_WRAPPER, "hclk_isp0_wrapper", "hclk_isp0", 27, 4), GATE(ACLK_ISP1_NOC, "aclk_isp1_noc", "aclk_isp1", 27, 3), GATE(HCLK_ISP1_NOC, "hclk_isp1_noc", "hclk_isp1", 27, 2), GATE(ACLK_ISP0_NOC, "aclk_isp0_noc", "aclk_isp0", 27, 1), GATE(HCLK_ISP0_NOC, "hclk_isp0_noc", "hclk_isp0", 27, 0), /* CRU_CLKGATE_CON28 */ /* 15 - 8 unused */ GATE(ACLK_VOP1, "aclk_vop1", "aclk_vop1_pre", 28, 7), GATE(HCLK_VOP1, "hclk_vop1", "hclk_vop1_pre", 28, 6), GATE(ACLK_VOP1_NOC, "aclk_vop1_noc", "aclk_vop1_pre", 28, 5), GATE(HCLK_VOP1_NOC, "hclk_vop1_noc", "hclk_vop1_pre", 28, 4), GATE(ACLK_VOP0, "aclk_vop0", "aclk_vop0_pre", 28, 3), GATE(HCLK_VOP0, "hclk_vop0", "hclk_vop0_pre", 28, 2), GATE(ACLK_VOP0_NOC, "aclk_vop0_noc", "aclk_vop0_pre", 28, 1), GATE(HCLK_VOP0_NOC, "hclk_vop0_noc", "hclk_vop0_pre", 28, 0), /* CRU_CLKGATE_CON29 */ /* 15 - 13 unused */ GATE(PCLK_VIO_GRF, "pclk_vio_grf", "pclk_vio", 29, 12), GATE(PCLK_GASKET, "pclk_gasket", "pclk_hdcp", 29, 11), GATE(ACLK_HDCP22, "aclk_hdcp22", "aclk_hdcp", 29, 10), GATE(HCLK_HDCP22, "hclk_hdcp22", "hclk_hdcp", 29, 9), GATE(PCLK_HDCP22, "pclk_hdcp22", "pclk_hdcp", 29, 8), GATE(PCLK_DP_CTRL, "pclk_dp_ctrl", "pclk_hdcp", 29, 7), GATE(PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "pclk_hdcp", 29, 6), GATE(HCLK_HDCP_NOC, "hclk_hdcp_noc", "hclk_hdcp", 29, 5), GATE(ACLK_HDCP_NOC, "aclk_hdcp_noc", "aclk_hdcp", 29, 4), GATE(PCLK_HDCP_NOC, "pclk_hdcp_noc", "pclk_hdcp", 29, 3), GATE(PCLK_MIPI_DSI1, "pclk_mipi_dsi1", "pclk_vio", 29, 2), GATE(PCLK_MIPI_DSI0, "pclk_mipi_dsi0", "pclk_vio", 29, 1), GATE(ACLK_VIO_NOC, "aclk_vio_noc", "aclk_vio", 29, 0), /* CRU_CLKGATE_CON30 */ /* 15 - 12 unused */ GATE(ACLK_GPU_GRF, "aclk_gpu_grf", "aclk_gpu_pre", 30, 11), GATE(ACLK_PERF_GPU, "aclk_perf_gpu", "aclk_gpu_pre", 30, 10), /* 9 unused */ GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 30, 8), /* 7 - 5 unused */ GATE(ACLK_USB3_GRF, "aclk_usb3_grf", "aclk_usb3", 30, 4), GATE(ACLK_USB3_RKSOC_AXI_PERF, "aclk_usb3_rksoc_axi_perf", "aclk_usb3", 30, 3), GATE(ACLK_USB3OTG1, "aclk_usb3otg1", "aclk_usb3", 30, 2), GATE(ACLK_USB3OTG0, "aclk_usb3otg0", "aclk_usb3", 30, 1), GATE(ACLK_USB3_NOC, "aclk_usb3_noc", "aclk_usb3", 30, 0), /* CRU_CLKGATE_CON31 */ /* 15 - 11 unused */ GATE(PCLK_SGRF, "pclk_sgrf", "pclk_alive", 31, 10), GATE(PCLK_PMU_INTR_ARB, "pclk_pmu_intr_arb", "pclk_alive", 31, 9), GATE(PCLK_HSICPHY, "pclk_hsicphy", "pclk_perihp", 31, 8), GATE(PCLK_TIMER1, "pclk_timer1", "pclk_alive", 31, 7), GATE(PCLK_TIMER0, "pclk_timer0", "pclk_alive", 31, 6), GATE(PCLK_GPIO4, "pclk_gpio4", "pclk_alive", 31, 5), GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_alive", 31, 4), GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_alive", 31, 3), GATE(PCLK_INTR_ARB, "pclk_intr_arb", "pclk_alive", 31, 2), GATE(PCLK_GRF, "pclk_grf", "pclk_alive", 31, 1), /* 0 unused */ /* CRU_CLKGATE_CON32 */ /* 15 - 14 unused */ GATE(PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", 32, 13), GATE(PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", 32, 12), /* 11 unused */ GATE(ACLK_EMMC_GRF, "aclk_emmcgrf", "aclk_emmc", 32, 10), GATE(ACLK_EMMC_NOC, "aclk_emmc_noc", "aclk_emmc", 32, 9), GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", 32, 8), /* 7 - 5 unused */ GATE(ACLK_PERF_GMAC, "aclk_perf_gmac", "aclk_gmac_pre", 32, 4), GATE(PCLK_GMAC_NOC, "pclk_gmac_noc", "pclk_gmac_pre", 32, 3), GATE(PCLK_GMAC, "pclk_gmac", "pclk_gmac_pre", 32, 2), GATE(ACLK_GMAC_NOC, "aclk_gmac_noc", "aclk_gmac_pre", 32, 1), GATE(ACLK_GMAC, "aclk_gmac", "aclk_gmac_pre", 32, 0), /* CRU_CLKGATE_CON33 */ /* 15 - 10 unused */ GATE(0, "hclk_sdmmc_noc", "hclk_sd", 33, 9), GATE(HCLK_SDMMC, "hclk_sdmmc", "hclk_sd", 33, 8), GATE(ACLK_GIC_ADB400_GIC_2_CORE_B, "aclk_gic_adb400_gic_2_core_b", "aclk_gic_pre", 33, 5), GATE(ACLK_GIC_ADB400_GIC_2_CORE_L, "aclk_gic_adb400_gic_2_core_l", "aclk_gic_pre", 33, 4), GATE(ACLK_GIC_ADB400_CORE_B_2_GIC, "aclk_gic_adb400_core_b_2_gic", "aclk_gic_pre", 33, 3), GATE(ACLK_GIC_ADB400_CORE_L_2_GIC, "aclk_gic_adb400_core_l_2_gic", "aclk_gic_pre", 33, 2), GATE(ACLK_GIC_NOC, "aclk_gic_noc", "aclk_gic_pre", 33, 1), GATE(ACLK_GIC, "aclk_gic", "aclk_gic_pre", 33, 0), /* CRU_CLKGATE_CON34 */ /* 15 - 7 unused */ GATE(0, "hclk_sdioaudio_noc", "hclk_perilp1", 34, 6), GATE(PCLK_SPI5, "pclk_spi5", "hclk_perilp1", 34, 5), GATE(HCLK_SDIO, "hclk_sdio", "hclk_perilp1", 34, 4), GATE(HCLK_SPDIF, "hclk_spdif", "hclk_perilp1", 34, 3), GATE(HCLK_I2S2_8CH, "hclk_i2s2", "hclk_perilp1", 34, 2), GATE(HCLK_I2S1_8CH, "hclk_i2s1", "hclk_perilp1", 34, 1), GATE(HCLK_I2S0_8CH, "hclk_i2s0", "hclk_perilp1", 34, 0), }; #define PLL_RATE(_hz, _ref, _fb, _post1, _post2, _dspd) \ { \ .freq = _hz, \ .refdiv = _ref, \ .fbdiv = _fb, \ .postdiv1 = _post1, \ .postdiv2 = _post2, \ .dsmpd = _dspd, \ } static struct rk_clk_pll_rate rk3399_pll_rates[] = { /* _mhz, _refdiv, _fbdiv, _postdiv1, _postdiv2, _dsmpd, _frac */ PLL_RATE(2208000000, 1, 92, 1, 1, 1), PLL_RATE(2184000000, 1, 91, 1, 1, 1), PLL_RATE(2160000000, 1, 90, 1, 1, 1), PLL_RATE(2136000000, 1, 89, 1, 1, 1), PLL_RATE(2112000000, 1, 88, 1, 1, 1), PLL_RATE(2088000000, 1, 87, 1, 1, 1), PLL_RATE(2064000000, 1, 86, 1, 1, 1), PLL_RATE(2040000000, 1, 85, 1, 1, 1), PLL_RATE(2016000000, 1, 84, 1, 1, 1), PLL_RATE(1992000000, 1, 83, 1, 1, 1), PLL_RATE(1968000000, 1, 82, 1, 1, 1), PLL_RATE(1944000000, 1, 81, 1, 1, 1), PLL_RATE(1920000000, 1, 80, 1, 1, 1), PLL_RATE(1896000000, 1, 79, 1, 1, 1), PLL_RATE(1872000000, 1, 78, 1, 1, 1), PLL_RATE(1848000000, 1, 77, 1, 1, 1), PLL_RATE(1824000000, 1, 76, 1, 1, 1), PLL_RATE(1800000000, 1, 75, 1, 1, 1), PLL_RATE(1776000000, 1, 74, 1, 1, 1), PLL_RATE(1752000000, 1, 73, 1, 1, 1), PLL_RATE(1728000000, 1, 72, 1, 1, 1), PLL_RATE(1704000000, 1, 71, 1, 1, 1), PLL_RATE(1680000000, 1, 70, 1, 1, 1), PLL_RATE(1656000000, 1, 69, 1, 1, 1), PLL_RATE(1632000000, 1, 68, 1, 1, 1), PLL_RATE(1608000000, 1, 67, 1, 1, 1), PLL_RATE(1600000000, 3, 200, 1, 1, 1), PLL_RATE(1584000000, 1, 66, 1, 1, 1), PLL_RATE(1560000000, 1, 65, 1, 1, 1), PLL_RATE(1536000000, 1, 64, 1, 1, 1), PLL_RATE(1512000000, 1, 63, 1, 1, 1), PLL_RATE(1488000000, 1, 62, 1, 1, 1), PLL_RATE(1464000000, 1, 61, 1, 1, 1), PLL_RATE(1440000000, 1, 60, 1, 1, 1), PLL_RATE(1416000000, 1, 59, 1, 1, 1), PLL_RATE(1392000000, 1, 58, 1, 1, 1), PLL_RATE(1368000000, 1, 57, 1, 1, 1), PLL_RATE(1344000000, 1, 56, 1, 1, 1), PLL_RATE(1320000000, 1, 55, 1, 1, 1), PLL_RATE(1296000000, 1, 54, 1, 1, 1), PLL_RATE(1272000000, 1, 53, 1, 1, 1), PLL_RATE(1248000000, 1, 52, 1, 1, 1), PLL_RATE(1200000000, 1, 50, 1, 1, 1), PLL_RATE(1188000000, 2, 99, 1, 1, 1), PLL_RATE(1104000000, 1, 46, 1, 1, 1), PLL_RATE(1100000000, 12, 550, 1, 1, 1), PLL_RATE(1008000000, 1, 84, 2, 1, 1), PLL_RATE(1000000000, 1, 125, 3, 1, 1), PLL_RATE( 984000000, 1, 82, 2, 1, 1), PLL_RATE( 960000000, 1, 80, 2, 1, 1), PLL_RATE( 936000000, 1, 78, 2, 1, 1), PLL_RATE( 912000000, 1, 76, 2, 1, 1), PLL_RATE( 900000000, 4, 300, 2, 1, 1), PLL_RATE( 888000000, 1, 74, 2, 1, 1), PLL_RATE( 864000000, 1, 72, 2, 1, 1), PLL_RATE( 840000000, 1, 70, 2, 1, 1), PLL_RATE( 816000000, 1, 68, 2, 1, 1), PLL_RATE( 800000000, 1, 100, 3, 1, 1), PLL_RATE( 700000000, 6, 350, 2, 1, 1), PLL_RATE( 696000000, 1, 58, 2, 1, 1), PLL_RATE( 676000000, 3, 169, 2, 1, 1), PLL_RATE( 600000000, 1, 75, 3, 1, 1), PLL_RATE( 594000000, 1, 99, 4, 1, 1), PLL_RATE( 533250000, 8, 711, 4, 1, 1), PLL_RATE( 504000000, 1, 63, 3, 1, 1), PLL_RATE( 500000000, 6, 250, 2, 1, 1), PLL_RATE( 408000000, 1, 68, 2, 2, 1), PLL_RATE( 312000000, 1, 52, 2, 2, 1), PLL_RATE( 297000000, 1, 99, 4, 2, 1), PLL_RATE( 216000000, 1, 72, 4, 2, 1), PLL_RATE( 148500000, 1, 99, 4, 4, 1), PLL_RATE( 106500000, 1, 71, 4, 4, 1), PLL_RATE( 96000000, 1, 64, 4, 4, 1), PLL_RATE( 74250000, 2, 99, 4, 4, 1), PLL_RATE( 65000000, 1, 65, 6, 4, 1), PLL_RATE( 54000000, 1, 54, 6, 4, 1), PLL_RATE( 27000000, 1, 27, 6, 4, 1), {}, }; static struct rk_clk_armclk_rates rk3399_cpu_l_rates[] = { {1800000000, 1}, {1704000000, 1}, {1608000000, 1}, {1512000000, 1}, {1488000000, 1}, {1416000000, 1}, {1200000000, 1}, {1008000000, 1}, { 816000000, 1}, { 696000000, 1}, { 600000000, 1}, { 408000000, 1}, { 312000000, 1}, { 216000000, 1}, { 96000000, 1}, }; static struct rk_clk_armclk_rates rk3399_cpu_b_rates[] = { {2208000000, 1}, {2184000000, 1}, {2088000000, 1}, {2040000000, 1}, {2016000000, 1}, {1992000000, 1}, {1896000000, 1}, {1800000000, 1}, {1704000000, 1}, {1608000000, 1}, {1512000000, 1}, {1488000000, 1}, {1416000000, 1}, {1200000000, 1}, {1008000000, 1}, { 816000000, 1}, { 696000000, 1}, { 600000000, 1}, { 408000000, 1}, { 312000000, 1}, { 216000000, 1}, { 96000000, 1}, }; /* Standard PLL. */ #define PLL(_id, _name, _base) \ { \ .type = RK3399_CLK_PLL, \ .clk.pll = &(struct rk_clk_pll_def) { \ .clkdef.id = _id, \ .clkdef.name = _name, \ .clkdef.parent_names = pll_src_p, \ .clkdef.parent_cnt = nitems(pll_src_p), \ .clkdef.flags = CLK_NODE_STATIC_STRINGS, \ .base_offset = _base, \ .rates = rk3399_pll_rates, \ }, \ } #define PLIST(_name) static const char *_name[] PLIST(pll_src_p) = {"xin24m", "xin32k"}; PLIST(armclkl_p) = {"clk_core_l_lpll_src", "clk_core_l_bpll_src", "clk_core_l_dpll_src", "clk_core_l_gpll_src"}; PLIST(armclkb_p) = {"clk_core_b_lpll_src", "clk_core_b_bpll_src", "clk_core_b_dpll_src", "clk_core_b_gpll_src"}; PLIST(ddrclk_p) = {"clk_ddrc_lpll_src", "clk_ddrc_bpll_src", "clk_ddrc_dpll_src", "clk_ddrc_gpll_src"}; PLIST(pll_src_cpll_gpll_p) = {"cpll", "gpll"}; PLIST(pll_src_cpll_gpll_ppll_p) = {"cpll", "gpll", "ppll"}; PLIST(pll_src_cpll_gpll_upll_p) = {"cpll", "gpll", "upll"}; PLIST(pll_src_npll_cpll_gpll_p) = {"npll", "cpll", "gpll"}; PLIST(pll_src_cpll_gpll_npll_npll_p) = {"cpll", "gpll", "npll", "npll"}; PLIST(pll_src_cpll_gpll_npll_ppll_p) = {"cpll", "gpll", "npll", "ppll" }; PLIST(pll_src_cpll_gpll_npll_24m_p) = {"cpll", "gpll", "npll", "xin24m" }; PLIST(pll_src_cpll_gpll_npll_usbphy480m_p)= {"cpll", "gpll", "npll", "clk_usbphy_480m" }; PLIST(pll_src_ppll_cpll_gpll_npll_upll_p) = { "ppll", "cpll", "gpll", "npll", "upll" }; PLIST(pll_src_cpll_gpll_npll_upll_24m_p)= { "cpll", "gpll", "npll", "upll", "xin24m" }; PLIST(pll_src_cpll_gpll_npll_ppll_upll_24m_p) = { "cpll", "gpll", "npll", "ppll", "upll", "xin24m" }; PLIST(pll_src_vpll_cpll_gpll_gpll_p) = {"vpll", "cpll", "gpll", "gpll"}; PLIST(pll_src_vpll_cpll_gpll_npll_p) = {"vpll", "cpll", "gpll", "npll"}; PLIST(aclk_cci_p) = {"cpll_aclk_cci_src", "gpll_aclk_cci_src", "npll_aclk_cci_src", "vpll_aclk_cci_src"}; PLIST(cci_trace_p) = {"cpll_cci_trace","gpll_cci_trace"}; PLIST(cs_p)= {"cpll_cs", "gpll_cs", "npll_cs","npll_cs"}; PLIST(aclk_perihp_p)= {"cpll_aclk_perihp_src", "gpll_aclk_perihp_src" }; PLIST(dclk_vop0_p) = {"dclk_vop0_div", "dclk_vop0_frac"}; PLIST(dclk_vop1_p)= {"dclk_vop1_div", "dclk_vop1_frac"}; PLIST(clk_cif_p) = {"clk_cifout_src", "xin24m"}; PLIST(pll_src_24m_usbphy480m_p) = { "xin24m", "clk_usbphy_480m"}; PLIST(pll_src_24m_pciephy_p) = { "xin24m", "clk_pciephy_ref100m"}; PLIST(pll_src_24m_32k_cpll_gpll_p)= {"xin24m", "xin32k", "cpll", "gpll"}; PLIST(pciecore_cru_phy_p) = {"clk_pcie_core_cru", "clk_pcie_core_phy"}; PLIST(aclk_emmc_p) = { "cpll_aclk_emmc_src", "gpll_aclk_emmc_src"}; PLIST(aclk_perilp0_p) = { "cpll_aclk_perilp0_src", "gpll_aclk_perilp0_src" }; PLIST(fclk_cm0s_p) = { "cpll_fclk_cm0s_src", "gpll_fclk_cm0s_src" }; PLIST(hclk_perilp1_p) = { "cpll_hclk_perilp1_src", "gpll_hclk_perilp1_src" }; PLIST(clk_testout1_p) = { "clk_testout1_pll_src", "xin24m" }; PLIST(clk_testout2_p) = { "clk_testout2_pll_src", "xin24m" }; PLIST(usbphy_480m_p) = { "clk_usbphy0_480m_src", "clk_usbphy1_480m_src" }; PLIST(aclk_gmac_p) = { "cpll_aclk_gmac_src", "gpll_aclk_gmac_src" }; PLIST(rmii_p) = { "clk_gmac", "clkin_gmac" }; PLIST(spdif_p) = { "clk_spdif_div", "clk_spdif_frac", "clkin_i2s", "xin12m" }; PLIST(i2s0_p) = { "clk_i2s0_div", "clk_i2s0_frac", "clkin_i2s", "xin12m" }; PLIST(i2s1_p) = { "clk_i2s1_div", "clk_i2s1_frac", "clkin_i2s", "xin12m" }; PLIST(i2s2_p) = { "clk_i2s2_div", "clk_i2s2_frac", "clkin_i2s", "xin12m" }; PLIST(i2sch_p) = {"clk_i2s0", "clk_i2s1", "clk_i2s2"}; PLIST(i2sout_p) = {"clk_i2sout_src", "xin12m"}; PLIST(uart0_p)= {"clk_uart0_div", "clk_uart0_frac", "xin24m"}; PLIST(uart1_p)= {"clk_uart1_div", "clk_uart1_frac", "xin24m"}; PLIST(uart2_p)= {"clk_uart2_div", "clk_uart2_frac", "xin24m"}; PLIST(uart3_p)= {"clk_uart3_div", "clk_uart3_frac", "xin24m"}; static struct rk_clk rk3399_clks[] = { /* External clocks */ LINK("xin24m"), LINK("xin32k"), FFACT(0, "xin12m", "xin24m", 1, 2), FRATE(0, "clkin_i2s", 0), FRATE(0, "pclkin_cif", 0), LINK("clk_usbphy0_480m"), LINK("clk_usbphy1_480m"), LINK("clkin_gmac"), FRATE(0, "clk_pcie_core_phy", 0), FFACT(0, "clk_ddrc_div2", "clk_ddrc", 1, 2), /* PLLs */ PLL(PLL_APLLL, "lpll", 0x00), PLL(PLL_APLLB, "bpll", 0x20), PLL(PLL_DPLL, "dpll", 0x40), PLL(PLL_CPLL, "cpll", 0x60), PLL(PLL_GPLL, "gpll", 0x80), PLL(PLL_NPLL, "npll", 0xA0), PLL(PLL_VPLL, "vpll", 0xC0), /* CRU_CLKSEL_CON0 */ CDIV(0, "aclkm_core_l_c", "armclkl", 0, 0, 8, 5), ARMDIV(ARMCLKL, "armclkl", armclkl_p, rk3399_cpu_l_rates, 0, 0, 5, 6, 2, 0, 3), /* CRU_CLKSEL_CON1 */ CDIV(0, "pclk_dbg_core_l_c", "armclkl", 0, 1, 8, 5), CDIV(0, "atclk_core_l_c", "armclkl", 0, 1, 0, 5), /* CRU_CLKSEL_CON2 */ CDIV(0, "aclkm_core_b_c", "armclkb", 0, 2, 8, 5), ARMDIV(ARMCLKB, "armclkb", armclkb_p, rk3399_cpu_b_rates, 2, 0, 5, 6, 2, 1, 3), /* CRU_CLKSEL_CON3 */ CDIV(0, "pclken_dbg_core_b", "pclk_dbg_core_b", 0, 3, 13, 2), CDIV(0, "pclk_dbg_core_b_c", "armclkb", 0, 3, 8, 5), CDIV(0, "atclk_core_b_c", "armclkb", 0, 3, 0, 5), /* CRU_CLKSEL_CON4 */ COMP(0, "clk_cs", cs_p, 0, 4, 0, 5, 6, 2), /* CRU_CLKSEL_CON5 */ COMP(0, "clk_cci_trace_c", cci_trace_p, 0, 5, 8, 5, 15, 1), COMP(0, "aclk_cci_pre_c", aclk_cci_p, 0, 5, 0, 5, 6, 2), /* CRU_CLKSEL_CON6 */ COMP(0, "pclk_ddr_c", pll_src_cpll_gpll_p, 0, 6, 8, 5, 15, 1), COMP(SCLK_DDRC, "clk_ddrc", ddrclk_p, 0, 6, 0, 3, 4, 2), /* CRU_CLKSEL_CON7 */ CDIV(0, "hclk_vcodec_pre_c", "aclk_vcodec_pre", 0, 7, 8, 5), COMP(0, "aclk_vcodec_pre_c", pll_src_cpll_gpll_npll_ppll_p, 0, 7, 0, 5, 6, 2), /* CRU_CLKSEL_CON8 */ CDIV(0, "hclk_vdu_pre_c", "aclk_vdu_pre", 0, 8, 8, 5), COMP(0, "aclk_vdu_pre_c", pll_src_cpll_gpll_npll_ppll_p, 0, 8, 0, 5, 6, 2), /* CRU_CLKSEL_CON9 */ COMP(0, "clk_vdu_ca_c", pll_src_cpll_gpll_npll_npll_p, 0, 9, 8, 5, 14, 2), COMP(0, "clk_vdu_core_c", pll_src_cpll_gpll_npll_npll_p, 0, 9, 0, 5, 6, 2), /* CRU_CLKSEL_CON10 */ CDIV(0, "hclk_iep_pre_c", "aclk_iep_pre", 0, 10, 8, 5), COMP(0, "aclk_iep_pre_c", pll_src_cpll_gpll_npll_ppll_p, 0, 10, 0, 5, 6, 2), /* CRU_CLKSEL_CON11 */ CDIV(0, "hclk_rga_pre_c", "aclk_rga_pre", 0, 11, 8, 5), COMP(0, "aclk_rga_pre_c", pll_src_cpll_gpll_npll_ppll_p, 0, 11, 0, 5, 6, 2), /* CRU_CLKSEL_CON12 */ COMP(0, "aclk_center_c", pll_src_cpll_gpll_npll_npll_p, 0, 12, 8, 5, 14, 2), COMP(SCLK_RGA_CORE, "clk_rga_core_c", pll_src_cpll_gpll_npll_ppll_p, 0, 12, 0, 5, 6, 2), /* CRU_CLKSEL_CON13 */ COMP(0, "hclk_sd_c", pll_src_cpll_gpll_p, 0, 13, 8, 5, 15, 1), COMP(0, "aclk_gpu_pre_c", pll_src_ppll_cpll_gpll_npll_upll_p, 0, 13, 0, 5, 5, 3), /* CRU_CLKSEL_CON14 */ MUX(0, "upll", pll_src_24m_usbphy480m_p, 0, 14, 15, 1), CDIV(0, "pclk_perihp_c", "aclk_perihp", 0, 14, 12, 2), CDIV(0, "hclk_perihp_c", "aclk_perihp", 0, 14, 8, 2), MUX(0, "clk_usbphy_480m", usbphy_480m_p, 0, 14, 6, 1), COMP(0, "aclk_perihp_c", aclk_perihp_p, 0, 14, 0, 5, 7, 1), /* CRU_CLKSEL_CON15 */ COMP(0, "clk_sdio_c", pll_src_cpll_gpll_npll_ppll_upll_24m_p, 0, 15, 0, 7, 8, 3), /* CRU_CLKSEL_CON16 */ COMP(0, "clk_sdmmc_c", pll_src_cpll_gpll_npll_ppll_upll_24m_p, 0, 16, 0, 7, 8, 3), /* CRU_CLKSEL_CON17 */ COMP(0, "clk_pcie_pm_c", pll_src_cpll_gpll_npll_24m_p, 0, 17, 0, 7, 8, 3), /* CRU_CLKSEL_CON18 */ CDIV(0, "clk_pciephy_ref100m_c", "npll", 0, 18, 11, 5), MUX(SCLK_PCIEPHY_REF, "clk_pciephy_ref", pll_src_24m_pciephy_p, 0, 18, 10, 1), MUX(SCLK_PCIE_CORE, "clk_pcie_core", pciecore_cru_phy_p, 0, 18, 7, 1), COMP(0, "clk_pcie_core_cru_c", pll_src_cpll_gpll_npll_npll_p, 0, 18, 0, 7, 8, 2), /* CRU_CLKSEL_CON19 */ CDIV(0, "pclk_gmac_pre_c", "aclk_gmac_pre", 0, 19, 8, 3), MUX(SCLK_RMII_SRC, "clk_rmii_src",rmii_p, 0, 19, 4, 1), MUX(SCLK_HSICPHY, "clk_hsicphy_c", pll_src_cpll_gpll_npll_usbphy480m_p, 0, 19, 0, 2), /* CRU_CLKSEL_CON20 */ COMP(0, "clk_gmac_c", pll_src_cpll_gpll_npll_npll_p, 0, 20, 8, 5, 14, 2), COMP(0, "aclk_gmac_pre_c", aclk_gmac_p, 0, 20, 0, 5, 7, 1), /* CRU_CLKSEL_CON21 */ COMP(ACLK_EMMC, "aclk_emmc", aclk_emmc_p, 0, 21, 0, 5, 7, 1), /* CRU_CLKSEL_CON22 */ COMP(0, "clk_emmc_c", pll_src_cpll_gpll_npll_upll_24m_p, 0, 22, 0, 7, 8, 3), /* CRU_CLKSEL_CON23 */ CDIV(0, "pclk_perilp0_c", "aclk_perilp0", 0, 23, 12, 3), CDIV(0, "hclk_perilp0_c", "aclk_perilp0", 0, 23, 8, 2), COMP(0, "aclk_perilp0_c", aclk_perilp0_p, 0, 23, 0, 5, 7, 1), /* CRU_CLKSEL_CON24 */ COMP(0, "fclk_cm0s_c", fclk_cm0s_p, 0, 24, 8, 5, 15, 1), COMP(0, "clk_crypto0_c", pll_src_cpll_gpll_ppll_p, 0, 24, 0, 5, 6, 2), /* CRU_CLKSEL_CON25 */ CDIV(0, "pclk_perilp1_c", "hclk_perilp1", 0, 25, 8, 3), COMP(HCLK_PERILP1, "hclk_perilp1", hclk_perilp1_p, 0, 25, 0, 5, 7, 1), /* CRU_CLKSEL_CON26 */ CDIV(0, "clk_saradc_c", "xin24m", 0, 26, 8, 8), COMP(0, "clk_crypto1_c", pll_src_cpll_gpll_ppll_p, 0, 26, 0, 5, 6, 2), /* CRU_CLKSEL_CON27 */ COMP(0, "clk_tsadc_c", pll_src_p, 0, 27, 0, 10, 15, 1), /* CRU_CLKSEL_CON28 */ MUX(0, "clk_i2s0_mux", i2s0_p, RK_CLK_MUX_REPARENT, 28, 8, 2), COMP(0, "clk_i2s0_div_c", pll_src_cpll_gpll_p, 0, 28, 0, 7, 7, 1), /* CRU_CLKSEL_CON29 */ MUX(0, "clk_i2s1_mux", i2s1_p, RK_CLK_MUX_REPARENT, 29, 8, 2), COMP(0, "clk_i2s1_div_c", pll_src_cpll_gpll_p, 0, 29, 0, 7, 7, 1), /* CRU_CLKSEL_CON30 */ MUX(0, "clk_i2s2_mux", i2s2_p, RK_CLK_MUX_REPARENT, 30, 8, 2), COMP(0, "clk_i2s2_div_c", pll_src_cpll_gpll_p, 0, 30, 0, 7, 7, 1), /* CRU_CLKSEL_CON31 */ MUX(0, "clk_i2sout_c", i2sout_p, 0, 31, 2, 1), MUX(0, "clk_i2sout_src", i2sch_p, 0, 31, 0, 2), /* CRU_CLKSEL_CON32 */ COMP(0, "clk_spdif_rec_dptx_c", pll_src_cpll_gpll_p, 0, 32, 8, 5, 15, 1), MUX(0, "clk_spdif_mux", spdif_p, 0, 32, 13, 2), COMP(0, "clk_spdif_div_c", pll_src_cpll_gpll_p, 0, 32, 0, 7, 7, 1), /* CRU_CLKSEL_CON33 */ MUX(0, "clk_uart_src", pll_src_cpll_gpll_p, 0, 33, 15, 1), MUX(0, "clk_uart0_src", pll_src_cpll_gpll_upll_p, 0, 33, 12, 2), MUX(SCLK_UART0, "clk_uart0", uart0_p, 0, 33, 8, 2), CDIV(0, "clk_uart0_div_c", "clk_uart0_src", 0, 33, 0, 7), /* CRU_CLKSEL_CON34 */ MUX(SCLK_UART1, "clk_uart1", uart1_p, 0, 34, 8, 2), CDIV(0, "clk_uart1_div_c", "clk_uart_src", 0, 34, 0, 7), /* CRU_CLKSEL_CON35 */ MUX(SCLK_UART2, "clk_uart2", uart2_p, 0, 35, 8, 2), CDIV(0, "clk_uart2_div_c", "clk_uart_src", 0, 35, 0, 7), /* CRU_CLKSEL_CON36 */ MUX(SCLK_UART3, "clk_uart3", uart3_p, 0, 36, 8, 2), CDIV(0, "clk_uart3_div_c", "clk_uart_src", 0, 36, 0, 7), /* CRU_CLKSEL_CON37 */ /* unused */ /* CRU_CLKSEL_CON38 */ MUX(0, "clk_testout2_pll_src", pll_src_cpll_gpll_npll_npll_p, 0, 38, 14, 2), COMP(0, "clk_testout2_c", clk_testout2_p, 0, 38, 8, 5, 13, 1), MUX(0, "clk_testout1_pll_src", pll_src_cpll_gpll_npll_npll_p, 0, 38, 6, 2), COMP(0, "clk_testout1_c", clk_testout1_p, 0, 38, 0, 5, 5, 1), /* CRU_CLKSEL_CON39 */ COMP(0, "aclk_usb3_c", pll_src_cpll_gpll_npll_npll_p, 0, 39, 0, 5, 6, 2), /* CRU_CLKSEL_CON40 */ COMP(0, "clk_usb3otg0_suspend_c", pll_src_p, 0, 40, 0, 10, 15, 1), /* CRU_CLKSEL_CON41 */ COMP(0, "clk_usb3otg1_suspend_c", pll_src_p, 0, 41, 0, 10, 15, 1), /* CRU_CLKSEL_CON42 */ COMP(0, "aclk_hdcp_c", pll_src_cpll_gpll_ppll_p, 0, 42, 8, 5, 14, 2), COMP(0, "aclk_vio_c", pll_src_cpll_gpll_ppll_p, 0, 42, 0, 5, 6, 2), /* CRU_CLKSEL_CON43 */ CDIV(0, "pclk_hdcp_c", "aclk_hdcp", 0, 43, 10, 5), CDIV(0, "hclk_hdcp_c", "aclk_hdcp", 0, 43, 5, 5), CDIV(0, "pclk_vio_c", "aclk_vio", 0, 43, 0, 5), /* CRU_CLKSEL_CON44 */ COMP(0, "pclk_edp_c", pll_src_cpll_gpll_p, 0, 44, 8, 6, 15, 1), /* CRU_CLKSEL_CON45 - XXX clocks in mux are reversed in TRM !!!*/ COMP(0, "clk_hdmi_cec_c", pll_src_p, 0, 45, 0, 10, 15, 1), /* CRU_CLKSEL_CON46 */ COMP(0, "clk_dp_core_c", pll_src_npll_cpll_gpll_p, 0, 46, 0, 5, 6, 2), /* CRU_CLKSEL_CON47 */ CDIV(0, "hclk_vop0_pre_c", "aclk_vop0_pre_c", 0, 47, 8, 5), COMP(0, "aclk_vop0_pre_c", pll_src_vpll_cpll_gpll_npll_p, 0, 47, 0, 5, 6, 2), /* CRU_CLKSEL_CON48 */ CDIV(0, "hclk_vop1_pre_c", "aclk_vop1_pre", 0, 48, 8, 5), COMP(0, "aclk_vop1_pre_c", pll_src_vpll_cpll_gpll_npll_p, 0, 48, 0, 5, 6, 2), /* CRU_CLKSEL_CON49 */ MUX(DCLK_VOP0, "dclk_vop0", dclk_vop0_p, 0, 49, 11, 1), COMP(0, "dclk_vop0_div_c", pll_src_vpll_cpll_gpll_gpll_p, 0, 49, 0, 8, 8, 2), /* CRU_CLKSEL_CON50 */ MUX(DCLK_VOP1, "dclk_vop1", dclk_vop1_p, 0, 50, 11, 1), COMP(0, "dclk_vop1_div_c", pll_src_vpll_cpll_gpll_gpll_p, 0, 50, 0, 8, 8, 2), /* CRU_CLKSEL_CON51 */ COMP(0, "clk_vop0_pwm_c", pll_src_vpll_cpll_gpll_gpll_p, 0, 51, 0, 5, 6, 2), /* CRU_CLKSEL_CON52 */ COMP(0, "clk_vop1_pwm_c", pll_src_vpll_cpll_gpll_gpll_p, 0, 52, 0, 5, 6, 2), /* CRU_CLKSEL_CON53 */ CDIV(0, "hclk_isp0_c", "aclk_isp0", 0, 53, 8, 5), COMP(0, "aclk_isp0_c", pll_src_cpll_gpll_ppll_p, 0, 53, 0, 5, 6, 2), /* CRU_CLKSEL_CON54 */ CDIV(0, "hclk_isp1_c", "aclk_isp1", 0, 54, 8, 5), COMP(0, "aclk_isp1_c", pll_src_cpll_gpll_ppll_p, 0, 54, 0, 5, 6, 2), /* CRU_CLKSEL_CON55 */ COMP(0, "clk_isp1_c", pll_src_cpll_gpll_npll_npll_p, 0, 55, 8, 5, 14, 2), COMP(0, "clk_isp0_c", pll_src_cpll_gpll_npll_npll_p, 0, 55, 0, 5, 6, 2), /* CRU_CLKSEL_CON56 */ COMP(0, "aclk_gic_pre_c", pll_src_cpll_gpll_p, 0, 56, 8, 5, 15, 1), MUX(0, "clk_cifout_src_c", pll_src_cpll_gpll_npll_npll_p, 0, 56, 6, 2), COMP(SCLK_CIF_OUT, "clk_cifout", clk_cif_p, 0, 56, 0, 5, 5, 1), /* CRU_CLKSEL_CON57 */ CDIV(0, "clk_test_24m", "xin24m", 0, 57, 6, 10), CDIV(PCLK_ALIVE, "pclk_alive", "gpll", 0, 57, 0, 5), /* CRU_CLKSEL_CON58 */ COMP(0, "clk_spi5_c", pll_src_cpll_gpll_p, 0, 58, 8, 7, 15, 1), MUX(0, "clk_test_pre", pll_src_cpll_gpll_p, 0, 58, 7, 1), CDIV(0, "clk_test_c", "clk_test_pre", 0, 58, 0, 5), /* CRU_CLKSEL_CON59 */ COMP(0, "clk_spi1_c", pll_src_cpll_gpll_p, 0, 59, 8, 7, 15, 1), COMP(0, "clk_spi0_c", pll_src_cpll_gpll_p, 0, 59, 0, 7, 7, 1), /* CRU_CLKSEL_CON60 */ COMP(0, "clk_spi4_c", pll_src_cpll_gpll_p, 0, 60, 8, 7, 15, 1), COMP(0, "clk_spi2_c", pll_src_cpll_gpll_p, 0, 60, 0, 7, 7, 1), /* CRU_CLKSEL_CON61 */ COMP(0, "clk_i2c5_c", pll_src_cpll_gpll_p, 0, 61, 8, 7, 15, 1), COMP(0, "clk_i2c1_c", pll_src_cpll_gpll_p, 0, 61, 0, 7, 7, 1), /* CRU_CLKSEL_CON62 */ COMP(0, "clk_i2c6_c", pll_src_cpll_gpll_p, 0, 62, 8, 7, 15, 1), COMP(0, "clk_i2c2_c", pll_src_cpll_gpll_p, 0, 62, 0, 7, 7, 1), /* CRU_CLKSEL_CON63 */ COMP(0, "clk_i2c7_c", pll_src_cpll_gpll_p, 0, 63, 8, 7, 15, 1), COMP(0, "clk_i2c3_c", pll_src_cpll_gpll_p, 0, 63, 0, 7, 7, 1), /* CRU_CLKSEL_CON64 */ COMP(0, "clk_uphy0_tcpdphy_ref_c", pll_src_p, 0, 64, 8, 5, 15, 1), COMP(0, "clk_uphy0_tcpdcore_c", pll_src_24m_32k_cpll_gpll_p, 0, 64, 0, 5, 6, 2), /* CRU_CLKSEL_CON65 */ COMP(0, "clk_uphy1_tcpdphy_ref_c", pll_src_p, 0, 65, 8, 5, 15, 1), COMP(0, "clk_uphy1_tcpdcore_c", pll_src_24m_32k_cpll_gpll_p, 0, 65, 0, 5, 6, 2), /* CRU_CLKSEL_CON99 - 107 */ FRACT(0, "clk_spdif_frac_c", "clk_spdif_div", 0, 99), FRACT(0, "clk_i2s0_frac_c", "clk_i2s0_div", 0, 96), FRACT(0, "clk_i2s1_frac_c", "clk_i2s1_div", 0, 97), FRACT(0, "clk_i2s2_frac_c", "clk_i2s2_div", 0, 98), FRACT(0, "clk_uart0_frac_c", "clk_uart0_div", 0, 100), FRACT(0, "clk_uart1_frac_c", "clk_uart1_div", 0, 101), FRACT(0, "clk_uart2_frac_c", "clk_uart2_div", 0, 102), FRACT(0, "clk_uart3_frac_c", "clk_uart3_div", 0, 103), FRACT(0, "clk_test_frac_c", "clk_test_pre", 0, 105), FRACT(DCLK_VOP0_FRAC, "dclk_vop0_frac", "dclk_vop0_div", 0, 106), FRACT(DCLK_VOP1_FRAC, "dclk_vop1_frac", "dclk_vop1_div", 0, 107), /* * This clock is controlled in the secure world */ FFACT(PCLK_WDT, "pclk_wdt", "pclk_alive", 1, 1), /* Not yet implemented yet * MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "clk_sdmmc", RK3399_SDMMC_CON0, 1), * MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "clk_sdmmc", RK3399_SDMMC_CON1, 1), * MMC(SCLK_SDIO_DRV, "sdio_drv", "clk_sdio", RK3399_SDIO_CON0, 1), * MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "clk_sdio", RK3399_SDIO_CON1, 1), */ }; static int rk3399_cru_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) return (ENXIO); if (ofw_bus_is_compatible(dev, "rockchip,rk3399-cru")) { device_set_desc(dev, "Rockchip RK3399 Clock and Reset Unit"); return (BUS_PROBE_DEFAULT); } return (ENXIO); } static int rk3399_cru_attach(device_t dev) { struct rk_cru_softc *sc; sc = device_get_softc(dev); sc->dev = dev; sc->gates = rk3399_gates; sc->ngates = nitems(rk3399_gates); sc->clks = rk3399_clks; sc->nclks = nitems(rk3399_clks); sc->reset_offset = 0x400; sc->reset_num = 335; return (rk_cru_attach(dev)); } static device_method_t rk3399_cru_methods[] = { /* Device interface */ DEVMETHOD(device_probe, rk3399_cru_probe), DEVMETHOD(device_attach, rk3399_cru_attach), DEVMETHOD_END }; DEFINE_CLASS_1(rk3399_cru, rk3399_cru_driver, rk3399_cru_methods, sizeof(struct rk_cru_softc), rk_cru_driver); EARLY_DRIVER_MODULE(rk3399_cru, simplebus, rk3399_cru_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/rockchip/clk/rk3399_pmucru.c b/sys/arm64/rockchip/clk/rk3399_pmucru.c index 3092e265a7f4..74ad9ac8023c 100644 --- a/sys/arm64/rockchip/clk/rk3399_pmucru.c +++ b/sys/arm64/rockchip/clk/rk3399_pmucru.c @@ -1,867 +1,867 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2018 Emmanuel Vadot - * Copyright (c) 2018 Greg V + * Copyright (c) 2018 Val Packett * * 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. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* GATES */ #define PCLK_PMU 20 #define PCLK_GPIO0_PMU 23 #define PCLK_GPIO1_PMU 24 #define PCLK_I2C0_PMU 27 #define PCLK_I2C4_PMU 28 #define PCLK_I2C8_PMU 29 #define PCLK_RKPWM_PMU 30 static struct rk_cru_gate rk3399_pmu_gates[] = { /* PMUCRU_CLKGATE_CON1 */ CRU_GATE(PCLK_PMU, "pclk_pmu", "pclk_pmu_src", 0x104, 0) CRU_GATE(PCLK_GPIO0_PMU, "pclk_gpio0_pmu", "pclk_pmu_src", 0x104, 3) CRU_GATE(PCLK_GPIO1_PMU, "pclk_gpio1_pmu", "pclk_pmu_src", 0x104, 4) CRU_GATE(PCLK_I2C0_PMU, "pclk_i2c0_pmu", "pclk_pmu_src", 0x104, 7) CRU_GATE(PCLK_I2C4_PMU, "pclk_i2c4_pmu", "pclk_pmu_src", 0x104, 8) CRU_GATE(PCLK_I2C8_PMU, "pclk_i2c8_pmu", "pclk_pmu_src", 0x104, 9) CRU_GATE(PCLK_RKPWM_PMU, "pclk_rkpwm_pmu", "pclk_pmu_src", 0x104, 10) }; /* * PLLs */ #define PLL_PPLL 1 static struct rk_clk_pll_rate rk3399_pll_rates[] = { { .freq = 2208000000, .refdiv = 1, .fbdiv = 92, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2184000000, .refdiv = 1, .fbdiv = 91, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2160000000, .refdiv = 1, .fbdiv = 90, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2136000000, .refdiv = 1, .fbdiv = 89, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2112000000, .refdiv = 1, .fbdiv = 88, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2088000000, .refdiv = 1, .fbdiv = 87, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2064000000, .refdiv = 1, .fbdiv = 86, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2040000000, .refdiv = 1, .fbdiv = 85, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 2016000000, .refdiv = 1, .fbdiv = 84, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1992000000, .refdiv = 1, .fbdiv = 83, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1968000000, .refdiv = 1, .fbdiv = 82, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1944000000, .refdiv = 1, .fbdiv = 81, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1920000000, .refdiv = 1, .fbdiv = 80, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1896000000, .refdiv = 1, .fbdiv = 79, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1872000000, .refdiv = 1, .fbdiv = 78, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1848000000, .refdiv = 1, .fbdiv = 77, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1824000000, .refdiv = 1, .fbdiv = 76, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1800000000, .refdiv = 1, .fbdiv = 75, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1776000000, .refdiv = 1, .fbdiv = 74, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1752000000, .refdiv = 1, .fbdiv = 73, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1728000000, .refdiv = 1, .fbdiv = 72, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1704000000, .refdiv = 1, .fbdiv = 71, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1680000000, .refdiv = 1, .fbdiv = 70, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1656000000, .refdiv = 1, .fbdiv = 69, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1632000000, .refdiv = 1, .fbdiv = 68, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1608000000, .refdiv = 1, .fbdiv = 67, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1600000000, .refdiv = 3, .fbdiv = 200, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1584000000, .refdiv = 1, .fbdiv = 66, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1560000000, .refdiv = 1, .fbdiv = 65, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1536000000, .refdiv = 1, .fbdiv = 64, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1512000000, .refdiv = 1, .fbdiv = 63, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1488000000, .refdiv = 1, .fbdiv = 62, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1464000000, .refdiv = 1, .fbdiv = 61, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1440000000, .refdiv = 1, .fbdiv = 60, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1416000000, .refdiv = 1, .fbdiv = 59, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1392000000, .refdiv = 1, .fbdiv = 58, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1368000000, .refdiv = 1, .fbdiv = 57, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1344000000, .refdiv = 1, .fbdiv = 56, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1320000000, .refdiv = 1, .fbdiv = 55, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1296000000, .refdiv = 1, .fbdiv = 54, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1272000000, .refdiv = 1, .fbdiv = 53, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1248000000, .refdiv = 1, .fbdiv = 52, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1200000000, .refdiv = 1, .fbdiv = 50, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1188000000, .refdiv = 2, .fbdiv = 99, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1104000000, .refdiv = 1, .fbdiv = 46, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1100000000, .refdiv = 12, .fbdiv = 550, .postdiv1 = 1, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1008000000, .refdiv = 1, .fbdiv = 84, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 1000000000, .refdiv = 1, .fbdiv = 125, .postdiv1 = 3, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 984000000, .refdiv = 1, .fbdiv = 82, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 960000000, .refdiv = 1, .fbdiv = 80, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 936000000, .refdiv = 1, .fbdiv = 78, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 912000000, .refdiv = 1, .fbdiv = 76, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 900000000, .refdiv = 4, .fbdiv = 300, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 888000000, .refdiv = 1, .fbdiv = 74, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 864000000, .refdiv = 1, .fbdiv = 72, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 840000000, .refdiv = 1, .fbdiv = 70, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 816000000, .refdiv = 1, .fbdiv = 68, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 800000000, .refdiv = 1, .fbdiv = 100, .postdiv1 = 3, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 700000000, .refdiv = 6, .fbdiv = 350, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 696000000, .refdiv = 1, .fbdiv = 58, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 676000000, .refdiv = 3, .fbdiv = 169, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 600000000, .refdiv = 1, .fbdiv = 75, .postdiv1 = 3, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 594000000, .refdiv = 1, .fbdiv = 99, .postdiv1 = 4, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 533250000, .refdiv = 8, .fbdiv = 711, .postdiv1 = 4, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 504000000, .refdiv = 1, .fbdiv = 63, .postdiv1 = 3, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 500000000, .refdiv = 6, .fbdiv = 250, .postdiv1 = 2, .postdiv2 = 1, .dsmpd = 1, }, { .freq = 408000000, .refdiv = 1, .fbdiv = 68, .postdiv1 = 2, .postdiv2 = 2, .dsmpd = 1, }, { .freq = 312000000, .refdiv = 1, .fbdiv = 52, .postdiv1 = 2, .postdiv2 = 2, .dsmpd = 1, }, { .freq = 297000000, .refdiv = 1, .fbdiv = 99, .postdiv1 = 4, .postdiv2 = 2, .dsmpd = 1, }, { .freq = 216000000, .refdiv = 1, .fbdiv = 72, .postdiv1 = 4, .postdiv2 = 2, .dsmpd = 1, }, { .freq = 148500000, .refdiv = 1, .fbdiv = 99, .postdiv1 = 4, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 106500000, .refdiv = 1, .fbdiv = 71, .postdiv1 = 4, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 96000000, .refdiv = 1, .fbdiv = 64, .postdiv1 = 4, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 74250000, .refdiv = 2, .fbdiv = 99, .postdiv1 = 4, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 65000000, .refdiv = 1, .fbdiv = 65, .postdiv1 = 6, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 54000000, .refdiv = 1, .fbdiv = 54, .postdiv1 = 6, .postdiv2 = 4, .dsmpd = 1, }, { .freq = 27000000, .refdiv = 1, .fbdiv = 27, .postdiv1 = 6, .postdiv2 = 4, .dsmpd = 1, }, {}, }; static const char *pll_parents[] = {"xin24m"}; static struct rk_clk_pll_def ppll = { .clkdef = { .id = PLL_PPLL, .name = "ppll", .parent_names = pll_parents, .parent_cnt = nitems(pll_parents), }, .base_offset = 0x00, .rates = rk3399_pll_rates, }; static const char *pmu_parents[] = {"ppll"}; #define PCLK_PMU_SRC 19 static struct rk_clk_composite_def pclk_pmu_src = { .clkdef = { .id = PCLK_PMU_SRC, .name = "pclk_pmu_src", .parent_names = pmu_parents, .parent_cnt = nitems(pmu_parents), }, /* PMUCRU_CLKSEL_CON0 */ .muxdiv_offset = 0x80, .div_shift = 0, .div_width = 5, }; #define SCLK_I2C0_PMU 9 #define SCLK_I2C4_PMU 10 #define SCLK_I2C8_PMU 11 static struct rk_clk_composite_def i2c0 = { .clkdef = { .id = SCLK_I2C0_PMU, .name = "clk_i2c0_pmu", .parent_names = pmu_parents, .parent_cnt = nitems(pmu_parents), }, /* PMUCRU_CLKSEL_CON2 */ .muxdiv_offset = 0x88, .div_shift = 0, .div_width = 7, /* PMUCRU_CLKGATE_CON0 */ .gate_offset = 0x100, .gate_shift = 9, .flags = RK_CLK_COMPOSITE_HAVE_GATE, }; static struct rk_clk_composite_def i2c8 = { .clkdef = { .id = SCLK_I2C8_PMU, .name = "clk_i2c8_pmu", .parent_names = pmu_parents, .parent_cnt = nitems(pmu_parents), }, /* PMUCRU_CLKSEL_CON2 */ .muxdiv_offset = 0x88, .div_shift = 8, .div_width = 7, /* PMUCRU_CLKGATE_CON0 */ .gate_offset = 0x100, .gate_shift = 11, .flags = RK_CLK_COMPOSITE_HAVE_GATE, }; static struct rk_clk_composite_def i2c4 = { .clkdef = { .id = SCLK_I2C4_PMU, .name = "clk_i2c4_pmu", .parent_names = pmu_parents, .parent_cnt = nitems(pmu_parents), }, /* PMUCRU_CLKSEL_CON3 */ .muxdiv_offset = 0x8c, .div_shift = 0, .div_width = 7, /* PMUCRU_CLKGATE_CON0 */ .gate_offset = 0x100, .gate_shift = 10, .flags = RK_CLK_COMPOSITE_HAVE_GATE, }; static struct rk_clk rk3399_pmu_clks[] = { { .type = RK3399_CLK_PLL, .clk.pll = &ppll }, { .type = RK_CLK_COMPOSITE, .clk.composite = &pclk_pmu_src }, { .type = RK_CLK_COMPOSITE, .clk.composite = &i2c0 }, { .type = RK_CLK_COMPOSITE, .clk.composite = &i2c4 }, { .type = RK_CLK_COMPOSITE, .clk.composite = &i2c8 }, }; static int rk3399_pmucru_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) return (ENXIO); if (ofw_bus_is_compatible(dev, "rockchip,rk3399-pmucru")) { device_set_desc(dev, "Rockchip RK3399 PMU Clock and Reset Unit"); return (BUS_PROBE_DEFAULT); } return (ENXIO); } static int rk3399_pmucru_attach(device_t dev) { struct rk_cru_softc *sc; sc = device_get_softc(dev); sc->dev = dev; sc->gates = rk3399_pmu_gates; sc->ngates = nitems(rk3399_pmu_gates); sc->clks = rk3399_pmu_clks; sc->nclks = nitems(rk3399_pmu_clks); sc->reset_offset = 0x110; sc->reset_num = 30; return (rk_cru_attach(dev)); } static device_method_t rk3399_pmucru_methods[] = { /* Device interface */ DEVMETHOD(device_probe, rk3399_pmucru_probe), DEVMETHOD(device_attach, rk3399_pmucru_attach), DEVMETHOD_END }; DEFINE_CLASS_1(rk3399_pmucru, rk3399_pmucru_driver, rk3399_pmucru_methods, sizeof(struct rk_cru_softc), rk_cru_driver); EARLY_DRIVER_MODULE(rk3399_pmucru, simplebus, rk3399_pmucru_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/compat/linuxkpi/common/include/asm/fpu/api.h b/sys/compat/linuxkpi/common/include/asm/fpu/api.h index 133754abdc4b..b4e37ed9a3c1 100644 --- a/sys/compat/linuxkpi/common/include/asm/fpu/api.h +++ b/sys/compat/linuxkpi/common/include/asm/fpu/api.h @@ -1,40 +1,40 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 AUTHORS 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 AUTHORS 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. */ #ifndef _LINUXKPI_ASM_FPU_API_H_ #define _LINUXKPI_ASM_FPU_API_H_ #define kernel_fpu_begin() \ lkpi_kernel_fpu_begin() #define kernel_fpu_end() \ lkpi_kernel_fpu_end() extern void lkpi_kernel_fpu_begin(void); extern void lkpi_kernel_fpu_end(void); #endif /* _LINUXKPI_ASM_FPU_API_H_ */ diff --git a/sys/compat/linuxkpi/common/include/asm/neon.h b/sys/compat/linuxkpi/common/include/asm/neon.h index 2547fa9304d5..935b4055bc02 100644 --- a/sys/compat/linuxkpi/common/include/asm/neon.h +++ b/sys/compat/linuxkpi/common/include/asm/neon.h @@ -1,40 +1,40 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2022 Greg V + * Copyright (c) 2022 Val Packett * * 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 AUTHORS 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 AUTHORS 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. */ #ifndef _LINUXKPI_ASM_NEON_H_ #define _LINUXKPI_ASM_NEON_H_ #define kernel_neon_begin() \ lkpi_kernel_fpu_begin() #define kernel_neon_end() \ lkpi_kernel_fpu_end() extern void lkpi_kernel_fpu_begin(void); extern void lkpi_kernel_fpu_end(void); #endif /* _LINUXKPI_ASM_NEON_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_fpu.c b/sys/compat/linuxkpi/common/src/linux_fpu.c index 08f7e075d827..5b7021c4954b 100644 --- a/sys/compat/linuxkpi/common/src/linux_fpu.c +++ b/sys/compat/linuxkpi/common/src/linux_fpu.c @@ -1,73 +1,73 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 AUTHORS 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 AUTHORS 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 #include #include #include #include #include #if defined(__aarch64__) || defined(__amd64__) || defined(__i386__) #include /* * Technically the Linux API isn't supposed to allow nesting sections * either, but currently used versions of GPU drivers rely on nesting * working, so we only enter the section on the outermost level. */ void lkpi_kernel_fpu_begin(void) { if ((current->fpu_ctx_level)++ == 0) fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); } void lkpi_kernel_fpu_end(void) { if (--(current->fpu_ctx_level) == 0) fpu_kern_leave(curthread, NULL); } #else void lkpi_kernel_fpu_begin(void) { } void lkpi_kernel_fpu_end(void) { } #endif diff --git a/sys/dev/hid/hgame.c b/sys/dev/hid/hgame.c index b746661ae50c..5f63cfdd8cfb 100644 --- a/sys/dev/hid/hgame.c +++ b/sys/dev/hid/hgame.c @@ -1,235 +1,235 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020 Vladimir Kondratyev - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 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 AUTHOR 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 __FBSDID("$FreeBSD$"); /* * Generic HID game controller (joystick/gamepad) driver, */ #include #include #include #include #include #include #include #include #include #include #include #include #define HGAME_MAP_BRG(number_from, number_to, code) \ { HIDMAP_KEY_RANGE(HUP_BUTTON, number_from, number_to, code) } #define HGAME_MAP_ABS(usage, code) \ { HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code) } #define HGAME_MAP_GCB(usage, callback) \ { HIDMAP_ANY_CB(HUP_GENERIC_DESKTOP, HUG_##usage, callback) } #define HGAME_MAP_CRG(usage_from, usage_to, callback) \ { HIDMAP_ANY_CB_RANGE(HUP_GENERIC_DESKTOP, \ HUG_##usage_from, HUG_##usage_to, callback) } #define HGAME_FINALCB(cb) \ { HIDMAP_FINAL_CB(&cb) } static const struct hidmap_item hgame_map[] = { HGAME_MAP_BRG(1, 16, BTN_TRIGGER), HGAME_MAP_ABS(X, ABS_X), HGAME_MAP_ABS(Y, ABS_Y), HGAME_MAP_ABS(Z, ABS_Z), HGAME_MAP_ABS(RX, ABS_RX), HGAME_MAP_ABS(RY, ABS_RY), HGAME_MAP_ABS(RZ, ABS_RZ), HGAME_MAP_GCB(HAT_SWITCH, hgame_hat_switch_cb), HGAME_MAP_CRG(D_PAD_UP, D_PAD_LEFT, hgame_dpad_cb), HGAME_MAP_BRG(17, 57, BTN_TRIGGER_HAPPY), HGAME_FINALCB( hgame_final_cb), }; static const struct hid_device_id hgame_devs[] = { { HID_TLC(HUP_GENERIC_DESKTOP, HUG_JOYSTICK), HID_DRIVER_INFO(HUG_JOYSTICK) }, { HID_TLC(HUP_GENERIC_DESKTOP, HUG_GAME_PAD), HID_DRIVER_INFO(HUG_GAME_PAD) }, }; int hgame_hat_switch_cb(HIDMAP_CB_ARGS) { static const struct { int32_t x; int32_t y; } hat_switch_map[] = { {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1},{0, 0} }; struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); u_int idx; switch (HIDMAP_CB_GET_STATE()) { case HIDMAP_CB_IS_ATTACHING: evdev_support_event(evdev, EV_ABS); evdev_support_abs(evdev, ABS_HAT0X, -1, 1, 0, 0, 0); evdev_support_abs(evdev, ABS_HAT0Y, -1, 1, 0, 0, 0); break; case HIDMAP_CB_IS_RUNNING: idx = MIN(nitems(hat_switch_map) - 1, (u_int)ctx.data); evdev_push_abs(evdev, ABS_HAT0X, hat_switch_map[idx].x); evdev_push_abs(evdev, ABS_HAT0Y, hat_switch_map[idx].y); break; default: break; } return (0); } /* * Emulate the hat switch report via the D-pad usages * found on XInput/XBox style devices */ int hgame_dpad_cb(HIDMAP_CB_ARGS) { struct hgame_softc *sc = HIDMAP_CB_GET_SOFTC(); struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); int32_t data; switch (HIDMAP_CB_GET_STATE()) { case HIDMAP_CB_IS_ATTACHING: HIDMAP_CB_UDATA64 = HID_GET_USAGE(ctx.hi->usage); evdev_support_event(evdev, EV_ABS); evdev_support_abs(evdev, ABS_HAT0X, -1, 1, 0, 0, 0); evdev_support_abs(evdev, ABS_HAT0Y, -1, 1, 0, 0, 0); break; case HIDMAP_CB_IS_RUNNING: data = ctx.data; switch (HIDMAP_CB_UDATA64) { case HUG_D_PAD_UP: if (sc->dpad_down) return (ENOMSG); evdev_push_abs(evdev, ABS_HAT0Y, (data == 0) ? 0 : -1); sc->dpad_up = (data != 0); break; case HUG_D_PAD_DOWN: if (sc->dpad_up) return (ENOMSG); evdev_push_abs(evdev, ABS_HAT0Y, (data == 0) ? 0 : 1); sc->dpad_down = (data != 0); break; case HUG_D_PAD_RIGHT: if (sc->dpad_left) return (ENOMSG); evdev_push_abs(evdev, ABS_HAT0X, (data == 0) ? 0 : 1); sc->dpad_right = (data != 0); break; case HUG_D_PAD_LEFT: if (sc->dpad_right) return (ENOMSG); evdev_push_abs(evdev, ABS_HAT0X, (data == 0) ? 0 : -1); sc->dpad_left = (data != 0); break; } break; default: break; } return (0); } int hgame_final_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) evdev_support_prop(evdev, INPUT_PROP_DIRECT); /* Do not execute callback at interrupt handler and detach */ return (ENOSYS); } static int hgame_probe(device_t dev) { const struct hid_device_info *hw = hid_get_device_info(dev); struct hgame_softc *sc = device_get_softc(dev); int error; if (hid_test_quirk(hw, HQ_IS_XBOX360GP)) return(ENXIO); error = HIDMAP_PROBE(&sc->hm, dev, hgame_devs, hgame_map, NULL); if (error > 0) return (error); hidbus_set_desc(dev, hidbus_get_driver_info(dev) == HUG_GAME_PAD ? "Gamepad" : "Joystick"); return (BUS_PROBE_GENERIC); } static int hgame_attach(device_t dev) { struct hgame_softc *sc = device_get_softc(dev); return (hidmap_attach(&sc->hm)); } static int hgame_detach(device_t dev) { struct hgame_softc *sc = device_get_softc(dev); return (hidmap_detach(&sc->hm)); } static device_method_t hgame_methods[] = { DEVMETHOD(device_probe, hgame_probe), DEVMETHOD(device_attach, hgame_attach), DEVMETHOD(device_detach, hgame_detach), DEVMETHOD_END }; DEFINE_CLASS_0(hgame, hgame_driver, hgame_methods, sizeof(struct hgame_softc)); DRIVER_MODULE(hgame, hidbus, hgame_driver, NULL, NULL); MODULE_DEPEND(hgame, hid, 1, 1, 1); MODULE_DEPEND(hgame, hidbus, 1, 1, 1); MODULE_DEPEND(hgame, hidmap, 1, 1, 1); MODULE_DEPEND(hgame, evdev, 1, 1, 1); MODULE_VERSION(hgame, 1); HID_PNP_INFO(hgame_devs); diff --git a/sys/dev/hid/hgame.h b/sys/dev/hid/hgame.h index 702c65a4a4c1..f2f12798bde7 100644 --- a/sys/dev/hid/hgame.h +++ b/sys/dev/hid/hgame.h @@ -1,46 +1,46 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020 Vladimir Kondratyev - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 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 AUTHOR 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. */ #ifndef _HID_HGAME_H_ #define _HID_HGAME_H_ #include hidmap_cb_t hgame_hat_switch_cb; hidmap_cb_t hgame_dpad_cb; hidmap_cb_t hgame_final_cb; struct hgame_softc { struct hidmap hm; bool dpad_up; bool dpad_down; bool dpad_right; bool dpad_left; }; #endif /* !_HGAME_H_ */ diff --git a/sys/dev/hid/hpen.c b/sys/dev/hid/hpen.c index 6ffd1f387a0b..456014abb332 100644 --- a/sys/dev/hid/hpen.c +++ b/sys/dev/hid/hpen.c @@ -1,262 +1,262 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2019 Vladimir Kondratyev - * Copyright (c) 2019 Greg V + * Copyright (c) 2019 Val Packett * * 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 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 AUTHOR 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 __FBSDID("$FreeBSD$"); /* * Generic / MS Windows compatible HID pen tablet driver: * https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/required-hid-top-level-collections * * Tested on: Wacom WCOM50C1 (Google Pixelbook "eve") */ #include #include #include #include #include #include #include #include #include #include #include #include #include "usbdevs.h" static const uint8_t hpen_graphire_report_descr[] = { HID_GRAPHIRE_REPORT_DESCR() }; static const uint8_t hpen_graphire3_4x5_report_descr[] = { HID_GRAPHIRE3_4X5_REPORT_DESCR() }; static hidmap_cb_t hpen_battery_strenght_cb; static hidmap_cb_t hpen_final_pen_cb; #define HPEN_MAP_BUT(usage, code) \ HIDMAP_KEY(HUP_DIGITIZERS, HUD_##usage, code) #define HPEN_MAP_ABS(usage, code) \ HIDMAP_ABS(HUP_DIGITIZERS, HUD_##usage, code) #define HPEN_MAP_ABS_GD(usage, code) \ HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code) #define HPEN_MAP_ABS_CB(usage, cb) \ HIDMAP_ABS_CB(HUP_DIGITIZERS, HUD_##usage, &cb) /* Generic map digitizer page map according to hut1_12v2.pdf */ static const struct hidmap_item hpen_map_pen[] = { { HPEN_MAP_ABS_GD(X, ABS_X), .required = true }, { HPEN_MAP_ABS_GD(Y, ABS_Y), .required = true }, { HPEN_MAP_ABS( TIP_PRESSURE, ABS_PRESSURE) }, { HPEN_MAP_ABS( X_TILT, ABS_TILT_X) }, { HPEN_MAP_ABS( Y_TILT, ABS_TILT_Y) }, { HPEN_MAP_ABS( CONTACTID, 0), .forbidden = true }, { HPEN_MAP_ABS( CONTACTCOUNT, 0), .forbidden = true }, { HPEN_MAP_ABS_CB(BATTERY_STRENGTH, hpen_battery_strenght_cb) }, { HPEN_MAP_BUT( TOUCH, BTN_TOUCH) }, { HPEN_MAP_BUT( TIP_SWITCH, BTN_TOUCH) }, { HPEN_MAP_BUT( SEC_TIP_SWITCH, BTN_TOUCH) }, { HPEN_MAP_BUT( BARREL_SWITCH, BTN_STYLUS) }, { HPEN_MAP_BUT( INVERT, BTN_TOOL_RUBBER) }, { HPEN_MAP_BUT( ERASER, BTN_TOUCH) }, { HPEN_MAP_BUT( TABLET_PICK, BTN_STYLUS2) }, { HPEN_MAP_BUT( SEC_BARREL_SWITCH,BTN_STYLUS2) }, { HIDMAP_FINAL_CB( &hpen_final_pen_cb) }, }; static const struct hidmap_item hpen_map_stylus[] = { { HPEN_MAP_BUT( IN_RANGE, BTN_TOOL_PEN) }, }; static const struct hidmap_item hpen_map_finger[] = { { HPEN_MAP_BUT( IN_RANGE, BTN_TOOL_FINGER) }, }; static const struct hid_device_id hpen_devs[] = { { HID_TLC(HUP_DIGITIZERS, HUD_DIGITIZER) }, { HID_TLC(HUP_DIGITIZERS, HUD_PEN) }, { HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN), HID_BVP(BUS_USB, USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL) }, }; /* Do not autoload legacy pen driver for all touchscreen */ static const struct hid_device_id hpen_devs_no_load[] = { { HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN) }, }; static int hpen_battery_strenght_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); switch (HIDMAP_CB_GET_STATE()) { case HIDMAP_CB_IS_ATTACHING: evdev_support_event(evdev, EV_PWR); /* TODO */ break; case HIDMAP_CB_IS_RUNNING: /* TODO */ break; default: break; } return (0); } static int hpen_final_pen_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { if (hidbus_get_usage(HIDMAP_CB_GET_DEV()) == HID_USAGE2(HUP_DIGITIZERS, HUD_DIGITIZER)) evdev_support_prop(evdev, INPUT_PROP_POINTER); else evdev_support_prop(evdev, INPUT_PROP_DIRECT); } /* Do not execute callback at interrupt handler and detach */ return (ENOSYS); } static void hpen_identify(driver_t *driver, device_t parent) { const struct hid_device_info *hw = hid_get_device_info(parent); /* the report descriptor for the Wacom Graphire is broken */ if (hw->idBus == BUS_USB && hw->idVendor == USB_VENDOR_WACOM) { switch (hw->idProduct) { case USB_PRODUCT_WACOM_GRAPHIRE: hid_set_report_descr(parent, hpen_graphire_report_descr, sizeof(hpen_graphire_report_descr)); break; case USB_PRODUCT_WACOM_GRAPHIRE3_4X5: hid_set_report_descr(parent, hpen_graphire3_4x5_report_descr, sizeof(hpen_graphire3_4x5_report_descr)); break; } } } static int hpen_probe(device_t dev) { struct hidmap *hm = device_get_softc(dev); const char *desc; void *d_ptr; hid_size_t d_len; int error; if (HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs_no_load) != 0) { error = HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs); if (error != 0) return (error); } hidmap_set_dev(hm, dev); /* Check if report descriptor belongs to a HID pen device */ error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL); if (error != 0) return (error); if (hid_get_report_descr(dev, &d_ptr, &d_len) != 0) return (ENXIO); if (hidbus_is_collection(d_ptr, d_len, HID_USAGE2(HUP_DIGITIZERS, HUD_FINGER), hidbus_get_index(dev))) { HIDMAP_ADD_MAP(hm, hpen_map_finger, NULL); desc = "TouchScreen"; } else { HIDMAP_ADD_MAP(hm, hpen_map_stylus, NULL); desc = "Pen"; } if (hidbus_get_usage(dev) == HID_USAGE2(HUP_DIGITIZERS, HUD_DIGITIZER)) desc = "Digitizer"; hidbus_set_desc(dev, desc); return (BUS_PROBE_DEFAULT); } static int hpen_attach(device_t dev) { const struct hid_device_info *hw = hid_get_device_info(dev); struct hidmap *hm = device_get_softc(dev); int error; if (hw->idBus == BUS_USB && hw->idVendor == USB_VENDOR_WACOM && hw->idProduct == USB_PRODUCT_WACOM_GRAPHIRE3_4X5) { /* * The Graphire3 needs 0x0202 to be written to * feature report ID 2 before it'll start * returning digitizer data. */ static const uint8_t reportbuf[3] = {2, 2, 2}; error = hid_set_report(dev, reportbuf, sizeof(reportbuf), HID_FEATURE_REPORT, reportbuf[0]); if (error) device_printf(dev, "set feature report failed, " "error=%d (ignored)\n", error); } return (hidmap_attach(hm)); } static int hpen_detach(device_t dev) { return (hidmap_detach(device_get_softc(dev))); } static device_method_t hpen_methods[] = { DEVMETHOD(device_identify, hpen_identify), DEVMETHOD(device_probe, hpen_probe), DEVMETHOD(device_attach, hpen_attach), DEVMETHOD(device_detach, hpen_detach), DEVMETHOD_END }; DEFINE_CLASS_0(hpen, hpen_driver, hpen_methods, sizeof(struct hidmap)); DRIVER_MODULE(hpen, hidbus, hpen_driver, NULL, NULL); MODULE_DEPEND(hpen, hid, 1, 1, 1); MODULE_DEPEND(hpen, hidbus, 1, 1, 1); MODULE_DEPEND(hpen, hidmap, 1, 1, 1); MODULE_DEPEND(hpen, evdev, 1, 1, 1); MODULE_VERSION(hpen, 1); HID_PNP_INFO(hpen_devs); diff --git a/sys/dev/hid/xb360gp.c b/sys/dev/hid/xb360gp.c index 8f4377305f8a..d6a2bc6a47cc 100644 --- a/sys/dev/hid/xb360gp.c +++ b/sys/dev/hid/xb360gp.c @@ -1,182 +1,182 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020 Vladimir Kondratyev - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 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 AUTHOR 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 __FBSDID("$FreeBSD$"); /* * XBox 360 gamepad driver thanks to the custom descriptor in usbhid. * * Tested on: SVEN GC-5070 in both XInput (XBox 360) and DirectInput modes */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static const uint8_t xb360gp_rdesc[] = {HID_XB360GP_REPORT_DESCR()}; #define XB360GP_MAP_BUT(number, code) \ { HIDMAP_KEY(HUP_BUTTON, number, code) } #define XB360GP_MAP_ABS(usage, code) \ { HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code) } #define XB360GP_MAP_ABS_FLT(usage, code) \ { HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code), \ .fuzz = 16, .flat = 128 } #define XB360GP_MAP_ABS_INV(usage, code) \ { HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code), \ .fuzz = 16, .flat = 128, .invert_value = true } #define XB360GP_MAP_CRG(usage_from, usage_to, callback) \ { HIDMAP_ANY_CB_RANGE(HUP_GENERIC_DESKTOP, \ HUG_##usage_from, HUG_##usage_to, callback) } #define XB360GP_FINALCB(cb) \ { HIDMAP_FINAL_CB(&cb) } /* Customized to match usbhid's XBox 360 descriptor */ static const struct hidmap_item xb360gp_map[] = { XB360GP_MAP_BUT(1, BTN_SOUTH), XB360GP_MAP_BUT(2, BTN_EAST), XB360GP_MAP_BUT(3, BTN_WEST), XB360GP_MAP_BUT(4, BTN_NORTH), XB360GP_MAP_BUT(5, BTN_TL), XB360GP_MAP_BUT(6, BTN_TR), XB360GP_MAP_BUT(7, BTN_SELECT), XB360GP_MAP_BUT(8, BTN_START), XB360GP_MAP_BUT(9, BTN_THUMBL), XB360GP_MAP_BUT(10, BTN_THUMBR), XB360GP_MAP_BUT(11, BTN_MODE), XB360GP_MAP_CRG(D_PAD_UP, D_PAD_LEFT, hgame_dpad_cb), XB360GP_MAP_ABS_FLT(X, ABS_X), XB360GP_MAP_ABS_INV(Y, ABS_Y), XB360GP_MAP_ABS(Z, ABS_Z), XB360GP_MAP_ABS_FLT(RX, ABS_RX), XB360GP_MAP_ABS_INV(RY, ABS_RY), XB360GP_MAP_ABS(RZ, ABS_RZ), XB360GP_FINALCB( hgame_final_cb), }; static const STRUCT_USB_HOST_ID xb360gp_devs[] = { /* the Xbox 360 gamepad doesn't use the HID class */ {USB_IFACE_CLASS(UICLASS_VENDOR), USB_IFACE_SUBCLASS(UISUBCLASS_XBOX360_CONTROLLER), USB_IFACE_PROTOCOL(UIPROTO_XBOX360_GAMEPAD),}, }; static void xb360gp_identify(driver_t *driver, device_t parent) { const struct hid_device_info *hw = hid_get_device_info(parent); /* the Xbox 360 gamepad has no report descriptor */ if (hid_test_quirk(hw, HQ_IS_XBOX360GP)) hid_set_report_descr(parent, xb360gp_rdesc, sizeof(xb360gp_rdesc)); } static int xb360gp_probe(device_t dev) { struct hgame_softc *sc = device_get_softc(dev); const struct hid_device_info *hw = hid_get_device_info(dev); int error; if (!hid_test_quirk(hw, HQ_IS_XBOX360GP)) return (ENXIO); hidmap_set_dev(&sc->hm, dev); error = HIDMAP_ADD_MAP(&sc->hm, xb360gp_map, NULL); if (error != 0) return (error); device_set_desc(dev, "XBox 360 Gamepad"); return (BUS_PROBE_DEFAULT); } static int xb360gp_attach(device_t dev) { struct hgame_softc *sc = device_get_softc(dev); int error; /* * Turn off the four LEDs on the gamepad which * are blinking by default: */ static const uint8_t reportbuf[3] = {1, 3, 0}; error = hid_set_report(dev, reportbuf, sizeof(reportbuf), HID_OUTPUT_REPORT, 0); if (error) device_printf(dev, "set output report failed, error=%d " "(ignored)\n", error); return (hidmap_attach(&sc->hm)); } static int xb360gp_detach(device_t dev) { struct hgame_softc *sc = device_get_softc(dev); return (hidmap_detach(&sc->hm)); } static device_method_t xb360gp_methods[] = { DEVMETHOD(device_identify, xb360gp_identify), DEVMETHOD(device_probe, xb360gp_probe), DEVMETHOD(device_attach, xb360gp_attach), DEVMETHOD(device_detach, xb360gp_detach), DEVMETHOD_END }; DEFINE_CLASS_0(xb360gp, xb360gp_driver, xb360gp_methods, sizeof(struct hgame_softc)); DRIVER_MODULE(xb360gp, hidbus, xb360gp_driver, NULL, NULL); MODULE_DEPEND(xb360gp, hid, 1, 1, 1); MODULE_DEPEND(xb360gp, hidbus, 1, 1, 1); MODULE_DEPEND(xb360gp, hidmap, 1, 1, 1); MODULE_DEPEND(xb360gp, hgame, 1, 1, 1); MODULE_DEPEND(xb360gp, evdev, 1, 1, 1); MODULE_VERSION(xb360gp, 1); USB_PNP_HOST_INFO(xb360gp_devs); diff --git a/sys/dev/usb/controller/generic_xhci_acpi.c b/sys/dev/usb/controller/generic_xhci_acpi.c index b5fa9d7009b9..a88a5c3bc7d9 100644 --- a/sys/dev/usb/controller/generic_xhci_acpi.c +++ b/sys/dev/usb/controller/generic_xhci_acpi.c @@ -1,84 +1,84 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2019 Greg V + * Copyright (c) 2019 Val Packett * * 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 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 AUTHOR 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 __FBSDID("$FreeBSD$"); #include "opt_acpi.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "generic_xhci.h" static char *xhci_ids[] = { "PNP0D10", "PNP0D15", NULL, }; static int generic_xhci_acpi_probe(device_t dev) { if (ACPI_ID_PROBE(device_get_parent(dev), dev, xhci_ids, NULL) >= 0) return (ENXIO); device_set_desc(dev, XHCI_HC_DEVSTR); return (BUS_PROBE_GENERIC); } static device_method_t xhci_acpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, generic_xhci_acpi_probe), DEVMETHOD_END }; DEFINE_CLASS_1(xhci, xhci_acpi_driver, xhci_acpi_methods, sizeof(struct xhci_softc), generic_xhci_driver); DRIVER_MODULE(xhci, acpi, xhci_acpi_driver, 0, 0); MODULE_DEPEND(xhci, usb, 1, 1, 1); diff --git a/sys/sys/eventfd.h b/sys/sys/eventfd.h index 1bdec8ebc269..8024dd0bd113 100644 --- a/sys/sys/eventfd.h +++ b/sys/sys/eventfd.h @@ -1,54 +1,54 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 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 AUTHOR 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. */ #ifndef _SYS_EVENTFD_H_ #define _SYS_EVENTFD_H_ #include typedef uint64_t eventfd_t; #define EFD_SEMAPHORE 0x00000001 #define EFD_NONBLOCK 0x00000004 #define EFD_CLOEXEC 0x00100000 #ifdef _KERNEL int eventfd_create_file(struct thread *td, struct file *fp, uint32_t initval, int flags); #else __BEGIN_DECLS int eventfd(unsigned int initval, int flags); int eventfd_read(int fd, eventfd_t *value); int eventfd_write(int fd, eventfd_t value); __END_DECLS #endif /* !_KERNEL */ #endif /* !_SYS_EVENTFD_H_ */ diff --git a/sys/sys/specialfd.h b/sys/sys/specialfd.h index c388bdcb7b6f..169cf72ed64a 100644 --- a/sys/sys/specialfd.h +++ b/sys/sys/specialfd.h @@ -1,42 +1,42 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * 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 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 AUTHOR 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. * * $FreeBSD$ */ #ifndef _SYS_SPECIALFD_H_ #define _SYS_SPECIALFD_H_ enum specialfd_type { SPECIALFD_EVENTFD = 1, }; struct specialfd_eventfd { unsigned int initval; int flags; }; #endif /* !_SYS_SPECIALFD_H_ */