Lines Matching +full:bcm2835 +full:- +full:aux +full:- +full:uart

1 /*-
32 * The mini Uart has the following features:
33 * - 7 or 8 bit operation.
34 * - 1 start and 1 stop bit.
35 * - No parities.
36 * - Break generation.
37 * - 8 symbols deep FIFOs for receive and transmit.
38 * - SW controlled RTS, SW readable CTS.
39 * - Auto flow control with programmable FIFO level.
40 * - 16550 like registers.
41 * - Baudrate derived from system clock.
42 * This is a mini UART and it does NOT have the following capabilities:
43 * - Break detection
44 * - Framing errors detection.
45 * - Parity bit
46 * - Receive Time-out interrupt
47 * - DCD, DSR, DTR or RI signals.
48 * The implemented UART is not a 16650 compatible UART However as far
50 * like a 16550 UART. All 16550 register bits which are not supported can
52 * for simple UART receive/transmit operations are available.
67 #include <dev/uart/uart.h>
68 #include <dev/uart/uart_cpu.h>
70 #include <dev/uart/uart_cpu_fdt.h>
73 #include <dev/uart/uart_bus.h>
76 /* BCM2835 Micro UART registers and masks*/
124 * FIXME: actual register size is SoC-dependent, we need to handle it
127 bus_space_read_4((bas)->bst, (bas)->bsh, uart_regofs(bas, reg))
129 bus_space_write_4((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value)
132 * Low-level UART interface.
159 * the micro-uart is used
172 * UART is disabled and not configured in uart_mu_param()
177 /* As I know UART is disabled I can setup the line */ in uart_mu_param()
191 /* See 2.2.1 BCM2835-ARM-Peripherals baudrate */ in uart_mu_param()
200 /* re-enable UART */ in uart_mu_param()
248 * High-level UART interface.
287 "aux-uart",
298 {"brcm,bcm2835-aux-uart" , (uintptr_t)&uart_mu_class},
311 bas = &sc->sc_bas; in uart_mu_bus_attach()
315 psc->aux_ier = (IER_RXENABLE|IER_TXENABLE|IER_REQUIRED); in uart_mu_bus_attach()
316 __uart_setreg(bas, AUX_MU_IER_REG, psc->aux_ier); in uart_mu_bus_attach()
317 sc->sc_txbusy = 0; in uart_mu_bus_attach()
349 uart_lock(sc->sc_hwmtx); in uart_mu_bus_ioctl()
360 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_ioctl()
374 bas = &sc->sc_bas; in uart_mu_bus_ipend()
376 uart_lock(sc->sc_hwmtx); in uart_mu_bus_ipend()
388 if (sc->sc_txbusy) in uart_mu_bus_ipend()
393 psc->aux_ier & ~IER_TXENABLE); in uart_mu_bus_ipend()
397 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_ipend()
407 uart_lock(sc->sc_hwmtx); in uart_mu_bus_param()
408 uart_mu_param(&sc->sc_bas, baudrate, databits, stopbits, parity); in uart_mu_bus_param()
409 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_param()
419 sc->sc_rxfifosz = 8; in uart_mu_bus_probe()
420 sc->sc_txfifosz = 8; in uart_mu_bus_probe()
421 device_set_desc(sc->sc_dev, "BCM2835 Mini-UART"); in uart_mu_bus_probe()
433 bas = &sc->sc_bas; in uart_mu_bus_receive()
434 uart_lock(sc->sc_hwmtx); in uart_mu_bus_receive()
441 sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN; in uart_mu_bus_receive()
447 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_receive()
467 bas = &sc->sc_bas; in uart_mu_bus_transmit()
468 uart_lock(sc->sc_hwmtx); in uart_mu_bus_transmit()
470 for (i = 0; i < sc->sc_txdatasz; i++) { in uart_mu_bus_transmit()
471 __uart_setreg(bas, AUX_MU_IO_REG, sc->sc_txbuf[i] & 0xff); in uart_mu_bus_transmit()
476 sc->sc_txbusy = 1; in uart_mu_bus_transmit()
477 __uart_setreg(bas, AUX_MU_IER_REG, psc->aux_ier); in uart_mu_bus_transmit()
479 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_transmit()
491 bas = &sc->sc_bas; in uart_mu_bus_grab()
494 uart_lock(sc->sc_hwmtx); in uart_mu_bus_grab()
495 __uart_setreg(bas, AUX_MU_IER_REG, psc->aux_ier &~IER_MASK_ALL); in uart_mu_bus_grab()
496 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_grab()
506 bas = &sc->sc_bas; in uart_mu_bus_ungrab()
509 uart_lock(sc->sc_hwmtx); in uart_mu_bus_ungrab()
511 __uart_setreg(bas, AUX_MU_IER_REG, psc->aux_ier); in uart_mu_bus_ungrab()
512 uart_unlock(sc->sc_hwmtx); in uart_mu_bus_ungrab()