sync_serial.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * ioctl defines for synchronous serial port driver
  3. *
  4. * Copyright (c) 2001-2003 Axis Communications AB
  5. *
  6. * Author: Mikael Starvik
  7. *
  8. */
  9. #ifndef SYNC_SERIAL_H
  10. #define SYNC_SERIAL_H
  11. #include <linux/ioctl.h>
  12. #define SSP_SPEED _IOR('S', 0, unsigned int)
  13. #define SSP_MODE _IOR('S', 1, unsigned int)
  14. #define SSP_FRAME_SYNC _IOR('S', 2, unsigned int)
  15. #define SSP_IPOLARITY _IOR('S', 3, unsigned int)
  16. #define SSP_OPOLARITY _IOR('S', 4, unsigned int)
  17. #define SSP_SPI _IOR('S', 5, unsigned int)
  18. #define SSP_INBUFCHUNK _IOR('S', 6, unsigned int)
  19. #define SSP_INPUT _IOR('S', 7, unsigned int)
  20. /* Values for SSP_SPEED */
  21. #define SSP150 0
  22. #define SSP300 1
  23. #define SSP600 2
  24. #define SSP1200 3
  25. #define SSP2400 4
  26. #define SSP4800 5
  27. #define SSP9600 6
  28. #define SSP19200 7
  29. #define SSP28800 8
  30. #define SSP57600 9
  31. #define SSP115200 10
  32. #define SSP230400 11
  33. #define SSP460800 12
  34. #define SSP921600 13
  35. #define SSP3125000 14
  36. #define CODEC 15
  37. #define CODEC_f32768 16
  38. #define FREQ_4MHz 0
  39. #define FREQ_2MHz 1
  40. #define FREQ_1MHz 2
  41. #define FREQ_512kHz 3
  42. #define FREQ_256kHz 4
  43. #define FREQ_128kHz 5
  44. #define FREQ_64kHz 6
  45. #define FREQ_32kHz 7
  46. /* FREQ_* with values where bit (value & 0x10) is set are */
  47. /* used for CODEC_f32768 */
  48. #define FREQ_4096kHz 16 /* CODEC_f32768 */
  49. /* Used by application to set CODEC divider, word rate and frame rate */
  50. #define CODEC_VAL(freq, clk_per_sync, sync_per_frame) \
  51. ((CODEC + ((freq & 0x10) >> 4)) | (freq << 8) | \
  52. (clk_per_sync << 16) | (sync_per_frame << 28))
  53. /* Used by driver to extract speed */
  54. #define GET_SPEED(x) (x & 0xff)
  55. #define GET_FREQ(x) ((x & 0xff00) >> 8)
  56. #define GET_WORD_RATE(x) (((x & 0x0fff0000) >> 16) - 1)
  57. #define GET_FRAME_RATE(x) (((x & 0xf0000000) >> 28) - 1)
  58. /* Values for SSP_MODE */
  59. #define MASTER_OUTPUT 0
  60. #define SLAVE_OUTPUT 1
  61. #define MASTER_INPUT 2
  62. #define SLAVE_INPUT 3
  63. #define MASTER_BIDIR 4
  64. #define SLAVE_BIDIR 5
  65. /* Values for SSP_FRAME_SYNC */
  66. #define NORMAL_SYNC 1
  67. #define EARLY_SYNC 2
  68. #define SECOND_WORD_SYNC 0x40000
  69. #define LATE_SYNC 0x80000
  70. #define BIT_SYNC 4
  71. #define WORD_SYNC 8
  72. #define EXTENDED_SYNC 0x10
  73. #define SYNC_OFF 0x20
  74. #define SYNC_ON 0x40
  75. #define WORD_SIZE_8 0x80
  76. #define WORD_SIZE_12 0x100
  77. #define WORD_SIZE_16 0x200
  78. #define WORD_SIZE_24 0x400
  79. #define WORD_SIZE_32 0x800
  80. #define BIT_ORDER_LSB 0x1000
  81. #define BIT_ORDER_MSB 0x2000
  82. #define FLOW_CONTROL_ENABLE 0x4000
  83. #define FLOW_CONTROL_DISABLE 0x8000
  84. #define CLOCK_GATED 0x10000
  85. #define CLOCK_NOT_GATED 0x20000
  86. /* Values for SSP_IPOLARITY and SSP_OPOLARITY */
  87. #define CLOCK_NORMAL 1
  88. #define CLOCK_INVERT 2
  89. #define CLOCK_INEGEDGE CLOCK_NORMAL
  90. #define CLOCK_IPOSEDGE CLOCK_INVERT
  91. #define FRAME_NORMAL 4
  92. #define FRAME_INVERT 8
  93. #define STATUS_NORMAL 0x10
  94. #define STATUS_INVERT 0x20
  95. /* Values for SSP_SPI */
  96. #define SPI_MASTER 0
  97. #define SPI_SLAVE 1
  98. /* Values for SSP_INBUFCHUNK */
  99. /* plain integer with the size of DMA chunks */
  100. /* To ensure that the timestamps are aligned with the data being read
  101. * the read length MUST be a multiple of the length of the DMA buffers.
  102. *
  103. * Use a multiple of SSP_INPUT_CHUNK_SIZE defined below.
  104. */
  105. #define SSP_INPUT_CHUNK_SIZE 256
  106. /* Request struct to pass through the ioctl interface to read
  107. * data with timestamps.
  108. */
  109. struct ssp_request {
  110. char __user *buf; /* Where to put the data. */
  111. size_t len; /* Size of buf. MUST be a multiple of */
  112. /* SSP_INPUT_CHUNK_SIZE! */
  113. struct timespec ts; /* The time the data was sampled. */
  114. };
  115. #endif