bfin_sport.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * bfin_sport.h - userspace header for bfin sport driver
  3. *
  4. * Copyright 2004-2008 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef __BFIN_SPORT_H__
  9. #define __BFIN_SPORT_H__
  10. #define SPORT_MAJOR 237
  11. #define SPORT_NR_DEVS 2
  12. /* Sport mode: it can be set to TDM, i2s or others */
  13. #define NORM_MODE 0x0
  14. #define TDM_MODE 0x1
  15. #define I2S_MODE 0x2
  16. /* Data format, normal, a-law or u-law */
  17. #define NORM_FORMAT 0x0
  18. #define ALAW_FORMAT 0x2
  19. #define ULAW_FORMAT 0x3
  20. /* Function driver which use sport must initialize the structure */
  21. struct sport_config {
  22. /* TDM (multichannels), I2S or other mode */
  23. unsigned int mode:3;
  24. /* if TDM mode is selected, channels must be set */
  25. int channels; /* Must be in 8 units */
  26. unsigned int frame_delay:4; /* Delay between frame sync pulse and first bit */
  27. /* I2S mode */
  28. unsigned int right_first:1; /* Right stereo channel first */
  29. /* In mormal mode, the following item need to be set */
  30. unsigned int lsb_first:1; /* order of transmit or receive data */
  31. unsigned int fsync:1; /* Frame sync required */
  32. unsigned int data_indep:1; /* data independent frame sync generated */
  33. unsigned int act_low:1; /* Active low TFS */
  34. unsigned int late_fsync:1; /* Late frame sync */
  35. unsigned int tckfe:1;
  36. unsigned int sec_en:1; /* Secondary side enabled */
  37. /* Choose clock source */
  38. unsigned int int_clk:1; /* Internal or external clock */
  39. /* If external clock is used, the following fields are ignored */
  40. int serial_clk;
  41. int fsync_clk;
  42. unsigned int data_format:2; /* Normal, u-law or a-law */
  43. int word_len; /* How length of the word in bits, 3-32 bits */
  44. int dma_enabled;
  45. };
  46. /* Userspace interface */
  47. #define SPORT_IOC_MAGIC 'P'
  48. #define SPORT_IOC_CONFIG _IOWR('P', 0x01, struct sport_config)
  49. #ifdef __KERNEL__
  50. struct sport_register {
  51. unsigned short tcr1;
  52. unsigned short reserved0;
  53. unsigned short tcr2;
  54. unsigned short reserved1;
  55. unsigned short tclkdiv;
  56. unsigned short reserved2;
  57. unsigned short tfsdiv;
  58. unsigned short reserved3;
  59. unsigned long tx;
  60. unsigned long reserved_l0;
  61. unsigned long rx;
  62. unsigned long reserved_l1;
  63. unsigned short rcr1;
  64. unsigned short reserved4;
  65. unsigned short rcr2;
  66. unsigned short reserved5;
  67. unsigned short rclkdiv;
  68. unsigned short reserved6;
  69. unsigned short rfsdiv;
  70. unsigned short reserved7;
  71. unsigned short stat;
  72. unsigned short reserved8;
  73. unsigned short chnl;
  74. unsigned short reserved9;
  75. unsigned short mcmc1;
  76. unsigned short reserved10;
  77. unsigned short mcmc2;
  78. unsigned short reserved11;
  79. unsigned long mtcs0;
  80. unsigned long mtcs1;
  81. unsigned long mtcs2;
  82. unsigned long mtcs3;
  83. unsigned long mrcs0;
  84. unsigned long mrcs1;
  85. unsigned long mrcs2;
  86. unsigned long mrcs3;
  87. };
  88. struct sport_dev {
  89. struct cdev cdev; /* Char device structure */
  90. int sport_num;
  91. int dma_rx_chan;
  92. int dma_tx_chan;
  93. int rx_irq;
  94. unsigned char *rx_buf; /* Buffer store the received data */
  95. int rx_len; /* How many bytes will be received */
  96. int rx_received; /* How many bytes has been received */
  97. int tx_irq;
  98. const unsigned char *tx_buf;
  99. int tx_len;
  100. int tx_sent;
  101. int sport_err_irq;
  102. struct mutex mutex; /* mutual exclusion semaphore */
  103. struct task_struct *task;
  104. wait_queue_head_t waitq;
  105. int wait_con;
  106. struct sport_register *regs;
  107. struct sport_config config;
  108. };
  109. #endif
  110. #define SPORT_TCR1 0
  111. #define SPORT_TCR2 1
  112. #define SPORT_TCLKDIV 2
  113. #define SPORT_TFSDIV 3
  114. #define SPORT_RCR1 8
  115. #define SPORT_RCR2 9
  116. #define SPORT_RCLKDIV 10
  117. #define SPORT_RFSDIV 11
  118. #define SPORT_CHANNEL 13
  119. #define SPORT_MCMC1 14
  120. #define SPORT_MCMC2 15
  121. #define SPORT_MTCS0 16
  122. #define SPORT_MTCS1 17
  123. #define SPORT_MTCS2 18
  124. #define SPORT_MTCS3 19
  125. #define SPORT_MRCS0 20
  126. #define SPORT_MRCS1 21
  127. #define SPORT_MRCS2 22
  128. #define SPORT_MRCS3 23
  129. #endif