2 * Copyright 2013 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
20 #include <hv/drv_uart_intf.h>
25 * An API for manipulating UART interface.
30 * The Rshim allows access to the processor's UART interface.
33 /* A context object used to manage UART resources. */
36 /* File descriptor for calling up to the hypervisor. */
39 /* The VA at which our MMIO registers are mapped. */
42 } gxio_uart_context_t;
44 /* Request UART interrupts.
46 * Request that interrupts be delivered to a tile when the UART's
47 * Receive FIFO is written, or the Write FIFO is read.
49 * @param context Pointer to a properly initialized gxio_uart_context_t.
50 * @param bind_cpu_x X coordinate of CPU to which interrupt will be delivered.
51 * @param bind_cpu_y Y coordinate of CPU to which interrupt will be delivered.
52 * @param bind_interrupt IPI interrupt number.
53 * @param bind_event Sub-interrupt event bit number; a negative value can
54 * disable the interrupt.
55 * @return Zero if all of the requested UART events were successfully
56 * configured to interrupt.
58 extern int gxio_uart_cfg_interrupt(gxio_uart_context_t *context,
61 int bind_interrupt, int bind_event);
63 /* Initialize a UART context.
65 * A properly initialized context must be obtained before any of the other
66 * gxio_uart routines may be used.
68 * @param context Pointer to a gxio_uart_context_t, which will be initialized
69 * by this routine, if it succeeds.
70 * @param uart_index Index of the UART to use.
71 * @return Zero if the context was successfully initialized, else a
72 * GXIO_ERR_xxx error code.
74 extern int gxio_uart_init(gxio_uart_context_t *context, int uart_index);
76 /* Destroy a UART context.
78 * Once destroyed, a context may not be used with any gxio_uart routines
79 * other than gxio_uart_init(). After this routine returns, no further
80 * interrupts requested on this context will be delivered. The state and
81 * configuration of the pins which had been attached to this context are
82 * unchanged by this operation.
84 * @param context Pointer to a gxio_uart_context_t.
85 * @return Zero if the context was successfully destroyed, else a
86 * GXIO_ERR_xxx error code.
88 extern int gxio_uart_destroy(gxio_uart_context_t *context);
90 /* Write UART register.
91 * @param context Pointer to a gxio_uart_context_t.
92 * @param offset UART register offset.
93 * @param word Data will be wrote to UART reigister.
95 extern void gxio_uart_write(gxio_uart_context_t *context, uint64_t offset,
98 /* Read UART register.
99 * @param context Pointer to a gxio_uart_context_t.
100 * @param offset UART register offset.
101 * @return Data read from UART register.
103 extern uint64_t gxio_uart_read(gxio_uart_context_t *context, uint64_t offset);
105 #endif /* _GXIO_UART_H_ */