xref: /qemu/include/hw/i2c/imx_i2c.h (revision 2a6a4076e117113ebec97b1821071afccfdfbc96)
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 
21*2a6a4076SMarkus Armbruster #ifndef IMX_I2C_H
22*2a6a4076SMarkus Armbruster #define IMX_I2C_H
2320d0f9cfSJean-Christophe Dubois 
24a9c94277SMarkus Armbruster #include "hw/sysbus.h"
2520d0f9cfSJean-Christophe Dubois 
2620d0f9cfSJean-Christophe Dubois #define TYPE_IMX_I2C "imx.i2c"
2720d0f9cfSJean-Christophe Dubois #define IMX_I2C(obj) OBJECT_CHECK(IMXI2CState, (obj), TYPE_IMX_I2C)
2820d0f9cfSJean-Christophe Dubois 
2920d0f9cfSJean-Christophe Dubois #define IMX_I2C_MEM_SIZE           0x14
3020d0f9cfSJean-Christophe Dubois 
3120d0f9cfSJean-Christophe Dubois /* i.MX I2C memory map */
3220d0f9cfSJean-Christophe Dubois #define IADR_ADDR                  0x00  /* address register */
3320d0f9cfSJean-Christophe Dubois #define IFDR_ADDR                  0x04  /* frequency divider register */
3420d0f9cfSJean-Christophe Dubois #define I2CR_ADDR                  0x08  /* control register */
3520d0f9cfSJean-Christophe Dubois #define I2SR_ADDR                  0x0c  /* status register */
3620d0f9cfSJean-Christophe Dubois #define I2DR_ADDR                  0x10  /* data register */
3720d0f9cfSJean-Christophe Dubois 
3820d0f9cfSJean-Christophe Dubois #define IADR_MASK                  0xFE
3920d0f9cfSJean-Christophe Dubois #define IADR_RESET                 0
4020d0f9cfSJean-Christophe Dubois 
4120d0f9cfSJean-Christophe Dubois #define IFDR_MASK                  0x3F
4220d0f9cfSJean-Christophe Dubois #define IFDR_RESET                 0
4320d0f9cfSJean-Christophe Dubois 
4420d0f9cfSJean-Christophe Dubois #define I2CR_IEN                   (1 << 7)
4520d0f9cfSJean-Christophe Dubois #define I2CR_IIEN                  (1 << 6)
4620d0f9cfSJean-Christophe Dubois #define I2CR_MSTA                  (1 << 5)
4720d0f9cfSJean-Christophe Dubois #define I2CR_MTX                   (1 << 4)
4820d0f9cfSJean-Christophe Dubois #define I2CR_TXAK                  (1 << 3)
4920d0f9cfSJean-Christophe Dubois #define I2CR_RSTA                  (1 << 2)
5020d0f9cfSJean-Christophe Dubois #define I2CR_MASK                  0xFC
5120d0f9cfSJean-Christophe Dubois #define I2CR_RESET                 0
5220d0f9cfSJean-Christophe Dubois 
5320d0f9cfSJean-Christophe Dubois #define I2SR_ICF                   (1 << 7)
5420d0f9cfSJean-Christophe Dubois #define I2SR_IAAF                  (1 << 6)
5520d0f9cfSJean-Christophe Dubois #define I2SR_IBB                   (1 << 5)
5620d0f9cfSJean-Christophe Dubois #define I2SR_IAL                   (1 << 4)
5720d0f9cfSJean-Christophe Dubois #define I2SR_SRW                   (1 << 2)
5820d0f9cfSJean-Christophe Dubois #define I2SR_IIF                   (1 << 1)
5920d0f9cfSJean-Christophe Dubois #define I2SR_RXAK                  (1 << 0)
6020d0f9cfSJean-Christophe Dubois #define I2SR_MASK                  0xE9
6120d0f9cfSJean-Christophe Dubois #define I2SR_RESET                 0x81
6220d0f9cfSJean-Christophe Dubois 
6320d0f9cfSJean-Christophe Dubois #define I2DR_MASK                  0xFF
6420d0f9cfSJean-Christophe Dubois #define I2DR_RESET                 0
6520d0f9cfSJean-Christophe Dubois 
6620d0f9cfSJean-Christophe Dubois #define ADDR_RESET                 0xFF00
6720d0f9cfSJean-Christophe Dubois 
6820d0f9cfSJean-Christophe Dubois typedef struct IMXI2CState {
6920d0f9cfSJean-Christophe Dubois     /*< private >*/
7020d0f9cfSJean-Christophe Dubois     SysBusDevice parent_obj;
7120d0f9cfSJean-Christophe Dubois 
7220d0f9cfSJean-Christophe Dubois     /*< public >*/
7320d0f9cfSJean-Christophe Dubois     MemoryRegion iomem;
7420d0f9cfSJean-Christophe Dubois     I2CBus *bus;
7520d0f9cfSJean-Christophe Dubois     qemu_irq irq;
7620d0f9cfSJean-Christophe Dubois 
7720d0f9cfSJean-Christophe Dubois     uint16_t  address;
7820d0f9cfSJean-Christophe Dubois 
7920d0f9cfSJean-Christophe Dubois     uint16_t iadr;
8020d0f9cfSJean-Christophe Dubois     uint16_t ifdr;
8120d0f9cfSJean-Christophe Dubois     uint16_t i2cr;
8220d0f9cfSJean-Christophe Dubois     uint16_t i2sr;
8320d0f9cfSJean-Christophe Dubois     uint16_t i2dr_read;
8420d0f9cfSJean-Christophe Dubois     uint16_t i2dr_write;
8520d0f9cfSJean-Christophe Dubois } IMXI2CState;
8620d0f9cfSJean-Christophe Dubois 
87*2a6a4076SMarkus Armbruster #endif /* IMX_I2C_H */
88