diff options
Diffstat (limited to 'core/include/drivers')
-rw-r--r-- | core/include/drivers/cdns_uart.h | 16 | ||||
-rw-r--r-- | core/include/drivers/hi16xx_uart.h | 16 | ||||
-rw-r--r-- | core/include/drivers/imx_uart.h | 15 | ||||
-rw-r--r-- | core/include/drivers/ns16550.h | 8 | ||||
-rw-r--r-- | core/include/drivers/pl011.h | 16 | ||||
-rw-r--r-- | core/include/drivers/scif.h | 11 | ||||
-rw-r--r-- | core/include/drivers/serial.h | 27 | ||||
-rw-r--r-- | core/include/drivers/serial8250_uart.h | 16 | ||||
-rw-r--r-- | core/include/drivers/sprd_uart.h | 11 | ||||
-rw-r--r-- | core/include/drivers/stih_asc.h | 43 | ||||
-rw-r--r-- | core/include/drivers/sunxi_uart.h | 14 |
11 files changed, 132 insertions, 61 deletions
diff --git a/core/include/drivers/cdns_uart.h b/core/include/drivers/cdns_uart.h index 6688fd3..d97ee37 100644 --- a/core/include/drivers/cdns_uart.h +++ b/core/include/drivers/cdns_uart.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, Xilinx Inc + * Copyright (c) 2017, Linaro Limited * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,15 +29,14 @@ #define CDNS_UART_H #include <types_ext.h> +#include <drivers/serial.h> -void cdns_uart_init(vaddr_t base, uint32_t uart_clk, uint32_t baud_rate); +struct cdns_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void cdns_uart_putc(int ch, vaddr_t base); - -void cdns_uart_flush(vaddr_t base); - -bool cdns_uart_have_rx_data(vaddr_t base); - -int cdns_uart_getchar(vaddr_t base); +void cdns_uart_init(struct cdns_uart_data *pd, paddr_t base, uint32_t uart_clk, + uint32_t baud_rate); #endif /* CDNS_UART_H */ diff --git a/core/include/drivers/hi16xx_uart.h b/core/include/drivers/hi16xx_uart.h index a7d4f0c..d3bd727 100644 --- a/core/include/drivers/hi16xx_uart.h +++ b/core/include/drivers/hi16xx_uart.h @@ -33,18 +33,16 @@ #define HI16XX_UART_H #include <types_ext.h> +#include <drivers/serial.h> #define HI16XX_UART_REG_SIZE 0xF8 -void hi16xx_uart_init(vaddr_t base, uint32_t uart_clk, uint32_t baud_rate); +struct hi16xx_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void hi16xx_uart_putc(int ch, vaddr_t base); - -void hi16xx_uart_flush(vaddr_t base); - -bool hi16xx_uart_have_rx_data(vaddr_t base); - -int hi16xx_uart_getchar(vaddr_t base); +void hi16xx_uart_init(struct hi16xx_uart_data *pd, paddr_t base, + uint32_t uart_clk, uint32_t baud_rate); #endif /* HI16XX_UART_H */ - diff --git a/core/include/drivers/imx_uart.h b/core/include/drivers/imx_uart.h index db63227..bbcc953 100644 --- a/core/include/drivers/imx_uart.h +++ b/core/include/drivers/imx_uart.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 Freescale Semiconductor, Inc. + * Copyright (c) 2017, Linaro Limited * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,15 +29,13 @@ #define IMX_UART_H #include <types_ext.h> +#include <drivers/serial.h> -void imx_uart_init(vaddr_t base); +struct imx_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void imx_uart_putc(const char ch, vaddr_t base); - -void imx_uart_flush_tx_fifo(vaddr_t base); - -bool imx_uart_have_rx_data(vaddr_t base); - -int imx_uart_getchar(vaddr_t base); +void imx_uart_init(struct imx_uart_data *pd, paddr_t base); #endif /* IMX_UART_H */ diff --git a/core/include/drivers/ns16550.h b/core/include/drivers/ns16550.h index e865871..b8d1049 100644 --- a/core/include/drivers/ns16550.h +++ b/core/include/drivers/ns16550.h @@ -28,9 +28,13 @@ #define NS16550_H #include <types_ext.h> +#include <drivers/serial.h> -void ns16550_putc(int ch, vaddr_t base); +struct ns16550_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void ns16550_flush(vaddr_t base); +void ns16550_init(struct ns16550_data *pd, paddr_t base); #endif /* NS16550_H */ diff --git a/core/include/drivers/pl011.h b/core/include/drivers/pl011.h index b83f2b2..872b7d1 100644 --- a/core/include/drivers/pl011.h +++ b/core/include/drivers/pl011.h @@ -28,18 +28,16 @@ #define PL011_H #include <types_ext.h> +#include <drivers/serial.h> #define PL011_REG_SIZE 0x1000 -void pl011_init(vaddr_t base, uint32_t uart_clk, uint32_t baud_rate); +struct pl011_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void pl011_putc(int ch, vaddr_t base); - -void pl011_flush(vaddr_t base); - -bool pl011_have_rx_data(vaddr_t base); - -int pl011_getchar(vaddr_t base); +void pl011_init(struct pl011_data *pd, paddr_t base, uint32_t uart_clk, + uint32_t baud_rate); #endif /* PL011_H */ - diff --git a/core/include/drivers/scif.h b/core/include/drivers/scif.h index d9d1055..f621e6c 100644 --- a/core/include/drivers/scif.h +++ b/core/include/drivers/scif.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, GlobalLogic + * Copyright (c) 2017, Linaro Limited * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,13 +29,15 @@ #define SCIF_H #include <types_ext.h> +#include <drivers/serial.h> #define SCIF_REG_SIZE 0x1000 -void scif_uart_flush(vaddr_t base); +struct scif_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void scif_uart_init(vaddr_t base); - -void scif_uart_putc(int ch, vaddr_t base); +void scif_uart_init(struct scif_uart_data *pd, paddr_t base); #endif /* SCIF */ diff --git a/core/include/drivers/serial.h b/core/include/drivers/serial.h index b8f00df..c1e9ebe 100644 --- a/core/include/drivers/serial.h +++ b/core/include/drivers/serial.h @@ -27,6 +27,12 @@ #ifndef __DRIVERS_SERIAL_H #define __DRIVERS_SERIAL_H +#include <assert.h> +#include <stdbool.h> +#include <types_ext.h> +#include <mm/core_memprot.h> +#include <mm/core_mmu.h> + struct serial_chip { const struct serial_ops *ops; }; @@ -38,4 +44,25 @@ struct serial_ops { int (*getchar)(struct serial_chip *chip); }; +struct io_pa_va { + paddr_t pa; + vaddr_t va; +}; + +/* + * Helper function to return a physical or virtual address for a device, + * depending on whether the MMU is enabled or not + */ +static inline vaddr_t io_pa_or_va(struct io_pa_va *p) +{ + assert(p->pa); + if (cpu_mmu_enabled()) { + if (!p->va) + p->va = (vaddr_t)phys_to_virt_io(p->pa); + assert(p->va); + return p->va; + } + return p->pa; +} + #endif /*__DRIVERS_SERIASERIAL_H*/ diff --git a/core/include/drivers/serial8250_uart.h b/core/include/drivers/serial8250_uart.h index 5b8985d..d8b5051 100644 --- a/core/include/drivers/serial8250_uart.h +++ b/core/include/drivers/serial8250_uart.h @@ -28,19 +28,17 @@ #define SERIAL8250_UART_H #include <types_ext.h> +#include <drivers/serial.h> #define SERIAL8250_UART_REG_SIZE 0x20 -void serial8250_uart_init(vaddr_t base, - uint32_t uart_clk, uint32_t baud_rate); +struct serial8250_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void serial8250_uart_putc(int ch, vaddr_t base); - -void serial8250_uart_flush_tx_fifo(vaddr_t base); - -bool serial8250_uart_have_rx_data(vaddr_t base); - -int serial8250_uart_getchar(vaddr_t base); +void serial8250_uart_init(struct serial8250_uart_data *pd, paddr_t base, + uint32_t uart_clk, uint32_t baud_rate); #endif /* SERIAL8250_UART_H */ diff --git a/core/include/drivers/sprd_uart.h b/core/include/drivers/sprd_uart.h index c70bfb9..f89f914 100644 --- a/core/include/drivers/sprd_uart.h +++ b/core/include/drivers/sprd_uart.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, Spreadtrum Communications Inc. + * Copyright (c) 2017, Linaro Limited * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,12 +29,14 @@ #define SPRD_UART_H #include <types_ext.h> +#include <drivers/serial.h> -void sprd_uart_flush(vaddr_t base); +struct sprd_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void sprd_uart_putc(vaddr_t base, unsigned char ch); - -unsigned char sprd_uart_getc(vaddr_t base); +void sprd_uart_init(struct sprd_uart_data *pd, paddr_t base); #endif /* SPRD_UART_H */ diff --git a/core/include/drivers/stih_asc.h b/core/include/drivers/stih_asc.h new file mode 100644 index 0000000..a7cbee2 --- /dev/null +++ b/core/include/drivers/stih_asc.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef STIH_ASC_H +#define STIH_ASC_H + +#include <drivers/serial.h> +#include <types_ext.h> + +#define STIH_ASC_REG_SIZE 0x1000 + +struct stih_asc_pd { + struct io_pa_va base; + struct serial_chip chip; +}; + +void stih_asc_init(struct stih_asc_pd *pb, vaddr_t base); + +#endif /* STIH_ASC_H */ + diff --git a/core/include/drivers/sunxi_uart.h b/core/include/drivers/sunxi_uart.h index 2b33641..a5a2b8c 100644 --- a/core/include/drivers/sunxi_uart.h +++ b/core/include/drivers/sunxi_uart.h @@ -28,16 +28,14 @@ #define SUNXI_UART_H #include <types_ext.h> +#include <drivers/serial.h> -void sunxi_uart_init(vaddr_t base); +struct sunxi_uart_data { + struct io_pa_va base; + struct serial_chip chip; +}; -void sunxi_uart_putc(int ch, vaddr_t base); - -void sunxi_uart_flush(vaddr_t base); - -bool sunxi_uart_have_rx_data(vaddr_t base); - -int sunxi_uart_getchar(vaddr_t base); +void sunxi_uart_init(struct sunxi_uart_data *pd, paddr_t base); #endif /*SUNXI_UART_H*/ |