| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Jiri Svoboda
|
|---|
| 3 | * Copyright (c) 2013 Jakub Klama
|
|---|
| 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:
|
|---|
| 9 | *
|
|---|
| 10 | * - Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | * derived from this software without specific prior written permission.
|
|---|
| 17 | *
|
|---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | /** @addtogroup genarch
|
|---|
| 31 | * @{
|
|---|
| 32 | */
|
|---|
| 33 | /**
|
|---|
| 34 | * @file
|
|---|
| 35 | * @brief Gaisler GRLIB UART IP-Core driver.
|
|---|
| 36 | */
|
|---|
| 37 |
|
|---|
| 38 | #ifndef KERN_GRLIB_UART_H_
|
|---|
| 39 | #define KERN_GRLIB_UART_H_
|
|---|
| 40 |
|
|---|
| 41 | #include <ddi/ddi.h>
|
|---|
| 42 | #include <ddi/irq.h>
|
|---|
| 43 | #include <console/chardev.h>
|
|---|
| 44 | #include <typedefs.h>
|
|---|
| 45 |
|
|---|
| 46 | typedef struct {
|
|---|
| 47 | unsigned int rcnt: 6;
|
|---|
| 48 | unsigned int tcnt: 6;
|
|---|
| 49 | unsigned int : 9;
|
|---|
| 50 | unsigned int rf: 1;
|
|---|
| 51 | unsigned int tf: 1;
|
|---|
| 52 | unsigned int rh: 1;
|
|---|
| 53 | unsigned int th: 1;
|
|---|
| 54 | unsigned int fe: 1;
|
|---|
| 55 | unsigned int pe: 1;
|
|---|
| 56 | unsigned int ov: 1;
|
|---|
| 57 | unsigned int br: 1;
|
|---|
| 58 | unsigned int te: 1;
|
|---|
| 59 | unsigned int ts: 1;
|
|---|
| 60 | unsigned int dr: 1;
|
|---|
| 61 | } grlib_uart_status_t;
|
|---|
| 62 |
|
|---|
| 63 | typedef struct {
|
|---|
| 64 | unsigned int fa: 1;
|
|---|
| 65 | unsigned int : 16;
|
|---|
| 66 | unsigned int si: 1;
|
|---|
| 67 | unsigned int di: 1;
|
|---|
| 68 | unsigned int bi: 1;
|
|---|
| 69 | unsigned int db: 1;
|
|---|
| 70 | unsigned int rf: 1;
|
|---|
| 71 | unsigned int tf: 1;
|
|---|
| 72 | unsigned int ec: 1;
|
|---|
| 73 | unsigned int lb: 1;
|
|---|
| 74 | unsigned int fl: 1;
|
|---|
| 75 | unsigned int pe: 1;
|
|---|
| 76 | unsigned int ps: 1;
|
|---|
| 77 | unsigned int ti: 1;
|
|---|
| 78 | unsigned int ri: 1;
|
|---|
| 79 | unsigned int te: 1;
|
|---|
| 80 | unsigned int re: 1;
|
|---|
| 81 | } grlib_uart_control_t;
|
|---|
| 82 |
|
|---|
| 83 | /** GRLIB UART registers */
|
|---|
| 84 | typedef struct {
|
|---|
| 85 | uint32_t data;
|
|---|
| 86 | uint32_t status;
|
|---|
| 87 | uint32_t control;
|
|---|
| 88 | uint32_t scaler;
|
|---|
| 89 | uint32_t debug;
|
|---|
| 90 | } grlib_uart_io_t;
|
|---|
| 91 |
|
|---|
| 92 | typedef struct {
|
|---|
| 93 | grlib_uart_io_t *io;
|
|---|
| 94 | indev_t *indev;
|
|---|
| 95 | irq_t irq;
|
|---|
| 96 | parea_t parea;
|
|---|
| 97 | } grlib_uart_t;
|
|---|
| 98 |
|
|---|
| 99 | extern outdev_t *grlib_uart_init(uintptr_t, inr_t);
|
|---|
| 100 | extern void grlib_uart_input_wire(grlib_uart_t *,
|
|---|
| 101 | indev_t *);
|
|---|
| 102 |
|
|---|
| 103 | #endif
|
|---|
| 104 |
|
|---|
| 105 | /** @}
|
|---|
| 106 | */
|
|---|