PageRenderTime 41ms CodeModel.GetById 21ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/omap_hsi/hsi-protocol-if.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C Header | 187 lines | 149 code | 19 blank | 19 comment | 0 complexity | a646f80d3e42b5962e2b3b1f7711149a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1/*
  2 * hsi-if.h
  3 *
  4 * Part of the HSI character driver, private headers.
  5 *
  6 * Copyright (C) 2009 Nokia Corporation. All rights reserved.
  7 * Copyright (C) 2009 Texas Instruments, Inc.
  8 *
  9 * Author: Andras Domokos <andras.domokos@nokia.com>
 10 * Author: Sebastien JAN <s-jan@ti.com>
 11 *
 12 * This package is free software; you can redistribute it and/or modify
 13 * it under the terms of the GNU General Public License version 2 as
 14 * published by the Free Software Foundation.
 15 *
 16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 19 */
 20
 21#ifndef _HSI_IF_H
 22#define _HSI_IF_H
 23
 24#define HSI_EV_MASK		(0xffff << 0)
 25#define HSI_EV_TYPE_MASK	(0x0f << 16)
 26#define HSI_EV_IN		(0x01 << 16)
 27#define HSI_EV_OUT		(0x02 << 16)
 28#define HSI_EV_EXCEP		(0x03 << 16)
 29#define HSI_EV_AVAIL		(0x04 << 16)
 30#define HSI_EV_TYPE(event)	((event) & HSI_EV_TYPE_MASK)
 31
 32#define HSI_HWBREAK		1
 33#define HSI_ERROR		2
 34
 35#define HSI_MAX_CHANNELS	16
 36#define CHANNEL_MASK		0xFF
 37#define HSI_LL_INVALID_CHANNEL	0xFF
 38
 39struct hsi_event {
 40	unsigned int event;
 41	u32 *data;
 42	unsigned int count;
 43};
 44
 45struct if_hsi_channel {
 46	struct hsi_device *dev;
 47	unsigned int channel_id;
 48	u32 *tx_data;
 49	unsigned int tx_count;
 50	u32 *rx_data;
 51	unsigned int rx_count;
 52	unsigned int opened;
 53	unsigned int state;
 54	u32 *tx_buf;
 55	u32 *rx_buf;
 56	unsigned int tx_state;
 57	unsigned int rx_state;
 58	unsigned int tx_nak_count;
 59	unsigned int rx_nak_count;
 60	spinlock_t lock; /* Serializes access to channel data */
 61};
 62
 63struct if_hsi_iface {
 64	struct if_hsi_channel channels[HSI_MAX_CHANNELS];
 65#if 0
 66	int bootstrap;
 67#endif
 68	unsigned long init_chan_map;
 69	spinlock_t lock; /* Serializes access to HSI functional interface */
 70};
 71
 72struct if_hsi_cmd {
 73	u32 tx_cmd[50];
 74	u32 rx_cmd[50];
 75	struct timespec tx_cmd_time[50];
 76	struct timespec rx_cmd_time[50];
 77};
 78
 79enum {
 80	HSI_LL_MSG_BREAK           = 0x00,
 81	HSI_LL_MSG_ECHO            = 0x01,
 82	HSI_LL_MSG_INFO_REQ        = 0x02,
 83	HSI_LL_MSG_INFO            = 0x03,
 84	HSI_LL_MSG_CONFIGURE       = 0x04,
 85	HSI_LL_MSG_ALLOCATE_CH     = 0x05,
 86	HSI_LL_MSG_RELEASE_CH      = 0x06,
 87	HSI_LL_MSG_OPEN_CONN       = 0x07,
 88	HSI_LL_MSG_CONN_READY      = 0x08,
 89	HSI_LL_MSG_CONN_CLOSED     = 0x09,
 90	HSI_LL_MSG_CANCEL_CONN     = 0x0A,
 91	HSI_LL_MSG_ACK             = 0x0B,
 92	HSI_LL_MSG_NAK             = 0x0C,
 93	HSI_LL_MSG_CONF_RATE       = 0x0D,
 94	HSI_LL_MSG_OPEN_CONN_OCTET = 0x0E,
 95	HSI_LL_MSG_INVALID         = 0xFF,
 96};
 97
 98enum {
 99	HSI_LL_TX_STATE_UNDEF,
100	HSI_LL_TX_STATE_CLOSED,
101	HSI_LL_TX_STATE_IDLE,
102	HSI_LL_TX_STATE_POWER_DOWN,
103	HSI_LL_TX_STATE_ERROR,
104	HSI_LL_TX_STATE_SEND_OPEN_CONN,
105	HSI_LL_TX_STATE_WAIT_FOR_ACK,
106	HSI_LL_TX_STATE_NACK,
107	HSI_LL_TX_STATE_WAIT_FOR_CONN_READY,
108	HSI_LL_TX_STATE_SEND_CONF_RATE,
109	HSI_LL_TX_STATE_WAIT_FOR_CONF_ACK,
110	HSI_LL_TX_STATE_TX,
111	HSI_LL_TX_STATE_WAIT_FOR_CONN_CLOSED,
112	HSI_LL_TX_STATE_TO_OPEN_CONN,
113	HSI_LL_TX_STATE_TO_ACK,
114	HSI_LL_TX_STATE_TO_READY,
115	HSI_LL_TX_STATE_TO_CONF,
116	HSI_LL_TX_STATE_TO_CONF_ACK,
117	HSI_LL_TX_STATE_TO_TX,
118	HSI_LL_TX_STATE_TO_CLOSE,
119	HSI_LL_TX_STATE_SEND_BREAK,
120};
121
122enum {
123	HSI_LL_RX_STATE_UNDEF,
124	HSI_LL_RX_STATE_CLOSED,
125	HSI_LL_RX_STATE_IDLE,
126	HSI_LL_RX_STATE_POWER_DOWN,
127	HSI_LL_RX_STATE_ERROR,
128	HSI_LL_RX_STATE_BLOCKED,
129	HSI_LL_RX_STATE_SEND_ACK,
130	HSI_LL_RX_STATE_SEND_NACK,
131	HSI_LL_RX_STATE_SEND_CONN_READY,
132	HSI_LL_RX_STATE_RX,
133	HSI_LL_RX_STATE_SEND_CONN_CLOSED,
134	HSI_LL_RX_STATE_SEND_CONN_CANCEL,
135	HSI_LL_RX_STATE_WAIT_FOR_CANCEL_CONN_ACK,
136	HSI_LL_RX_STATE_SEND_CONF_ACK,
137	HSI_LL_RX_STATE_SEND_CONF_NACK,
138	HSI_LL_RX_STATE_TO_RX,
139	HSI_LL_RX_STATE_TO_ACK,
140	HSI_LL_RX_STATE_TO_NACK,
141	HSI_LL_RX_STATE_TO_CONN_READY,
142	HSI_LL_RX_STATE_TO_CONN_CLOSED,
143	HSI_LL_RX_STATE_TO_CONN_CANCEL,
144	HSI_LL_RX_STATE_TO_CONN_CANCEL_ACK,
145	HSI_LL_RX_STATE_TO_CONF_ACK,
146	HSI_LL_RX_STATE_SEND_BREAK,
147};
148
149
150int if_hsi_init(void);
151int if_hsi_exit(void);
152
153int if_hsi_start(int ch);
154void if_hsi_stop(int ch);
155
156void if_hsi_send_break(int ch);
157void if_hsi_flush_rx(int ch);
158void if_hsi_flush_tx(int ch);
159void if_hsi_bootstrap(int ch);
160void if_hsi_set_wakeline(int ch, unsigned int state);
161void if_hsi_get_wakeline(int ch, unsigned int *state);
162
163#if 0
164int if_hsi_set_rx(int ch, struct hsi_rx_config *cfg);
165void if_hsi_get_rx(int ch, struct hsi_rx_config *cfg);
166int if_hsi_set_tx(int ch, struct hsi_tx_config *cfg);
167void if_hsi_get_tx(int ch, struct hsi_tx_config *cfg);
168#endif
169
170int if_hsi_read(int ch, u32 *data, unsigned int count);
171int if_hsi_poll(int ch);
172int if_hsi_write(int ch, u32 *data, unsigned int count);
173
174void if_hsi_cancel_read(int ch);
175void if_hsi_cancel_write(int ch);
176
177void if_notify(int ch, struct hsi_event *ev);
178int hsi_proto_read(int ch, u32 *buffer, int count);
179int hsi_proto_write(int ch, u32 *buffer, int length);
180int hsi_decode_cmd(u32 *data, u32 *cmd, u32 *ch, u32 *param);
181int protocol_create_cmd(int cmd_type, unsigned int channel, void *arg);
182int hsi_protocol_send_command(u32 cmd, u32 channel, u32 param);
183void rx_stm(u32 cmd, u32 ch, u32 param);
184#if 0
185int hsi_start_protocol(void);
186#endif
187#endif /* _HSI_IF_H */