i2c.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * (C) Copyright 2004
  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 _OMAP24XX_I2C_H_
  24. #define _OMAP24XX_I2C_H_
  25. #define I2C_BASE 0x48070000
  26. #define I2C_BASE2 0x48072000 /* nothing hooked up on h4 */
  27. #define I2C_REV (I2C_BASE + 0x00)
  28. #define I2C_IE (I2C_BASE + 0x04)
  29. #define I2C_STAT (I2C_BASE + 0x08)
  30. #define I2C_IV (I2C_BASE + 0x0c)
  31. #define I2C_BUF (I2C_BASE + 0x14)
  32. #define I2C_CNT (I2C_BASE + 0x18)
  33. #define I2C_DATA (I2C_BASE + 0x1c)
  34. #define I2C_SYSC (I2C_BASE + 0x20)
  35. #define I2C_CON (I2C_BASE + 0x24)
  36. #define I2C_OA (I2C_BASE + 0x28)
  37. #define I2C_SA (I2C_BASE + 0x2c)
  38. #define I2C_PSC (I2C_BASE + 0x30)
  39. #define I2C_SCLL (I2C_BASE + 0x34)
  40. #define I2C_SCLH (I2C_BASE + 0x38)
  41. #define I2C_SYSTEST (I2C_BASE + 0x3c)
  42. /* I2C masks */
  43. /* I2C Interrupt Enable Register (I2C_IE): */
  44. #define I2C_IE_GC_IE (1 << 5)
  45. #define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
  46. #define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
  47. #define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
  48. #define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
  49. #define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
  50. /* I2C Status Register (I2C_STAT): */
  51. #define I2C_STAT_SBD (1 << 15) /* Single byte data */
  52. #define I2C_STAT_BB (1 << 12) /* Bus busy */
  53. #define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
  54. #define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
  55. #define I2C_STAT_AAS (1 << 9) /* Address as slave */
  56. #define I2C_STAT_GC (1 << 5)
  57. #define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
  58. #define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
  59. #define I2C_STAT_ARDY (1 << 2) /* Register access ready */
  60. #define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
  61. #define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
  62. /* I2C Interrupt Code Register (I2C_INTCODE): */
  63. #define I2C_INTCODE_MASK 7
  64. #define I2C_INTCODE_NONE 0
  65. #define I2C_INTCODE_AL 1 /* Arbitration lost */
  66. #define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */
  67. #define I2C_INTCODE_ARDY 3 /* Register access ready */
  68. #define I2C_INTCODE_RRDY 4 /* Rcv data ready */
  69. #define I2C_INTCODE_XRDY 5 /* Xmit data ready */
  70. /* I2C Buffer Configuration Register (I2C_BUF): */
  71. #define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */
  72. #define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */
  73. /* I2C Configuration Register (I2C_CON): */
  74. #define I2C_CON_EN (1 << 15) /* I2C module enable */
  75. #define I2C_CON_BE (1 << 14) /* Big endian mode */
  76. #define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */
  77. #define I2C_CON_MST (1 << 10) /* Master/slave mode */
  78. #define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode (master mode only) */
  79. #define I2C_CON_XA (1 << 8) /* Expand address */
  80. #define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */
  81. #define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */
  82. /* I2C System Test Register (I2C_SYSTEST): */
  83. #define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
  84. #define I2C_SYSTEST_FREE (1 << 14) /* Free running mode (on breakpoint) */
  85. #define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */
  86. #define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */
  87. #define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */
  88. #define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */
  89. #define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */
  90. #define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */
  91. /* These values were copied from omap3, include/asm-arm/arch-omap3/i2c.h. */
  92. #define OMAP_I2C_STANDARD 100000
  93. #define OMAP_I2C_FAST_MODE 400000
  94. #define OMAP_I2C_HIGH_SPEED 3400000
  95. #define SYSTEM_CLOCK_12 12000000
  96. #define SYSTEM_CLOCK_13 13000000
  97. #define SYSTEM_CLOCK_192 19200000
  98. #define SYSTEM_CLOCK_96 96000000
  99. #ifndef I2C_IP_CLK
  100. #define I2C_IP_CLK SYSTEM_CLOCK_96
  101. #endif
  102. #ifndef I2C_INTERNAL_SAMPLING_CLK
  103. #define I2C_INTERNAL_SAMPLING_CLK 19200000
  104. #endif
  105. /* These are the trim values for standard and fast speed */
  106. #ifndef I2C_FASTSPEED_SCLL_TRIM
  107. #define I2C_FASTSPEED_SCLL_TRIM 6
  108. #endif
  109. #ifndef I2C_FASTSPEED_SCLH_TRIM
  110. #define I2C_FASTSPEED_SCLH_TRIM 6
  111. #endif
  112. /* These are the trim values for high speed */
  113. #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM
  114. #define I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
  115. #endif
  116. #ifndef I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM
  117. #define I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
  118. #endif
  119. #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM
  120. #define I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
  121. #endif
  122. #ifndef I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM
  123. #define I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
  124. #endif
  125. #define I2C_PSC_MAX 0x0f
  126. #define I2C_PSC_MIN 0x00
  127. #endif