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; 55545d6befSCédric Le Goater uint32_t dma_addr; 56545d6befSCédric Le Goater uint32_t dma_len; 5716020011SCédric Le Goater } AspeedI2CBus; 5816020011SCédric Le Goater 5916020011SCédric Le Goater typedef struct AspeedI2CState { 6016020011SCédric Le Goater SysBusDevice parent_obj; 6116020011SCédric Le Goater 6216020011SCédric Le Goater MemoryRegion iomem; 6316020011SCédric Le Goater qemu_irq irq; 6416020011SCédric Le Goater 6516020011SCédric Le Goater uint32_t intr_status; 66aab90b1cSCédric Le Goater uint32_t ctrl_global; 676054fc73SCédric Le Goater MemoryRegion pool_iomem; 686054fc73SCédric Le Goater uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; 6916020011SCédric Le Goater 7016020011SCédric Le Goater AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; 71545d6befSCédric Le Goater MemoryRegion *dram_mr; 72545d6befSCédric Le Goater AddressSpace dram_as; 7316020011SCédric Le Goater } AspeedI2CState; 7416020011SCédric Le Goater 75f7da1aa8SCédric Le Goater #define ASPEED_I2C_CLASS(klass) \ 76f7da1aa8SCédric Le Goater OBJECT_CLASS_CHECK(AspeedI2CClass, (klass), TYPE_ASPEED_I2C) 77f7da1aa8SCédric Le Goater #define ASPEED_I2C_GET_CLASS(obj) \ 78f7da1aa8SCédric Le Goater OBJECT_GET_CLASS(AspeedI2CClass, (obj), TYPE_ASPEED_I2C) 79f7da1aa8SCédric Le Goater 80f7da1aa8SCédric Le Goater typedef 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 94f7da1aa8SCédric Le Goater } AspeedI2CClass; 95f7da1aa8SCédric Le Goater 96*7a204cbdSPhilippe Mathieu-Daudé I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr); 9716020011SCédric Le Goater 9816020011SCédric Le Goater #endif /* ASPEED_I2C_H */ 99