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