2 * Copyright (C) 2011, 2012 glevand <geoffrey.levand@mail.ru>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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.
29 #ifndef _PS3VUART_PORT_H
30 #define _PS3VUART_PORT_H
32 enum ps3vuart_port_param
{
33 PS3VUART_PORT_PARAM_TX_TRIG
= 0, /* rw */
34 PS3VUART_PORT_PARAM_RX_TRIG
= 1, /* rw */
35 PS3VUART_PORT_PARAM_INTR_MASK
= 2, /* rw */
36 PS3VUART_PORT_PARAM_RX_BUFSIZE
= 3, /* ro */
37 PS3VUART_PORT_PARAM_RX_BYTES
= 4, /* ro */
38 PS3VUART_PORT_PARAM_TX_BUFSIZE
= 5, /* ro */
39 PS3VUART_PORT_PARAM_TX_BYTES
= 6, /* ro */
40 PS3VUART_PORT_PARAM_INTR_STAT
= 7, /* ro */
43 enum ps3vuart_port_intr
{
44 PS3VUART_PORT_INTR_TX
= (1ul << 0),
45 PS3VUART_PORT_INTR_RX
= (1ul << 1),
46 PS3VUART_PORT_INTR_DISCONNECT
= (1ul << 2),
47 PS3VUART_PORT_INTR_CONNECT
= (1ul << 3),
50 struct ps3vuart_port_buf
{
51 TAILQ_ENTRY(ps3vuart_port_buf
) vb_queue
;
58 TAILQ_HEAD(ps3vuart_port_bufq
, ps3vuart_port_buf
);
60 struct ps3vuart_port_stat
{
61 unsigned long vs_rx_bytes
;
62 unsigned long vs_tx_bytes
;
63 unsigned long vs_rx_intrs
;
64 unsigned long vs_tx_intrs
;
67 struct ps3vuart_port
{
72 uint64_t vp_intr_mask
;
74 struct ps3vuart_port_bufq vp_rx_bufq
;
77 struct ps3vuart_port_bufq vp_tx_bufq
;
80 struct ps3vuart_port_stat vp_stat
;
83 int ps3vuart_port_init(struct ps3vuart_port
*vp
, int port
);
85 void ps3vuart_port_fini(struct ps3vuart_port
*vp
);
87 int ps3vuart_port_write(struct ps3vuart_port
*vp
, const char *buf
, int size
,
90 int ps3vuart_port_read(struct ps3vuart_port
*vp
, char *buf
, int size
,
93 int ps3vuart_port_set_param(struct ps3vuart_port
*vp
, int param
, uint64_t val
);
95 int ps3vuart_port_get_param(struct ps3vuart_port
*vp
, int param
, uint64_t *val
);
97 void ps3vuart_port_intr(struct ps3vuart_port
*vp
);
99 void ps3vuart_port_get_stat(struct ps3vuart_port
*vp
,
100 struct ps3vuart_port_stat
*stat
);
102 #endif /* _PS3VUART_PORT_H */