xref: /qemu/include/hw/i2c/aspeed_i2c.h (revision 1602001195dca96aaea8b16f740ac860238555a5)
1*16020011SCédric Le Goater /*
2*16020011SCédric Le Goater  *  ASPEED AST2400 I2C Controller
3*16020011SCédric Le Goater  *
4*16020011SCédric Le Goater  *  Copyright (C) 2016 IBM Corp.
5*16020011SCédric Le Goater  *
6*16020011SCédric Le Goater  *  This program is free software; you can redistribute it and/or modify
7*16020011SCédric Le Goater  *  it under the terms of the GNU General Public License as published by
8*16020011SCédric Le Goater  *  the Free Software Foundation; either version 2 of the License, or
9*16020011SCédric Le Goater  *  (at your option) any later version.
10*16020011SCédric Le Goater  *
11*16020011SCédric Le Goater  *  This program is distributed in the hope that it will be useful,
12*16020011SCédric Le Goater  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*16020011SCédric Le Goater  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*16020011SCédric Le Goater  *  GNU General Public License for more details.
15*16020011SCédric Le Goater  *
16*16020011SCédric Le Goater  *  You should have received a copy of the GNU General Public License along
17*16020011SCédric Le Goater  *  with this program; if not, write to the Free Software Foundation, Inc.,
18*16020011SCédric Le Goater  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*16020011SCédric Le Goater  */
20*16020011SCédric Le Goater #ifndef ASPEED_I2C_H
21*16020011SCédric Le Goater #define ASPEED_I2C_H
22*16020011SCédric Le Goater 
23*16020011SCédric Le Goater #include "hw/i2c/i2c.h"
24*16020011SCédric Le Goater 
25*16020011SCédric Le Goater #define TYPE_ASPEED_I2C "aspeed.i2c"
26*16020011SCédric Le Goater #define ASPEED_I2C(obj) \
27*16020011SCédric Le Goater     OBJECT_CHECK(AspeedI2CState, (obj), TYPE_ASPEED_I2C)
28*16020011SCédric Le Goater 
29*16020011SCédric Le Goater #define ASPEED_I2C_NR_BUSSES 14
30*16020011SCédric Le Goater 
31*16020011SCédric Le Goater struct AspeedI2CState;
32*16020011SCédric Le Goater 
33*16020011SCédric Le Goater typedef struct AspeedI2CBus {
34*16020011SCédric Le Goater     struct AspeedI2CState *controller;
35*16020011SCédric Le Goater 
36*16020011SCédric Le Goater     MemoryRegion mr;
37*16020011SCédric Le Goater 
38*16020011SCédric Le Goater     I2CBus *bus;
39*16020011SCédric Le Goater     uint8_t id;
40*16020011SCédric Le Goater 
41*16020011SCédric Le Goater     uint32_t ctrl;
42*16020011SCédric Le Goater     uint32_t timing[2];
43*16020011SCédric Le Goater     uint32_t intr_ctrl;
44*16020011SCédric Le Goater     uint32_t intr_status;
45*16020011SCédric Le Goater     uint32_t cmd;
46*16020011SCédric Le Goater     uint32_t buf;
47*16020011SCédric Le Goater } AspeedI2CBus;
48*16020011SCédric Le Goater 
49*16020011SCédric Le Goater typedef struct AspeedI2CState {
50*16020011SCédric Le Goater     SysBusDevice parent_obj;
51*16020011SCédric Le Goater 
52*16020011SCédric Le Goater     MemoryRegion iomem;
53*16020011SCédric Le Goater     qemu_irq irq;
54*16020011SCédric Le Goater 
55*16020011SCédric Le Goater     uint32_t intr_status;
56*16020011SCédric Le Goater 
57*16020011SCédric Le Goater     AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES];
58*16020011SCédric Le Goater } AspeedI2CState;
59*16020011SCédric Le Goater 
60*16020011SCédric Le Goater I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr);
61*16020011SCédric Le Goater 
62*16020011SCédric Le Goater #endif /* ASPEED_I2C_H */
63