uart_dev_at91usart.c (164969) | uart_dev_at91usart.c (166100) |
---|---|
1/*- 2 * Copyright (c) 2005 M. Warner Losh 3 * Copyright (c) 2005 Olivier Houchard 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005 M. Warner Losh 3 * Copyright (c) 2005 Olivier Houchard 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/arm/at91/uart_dev_at91usart.c 164969 2006-12-07 00:24:15Z cognet $"); | 29__FBSDID("$FreeBSD: head/sys/arm/at91/uart_dev_at91usart.c 166100 2007-01-18 22:01:19Z marius $"); |
30 31#include "opt_comconsole.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/conf.h> 37#include <sys/cons.h> --- 51 unchanged lines hidden (view full) --- 89 90/* 91 * Low-level UART interface. 92 */ 93static int at91_usart_probe(struct uart_bas *bas); 94static void at91_usart_init(struct uart_bas *bas, int, int, int, int); 95static void at91_usart_term(struct uart_bas *bas); 96static void at91_usart_putc(struct uart_bas *bas, int); | 30 31#include "opt_comconsole.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/conf.h> 37#include <sys/cons.h> --- 51 unchanged lines hidden (view full) --- 89 90/* 91 * Low-level UART interface. 92 */ 93static int at91_usart_probe(struct uart_bas *bas); 94static void at91_usart_init(struct uart_bas *bas, int, int, int, int); 95static void at91_usart_term(struct uart_bas *bas); 96static void at91_usart_putc(struct uart_bas *bas, int); |
97static int at91_usart_poll(struct uart_bas *bas); | 97static int at91_usart_rxready(struct uart_bas *bas); |
98static int at91_usart_getc(struct uart_bas *bas, struct mtx *mtx); 99 100extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 101 102static int 103at91_usart_param(struct uart_bas *bas, int baudrate, int databits, 104 int stopbits, int parity) 105{ --- 90 unchanged lines hidden (view full) --- 196 return (0); 197} 198 199struct uart_ops at91_usart_ops = { 200 .probe = at91_usart_probe, 201 .init = at91_usart_init, 202 .term = at91_usart_term, 203 .putc = at91_usart_putc, | 98static int at91_usart_getc(struct uart_bas *bas, struct mtx *mtx); 99 100extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 101 102static int 103at91_usart_param(struct uart_bas *bas, int baudrate, int databits, 104 int stopbits, int parity) 105{ --- 90 unchanged lines hidden (view full) --- 196 return (0); 197} 198 199struct uart_ops at91_usart_ops = { 200 .probe = at91_usart_probe, 201 .init = at91_usart_init, 202 .term = at91_usart_term, 203 .putc = at91_usart_putc, |
204 .poll = at91_usart_poll, | 204 .rxready = at91_usart_rxready, |
205 .getc = at91_usart_getc, 206}; 207 208static int 209at91_usart_probe(struct uart_bas *bas) 210{ 211 /* We know that this is always here */ 212 return (0); --- 34 unchanged lines hidden (view full) --- 247{ 248 249 while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) 250 continue; 251 WR4(bas, USART_THR, c); 252} 253 254/* | 205 .getc = at91_usart_getc, 206}; 207 208static int 209at91_usart_probe(struct uart_bas *bas) 210{ 211 /* We know that this is always here */ 212 return (0); --- 34 unchanged lines hidden (view full) --- 247{ 248 249 while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) 250 continue; 251 WR4(bas, USART_THR, c); 252} 253 254/* |
255 * Poll for a character available | 255 * Check for a character available. |
256 */ 257static int | 256 */ 257static int |
258at91_usart_poll(struct uart_bas *bas) | 258at91_usart_rxready(struct uart_bas *bas) |
259{ 260 | 259{ 260 |
261 if (!(RD4(bas, USART_CSR) & USART_CSR_RXRDY)) 262 return (-1); 263 return (RD4(bas, USART_RHR) & 0xff); | 261 return ((RD4(bas, USART_CSR) & USART_CSR_RXRDY) != 0 ? 1 : 0); |
264} 265 266/* 267 * Block waiting for a character. 268 */ 269static int 270at91_usart_getc(struct uart_bas *bas, struct mtx *mtx) 271{ --- 402 unchanged lines hidden --- | 262} 263 264/* 265 * Block waiting for a character. 266 */ 267static int 268at91_usart_getc(struct uart_bas *bas, struct mtx *mtx) 269{ --- 402 unchanged lines hidden --- |