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" 26db1015e9SEduardo Habkost #include "qom/object.h" 2716020011SCédric Le Goater 2816020011SCédric Le Goater #define TYPE_ASPEED_I2C "aspeed.i2c" 29f7da1aa8SCédric Le Goater #define TYPE_ASPEED_2400_I2C TYPE_ASPEED_I2C "-ast2400" 30f7da1aa8SCédric Le Goater #define TYPE_ASPEED_2500_I2C TYPE_ASPEED_I2C "-ast2500" 3151dd4923SCédric Le Goater #define TYPE_ASPEED_2600_I2C TYPE_ASPEED_I2C "-ast2600" 32a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, 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 39*60261038SCédric Le Goater #define TYPE_ASPEED_I2C_BUS "aspeed.i2c.bus" 40*60261038SCédric Le Goater OBJECT_DECLARE_SIMPLE_TYPE(AspeedI2CBus, ASPEED_I2C_BUS) 41*60261038SCédric Le Goater struct AspeedI2CBus { 42*60261038SCédric Le Goater SysBusDevice parent_obj; 43*60261038SCédric Le Goater 4416020011SCédric Le Goater struct AspeedI2CState *controller; 4516020011SCédric Le Goater 4616020011SCédric Le Goater MemoryRegion mr; 4716020011SCédric Le Goater 4816020011SCédric Le Goater I2CBus *bus; 4916020011SCédric Le Goater uint8_t id; 5051dd4923SCédric Le Goater qemu_irq irq; 5116020011SCédric Le Goater 5216020011SCédric Le Goater uint32_t ctrl; 5316020011SCédric Le Goater uint32_t timing[2]; 5416020011SCédric Le Goater uint32_t intr_ctrl; 5516020011SCédric Le Goater uint32_t intr_status; 5616020011SCédric Le Goater uint32_t cmd; 5716020011SCédric Le Goater uint32_t buf; 586054fc73SCédric Le Goater uint32_t pool_ctrl; 59545d6befSCédric Le Goater uint32_t dma_addr; 60545d6befSCédric Le Goater uint32_t dma_len; 61*60261038SCédric Le Goater }; 6216020011SCédric Le Goater 63db1015e9SEduardo Habkost struct AspeedI2CState { 6416020011SCédric Le Goater SysBusDevice parent_obj; 6516020011SCédric Le Goater 6616020011SCédric Le Goater MemoryRegion iomem; 6716020011SCédric Le Goater qemu_irq irq; 6816020011SCédric Le Goater 6916020011SCédric Le Goater uint32_t intr_status; 70aab90b1cSCédric Le Goater uint32_t ctrl_global; 716054fc73SCédric Le Goater MemoryRegion pool_iomem; 726054fc73SCédric Le Goater uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; 7316020011SCédric Le Goater 7416020011SCédric Le Goater AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; 75545d6befSCédric Le Goater MemoryRegion *dram_mr; 76545d6befSCédric Le Goater AddressSpace dram_as; 77db1015e9SEduardo Habkost }; 7816020011SCédric Le Goater 79f7da1aa8SCédric Le Goater 80db1015e9SEduardo Habkost struct AspeedI2CClass { 81f7da1aa8SCédric Le Goater SysBusDeviceClass parent_class; 82f7da1aa8SCédric Le Goater 83f7da1aa8SCédric Le Goater uint8_t num_busses; 84f7da1aa8SCédric Le Goater uint8_t reg_size; 85f7da1aa8SCédric Le Goater uint8_t gap; 8651dd4923SCédric Le Goater qemu_irq (*bus_get_irq)(AspeedI2CBus *); 876054fc73SCédric Le Goater 886054fc73SCédric Le Goater uint64_t pool_size; 896054fc73SCédric Le Goater hwaddr pool_base; 906054fc73SCédric Le Goater uint8_t *(*bus_pool_base)(AspeedI2CBus *); 91aab90b1cSCédric Le Goater bool check_sram; 92545d6befSCédric Le Goater bool has_dma; 93aab90b1cSCédric Le Goater 94db1015e9SEduardo Habkost }; 95f7da1aa8SCédric Le Goater 967a204cbdSPhilippe Mathieu-Daudé I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr); 9716020011SCédric Le Goater 9816020011SCédric Le Goater #endif /* ASPEED_I2C_H */ 99