2016-06-06 17:59:29 +02:00
|
|
|
/*
|
|
|
|
* ASPEED AST2400 I2C Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 IBM Corp.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2019-08-12 07:23:31 +02:00
|
|
|
|
2016-06-06 17:59:29 +02:00
|
|
|
#ifndef ASPEED_I2C_H
|
|
|
|
#define ASPEED_I2C_H
|
|
|
|
|
|
|
|
#include "hw/i2c/i2c.h"
|
2019-08-12 07:23:31 +02:00
|
|
|
#include "hw/sysbus.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2016-06-06 17:59:29 +02:00
|
|
|
|
|
|
|
#define TYPE_ASPEED_I2C "aspeed.i2c"
|
2019-09-25 16:32:40 +02:00
|
|
|
#define TYPE_ASPEED_2400_I2C TYPE_ASPEED_I2C "-ast2400"
|
|
|
|
#define TYPE_ASPEED_2500_I2C TYPE_ASPEED_I2C "-ast2500"
|
2019-09-25 16:32:41 +02:00
|
|
|
#define TYPE_ASPEED_2600_I2C TYPE_ASPEED_I2C "-ast2600"
|
2020-09-16 20:25:18 +02:00
|
|
|
OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, ASPEED_I2C)
|
2016-06-06 17:59:29 +02:00
|
|
|
|
2019-09-25 16:32:41 +02:00
|
|
|
#define ASPEED_I2C_NR_BUSSES 16
|
2019-11-19 15:11:55 +01:00
|
|
|
#define ASPEED_I2C_MAX_POOL_SIZE 0x800
|
2016-06-06 17:59:29 +02:00
|
|
|
|
|
|
|
struct AspeedI2CState;
|
|
|
|
|
2021-10-12 08:20:08 +02:00
|
|
|
#define TYPE_ASPEED_I2C_BUS "aspeed.i2c.bus"
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(AspeedI2CBus, ASPEED_I2C_BUS)
|
|
|
|
struct AspeedI2CBus {
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2016-06-06 17:59:29 +02:00
|
|
|
struct AspeedI2CState *controller;
|
|
|
|
|
|
|
|
MemoryRegion mr;
|
|
|
|
|
|
|
|
I2CBus *bus;
|
|
|
|
uint8_t id;
|
2019-09-25 16:32:41 +02:00
|
|
|
qemu_irq irq;
|
2016-06-06 17:59:29 +02:00
|
|
|
|
|
|
|
uint32_t ctrl;
|
|
|
|
uint32_t timing[2];
|
|
|
|
uint32_t intr_ctrl;
|
|
|
|
uint32_t intr_status;
|
|
|
|
uint32_t cmd;
|
|
|
|
uint32_t buf;
|
2019-11-19 15:11:55 +01:00
|
|
|
uint32_t pool_ctrl;
|
2019-11-19 15:11:58 +01:00
|
|
|
uint32_t dma_addr;
|
|
|
|
uint32_t dma_len;
|
2021-10-12 08:20:08 +02:00
|
|
|
};
|
2016-06-06 17:59:29 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct AspeedI2CState {
|
2016-06-06 17:59:29 +02:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
MemoryRegion iomem;
|
|
|
|
qemu_irq irq;
|
|
|
|
|
|
|
|
uint32_t intr_status;
|
2019-11-19 15:11:56 +01:00
|
|
|
uint32_t ctrl_global;
|
2019-11-19 15:11:55 +01:00
|
|
|
MemoryRegion pool_iomem;
|
|
|
|
uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE];
|
2016-06-06 17:59:29 +02:00
|
|
|
|
|
|
|
AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES];
|
2019-11-19 15:11:58 +01:00
|
|
|
MemoryRegion *dram_mr;
|
|
|
|
AddressSpace dram_as;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2016-06-06 17:59:29 +02:00
|
|
|
|
2019-09-25 16:32:40 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct AspeedI2CClass {
|
2019-09-25 16:32:40 +02:00
|
|
|
SysBusDeviceClass parent_class;
|
|
|
|
|
|
|
|
uint8_t num_busses;
|
|
|
|
uint8_t reg_size;
|
|
|
|
uint8_t gap;
|
2019-09-25 16:32:41 +02:00
|
|
|
qemu_irq (*bus_get_irq)(AspeedI2CBus *);
|
2019-11-19 15:11:55 +01:00
|
|
|
|
|
|
|
uint64_t pool_size;
|
|
|
|
hwaddr pool_base;
|
|
|
|
uint8_t *(*bus_pool_base)(AspeedI2CBus *);
|
2019-11-19 15:11:56 +01:00
|
|
|
bool check_sram;
|
2019-11-19 15:11:58 +01:00
|
|
|
bool has_dma;
|
2019-11-19 15:11:56 +01:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2019-09-25 16:32:40 +02:00
|
|
|
|
2020-07-06 00:41:50 +02:00
|
|
|
I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr);
|
2016-06-06 17:59:29 +02:00
|
|
|
|
|
|
|
#endif /* ASPEED_I2C_H */
|