Deleted Added
full compact
uart_dev_sab82532.c (157300) uart_dev_sab82532.c (157380)
1/*-
2 * Copyright (c) 2003 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_dev_sab82532.c 157300 2006-03-30 18:37:03Z marcel $");
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_dev_sab82532.c 157380 2006-04-01 19:04:54Z marcel $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <machine/bus.h>
35
36#include <dev/uart/uart.h>

--- 132 unchanged lines hidden (view full) ---

169/*
170 * Low-level UART interface.
171 */
172static int sab82532_probe(struct uart_bas *bas);
173static void sab82532_init(struct uart_bas *bas, int, int, int, int);
174static void sab82532_term(struct uart_bas *bas);
175static void sab82532_putc(struct uart_bas *bas, int);
176static int sab82532_poll(struct uart_bas *bas);
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <machine/bus.h>
35
36#include <dev/uart/uart.h>

--- 132 unchanged lines hidden (view full) ---

169/*
170 * Low-level UART interface.
171 */
172static int sab82532_probe(struct uart_bas *bas);
173static void sab82532_init(struct uart_bas *bas, int, int, int, int);
174static void sab82532_term(struct uart_bas *bas);
175static void sab82532_putc(struct uart_bas *bas, int);
176static int sab82532_poll(struct uart_bas *bas);
177static int sab82532_getc(struct uart_bas *bas);
177static int sab82532_getc(struct uart_bas *bas, struct mtx *);
178
179struct uart_ops uart_sab82532_ops = {
180 .probe = sab82532_probe,
181 .init = sab82532_init,
182 .term = sab82532_term,
183 .putc = sab82532_putc,
184 .poll = sab82532_poll,
185 .getc = sab82532_getc,

--- 116 unchanged lines hidden (view full) ---

302 DELAY(delay);
303}
304
305static int
306sab82532_poll(struct uart_bas *bas)
307{
308
309 if (uart_getreg(bas, SAB_STAR) & SAB_STAR_RFNE)
178
179struct uart_ops uart_sab82532_ops = {
180 .probe = sab82532_probe,
181 .init = sab82532_init,
182 .term = sab82532_term,
183 .putc = sab82532_putc,
184 .poll = sab82532_poll,
185 .getc = sab82532_getc,

--- 116 unchanged lines hidden (view full) ---

302 DELAY(delay);
303}
304
305static int
306sab82532_poll(struct uart_bas *bas)
307{
308
309 if (uart_getreg(bas, SAB_STAR) & SAB_STAR_RFNE)
310 return (sab82532_getc(bas));
310 return (sab82532_getc(bas, NULL));
311 return (-1);
312}
313
314static int
311 return (-1);
312}
313
314static int
315sab82532_getc(struct uart_bas *bas)
315sab82532_getc(struct uart_bas *bas, struct mtx *hwmtx)
316{
317 int c, delay;
318
316{
317 int c, delay;
318
319 uart_lock(hwmtx);
320
319 /* 1/10th the time to transmit 1 character (estimate). */
320 delay = sab82532_delay(bas);
321
321 /* 1/10th the time to transmit 1 character (estimate). */
322 delay = sab82532_delay(bas);
323
322 while (!(uart_getreg(bas, SAB_STAR) & SAB_STAR_RFNE))
324 while (!(uart_getreg(bas, SAB_STAR) & SAB_STAR_RFNE)) {
325 uart_unlock(hwmtx);
323 DELAY(delay);
326 DELAY(delay);
327 uart_lock(hwmtx);
328 }
324
325 while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC)
326 ;
327 uart_setreg(bas, SAB_CMDR, SAB_CMDR_RFRD);
328 uart_barrier(bas);
329
330 while (!(uart_getreg(bas, SAB_ISR0) & SAB_ISR0_TCD))
331 DELAY(delay);
332
333 c = uart_getreg(bas, SAB_RFIFO);
334 uart_barrier(bas);
335
336 /* Blow away everything left in the FIFO... */
337 while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC)
338 ;
339 uart_setreg(bas, SAB_CMDR, SAB_CMDR_RMC);
340 uart_barrier(bas);
329
330 while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC)
331 ;
332 uart_setreg(bas, SAB_CMDR, SAB_CMDR_RFRD);
333 uart_barrier(bas);
334
335 while (!(uart_getreg(bas, SAB_ISR0) & SAB_ISR0_TCD))
336 DELAY(delay);
337
338 c = uart_getreg(bas, SAB_RFIFO);
339 uart_barrier(bas);
340
341 /* Blow away everything left in the FIFO... */
342 while (uart_getreg(bas, SAB_STAR) & SAB_STAR_CEC)
343 ;
344 uart_setreg(bas, SAB_CMDR, SAB_CMDR_RMC);
345 uart_barrier(bas);
346
347 uart_unlock(hwmtx);
348
341 return (c);
342}
343
344/*
345 * High-level UART interface.
346 */
347struct sab82532_softc {
348 struct uart_softc base;

--- 371 unchanged lines hidden ---
349 return (c);
350}
351
352/*
353 * High-level UART interface.
354 */
355struct sab82532_softc {
356 struct uart_softc base;

--- 371 unchanged lines hidden ---