aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/omap_hsi/hsi-protocol-if.h
blob: f56ef364027b12ff461ba2611fd910be8dab8cf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * hsi-if.h
 *
 * Part of the HSI character driver, private headers.
 *
 * Copyright (C) 2009 Nokia Corporation. All rights reserved.
 * Copyright (C) 2009 Texas Instruments, Inc.
 *
 * Author: Andras Domokos <andras.domokos@nokia.com>
 * Author: Sebastien JAN <s-jan@ti.com>
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef _HSI_IF_H
#define _HSI_IF_H

#define HSI_EV_MASK		(0xffff << 0)
#define HSI_EV_TYPE_MASK	(0x0f << 16)
#define HSI_EV_IN		(0x01 << 16)
#define HSI_EV_OUT		(0x02 << 16)
#define HSI_EV_EXCEP		(0x03 << 16)
#define HSI_EV_AVAIL		(0x04 << 16)
#define HSI_EV_TYPE(event)	((event) & HSI_EV_TYPE_MASK)

#define HSI_HWBREAK		1
#define HSI_ERROR		2

#define HSI_MAX_CHANNELS	16
#define CHANNEL_MASK		0xFF
#define HSI_LL_INVALID_CHANNEL	0xFF

struct hsi_event {
	unsigned int event;
	u32 *data;
	unsigned int count;
};

struct if_hsi_channel {
	struct hsi_device *dev;
	unsigned int channel_id;
	u32 *tx_data;
	unsigned int tx_count;
	u32 *rx_data;
	unsigned int rx_count;
	unsigned int opened;
	unsigned int state;
	u32 *tx_buf;
	u32 *rx_buf;
	unsigned int tx_state;
	unsigned int rx_state;
	unsigned int tx_nak_count;
	unsigned int rx_nak_count;
	spinlock_t lock; /* Serializes access to channel data */
};

struct if_hsi_iface {
	struct if_hsi_channel channels[HSI_MAX_CHANNELS];
#if 0
	int bootstrap;
#endif
	unsigned long init_chan_map;
	spinlock_t lock; /* Serializes access to HSI functional interface */
};

struct if_hsi_cmd {
	u32 tx_cmd[50];
	u32 rx_cmd[50];
	struct timespec tx_cmd_time[50];
	struct timespec rx_cmd_time[50];
};

enum {
	HSI_LL_MSG_BREAK           = 0x00,
	HSI_LL_MSG_ECHO            = 0x01,
	HSI_LL_MSG_INFO_REQ        = 0x02,
	HSI_LL_MSG_INFO            = 0x03,
	HSI_LL_MSG_CONFIGURE       = 0x04,
	HSI_LL_MSG_ALLOCATE_CH     = 0x05,
	HSI_LL_MSG_RELEASE_CH      = 0x06,
	HSI_LL_MSG_OPEN_CONN       = 0x07,
	HSI_LL_MSG_CONN_READY      = 0x08,
	HSI_LL_MSG_CONN_CLOSED     = 0x09,
	HSI_LL_MSG_CANCEL_CONN     = 0x0A,
	HSI_LL_MSG_ACK             = 0x0B,
	HSI_LL_MSG_NAK             = 0x0C,
	HSI_LL_MSG_CONF_RATE       = 0x0D,
	HSI_LL_MSG_OPEN_CONN_OCTET = 0x0E,
	HSI_LL_MSG_INVALID         = 0xFF,
};

