xref: /openbmc/qemu/include/hw/i2c/imx_i2c.h (revision 4dad0a9aa818698e0735c8352bf7925a1660df6f)
120d0f9cfSJean-Christophe Dubois /*
220d0f9cfSJean-Christophe Dubois  *  i.MX I2C Bus Serial Interface registers definition
320d0f9cfSJean-Christophe Dubois  *
420d0f9cfSJean-Christophe Dubois  *  Copyright (C) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net>
520d0f9cfSJean-Christophe Dubois  *
620d0f9cfSJean-Christophe Dubois  *  This program is free software; you can redistribute it and/or modify it
720d0f9cfSJean-Christophe Dubois  *  under the terms of the GNU General Public License as published by the
820d0f9cfSJean-Christophe Dubois  *  Free Software Foundation; either version 2 of the License, or
920d0f9cfSJean-Christophe Dubois  *  (at your option) any later version.
1020d0f9cfSJean-Christophe Dubois  *
1120d0f9cfSJean-Christophe Dubois  *  This program is distributed in the hope that it will be useful, but WITHOUT
1220d0f9cfSJean-Christophe Dubois  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1320d0f9cfSJean-Christophe Dubois  *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1420d0f9cfSJean-Christophe Dubois  *  for more details.
1520d0f9cfSJean-Christophe Dubois  *
1620d0f9cfSJean-Christophe Dubois  *  You should have received a copy of the GNU General Public License along
1720d0f9cfSJean-Christophe Dubois  *  with this program; if not, see <http://www.gnu.org/licenses/>.
1820d0f9cfSJean-Christophe Dubois  *
1920d0f9cfSJean-Christophe Dubois  */
2020d0f9cfSJean-Christophe Dubois 
212a6a4076SMarkus Armbruster #ifndef IMX_I2C_H
222a6a4076SMarkus Armbruster #define IMX_I2C_H
2320d0f9cfSJean-Christophe Dubois 
24a9c94277SMarkus Armbruster #include "hw/sysbus.h"
25db1015e9SEduardo Habkost #include "qom/object.h"
2620d0f9cfSJean-Christophe Dubois 
2720d0f9cfSJean-Christophe Dubois #define TYPE_IMX_I2C "imx.i2c"
28*8063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IMXI2CState, IMX_I2C)
2920d0f9cfSJean-Christophe Dubois 
3020d0f9cfSJean-Christophe Dubois #define IMX_I2C_MEM_SIZE           0x14
3120d0f9cfSJean-Christophe Dubois 
3220d0f9cfSJean-Christophe Dubois /* i.MX I2C memory map */
3320d0f9cfSJean-Christophe Dubois #define IADR_ADDR                  0x00  /* address register */
3420d0f9cfSJean-Christophe Dubois #define IFDR_ADDR                  0x04  /* frequency divider register */
3520d0f9cfSJean-Christophe Dubois #define I2CR_ADDR                  0x08  /* control register */
3620d0f9cfSJean-Christophe Dubois #define I2SR_ADDR                  0x0c  /* status register */
3720d0f9cfSJean-Christophe Dubois #define I2DR_ADDR                  0x10  /* data register */
3820d0f9cfSJean-Christophe Dubois 
3920d0f9cfSJean-Christophe Dubois #define IADR_MASK                  0xFE
4020d0f9cfSJean-Christophe Dubois #define IADR_RESET                 0
4120d0f9cfSJean-Christophe Dubois 
4220d0f9cfSJean-Christophe Dubois #define IFDR_MASK                  0x3F
4320d0f9cfSJean-Christophe Dubois #define IFDR_RESET                 0
4420d0f9cfSJean-Christophe Dubois 
4520d0f9cfSJean-Christophe Dubois #define I2CR_IEN                   (1 << 7)
4620d0f9cfSJean-Christophe Dubois #define I2CR_IIEN                  (1 << 6)
4720d0f9cfSJean-Christophe Dubois #define I2CR_MSTA                  (1 << 5)
4820d0f9cfSJean-Christophe Dubois #define I2CR_MTX                   (1 << 4)
4920d0f9cfSJean-Christophe Dubois #define I2CR_TXAK                  (1 << 3)
5020d0f9cfSJean-Christophe Dubois #define I2CR_RSTA                  (1 << 2)
5120d0f9cfSJean-Christophe Dubois #define I2CR_MASK                  0xFC
5220d0f9cfSJean-Christophe Dubois #define I2CR_RESET                 0
5320d0f9cfSJean-Christophe Dubois 
5420d0f9cfSJean-Christophe Dubois #define I2SR_ICF                   (1 << 7)
5520d0f9cfSJean-Christophe Dubois #define I2SR_IAAF                  (1 << 6)
5620d0f9cfSJean-Christophe Dubois #define I2SR_IBB                   (1 << 5)
5720d0f9cfSJean-Christophe Dubois #define I2SR_IAL                   (1 << 4)
5820d0f9cfSJean-Christophe Dubois #define I2SR_SRW                   (1 << 2)
5920d0f9cfSJean-Christophe Dubois #define I2SR_IIF                   (1 << 1)
6020d0f9cfSJean-Christophe Dubois #define I2SR_RXAK                  (1 << 0)
6120d0f9cfSJean-Christophe Dubois #define I2SR_MASK                  0xE9
6220d0f9cfSJean-Christophe Dubois #define I2SR_RESET                 0x81
6320d0f9cfSJean-Christophe Dubois 
6420d0f9cfSJean-Christophe Dubois #define I2DR_MASK                  0xFF
6520d0f9cfSJean-Christophe Dubois #define I2DR_RESET                 0
6620d0f9cfSJean-Christophe Dubois 
6720d0f9cfSJean-Christophe Dubois #define ADDR_RESET                 0xFF00
6820d0f9cfSJean-Christophe Dubois 
69db1015e9SEduardo Habkost struct IMXI2CState {
7020d0f9cfSJean-Christophe Dubois     /*< private >*/
7120d0f9cfSJean-Christophe Dubois     SysBusDevice parent_obj;
7220d0f9cfSJean-Christophe Dubois 
7320d0f9cfSJean-Christophe Dubois     /*< public >*/
7420d0f9cfSJean-Christophe Dubois     MemoryRegion iomem;
7520d0f9cfSJean-Christophe Dubois     I2CBus *bus;
7620d0f9cfSJean-Christophe Dubois     qemu_irq irq;
7720d0f9cfSJean-Christophe Dubois 
7820d0f9cfSJean-Christophe Dubois     uint16_t  address;
7920d0f9cfSJean-Christophe Dubois 
8020d0f9cfSJean-Christophe Dubois     uint16_t iadr;
8120d0f9cfSJean-Christophe Dubois     uint16_t ifdr;
8220d0f9cfSJean-Christophe Dubois     uint16_t i2cr;
8320d0f9cfSJean-Christophe Dubois     uint16_t i2sr;
8420d0f9cfSJean-Christophe Dubois     uint16_t i2dr_read;
8520d0f9cfSJean-Christophe Dubois     uint16_t i2dr_write;
86db1015e9SEduardo Habkost };
8720d0f9cfSJean-Christophe Dubois 
882a6a4076SMarkus Armbruster #endif /* IMX_I2C_H */
89