From owner-svn-src-head@freebsd.org Tue May 1 13:57:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F9E9FAC722; Tue, 1 May 2018 13:57:09 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E8D126C62B; Tue, 1 May 2018 13:57:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CAEBA22EA0; Tue, 1 May 2018 13:57:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w41Dv8Pv035115; Tue, 1 May 2018 13:57:08 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w41Dv8f5035113; Tue, 1 May 2018 13:57:08 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201805011357.w41Dv8f5035113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 1 May 2018 13:57:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333138 - in head/sys: arm/allwinner dev/uart X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in head/sys: arm/allwinner dev/uart X-SVN-Commit-Revision: 333138 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2018 13:57:09 -0000 Author: manu Date: Tue May 1 13:57:08 2018 New Revision: 333138 URL: https://svnweb.freebsd.org/changeset/base/333138 Log: uart_snps: Add early printf support Move the allwinner early printf support to the snps driver as it should work with all implementation. While here add instruction for enabling it on 64bits SoCs. Modified: head/sys/arm/allwinner/aw_machdep.c head/sys/dev/uart/uart_dev_snps.c Modified: head/sys/arm/allwinner/aw_machdep.c ============================================================================== --- head/sys/arm/allwinner/aw_machdep.c Tue May 1 12:58:01 2018 (r333137) +++ head/sys/arm/allwinner/aw_machdep.c Tue May 1 13:57:08 2018 (r333138) @@ -164,30 +164,6 @@ allwinner_cpu_reset(platform_t plat) while (1); } -/* - * To use early printf on Allwinner SoC, add to kernel config - * options SOCDEV_PA=0x01C00000 - * options SOCDEV_VA=0x10000000 - * options EARLY_PRINTF - * And remove the if 0 -*/ -#if 0 -#ifdef EARLY_PRINTF -static void -allwinner_early_putc(int c) -{ - volatile uint32_t * UART_STAT_REG = (uint32_t *)0x1002807C; - volatile uint32_t * UART_TX_REG = (uint32_t *)0x10028000; - const uint32_t UART_TXRDY = (1 << 2); - - while ((*UART_STAT_REG & UART_TXRDY) == 0) - continue; - *UART_TX_REG = c; -} -early_putc_t *early_putc = allwinner_early_putc; -#endif /* EARLY_PRINTF */ -#endif - #if defined(SOC_ALLWINNER_A10) static platform_method_t a10_methods[] = { PLATFORMMETHOD(platform_attach, a10_attach), Modified: head/sys/dev/uart/uart_dev_snps.c ============================================================================== --- head/sys/dev/uart/uart_dev_snps.c Tue May 1 12:58:01 2018 (r333137) +++ head/sys/dev/uart/uart_dev_snps.c Tue May 1 13:57:08 2018 (r333138) @@ -61,6 +61,44 @@ struct snps_softc { #endif }; +/* + * To use early printf on 64 bits Allwinner SoC, add to kernel config + * options SOCDEV_PA=0x0 + * options SOCDEV_VA=0x40000000 + * options EARLY_PRINTF + * + * To use early printf on 32 bits Allwinner SoC, add to kernel config + * options SOCDEV_PA=0x01C00000 + * options SOCDEV_VA=0x10000000 + * options EARLY_PRINTF + * + * remove the if 0 +*/ +#if 0 +#ifdef EARLY_PRINTF +static void +uart_snps_early_putc(int c) +{ + volatile uint32_t *stat; + volatile uint32_t *tx; + +#ifdef ALLWINNER_64 + stat = (uint32_t *) (SOCDEV_VA + 0x1C2807C); + tx = (uint32_t *) (SOCDEV_VA + 0x1C28000); +#endif +#ifdef ALLWINNER_32 + stat = (uint32_t *) (SOCDEV_VA + 0x2807C); + tx = (uint32_t *) (SOCDEV_VA + 0x28000); +#endif + + while ((*stat & (1 << 2)) == 0) + continue; + *tx = c; +} +early_putc_t *early_putc = uart_snps_early_putc; +#endif /* EARLY_PRINTF */ +#endif + static int snps_uart_attach(struct uart_softc *uart_sc) {