116020011SCédric Le Goater /* 216020011SCédric Le Goater * ASPEED AST2400 I2C Controller 316020011SCédric Le Goater * 416020011SCédric Le Goater * Copyright (C) 2016 IBM Corp. 516020011SCédric Le Goater * 616020011SCédric Le Goater * This program is free software; you can redistribute it and/or modify 716020011SCédric Le Goater * it under the terms of the GNU General Public License as published by 816020011SCédric Le Goater * the Free Software Foundation; either version 2 of the License, or 916020011SCédric Le Goater * (at your option) any later version. 1016020011SCédric Le Goater * 1116020011SCédric Le Goater * This program is distributed in the hope that it will be useful, 1216020011SCédric Le Goater * but WITHOUT ANY WARRANTY; without even the implied warranty of 1316020011SCédric Le Goater * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1416020011SCédric Le Goater * GNU General Public License for more details. 1516020011SCédric Le Goater * 1616020011SCédric Le Goater * You should have received a copy of the GNU General Public License along 1716020011SCédric Le Goater * with this program; if not, write to the Free Software Foundation, Inc., 1816020011SCédric Le Goater * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 1916020011SCédric Le Goater */ 20ec150c7eSMarkus Armbruster 2116020011SCédric Le Goater #ifndef ASPEED_I2C_H 2216020011SCédric Le Goater #define ASPEED_I2C_H 2316020011SCédric Le Goater 2416020011SCédric Le Goater #include "hw/i2c/i2c.h" 25ec150c7eSMarkus Armbruster #include "hw/sysbus.h" 2616020011SCédric Le Goater 2716020011SCédric Le Goater #define TYPE_ASPEED_I2C "aspeed.i2c" 28f7da1aa8SCédric Le Goater #define TYPE_ASPEED_2400_I2C TYPE_ASPEED_I2C "-ast2400" 29f7da1aa8SCédric Le Goater #define TYPE_ASPEED_2500_I2C TYPE_ASPEED_I2C "-ast2500" 3051dd4923SCédric Le Goater #define TYPE_ASPEED_2600_I2C TYPE_ASPEED_I2C "-ast2600" 3116020011SCédric Le Goater #define ASPEED_I2C(obj) \ 3216020011SCédric Le Goater OBJECT_CHECK(AspeedI2CState, (obj), TYPE_ASPEED_I2C) 3316020011SCédric Le Goater 3451dd4923SCédric Le Goater #define ASPEED_I2C_NR_BUSSES 16 356054fc73SCédric Le Goater #define ASPEED_I2C_MAX_POOL_SIZE 0x800 3616020011SCédric Le Goater 3716020011SCédric Le Goater struct AspeedI2CState; 3816020011SCédric Le Goater 3916020011SCédric Le Goater typedef struct AspeedI2CBus { 4016020011SCédric Le Goater struct AspeedI2CState *controller; 4116020011SCédric Le Goater 4216020011SCédric Le Goater MemoryRegion mr; 4316020011SCédric Le Goater 4416020011SCédric Le Goater I2CBus *bus; 4516020011SCédric Le Goater uint8_t id; 4651dd4923SCédric Le Goater qemu_irq irq; 4716020011SCédric Le Goater 4816020011SCédric Le Goater uint32_t ctrl; 4916020011SCédric Le Goater uint32_t timing[2]; 5016020011SCédric Le Goater uint32_t intr_ctrl; 5116020011SCédric Le Goater uint32_t intr_status; 5216020011SCédric Le Goater uint32_t cmd; 5316020011SCédric Le Goater uint32_t buf; 546054fc73SCédric Le Goater uint32_t pool_ctrl; 5516020011SCédric Le Goater } AspeedI2CBus; 5616020011SCédric Le Goater 5716020011SCédric Le Goater typedef struct AspeedI2CState { 5816020011SCédric Le Goater SysBusDevice parent_obj; 5916020011SCédric Le Goater 6016020011SCédric Le Goater MemoryRegion iomem; 6116020011SCédric Le Goater qemu_irq irq; 6216020011SCédric Le Goater 6316020011SCédric Le Goater uint32_t intr_status; 64*aab90b1cSCédric Le Goater uint32_t ctrl_global; 656054fc73SCédric Le Goater MemoryRegion pool_iomem; 666054fc73SCédric Le Goater uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; 6716020011SCédric Le Goater 6816020011SCédric Le Goater AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; 6916020011SCédric Le Goater } AspeedI2CState; 7016020011SCédric Le Goater 71f7da1aa8SCédric Le Goater #define ASPEED_I2C_CLASS(klass) \ 72f7da1aa8SCédric Le Goater OBJECT_CLASS_CHECK(AspeedI2CClass, (klass), TYPE_ASPEED_I2C) 73f7da1aa8SCédric Le Goater #define ASPEED_I2C_GET_CLASS(obj) \ 74f7da1aa8SCédric Le Goater OBJECT_GET_CLASS(AspeedI2CClass, (obj), TYPE_ASPEED_I2C) 75f7da1aa8SCédric Le Goater 76f7da1aa8SCédric Le Goater typedef struct AspeedI2CClass { 77f7da1aa8SCédric Le Goater SysBusDeviceClass parent_class; 78f7da1aa8SCédric Le Goater 79f7da1aa8SCédric Le Goater uint8_t num_busses; 80f7da1aa8SCédric Le Goater uint8_t reg_size; 81f7da1aa8SCédric Le Goater uint8_t gap; 8251dd4923SCédric Le Goater qemu_irq (*bus_get_irq)(AspeedI2CBus *); 836054fc73SCédric Le Goater 846054fc73SCédric Le Goater uint64_t pool_size; 856054fc73SCédric Le Goater hwaddr pool_base; 866054fc73SCédric Le Goater uint8_t *(*bus_pool_base)(AspeedI2CBus *); 87*aab90b1cSCédric Le Goater bool check_sram; 88*aab90b1cSCédric Le Goater 89f7da1aa8SCédric Le Goater } AspeedI2CClass; 90f7da1aa8SCédric Le Goater 9116020011SCédric Le Goater I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); 9216020011SCédric Le Goater 9316020011SCédric Le Goater #endif /* ASPEED_I2C_H */ 94