From owner-svn-src-head@freebsd.org Sat Mar 4 22:00:07 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DDB2CF912A; Sat, 4 Mar 2017 22:00:07 +0000 (UTC) (envelope-from ian@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 mx1.freebsd.org (Postfix) with ESMTPS id C845519A7; Sat, 4 Mar 2017 22:00:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24M05Re092125; Sat, 4 Mar 2017 22:00:05 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24M05qH092124; Sat, 4 Mar 2017 22:00:05 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201703042200.v24M05qH092124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 4 Mar 2017 22:00:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314682 - head/sys/dev/uart X-SVN-Group: head 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.23 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: Sat, 04 Mar 2017 22:00:07 -0000 Author: ian Date: Sat Mar 4 22:00:05 2017 New Revision: 314682 URL: https://svnweb.freebsd.org/changeset/base/314682 Log: Reconfigure the fifo watermark levels on the pl011 uart to interrupt when the fifos are 3/4 full (rc) or empty (tx). Modified: head/sys/dev/uart/uart_dev_pl011.c Modified: head/sys/dev/uart/uart_dev_pl011.c ============================================================================== --- head/sys/dev/uart/uart_dev_pl011.c Sat Mar 4 21:47:43 2017 (r314681) +++ head/sys/dev/uart/uart_dev_pl011.c Sat Mar 4 22:00:05 2017 (r314682) @@ -86,6 +86,16 @@ __FBSDID("$FreeBSD$"); #define CR_TXE (1 << 8) /* Transmit enable */ #define CR_UARTEN (1 << 0) /* UART enable */ +#define UART_IFLS 0x0d /* FIFO level select register */ +#define IFLS_RX_SHIFT 3 /* RX level in bits [5:3] */ +#define IFLS_TX_SHIFT 0 /* TX level in bits [2:0] */ +#define IFLS_MASK 0x07 /* RX/TX level is 3 bits */ +#define IFLS_LVL_1_8th 0 /* Interrupt at 1/8 full */ +#define IFLS_LVL_2_8th 1 /* Interrupt at 1/4 full */ +#define IFLS_LVL_4_8th 2 /* Interrupt at 1/2 full */ +#define IFLS_LVL_6_8th 3 /* Interrupt at 3/4 full */ +#define IFLS_LVL_7_8th 4 /* Interrupt at 7/8 full */ + #define UART_IMSC 0x0e /* Interrupt mask set/clear register */ #define IMSC_MASK_ALL 0x7ff /* Mask all interrupts */ @@ -102,6 +112,18 @@ __FBSDID("$FreeBSD$"); #define UART_ICR 0x11 /* Interrupt clear register */ /* + * The hardware FIFOs are 16 bytes each. We configure them to interrupt when + * 3/4 full/empty. For RX we set the size to the full hardware capacity so that + * the uart core allocates enough buffer space to hold a complete fifo full of + * incoming data. For TX, we need to limit the size to the capacity we know + * will be available when the interrupt occurs; uart_core will feed exactly that + * many bytes to uart_pl011_bus_transmit() which must consume them all. + */ +#define FIFO_RX_SIZE 16 +#define FIFO_TX_SIZE 12 +#define FIFO_IFLS_BITS ((IFLS_LVL_6_8th << IFLS_RX_SHIFT) | (IFLS_LVL_2_8th)) + +/* * FIXME: actual register size is SoC-dependent, we need to handle it */ #define __uart_getreg(bas, reg) \ @@ -187,6 +209,9 @@ uart_pl011_param(struct uart_bas *bas, i __uart_setreg(bas, UART_LCR_H, (__uart_getreg(bas, UART_LCR_H) & ~0xff) | line); + /* Set rx and tx fifo levels. */ + __uart_setreg(bas, UART_IFLS, FIFO_IFLS_BITS); + __uart_setreg(bas, UART_CR, ctrl); } @@ -418,8 +443,8 @@ uart_pl011_bus_probe(struct uart_softc * device_set_desc(sc->sc_dev, "PrimeCell UART (PL011)"); - sc->sc_rxfifosz = 16; - sc->sc_txfifosz = 8; + sc->sc_rxfifosz = FIFO_RX_SIZE; + sc->sc_txfifosz = FIFO_TX_SIZE; return (0); }