spr_i2c.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * (C) Copyright 2009
  3. * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.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 __SPR_I2C_H_
  24. #define __SPR_I2C_H_
  25. struct i2c_regs {
  26. u32 ic_con;
  27. u32 ic_tar;
  28. u32 ic_sar;
  29. u32 ic_hs_maddr;
  30. u32 ic_cmd_data;
  31. u32 ic_ss_scl_hcnt;
  32. u32 ic_ss_scl_lcnt;
  33. u32 ic_fs_scl_hcnt;
  34. u32 ic_fs_scl_lcnt;
  35. u32 ic_hs_scl_hcnt;
  36. u32 ic_hs_scl_lcnt;
  37. u32 ic_intr_stat;
  38. u32 ic_intr_mask;
  39. u32 ic_raw_intr_stat;
  40. u32 ic_rx_tl;
  41. u32 ic_tx_tl;
  42. u32 ic_clr_intr;
  43. u32 ic_clr_rx_under;
  44. u32 ic_clr_rx_over;
  45. u32 ic_clr_tx_over;
  46. u32 ic_clr_rd_req;
  47. u32 ic_clr_tx_abrt;
  48. u32 ic_clr_rx_done;
  49. u32 ic_clr_activity;
  50. u32 ic_clr_stop_det;
  51. u32 ic_clr_start_det;
  52. u32 ic_clr_gen_call;
  53. u32 ic_enable;
  54. u32 ic_status;
  55. u32 ic_txflr;
  56. u32 ix_rxflr;
  57. u32 reserved_1;
  58. u32 ic_tx_abrt_source;
  59. };
  60. #define IC_CLK 166
  61. #define NANO_TO_MICRO 1000
  62. /* High and low times in different speed modes (in ns) */
  63. #define MIN_SS_SCL_HIGHTIME 4000
  64. #define MIN_SS_SCL_LOWTIME 5000
  65. #define MIN_FS_SCL_HIGHTIME 800
  66. #define MIN_FS_SCL_LOWTIME 1700
  67. #define MIN_HS_SCL_HIGHTIME 60
  68. #define MIN_HS_SCL_LOWTIME 160
  69. /* Worst case timeout for 1 byte is kept as 2ms */
  70. #define I2C_BYTE_TO (CONFIG_SYS_HZ/500)
  71. #define I2C_STOPDET_TO (CONFIG_SYS_HZ/500)
  72. #define I2C_BYTE_TO_BB (I2C_BYTE_TO * 16)
  73. /* i2c control register definitions */
  74. #define IC_CON_SD 0x0040
  75. #define IC_CON_RE 0x0020
  76. #define IC_CON_10BITADDRMASTER 0x0010
  77. #define IC_CON_10BITADDR_SLAVE 0x0008
  78. #define IC_CON_SPD_MSK 0x0006
  79. #define IC_CON_SPD_SS 0x0002
  80. #define IC_CON_SPD_FS 0x0004
  81. #define IC_CON_SPD_HS 0x0006
  82. #define IC_CON_MM 0x0001
  83. /* i2c target address register definitions */
  84. #define TAR_ADDR 0x0050
  85. /* i2c slave address register definitions */
  86. #define IC_SLAVE_ADDR 0x0002
  87. /* i2c data buffer and command register definitions */
  88. #define IC_CMD 0x0100
  89. /* i2c interrupt status register definitions */
  90. #define IC_GEN_CALL 0x0800
  91. #define IC_START_DET 0x0400
  92. #define IC_STOP_DET 0x0200
  93. #define IC_ACTIVITY 0x0100
  94. #define IC_RX_DONE 0x0080
  95. #define IC_TX_ABRT 0x0040
  96. #define IC_RD_REQ 0x0020
  97. #define IC_TX_EMPTY 0x0010
  98. #define IC_TX_OVER 0x0008
  99. #define IC_RX_FULL 0x0004
  100. #define IC_RX_OVER 0x0002
  101. #define IC_RX_UNDER 0x0001
  102. /* fifo threshold register definitions */
  103. #define IC_TL0 0x00
  104. #define IC_TL1 0x01
  105. #define IC_TL2 0x02
  106. #define IC_TL3 0x03
  107. #define IC_TL4 0x04
  108. #define IC_TL5 0x05
  109. #define IC_TL6 0x06
  110. #define IC_TL7 0x07
  111. #define IC_RX_TL IC_TL0
  112. #define IC_TX_TL IC_TL0
  113. /* i2c enable register definitions */
  114. #define IC_ENABLE_0B 0x0001
  115. /* i2c status register definitions */
  116. #define IC_STATUS_SA 0x0040
  117. #define IC_STATUS_MA 0x0020
  118. #define IC_STATUS_RFF 0x0010
  119. #define IC_STATUS_RFNE 0x0008
  120. #define IC_STATUS_TFE 0x0004
  121. #define IC_STATUS_TFNF 0x0002
  122. #define IC_STATUS_ACT 0x0001
  123. /* Speed Selection */
  124. #define IC_SPEED_MODE_STANDARD 1
  125. #define IC_SPEED_MODE_FAST 2
  126. #define IC_SPEED_MODE_MAX 3
  127. #define I2C_MAX_SPEED 3400000
  128. #define I2C_FAST_SPEED 400000
  129. #define I2C_STANDARD_SPEED 100000
  130. #endif /* __SPR_I2C_H_ */