enum {
	HSI_LL_TX_STATE_UNDEF,
	HSI_LL_TX_STATE_CLOSED,
	HSI_LL_TX_STATE_IDLE,
	HSI_LL_TX_STATE_POWER_DOWN,
	HSI_LL_TX_STATE_ERROR,
	HSI_LL_TX_STATE_SEND_OPEN_CONN,
	HSI_LL_TX_STATE_WAIT_FOR_ACK,
	HSI_LL_TX_STATE_NACK,
	HSI_LL_TX_STATE_WAIT_FOR_CONN_READY,
	HSI_LL_TX_STATE_SEND_CONF_RATE,
	HSI_LL_TX_STATE_WAIT_FOR_CONF_ACK,
	HSI_LL_TX_STATE_TX,
	HSI_LL_TX_STATE_WAIT_FOR_CONN_CLOSED,
	HSI_LL_TX_STATE_TO_OPEN_CONN,
	HSI_LL_TX_STATE_TO_ACK,
	HSI_LL_TX_STATE_TO_READY,
	HSI_LL_TX_STATE_TO_CONF,
	HSI_LL_TX_STATE_TO_CONF_ACK,
	HSI_LL_TX_STATE_TO_TX,
	HSI_LL_TX_STATE_TO_CLOSE,
	HSI_LL_TX_STATE_SEND_BREAK,
};

enum {
	HSI_LL_RX_STATE_UNDEF,
	HSI_LL_RX_STATE_CLOSED,
	HSI_LL_RX_STATE_IDLE,
	HSI_LL_RX_STATE_POWER_DOWN,
	HSI_LL_RX_STATE_ERROR,
	HSI_LL_RX_STATE_BLOCKED,
	HSI_LL_RX_STATE_SEND_ACK,
	HSI_LL_RX_STATE_SEND_NACK,
	HSI_LL_RX_STATE_SEND_CONN_READY,
	HSI_LL_RX_STATE_RX,
	HSI_LL_RX_STATE_SEND_CONN_CLOSED,
	HSI_LL_RX_STATE_SEND_CONN_CANCEL,
	HSI_LL_RX_STATE_WAIT_FOR_CANCEL_CONN_ACK,
	HSI_LL_RX_STATE_SEND_CONF_ACK,
	HSI_LL_RX_STATE_SEND_CONF_NACK,
	HSI_LL_RX_STATE_TO_RX,
	HSI_LL_RX_STATE_TO_ACK,
	HSI_LL_RX_STATE_TO_NACK,
	HSI_LL_RX_STATE_TO_CONN_READY,
	HSI_LL_RX_STATE_TO_CONN_CLOSED,
	HSI_LL_RX_STATE_TO_CONN_CANCEL,
	HSI_LL_RX_STATE_TO_CONN_CANCEL_ACK,
	HSI_LL_RX_STATE_TO_CONF_ACK,
	HSI_LL_RX_STATE_SEND_BREAK,
};


int if_hsi_init(void);
int if_hsi_exit(void);

int if_hsi_start(int ch);
void if_hsi_stop(int ch);

void if_hsi_send_break(int ch);
void if_hsi_flush_rx(int ch);
void if_hsi_flush_tx(int ch);
void if_hsi_bootstrap(int ch);
void if_hsi_set_wakeline(int ch, unsigned int state);
void if_hsi_get_wakeline(int ch, unsigned int *state);

#if 0
int if_hsi_set_rx(int ch, struct hsi_rx_config *cfg);
void if_hsi_get_rx(int ch, struct hsi_rx_config *cfg);
int if_hsi_set_tx(int ch, struct hsi_tx_config *cfg);
void if_hsi_get_tx(int ch, struct hsi_tx_config *cfg);
#endif

int if_hsi_read(int ch, u32 *data, unsigned int count);
int if_hsi_poll(int ch);
int if_hsi_write(int ch, u32 *data, unsigned int count);

void if_hsi_cancel_read(int ch);
void if_hsi_cancel_write(int ch);

void if_notify(int ch, struct hsi_event *ev);
int hsi_proto_read(int ch, u32 *buffer, int count);
int hsi_proto_write(int ch, u32 *buffer, int length);
int hsi_decode_cmd(u32 *data, u32 *cmd, u32 *ch, u32 *param);
int protocol_create_cmd(int cmd_type, unsigned int channel, void *arg);
int hsi_protocol_send_command(u32 cmd, u32 channel, u32 param);
void rx_stm(u32 cmd, u32 ch, u32 param);
#if 0
int hsi_start_protocol(void);
#endif
#endif /* _HSI_IF_H */