i2c-ibm_iic.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * drivers/i2c/busses/i2c-ibm_iic.h
  3. *
  4. * Support for the IIC peripheral on IBM PPC 4xx
  5. *
  6. * Copyright (c) 2003 Zultys Technologies.
  7. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  8. *
  9. * Based on original work by
  10. * Ian DaSilva <idasilva@mvista.com>
  11. * Armin Kuster <akuster@mvista.com>
  12. * Matt Porter <mporter@mvista.com>
  13. *
  14. * Copyright 2000-2003 MontaVista Software Inc.
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the
  18. * Free Software Foundation; either version 2 of the License, or (at your
  19. * option) any later version.
  20. *
  21. */
  22. #ifndef __I2C_IBM_IIC_H_
  23. #define __I2C_IBM_IIC_H_
  24. #include <linux/i2c.h>
  25. struct iic_regs {
  26. u16 mdbuf;
  27. u16 sbbuf;
  28. u8 lmadr;
  29. u8 hmadr;
  30. u8 cntl;
  31. u8 mdcntl;
  32. u8 sts;
  33. u8 extsts;
  34. u8 lsadr;
  35. u8 hsadr;
  36. u8 clkdiv;
  37. u8 intmsk;
  38. u8 xfrcnt;
  39. u8 xtcntlss;
  40. u8 directcntl;
  41. };
  42. struct ibm_iic_private {
  43. struct i2c_adapter adap;
  44. volatile struct iic_regs __iomem *vaddr;
  45. wait_queue_head_t wq;
  46. int idx;
  47. int irq;
  48. int fast_mode;
  49. u8 clckdiv;
  50. };
  51. /* IICx_CNTL register */
  52. #define CNTL_HMT 0x80
  53. #define CNTL_AMD 0x40
  54. #define CNTL_TCT_MASK 0x30
  55. #define CNTL_TCT_SHIFT 4
  56. #define CNTL_RPST 0x08
  57. #define CNTL_CHT 0x04
  58. #define CNTL_RW 0x02
  59. #define CNTL_PT 0x01
  60. /* IICx_MDCNTL register */
  61. #define MDCNTL_FSDB 0x80
  62. #define MDCNTL_FMDB 0x40
  63. #define MDCNTL_EGC 0x20
  64. #define MDCNTL_FSM 0x10
  65. #define MDCNTL_ESM 0x08
  66. #define MDCNTL_EINT 0x04
  67. #define MDCNTL_EUBS 0x02
  68. #define MDCNTL_HSCL 0x01
  69. /* IICx_STS register */
  70. #define STS_SSS 0x80
  71. #define STS_SLPR 0x40
  72. #define STS_MDBS 0x20
  73. #define STS_MDBF 0x10
  74. #define STS_SCMP 0x08
  75. #define STS_ERR 0x04
  76. #define STS_IRQA 0x02
  77. #define STS_PT 0x01
  78. /* IICx_EXTSTS register */
  79. #define EXTSTS_IRQP 0x80
  80. #define EXTSTS_BCS_MASK 0x70
  81. #define EXTSTS_BCS_FREE 0x40
  82. #define EXTSTS_IRQD 0x08
  83. #define EXTSTS_LA 0x04
  84. #define EXTSTS_ICT 0x02
  85. #define EXTSTS_XFRA 0x01
  86. /* IICx_INTRMSK register */
  87. #define INTRMSK_EIRC 0x80
  88. #define INTRMSK_EIRS 0x40
  89. #define INTRMSK_EIWC 0x20
  90. #define INTRMSK_EIWS 0x10
  91. #define INTRMSK_EIHE 0x08
  92. #define INTRMSK_EIIC 0x04
  93. #define INTRMSK_EITA 0x02
  94. #define INTRMSK_EIMTC 0x01
  95. /* IICx_XFRCNT register */
  96. #define XFRCNT_MTC_MASK 0x07
  97. /* IICx_XTCNTLSS register */
  98. #define XTCNTLSS_SRC 0x80
  99. #define XTCNTLSS_SRS 0x40
  100. #define XTCNTLSS_SWC 0x20
  101. #define XTCNTLSS_SWS 0x10
  102. #define XTCNTLSS_SRST 0x01
  103. /* IICx_DIRECTCNTL register */
  104. #define DIRCNTL_SDAC 0x08
  105. #define DIRCNTL_SCC 0x04
  106. #define DIRCNTL_MSDA 0x02
  107. #define DIRCNTL_MSC 0x01
  108. /* Check if we really control the I2C bus and bus is free */
  109. #define DIRCTNL_FREE(v) (((v) & 0x0f) == 0x0f)
  110. #endif /* __I2C_IBM_IIC_H_ */