i2c-algo-ite.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. --------------------------------------------------------------------
  3. i2c-ite.h: Global defines for the I2C controller on board the
  4. ITE MIPS processor.
  5. --------------------------------------------------------------------
  6. Hai-Pao Fan, MontaVista Software, Inc.
  7. hpfan@mvista.com or source@mvista.com
  8. Copyright 2001 MontaVista Software Inc.
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  15. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  17. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  20. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  21. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. *
  25. * You should have received a copy of the GNU General Public License along
  26. * with this program; if not, write to the Free Software Foundation, Inc.,
  27. * 675 Mass Ave, Cambridge, MA 02139, USA.
  28. */
  29. #ifndef I2C_ITE_H
  30. #define I2C_ITE_H 1
  31. #include <asm/it8172/it8172.h>
  32. /* I2C Registers */
  33. #define ITE_I2CHCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x30
  34. #define ITE_I2CHSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x34
  35. #define ITE_I2CSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x38
  36. #define ITE_I2CSSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x3c
  37. #define ITE_I2CCKCNT IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x48
  38. #define ITE_I2CSHDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x4c
  39. #define ITE_I2CRSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x50
  40. #define ITE_I2CPSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x54
  41. #define ITE_I2CFDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x70
  42. #define ITE_I2CFBCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x74
  43. #define ITE_I2CFCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x78
  44. #define ITE_I2CFSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x7c
  45. /* Host Control Register ITE_I2CHCR */
  46. #define ITE_I2CHCR_HCE 0x01 /* Enable I2C Host Controller */
  47. #define ITE_I2CHCR_IE 0x02 /* Enable the interrupt after completing
  48. the current transaction */
  49. #define ITE_I2CHCR_CP_W 0x00 /* bit2-4 000 - Write */
  50. #define ITE_I2CHCR_CP_R 0x08 /* 010 - Current address read */
  51. #define ITE_I2CHCR_CP_S 0x10 /* 100 - Sequential read */
  52. #define ITE_I2CHCR_ST 0x20 /* Initiates the I2C host controller to execute
  53. the command and send the data programmed in
  54. all required registers to I2C bus */
  55. #define ITE_CMD ITE_I2CHCR_HCE | ITE_I2CHCR_IE | ITE_I2CHCR_ST
  56. #define ITE_WRITE ITE_CMD | ITE_I2CHCR_CP_W
  57. #define ITE_READ ITE_CMD | ITE_I2CHCR_CP_R
  58. #define ITE_SREAD ITE_CMD | ITE_I2CHCR_CP_S
  59. /* Host Status Register ITE_I2CHSR */
  60. #define ITE_I2CHSR_DB 0x01 /* Device is busy, receives NACK response except
  61. in the first and last bytes */
  62. #define ITE_I2CHSR_DNE 0x02 /* Target address on I2C bus does not exist */
  63. #define ITE_I2CHSR_TDI 0x04 /* R/W Transaction on I2C bus was completed */
  64. #define ITE_I2CHSR_HB 0x08 /* Host controller is processing transactions */
  65. #define ITE_I2CHSR_FER 0x10 /* Error occurs in the FIFO */
  66. /* Slave Address Register ITE_I2CSAR */
  67. #define ITE_I2CSAR_SA_MASK 0xfe /* Target I2C device address */
  68. #define ITE_I2CSAR_ASO 0x0100 /* Output 1/0 to I2CAS port when the
  69. next slave address is addressed */
  70. /* Slave Sub-address Register ITE_I2CSSAR */
  71. #define ITE_I2CSSAR_SUBA_MASK 0xff /* Target I2C device sub-address */
  72. /* Clock Counter Register ITE_I2CCKCNT */
  73. #define ITE_I2CCKCNT_STOP 0x00 /* stop I2C clock */
  74. #define ITE_I2CCKCNT_HPCC_MASK 0x7f /* SCL high period counter */
  75. #define ITE_I2CCKCNT_LPCC_MASK 0x7f00 /* SCL low period counter */
  76. /* START Hold Time Register ITE_I2CSHDR */
  77. /* value is counted based on 16 MHz internal clock */
  78. #define ITE_I2CSHDR_FM 0x0a /* START condition at fast mode */
  79. #define ITE_I2CSHDR_SM 0x47 /* START contition at standard mode */
  80. /* (Repeated) START Setup Time Register ITE_I2CRSUR */
  81. /* value is counted based on 16 MHz internal clock */
  82. #define ITE_I2CRSUR_FM 0x0a /* repeated START condition at fast mode */
  83. #define ITE_I2CRSUR_SM 0x50 /* repeated START condition at standard mode */
  84. /* STOP setup Time Register ITE_I2CPSUR */
  85. /* FIFO Data Register ITE_I2CFDR */
  86. #define ITE_I2CFDR_MASK 0xff
  87. /* FIFO Byte Count Register ITE_I2CFBCR */
  88. #define ITE_I2CFBCR_MASK 0x3f
  89. /* FIFO Control Register ITE_I2CFCR */
  90. #define ITE_I2CFCR_FLUSH 0x01 /* Flush FIFO and reset the FIFO point
  91. and I2CFSR */
  92. /* FIFO Status Register ITE_I2CFSR */
  93. #define ITE_I2CFSR_FO 0x01 /* FIFO is overrun when write */
  94. #define ITE_I2CFSR_FU 0x02 /* FIFO is underrun when read */
  95. #define ITE_I2CFSR_FF 0x04 /* FIFO is full when write */
  96. #define ITE_I2CFSR_FE 0x08 /* FIFO is empty when read */
  97. #endif /* I2C_ITE_H */