aspeed queue
The following changes since commit ea9cdbcf3a0b8d5497cddf87990f1b39d8f3bb0a:
Merge tag 'hw-misc-20240913' of https://github.com/philmd/qemu into staging (2024-09-15 18:27:40 +0100)
are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-aspeed-20240916
for you to fetch changes up to a93bb519e683fd8f8d7945e5517fd5ad74cc41c0:
machine_aspeed.py: Update to test I2C for AST2700 (2024-09-16 17:44:08 +0200)
----------------------------------------------------------------
aspeed queue:
* I2C support for AST2700
* Coverity fixes
----------------------------------------------------------------
Jamin Lin (11):
hw/i2c/aspeed: Support discontinuous register memory region of I2C bus hw/i2c/aspeed: Introduce a new bus pool buffer attribute in AspeedI2Cbus hw/i2c/aspeed: Support discontinuous poll buffer memory region of I2C bus hw/i2c/aspeed: Introduce a new dma_dram_offset attribute in AspeedI2Cbus hw/i2c/aspeed: Add AST2700 support
hw/i2c/aspeed: Add support for Tx/Rx buffer 64 bit addresses hw/i2c/aspeed: Add support for 64 bit addresses
aspeed/soc: Introduce a new API to get the device irq aspeed/soc: Support I2C for AST2700
aspeed: Add tmp105 in i2c bus 0 for AST2700 machine_aspeed.py: Update to test I2C for AST2700
Peter Maydell (1):
hw/gpio/aspeed_gpio: Avoid shift into sign bit
include/hw/i2c/aspeed_i2c.h | 28 ++-- hw/arm/aspeed.c | 10 ++ hw/arm/aspeed_ast27x0.c | 45 ++++++ hw/gpio/aspeed_gpio.c | 2 +- hw/i2c/aspeed_i2c.c | 310 +++++++++++++++++++++++++++++++++++----- tests/avocado/machine_aspeed.py | 16 +++ 6 files changed, 363 insertions(+), 48 deletions(-)
[PULL 01/12] hw/gpio/aspeed_gpio: Avoid shift into sign bit
From: Peter Maydell <[email protected]>
In aspeed_gpio_update() we calculate "mask = 1 << gpio", where gpio can be between 0 and 31. Coverity complains about this because 1 << 31 won't fit in a signed integer.
For QEMU this isn't an error because we enable -fwrapv, but we can keep Coverity happy by doing the shift on unsigned numbers.
Resolves: Coverity CID 1547742
--- hw/gpio/aspeed_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/gpio/aspeed_gpio.c +1 -1
@@ -281,7 +281,7 @@ static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs, diff &= mode_mask;if (diff) {for (gpio =0 ; gpio <ASPEED_GPIOS_PER_SET ; gpio++) { -uint32_t mask =1 << gpio; +uint32_t mask =1U << gpio;/* If the gpio needs to be updated... */ if (!(diff & mask)) {
Signature · 1 line
2.46.0
[PULL 05/12] hw/i2c/aspeed: Introduce a new dma_dram_offset attribute in AspeedI2Cbus
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
The "Current DMA Operating Address Status(0x50)" register of I2C new mode has been removed in AST2700.
This register is used for debugging and it is a read only register.
To support AST2700 DMA mode, introduce a new dma_dram_offset class attribute in AspeedI2Cbus to save the current DMA operating address.
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) And the base address of dram is "0x4 00000000" which is 64bits address.
Set the dma_dram_offset data type to uint64_t for
64 bits dram address DMA support.
Both "DMA Mode Buffer Address Register(I2CD24 old mode)" and
"DMA Operating Address Status (I2CC50 new mode)" are used for showing the low part dram offset bits [31:0], so change to read/write both register bits [31:0] in bus register read/write functions.
The aspeed_i2c_bus_vmstate is changed again and version is not increased because it was done earlier in the same series.
--- include/hw/i2c/aspeed_i2c.h | 9 +------ hw/i2c/aspeed_i2c.c | 51 +++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 27 deletions(-)
include/hw/i2c/aspeed_i2c.h +1 -8
@@ -248,6 +248,7 @@ struct AspeedI2CBus {uint32_t regs[ASPEED_I2C_NEW_NUM_REG ];uint8_t pool[ASPEED_I2C_BUS_POOL_SIZE ]; +uint64_t dma_dram_offset; };struct AspeedI2CState {
@@ -369,14 +370,6 @@ static inline uint32_t aspeed_i2c_bus_dma_len_offset(AspeedI2CBus *bus)return R_I2CD_DMA_LEN ; } -static inline uint32_t aspeed_i2c_bus_dma_addr_offset (AspeedI2CBus *bus) -{ -if (aspeed_i2c_is_new_mode (bus->controller)) { -return R_I2CC_DMA_ADDR ; - } -return R_I2CD_DMA_ADDR ; -} -static inline bool aspeed_i2c_bus_is_master (AspeedI2CBus *bus) { return SHARED_ARRAY_FIELD_EX32(bus->regs, aspeed_i2c_bus_ctrl_offset(bus),
hw/i2c/aspeed_i2c.c +32 -19
138 lines not on this page · raw message
Signature · 1 line
2.46.0
[PULL 06/12] hw/i2c/aspeed: Add AST2700 support
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Introduce a new ast2700 class to support AST2700. The I2C bus register memory regions and
I2C bus pool buffer memory regions are discontinuous and they do not back compatible AST2600.
Add a new ast2700 i2c class init function to match the address of I2C bus register and pool buffer from the datasheet.
An I2C controller registers owns 8KB address space.
--- include/hw/i2c/aspeed_i2c.h | 1 + hw/i2c/aspeed_i2c.c | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
include/hw/i2c/aspeed_i2c.h +1 -0
@@ -31,6 +31,7 @@#define TYPE_ASPEED_2500_I2C TYPE_ASPEED_I2C "-ast2500"#define TYPE_ASPEED_2600_I2C TYPE_ASPEED_I2C "-ast2600"#define TYPE_ASPEED_1030_I2C TYPE_ASPEED_I2C "-ast1030" +#define TYPE_ASPEED_2700_I2C TYPE_ASPEED_I2C "-ast2700" OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, ASPEED_I2C)#define ASPEED_I2C_NR_BUSSES 16
hw/i2c/aspeed_i2c.c +62 -0
80 lines not on this page · raw message
Signature · 1 line
2.46.0
[PULL 04/12] hw/i2c/aspeed: Support discontinuous poll buffer memory region of I2C bus
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
It only support continuous pool buffer memory region for all I2C bus. However, the pool buffer address of all I2c bus are discontinuous for AST2700.
Ex: the pool buffer address of I2C bus for ast2700 as following. 0x1A0 - 0x1BF: Device 0 buffer0x2A0 - 0x2BF: Device 1 buffer0x3A0 - 0x3BF: Device 2 buffer0x4A0 - 0x4BF: Device 3 buffer0x5A0 - 0x5BF: Device 4 buffer0x6A0 - 0x6BF: Device 5 buffer0x7A0 - 0x7BF: Device 6 buffer0x8A0 - 0x8BF: Device 7 buffer0x9A0 - 0x9BF: Device 8 buffer0xAA0 - 0xABF: Device 9 buffer0xBA0 - 0xBBF: Device 10 buffer0xCA0 - 0xCBF: Device 11 buffer0xDA0 - 0xDBF: Device 12 buffer0xEA0 - 0xEBF: Device 13 buffer0xFA0 – 0xFBF: Device 14 buffer0x10A0 – 0x10BF: Device 15 buffer
Introduce a new class attribute to make user set each I2C bus pool buffer gap size. Update formula to create all I2C bus pool buffer memory regions.
--- include/hw/i2c/aspeed_i2c.h | 1 + hw/i2c/aspeed_i2c.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
include/hw/i2c/aspeed_i2c.h +1 -0
@@ -284,6 +284,7 @@ struct AspeedI2CClass {uint64_t pool_size;hwaddr pool_base; +uint32_t pool_gap_size;uint8_t *(*bus_pool_base)(AspeedI2CBus *);bool check_sram;bool has_dma;
hw/i2c/aspeed_i2c.c +2 -1
@@ -1098,6 +1098,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp)AspeedI2CState *s =ASPEED_I2C (dev);AspeedI2CClass *aic =ASPEED_I2C_GET_CLASS (s);uint32_t reg_offset = aic->reg_size + aic->reg_gap_size; +uint32_t pool_offset = aic->pool_size + aic->pool_gap_size;sysbus_init_irq (sbd, &s->irq); memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i2c_ctrl_ops, s,
@@ -1133,7 +1134,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) }else {for (i =0 ; i < aic->num_busses; i++) {memory_region_add_subregion (&s->iomem, - aic->pool_base + (aic->pool_size * i), + aic->pool_base + (pool_offset * i), &s->busses[i].mr_pool); } }
Signature · 1 line
2.46.0
[PULL 11/12] aspeed: Add tmp105 in i2c bus 0 for AST2700
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED SDK add lm75 in i2c bus 0 for AST2700. LM75 is compatible with TMP105 driver.
Introduce a new i2c init function and
add tmp105 device model in i2c bus 0.
--- hw/arm/aspeed.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/arm/aspeed.c +10 -0
@@ -1650,6 +1650,15 @@ static void aspeed_minibmc_machine_ast1030_evb_class_init(ObjectClass *oc, }#ifdef TARGET_AARCH64 +static void ast2700_evb_i2c_init (AspeedMachineState *bmc) +{ +AspeedSoCState *soc = bmc->soc; + +/* LM75 is compatible with TMP105 driver */ +i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ), +TYPE_TMP105 ,0x4d ); +} +static void aspeed_machine_ast2700_evb_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1664,6 +1673,7 @@ static void aspeed_machine_ast2700_evb_class_init(ObjectClass *oc, void *data) amc->num_cs =2 ; amc->macs_mask =ASPEED_MAC0_ON |ASPEED_MAC1_ON |ASPEED_MAC2_ON ; amc->uart_default =ASPEED_DEV_UART12 ; + amc->i2c_init = ast2700_evb_i2c_init; mc->default_ram_size =1 * GiB;aspeed_machine_class_init_cpus_defaults (mc); }
Signature · 1 line
2.46.0
[PULL 12/12] machine_aspeed.py: Update to test I2C for AST2700
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Update test case to test lm75 temperature sensor.
--- tests/avocado/machine_aspeed.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tests/avocado/machine_aspeed.py +16 -0
@@ -433,9 +433,25 @@ def test_aarch64_ast2700_evb_sdk_v09_02(self): f'loader,addr=0x430000000,cpu-num={i}') self.vm.add_args('-smp', str(num_cpu)) + self.vm.add_args('-device', + 'tmp105,bus=aspeed.i2c.bus.1,address=0x4d,id=tmp-test') self.do_test_aarch64_aspeed_sdk_start(image_dir + 'image-bmc') self.wait_for_console_pattern('nodistro.0 ast2700-default ttyS12') + self.ssh_connect('root', '0penBmc', False) + self.ssh_command('dmesg -c > /dev/null') + + self.ssh_command_output_contains( + 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-1/device/new_device ' + '&& dmesg -c', + 'i2c i2c-1: new_device: Instantiated device lm75 at 0x4d'); + + self.ssh_command_output_contains( + 'cat /sys/class/hwmon/hwmon20/temp1_input', '0') + self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', + property='temperature', value=18000) + self.ssh_command_output_contains( + 'cat /sys/class/hwmon/hwmon20/temp1_input', '18000') class AST2x00MachineMMC(QemuSystemTest):
Signature · 1 line
2.46.0
[PULL 03/12] hw/i2c/aspeed: Introduce a new bus pool buffer attribute in AspeedI2Cbus
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
According to the datasheet of ASPEED SOCs,
each I2C bus has their own pool buffer since AST2500. Only AST2400 utilized a pool buffer share to all I2C bus. Besides, using a share pool buffer only support pool buffer memory regions are continuous for all I2C bus.
To make this model more readable and support discontinuous bus pool buffer memory regions, changes to introduce a new bus pool buffer attribute in AspeedI2Cbus and new memops. So, it does not need to calculate
the pool buffer offset for different I2C bus.
Introduce a new has_share_pool class attribute in AspeedI2CClass and use it to create either a share pool buffer or bus pool buffers in aspeed_i2c_realize. Update each pull buffer size to 0x10 for AST2500 and 0x20 for AST2600 and AST1030.
Incrementing the version of aspeed_i2c_bus_vmstate to 6.
--- include/hw/i2c/aspeed_i2c.h | 4 ++ hw/i2c/aspeed_i2c.c | 131 +++++++++++++++++++++++++++++++----- 2 files changed, 117 insertions(+), 18 deletions(-)
include/hw/i2c/aspeed_i2c.h +4 -0
@@ -35,6 +35,7 @@ OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, ASPEED_I2C)#define ASPEED_I2C_NR_BUSSES 16#define ASPEED_I2C_SHARE_POOL_SIZE 0x800 +#define ASPEED_I2C_BUS_POOL_SIZE 0x20#define ASPEED_I2C_OLD_NUM_REG 11#define ASPEED_I2C_NEW_NUM_REG 22
@@ -239,12 +240,14 @@ struct AspeedI2CBus {I2CSlave *slave;MemoryRegion mr; +MemoryRegion mr_pool;I2CBus *bus;uint8_t id;qemu_irq irq;uint32_t regs[ASPEED_I2C_NEW_NUM_REG ]; +uint8_t pool[ASPEED_I2C_BUS_POOL_SIZE ]; };struct AspeedI2CState {
@@ -284,6 +287,7 @@ struct AspeedI2CClass {uint8_t *(*bus_pool_base)(AspeedI2CBus *);bool check_sram;bool has_dma; +bool has_share_pool;uint64_t mem_size; };
hw/i2c/aspeed_i2c.c +113 -18
209 lines not on this page · raw message
Signature · 1 line
2.46.0
[PULL 08/12] hw/i2c/aspeed: Add support for 64 bit addresses
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) and the base address of dram is "0x4 00000000" which is 64bits address.
The AST2700 support the maximum DRAM size is 8 GB. The DRAM physical address range is from "0x4_0000_0000" to "0x5_FFFF_FFFF".
The DRAM offset range is from "0x0_0000_0000" to "0x1_FFFF_FFFF" and it is enough to use bits [33:0] saving the dram offset.
Therefore, save the high part physical address bit[1:0] of Tx/Rx buffer address as dma_dram_offset bit[33:32]. It does not need to decrease the dram physical high part address for DMA operation.
(high part physical address bit[7:0] – 4)
--- hw/i2c/aspeed_i2c.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/i2c/aspeed_i2c.c +14 -0
@@ -743,6 +743,14 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, __func__);break ; +/* +* The AST2700 support the maximum DRAM size is 8 GB. +* The DRAM offset range is from 0x0_0000_0000 to +* 0x1_FFFF_FFFF and it is enough to use bits [33:0] +* saving the dram offset. +* Therefore, save the high part physical address bit[1:0] +* of Tx/Rx buffer address as dma_dram_offset bit[33:32]. +*/ case A_I2CM_DMA_TX_ADDR_HI :if (!aic->has_dma64) { qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA 64 bits support\n",
@@ -752,6 +760,8 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->regs[R_I2CM_DMA_TX_ADDR_HI ] =FIELD_EX32 (value,I2CM_DMA_TX_ADDR_HI ,ADDR_HI ); + bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,32 ,32 , +extract32 (value,0 ,2 ));break ;case A_I2CM_DMA_RX_ADDR_HI :if (!aic->has_dma64) {
@@ -762,6 +772,8 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->regs[R_I2CM_DMA_RX_ADDR_HI ] =FIELD_EX32 (value,I2CM_DMA_RX_ADDR_HI ,ADDR_HI ); + bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,32 ,32 , +extract32 (value,0 ,2 ));break ;case A_I2CS_DMA_TX_ADDR_HI : qemu_log_mask(LOG_UNIMP,
@@ -777,6 +789,8 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->regs[R_I2CS_DMA_RX_ADDR_HI ] =FIELD_EX32 (value,I2CS_DMA_RX_ADDR_HI ,ADDR_HI ); + bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,32 ,32 , +extract32 (value,0 ,2 ));break ;default : qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
Signature · 1 line
2.46.0
[PULL 07/12] hw/i2c/aspeed: Add support for Tx/Rx buffer 64 bit addresses
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
ASPEED AST2700 SOC is a 64 bits quad core CPUs (Cortex-a35) and the base address of dram is "0x4 00000000" which is 64bits address.
It has "Master DMA Mode Tx Buffer Base Address[39:32](0x60)" and "Master DMA Mode Rx Buffer Base Address[39:32](0x64)" registers to save the high part physical address of Tx/Rx buffer address for master mode.
It has "Slave DMA Mode Tx Buffer Base Address[39:32](0x68)" and "Slave DMA Mode Rx Buffer Base Address[39:32](0x6C)" registers to save the high part physical address of Tx/Rx buffer address for slave mode.
Ex: Tx buffer address for master mode [39:0]
The "Master DMA Mode Tx Buffer Base Address[39:32](0x60)" bits [7:0] which corresponds the bits [39:32] of the 64 bits address of the Tx buffer address.
The "Master DMA Mode Tx Buffer Base Address(0x30)" bits [31:0] which corresponds the bits [31:0] of the 64 bits address
of the Tx buffer address.
Introduce a new has_dma64 class attribute and new registers for the new mode to support DMA 64 bits dram address.
Update new mode register number to 28.
The aspeed_i2c_bus_vmstate is changed again and
version is not increased because it was done earlier in the same series.
--- include/hw/i2c/aspeed_i2c.h | 12 +++++++++- hw/i2c/aspeed_i2c.c | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-)
include/hw/i2c/aspeed_i2c.h +11 -1
@@ -38,7 +38,7 @@ OBJECT_DECLARE_TYPE(AspeedI2CState, AspeedI2CClass, ASPEED_I2C)#define ASPEED_I2C_SHARE_POOL_SIZE 0x800#define ASPEED_I2C_BUS_POOL_SIZE 0x20#define ASPEED_I2C_OLD_NUM_REG 11 -#define ASPEED_I2C_NEW_NUM_REG 22 +#define ASPEED_I2C_NEW_NUM_REG 28#define A_I2CD_M_STOP_CMD BIT(5)#define A_I2CD_M_RX_CMD BIT(3)
@@ -227,6 +227,15 @@ REG32(I2CS_DMA_LEN_STS, 0x4c) FIELD(I2CS_DMA_LEN_STS, TX_LEN, 0, 13) REG32(I2CC_DMA_ADDR, 0x50)REG32 (I2CC_DMA_LEN ,0x54 ) +/* DMA 64bits */ +REG32(I2CM_DMA_TX_ADDR_HI, 0x60) + FIELD(I2CM_DMA_TX_ADDR_HI, ADDR_HI, 0, 7) +REG32(I2CM_DMA_RX_ADDR_HI, 0x64) + FIELD(I2CM_DMA_RX_ADDR_HI, ADDR_HI, 0, 7) +REG32(I2CS_DMA_TX_ADDR_HI, 0x68) + FIELD(I2CS_DMA_TX_ADDR_HI, ADDR_HI, 0, 7) +REG32(I2CS_DMA_RX_ADDR_HI, 0x6c) + FIELD(I2CS_DMA_RX_ADDR_HI, ADDR_HI, 0, 7)struct AspeedI2CState ;
@@ -292,6 +301,7 @@ struct AspeedI2CClass {bool has_dma;bool has_share_pool;uint64_t mem_size; +bool has_dma64; };static inline bool aspeed_i2c_is_new_mode (AspeedI2CState *s)
hw/i2c/aspeed_i2c.c +48 -0
72 lines not on this page · raw message
Signature · 1 line
2.46.0
[PULL 09/12] aspeed/soc: Introduce a new API to get the device irq
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Currently, users can set the INTC mapping table with enumerated device id and device irq to get the INTC orgate input pins. However, some devices use the continuous source numbers in the same INTC orgate. To reduce the enumerated device id definition, create a new API to get the INTC orgate input pin
if users only provide the device id with its bus number index.
--- hw/arm/aspeed_ast27x0.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/arm/aspeed_ast27x0.c +21 -0
@@ -193,6 +193,27 @@ static qemu_irq aspeed_soc_ast2700_get_irq(AspeedSoCState *s, int dev)return qdev_get_gpio_in (DEVICE (&a->gic), sc->irqmap[dev]); } +static qemu_irq aspeed_soc_ast2700_get_irq_index (AspeedSoCState *s,int dev, +int index) +{ +Aspeed27x0SoCState *a =ASPEED27X0_SOC (s); +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); +int i; + +for (i =0 ; i <ARRAY_SIZE (aspeed_soc_ast2700_gic_intcmap); i++) { +if (sc->irqmap[dev] == aspeed_soc_ast2700_gic_intcmap[i].irq) { +assert (aspeed_soc_ast2700_gic_intcmap[i].ptr); +return qdev_get_gpio_in (DEVICE (&a->intc.orgates[i]), + aspeed_soc_ast2700_gic_intcmap[i].ptr[dev] + index); + } + } + +/* +* Invalid orgate index, device irq should be 128 to 136. +*/ +g_assert_not_reached (); +} +static uint64_t aspeed_ram_capacity_read (void *opaque,hwaddr addr,unsigned int size) {
Signature · 1 line
2.46.0
[PULL 02/12] hw/i2c/aspeed: Support discontinuous register memory region of I2C bus
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
It only support continuous register memory region for all I2C bus. However, the register address of all I2c bus are discontinuous for AST2700.
Ex: the register address of I2C bus for ast2700 as following. 0x100 - 0x17F: Device 00x200 - 0x27F: Device 10x300 - 0x37F: Device 20x400 - 0x47F: Device 30x500 - 0x57F: Device 40x600 - 0x67F: Device 50x700 - 0x77F: Device 60x800 - 0x87F: Device 70x900 - 0x97F: Device 80xA00 - 0xA7F: Device 90xB00 - 0xB7F: Device 100xC00 - 0xC7F: Device 110xD00 - 0xD7F: Device 120xE00 - 0xE7F: Device 130xF00 – 0xF7F: Device 140x1000 – 0x107F: Device 15
Introduce a new class attribute to make user set each I2C bus gap size. Update formula to create all I2C bus register memory regions.
--- include/hw/i2c/aspeed_i2c.h | 1 + hw/i2c/aspeed_i2c.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
include/hw/i2c/aspeed_i2c.h +1 -0
@@ -275,6 +275,7 @@ struct AspeedI2CClass {uint8_t num_busses;uint8_t reg_size; +uint32_t reg_gap_size;uint8_t gap;qemu_irq (*bus_get_irq)(AspeedI2CBus *);
hw/i2c/aspeed_i2c.c +2 -1
@@ -1012,6 +1012,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);AspeedI2CState *s =ASPEED_I2C (dev);AspeedI2CClass *aic =ASPEED_I2C_GET_CLASS (s); +uint32_t reg_offset = aic->reg_size + aic->reg_gap_size;sysbus_init_irq (sbd, &s->irq); memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i2c_ctrl_ops, s,
@@ -1034,7 +1035,7 @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp)return ; } -memory_region_add_subregion (&s->iomem, aic->reg_size * (i + offset), +memory_region_add_subregion (&s->iomem, reg_offset * (i + offset), &s->busses[i].mr); }
Signature · 1 line
2.46.0
[PULL 10/12] aspeed/soc: Support I2C for AST2700
In reply to Cédric Le GoaterFrom: Jamin Lin <[email protected]>
Add I2C model for AST2700 I2C support.
The I2C controller registers base address is start at 0x14C0_F000 and its address space is 0x2000.
The AST2700 I2C controller has one source INTC per bus. I2C buses interrupt are connected to GICINT130_INTC from bit 0 to bit 15.
I2C bus 0 is connected to GICINT130_INTC at bit 0. I2C bus 15 is connected to GICINT130_INTC at bit 15.
--- hw/arm/aspeed_ast27x0.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
hw/arm/aspeed_ast27x0.c +24 -0
@@ -61,6 +61,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_GIC_DIST] = 0x12200000, [ASPEED_GIC_REDIST] = 0x12280000, [ASPEED_DEV_ADC] = 0x14C00000, + [ASPEED_DEV_I2C] = 0x14C0F000, };#define AST2700_MAX_IRQ 288
@@ -369,6 +370,9 @@ static void aspeed_soc_ast2700_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.adc-%s" , socname);object_initialize_child (obj,"adc" , &s->adc, typename); + +snprintf (typename,sizeof (typename),"aspeed.i2c-%s" , socname); +object_initialize_child (obj,"i2c" , &s->i2c, typename); }/*
@@ -452,6 +456,7 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);AspeedINTCClass *ic =ASPEED_INTC_GET_CLASS (&a->intc); g_autofree char *sram_name = NULL; +qemu_irq irq;/* Default boot region (SPI memory or ROMs) */ memory_region_init(&s->spi_boot_container, OBJECT(s),
@@ -634,6 +639,25 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adc),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_ADC )); +/* I2C */ +object_property_set_link (OBJECT (&s->i2c),"dram" ,OBJECT (s->dram_mr), + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->i2c), errp)) { +return ; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->i2c),0 , sc->memmap[ASPEED_DEV_I2C ]); +for (i =0 ; i <ASPEED_I2C_GET_CLASS (&s->i2c)->num_busses; i++) { +/* +* The AST2700 I2C controller has one source INTC per bus. +* I2C buses interrupt are connected to GICINT130_INTC +* from bit 0 to bit 15. +* I2C bus 0 is connected to GICINT130_INTC at bit 0. +* I2C bus 15 is connected to GICINT130_INTC at bit 15. +*/ + irq =aspeed_soc_ast2700_get_irq_index (s,ASPEED_DEV_I2C , i); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c.busses[i]),0 , irq); + } +create_unimplemented_device ("ast2700.dpmcu" ,0x11000000 ,0x40000 );create_unimplemented_device ("ast2700.iomem0" ,0x12000000 ,0x01000000 );create_unimplemented_device ("ast2700.iomem1" ,0x14000000 ,0x01000000 );
Signature · 1 line
2.46.0
Peter Maydell
AppliedQuoted 11 lines · Cédric Le Goater
The following changes since commit
ea9cdbcf3a0b8d5497cddf87990f1b39d8f3bb0a:Merge tag 'hw-misc-20240913' of https://github.com/philmd/qemu into staging (2024-09-15 18:27:40 +0100)
are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-aspeed-20240916
for you to fetch changes up to
a93bb519e683fd8f8d7945e5517fd5ad74cc41c0:
Quoted 7 lines
machine_aspeed.py: Update to test I2C for AST2700 (2024-09-16 17:44:08 +0200)----------------------------------------------------------------
aspeed queue:* I2C support for AST2700
* Coverity fixes
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/9.2
for any user-visible changes.
-- PMM