imx_i2c.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * i.MX I2C Bus Serial Interface registers definition
  3. *
  4. * Copyright (C) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef IMX_I2C_H
  21. #define IMX_I2C_H
  22. #include "hw/sysbus.h"
  23. #include "qom/object.h"
  24. #define TYPE_IMX_I2C "imx.i2c"
  25. OBJECT_DECLARE_SIMPLE_TYPE(IMXI2CState, IMX_I2C)
  26. #define IMX_I2C_MEM_SIZE 0x14
  27. /* i.MX I2C memory map */
  28. #define IADR_ADDR 0x00 /* address register */
  29. #define IFDR_ADDR 0x04 /* frequency divider register */
  30. #define I2CR_ADDR 0x08 /* control register */
  31. #define I2SR_ADDR 0x0c /* status register */
  32. #define I2DR_ADDR 0x10 /* data register */
  33. #define IADR_MASK 0xFE
  34. #define IADR_RESET 0
  35. #define IFDR_MASK 0x3F
  36. #define IFDR_RESET 0
  37. #define I2CR_IEN (1 << 7)
  38. #define I2CR_IIEN (1 << 6)
  39. #define I2CR_MSTA (1 << 5)
  40. #define I2CR_MTX (1 << 4)
  41. #define I2CR_TXAK (1 << 3)
  42. #define I2CR_RSTA (1 << 2)
  43. #define I2CR_MASK 0xFC
  44. #define I2CR_RESET 0
  45. #define I2SR_ICF (1 << 7)
  46. #define I2SR_IAAF (1 << 6)
  47. #define I2SR_IBB (1 << 5)
  48. #define I2SR_IAL (1 << 4)
  49. #define I2SR_SRW (1 << 2)
  50. #define I2SR_IIF (1 << 1)
  51. #define I2SR_RXAK (1 << 0)
  52. #define I2SR_MASK 0xE9
  53. #define I2SR_RESET 0x81
  54. #define I2DR_MASK 0xFF
  55. #define I2DR_RESET 0
  56. #define ADDR_RESET 0xFF00
  57. struct IMXI2CState {
  58. /*< private >*/
  59. SysBusDevice parent_obj;
  60. /*< public >*/
  61. MemoryRegion iomem;
  62. I2CBus *bus;
  63. qemu_irq irq;
  64. uint16_t address;
  65. uint16_t iadr;
  66. uint16_t ifdr;
  67. uint16_t i2cr;
  68. uint16_t i2sr;
  69. uint16_t i2dr_read;
  70. uint16_t i2dr_write;
  71. };
  72. #endif /* IMX_I2C_H */