/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

  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. #ifndef _HSI_IF_H
  21. #define _HSI_IF_H
  22. #define HSI_EV_MASK (0xffff << 0)
  23. #define HSI_EV_TYPE_MASK (0x0f << 16)
  24. #define HSI_EV_IN (0x01 << 16)
  25. #define HSI_EV_OUT (0x02 << 16)
  26. #define HSI_EV_EXCEP (0x03 << 16)
  27. #define HSI_EV_AVAIL (0x04 << 16)
  28. #define HSI_EV_TYPE(event) ((event) & HSI_EV_TYPE_MASK)
  29. #define HSI_HWBREAK 1
  30. #define HSI_ERROR 2
  31. #define HSI_MAX_CHANNELS 16
  32. #define CHANNEL_MASK 0xFF
  33. #define HSI_LL_INVALID_CHANNEL 0xFF
  34. struct hsi_event {
  35. unsigned int event;
  36. u32 *data;
  37. unsigned int count;
  38. };
  39. struct if_hsi_channel {
  40. struct hsi_device *dev;
  41. unsigned int channel_id;
  42. u32 *tx_data;
  43. unsigned int tx_count;
  44. u32 *rx_data;
  45. unsigned int rx_count;
  46. unsigned int opened;
  47. unsigned int state;
  48. u32 *tx_buf;
  49. u32 *rx_buf;
  50. unsigned int tx_state;
  51. unsigned int rx_state;
  52. unsigned int tx_nak_count;
  53. unsigned int rx_nak_count;
  54. spinlock_t lock; /* Serializes access to channel data */
  55. };
  56. struct if_hsi_iface {
  57. struct if_hsi_channel channels[HSI_MAX_CHANNELS];
  58. #if 0
  59. int bootstrap;
  60. #endif
  61. unsigned long init_chan_map;
  62. spinlock_t lock; /* Serializes access to HSI functional interface */
  63. };
  64. struct if_hsi_cmd {
  65. u32 tx_cmd[50];
  66. u32 rx_cmd[50];
  67. struct timespec tx_cmd_time[50];
  68. struct timespec rx_cmd_time[50];
  69. };
  70. enum {
  71. HSI_LL_MSG_BREAK = 0x00,
  72. HSI_LL_MSG_ECHO = 0x01,
  73. HSI_LL_MSG_INFO_REQ = 0x02,
  74. HSI_LL_MSG_INFO = 0x03,
  75. HSI_LL_MSG_CONFIGURE = 0x04,
  76. HSI_LL_MSG_ALLOCATE_CH = 0x05,
  77. HSI_LL_MSG_RELEASE_CH = 0x06,
  78. HSI_LL_MSG_OPEN_CONN = 0x07,
  79. HSI_LL_MSG_CONN_READY = 0x08,
  80. HSI_LL_MSG_CONN_CLOSED = 0x09,
  81. HSI_LL_MSG_CANCEL_CONN = 0x0A,
  82. HSI_LL_MSG_ACK = 0x0B,
  83. HSI_LL_MSG_NAK = 0x0C,
  84. HSI_LL_MSG_CONF_RATE = 0x0D,
  85. HSI_LL_MSG_OPEN_CONN_OCTET = 0x0E,
  86. HSI_LL_MSG_INVALID = 0xFF,
  87. };
  88. enum {
  89. HSI_LL_TX_STATE_UNDEF,
  90. HSI_LL_TX_STATE_CLOSED,
  91. HSI_LL_TX_STATE_IDLE,
  92. HSI_LL_TX_STATE_POWER_DOWN,
  93. HSI_LL_TX_STATE_ERROR,
  94. HSI_LL_TX_STATE_SEND_OPEN_CONN,
  95. HSI_LL_TX_STATE_WAIT_FOR_ACK,
  96. HSI_LL_TX_STATE_NACK,
  97. HSI_LL_TX_STATE_WAIT_FOR_CONN_READY,
  98. HSI_LL_TX_STATE_SEND_CONF_RATE,
  99. HSI_LL_TX_STATE_WAIT_FOR_CONF_ACK,
  100. HSI_LL_TX_STATE_TX,
  101. HSI_LL_TX_STATE_WAIT_FOR_CONN_CLOSED,
  102. HSI_LL_TX_STATE_TO_OPEN_CONN,
  103. HSI_LL_TX_STATE_TO_ACK,
  104. HSI_LL_TX_STATE_TO_READY,
  105. HSI_LL_TX_STATE_TO_CONF,
  106. HSI_LL_TX_STATE_TO_CONF_ACK,
  107. HSI_LL_TX_STATE_TO_TX,
  108. HSI_LL_TX_STATE_TO_CLOSE,
  109. HSI_LL_TX_STATE_SEND_BREAK,
  110. };
  111. enum {
  112. HSI_LL_RX_STATE_UNDEF,
  113. HSI_LL_RX_STATE_CLOSED,
  114. HSI_LL_RX_STATE_IDLE,
  115. HSI_LL_RX_STATE_POWER_DOWN,
  116. HSI_LL_RX_STATE_ERROR,
  117. HSI_LL_RX_STATE_BLOCKED,
  118. HSI_LL_RX_STATE_SEND_ACK,
  119. HSI_LL_RX_STATE_SEND_NACK,
  120. HSI_LL_RX_STATE_SEND_CONN_READY,
  121. HSI_LL_RX_STATE_RX,
  122. HSI_LL_RX_STATE_SEND_CONN_CLOSED,
  123. HSI_LL_RX_STATE_SEND_CONN_CANCEL,
  124. HSI_LL_RX_STATE_WAIT_FOR_CANCEL_CONN_ACK,
  125. HSI_LL_RX_STATE_SEND_CONF_ACK,
  126. HSI_LL_RX_STATE_SEND_CONF_NACK,
  127. HSI_LL_RX_STATE_TO_RX,
  128. HSI_LL_RX_STATE_TO_ACK,
  129. HSI_LL_RX_STATE_TO_NACK,
  130. HSI_LL_RX_STATE_TO_CONN_READY,
  131. HSI_LL_RX_STATE_TO_CONN_CLOSED,
  132. HSI_LL_RX_STATE_TO_CONN_CANCEL,
  133. HSI_LL_RX_STATE_TO_CONN_CANCEL_ACK,
  134. HSI_LL_RX_STATE_TO_CONF_ACK,
  135. HSI_LL_RX_STATE_SEND_BREAK,
  136. };
  137. int if_hsi_init(void);
  138. int if_hsi_exit(void);
  139. int if_hsi_start(int ch);
  140. void if_hsi_stop(int ch);
  141. void if_hsi_send_break(int ch);
  142. void if_hsi_flush_rx(int ch);
  143. void if_hsi_flush_tx(int ch);
  144. void if_hsi_bootstrap(int ch);
  145. void if_hsi_set_wakeline(int ch, unsigned int state);
  146. void if_hsi_get_wakeline(int ch, unsigned int *state);
  147. #if 0
  148. int if_hsi_set_rx(int ch, struct hsi_rx_config *cfg);
  149. void if_hsi_get_rx(int ch, struct hsi_rx_config *cfg);
  150. int if_hsi_set_tx(int ch, struct hsi_tx_config *cfg);
  151. void if_hsi_get_tx(int ch, struct hsi_tx_config *cfg);
  152. #endif
  153. int if_hsi_read(int ch, u32 *data, unsigned int count);
  154. int if_hsi_poll(int ch);
  155. int if_hsi_write(int ch, u32 *data, unsigned int count);
  156. void if_hsi_cancel_read(int ch);
  157. void if_hsi_cancel_write(int ch);
  158. void if_notify(int ch, struct hsi_event *ev);
  159. int hsi_proto_read(int ch, u32 *buffer, int count);
  160. int hsi_proto_write(int ch, u32 *buffer, int length);
  161. int hsi_decode_cmd(u32 *data, u32 *cmd, u32 *ch, u32 *param);
  162. int protocol_create_cmd(int cmd_type, unsigned int channel, void *arg);
  163. int hsi_protocol_send_command(u32 cmd, u32 channel, u32 param);
  164. void rx_stm(u32 cmd, u32 ch, u32 param);
  165. #if 0
  166. int hsi_start_protocol(void);
  167. #endif
  168. #endif /* _HSI_IF_H */