2016-06-06 18:59:29 +03: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 08:23:31 +03:00
|
|
|
|
2016-06-06 18:59:29 +03:00
|
|
|
#ifndef ASPEED_I2C_H
|
|
|
|
#define ASPEED_I2C_H
|
|
|
|
|
|
|
|
#include "hw/i2c/i2c.h"
|
2019-08-12 08:23:31 +03:00
|
|
|
#include "hw/sysbus.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2016-06-06 18:59:29 +03:00
|
|
|
|
|
|
|
#define TYPE_ASPEED_I2C "aspeed.i2c"
|
2019-09-25 17:32:40 +03:00
|
|
|
#define TYPE_ASPEED_2400_I2C TYPE_ASPEED_I2C "-ast2400"
|
|
|
|
#define TYPE_ASPEED_2500_I2C TYPE_ASPEED_I2C "-ast2500"
|
2019-09-25 17:32:41 +03:00
|
|
|
#define TYPE_ASPEED_2600_I2C TYPE_ASPEED_I2C "-ast2600"
|
2020-09-16 21:25:18 +03:00
|
|
|
OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, ASPEED_I2C)
|
2016-06-06 18:59:29 +03:00
|
|
|
|
2019-09-25 17:32:41 +03:00
|
|
|
#define ASPEED_I2C_NR_BUSSES 16
|
2019-11-19 17:11:55 +03:00
|
|
|
#define ASPEED_I2C_MAX_POOL_SIZE 0x800
|
2016-06-06 18:59:29 +03:00
|
|
|
|
|
|
|
struct AspeedI2CState;
|
|
|
|
|
|
|
|
typedef struct AspeedI2CBus {
|
|
|
|
struct AspeedI2CState *controller;
|
|
|
|
|
|
|
|
MemoryRegion mr;
|
|
|
|
|
|
|
|
I2CBus *bus;
|
|
|
|
uint8_t id;
|
2019-09-25 17:32:41 +03:00
|
|
|
qemu_irq irq;
|
2016-06-06 18:59:29 +03: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 17:11:55 +03:00
|
|
|
uint32_t pool_ctrl;
|
2019-11-19 17:11:58 +03:00
|
|
|
uint32_t dma_addr;
|
|
|
|
uint32_t dma_len;
|
2016-06-06 18:59:29 +03:00
|
|
|
} AspeedI2CBus;
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct AspeedI2CState {
|
2016-06-06 18:59:29 +03:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
MemoryRegion iomem;
|
|
|
|
qemu_irq irq;
|
|
|
|
|
|
|
|
uint32_t intr_status;
|
2019-11-19 17:11:56 +03:00
|
|
|
uint32_t ctrl_global;
|
2019-11-19 17:11:55 +03:00
|
|
|
MemoryRegion pool_iomem;
|
|
|
|
uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE];
|
2016-06-06 18:59:29 +03:00
|
|
|
|
|
|
|
AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES];
|
2019-11-19 17:11:58 +03:00
|
|
|
MemoryRegion *dram_mr;
|
|
|
|
AddressSpace dram_as;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2016-06-06 18:59:29 +03:00
|
|
|
|
2019-09-25 17:32:40 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct AspeedI2CClass {
|
2019-09-25 17:32:40 +03:00
|
|
|
SysBusDeviceClass parent_class;
|
|
|
|
|
|
|
|
uint8_t num_busses;
|
|
|
|
uint8_t reg_size;
|
|
|
|
uint8_t gap;
|
2019-09-25 17:32:41 +03:00
|
|
|
qemu_irq (*bus_get_irq)(AspeedI2CBus *);
|
2019-11-19 17:11:55 +03:00
|
|
|
|
|
|
|
uint64_t pool_size;
|
|
|
|
hwaddr pool_base;
|
|
|
|
uint8_t *(*bus_pool_base)(AspeedI2CBus *);
|
2019-11-19 17:11:56 +03:00
|
|
|
bool check_sram;
|
2019-11-19 17:11:58 +03:00
|
|
|
bool has_dma;
|
2019-11-19 17:11:56 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2019-09-25 17:32:40 +03:00
|
|
|
|
2020-07-06 01:41:50 +03:00
|
|
|
I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr);
|
2016-06-06 18:59:29 +03:00
|
|
|
|
|
|
|
#endif /* ASPEED_I2C_H */
|