i2c-yosemite.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * arch/mips/pmc-sierra/yosemite/i2c-yosemite.h
  3. *
  4. * Copyright (C) 2003 PMC-Sierra Inc.
  5. * Author: Manish Lachwani (lachwani@pmc-sierra.com)
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  15. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  19. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #ifndef __I2C_YOSEMITE_H
  28. #define __I2C_YOSEMITE_H
  29. /* Read and Write operations to the chip */
  30. #define TITAN_I2C_BASE 0xbb000000 /* XXX Needs to change */
  31. #define TITAN_I2C_WRITE(offset, data) \
  32. *(volatile unsigned long *)(TITAN_I2C_BASE + offset) = data
  33. #define TITAN_I2C_READ(offset) *(volatile unsigned long *)(TITAN_I2C_BASE + offset)
  34. /* Local constansts*/
  35. #define TITAN_I2C_MAX_FILTER 15
  36. #define TITAN_I2C_MAX_CLK 1023
  37. #define TITAN_I2C_MAX_ARBF 15
  38. #define TITAN_I2C_MAX_NAK 15
  39. #define TITAN_I2C_MAX_MASTERCODE 7
  40. #define TITAN_I2C_MAX_WORDS_PER_RW 4
  41. #define TITAN_I2C_MAX_POLL 100
  42. /* Registers used for I2C work */
  43. #define TITAN_I2C_SCMB_CONTROL 0x0180 /* SCMB Control */
  44. #define TITAN_I2C_SCMB_CLOCK_A 0x0184 /* SCMB Clock A */
  45. #define TITAN_I2C_SCMB_CLOCK_B 0x0188 /* SCMB Clock B */
  46. #define TITAN_I2C_CONFIG 0x01A0 /* I2C Config */
  47. #define TITAN_I2C_COMMAND 0x01A4 /* I2C Command */
  48. #define TITAN_I2C_SLAVE_ADDRESS 0x01A8 /* I2C Slave Address */
  49. #define TITAN_I2C_DATA 0x01AC /* I2C Data [15:0] */
  50. #define TITAN_I2C_INTERRUPTS 0x01BC /* I2C Interrupts */
  51. /* Error */
  52. #define TITAN_I2C_ERR_ARB_LOST (-9220)
  53. #define TITAN_I2C_ERR_NO_RESP (-9221)
  54. #define TITAN_I2C_ERR_DATA_COLLISION (-9222)
  55. #define TITAN_I2C_ERR_TIMEOUT (-9223)
  56. #define TITAN_I2C_ERR_OK 0
  57. /* I2C Command Type */
  58. typedef enum {
  59. TITAN_I2C_CMD_WRITE = 0,
  60. TITAN_I2C_CMD_READ = 1,
  61. TITAN_I2C_CMD_READ_WRITE = 2
  62. } titan_i2c_cmd_type;
  63. /* I2C structures */
  64. typedef struct {
  65. int filtera; /* Register 0x0184, bits 15 - 12 */
  66. int clka; /* Register 0x0184, bits 9 - 0 */
  67. int filterb; /* Register 0x0188, bits 15 - 12 */
  68. int clkb; /* Register 0x0188, bits 9 - 0 */
  69. } titan_i2c_config;
  70. /* I2C command type */
  71. typedef struct {
  72. titan_i2c_cmd_type type; /* Type of command */
  73. int num_arb; /* Register 0x01a0, bits 15 - 12 */
  74. int num_nak; /* Register 0x01a0, bits 11 - 8 */
  75. int addr_size; /* Register 0x01a0, bit 7 */
  76. int mst_code; /* Register 0x01a0, bits 6 - 4 */
  77. int arb_en; /* Register 0x01a0, bit 1 */
  78. int speed; /* Register 0x01a0, bit 0 */
  79. int slave_addr; /* Register 0x01a8 */
  80. int write_size; /* Register 0x01a4, bits 10 - 8 */
  81. unsigned int *data; /* Register 0x01ac */
  82. } titan_i2c_command;
  83. #endif /* __I2C_YOSEMITE_H */