CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 30 13:02:18 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot efiacpi.c version Added Files: src/sys/stand/efiboot: smbios.c smbios.h Log Message: Use SMBIOS system vendor and product strings to create a "model" string for the root node in the fabricated ACPI device tree, when possible. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/smbios.c \ src/sys/stand/efiboot/smbios.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 30 13:02:18 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot efiacpi.c version Added Files: src/sys/stand/efiboot: smbios.c smbios.h Log Message: Use SMBIOS system vendor and product strings to create a "model" string for the root node in the fabricated ACPI device tree, when possible. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/smbios.c \ src/sys/stand/efiboot/smbios.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.8 src/sys/stand/efiboot/Makefile.efiboot:1.9 --- src/sys/stand/efiboot/Makefile.efiboot:1.8 Sun Jul 21 17:01:39 2019 +++ src/sys/stand/efiboot/Makefile.efiboot Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.8 2019/07/21 17:01:39 rin Exp $ +# $NetBSD: Makefile.efiboot,v 1.9 2019/11/30 13:02:18 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang .PATH: ${EFIDIR}/gnuefi SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c SOURCES+= boot.c conf.c console.c dev_net.c devopen.c exec.c panic.c prompt.c -SOURCES+= efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c +SOURCES+= efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c smbios.c .PATH: ${S}/external/bsd/libfdt/dist CPPFLAGS+= -I${S}/external/bsd/libfdt/dist Index: src/sys/stand/efiboot/efiacpi.c diff -u src/sys/stand/efiboot/efiacpi.c:1.4 src/sys/stand/efiboot/efiacpi.c:1.5 --- src/sys/stand/efiboot/efiacpi.c:1.4 Thu Aug 1 13:11:16 2019 +++ src/sys/stand/efiboot/efiacpi.c Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiacpi.c,v 1.4 2019/08/01 13:11:16 jmcneill Exp $ */ +/* $NetBSD: efiacpi.c,v 1.5 2019/11/30 13:02:18 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #include "efiboot.h" #include "efiacpi.h" #include "efifdt.h" +#include "smbios.h" #include @@ -77,6 +78,39 @@ efi_acpi_show(void) printf("\n"); } +static char model_buf[128]; + +static const char * +efi_acpi_get_model(void) +{ + struct smbtable smbios; + struct smbios_sys *psys; + const char *s; + char *buf; + + memset(model_buf, 0, sizeof(model_buf)); + + if (smbios3_table != NULL) { + smbios_init(smbios3_table); + + buf = model_buf; + smbios.cookie = 0; + if (smbios_find_table(SMBIOS_TYPE_SYSTEM, )) { + psys = smbios.tblhdr; + if ((s = smbios_get_string(, psys->vendor, buf, 64)) != NULL) { +buf += strlen(s); +*buf++ = ' '; + } + smbios_get_string(, psys->product, buf, 64); + } + } + + if (model_buf[0] == '\0') + strcpy(model_buf, "ACPI"); + + return model_buf; +} + int efi_acpi_create_fdt(void) { @@ -94,8 +128,10 @@ efi_acpi_create_fdt(void) if (error) return EIO; + const char *model = efi_acpi_get_model(); + fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "compatible", "netbsd,generic-acpi"); - fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", "ACPI"); + fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", model); fdt_setprop_cell(fdt, fdt_path_offset(fdt, "/"), "#address-cells", 2); fdt_setprop_cell(fdt, fdt_path_offset(fdt, "/"), "#size-cells", 2); Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.12 src/sys/stand/efiboot/version:1.13 --- src/sys/stand/efiboot/version:1.12 Thu Aug 1 13:11:16 2019 +++ src/sys/stand/efiboot/version Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.12 2019/08/01 13:11:16 jmcneill Exp $ +$NetBSD: version,v 1.13 2019/11/30 13:02:18 jmcneill Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item @@ -16,3 +16,4 @@ is taken as the current. 1.9: Add support for efiboot.plist and loading device tree overlays. 1.10: Add support for EFI GOP framebuffers in ACPI mode. 1.11: Add full UEFI memory map to /chosen node. +1.12: Derive ACPI model string from SMBIOS. Added files: Index: src/sys/stand/efiboot/smbios.c diff -u /dev/null src/sys/stand/efiboot/smbios.c:1.1 --- /dev/null Sat Nov 30 13:02:18 2019 +++ src/sys/stand/efiboot/smbios.c Sat Nov 30 13:02:18 2019 @@ -0,0 +1,190 @@ +/* $NetBSD: smbios.c,v 1.1 2019/11/30 13:02:18 jmcneill Exp $ */ + +/* + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Fri Nov 29 20:54:17 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC Log Message: Add tiwdt To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Fri Nov 29 20:54:00 UTC 2019 Modified Files: src/sys/arch/arm/ti: am3_prcm.c files.ti Added Files: src/sys/arch/arm/ti: ti_wdt.c Log Message: Add TI OMAP watchdog timer driver. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Fri Nov 29 20:54:17 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC Log Message: Add tiwdt To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC diff -u src/sys/arch/evbarm/conf/GENERIC:1.67 src/sys/arch/evbarm/conf/GENERIC:1.68 --- src/sys/arch/evbarm/conf/GENERIC:1.67 Sun Nov 3 22:59:24 2019 +++ src/sys/arch/evbarm/conf/GENERIC Fri Nov 29 20:54:17 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC,v 1.67 2019/11/03 22:59:24 jmcneill Exp $ +# $NetBSD: GENERIC,v 1.68 2019/11/29 20:54:17 jmcneill Exp $ # # GENERIC ARM (aarch32) kernel # @@ -401,10 +401,11 @@ sunxihstimer* at fdt? # Allwinner Hig tegratimer* at fdt? # Timers # Watchdog +bcmpmwdog* at fdt? # Broadcom BCM283x watchdog dwcwdt* at fdt? # DesignWare watchdog mesonwdt* at fdt? # Amlogic Meson watchdog sunxiwdt* at fdt? # Allwinner watchdog -bcmpmwdog* at fdt? # Broadcom BCM283x watchdog +tiwdt* at fdt? # TI OMAP watchdog # Interrupt controller gic* at fdt? pass 1 # ARM GIC
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Fri Nov 29 20:54:00 UTC 2019 Modified Files: src/sys/arch/arm/ti: am3_prcm.c files.ti Added Files: src/sys/arch/arm/ti: ti_wdt.c Log Message: Add TI OMAP watchdog timer driver. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/ti/am3_prcm.c diff -u src/sys/arch/arm/ti/am3_prcm.c:1.11 src/sys/arch/arm/ti/am3_prcm.c:1.12 --- src/sys/arch/arm/ti/am3_prcm.c:1.11 Wed Nov 27 23:02:54 2019 +++ src/sys/arch/arm/ti/am3_prcm.c Fri Nov 29 20:54:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */ +/* $NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $"); #include #include @@ -169,6 +169,8 @@ static struct ti_prcm_clk am3_prcm_clks[ AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"), AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"), + AM3_PRCM_HWMOD_WKUP("wd_timer2", 0xd4, "FIXED_32K"), + AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"), AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"), AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"), Index: src/sys/arch/arm/ti/files.ti diff -u src/sys/arch/arm/ti/files.ti:1.20 src/sys/arch/arm/ti/files.ti:1.21 --- src/sys/arch/arm/ti/files.ti:1.20 Sun Nov 3 22:59:06 2019 +++ src/sys/arch/arm/ti/files.ti Fri Nov 29 20:54:00 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.ti,v 1.20 2019/11/03 22:59:06 jmcneill Exp $ +# $NetBSD: files.ti,v 1.21 2019/11/29 20:54:00 jmcneill Exp $ # file arch/arm/ti/ti_cpufreq.c soc_ti @@ -131,6 +131,11 @@ device omapnand: nandbus attach omapnand at fdt file arch/arm/ti/omap2_nand.c omapnand +# Watchdog timer +device tiwdt: sysmon_wdog +attach tiwdt at fdt with ti_wdt +file arch/arm/ti/ti_wdt.c ti_wdt + # SOC parameters defflag opt_soc.h SOC_TI defflag opt_soc.h SOC_AM33XX: SOC_TI Added files: Index: src/sys/arch/arm/ti/ti_wdt.c diff -u /dev/null src/sys/arch/arm/ti/ti_wdt.c:1.1 --- /dev/null Fri Nov 29 20:54:00 2019 +++ src/sys/arch/arm/ti/ti_wdt.c Fri Nov 29 20:54:00 2019 @@ -0,0 +1,259 @@ +/* $NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $"); + +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#define WDT_WDSC 0x10 +#define WDSC_SOFTRESET __BIT(1) +#define WDT_WDST 0x14 +#define WDT_WISR 0x18 +#define WDT_WIER 0x1c +#define WDT_WCLR 0x24 +#define WCLR_PRE __BIT(5) +#define WCLR_PTV __BITS(4,2) +#define WDT_WCRR 0x28 +#define WDT_WLDR 0x2c +#define WDT_WTGR 0x30 +#define WDT_WWPS 0x34 +#define WWPS_W_PEND_WDLY __BIT(5) +#define WWPS_W_PEND_WSPR __BIT(4) +#define WWPS_W_PEND_WTGR __BIT(3) +#define WWPS_W_PEND_WLDR __BIT(2) +#define WWPS_W_PEND_WCRR __BIT(1) +#define WWPS_W_PEND_WCLR __BIT(0) +#define WWPS_W_PEND_MASK __BITS(5,0) +#define WDT_WDLY 0x44 +#define WDT_WSPR 0x48 +#define WDT_WIRQSTATRAW 0x54 +#define WDT_WIRQSTAT 0x58 +#define WDT_WIRQENSET 0x5c +#define WDT_WIRQENCLR 0x60 +#define WIRQ_EVENT_DLY __BIT(1) +#define WIRQ_EVENT_OVF __BIT(0) + +#define
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Fri Nov 29 00:36:22 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_pcie.c Log Message: Do not crash if the optional vpcie3v3-supply property is missing or the regulator can not be found. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk3399_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Fri Nov 29 00:36:22 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_pcie.c Log Message: Do not crash if the optional vpcie3v3-supply property is missing or the regulator can not be found. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk3399_pcie.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk3399_pcie.c diff -u src/sys/arch/arm/rockchip/rk3399_pcie.c:1.6 src/sys/arch/arm/rockchip/rk3399_pcie.c:1.7 --- src/sys/arch/arm/rockchip/rk3399_pcie.c:1.6 Sun Jun 23 16:15:43 2019 +++ src/sys/arch/arm/rockchip/rk3399_pcie.c Fri Nov 29 00:36:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk3399_pcie.c,v 1.6 2019/06/23 16:15:43 jmcneill Exp $ */ +/* $NetBSD: rk3399_pcie.c,v 1.7 2019/11/29 00:36:22 jmcneill Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -17,7 +17,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: rk3399_pcie.c,v 1.6 2019/06/23 16:15:43 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: rk3399_pcie.c,v 1.7 2019/11/29 00:36:22 jmcneill Exp $"); #include #include @@ -241,8 +241,10 @@ rkpcie_attach(device_t parent, device_t struct fdtbus_regulator *regulator; regulator = fdtbus_regulator_acquire(phandle, "vpcie3v3-supply"); - fdtbus_regulator_enable(regulator); - fdtbus_regulator_release(regulator); + if (regulator != NULL) { + fdtbus_regulator_enable(regulator); + fdtbus_regulator_release(regulator); + } fdtbus_clock_assign(phandle); clock_enable_all(phandle);
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Thu Nov 28 23:57:09 UTC 2019 Modified Files: src/sys/arch/arm/ti: ti_sdhc.c Log Message: Support 1-bit mode and force all xfers to bounce to workaround a transfer error issue for now To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Thu Nov 28 23:57:09 UTC 2019 Modified Files: src/sys/arch/arm/ti: ti_sdhc.c Log Message: Support 1-bit mode and force all xfers to bounce to workaround a transfer error issue for now To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/ti/ti_sdhc.c diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.4 src/sys/arch/arm/ti/ti_sdhc.c:1.5 --- src/sys/arch/arm/ti/ti_sdhc.c:1.4 Wed Nov 27 23:03:24 2019 +++ src/sys/arch/arm/ti/ti_sdhc.c Thu Nov 28 23:57:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $ */ +/* $NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $"); #include #include @@ -428,15 +428,21 @@ static int ti_sdhc_bus_width(struct sdhc_softc *sc, int width) { struct ti_sdhc_softc *hmsc = (struct ti_sdhc_softc *)sc; - uint32_t con; + uint32_t con, hctl; con = bus_space_read_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON); + hctl = SDHC_READ(hmsc, SDHC_HOST_CTL); if (width == 8) { con |= CON_DW8; + } else if (width == 4) { + con &= ~CON_DW8; + hctl |= SDHC_4BIT_MODE; } else { con &= ~CON_DW8; + hctl &= ~SDHC_4BIT_MODE; } bus_space_write_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON, con); + SDHC_WRITE(hmsc, SDHC_HOST_CTL, hctl); return 0; } @@ -487,6 +493,13 @@ ti_sdhc_edma_init(struct ti_sdhc_softc * error); return error; } + error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap, + sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK); + if (error) { + device_printf(sc->sc.sc_dev, "couldn't load dmamap: %d\n", + error); + return error; + } return error; } @@ -496,24 +509,23 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc { struct ti_sdhc_softc *sc = device_private(sdhc_sc->sc_dev); const bus_dmamap_t map = cmd->c_dmamap; - int seg, error; bool bounce; + int error; - for (bounce = false, seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) { - if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0) { +#if notyet + bounce = false; + for (int seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) { + if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0 || + (cmd->c_dmamap->dm_segs[seg].ds_len & 3) != 0) { bounce = true; break; } } +#else + bounce = true; +#endif if (bounce) { - error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap, - sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK); - if (error) { - device_printf(sc->sc.sc_dev, - "[bounce] bus_dmamap_load failed: %d\n", error); - return error; - } if (ISSET(cmd->c_flags, SCF_CMD_READ)) { bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0, MAXPHYS, BUS_DMASYNC_PREREAD); @@ -536,7 +548,6 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0, MAXPHYS, BUS_DMASYNC_POSTWRITE); } - bus_dmamap_unload(sc->sc.sc_dmat, sc->sc_edma_dmamap); if (ISSET(cmd->c_flags, SCF_CMD_READ) && error == 0) { memcpy(cmd->c_data, sc->sc_edma_bbuf, cmd->c_datalen); }
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Wed Nov 27 23:03:24 UTC 2019 Modified Files: src/sys/arch/arm/ti: ti_sdhc.c Log Message: Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/ti/ti_sdhc.c diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.3 src/sys/arch/arm/ti/ti_sdhc.c:1.4 --- src/sys/arch/arm/ti/ti_sdhc.c:1.3 Tue Oct 29 22:19:13 2019 +++ src/sys/arch/arm/ti/ti_sdhc.c Wed Nov 27 23:03:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $ */ +/* $NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $"); #include #include @@ -180,7 +180,6 @@ ti_sdhc_attach(device_t parent, device_t sc->sc_addr = addr; sc->sc_bst = faa->faa_bst; -#if notyet /* XXX use fdtbus_dma API */ int len; const u_int *dmas = fdtbus_get_prop(phandle, "dmas", ); @@ -198,10 +197,6 @@ ti_sdhc_attach(device_t parent, device_t sc->sc_edma_chan[EDMA_CHAN_RX] = -1; break; } -#else - sc->sc_edma_chan[EDMA_CHAN_TX] = -1; - sc->sc_edma_chan[EDMA_CHAN_RX] = -1; -#endif if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) { aprint_error(": couldn't map registers\n"); @@ -219,7 +214,7 @@ ti_sdhc_attach(device_t parent, device_t sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE; if (of_hasprop(phandle, "ti,needs-special-reset")) sc->sc.sc_flags |= SDHC_FLAG_WAIT_RESET; - if (of_hasprop(phandle, "ti,needs-special-hs-handling")) + if (!of_hasprop(phandle, "ti,needs-special-hs-handling")) sc->sc.sc_flags |= SDHC_FLAG_NO_HS_BIT; if (of_hasprop(phandle, "ti,dual-volt")) sc->sc.sc_caps = SDHC_VOLTAGE_SUPP_3_0V;
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Wed Nov 27 23:03:24 UTC 2019 Modified Files: src/sys/arch/arm/ti: ti_sdhc.c Log Message: Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Wed Nov 27 23:02:54 UTC 2019 Modified Files: src/sys/arch/arm/ti: am3_prcm.c Log Message: Fix mmc and timer indexes. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/ti/am3_prcm.c diff -u src/sys/arch/arm/ti/am3_prcm.c:1.10 src/sys/arch/arm/ti/am3_prcm.c:1.11 --- src/sys/arch/arm/ti/am3_prcm.c:1.10 Mon Nov 4 09:37:51 2019 +++ src/sys/arch/arm/ti/am3_prcm.c Wed Nov 27 23:02:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $ */ +/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $"); #include #include @@ -161,7 +161,7 @@ static struct ti_prcm_clk am3_prcm_clks[ AM3_PRCM_HWMOD_PER("gpio3", 0xb0, "PERIPH_CLK"), AM3_PRCM_HWMOD_PER("gpio4", 0xb4, "PERIPH_CLK"), - AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"), + AM3_PRCM_HWMOD_WKUP("timer1", 0x10, "FIXED_32K"), AM3_PRCM_HWMOD_PER("timer2", 0x80, "FIXED_24MHZ"), AM3_PRCM_HWMOD_PER("timer3", 0x84, "FIXED_24MHZ"), AM3_PRCM_HWMOD_PER("timer4", 0x88, "FIXED_24MHZ"), @@ -169,9 +169,9 @@ static struct ti_prcm_clk am3_prcm_clks[ AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"), AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"), - AM3_PRCM_HWMOD_PER("mmc0", 0x3c, "MMC_CLK"), - AM3_PRCM_HWMOD_PER("mmc1", 0xf4, "MMC_CLK"), - AM3_PRCM_HWMOD_PER("mmc2", 0xf8, "MMC_CLK"), + AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"), + AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"), + AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"), AM3_PRCM_HWMOD_PER("tpcc", 0xbc, "PERIPH_CLK"), AM3_PRCM_HWMOD_PER("tptc0", 0x24, "PERIPH_CLK"),
CVS commit: src/sys/arch/arm/ti
Module Name:src Committed By: jmcneill Date: Wed Nov 27 23:02:54 UTC 2019 Modified Files: src/sys/arch/arm/ti: am3_prcm.c Log Message: Fix mmc and timer indexes. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jmcneill Date: Tue Nov 26 10:33:19 UTC 2019 Modified Files: src/sys/dev/pci: if_mcx.c Log Message: Fix IFF_ALLMULTI handling. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_mcx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_mcx.c diff -u src/sys/dev/pci/if_mcx.c:1.6 src/sys/dev/pci/if_mcx.c:1.7 --- src/sys/dev/pci/if_mcx.c:1.6 Mon Nov 18 04:40:05 2019 +++ src/sys/dev/pci/if_mcx.c Tue Nov 26 10:33:19 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */ +/* $NetBSD: if_mcx.c,v 1.7 2019/11/26 10:33:19 jmcneill Exp $ */ /* $OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */ /* @@ -6205,8 +6205,11 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd, { struct mcx_softc *sc = (struct mcx_softc *)ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; + struct ethercom *ec = >sc_ec; uint8_t addrhi[ETHER_ADDR_LEN], addrlo[ETHER_ADDR_LEN]; - int s, i, error = 0; + struct ether_multi *enm; + struct ether_multistep step; + int s, i, flags, error = 0; s = splnet(); switch (cmd) { @@ -6214,8 +6217,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd, case SIOCADDMULTI: if (ether_addmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) { error = ether_multiaddr(>ifr_addr, addrlo, addrhi); - if (error != 0) + if (error != 0) { +splx(s); return (error); + } for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) { if (sc->sc_mcast_flows[i][0] == 0) { @@ -6238,7 +6243,7 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd, error = ENETRESET; } -if (sc->sc_ec.ec_multicnt > 0) { +if (memcmp(addrlo, addrhi, ETHER_ADDR_LEN)) { SET(ifp->if_flags, IFF_ALLMULTI); error = ENETRESET; } @@ -6249,8 +6254,10 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd, case SIOCDELMULTI: if (ether_delmulti(ifreq_getaddr(cmd, ifr), >sc_ec) == ENETRESET) { error = ether_multiaddr(>ifr_addr, addrlo, addrhi); - if (error != 0) + if (error != 0) { +splx(s); return (error); + } for (i = 0; i < MCX_NUM_MCAST_FLOWS; i++) { if (memcmp(sc->sc_mcast_flows[i], addrlo, @@ -6269,10 +6276,23 @@ mcx_ioctl(struct ifnet *ifp, u_long cmd, sc->sc_extra_mcast--; if (ISSET(ifp->if_flags, IFF_ALLMULTI) && - (sc->sc_extra_mcast == 0) && - (sc->sc_ec.ec_multicnt == 0)) { -CLR(ifp->if_flags, IFF_ALLMULTI); -error = ENETRESET; + sc->sc_extra_mcast == 0) { +flags = 0; +ETHER_LOCK(ec); +ETHER_FIRST_MULTI(step, ec, enm); +while (enm != NULL) { + if (memcmp(enm->enm_addrlo, + enm->enm_addrhi, ETHER_ADDR_LEN)) { + SET(flags, IFF_ALLMULTI); + break; + } + ETHER_NEXT_MULTI(step, enm); +} +ETHER_UNLOCK(ec); +if (!ISSET(flags, IFF_ALLMULTI)) { + CLR(ifp->if_flags, IFF_ALLMULTI); + error = ENETRESET; +} } } break;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jmcneill Date: Tue Nov 26 10:33:19 UTC 2019 Modified Files: src/sys/dev/pci: if_mcx.c Log Message: Fix IFF_ALLMULTI handling. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_mcx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 12:21:14 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reclaim bootloader FB memory for CMA pool. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_drm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_drm.c diff -u src/sys/arch/arm/sunxi/sunxi_drm.c:1.8 src/sys/arch/arm/sunxi/sunxi_drm.c:1.9 --- src/sys/arch/arm/sunxi/sunxi_drm.c:1.8 Tue Nov 5 23:31:23 2019 +++ src/sys/arch/arm/sunxi/sunxi_drm.c Sun Nov 24 12:21:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $ */ +/* $NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.8 2019/11/05 23:31:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.9 2019/11/24 12:21:14 jmcneill Exp $"); #include #include @@ -296,6 +296,27 @@ static struct drm_mode_config_funcs sunx }; static int +sunxi_drm_simplefb_lookup(bus_addr_t *paddr, bus_size_t *psize) +{ + static const char * compat[] = { "simple-framebuffer", NULL }; + int chosen, child; + + chosen = OF_finddevice("/chosen"); + if (chosen == -1) + return ENOENT; + + for (child = OF_child(chosen); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) + continue; + if (!of_match_compatible(child, compat)) + continue; + return fdtbus_get_reg(child, 0, paddr, psize); + } + + return ENOENT; +} + +static int sunxi_drm_fb_probe(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes) { struct sunxi_drm_softc * const sc = sunxi_drm_private(helper->dev); @@ -303,6 +324,8 @@ sunxi_drm_fb_probe(struct drm_fb_helper struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb); struct drm_framebuffer *fb = helper->fb; struct sunxi_drmfb_attach_args sfa; + bus_addr_t sfb_addr; + bus_size_t sfb_size; size_t cma_size; int error; @@ -312,14 +335,31 @@ sunxi_drm_fb_probe(struct drm_fb_helper const size_t size = roundup(height * pitch, PAGE_SIZE); - /* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */ - cma_size = size; - cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4); + if (sunxi_drm_simplefb_lookup(_addr, _size) != 0) + sfb_size = 0; + + /* Reserve enough memory for a 4K plane, rounded to 1MB */ + cma_size = (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4); + if (sfb_size == 0) { + /* Add memory for FB console if we cannot reclaim bootloader memory */ + cma_size += size; + } cma_size = roundup(cma_size, 1024 * 1024); sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size); - if (sc->sc_ddev->cma_pool != NULL) - aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n", - (u_int)(cma_size / (1024 * 1024))); + if (sc->sc_ddev->cma_pool != NULL) { + if (sfb_size != 0) { + error = vmem_add(sc->sc_ddev->cma_pool, sfb_addr, + sfb_size, VM_SLEEP); + if (error != 0) +sfb_size = 0; + } + aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA", + (u_int)((cma_size + sfb_size) / (1024 * 1024))); + if (sfb_size != 0) + aprint_normal(" (%u MB reclaimed from bootloader)", + (u_int)(sfb_size / (1024 * 1024))); + aprint_normal("\n"); + } sfb->obj = drm_gem_cma_create(ddev, size); if (sfb->obj == NULL) {
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 12:21:14 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_drm.c Log Message: Reclaim bootloader FB memory for CMA pool. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_drm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 10:27:37 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c sunxi_platform.c Log Message: Try to avoid changing hardware settings when the "nomodeset" kernel arg is present. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/sunxi/sunxi_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 24 10:27:37 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_dwhdmi.c sunxi_platform.c Log Message: Try to avoid changing hardware settings when the "nomodeset" kernel arg is present. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/sunxi/sunxi_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.20 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 Sat Nov 23 22:46:53 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.20 2019/11/24 10:27:37 jmcneill Exp $"); #include #include @@ -601,6 +601,8 @@ sun50i_a64_ccu_attach(device_t parent, d { struct sunxi_ccu_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + prop_dictionary_t prop = device_properties(self); + bool nomodeset; sc->sc_dev = self; sc->sc_phandle = faa->faa_phandle; @@ -618,19 +620,23 @@ sun50i_a64_ccu_attach(device_t parent, d aprint_naive("\n"); aprint_normal(": A64 CCU\n"); - /* Set DE parent to PLL_DE */ - clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base); - clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000); - - /* Set video PLLs to 297 MHz */ - clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); - clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); - - /* Set TCON1 parent to PLL_VIDEO1(1X) */ - clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); - - /* Set HDMI parent to PLL_VIDEO1(1X) */ - clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); + nomodeset = false; + prop_dictionary_get_bool(prop, "nomodeset", ); + if (!nomodeset) { + /* Set DE parent to PLL_DE */ + clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base); + clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000); + + /* Set video PLLs to 297 MHz */ + clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); + clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + + /* Set TCON1 parent to PLL_VIDEO1(1X) */ + clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); + + /* Set HDMI parent to PLL_VIDEO1(1X) */ + clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); + } sunxi_ccu_print(sc); } Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 Sat Nov 23 18:55:08 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.8 2019/11/24 10:27:37 jmcneill Exp $"); #include #include @@ -228,12 +228,20 @@ sunxi_dwhdmi_attach(device_t parent, dev { struct sunxi_dwhdmi_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + prop_dictionary_t prop = device_properties(self); const int phandle = faa->faa_phandle; struct clk *clk_iahb, *clk_isfr, *clk_tmds; struct fdtbus_reset *rst; + bool is_disabled; bus_addr_t addr; bus_size_t size; + if (prop_dictionary_get_bool(prop, "disabled", _disabled) && is_disabled) { + aprint_naive("\n"); + aprint_normal(": HDMI TX (disabled)\n"); + return; + } + if (fdtbus_get_reg(phandle, 0, , ) != 0) { aprint_error(": couldn't get registers\n"); return; Index: src/sys/arch/arm/sunxi/sunxi_platform.c diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.37 src/sys/arch/arm/sunxi/sunxi_platform.c:1.38 --- src/sys/arch/arm/sunxi/sunxi_platform.c:1.37 Mon Jun 17 05:27:01 2019 +++ src/sys/arch/arm/sunxi/sunxi_platform.c Sun Nov 24 10:27:37 2019 @@ -1,4 +1,4 @@ -/*
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sun Nov 24 02:06:16 UTC 2019 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pinebook.dts Log Message: Enable HDMI and HDMI audio To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sun Nov 24 02:06:16 UTC 2019 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pinebook.dts Log Message: Enable HDMI and HDMI audio To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/dts/sun50i-a64-pinebook.dts diff -u src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.16 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.17 --- src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.16 Thu Jun 6 23:19:45 2019 +++ src/sys/arch/arm/dts/sun50i-a64-pinebook.dts Sun Nov 24 02:06:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64-pinebook.dts,v 1.16 2019/06/06 23:19:45 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64-pinebook.dts,v 1.17 2019/11/24 02:06:16 jmcneill Exp $ */ /*- * Copyright (c) 2017-2019 Jared McNeill @@ -54,6 +54,17 @@ sound_spdif { status = "disabled"; }; + + hdmi-connector { + compatible = "hdmi-connector"; + type = "c"; + + port { + hdmi_con_in: endpoint { +remote-endpoint = <_out_con>; + }; + }; + }; }; { @@ -151,3 +162,28 @@ }; }; }; + +_dldo1 { + regulator-min-microvolt = <330>; + regulator-max-microvolt = <330>; + regulator-name = "vcc-hdmi"; +}; + + { + hvcc-supply = <_dldo1>; + status = "okay"; +}; + +_out { + hdmi_out_con: endpoint { + remote-endpoint = <_con_in>; + }; +}; + + { + status = "okay"; +}; + +_hdmi { + status = "okay"; +};
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 23:47:57 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume the cursor pitch is the same as the primary fb To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_mixer.c diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.10 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 Sat Nov 23 21:40:57 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 23:47:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.10 2019/11/23 23:47:57 jmcneill Exp $"); #include #include @@ -373,7 +373,7 @@ sunxi_mixer_cursor_set(struct drm_crtc * /* Set UI overlay offset */ OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset); /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]); + OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 23:47:57 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume the cursor pitch is the same as the primary fb To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 22:46:53 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set video PLLs to 297MHz To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 22:46:53 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set video PLLs to 297MHz To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.19 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 Sat Nov 23 18:57:36 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 22:46:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.19 2019/11/23 22:46:53 jmcneill Exp $"); #include #include @@ -622,9 +622,15 @@ sun50i_a64_ccu_attach(device_t parent, d clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base); clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000); + /* Set video PLLs to 297 MHz */ + clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO0].base, 29700); + clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + /* Set TCON1 parent to PLL_VIDEO1(1X) */ clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); - clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + + /* Set HDMI parent to PLL_VIDEO1(1X) */ + clk_set_parent(>sc_clks[A64_CLK_HDMI].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); sunxi_ccu_print(sc); }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:40:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Support non-zero fb start pixels. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_mixer.c diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.9 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 Sat Nov 23 20:24:12 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 21:40:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.9 2019/11/23 21:40:57 jmcneill Exp $"); #include #include @@ -252,6 +252,9 @@ sunxi_mixer_mode_do_set_base(struct drm_ uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr; + paddr += y * sfb->base.pitches[0]; + paddr += x * drm_format_plane_cpp(sfb->base.pixel_format, 0); + uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0; uint32_t laddr = paddr & 0x; @@ -461,7 +464,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr const uint32_t size = ((adjusted_mode->vdisplay - 1) << 16) | (adjusted_mode->hdisplay - 1); - const uint32_t offset = (y << 16) | x; /* Set global size */ GLB_WRITE(sc, GLB_SIZE, size); @@ -474,7 +476,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr /* Set blender 0 input size */ BLD_WRITE(sc, BLD_CH_ISIZE(0), size); /* Set blender 0 offset */ - BLD_WRITE(sc, BLD_CH_OFFSET(0), offset); + BLD_WRITE(sc, BLD_CH_OFFSET(0), 0); /* Route channel 1 to pipe 0 */ val = BLD_READ(sc, BLD_CH_RTCTL); val &= ~BLD_CH_RTCTL_P0; @@ -493,7 +495,7 @@ sunxi_mixer_mode_set(struct drm_crtc *cr /* Set UI overlay layer size */ OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size); /* Set UI overlay offset */ - OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset); + OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), 0); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:40:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Support non-zero fb start pixels. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:30:41 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by jak. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 Sat Nov 23 18:52:09 2019 +++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Sat Nov 23 21:30:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.6 2019/11/23 21:30:41 jmcneill Exp $"); #include #include @@ -137,6 +137,7 @@ sunxi_ccu_fractional_set_rate(struct sun for (i = 0; i < __arraycount(fractional->frac); i++) { if (fractional->frac[i] == new_rate) { + val &= ~fractional->prediv; val &= ~fractional->div_en; val &= ~fractional->frac_sel; val |= __SHIFTIN(i, fractional->frac_sel);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 21:30:41 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Set pre-divider M to 0 in fractional mode, as noted in user manual. Spotted by jak. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:28:04 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_lcdc.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_lcdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_lcdc.c diff -u src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6 src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_lcdc.c:1.6 Sat Jul 6 00:23:38 2019 +++ src/sys/arch/arm/sunxi/sunxi_lcdc.c Sat Nov 23 20:28:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $ */ +/* $NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.6 2019/07/06 00:23:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c,v 1.7 2019/11/23 20:28:04 jmcneill Exp $"); #include #include @@ -81,7 +81,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_lcdc.c #define TCON1_CTL_REG 0x090 #define TCON1_CTL_TCON1_EN __BIT(31) #define TCON1_CTL_START_DELAY __BITS(8,4) -#define TCON1_CTL_TCON1_SRC_SEL __BIT(1) +#define TCON1_CTL_TCON1_SRC_SEL __BITS(1,0) #define TCON1_BASIC0_REG 0x094 #define TCON1_BASIC1_REG 0x098 #define TCON1_BASIC2_REG 0x09c @@ -185,6 +185,7 @@ sunxi_lcdc_tcon0_prepare(struct drm_enco val = TCON_READ(sc, TCON_GCTL_REG); val |= TCON_GCTL_TCON_EN; + val &= ~TCON_GCTL_IO_MAP_SEL; TCON_WRITE(sc, TCON_GCTL_REG, val); TCON_WRITE(sc, TCON0_IO_TRI_REG, 0); @@ -215,20 +216,20 @@ sunxi_lcdc_tcon0_commit(struct drm_encod int error; const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0; - const u_int hspw = mode->hsync_end - mode->hsync_start; - const u_int hbp = mode->htotal - mode->hsync_start; - const u_int vspw = mode->vsync_end - mode->vsync_start; - const u_int vbp = mode->vtotal - mode->vsync_start; - const u_int vblank_len = (mode->vtotal - mode->vdisplay) >> interlace_p; + const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start; + const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start; + const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start; + const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start; + const u_int vblank_len = (mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p; const u_int start_delay = uimin(vblank_len, 30); val = TCON0_CTL_TCON0_EN | __SHIFTIN(start_delay, TCON0_CTL_START_DELAY); TCON_WRITE(sc, TCON0_CTL_REG, val); - TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->htotal - 1) << 16) | (hbp - 1)); - TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->vtotal * 2) << 16) | (vbp - 1)); + TCON_WRITE(sc, TCON0_BASIC0_REG, ((mode->crtc_hdisplay - 1) << 16) | (mode->crtc_vdisplay - 1)); + TCON_WRITE(sc, TCON0_BASIC1_REG, ((mode->crtc_htotal - 1) << 16) | (hbp - 1)); + TCON_WRITE(sc, TCON0_BASIC2_REG, ((mode->crtc_vtotal * 2) << 16) | (vbp - 1)); TCON_WRITE(sc, TCON0_BASIC3_REG, ((hspw - 1) << 16) | (vspw - 1)); val = TCON_READ(sc, TCON0_IO_POL_REG); @@ -268,24 +269,22 @@ sunxi_lcdc_tcon1_commit(struct drm_encod int error; const u_int interlace_p = (mode->flags & DRM_MODE_FLAG_INTERLACE) != 0; - const u_int hspw = mode->hsync_end - mode->hsync_start; - const u_int hbp = mode->htotal - mode->hsync_start; - const u_int vspw = mode->vsync_end - mode->vsync_start; - const u_int vbp = mode->vtotal - mode->vsync_start; - const u_int vblank_len = - ((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2; - const u_int start_delay = - vblank_len >= 32 ? 30 : vblank_len - 2; + const u_int hspw = mode->crtc_hsync_end - mode->crtc_hsync_start; + const u_int hbp = mode->crtc_htotal - mode->crtc_hsync_start; + const u_int vspw = mode->crtc_vsync_end - mode->crtc_vsync_start; + const u_int vbp = mode->crtc_vtotal - mode->crtc_vsync_start; + const u_int vblank_len = ((mode->crtc_vtotal - mode->crtc_vdisplay) >> interlace_p) - 2; + const u_int start_delay = uimin(vblank_len, 30); val = TCON1_CTL_TCON1_EN | __SHIFTIN(start_delay, TCON1_CTL_START_DELAY); TCON_WRITE(sc, TCON1_CTL_REG, val); - TCON_WRITE(sc, TCON1_BASIC0_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC1_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC2_REG, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); - TCON_WRITE(sc, TCON1_BASIC3
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:27:39 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/dw_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:28:04 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_lcdc.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_lcdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:27:39 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c Log Message: Use actual hw mode, not proposed mode. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/dw_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dw_hdmi.c diff -u src/sys/dev/ic/dw_hdmi.c:1.5 src/sys/dev/ic/dw_hdmi.c:1.6 --- src/sys/dev/ic/dw_hdmi.c:1.5 Sat Nov 23 12:28:44 2019 +++ src/sys/dev/ic/dw_hdmi.c Sat Nov 23 20:27:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_hdmi.c,v 1.5 2019/11/23 12:28:44 jmcneill Exp $ */ +/* $NetBSD: dw_hdmi.c,v 1.6 2019/11/23 20:27:39 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.5 2019/11/23 12:28:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.6 2019/11/23 20:27:39 jmcneill Exp $"); #include #include @@ -429,14 +429,14 @@ dwhdmi_fc_init(struct dwhdmi_softc *sc, uint8_t val; const uint8_t vic = drm_match_cea_mode(mode); - const uint16_t inhactiv = mode->hdisplay; - const uint16_t inhblank = mode->htotal - mode->hdisplay; - const uint16_t invactiv = mode->vdisplay; - const uint8_t invblank = mode->vtotal - mode->vdisplay; - const uint16_t hsyncindelay = mode->hsync_start - mode->hdisplay; - const uint16_t hsyncinwidth = mode->hsync_end - mode->hsync_start; - const uint8_t vsyncindelay = mode->vsync_start - mode->vdisplay; - const uint8_t vsyncinwidth = mode->vsync_end - mode->vsync_start; + const uint16_t inhactiv = mode->crtc_hdisplay; + const uint16_t inhblank = mode->crtc_htotal - mode->crtc_hdisplay; + const uint16_t invactiv = mode->crtc_vdisplay; + const uint8_t invblank = mode->crtc_vtotal - mode->crtc_vdisplay; + const uint16_t hsyncindelay = mode->crtc_hsync_start - mode->crtc_hdisplay; + const uint16_t hsyncinwidth = mode->crtc_hsync_end - mode->crtc_hsync_start; + const uint8_t vsyncindelay = mode->crtc_vsync_start - mode->crtc_vdisplay; + const uint8_t vsyncinwidth = mode->crtc_vsync_end - mode->crtc_vsync_start; /* Input video configuration for frame composer */ val = HDMI_FC_INVIDCONF_DE_IN_POLARITY;
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:24:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume that an fb's pitch is width * 4 bytes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 20:24:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_mixer.c Log Message: Do not assume that an fb's pitch is width * 4 bytes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_mixer.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_mixer.c diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7 Sat Feb 16 16:20:50 2019 +++ src/sys/arch/arm/sunxi/sunxi_mixer.c Sat Nov 23 20:24:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $ */ +/* $NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.8 2019/11/23 20:24:12 jmcneill Exp $"); #include #include @@ -255,6 +255,9 @@ sunxi_mixer_mode_do_set_base(struct drm_ uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0; uint32_t laddr = paddr & 0x; + /* Set UI overlay line size */ + OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), sfb->base.pitches[0]); + /* Framebuffer start address */ val = OVL_UI_READ(sc, 0, OVL_UI_TOP_HADD); val &= ~OVL_UI_TOP_HADD_LAYER0; @@ -367,7 +370,7 @@ sunxi_mixer_cursor_set(struct drm_crtc * /* Set UI overlay offset */ OVL_UI_WRITE(sc, 1, OVL_UI_COOR(0), offset); /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), width * 4); + OVL_UI_WRITE(sc, 1, OVL_UI_PITCH(0), crtc->primary->fb->pitches[0]); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 1, OVL_UI_SIZE, crtc_size); @@ -491,8 +494,6 @@ sunxi_mixer_mode_set(struct drm_crtc *cr OVL_UI_WRITE(sc, 0, OVL_UI_MBSIZE(0), size); /* Set UI overlay offset */ OVL_UI_WRITE(sc, 0, OVL_UI_COOR(0), offset); - /* Set UI overlay line size */ - OVL_UI_WRITE(sc, 0, OVL_UI_PITCH(0), adjusted_mode->hdisplay * 4); /* Set UI overlay window size */ OVL_UI_WRITE(sc, 0, OVL_UI_SIZE, size);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:57:36 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set TCON1 parent to PLL_VIDEO1(1X) To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.18 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 Sat Nov 23 12:29:20 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 18:57:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.18 2019/11/23 18:57:36 jmcneill Exp $"); #include #include @@ -622,5 +622,9 @@ sun50i_a64_ccu_attach(device_t parent, d clk_set_parent(>sc_clks[A64_CLK_DE].base, >sc_clks[A64_CLK_PLL_DE].base); clk_set_rate(>sc_clks[A64_CLK_PLL_DE].base, 42000); + /* Set TCON1 parent to PLL_VIDEO1(1X) */ + clk_set_parent(>sc_clks[A64_CLK_TCON1].base, >sc_clks[A64_CLK_PLL_VIDEO1].base); + clk_set_rate(>sc_clks[A64_CLK_PLL_VIDEO1].base, 29700); + sunxi_ccu_print(sc); }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:57:36 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Set TCON1 parent to PLL_VIDEO1(1X) To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:55:08 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Set pixel clock on mode set To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 Sat Nov 23 12:30:45 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sat Nov 23 18:55:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.7 2019/11/23 18:55:08 jmcneill Exp $"); #include #include @@ -62,6 +62,7 @@ struct sunxi_dwhdmi_softc { int sc_phandle; struct fdtbus_phy *sc_phy; struct fdtbus_regulator *sc_regulator; + struct clk *sc_clk; struct fdt_device_ports sc_ports; struct drm_display_mode sc_curmode; @@ -186,6 +187,15 @@ sunxi_dwhdmi_mode_set(struct dwhdmi_soft struct drm_display_mode *adjusted_mode) { struct sunxi_dwhdmi_softc * const sc = to_sunxi_dwhdmi_softc(dsc); + int error; + + if (sc->sc_clk != NULL) { + error = clk_set_rate(sc->sc_clk, adjusted_mode->clock * 1000); + if (error != 0) + device_printf(sc->sc_base.sc_dev, + "couldn't set pixel clock to %u Hz: %d\n", + adjusted_mode->clock * 1000, error); + } sc->sc_curmode = *adjusted_mode; } @@ -229,12 +239,6 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } - rst = fdtbus_reset_get(phandle, "ctrl"); - if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { - aprint_error(": couldn't de-assert reset\n"); - return; - } - clk_iahb = fdtbus_clock_get(phandle, "iahb"); if (clk_iahb == NULL || clk_enable(clk_iahb) != 0) { aprint_error(": couldn't enable iahb clock\n"); @@ -267,6 +271,7 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_base.sc_scl_hcnt = 0xd8; sc->sc_base.sc_scl_lcnt = 0xfe; sc->sc_phandle = faa->faa_phandle; + sc->sc_clk = clk_tmds; aprint_naive("\n"); aprint_normal(": HDMI TX\n"); @@ -281,6 +286,12 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } + rst = fdtbus_reset_get(phandle, "ctrl"); + if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { + aprint_error_dev(self, "couldn't de-assert reset\n"); + return; + } + sunxi_hdmiphy_init(sc->sc_phy); if (dwhdmi_attach(>sc_base) != 0) {
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:55:08 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Set pixel clock on mode set To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:54:26 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_hdmiphy.c Log Message: Need to initialize the PHY before HPD sense and DDC will work To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_hdmiphy.c diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.4 --- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 Sat Nov 23 12:30:45 2019 +++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Sat Nov 23 18:54:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */ +/* $NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.4 2019/11/23 18:54:26 jmcneill Exp $"); #include #include @@ -128,6 +128,7 @@ struct sunxi_hdmiphy_softc { const struct sunxi_hdmiphy_data *sc_data; + struct fdtbus_reset *sc_rst; struct clk *sc_clk_bus; struct clk *sc_clk_mod; struct clk *sc_clk_pll0; @@ -173,14 +174,6 @@ sunxi_hdmiphy_release(device_t dev, void static int sunxi_hdmiphy_enable(device_t dev, void *priv, bool enable) { - struct sunxi_hdmiphy_softc * const sc = priv; - - if (enable) { - sc->sc_data->init(sc); - } else { - sc->sc_data->config(sc, 0); - } - return 0; } @@ -421,11 +414,10 @@ sunxi_hdmiphy_attach(device_t parent, de } rst = fdtbus_reset_get(phandle, "phy"); - if (rst == NULL || fdtbus_reset_deassert(rst) != 0) { - aprint_error(": couldn't de-assert reset\n"); + if (rst == NULL) { + aprint_error(": couldn't get reset\n"); return; } - clk_bus = fdtbus_clock_get(phandle, "bus"); clk_mod = fdtbus_clock_get(phandle, "mod"); clk_pll0 = fdtbus_clock_get(phandle, "pll-0"); @@ -441,6 +433,7 @@ sunxi_hdmiphy_attach(device_t parent, de aprint_error(": couldn't map registers\n"); return; } + sc->sc_rst = rst; sc->sc_clk_bus = clk_bus; sc->sc_clk_mod = clk_mod; sc->sc_clk_pll0 = clk_pll0; @@ -461,6 +454,10 @@ sunxi_hdmiphy_init(struct fdtbus_phy *ph clk_enable(sc->sc_clk_mod); clk_enable(sc->sc_clk_pll0); + fdtbus_reset_deassert(sc->sc_rst); + + sc->sc_data->init(sc); + PHY_WRITE(sc, READ_EN, READ_EN_MAGIC); PHY_WRITE(sc, UNSCRAMBLE, UNSCRAMBLE_MAGIC);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:54:26 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_hdmiphy.c Log Message: Need to initialize the PHY before HPD sense and DDC will work To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:53:05 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Use fdtbus_get_reg to read "reg" property To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:53:05 UTC 2019 Modified Files: src/sys/dev/fdt: fdt_port.c Log Message: Use fdtbus_get_reg to read "reg" property To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/fdt_port.c diff -u src/sys/dev/fdt/fdt_port.c:1.2 src/sys/dev/fdt/fdt_port.c:1.3 --- src/sys/dev/fdt/fdt_port.c:1.2 Wed Jan 30 01:24:00 2019 +++ src/sys/dev/fdt/fdt_port.c Sat Nov 23 18:53:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_port.c,v 1.2 2019/01/30 01:24:00 jmcneill Exp $ */ +/* $NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.2 2019/01/30 01:24:00 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.3 2019/11/23 18:53:05 jmcneill Exp $"); #include #include @@ -296,7 +296,7 @@ again: } if (strcmp(buf, "port") != 0) continue; - if (fdtbus_get_reg64(child, 0, , NULL) != 0) { + if (fdtbus_get_reg(child, 0, , NULL) != 0) { if (ports->dp_nports > 1) aprint_error_dev(self, "%s: missing reg property",
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:52:09 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.5 --- src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c:1.4 Wed Jan 30 01:24:00 2019 +++ src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Sat Nov 23 18:52:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $ */ +/* $NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.4 2019/01/30 01:24:00 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fractional.c,v 1.5 2019/11/23 18:52:09 jmcneill Exp $"); #include #include @@ -140,6 +140,8 @@ sunxi_ccu_fractional_set_rate(struct sun val &= ~fractional->div_en; val &= ~fractional->frac_sel; val |= __SHIFTIN(i, fractional->frac_sel); + if (fractional->flags & SUNXI_CCU_FRACTIONAL_SET_ENABLE) +val |= fractional->enable; CCU_WRITE(sc, fractional->reg, val); return 0; }
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 18:52:09 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_ccu_fractional.c Log Message: Honour SUNXI_CCU_FRACTIONAL_SET_ENABLE in fractional mode To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:30:45 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h Log Message: HDMI PHY and TX share the same clocks. Do not enable clocks until both reset resources have been deasserted. Explicitly set DDC clock dividers. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 Fri Nov 22 19:48:58 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sat Nov 23 12:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.6 2019/11/23 12:30:45 jmcneill Exp $"); #include #include @@ -101,13 +101,6 @@ sunxi_dwhdmi_ep_activate(device_t dev, s if (encoder == NULL) return EINVAL; - sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy"); - if (sc->sc_phy == NULL) { - device_printf(dev, "couldn't find hdmi-phy\n"); - return ENXIO; - } - - sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply"); if (sc->sc_regulator != NULL) { error = fdtbus_regulator_enable(sc->sc_regulator); if (error != 0) { @@ -271,11 +264,25 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_base.sc_enable = sunxi_dwhdmi_enable; sc->sc_base.sc_disable = sunxi_dwhdmi_disable; sc->sc_base.sc_mode_set = sunxi_dwhdmi_mode_set; + sc->sc_base.sc_scl_hcnt = 0xd8; + sc->sc_base.sc_scl_lcnt = 0xfe; sc->sc_phandle = faa->faa_phandle; aprint_naive("\n"); aprint_normal(": HDMI TX\n"); + sc->sc_regulator = fdtbus_regulator_acquire(sc->sc_phandle, "hvcc-supply"); + + sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "hdmi-phy"); + if (sc->sc_phy == NULL) + sc->sc_phy = fdtbus_phy_get(sc->sc_phandle, "phy"); + if (sc->sc_phy == NULL) { + device_printf(self, "couldn't find PHY\n"); + return; + } + + sunxi_hdmiphy_init(sc->sc_phy); + if (dwhdmi_attach(>sc_base) != 0) { aprint_error_dev(self, "failed to attach driver\n"); return; Index: src/sys/arch/arm/sunxi/sunxi_hdmiphy.c diff -u src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.3 --- src/sys/arch/arm/sunxi/sunxi_hdmiphy.c:1.2 Thu Jan 31 01:49:28 2019 +++ src/sys/arch/arm/sunxi/sunxi_hdmiphy.c Sat Nov 23 12:30:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $ */ +/* $NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.2 2019/01/31 01:49:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_hdmiphy.c,v 1.3 2019/11/23 12:30:45 jmcneill Exp $"); #include #include @@ -128,6 +128,8 @@ struct sunxi_hdmiphy_softc { const struct sunxi_hdmiphy_data *sc_data; + struct clk *sc_clk_bus; + struct clk *sc_clk_mod; struct clk *sc_clk_pll0; u_int sc_rcalib; @@ -425,20 +427,10 @@ sunxi_hdmiphy_attach(device_t parent, de } clk_bus = fdtbus_clock_get(phandle, "bus"); - if (clk_bus == NULL || clk_enable(clk_bus) != 0) { - aprint_error(": couldn't enable bus clock\n"); - return; - } - clk_mod = fdtbus_clock_get(phandle, "mod"); - if (clk_mod == NULL || clk_enable(clk_mod) != 0) { - aprint_error(": couldn't enable mod clock\n"); - return; - } - clk_pll0 = fdtbus_clock_get(phandle, "pll-0"); - if (clk_pll0 == NULL || clk_enable(clk_pll0) != 0) { - aprint_error(": couldn't enable pll-0 clock\n"); + if (clk_bus == NULL || clk_mod == NULL || clk_pll0 == NULL) { + aprint_error(": couldn't get clocks\n"); return; } @@ -449,12 +441,25 @@ sunxi_hdmiphy_attach(device_t parent, de aprint_error(": couldn't map registers\n"); return; } + sc->sc_clk_bus = clk_bus; + sc->sc_clk_mod = clk_mod; sc->sc_clk_pll0 = clk_pll0; aprint_naive("\n"); aprint_normal(": HDMI PHY\n"); fdtbus_register_phy_controller(self, phandle, _hdmiphy_funcs); +} + +void +sunxi_hdmiphy_init(stru
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:30:45 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_hdmiphy.c sunxi_hdmiphy.h Log Message: HDMI PHY and TX share the same clocks. Do not enable clocks until both reset resources have been deasserted. Explicitly set DDC clock dividers. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_hdmiphy.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_hdmiphy.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:29:20 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add TCON0 clock To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:29:20 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add TCON0 clock To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.17 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 Fri Nov 22 19:46:38 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sat Nov 23 12:29:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.17 2019/11/23 12:29:20 jmcneill Exp $"); #include #include @@ -69,6 +69,7 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define DRAM_CFG_REG 0x0f4 #define MBUS_RST_REG 0x0fc #define DE_CLK_REG 0x104 +#define TCON0_CLK_REG 0x118 #define TCON1_CLK_REG 0x11c #define AC_DIG_CLK_REG 0x140 #define HDMI_CLK_REG 0x150 @@ -161,6 +162,7 @@ static const char *de_parents[] = { "pll static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL }; +static const char *tcon0_parents[] = { "pll_mipi", NULL, "pll_video0_2x", NULL }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -459,6 +461,13 @@ static struct sunxi_ccu_clk sun50i_a64_c __BIT(31), /* enable */ SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), + SUNXI_CCU_DIV_GATE(A64_CLK_TCON0, "tcon0", tcon0_parents, + TCON0_CLK_REG, /* reg */ + 0, /* div */ + __BITS(26,24), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */ __BITS(3,0), /* div */
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 23 12:28:44 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c dw_hdmi.h Log Message: Allow bus glue to setup DDC clocks To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:48:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Enable TMDS clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.5 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 Sun Nov 17 17:33:34 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Fri Nov 22 19:48:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.5 2019/11/22 19:48:58 jmcneill Exp $"); #include #include @@ -226,7 +226,7 @@ sunxi_dwhdmi_attach(device_t parent, dev struct sunxi_dwhdmi_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - struct clk *clk_iahb, *clk_isfr; + struct clk *clk_iahb, *clk_isfr, *clk_tmds; struct fdtbus_reset *rst; bus_addr_t addr; bus_size_t size; @@ -254,6 +254,12 @@ sunxi_dwhdmi_attach(device_t parent, dev return; } + clk_tmds = fdtbus_clock_get(phandle, "tmds"); + if (clk_tmds == NULL || clk_enable(clk_tmds) != 0) { + aprint_error(": couldn't enable tmds clock\n"); + return; + } + sc->sc_base.sc_dev = self; sc->sc_base.sc_reg_width = 1; sc->sc_base.sc_bst = faa->faa_bst;
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:48:58 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c Log Message: Enable TMDS clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Fri Nov 22 19:46:38 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Fix CLK_BUS_HDMI bit To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.16 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 Sun Nov 17 19:51:12 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Fri Nov 22 19:46:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.16 2019/11/22 19:46:38 jmcneill Exp $"); #include #include @@ -521,7 +521,7 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_GATE(A64_CLK_BUS_CSI, "bus-csi", "ahb1", BUS_CLK_GATING_REG1, 8), SUNXI_CCU_GATE(A64_CLK_BUS_HDMI, "bus-hdmi", "ahb1", - BUS_CLK_GATING_REG1, 10), + BUS_CLK_GATING_REG1, 11), SUNXI_CCU_GATE(A64_CLK_BUS_DE, "bus-de", "ahb1", BUS_CLK_GATING_REG1, 12), SUNXI_CCU_GATE(A64_CLK_BUS_GPU, "bus-gpu", "ahb1",
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:35 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add sun6ispi To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:35 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add sun6ispi To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.114 src/sys/arch/evbarm/conf/GENERIC64:1.115 --- src/sys/arch/evbarm/conf/GENERIC64:1.114 Sun Nov 17 19:30:59 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Sun Nov 17 19:51:35 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.114 2019/11/17 19:30:59 jmcneill Exp $ +# $NetBSD: GENERIC64,v 1.115 2019/11/17 19:51:35 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -407,6 +407,7 @@ ld* at nvme? nsid ? # SPI controllers bcmspi* at fdt? # Broadcom BCM283x SPI rkspi* at fdt? # Rockchip SPI +sun6ispi* at fdt? # Allwinner SPI spi* at spibus? m25p* at spi? spiflash* at spiflashbus?
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add SPI clocks To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.15 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 Sun Nov 17 17:33:17 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 17 19:51:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.15 2019/11/17 19:51:12 jmcneill Exp $"); #include #include @@ -60,6 +60,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define SDMMC0_CLK_REG 0x088 #define SDMMC1_CLK_REG 0x08c #define SDMMC2_CLK_REG 0x090 +#define SPI0_CLK_REG 0x0a0 +#define SPI1_CLK_REG 0x0a4 #define I2SPCM0_CLK_REG 0x0b0 #define I2SPCM1_CLK_REG 0x0b4 #define I2SPCM2_CLK_REG 0x0b8 @@ -158,6 +160,7 @@ static const char *ths_parents[] = { "ho static const char *de_parents[] = { "pll_periph0_2x", "pll_de" }; static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; +static const char *spi_parents[] = { "hosc", "pll_periph0", "pll_periph1", NULL }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -260,6 +263,16 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_NKMP_DIVIDE_BY_TWO), SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH0_2X, "pll_periph0_2x", "pll_periph0", 1, 2), + SUNXI_CCU_NKMP(A64_CLK_PLL_PERIPH1, "pll_periph1", "hosc", + PLL_PERIPH1_CTRL_REG, /* reg */ + __BITS(12,8), /* n */ + __BITS(5,4), /* k */ + 0,/* m */ + __BITS(17,16), /* p */ + __BIT(31), /* enable */ + SUNXI_CCU_NKMP_DIVIDE_BY_TWO), + SUNXI_CCU_FIXED_FACTOR(A64_CLK_PLL_PERIPH1_2X, "pll_periph1_2x", "pll_periph1", 1, 2), + SUNXI_CCU_NKMP_TABLE(A64_CLK_PLL_AUDIO_BASE, "pll_audio_base", "hosc", PLL_AUDIO_CTRL_REG, /* reg */ __BITS(14,8), /* n */ @@ -430,6 +443,21 @@ static struct sunxi_ccu_clk sun50i_a64_c __BIT(31), /* enable */ 0), + SUNXI_CCU_NM(A64_CLK_SPI0, "spi0", spi_parents, + SPI0_CLK_REG, /* reg */ + __BITS(17,16), /* n */ + __BITS(3,0), /* m */ + __BITS(25,24), /* sel */ + __BIT(31), /* enable */ + SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), + + SUNXI_CCU_NM(A64_CLK_SPI1, "spi1", spi_parents, + SPI1_CLK_REG, /* reg */ + __BITS(17,16), /* n */ + __BITS(3,0), /* m */ + __BITS(25,24), /* sel */ + __BIT(31), /* enable */ + SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN), SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:51:12 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c Log Message: Add SPI clocks To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:43 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: spdif_tx.c Log Message: Add driver for dummy spdif transmitter bindings. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/spdif_tx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/files.fdt diff -u src/sys/dev/fdt/files.fdt:1.47 src/sys/dev/fdt/files.fdt:1.48 --- src/sys/dev/fdt/files.fdt:1.47 Wed Oct 30 21:37:56 2019 +++ src/sys/dev/fdt/files.fdt Sun Nov 17 19:30:42 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.47 2019/10/30 21:37:56 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.48 2019/11/17 19:30:42 jmcneill Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -98,6 +98,10 @@ device ausoc: audiobus attach ausoc at fdt file dev/fdt/ausoc.causoc +device spdiftx +attach spdiftx at fdt +file dev/fdt/spdif_tx.c spdiftx + define fdt_display_timing file dev/fdt/display_timing.c fdt_display_timing Added files: Index: src/sys/dev/fdt/spdif_tx.c diff -u /dev/null src/sys/dev/fdt/spdif_tx.c:1.1 --- /dev/null Sun Nov 17 19:30:43 2019 +++ src/sys/dev/fdt/spdif_tx.c Sun Nov 17 19:30:42 2019 @@ -0,0 +1,114 @@ +/* $NetBSD: spdif_tx.c,v 1.1 2019/11/17 19:30:42 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: spdif_tx.c,v 1.1 2019/11/17 19:30:42 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include + +#include + +#include + +struct spdif_tx_softc { + device_t sc_dev; + struct audio_dai_device sc_dai; +}; + +static int spdif_tx_match(device_t, cfdata_t, void *); +static void spdif_tx_attach(device_t, device_t, void *); + +static const char *compatible[] = { + "linux,spdif-dit", + NULL +}; + +CFATTACH_DECL_NEW(spdiftx, sizeof(struct spdif_tx_softc), + spdif_tx_match, spdif_tx_attach, NULL, NULL); + +static int +spdif_tx_set_format(audio_dai_tag_t dai, u_int format) +{ + return 0; +} + +static int +spdif_tx_add_device(audio_dai_tag_t dai, audio_dai_tag_t aux) +{ + return 0; +} + +static const struct audio_hw_if spdif_tx_hw_if = { }; + +static audio_dai_tag_t +spdif_tx_dai_get_tag(device_t dev, const void *data, size_t len) +{ + struct spdif_tx_softc * const sc = device_private(dev); + + if (len != 4) + return NULL; + + return >sc_dai; +} + +static struct fdtbus_dai_controller_func spdif_tx_dai_funcs = { + .get_tag = spdif_tx_dai_get_tag +}; + +static int +spdif_tx_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +static void +spdif_tx_attach(device_t parent, device_t self, void *aux) +{ + struct spdif_tx_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + + sc->sc_dev = self; + + aprint_naive("\n"); + aprint_normal(": SPDIF transmitter\n"); + + sc->sc_dai.dai_set_format = spdif_tx_set_format; + sc->sc_dai.dai_add_device = spdif_tx_add_device; + sc->sc_dai.dai_hw_if = _tx_hw_if; + sc->sc_dai.dai_dev = self; + sc->sc_dai.dai_priv = sc; + fdtbus_register_dai_controller(self, phandle, _tx_dai_funcs); +}
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:59 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add spdiftx To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.113 src/sys/arch/evbarm/conf/GENERIC64:1.114 --- src/sys/arch/evbarm/conf/GENERIC64:1.113 Sat Nov 16 13:24:40 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Sun Nov 17 19:30:59 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.113 2019/11/16 13:24:40 jmcneill Exp $ +# $NetBSD: GENERIC64,v 1.114 2019/11/17 19:30:59 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -419,6 +419,7 @@ options HDAUDIOVERBOSE options HDAUDIO_ENABLE_HDMI options HDAUDIO_ENABLE_DISPLAYPORT ausoc* at fdt? # Simple SoC audio card +spdiftx* at fdt? # SPDIF transmitter rki2s* at fdt? # Rockchip I2S/PCM sunxicodec* at fdt? # Allwinner audio codec sun8icodec* at fdt? # Allwinner audio codec (sun8i/sun50i)
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:43 UTC 2019 Modified Files: src/sys/dev/fdt: files.fdt Added Files: src/sys/dev/fdt: spdif_tx.c Log Message: Add driver for dummy spdif transmitter bindings. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/dev/fdt/spdif_tx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sun Nov 17 19:30:59 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add spdiftx To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:35:10 UTC 2019 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pine64-plus.dts sun50i-a64-pine64.dts sun50i-a64-sopine-baseboard.dts sun50i-a64.dtsi Log Message: Enable HDMI audio support on Pine64, Pine64+, and Pine64 LTS boards. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun50i-a64-pine64.dts \ src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/dts/sun50i-a64.dtsi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:35:10 UTC 2019 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pine64-plus.dts sun50i-a64-pine64.dts sun50i-a64-sopine-baseboard.dts sun50i-a64.dtsi Log Message: Enable HDMI audio support on Pine64, Pine64+, and Pine64 LTS boards. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun50i-a64-pine64.dts \ src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/dts/sun50i-a64.dtsi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts diff -u src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.2 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.3 --- src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.2 Sat Sep 9 12:05:28 2017 +++ src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts Sun Nov 17 17:35:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.2 2017/09/09 12:05:28 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.3 2019/11/17 17:35:10 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -49,3 +49,11 @@ { status = "okay"; }; + + { + status = "okay"; +}; + +_hdmi { + status = "okay"; +}; Index: src/sys/arch/arm/dts/sun50i-a64-pine64.dts diff -u src/sys/arch/arm/dts/sun50i-a64-pine64.dts:1.1 src/sys/arch/arm/dts/sun50i-a64-pine64.dts:1.2 --- src/sys/arch/arm/dts/sun50i-a64-pine64.dts:1.1 Sun Feb 18 12:20:25 2018 +++ src/sys/arch/arm/dts/sun50i-a64-pine64.dts Sun Nov 17 17:35:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64-pine64.dts,v 1.1 2018/02/18 12:20:25 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64-pine64.dts,v 1.2 2019/11/17 17:35:10 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -28,3 +28,11 @@ #include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts" #include "sun50i-a64.dtsi" + + { + status = "okay"; +}; + +_hdmi { + status = "okay"; +}; Index: src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts diff -u src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.1 src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.2 --- src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.1 Thu Jun 7 00:51:41 2018 +++ src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts Sun Nov 17 17:35:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.1 2018/06/07 00:51:41 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.2 2019/11/17 17:35:10 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -28,3 +28,11 @@ #include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts" #include "sun50i-a64.dtsi" + + { + status = "okay"; +}; + +_hdmi { + status = "okay"; +}; Index: src/sys/arch/arm/dts/sun50i-a64.dtsi diff -u src/sys/arch/arm/dts/sun50i-a64.dtsi:1.12 src/sys/arch/arm/dts/sun50i-a64.dtsi:1.13 --- src/sys/arch/arm/dts/sun50i-a64.dtsi:1.12 Fri Nov 8 11:12:09 2019 +++ src/sys/arch/arm/dts/sun50i-a64.dtsi Sun Nov 17 17:35:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64.dtsi,v 1.12 2019/11/08 11:12:09 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64.dtsi,v 1.13 2019/11/17 17:35:10 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -59,6 +59,36 @@ , ; }; + + i2s2: i2s@1c22800 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun50i-a64-i2s", + "allwinner,sun8i-h3-i2s"; + reg = <0x01c22800 0x400>; + interrupts = ; + clocks = < CLK_BUS_I2S2>, < CLK_I2S2>; + clock-names = "apb", "mod"; + resets = < RST_BUS_I2S2>; + dma-names = "tx"; + dmas = < 27>; + status = "disabled"; + }; + + sound_hdmi: sound-hdmi { + compatible = "simple-audio-card"; + simple-audio-card,name = "hdmi-audio"; + simple-audio-card,format = "i2s"; + simple-audio-card,mclk-fs = <256>; + status = "disabled"; + + simple-audio-card,cpu { + sound-dai = <>; + }; + + simple-audio-card,codec { + sound-dai = <>; + }; + }; }; {
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:34 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_i2s.c Log Message: Add A64 HDMI audio support. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_i2s.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_dwhdmi.c diff -u src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.3 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.4 --- src/sys/arch/arm/sunxi/sunxi_dwhdmi.c:1.3 Sat Feb 2 17:35:16 2019 +++ src/sys/arch/arm/sunxi/sunxi_dwhdmi.c Sun Nov 17 17:33:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $ */ +/* $NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.3 2019/02/02 17:35:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_dwhdmi.c,v 1.4 2019/11/17 17:33:34 jmcneill Exp $"); #include #include @@ -197,6 +197,21 @@ sunxi_dwhdmi_mode_set(struct dwhdmi_soft sc->sc_curmode = *adjusted_mode; } +static audio_dai_tag_t +sunxi_dwhdmi_dai_get_tag(device_t dev, const void *data, size_t len) +{ + struct sunxi_dwhdmi_softc * const sc = device_private(dev); + + if (len != 4) + return NULL; + + return >sc_base.sc_dai; +} + +static struct fdtbus_dai_controller_func sunxi_dwhdmi_dai_funcs = { + .get_tag = sunxi_dwhdmi_dai_get_tag +}; + static int sunxi_dwhdmi_match(device_t parent, cfdata_t cf, void *aux) { @@ -263,6 +278,8 @@ sunxi_dwhdmi_attach(device_t parent, dev sc->sc_ports.dp_ep_activate = sunxi_dwhdmi_ep_activate; sc->sc_ports.dp_ep_get_data = sunxi_dwhdmi_ep_get_data; fdt_ports_register(>sc_ports, self, phandle, EP_DRM_BRIDGE); + + fdtbus_register_dai_controller(self, phandle, _dwhdmi_dai_funcs); } CFATTACH_DECL_NEW(sunxi_dwhdmi, sizeof(struct sunxi_dwhdmi_softc), Index: src/sys/arch/arm/sunxi/sunxi_i2s.c diff -u src/sys/arch/arm/sunxi/sunxi_i2s.c:1.6 src/sys/arch/arm/sunxi/sunxi_i2s.c:1.7 --- src/sys/arch/arm/sunxi/sunxi_i2s.c:1.6 Sat Jun 8 08:02:37 2019 +++ src/sys/arch/arm/sunxi/sunxi_i2s.c Sun Nov 17 17:33:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_i2s.c,v 1.6 2019/06/08 08:02:37 isaki Exp $ */ +/* $NetBSD: sunxi_i2s.c,v 1.7 2019/11/17 17:33:34 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.6 2019/06/08 08:02:37 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.7 2019/11/17 17:33:34 jmcneill Exp $"); #include #include @@ -42,16 +42,24 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c, #include -#define SUNXI_I2S_CLK_RATE 24576000 +#define SUNXI_I2S_CLK_RATE 24576000 +#define SUNXI_I2S_SAMPLE_RATE 48000 #define DA_CTL 0x00 +#define DA_CTL_BCLK_OUT __BIT(18) /* sun8i */ +#define DA_CLK_LRCK_OUT __BIT(17) /* sun8i */ #define DA_CTL_SDO_EN __BIT(8) -#define DA_CTL_MS __BIT(5) -#define DA_CTL_PCM __BIT(4) +#define DA_CTL_MS __BIT(5) /* sun4i */ +#define DA_CTL_PCM __BIT(4) /* sun4i */ +#define DA_CTL_MODE_SEL __BITS(5,4) /* sun8i */ +#define DA_CTL_MODE_SEL_PCM 0 +#define DA_CTL_MODE_SEL_LJ 1 +#define DA_CTL_MODE_SEL_RJ 2 #define DA_CTL_TXEN __BIT(2) #define DA_CTL_RXEN __BIT(1) #define DA_CTL_GEN __BIT(0) #define DA_FAT0 0x04 +#define DA_FAT0_LRCK_PERIOD __BITS(17,8) /* sun8i */ #define DA_FAT0_LRCP __BIT(7) #define DA_LRCP_NORMAL 0 #define DA_LRCP_INVERTED 1 @@ -79,20 +87,34 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c, #define DA_INT_RX_DRQ __BIT(3) #define DA_TXFIFO 0x20 #define DA_CLKD 0x24 -#define DA_CLKD_MCLKO_EN __BIT(7) -#define DA_CLKD_BCLKDIV __BITS(6,4) +#define DA_CLKD_MCLKO_EN_SUN8I __BIT(8) +#define DA_CLKD_MCLKO_EN_SUN4I __BIT(7) +#define DA_CLKD_BCLKDIV_SUN8I __BITS(7,4) +#define DA_CLKD_BCLKDIV_SUN4I __BITS(6,4) #define DA_CLKD_BCLKDIV_8 3 #define DA_CLKD_BCLKDIV_16 5 #define DA_CLKD_MCLKDIV __BITS(3,0) #define DA_CLKD_MCLKDIV_1 0 #define DA_TXCNT 0x28 #define DA_RXCNT 0x2c +#define DA_CHCFG 0x30 /* sun8i */ +#define DA_CHCFG_TX_SLOT_HIZ __BIT(9) +#define DA_CHCFG_TXN_STATE __BIT(8) +#define DA_CHCFG_RX_SLOT_NUM __BITS(6,4) +#define DA_CHCFG_TX_SLOT_NUM __BITS(2,0) +#define DA_CHSEL_OFFSET __BITS(13,12) /* sun8i */ #define DA_CHSEL_EN __BITS(11,4) #define DA_CHSEL_SEL __BITS(2,0) +enum sunxi_i2s_type { + SUNXI_I2S_SUN4I, + SUNXI_I2S_SUN8I, +}; + struct sunxi_i2s_config { const char *name; + enum sunxi_i2s_type type; bus_size_t txchsel; bus_size_t txchmap; bus_size_t rxchsel; @@ -101,15 +123,27 @@ struct sunxi_i2s_config { static const struct sunxi_i2s_config sun50i_a64_codec_config = { .name = "Aud
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:17 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_ccu_div.c Log Message: Add support for A64 I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:17 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sun50i_a64_ccu.c sunxi_ccu_div.c Log Message: Add support for A64 I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sun50i_a64_ccu.c diff -u src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.13 src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.14 --- src/sys/arch/arm/sunxi/sun50i_a64_ccu.c:1.13 Mon Jul 1 21:06:47 2019 +++ src/sys/arch/arm/sunxi/sun50i_a64_ccu.c Sun Nov 17 17:33:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i_a64_ccu.c,v 1.13 2019/07/01 21:06:47 jmcneill Exp $ */ +/* $NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.13 2019/07/01 21:06:47 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sun50i_a64_ccu.c,v 1.14 2019/11/17 17:33:17 jmcneill Exp $"); #include #include @@ -60,6 +60,9 @@ __KERNEL_RCSID(1, "$NetBSD: sun50i_a64_c #define SDMMC0_CLK_REG 0x088 #define SDMMC1_CLK_REG 0x08c #define SDMMC2_CLK_REG 0x090 +#define I2SPCM0_CLK_REG 0x0b0 +#define I2SPCM1_CLK_REG 0x0b4 +#define I2SPCM2_CLK_REG 0x0b8 #define USBPHY_CFG_REG 0x0cc #define DRAM_CFG_REG 0x0f4 #define MBUS_RST_REG 0x0fc @@ -154,6 +157,7 @@ static const char *mmc_parents[] = { "ho static const char *ths_parents[] = { "hosc", NULL, NULL, NULL }; static const char *de_parents[] = { "pll_periph0_2x", "pll_de" }; static const char *hdmi_parents[] = { "pll_video0", "pll_video1" }; +static const char *i2s_parents[] = { "pll_audio_8x", "pll_audio_4x", "pll_audio_2x", "pll_audio" }; static const char *tcon1_parents[] = { "pll_video0", NULL, "pll_video1", NULL }; static const char *gpu_parents[] = { "pll_gpu" }; @@ -407,6 +411,26 @@ static struct sunxi_ccu_clk sun50i_a64_c SUNXI_CCU_GATE(A64_CLK_HDMI_DDC, "hdmi-ddc", "hosc", HDMI_SLOW_CLK_REG, 31), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S0, "i2s0", i2s_parents, + I2SPCM0_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S1, "i2s1", i2s_parents, + I2SPCM1_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + SUNXI_CCU_DIV_GATE(A64_CLK_I2S2, "i2s2", i2s_parents, + I2SPCM2_CLK_REG, /* reg */ + 0, /* div */ + __BITS(17,16), /* sel */ + __BIT(31), /* enable */ + 0), + + SUNXI_CCU_DIV_GATE(A64_CLK_TCON1, "tcon1", tcon1_parents, TCON1_CLK_REG, /* reg */ __BITS(3,0), /* div */ Index: src/sys/arch/arm/sunxi/sunxi_ccu_div.c diff -u src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.5 src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_ccu_div.c:1.5 Mon Mar 19 16:19:17 2018 +++ src/sys/arch/arm/sunxi/sunxi_ccu_div.c Sun Nov 17 17:33:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $ */ +/* $NetBSD: sunxi_ccu_div.c,v 1.6 2019/11/17 17:33:17 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.5 2018/03/19 16:19:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_div.c,v 1.6 2019/11/17 17:33:17 jmcneill Exp $"); #include #include @@ -98,6 +98,38 @@ sunxi_ccu_div_get_rate(struct sunxi_ccu_ return rate / ratio; } +static int +sunxi_ccu_div_select_parent(struct sunxi_ccu_softc *sc, +struct sunxi_ccu_clk *clk, u_int new_rate) +{ + struct sunxi_ccu_div *div = >u.div; + struct sunxi_ccu_clk *clk_parent; + struct clk *best_parent; + u_int index, best_diff; + const char *pname; + + best_parent = NULL; + best_diff = ~0u; + for (index = 0; index < div->nparents; index++) { + pname = div->parents[index]; + if (pname == NULL) + continue; + clk_parent = sunxi_ccu_clock_find(sc, pname); + if (clk_parent == NULL) + continue; + const u_int rate = clk_get_rate(_parent->base); + const u_int diff = abs((int)rate - (int)new_rate); + if (diff < best_diff) { + best_diff = diff; + best_parent = _parent->base; + } + } + if (best_diff == ~0u) + return EINVAL; + + return clk_set_parent(>base, best_parent); +} + int sunxi_ccu_div_set_rate(struct sunxi_ccu_softc *sc, struct sunxi_ccu_clk *clk, u_int new_rate) @@ -119,7 +151,7 @@ sunxi_ccu_div_set_rate(struct sunxi_ccu_ if ((div->flags & SUNXI_CCU_DIV_SET_RATE_PARENT) != 0) return clk_set_rate(clkp_parent, new_rate); else - return ENXIO; + return sunxi_ccu_div_select_parent(sc, clk, new_rate); } val = CCU_READ(sc, div->reg);
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sun Nov 17 17:33:34 UTC 2019 Modified Files: src/sys/arch/arm/sunxi: sunxi_dwhdmi.c sunxi_i2s.c Log Message: Add A64 HDMI audio support. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_dwhdmi.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_i2s.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:25:33 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_dwhdmi.c Log Message: Add audio support To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/rockchip/rk_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:25:33 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_dwhdmi.c Log Message: Add audio support To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/rockchip/rk_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk_dwhdmi.c diff -u src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.2 src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.3 --- src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.2 Sun Nov 10 12:07:50 2019 +++ src/sys/arch/arm/rockchip/rk_dwhdmi.c Sat Nov 16 13:25:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_dwhdmi.c,v 1.2 2019/11/10 12:07:50 jmcneill Exp $ */ +/* $NetBSD: rk_dwhdmi.c,v 1.3 2019/11/16 13:25:33 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.2 2019/11/10 12:07:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.3 2019/11/16 13:25:33 jmcneill Exp $"); #include #include @@ -194,6 +194,21 @@ rk_dwhdmi_mode_set(struct dwhdmi_softc * dwhdmi_phy_mode_set(dsc, mode, adjusted_mode); } +static audio_dai_tag_t +rk_dwhdmi_dai_get_tag(device_t dev, const void *data, size_t len) +{ + struct rk_dwhdmi_softc * const sc = device_private(dev); + + if (len != 4) + return NULL; + + return >sc_base.sc_dai; +} + +static struct fdtbus_dai_controller_func rk_dwhdmi_dai_funcs = { + .get_tag = rk_dwhdmi_dai_get_tag +}; + static int rk_dwhdmi_match(device_t parent, cfdata_t cf, void *aux) { @@ -287,6 +302,8 @@ rk_dwhdmi_attach(device_t parent, device sc->sc_ports.dp_ep_activate = rk_dwhdmi_ep_activate; sc->sc_ports.dp_ep_get_data = rk_dwhdmi_ep_get_data; fdt_ports_register(>sc_ports, self, phandle, EP_DRM_BRIDGE); + + fdtbus_register_dai_controller(self, phandle, _dwhdmi_dai_funcs); } CFATTACH_DECL_NEW(rk_dwhdmi, sizeof(struct rk_dwhdmi_softc),
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:40 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add rki2s To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.112 src/sys/arch/evbarm/conf/GENERIC64:1.113 --- src/sys/arch/evbarm/conf/GENERIC64:1.112 Thu Nov 14 20:40:25 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Sat Nov 16 13:24:40 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.112 2019/11/14 20:40:25 jmcneill Exp $ +# $NetBSD: GENERIC64,v 1.113 2019/11/16 13:24:40 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -419,6 +419,7 @@ options HDAUDIOVERBOSE options HDAUDIO_ENABLE_HDMI options HDAUDIO_ENABLE_DISPLAYPORT ausoc* at fdt? # Simple SoC audio card +rki2s* at fdt? # Rockchip I2S/PCM sunxicodec* at fdt? # Allwinner audio codec sun8icodec* at fdt? # Allwinner audio codec (sun8i/sun50i) h3codec* at fdt? # Allwinner H3 audio codec (analog part)
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:25 UTC 2019 Modified Files: src/sys/arch/arm/dts: rk3399-rockpro64.dts Log Message: Enable HDMI audio on ROCKPro64 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/dts/rk3399-rockpro64.dts Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/dts/rk3399-rockpro64.dts diff -u src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.8 src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.9 --- src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.8 Tue Aug 13 17:24:25 2019 +++ src/sys/arch/arm/dts/rk3399-rockpro64.dts Sat Nov 16 13:24:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk3399-rockpro64.dts,v 1.8 2019/08/13 17:24:25 tnn Exp $ */ +/* $NetBSD: rk3399-rockpro64.dts,v 1.9 2019/11/16 13:24:25 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -88,3 +88,7 @@ status = "okay"; }; }; + +_sound { + status = "okay"; +};
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:03 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: files.rockchip Added Files: src/sys/arch/arm/rockchip: rk_i2s.c Log Message: Add driver for Rockchip I2S/PCM controller. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/rockchip/files.rockchip cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_i2s.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:03 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: files.rockchip Added Files: src/sys/arch/arm/rockchip: rk_i2s.c Log Message: Add driver for Rockchip I2S/PCM controller. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/rockchip/files.rockchip cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_i2s.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/files.rockchip diff -u src/sys/arch/arm/rockchip/files.rockchip:1.21 src/sys/arch/arm/rockchip/files.rockchip:1.22 --- src/sys/arch/arm/rockchip/files.rockchip:1.21 Sat Nov 9 23:30:14 2019 +++ src/sys/arch/arm/rockchip/files.rockchip Sat Nov 16 13:24:03 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.rockchip,v 1.21 2019/11/09 23:30:14 jmcneill Exp $ +# $NetBSD: files.rockchip,v 1.22 2019/11/16 13:24:03 jmcneill Exp $ # # Configuration info for Rockchip family SoCs # @@ -103,6 +103,11 @@ file arch/arm/rockchip/rk_vop.c rk_vop attach dwhdmi at fdt with rk_dwhdmi file arch/arm/rockchip/rk_dwhdmi.c rk_dwhdmi +# I2S/PCM controller +device rki2s +attach rki2s at fdt with rk_i2s +filearch/arm/rockchip/rk_i2s.c rk_i2s + # SOC parameters defflag opt_soc.h SOC_ROCKCHIP defflag opt_soc.h SOC_RK3328: SOC_ROCKCHIP Added files: Index: src/sys/arch/arm/rockchip/rk_i2s.c diff -u /dev/null src/sys/arch/arm/rockchip/rk_i2s.c:1.1 --- /dev/null Sat Nov 16 13:24:03 2019 +++ src/sys/arch/arm/rockchip/rk_i2s.c Sat Nov 16 13:24:03 2019 @@ -0,0 +1,638 @@ +/* $NetBSD: rk_i2s.c,v 1.1 2019/11/16 13:24:03 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: rk_i2s.c,v 1.1 2019/11/16 13:24:03 jmcneill Exp $"); + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#define RK_I2S_FIFO_DEPTH 32 +#define RK_I2S_SAMPLE_RATE 48000 + +#define I2S_TXCR 0x00 +#define TXCR_RCNT __BITS(22,17) +#define TXCR_TCSR __BITS(16,15) +#define TXCR_HWT __BIT(14) +#define TXCR_SJM __BIT(12) +#define TXCR_FBM __BIT(11) +#define TXCR_IBM __BITS(10,9) +#define TXCR_PBM __BITS(8,7) +#define TXCR_TFS __BIT(5) +#define TXCR_VDW __BITS(4,0) +#define I2S_RXCR 0x04 +#define RXCR_RCSR __BITS(16,15) +#define RXCR_HWT __BIT(14) +#define RXCR_SJM __BIT(12) +#define RXCR_FBM __BIT(11) +#define RXCR_IBM __BITS(10,9) +#define RXCR_PBM __BITS(8,7) +#define RXCR_TFS __BIT(5) +#define RXCR_VDW __BITS(4,0) +#define I2S_CKR 0x08 +#define CKR_TRCM __BITS(29,28) +#define CKR_MSS __BIT(27) +#define CKR_CKP __BIT(26) +#define CKR_RLP __BIT(25) +#define CKR_TLP __BIT(24) +#define CKR_MDIV __BITS(23,16) +#define CKR_RSD __BITS(15,8) +#define CKR_TSD __BITS(7,0) +#define I2S_TXFIFOLR 0x0c +#define TXFIFOLR_TFL(n) __BITS((n) * 6 + 5, (n) * 6) +#define I2S_DMACR 0x10 +#define DMACR_RDE __BIT(24) +#define DMACR_RDL __BITS(20,16) +#define DMACR_TDE __BIT(8) +#define DMACR_TDL __BITS(4,0) +#define I2S_INTCR 0x14 +#define INTCR_RFT __BITS(24,20) +#define INTCR_RXOIC __BIT(18) +#define INTCR_RXOIE __BIT(17) +#define INTCR_RXFIE __BIT(16) +#define INTCR_TFT __BITS(8,4) +#define INTCR_TXUIC __BIT(2) +#define INTCR_TXUIE __BIT(1) +#define INTCR_TXEIE __BIT(0) +#define I2S_INTSR 0x18 +#define INTSR_RXOI __BIT(17) +#define INTSR_RXFI __BIT(16) +#define INTSR_TXUI __BIT(1) +#define INTSR_TXEI __BIT(0) +#define I2S_XFER 0x1c +#define XFER_RXS __BIT(1) +#define
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:40 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add rki2s To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:24:25 UTC 2019 Modified Files: src/sys/arch/arm/dts: rk3399-rockpro64.dts Log Message: Enable HDMI audio on ROCKPro64 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/dts/rk3399-rockpro64.dts Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:23:13 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_cru.c rk_cru.h rk_cru_composite.c Log Message: Add support for I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/rockchip/rk3399_cru.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk_cru.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk_cru_composite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:23:13 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_cru.c rk_cru.h rk_cru_composite.c Log Message: Add support for I2S clocks. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/rockchip/rk3399_cru.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk_cru.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/rockchip/rk_cru_composite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk3399_cru.c diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.12 src/sys/arch/arm/rockchip/rk3399_cru.c:1.13 --- src/sys/arch/arm/rockchip/rk3399_cru.c:1.12 Sun Nov 10 11:43:04 2019 +++ src/sys/arch/arm/rockchip/rk3399_cru.c Sat Nov 16 13:23:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk3399_cru.c,v 1.12 2019/11/10 11:43:04 jmcneill Exp $ */ +/* $NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.12 2019/11/10 11:43:04 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $"); #include #include @@ -361,6 +361,11 @@ static const char * mux_aclk_perihp_pare static const char * mux_aclk_cci_parents[] = { "cpll_aclk_cci_src", "gpll_aclk_cci_src", "npll_aclk_cci_src", "vpll_aclk_cci_src" }; static const char * mux_dclk_vop0_parents[] = { "dclk_vop0_div", "dclk_vop0_frac" }; static const char * mux_dclk_vop1_parents[] = { "dclk_vop1_div", "dclk_vop1_frac" }; +static const char * mux_i2s0_parents[] = { "clk_i2s0_div", "clk_i2s0_frac", "clkin_i2s", "xin12m" }; +static const char * mux_i2s1_parents[] = { "clk_i2s1_div", "clk_i2s1_frac", "clkin_i2s", "xin12m" }; +static const char * mux_i2s2_parents[] = { "clk_i2s2_div", "clk_i2s2_frac", "clkin_i2s", "xin12m" }; +static const char * mux_i2sch_parents[] = { "clk_i2s0", "clk_i2s1", "clk_i2s2" }; +static const char * mux_i2sout_parents[] = { "clk_i2sout_src", "xin12m" }; static const char * mux_uart0_parents[] = { "clk_uart0_div", "clk_uart0_frac", "xin24m" }; static const char * mux_uart1_parents[] = { "clk_uart1_div", "clk_uart1_frac", "xin24m" }; static const char * mux_uart2_parents[] = { "clk_uart2_div", "clk_uart2_frac", "xin24m" }; @@ -939,13 +944,73 @@ static struct rk_cru_clk rk3399_cru_clks 0), RK_GATE(RK3399_PCLK_HDMI_CTRL, "pclk_hdmi_ctrl", "pclk_hdcp", CLKGATE_CON(29), 6), RK_GATE(RK3399_SCLK_HDMI_SFR, "clk_hdmi_sfr", "xin24m", CLKGATE_CON(11), 6), + + /* I2S2 */ + RK_COMPOSITE(0, "clk_i2s0_div", mux_pll_src_cpll_gpll_parents, + CLKSEL_CON(28), /* muxdiv_reg */ + __BIT(7), /* mux_mask */ + __BITS(6,0), /* div_mask */ + CLKGATE_CON(8), /* gate_reg */ + __BIT(3), /* gate_mask */ + 0), + RK_COMPOSITE(0, "clk_i2s1_div", mux_pll_src_cpll_gpll_parents, + CLKSEL_CON(29), /* muxdiv_reg */ + __BIT(7), /* mux_mask */ + __BITS(6,0), /* div_mask */ + CLKGATE_CON(8), /* gate_reg */ + __BIT(6), /* gate_mask */ + 0), + RK_COMPOSITE(0, "clk_i2s2_div", mux_pll_src_cpll_gpll_parents, + CLKSEL_CON(30), /* muxdiv_reg */ + __BIT(7), /* mux_mask */ + __BITS(6,0), /* div_mask */ + CLKGATE_CON(8), /* gate_reg */ + __BIT(9), /* gate_mask */ + 0), + RK_COMPOSITE_FRAC(0, "clk_i2s0_frac", "clk_i2s0_div", + CLKSEL_CON(96), /* frac_reg */ + 0), + RK_COMPOSITE_FRAC(0, "clk_i2s1_frac", "clk_i2s1_div", + CLKSEL_CON(97), /* frac_reg */ + 0), + RK_COMPOSITE_FRAC(0, "clk_i2s2_frac", "clk_i2s2_div", + CLKSEL_CON(98), /* frac_reg */ + 0), + RK_MUX(0, "clk_i2s0_mux", mux_i2s0_parents, CLKSEL_CON(28), __BITS(9,8)), + RK_MUX(0, "clk_i2s1_mux", mux_i2s1_parents, CLKSEL_CON(29), __BITS(9,8)), + RK_MUX(0, "clk_i2s2_mux", mux_i2s2_parents, CLKSEL_CON(30), __BITS(9,8)), + RK_GATE(RK3399_SCLK_I2S0_8CH, "clk_i2s0", "clk_i2s0_mux", CLKGATE_CON(8), 5), + RK_GATE(RK3399_SCLK_I2S1_8CH, "clk_i2s1", "clk_i2s1_mux", CLKGATE_CON(8), 8), + RK_GATE(RK3399_SCLK_I2S2_8CH, "clk_i2s2", "clk_i2s2_mux", CLKGATE_CON(8), 11), + RK_GATE(RK3399_HCLK_I2S0_8CH, "hclk_i2s0", "hclk_perilp1", CLKGATE_CON(34), 0), + RK_GATE(RK3399_HCLK_I2S1_8CH, "hclk_i2s1", "hclk_perilp1", CLKGATE_CON(34), 1), + RK_GATE(RK3399_HCLK_I2S2_8CH, "hclk_i2s2", "hclk_perilp1", CLKGATE_CON(34), 2), + RK_MUX(0, "clk_i2sout_src", mux_i2sch_parents, CLKSEL_CON(31), __BITS(1,0)), + RK_COMPOSITE(RK3399_SCLK_I2S_8CH_OUT, "clk_i2sout", mux_i2sout_parents, + CLKSEL_CON(31), /* muxdiv_reg */ + __BIT(2), /* mux_mask */ + 0, /* div_mask */ + CLKGATE_CON(8), /* gate_reg */ + __BIT(12), /* gate_mask */ + RK_COMPOSITE_SET_RATE_PARENT), +}; + +static const struct rk3399_init_param { + const char *clk; + const char *parent; +} rk3399_init_params[] = { + { .clk = "clk_i2s0_mux", .parent
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:10:07 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c dw_hdmi.h Log Message: Add software volume controls. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dw_hdmi.c diff -u src/sys/dev/ic/dw_hdmi.c:1.3 src/sys/dev/ic/dw_hdmi.c:1.4 --- src/sys/dev/ic/dw_hdmi.c:1.3 Sat Nov 16 12:50:08 2019 +++ src/sys/dev/ic/dw_hdmi.c Sat Nov 16 13:10:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */ +/* $NetBSD: dw_hdmi.c,v 1.4 2019/11/16 13:10:07 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.4 2019/11/16 13:10:07 jmcneill Exp $"); #include #include @@ -752,12 +752,47 @@ dwhdmi_dai_add_device(audio_dai_tag_t da return 0; } +static void +dwhdmi_audio_swvol_codec(audio_filter_arg_t *arg) +{ + struct dwhdmi_softc * const sc = arg->context; + const aint_t *src; + aint_t *dst; + u_int sample_count; + u_int i; + + src = arg->src; + dst = arg->dst; + sample_count = arg->count * arg->srcfmt->channels; + for (i = 0; i < sample_count; i++) { + aint2_t v = (aint2_t)(*src++); + v = v * sc->sc_swvol / 255; + *dst++ = (aint_t)v; + } +} + +static int +dwhdmi_audio_set_format(void *priv, int setmode, +const audio_params_t *play, const audio_params_t *rec, +audio_filter_reg_t *pfil, audio_filter_reg_t *rfil) +{ + struct dwhdmi_softc * const sc = priv; + + pfil->codec = dwhdmi_audio_swvol_codec; + pfil->context = sc; + + return 0; +} + static int -dwhdmi_dai_set_port(void *priv, mixer_ctrl_t *mc) +dwhdmi_audio_set_port(void *priv, mixer_ctrl_t *mc) { + struct dwhdmi_softc * const sc = priv; + switch (mc->dev) { case DWHDMI_DAI_OUTPUT_MASTER_VOLUME: case DWHDMI_DAI_INPUT_DAC_VOLUME: + sc->sc_swvol = mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT]; return 0; default: return ENXIO; @@ -765,13 +800,15 @@ dwhdmi_dai_set_port(void *priv, mixer_ct } static int -dwhdmi_dai_get_port(void *priv, mixer_ctrl_t *mc) +dwhdmi_audio_get_port(void *priv, mixer_ctrl_t *mc) { + struct dwhdmi_softc * const sc = priv; + switch (mc->dev) { case DWHDMI_DAI_OUTPUT_MASTER_VOLUME: case DWHDMI_DAI_INPUT_DAC_VOLUME: - mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 255; - mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = 255; + mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->sc_swvol; + mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_swvol; return 0; default: return ENXIO; @@ -779,7 +816,7 @@ dwhdmi_dai_get_port(void *priv, mixer_ct } static int -dwhdmi_dai_query_devinfo(void *priv, mixer_devinfo_t *di) +dwhdmi_audio_query_devinfo(void *priv, mixer_devinfo_t *di) { switch (di->index) { case DWHDMI_DAI_OUTPUT_CLASS: @@ -822,9 +859,10 @@ dwhdmi_dai_query_devinfo(void *priv, mix } static const struct audio_hw_if dwhdmi_dai_hw_if = { - .set_port = dwhdmi_dai_set_port, - .get_port = dwhdmi_dai_get_port, - .query_devinfo = dwhdmi_dai_query_devinfo, + .set_format = dwhdmi_audio_set_format, + .set_port = dwhdmi_audio_set_port, + .get_port = dwhdmi_audio_get_port, + .query_devinfo = dwhdmi_audio_query_devinfo, }; int @@ -849,6 +887,8 @@ dwhdmi_attach(struct dwhdmi_softc *sc) sc->sc_version >> 12, sc->sc_version & 0xfff, sc->sc_phytype); + sc->sc_swvol = 255; + /* * If a DDC i2c bus tag is provided by the caller, use it. Otherwise, * use the I2C master built-in to DWC HDMI. Index: src/sys/dev/ic/dw_hdmi.h diff -u src/sys/dev/ic/dw_hdmi.h:1.3 src/sys/dev/ic/dw_hdmi.h:1.4 --- src/sys/dev/ic/dw_hdmi.h:1.3 Sat Nov 16 12:50:08 2019 +++ src/sys/dev/ic/dw_hdmi.h Sat Nov 16 13:10:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_hdmi.h,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */ +/* $NetBSD: dw_hdmi.h,v 1.4 2019/11/16 13:10:07 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -76,6 +76,7 @@ struct dwhdmi_softc { struct i2c_controller sc_ic_builtin; struct audio_dai_device sc_dai; + uint8_t sc_swvol; struct dwhdmi_connector sc_connector; struct drm_bridge sc_bridge;
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 16 13:10:07 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c dw_hdmi.h Log Message: Add software volume controls. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:50:08 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c dw_hdmi.h Log Message: Add I2S audio input support. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dw_hdmi.c diff -u src/sys/dev/ic/dw_hdmi.c:1.2 src/sys/dev/ic/dw_hdmi.c:1.3 --- src/sys/dev/ic/dw_hdmi.c:1.2 Sat Nov 9 23:27:50 2019 +++ src/sys/dev/ic/dw_hdmi.c Sat Nov 16 12:50:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_hdmi.c,v 1.2 2019/11/09 23:27:50 jmcneill Exp $ */ +/* $NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.2 2019/11/09 23:27:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $"); #include #include @@ -45,6 +45,8 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v #include #include +#include + #include #include #include @@ -52,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v #define HDMI_DESIGN_ID 0x #define HDMI_REVISION_ID 0x0001 +#define HDMI_CONFIG0_ID 0x0004 +#define HDMI_CONFIG0_ID_AUDI2S __BIT(4) #define HDMI_CONFIG2_ID 0x0006 #define HDMI_IH_I2CM_STAT0 0x0105 @@ -131,6 +135,10 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v #define HDMI_FC_CH1PREAM_DEFAULT 0x16 #define HDMI_FC_CH2PREAM 0x1016 #define HDMI_FC_CH2PREAM_DEFAULT 0x21 +#define HDMI_FC_AUDCONF0 0x1025 +#define HDMI_FC_AUDCONF1 0x1026 +#define HDMI_FC_AUDCONF2 0x1027 +#define HDMI_FC_AUDCONF3 0x1028 #define HDMI_PHY_CONF0 0x3000 #define HDMI_PHY_CONF0_PDZ __BIT(7) @@ -149,6 +157,28 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v #define HDMI_PHY_STAT0_HPD __BIT(1) #define HDMI_PHY_STAT0_TX_PHY_LOCK __BIT(0) +#define HDMI_AUD_CONF0 0x3100 +#define HDMI_AUD_CONF0_SW_AUDIO_FIFO_RST __BIT(7) +#define HDMI_AUD_CONF0_I2S_SELECT __BIT(5) +#define HDMI_AUD_CONF0_I2S_IN_EN __BITS(3,0) +#define HDMI_AUD_CONF1 0x3101 +#define HDMI_AUD_CONF1_I2S_WIDTH __BITS(4,0) +#define HDMI_AUD_INT 0x3102 +#define HDMI_AUD_CONF2 0x3103 +#define HDMI_AUD_CONF2_INSERT_PCUV __BIT(2) +#define HDMI_AUD_CONF2_NLPCM __BIT(1) +#define HDMI_AUD_CONF2_HBR __BIT(0) +#define HDMI_AUD_INT1 0x3104 + +#define HDMI_AUD_N1 0x3200 +#define HDMI_AUD_N2 0x3201 +#define HDMI_AUD_N3 0x3202 +#define HDMI_AUD_CTS1 0x3203 +#define HDMI_AUD_CTS2 0x3204 +#define HDMI_AUD_CTS3 0x3205 +#define HDMI_AUD_INPUTCLKFS 0x3206 +#define HDMI_AUD_INPUTCLKFS_IFSFACTOR __BITS(2,0) + #define HDMI_MC_CLKDIS 0x4001 #define HDMI_MC_CLKDIS_HDCPCLK_DISABLE __BIT(6) #define HDMI_MC_CLKDIS_CECCLK_DISABLE __BIT(5) @@ -210,6 +240,16 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v #define HDMI_I2CM_SOFTRSTZ_I2C_SOFTRST __BIT(0) #define HDMI_I2CM_SEGPTR 0x7e0a +enum dwhdmi_dai_mixer_ctrl { + DWHDMI_DAI_OUTPUT_CLASS, + DWHDMI_DAI_INPUT_CLASS, + + DWHDMI_DAI_OUTPUT_MASTER_VOLUME, + DWHDMI_DAI_INPUT_DAC_VOLUME, + + DWHDMI_DAI_MIXER_CTRL_LAST +}; + static int dwhdmi_ddc_acquire_bus(void *priv, int flags) { @@ -433,7 +473,6 @@ dwhdmi_fc_init(struct dwhdmi_softc *sc, static void dwhdmi_mc_init(struct dwhdmi_softc *sc) { - struct dwhdmi_connector *dwhdmi_connector = >sc_connector; uint8_t val; u_int n, iter; @@ -445,8 +484,6 @@ dwhdmi_mc_init(struct dwhdmi_softc *sc) HDMI_MC_CLKDIS_CECCLK_DISABLE | HDMI_MC_CLKDIS_CSCCLK_DISABLE | HDMI_MC_CLKDIS_PREPCLK_DISABLE; - if (!dwhdmi_connector->monitor_audio) - val |= HDMI_MC_CLKDIS_AUDCLK_DISABLE; dwhdmi_write(sc, HDMI_MC_CLKDIS, val); /* Soft reset TMDS */ @@ -467,6 +504,59 @@ dwhdmi_mc_disable(struct dwhdmi_softc *s dwhdmi_write(sc, HDMI_MC_CLKDIS, 0xff); } +static void +dwhdmi_audio_init(struct dwhdmi_softc *sc) +{ + uint8_t val; + u_int n; + + /* The following values are for 48 kHz */ + switch (sc->sc_curmode.clock) { + case 25170: + n = 6864; + break; + case 74170: + n = 11648; + break; + case 148350: + n = 5824; + break; + default: + n = 6144; + break; + } + + /* Use automatic CTS generation */ + dwhdmi_write(sc, HDMI_AUD_CTS1, 0); + dwhdmi_write(sc, HDMI_AUD_CTS2, 0); + dwhdmi_write(sc, HDMI_AUD_CTS3, 0); + + /* Set N factor for audio clock regeneration */ + dwhdmi_write(sc, HDMI_AUD_N1, n & 0xff); + dwhdmi_write(sc, HDMI_AUD_N2, (n >> 8) & 0xff); + dwhdmi_write(sc, HDMI_AUD_N3, (n >> 16) & 0xff); + + val = dwhdmi_read(sc, HDMI_AUD_CONF0); + val |= HDMI_AUD_CONF0_I2S_SELECT; /* XXX i2s mode */ + val &= ~HDMI_AUD_CONF0_I2S_IN_EN; + val |= __SHIFTIN(1, HDMI_AUD_CONF0_I2S_IN_EN); /* XXX 2ch */ + dwhdmi_write(sc, HDMI_AUD_CONF0, val); + + val = __SHIFTIN(16, HDMI_AUD_CONF1_I2S_WIDTH); + dwhdmi_write(sc
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:50:08 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi.c dw_hdmi.h Log Message: Add I2S audio input support. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:47:47 UTC 2019 Modified Files: src/sys/dev/fdt: ausoc.c Log Message: Set sysclk rate at set_format time, so the link set_format callback can read the new sysclk To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/ausoc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 16 12:47:47 UTC 2019 Modified Files: src/sys/dev/fdt: ausoc.c Log Message: Set sysclk rate at set_format time, so the link set_format callback can read the new sysclk To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/ausoc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fdt/ausoc.c diff -u src/sys/dev/fdt/ausoc.c:1.4 src/sys/dev/fdt/ausoc.c:1.5 --- src/sys/dev/fdt/ausoc.c:1.4 Wed May 8 13:40:18 2019 +++ src/sys/dev/fdt/ausoc.c Sat Nov 16 12:47:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ausoc.c,v 1.4 2019/05/08 13:40:18 isaki Exp $ */ +/* $NetBSD: ausoc.c,v 1.5 2019/11/16 12:47:47 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.4 2019/05/08 13:40:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.5 2019/11/16 12:47:47 jmcneill Exp $"); #include #include @@ -121,8 +121,22 @@ ausoc_set_format(void *priv, int setmode audio_filter_reg_t *pfil, audio_filter_reg_t *rfil) { struct ausoc_link * const link = priv; + const audio_params_t *params = (setmode & AUMODE_PLAY) != 0 ? + play : rec; int error; + if (link->link_mclk_fs) { + const u_int rate = params->sample_rate * link->link_mclk_fs; + error = audio_dai_set_sysclk(link->link_codec, rate, + AUDIO_DAI_CLOCK_IN); + if (error) + return error; + error = audio_dai_set_sysclk(link->link_cpu, rate, + AUDIO_DAI_CLOCK_OUT); + if (error) + return error; + } + error = audio_dai_mi_set_format(link->link_cpu, setmode, play, rec, pfil, rfil); if (error) @@ -246,20 +260,8 @@ ausoc_trigger_output(void *priv, void *s void (*intr)(void *), void *intrarg, const audio_params_t *params) { struct ausoc_link * const link = priv; - u_int n, rate; int error; - - if (link->link_mclk_fs) { - rate = params->sample_rate * link->link_mclk_fs; - error = audio_dai_set_sysclk(link->link_codec, rate, - AUDIO_DAI_CLOCK_IN); - if (error) - goto failed; - error = audio_dai_set_sysclk(link->link_cpu, rate, - AUDIO_DAI_CLOCK_OUT); - if (error) - goto failed; - } + u_int n; for (n = 0; n < link->link_naux; n++) { error = audio_dai_trigger(link->link_aux[n], start, end, @@ -285,20 +287,8 @@ ausoc_trigger_input(void *priv, void *st void (*intr)(void *), void *intrarg, const audio_params_t *params) { struct ausoc_link * const link = priv; - u_int n, rate; int error; - - if (link->link_mclk_fs) { - rate = params->sample_rate * link->link_mclk_fs; - error = audio_dai_set_sysclk(link->link_codec, rate, - AUDIO_DAI_CLOCK_IN); - if (error) - goto failed; - error = audio_dai_set_sysclk(link->link_cpu, rate, - AUDIO_DAI_CLOCK_OUT); - if (error) - goto failed; - } + u_int n; for (n = 0; n < link->link_naux; n++) { error = audio_dai_trigger(link->link_aux[n], start, end,
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:40:26 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Enable Rockchip display support To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:39:46 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_drm.c Log Message: Remove debug output To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_drm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk_drm.c diff -u src/sys/arch/arm/rockchip/rk_drm.c:1.1 src/sys/arch/arm/rockchip/rk_drm.c:1.2 --- src/sys/arch/arm/rockchip/rk_drm.c:1.1 Sat Nov 9 23:30:14 2019 +++ src/sys/arch/arm/rockchip/rk_drm.c Thu Nov 14 20:39:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_drm.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */ +/* $NetBSD: rk_drm.c,v 1.2 2019/11/14 20:39:46 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rk_drm.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rk_drm.c,v 1.2 2019/11/14 20:39:46 jmcneill Exp $"); #include #include @@ -134,8 +134,6 @@ rk_drm_attach(device_t parent, device_t sc->sc_bst = faa->faa_bst; sc->sc_phandle = faa->faa_phandle; - drm_debug = 0xff; - aprint_naive("\n"); if (prop_dictionary_get_bool(dict, "disabled", _disabled) && is_disabled) {
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:40:26 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Enable Rockchip display support To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.111 src/sys/arch/evbarm/conf/GENERIC64:1.112 --- src/sys/arch/evbarm/conf/GENERIC64:1.111 Sun Nov 10 09:55:29 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Thu Nov 14 20:40:25 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.111 2019/11/10 09:55:29 mrg Exp $ +# $NetBSD: GENERIC64,v 1.112 2019/11/14 20:40:25 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -436,9 +436,9 @@ hdmicec* at hdmicecbus? anxedp* at iic? # Analogix eDP TX dispcon* at fdt? # Display connector devices dwhdmi* at fdt? # Designware HDMI TX -#rkdrm* at fdt? pass 5 # Rockchip DRM master -#rkfb* at rkdrm? # Rockchip DRM framebuffer -#rkvop* at fdt? # Rockchip Visual Output Processor +rkdrm* at fdt? pass 5 # Rockchip DRM master +rkfb* at rkdrm? # Rockchip DRM framebuffer +rkvop* at fdt? # Rockchip Visual Output Processor sunxide2bus* at fdt? pass 4 # Allwinner DE2 bus sunxidrm* at fdt? pass 5 # Allwinner Display Pipeline sunxifb* at sunxidrm? # Allwinner DRM framebuffer
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:39:46 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_drm.c Log Message: Remove debug output To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_drm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:31:50 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_vop.c Log Message: Fix a few swapped fields To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_vop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk_vop.c diff -u src/sys/arch/arm/rockchip/rk_vop.c:1.1 src/sys/arch/arm/rockchip/rk_vop.c:1.2 --- src/sys/arch/arm/rockchip/rk_vop.c:1.1 Sat Nov 9 23:30:14 2019 +++ src/sys/arch/arm/rockchip/rk_vop.c Thu Nov 14 20:31:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_vop.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */ +/* $NetBSD: rk_vop.c,v 1.2 2019/11/14 20:31:50 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rk_vop.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rk_vop.c,v 1.2 2019/11/14 20:31:50 jmcneill Exp $"); #include #include @@ -90,14 +90,14 @@ __KERNEL_RCSID(0, "$NetBSD: rk_vop.c,v 1 #define DSP_VACT_ST_POST __BITS(28,16) #define DSP_VACT_END_POST __BITS(12,0) #define VOP_DSP_HTOTAL_HS_END 0x0188 -#define DSP_HTOTAL __BITS(28,16) -#define DSP_HS_END __BITS(12,0) +#define DSP_HS_END __BITS(28,16) +#define DSP_HTOTAL __BITS(12,0) #define VOP_DSP_HACT_ST_END 0x018c #define DSP_HACT_ST __BITS(28,16) #define DSP_HACT_END __BITS(12,0) #define VOP_DSP_VTOTAL_VS_END 0x0190 -#define DSP_VTOTAL __BITS(28,16) -#define DSP_VS_END __BITS(12,0) +#define DSP_VS_END __BITS(28,16) +#define DSP_VTOTAL __BITS(12,0) #define VOP_DSP_VACT_ST_END 0x0194 #define DSP_VACT_ST __BITS(28,16) #define DSP_VACT_END __BITS(12,0) @@ -306,8 +306,8 @@ rk_vop_mode_set(struct drm_crtc *crtc, s __SHIFTIN(vactive - 1, WIN0_DSP_HEIGHT); WR4(sc, VOP_WIN0_DSP_INFO, val); - val = __SHIFTIN(hsync_len + hback_porch, WIN0_DSP_YST) | - __SHIFTIN(vsync_len + vback_porch, WIN0_DSP_XST); + val = __SHIFTIN(hsync_len + hback_porch, WIN0_DSP_XST) | + __SHIFTIN(vsync_len + vback_porch, WIN0_DSP_YST); WR4(sc, VOP_WIN0_DSP_ST, val); WR4(sc, VOP_WIN0_COLOR_KEY, 0);
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Thu Nov 14 20:31:50 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_vop.c Log Message: Fix a few swapped fields To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_vop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sun Nov 10 12:07:51 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_dwhdmi.c Log Message: Fix typo in phy config table To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk_dwhdmi.c diff -u src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.1 src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.2 --- src/sys/arch/arm/rockchip/rk_dwhdmi.c:1.1 Sat Nov 9 23:30:14 2019 +++ src/sys/arch/arm/rockchip/rk_dwhdmi.c Sun Nov 10 12:07:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_dwhdmi.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */ +/* $NetBSD: rk_dwhdmi.c,v 1.2 2019/11/10 12:07:50 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.2 2019/11/10 12:07:50 jmcneill Exp $"); #include #include @@ -64,7 +64,7 @@ static const struct dwhdmi_phy_config rk { 74250, 0x8009, 0x0004, 0x0272 }, { 148500, 0x802b, 0x0004, 0x028d }, { 297000, 0x8039, 0x0005, 0x028d }, - { 584000, 0x8039, 0x, 0x019d }, + { 594000, 0x8039, 0x, 0x019d }, { 0, 0x, 0x, 0x } };
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sun Nov 10 12:07:51 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk_dwhdmi.c Log Message: Fix typo in phy config table To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_dwhdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sun Nov 10 11:43:04 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_cru.c rk_cru.h rk_cru_composite.c Log Message: Force DCLK_VOP0/1 dividers to 1 and select closest match when setting PLL rates. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/rockchip/rk3399_cru.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/rockchip/rk_cru.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/rockchip/rk_cru_composite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/rk3399_cru.c diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.11 src/sys/arch/arm/rockchip/rk3399_cru.c:1.12 --- src/sys/arch/arm/rockchip/rk3399_cru.c:1.11 Sat Nov 9 23:29:48 2019 +++ src/sys/arch/arm/rockchip/rk3399_cru.c Sun Nov 10 11:43:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk3399_cru.c,v 1.11 2019/11/09 23:29:48 jmcneill Exp $ */ +/* $NetBSD: rk3399_cru.c,v 1.12 2019/11/10 11:43:04 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.11 2019/11/09 23:29:48 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.12 2019/11/10 11:43:04 jmcneill Exp $"); #include #include @@ -271,20 +271,21 @@ rk3399_cru_pll_set_rate(struct rk_cru_so struct rk_cru_pll *pll = >u.pll; const struct rk_cru_pll_rate *pll_rate = NULL; uint32_t val; - int retry; + int retry, best_diff; KASSERT(clk->type == RK_CRU_PLL); if (pll->rates == NULL || rate == 0) return EIO; - for (int i = 0; i < pll->nrates; i++) - if (pll->rates[i].rate == rate) { + best_diff = INT_MAX; + for (int i = 0; i < pll->nrates; i++) { + const int diff = (int)rate - (int)pll->rates[i].rate; + if (abs(diff) < best_diff) { pll_rate = >rates[i]; - break; + best_diff = abs(diff); } - if (pll_rate == NULL) - return EINVAL; + } val = __SHIFTIN(PLL_WORK_MODE_SLOW, PLL_WORK_MODE) | (PLL_WORK_MODE << 16); CRU_WRITE(sc, pll->con_base + PLL_CON3, val); @@ -869,7 +870,7 @@ static struct rk_cru_clk rk3399_cru_clks __BITS(7,0), /* div_mask */ CLKGATE_CON(10), /* gate_reg */ __BIT(12), /* gate_mask */ - 0), + RK_COMPOSITE_SET_RATE_PARENT), RK_GATE(RK3399_ACLK_VOP0, "aclk_vop0", "aclk_vop0_pre", CLKGATE_CON(28), 3), RK_GATE(RK3399_HCLK_VOP0, "hclk_vop0", "hclk_vop0_pre", CLKGATE_CON(28), 2), RK_MUX(RK3399_DCLK_VOP0, "dclk_vop0", mux_dclk_vop0_parents, CLKSEL_CON(49), __BIT(11)), @@ -894,7 +895,7 @@ static struct rk_cru_clk rk3399_cru_clks __BITS(7,0), /* div_mask */ CLKGATE_CON(10), /* gate_reg */ __BIT(13), /* gate_mask */ - 0), + RK_COMPOSITE_SET_RATE_PARENT), RK_GATE(RK3399_ACLK_VOP1, "aclk_vop1", "aclk_vop1_pre", CLKGATE_CON(28), 7), RK_GATE(RK3399_HCLK_VOP1, "hclk_vop1", "hclk_vop1_pre", CLKGATE_CON(28), 6), RK_MUX(RK3399_DCLK_VOP1, "dclk_vop1", mux_dclk_vop1_parents, CLKSEL_CON(50), __BIT(11)), @@ -944,12 +945,21 @@ static void rk3399_cru_init(struct rk_cru_softc *sc) { struct rk_cru_clk *clk; + uint32_t write_mask, write_val; /* * Force an update of BPLL to bring it out of slow mode. */ clk = rk_cru_clock_find(sc, "armclkb"); clk_set_rate(>base, clk_get_rate(>base)); + + /* + * Set DCLK_VOP0 and DCLK_VOP1 dividers to 1. + */ + write_mask = __BITS(7,0) << 16; + write_val = 0; + CRU_WRITE(sc, CLKSEL_CON(49), write_mask | write_val); + CRU_WRITE(sc, CLKSEL_CON(50), write_mask | write_val); } static int Index: src/sys/arch/arm/rockchip/rk_cru.h diff -u src/sys/arch/arm/rockchip/rk_cru.h:1.5 src/sys/arch/arm/rockchip/rk_cru.h:1.6 --- src/sys/arch/arm/rockchip/rk_cru.h:1.5 Sat Oct 19 12:55:21 2019 +++ src/sys/arch/arm/rockchip/rk_cru.h Sun Nov 10 11:43:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_cru.h,v 1.5 2019/10/19 12:55:21 tnn Exp $ */ +/* $NetBSD: rk_cru.h,v 1.6 2019/11/10 11:43:04 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -204,6 +204,7 @@ struct rk_cru_composite { u_int nparents; u_int flags; #define RK_COMPOSITE_ROUND_DOWN 0x01 +#define RK_COMPOSITE_SET_RATE_PARENT 0x02 }; int rk_cru_composite_enable(struct rk_cru_softc *, struct rk_cru_clk *, int); Index: src/sys/arch/arm/rockchip/rk_cru_composite.c diff -u src/sys/arch/arm/rockchip/rk_cru_composite.c:1.3 src/sys/arch/arm/rockchip/rk_cru_composite.c:1.4 --- src/sys/arch/arm/rockchip/rk_cru_composite.c:1.3 Tue Jun 19 01:24:17 2018 +++ src/sys/arch/arm/rockchip/rk_cru_composite.c Sun Nov 10 11:43:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_cru_composite.c,v 1.3 2018/06/19 01:24:17 jmcneill Exp $ */ +/* $NetBSD: rk_cru_composite.c,v 1.4 2019/11/10 11:43:04 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rk_cru_composite.c,v 1.3 2018/06/19 01:24:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD:
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sun Nov 10 11:43:04 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: rk3399_cru.c rk_cru.h rk_cru_composite.c Log Message: Force DCLK_VOP0/1 dividers to 1 and select closest match when setting PLL rates. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/rockchip/rk3399_cru.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/rockchip/rk_cru.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/rockchip/rk_cru_composite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sun Nov 10 10:36:01 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi_phy.c Log Message: Select the correct MPLL and PHY settings for the requested pixel clock To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/dw_hdmi_phy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jmcneill Date: Sun Nov 10 10:36:01 UTC 2019 Modified Files: src/sys/dev/ic: dw_hdmi_phy.c Log Message: Select the correct MPLL and PHY settings for the requested pixel clock To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/dw_hdmi_phy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dw_hdmi_phy.c diff -u src/sys/dev/ic/dw_hdmi_phy.c:1.1 src/sys/dev/ic/dw_hdmi_phy.c:1.2 --- src/sys/dev/ic/dw_hdmi_phy.c:1.1 Sat Nov 9 23:27:50 2019 +++ src/sys/dev/ic/dw_hdmi_phy.c Sun Nov 10 10:36:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_hdmi_phy.c,v 1.1 2019/11/09 23:27:50 jmcneill Exp $ */ +/* $NetBSD: dw_hdmi_phy.c,v 1.2 2019/11/10 10:36:01 jmcneill Exp $ */ /*- * Copyright (c) 2015 Oleksandr Tymoshenko @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dw_hdmi_phy.c,v 1.1 2019/11/09 23:27:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dw_hdmi_phy.c,v 1.2 2019/11/10 10:36:01 jmcneill Exp $"); #include @@ -300,7 +300,7 @@ dwhdmi_phy_configure(struct dwhdmi_softc * PLL/MPLL config */ for (mpll_conf = >sc_mpll_config[0]; mpll_conf->pixel_clock != 0; mpll_conf++) - if (mpll_conf->pixel_clock <= mode->clock) + if (mode->clock <= mpll_conf->pixel_clock) break; dwhdmi_phy_i2c_write(sc, mpll_conf->cpce, HDMI_PHY_I2C_CPCE_CTRL); @@ -308,7 +308,7 @@ dwhdmi_phy_configure(struct dwhdmi_softc dwhdmi_phy_i2c_write(sc, mpll_conf->curr, HDMI_PHY_I2C_CURRCTRL); for (phy_conf = >sc_phy_config[0]; phy_conf->pixel_clock != 0; phy_conf++) - if (phy_conf->pixel_clock <= mode->clock) + if (mode->clock <= phy_conf->pixel_clock) break; dwhdmi_phy_i2c_write(sc, 0x, HDMI_PHY_I2C_PLLPHBYCTRL);
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:30:55 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add (commented out) Rockchip display support To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:30:55 UTC 2019 Modified Files: src/sys/arch/evbarm/conf: GENERIC64 Log Message: Add (commented out) Rockchip display support To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/arch/evbarm/conf/GENERIC64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/GENERIC64 diff -u src/sys/arch/evbarm/conf/GENERIC64:1.109 src/sys/arch/evbarm/conf/GENERIC64:1.110 --- src/sys/arch/evbarm/conf/GENERIC64:1.109 Sat Oct 19 13:09:57 2019 +++ src/sys/arch/evbarm/conf/GENERIC64 Sat Nov 9 23:30:54 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC64,v 1.109 2019/10/19 13:09:57 tnn Exp $ +# $NetBSD: GENERIC64,v 1.110 2019/11/09 23:30:54 jmcneill Exp $ # # GENERIC ARM (aarch64) kernel # @@ -344,7 +344,7 @@ options I2C_MAX_ADDR=0xfff bsciic* at fdt? # Broadcom BCM283x Serial Control dwiic* at fdt? # Designware I2C dwiic* at acpi? -rkiic* at fdt? # Rockchip I2C +rkiic* at fdt? pass 4 # Rockchip I2C sunxirsb* at fdt? pass 4 # Allwinner RSB sunxitwi* at fdt? # Allwinner TWI tegrai2c* at fdt? pass 4 # NVIDIA Tegra I2C @@ -436,6 +436,9 @@ hdmicec* at hdmicecbus? anxedp* at iic? # Analogix eDP TX dispcon* at fdt? # Display connector devices dwhdmi* at fdt? # Designware HDMI TX +#rkdrm* at fdt? pass 5 # Rockchip DRM master +#rkfb* at rkdrm? # Rockchip DRM framebuffer +#rkvop* at fdt? # Rockchip Visual Output Processor sunxide2bus* at fdt? pass 4 # Allwinner DE2 bus sunxidrm* at fdt? pass 5 # Allwinner Display Pipeline sunxifb* at sunxidrm? # Allwinner DRM framebuffer
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:30:14 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: files.rockchip Added Files: src/sys/arch/arm/rockchip: rk_drm.c rk_drm.h rk_dwhdmi.c rk_fb.c rk_vop.c Log Message: WIP display driver for Rockchip RK3399 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/rockchip/files.rockchip cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_drm.c \ src/sys/arch/arm/rockchip/rk_drm.h src/sys/arch/arm/rockchip/rk_dwhdmi.c \ src/sys/arch/arm/rockchip/rk_fb.c src/sys/arch/arm/rockchip/rk_vop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/rockchip/files.rockchip diff -u src/sys/arch/arm/rockchip/files.rockchip:1.20 src/sys/arch/arm/rockchip/files.rockchip:1.21 --- src/sys/arch/arm/rockchip/files.rockchip:1.20 Mon Aug 5 15:22:59 2019 +++ src/sys/arch/arm/rockchip/files.rockchip Sat Nov 9 23:30:14 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.rockchip,v 1.20 2019/08/05 15:22:59 tnn Exp $ +# $NetBSD: files.rockchip,v 1.21 2019/11/09 23:30:14 jmcneill Exp $ # # Configuration info for Rockchip family SoCs # @@ -83,6 +83,26 @@ device rkpwm: pwm attach rkpwm at fdt with rk_pwm file arch/arm/rockchip/rk_pwm.c rk_pwm +# DRM master +define rkfbbus { } +device rkdrm: drmkms, ddc_read_edid, rkfbbus +attach rkdrm at fdt with rk_drm +file arch/arm/rockchip/rk_drm.c rk_drm + +# DRM framebuffer console +device rkfb: rkfbbus, drmfb, wsemuldisplaydev +attach rkfb at rkfbbus with rk_fb +file arch/arm/rockchip/rk_fb.c rk_fb + +# Visual Output Processor +device rkvop: drmkms +attach rkvop at fdt with rk_vop +file arch/arm/rockchip/rk_vop.c rk_vop + +# HDMI TX (Designware based) +attach dwhdmi at fdt with rk_dwhdmi +file arch/arm/rockchip/rk_dwhdmi.c rk_dwhdmi + # SOC parameters defflag opt_soc.h SOC_ROCKCHIP defflag opt_soc.h SOC_RK3328: SOC_ROCKCHIP Added files: Index: src/sys/arch/arm/rockchip/rk_drm.c diff -u /dev/null src/sys/arch/arm/rockchip/rk_drm.c:1.1 --- /dev/null Sat Nov 9 23:30:14 2019 +++ src/sys/arch/arm/rockchip/rk_drm.c Sat Nov 9 23:30:14 2019 @@ -0,0 +1,514 @@ +/* $NetBSD: rk_drm.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */ + +/*- + * Copyright (c) 2019 Jared D. McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: rk_drm.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#define RK_DRM_MAX_WIDTH 3840 +#define RK_DRM_MAX_HEIGHT 2160 + +static TAILQ_HEAD(, rk_drm_ports) rk_drm_ports = +TAILQ_HEAD_INITIALIZER(rk_drm_ports); + +static const char * const compatible[] = { + "rockchip,display-subsystem", + NULL +}; + +static const char * fb_compatible[] = { + "simple-framebuffer", + NULL +}; + +static int rk_drm_match(device_t, cfdata_t, void *); +static void rk_drm_attach(device_t, device_t, void *); + +static void rk_drm_init(device_t); +static vmem_t *rk_drm_alloc_cma_pool(struct drm_device *, size_t); + +static int rk_drm_set_busid(struct drm_device *, struct drm_master *); + +static uint32_t rk_drm_get_vblank_counter(struct drm_device *, unsigned int); +static int rk_drm_enable_vblank(struct drm_device *, unsigned int); +static void rk_drm_disable_vblank(struct drm_device *, unsigned int); + +static int rk_drm_load(struct drm_device *, unsigned long); +static int rk_drm_unload(struct drm_device *); + +static struct drm_driver rk_drm_driver = { + .driver_features
CVS commit: src/sys/arch/arm/rockchip
Module Name:src Committed By: jmcneill Date: Sat Nov 9 23:30:14 UTC 2019 Modified Files: src/sys/arch/arm/rockchip: files.rockchip Added Files: src/sys/arch/arm/rockchip: rk_drm.c rk_drm.h rk_dwhdmi.c rk_fb.c rk_vop.c Log Message: WIP display driver for Rockchip RK3399 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/rockchip/files.rockchip cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_drm.c \ src/sys/arch/arm/rockchip/rk_drm.h src/sys/arch/arm/rockchip/rk_dwhdmi.c \ src/sys/arch/arm/rockchip/rk_fb.c src/sys/arch/arm/rockchip/rk_vop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.