omap24xx_i2c.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * (C) Copyright 2004-2010
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _OMAP2PLUS_I2C_H_
  24. #define _OMAP2PLUS_I2C_H_
  25. /* I2C masks */
  26. /* I2C Interrupt Enable Register (I2C_IE): */
  27. #define I2C_IE_GC_IE (1 << 5)
  28. #define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
  29. #define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
  30. #define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
  31. #define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
  32. #define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
  33. /* I2C Status Register (I2C_STAT): */
  34. #define I2C_STAT_SBD (1 << 15) /* Single byte data */
  35. #define I2C_STAT_BB (1 << 12) /* Bus busy */
  36. #define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
  37. #define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
  38. #define I2C_STAT_AAS (1 << 9) /* Address as slave */
  39. #define I2C_STAT_GC (1 << 5)
  40. #define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
  41. #define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
  42. #define I2C_STAT_ARDY (1 << 2) /* Register access ready */
  43. #define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
  44. #define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
  45. /* I2C Interrupt Code Register (I2C_INTCODE): */
  46. #define I2C_INTCODE_MASK 7
  47. #define I2C_INTCODE_NONE 0
  48. #define I2C_INTCODE_AL 1 /* Arbitration lost */
  49. #define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */
  50. #define I2C_INTCODE_ARDY 3 /* Register access ready */
  51. #define I2C_INTCODE_RRDY 4 /* Rcv data ready */
  52. #define I2C_INTCODE_XRDY 5 /* Xmit data ready */
  53. /* I2C Buffer Configuration Register (I2C_BUF): */
  54. #define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */
  55. #define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */
  56. /* I2C Configuration Register (I2C_CON): */
  57. #define I2C_CON_EN (1 << 15) /* I2C module enable */
  58. #define I2C_CON_BE (1 << 14) /* Big endian mode */
  59. #define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */
  60. #define I2C_CON_MST (1 << 10) /* Master/slave mode */
  61. #define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode */
  62. /* (master mode only) */
  63. #define I2C_CON_XA (1 << 8) /* Expand address */
  64. #define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */
  65. #define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */
  66. /* I2C System Test Register (I2C_SYSTEST): */
  67. #define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
  68. #define I2C_SYSTEST_FREE (1 << 14) /* Free running mode, on brkpoint) */
  69. #define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */
  70. #define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */
  71. #define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */
  72. #define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */
  73. #define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */
  74. #define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */
  75. /* I2C System Status Register (I2C_SYSS): */
  76. #define I2C_SYSS_RDONE (1 << 0) /* Internel reset monitoring */
  77. #define I2C_SCLL_SCLL 0
  78. #define I2C_SCLL_SCLL_M 0xFF
  79. #define I2C_SCLL_HSSCLL 8
  80. #define I2C_SCLH_HSSCLL_M 0xFF
  81. #define I2C_SCLH_SCLH 0
  82. #define I2C_SCLH_SCLH_M 0xFF
  83. #define I2C_SCLH_HSSCLH 8
  84. #define I2C_SCLH_HSSCLH_M 0xFF
  85. #define OMAP_I2C_STANDARD 100000
  86. #define OMAP_I2C_FAST_MODE 400000
  87. #define OMAP_I2C_HIGH_SPEED 3400000
  88. #define SYSTEM_CLOCK_12 12000000
  89. #define SYSTEM_CLOCK_13 13000000
  90. #define SYSTEM_CLOCK_192 19200000
  91. #define SYSTEM_CLOCK_96 96000000
  92. /* Use the reference value of 96MHz if not explicitly set by the board */
  93. #ifndef I2C_IP_CLK
  94. #define I2C_IP_CLK SYSTEM_CLOCK_96
  95. #endif
  96. /*
  97. * The reference minimum clock for high speed is 19.2MHz.
  98. * The linux 2.6.30 kernel uses this value.
  99. * The reference minimum clock for fast mode is 9.6MHz
  100. * The reference minimum clock for standard mode is 4MHz
  101. * In TRM, the value of 12MHz is used.
  102. */
  103. #ifndef I2C_INTERNAL_SAMPLING_CLK
  104. #define I2C_INTERNAL_SAMPLING_CLK 19200000
  105. #endif
  106. /*
  107. * The equation for the low and high time is
  108. * tlow = scll + scll_trim = (sampling clock * tlow_duty) / speed
  109. * thigh = sclh + sclh_trim = (sampling clock * (1 - tlow_duty)) / speed
  110. *
  111. * If the duty cycle is 50%
  112. *
  113. * tlow = scll + scll_trim = sampling clock / (2 * speed)
  114. * thigh = sclh + sclh_trim = sampling clock / (2 * speed)
  115. *
  116. * In TRM
  117. * scll_trim = 7
  118. * sclh_trim = 5
  119. *
  120. * The linux 2.6.30 kernel uses
  121. * scll_trim = 6
  122. * sclh_trim = 6
  123. *
  124. * These are the trim values for standard and fast speed
  125. */
  126. #ifndef I2C_FASTSPEED_SCLL_TRIM
  127. #define I2C_FASTSPEED_SCLL_TRIM 6
  128. #endif
  129. #ifndef I2C_FASTSPEED_SCLH_TRIM
  130. #define I2C_FASTSPEED_SCLH_TRIM 6
  131. #endif
  132. /* These are the trim values for high speed */
  133. #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM
  134. #define I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
  135. #endif
  136. #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM
  137. #define I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
  138. #endif
  139. #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM
  140. #define I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
  141. #endif
  142. #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM
  143. #define I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
  144. #endif
  145. #define I2C_PSC_MAX 0x0f
  146. #define I2C_PSC_MIN 0x00
  147. #endif /* _OMAP24XX_I2C_H_ */