fti2c010.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Faraday I2C Controller
  3. *
  4. * (C) Copyright 2010 Faraday Technology
  5. * Dante Su <dantesu@faraday-tech.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __FTI2C010_H
  10. #define __FTI2C010_H
  11. /*
  12. * FTI2C010 registers
  13. */
  14. struct fti2c010_regs {
  15. uint32_t cr; /* 0x00: control register */
  16. uint32_t sr; /* 0x04: status register */
  17. uint32_t cdr; /* 0x08: clock division register */
  18. uint32_t dr; /* 0x0c: data register */
  19. uint32_t sar; /* 0x10: slave address register */
  20. uint32_t tgsr;/* 0x14: time & glitch suppression register */
  21. uint32_t bmr; /* 0x18: bus monitor register */
  22. uint32_t rsvd[5];
  23. uint32_t revr;/* 0x30: revision register */
  24. };
  25. /*
  26. * control register
  27. */
  28. #define CR_ALIRQ 0x2000 /* arbitration lost interrupt (master) */
  29. #define CR_SAMIRQ 0x1000 /* slave address match interrupt (slave) */
  30. #define CR_STOPIRQ 0x800 /* stop condition interrupt (slave) */
  31. #define CR_NAKRIRQ 0x400 /* NACK response interrupt (master) */
  32. #define CR_DRIRQ 0x200 /* rx interrupt (both) */
  33. #define CR_DTIRQ 0x100 /* tx interrupt (both) */
  34. #define CR_TBEN 0x80 /* tx enable (both) */
  35. #define CR_NAK 0x40 /* NACK (both) */
  36. #define CR_STOP 0x20 /* stop (master) */
  37. #define CR_START 0x10 /* start (master) */
  38. #define CR_GCEN 0x8 /* general call support (slave) */
  39. #define CR_SCLEN 0x4 /* enable clock out (master) */
  40. #define CR_I2CEN 0x2 /* enable I2C (both) */
  41. #define CR_I2CRST 0x1 /* reset I2C (both) */
  42. #define CR_ENABLE \
  43. (CR_ALIRQ | CR_NAKRIRQ | CR_DRIRQ | CR_DTIRQ | CR_SCLEN | CR_I2CEN)
  44. /*
  45. * status register
  46. */
  47. #define SR_CLRAL 0x400 /* clear arbitration lost */
  48. #define SR_CLRGC 0x200 /* clear general call */
  49. #define SR_CLRSAM 0x100 /* clear slave address match */
  50. #define SR_CLRSTOP 0x80 /* clear stop */
  51. #define SR_CLRNAKR 0x40 /* clear NACK respond */
  52. #define SR_DR 0x20 /* rx ready */
  53. #define SR_DT 0x10 /* tx done */
  54. #define SR_BB 0x8 /* bus busy */
  55. #define SR_BUSY 0x4 /* chip busy */
  56. #define SR_ACK 0x2 /* ACK/NACK received */
  57. #define SR_RW 0x1 /* set when master-rx or slave-tx mode */
  58. /*
  59. * clock division register
  60. */
  61. #define CDR_DIV(n) ((n) & 0x3ffff)
  62. /*
  63. * time & glitch suppression register
  64. */
  65. #define TGSR_GSR(n) (((n) & 0x7) << 10)
  66. #define TGSR_TSR(n) ((n) & 0x3ff)
  67. /*
  68. * bus monitor register
  69. */
  70. #define BMR_SCL 0x2 /* SCL is pull-up */
  71. #define BMR_SDA 0x1 /* SDA is pull-up */
  72. #endif /* __FTI2C010_H */