mps2: Add few more peripherals
v2 cover mps2: Add few more peripherals
Few patches while playing with Zephyr on the MPS2:
- clean 'versatile_i2c' a bit,
- describe it as 'ARM SBCon two-wire serial bus interface' which is common on the ARM documentation,
- add watchdog
- added fpgaio with correct prescale clk
- added i2c and spi
- added gpio/i2s as unimp
- dropped the fpgaio push-button patch
Zephyr ressources used:
https://docs.zephyrproject.org/latest/boards/arm/mps2_an385/doc/index.html
Philippe Mathieu-Daudé (14):
hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status hw/i2c/versatile_i2c: Add definitions for register addresses hw/i2c/versatile_i2c: Add SCL/SDA definitions
hw/i2c: Add header for ARM SBCon two-wire serial bus interface hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections hw/arm/mps2: Rename CMSDK AHB peripheral region hw/arm/mps2: Add CMSDK APB watchdog device
hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices hw/arm/mps2: Map the FPGA I/O block
hw/arm/mps2: Add SPI devices
hw/arm/mps2: Add I2C devices
hw/arm/mps2: Add audio I2S interface as unimplemented device hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface
include/hw/i2c/arm_sbcon_i2c.h | 35 +++++++++++++++++ hw/arm/mps2-tz.c | 23 ++++++++--- hw/arm/mps2.c | 65 ++++++++++++++++++++++++++++++-- hw/arm/realview.c | 3 +- hw/arm/versatilepb.c | 3 +- hw/arm/vexpress.c | 3 +- hw/i2c/versatile_i2c.c | 38 ++++++++++--------- hw/watchdog/cmsdk-apb-watchdog.c | 1 + MAINTAINERS | 1 + hw/arm/Kconfig | 1 + hw/watchdog/trace-events | 1 + 11 files changed, 144 insertions(+), 30 deletions(-) create mode 100644 include/hw/i2c/arm_sbcon_i2c.h
Signature · 1 line
2.21.3
PATCH v2 1/14 hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status
Add a trace event to see when a guest disable/enable the watchdog.
--- hw/watchdog/cmsdk-apb-watchdog.c | 1 + hw/watchdog/trace-events | 1 + 2 files changed, 2 insertions(+)
hw/watchdog/cmsdk-apb-watchdog.c +1 -0
@@ -225,6 +225,7 @@ static void cmsdk_apb_watchdog_write(void *opaque, hwaddr offset,break ;case A_WDOGLOCK : s->lock = (value !=WDOG_UNLOCK_VALUE ); +trace_cmsdk_apb_watchdog_lock (s->lock);break ;case A_WDOGITCR :if (s->is_luminary) {
hw/watchdog/trace-events +1 -0
@@ -4,3 +4,4 @@ cmsdk_apb_watchdog_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" cmsdk_apb_watchdog_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB watchdog write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" cmsdk_apb_watchdog_reset(void) "CMSDK APB watchdog: reset" +cmsdk_apb_watchdog_lock(uint32_t lock) "CMSDK APB watchdog: lock %" PRIu32
Signature · 1 line
2.21.3
PATCH v2 2/14 hw/i2c/versatile_i2c: Add definitions for register addresses
In reply to Philippe Mathieu-DaudéUse self-explicit definitions instead of magic values.
--- hw/i2c/versatile_i2c.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
hw/i2c/versatile_i2c.c +10 -4
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "hw/sysbus.h" #include "hw/i2c/bitbang_i2c.h" +#include "hw/registerfields.h" #include "qemu/log.h" #include "qemu/module.h"
@@ -40,14 +41,19 @@ typedef struct VersatileI2CState {int in; } VersatileI2CState; +REG32(CONTROL_GET, 0) +REG32(CONTROL_SET, 0) +REG32(CONTROL_CLR, 4) +static uint64_t versatile_i2c_read (void *opaque,hwaddr offset,unsigned size) {VersatileI2CState *s = (VersatileI2CState *)opaque; -if (offset ==0 ) { +switch (offset) { +case A_CONTROL_SET :return (s->out &1 ) | (s->in <<1 ); - }else { +default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad offset 0x%x\n" , __func__, (int )offset);return -1 ;
@@ -60,10 +66,10 @@ static void versatile_i2c_write(void *opaque, hwaddr offset,VersatileI2CState *s = (VersatileI2CState *)opaque;switch (offset) { -case 0 : +case A_CONTROL_SET : s->out |= value &3 ;break ; -case 4 : +case A_CONTROL_CLR : s->out &= ~value;break ;default :
Signature · 1 line
2.21.3
PATCH v2 3/14 hw/i2c/versatile_i2c: Add SCL/SDA definitions
In reply to Philippe Mathieu-DaudéUse self-explicit definitions instead of magic values.
--- hw/i2c/versatile_i2c.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/i2c/versatile_i2c.c +5 -2
@@ -45,6 +45,9 @@ REG32(CONTROL_GET, 0) REG32(CONTROL_SET, 0) REG32(CONTROL_CLR, 4) +#define SCL BIT(0) +#define SDA BIT(1) +static uint64_t versatile_i2c_read (void *opaque,hwaddr offset,unsigned size) {
@@ -76,8 +79,8 @@ static void versatile_i2c_write(void *opaque, hwaddr offset,qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad offset 0x%x\n" , __func__, (int )offset); } -bitbang_i2c_set (&s->bitbang,BITBANG_I2C_SCL , (s->out &1 ) !=0 ); - s->in =bitbang_i2c_set (&s->bitbang,BITBANG_I2C_SDA , (s->out &2 ) !=0 ); +bitbang_i2c_set (&s->bitbang,BITBANG_I2C_SCL , (s->out &SCL ) !=0 ); + s->in =bitbang_i2c_set (&s->bitbang,BITBANG_I2C_SDA , (s->out &SDA ) !=0 ); }static const MemoryRegionOps versatile_i2c_ops = {
Signature · 1 line
2.21.3
PATCH v2 4/14 hw/i2c: Add header for ARM SBCon two-wire serial bus interface
In reply to Philippe Mathieu-Daudé'ARM SBCon two-wire serial bus interface' is the official name describing the pair of registers used to bitbanging I2C in the Versatile boards.
Make the private VersatileI2CState structure as public ArmSbconI2CState.
Add the TYPE_ARM_SBCON_I2C, alias to our current TYPE_VERSATILE_I2C model.
Rename the memory region description as 'arm_sbcon_i2c'.
--- include/hw/i2c/arm_sbcon_i2c.h | 35 ++++++++++++++++++++++++++++++++++ hw/i2c/versatile_i2c.c | 17 +++++------------ MAINTAINERS | 1 + 3 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 include/hw/i2c/arm_sbcon_i2c.h
include/hw/i2c/arm_sbcon_i2c.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* ARM SBCon two-wire serial bus interface (I2C bitbang) +* a.k.a. +* ARM Versatile I2C controller +* +* Copyright (c) 2006-2007 CodeSourcery. +* Copyright (c) 2012 Oskar Andero <[email protected]> +* Copyright (C) 2020 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HW_I2C_ARM_SBCON_H +#define HW_I2C_ARM_SBCON_H + +#include "hw/sysbus.h" +#include "hw/i2c/bitbang_i2c.h" + +#define TYPE_VERSATILE_I2C "versatile_i2c" +#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C + +#define ARM_SBCON_I2C (obj) \ + OBJECT_CHECK(ArmSbconI2CState, (obj), TYPE_ARM_SBCON_I2C) + +typedef struct ArmSbconI2CState { +/*< private >*/ +SysBusDevice parent_obj; +/*< public >*/ + +MemoryRegion iomem; +bitbang_i2c_interface bitbang; +int out; +int in; +}ArmSbconI2CState ; + +#endif /* HW_I2C_ARM_SBCON_H */
hw/i2c/versatile_i2c.c +5 -12
@@ -1,5 +1,6 @@/* -* ARM Versatile I2C controller +* ARM SBCon two-wire serial bus interface (I2C bitbang) +* a.k.a. ARM Versatile I2C controller * * Copyright (c) 2006-2007 CodeSourcery. * Copyright (c) 2012 Oskar Andero <[email protected]>
@@ -22,24 +23,16 @@*/ #include "qemu/osdep.h" -#include "hw/sysbus.h" -#include "hw/i2c/bitbang_i2c.h" +#include "hw/i2c/arm_sbcon_i2c.h" #include "hw/registerfields.h" #include "qemu/log.h" #include "qemu/module.h" -#define TYPE_VERSATILE_I2C "versatile_i2c"#define VERSATILE_I2C (obj) \ OBJECT_CHECK(VersatileI2CState, (obj), TYPE_VERSATILE_I2C) -typedef struct VersatileI2CState { -SysBusDevice parent_obj; +typedef ArmSbconI2CState VersatileI2CState ; -MemoryRegion iomem; -bitbang_i2c_interface bitbang; -int out; -int in; -}VersatileI2CState ; REG32(CONTROL_GET, 0)REG32 (CONTROL_SET ,0 )
@@ -99,7 +92,7 @@ static void versatile_i2c_init(Object *obj) bus =i2c_init_bus (dev,"i2c" );bitbang_i2c_init (&s->bitbang, bus);memory_region_init_io (&s->iomem, obj, &versatile_i2c_ops, s, -"versatile_i2c" ,0x1000 ); +"arm_sbcon_i2c" ,0x1000 );sysbus_init_mmio (sbd, &s->iomem); }
MAINTAINERS +1 -0
@@ -842,6 +842,7 @@ M: Peter Maydell <[email protected]> L: [email protected] S: Maintained F: hw/*/versatile* +F: include/hw/i2c/arm_sbcon_i2c.h F: hw/misc/arm_sysctl.c F: docs/system/arm/versatile.rst
Signature · 1 line
2.21.3
PATCH v2 5/14 hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string
In reply to Philippe Mathieu-DaudéBy using the TYPE_* definitions for devices, we can:
- quickly find where devices are used with 'git-grep'
- easily rename a device (one-line change).
--- hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/arm/vexpress.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
hw/arm/realview.c +2 -1
@@ -26,6 +26,7 @@#include "hw/cpu/a9mpcore.h" #include "hw/intc/realview_gic.h" #include "hw/irq.h" +#include "hw/i2c/arm_sbcon_i2c.h" #define SMP_BOOT_ADDR 0xe0000000#define SMP_BOOTREG_ADDR 0x10000030
@@ -282,7 +283,7 @@ static void realview_init(MachineState *machine, } } - dev =sysbus_create_simple ("versatile_i2c" ,0x10002000 ,NULL ); + dev =sysbus_create_simple (TYPE_VERSATILE_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_create_slave (i2c,"ds1338" ,0x68 );
hw/arm/versatilepb.c +2 -1
@@ -18,6 +18,7 @@#include "sysemu/sysemu.h" #include "hw/pci/pci.h" #include "hw/i2c/i2c.h" +#include "hw/i2c/arm_sbcon_i2c.h" #include "hw/irq.h" #include "hw/boards.h" #include "exec/address-spaces.h"
@@ -314,7 +315,7 @@ static void versatile_init(MachineState *machine, int board_id)/* Add PL031 Real Time Clock. */ sysbus_create_simple ("pl031" ,0x101e8000 , pic[10 ]); - dev =sysbus_create_simple ("versatile_i2c" ,0x10002000 ,NULL ); + dev =sysbus_create_simple (TYPE_VERSATILE_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_create_slave (i2c,"ds1338" ,0x68 );
hw/arm/vexpress.c +2 -1
@@ -42,6 +42,7 @@#include "hw/char/pl011.h" #include "hw/cpu/a9mpcore.h" #include "hw/cpu/a15mpcore.h" +#include "hw/i2c/arm_sbcon_i2c.h" #define VEXPRESS_BOARD_ID 0x8e0#define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024)
@@ -640,7 +641,7 @@ static void vexpress_common_init(MachineState *machine)sysbus_create_simple ("sp804" , map[VE_TIMER01 ], pic[2 ]);sysbus_create_simple ("sp804" , map[VE_TIMER23 ], pic[3 ]); - dev =sysbus_create_simple ("versatile_i2c" , map[VE_SERIALDVI ],NULL ); + dev =sysbus_create_simple (TYPE_VERSATILE_I2C , map[VE_SERIALDVI ],NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_create_slave (i2c,"sii9022" ,0x39 );
Signature · 1 line
2.21.3
PATCH v2 6/14 hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections
In reply to Philippe Mathieu-Daudé--- hw/arm/mps2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/arm/mps2.c +4 -1
@@ -65,7 +65,9 @@ typedef struct {MemoryRegion blockram_m2;MemoryRegion blockram_m3;MemoryRegion sram; +/* FPGA APB subsystem */ MPS2SCC scc; +/* CMSDK APB subsystem */ CMSDKAPBDualTimer dualtimer; } MPS2MachineState;
@@ -299,9 +301,9 @@ static void mps2_common_init(MachineState *machine)g_assert_not_reached (); } +/* CMSDK APB subsystem */ cmsdk_apb_timer_create (0x40000000 ,qdev_get_gpio_in (armv7m,8 ),SYSCLK_FRQ );cmsdk_apb_timer_create (0x40001000 ,qdev_get_gpio_in (armv7m,9 ),SYSCLK_FRQ ); -object_initialize_child (OBJECT (mms),"dualtimer" , &mms->dualtimer,TYPE_CMSDK_APB_DUALTIMER );qdev_prop_set_uint32 (DEVICE (&mms->dualtimer),"pclk-frq" ,SYSCLK_FRQ );
@@ -310,6 +312,7 @@ static void mps2_common_init(MachineState *machine) qdev_get_gpio_in(armv7m, 10));sysbus_mmio_map (SYS_BUS_DEVICE (&mms->dualtimer),0 ,0x40002000 ); +/* FPGA APB subsystem */ object_initialize_child (OBJECT (mms),"scc" , &mms->scc,TYPE_MPS2_SCC ); sccdev =DEVICE (&mms->scc);qdev_prop_set_uint32 (sccdev,"scc-cfg4" ,0x2 );
Signature · 1 line
2.21.3
PATCH v2 7/14 hw/arm/mps2: Rename CMSDK AHB peripheral region
In reply to Philippe Mathieu-DaudéTo differenciate with the CMSDK APB peripheral region, rename this region 'CMSDK AHB peripheral region'.
--- hw/arm/mps2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/mps2.c +2 -1
@@ -212,10 +212,11 @@ static void mps2_common_init(MachineState *machine)*/ create_unimplemented_device ("CMSDK APB peripheral region @0x40000000" ,0x40000000 ,0x00010000 ); -create_unimplemented_device ("CMSDK peripheral region @0x40010000" , +create_unimplemented_device ("CMSDK AHB peripheral region @0x40010000" ,0x40010000 ,0x00010000 );create_unimplemented_device ("Extra peripheral region @0x40020000" ,0x40020000 ,0x00010000 ); +create_unimplemented_device ("RESERVED 4" ,0x40030000 ,0x001D0000 );create_unimplemented_device ("VGA" ,0x41000000 ,0x0200000 );
Signature · 1 line
2.21.3
PATCH v2 8/14 hw/arm/mps2: Add CMSDK APB watchdog device
In reply to Philippe Mathieu-DaudéWe already model the CMSDK APB watchdog device, let's use it!
---
v2: Use existing TYPE_CMSDK_APB_WATCHDOG (pm215)
--- hw/arm/mps2.c | 7 +++++++ hw/arm/Kconfig | 1 + 2 files changed, 8 insertions(+)
hw/arm/mps2.c +7 -0
@@ -312,6 +312,13 @@ static void mps2_common_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (&mms->dualtimer),0 ,qdev_get_gpio_in (armv7m,10 ));sysbus_mmio_map (SYS_BUS_DEVICE (&mms->dualtimer),0 ,0x40002000 ); +object_initialize_child (OBJECT (mms),"watchdog" , &mms->watchdog, +TYPE_CMSDK_APB_WATCHDOG ); +qdev_prop_set_uint32 (DEVICE (&mms->watchdog),"wdogclk-frq" ,SYSCLK_FRQ ); +sysbus_realize (SYS_BUS_DEVICE (&mms->watchdog), &error_fatal); +sysbus_connect_irq (SYS_BUS_DEVICE (&mms->watchdog),0 , +qdev_get_gpio_in_named (armv7m,"NMI" ,0 )); +sysbus_mmio_map (SYS_BUS_DEVICE (&mms->watchdog),0 ,0x40008000 );/* FPGA APB subsystem */ object_initialize_child (OBJECT (mms),"scc" , &mms->scc,TYPE_MPS2_SCC );
hw/arm/Kconfig +1 -0
@@ -405,6 +405,7 @@ config MPS2 select PL080 # DMA controller select SPLIT_IRQ select UNIMP + select CMSDK_APB_WATCHDOG config FSL_IMX7 bool
Signature · 1 line
2.21.3
PATCH v2 9/14 hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices
In reply to Philippe Mathieu-DaudéRegister the GPIO peripherals as unimplemented to better follow their accesses, for example booting Zephyr:
----------------
IN: arm_mps2_pinmux_init
0x00001160: f64f 0231 movw r2, #0xf831 0x00001164: 4b06 ldr r3, [pc, #0x18] 0x00001166: 2000 movs r0, #0 0x00001168: 619a str r2, [r3, #0x18] 0x0000116a: f24c 426f movw r2, #0xc46f 0x0000116e: f503 5380 add.w r3, r3, #0x1000 0x00001172: 619a str r2, [r3, #0x18] 0x00001174: f44f 529e mov.w r2, #0x13c0 0x00001178: f503 5380 add.w r3, r3, #0x1000 0x0000117c: 619a str r2, [r3, #0x18] 0x0000117e: 4770 bx lr
cmsdk-ahb-gpio: unimplemented device write (size 4, value 0xf831, offset 0x18)
cmsdk-ahb-gpio: unimplemented device write (size 4, value 0xc46f, offset 0x18)
cmsdk-ahb-gpio: unimplemented device write (size 4, value 0x13c0, offset 0x18)
--- hw/arm/mps2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/arm/mps2.c +6 -2
@@ -113,6 +113,7 @@ static void mps2_common_init(MachineState *machine)MemoryRegion *system_memory =get_system_memory ();MachineClass *mc =MACHINE_GET_CLASS (machine);DeviceState *armv7m, *sccdev; +int i;if (strcmp (machine->cpu_type, mc->default_cpu_type) !=0 ) { error_report("This board can only be used with CPU %s",
@@ -228,7 +229,6 @@ static void mps2_common_init(MachineState *machine)*/ Object *orgate;DeviceState *orgate_dev; -int i; orgate =object_new (TYPE_OR_IRQ );object_property_set_int (orgate,6 ,"num-lines" , &error_fatal);
@@ -265,7 +265,6 @@ static void mps2_common_init(MachineState *machine)*/ Object *orgate;DeviceState *orgate_dev; -int i; orgate =object_new (TYPE_OR_IRQ );object_property_set_int (orgate,10 ,"num-lines" , &error_fatal);
@@ -301,6 +300,11 @@ static void mps2_common_init(MachineState *machine)default :g_assert_not_reached (); } +for (i =0 ; i <4 ; i++) { +static const hwaddr gpiobase[] = {0x40010000 ,0x40011000 , +0x40012000 ,0x40013000 }; +create_unimplemented_device ("cmsdk-ahb-gpio" , gpiobase[i],0x1000 ); + }/* CMSDK APB subsystem */ cmsdk_apb_timer_create (0x40000000 ,qdev_get_gpio_in (armv7m,8 ),SYSCLK_FRQ );
Signature · 1 line
2.21.3
PATCH v2 10/14 hw/arm/mps2: Map the FPGA I/O block
In reply to Philippe Mathieu-Daudé---
v2: 25MHz prescale-clk property
--- hw/arm/mps2.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/arm/mps2.c +9 -0
@@ -38,8 +38,10 @@#include "hw/timer/cmsdk-apb-timer.h" #include "hw/timer/cmsdk-apb-dualtimer.h" #include "hw/misc/mps2-scc.h" +#include "hw/misc/mps2-fpgaio.h" #include "hw/net/lan9118.h" #include "net/net.h" +#include "hw/watchdog/cmsdk-apb-watchdog.h" typedef enum MPS2FPGAType { FPGA_AN385,
@@ -67,8 +69,10 @@ typedef struct {MemoryRegion sram;/* FPGA APB subsystem */ MPS2SCC scc; +MPS2FPGAIO fpgaio;/* CMSDK APB subsystem */ CMSDKAPBDualTimer dualtimer; +CMSDKAPBWatchdog watchdog; } MPS2MachineState;#define TYPE_MPS2_MACHINE "mps2"
@@ -332,6 +336,11 @@ static void mps2_common_init(MachineState *machine)qdev_prop_set_uint32 (sccdev,"scc-id" , mmc->scc_id);sysbus_realize (SYS_BUS_DEVICE (&mms->scc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (sccdev),0 ,0x4002f000 ); +object_initialize_child (OBJECT (mms),"fpgaio" , + &mms->fpgaio,TYPE_MPS2_FPGAIO ); +qdev_prop_set_uint32 (DEVICE (&mms->fpgaio),"prescale-clk" ,25000000 ); +sysbus_realize (SYS_BUS_DEVICE (&mms->fpgaio), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&mms->fpgaio),0 ,0x40028000 );/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature.
Signature · 1 line
2.21.3
PATCH v2 11/14 hw/arm/mps2: Add SPI devices
In reply to Philippe Mathieu-DaudéFrom 'Application Note AN385', chapter 3.9, SPI:
The SMM implements five PL022 SPI modules.
Two pairs of modules share the same OR-gated IRQ.
--- hw/arm/mps2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
hw/arm/mps2.c +24 -0
@@ -39,6 +39,7 @@#include "hw/timer/cmsdk-apb-dualtimer.h" #include "hw/misc/mps2-scc.h" #include "hw/misc/mps2-fpgaio.h" +#include "hw/ssi/pl022.h" #include "hw/net/lan9118.h" #include "net/net.h" #include "hw/watchdog/cmsdk-apb-watchdog.h"
@@ -341,6 +342,29 @@ static void mps2_common_init(MachineState *machine)qdev_prop_set_uint32 (DEVICE (&mms->fpgaio),"prescale-clk" ,25000000 );sysbus_realize (SYS_BUS_DEVICE (&mms->fpgaio), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (&mms->fpgaio),0 ,0x40028000 ); +sysbus_create_simple (TYPE_PL022 ,0x40025000 ,/* External ADC */ +qdev_get_gpio_in (armv7m,22 )); +for (i =0 ; i <2 ; i++) { +static const int spi_irqno[] = {11 ,24 }; +static const hwaddr spibase[] = {0x40020000 ,/* APB */ +0x40021000 ,/* LCD */ +0x40026000 ,/* Shield0 */ +0x40027000 };/* Shield1 */ +DeviceState *orgate_dev; +Object *orgate; +int j; + + orgate =object_new (TYPE_OR_IRQ ); +object_property_set_int (orgate,2 ,"num-lines" , &error_fatal); + orgate_dev =DEVICE (orgate); +qdev_realize (orgate_dev,NULL , &error_fatal); +qdev_connect_gpio_out (orgate_dev,0 , +qdev_get_gpio_in (armv7m, spi_irqno[i])); +for (j =0 ; j <2 ; j++) { +sysbus_create_simple (TYPE_PL022 , spibase[2 * i + j], +qdev_get_gpio_in (orgate_dev, j)); + } + }/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature.
Signature · 1 line
2.21.3
PATCH v2 12/14 hw/arm/mps2: Add I2C devices
In reply to Philippe Mathieu-DaudéFrom 'Application Note AN385', chapter 3.14:
The SMM implements a simple SBCon interface based on I2C.
There are 4 SBCon interfaces on the FPGA APB subsystem.
--- hw/arm/mps2.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/arm/mps2.c +8 -0
@@ -40,6 +40,7 @@#include "hw/misc/mps2-scc.h" #include "hw/misc/mps2-fpgaio.h" #include "hw/ssi/pl022.h" +#include "hw/i2c/arm_sbcon_i2c.h" #include "hw/net/lan9118.h" #include "net/net.h" #include "hw/watchdog/cmsdk-apb-watchdog.h"
@@ -365,6 +366,13 @@ static void mps2_common_init(MachineState *machine) qdev_get_gpio_in(orgate_dev, j)); } } +for (i =0 ; i <4 ; i++) { +static const hwaddr i2cbase[] = {0x40022000 ,/* Touch */ +0x40023000 ,/* Audio */ +0x40029000 ,/* Shield0 */ +0x4002a000 };/* Shield1 */ +sysbus_create_simple (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL ); + }/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature.
Signature · 1 line
2.21.3
PATCH v2 13/14 hw/arm/mps2: Add audio I2S interface as unimplemented device
In reply to Philippe Mathieu-Daudé--- hw/arm/mps2.c | 1 + 1 file changed, 1 insertion(+)
hw/arm/mps2.c +1 -0
@@ -373,6 +373,7 @@ static void mps2_common_init(MachineState *machine) 0x4002a000}; /* Shield1 */sysbus_create_simple (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL ); } +create_unimplemented_device ("i2s" ,0x40024000 ,0x400 );/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature.
Signature · 1 line
2.21.3
PATCH v2 14/14 hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface
In reply to Philippe Mathieu-DaudéFrom 'Application Note AN521', chapter 4.7:
The SMM implements four SBCon serial modules:
One SBCon module for use by the Color LCD touch interface. One SBCon module to configure the audio controller. Two general purpose SBCon modules, that connect to the Expansion headers J7 and J8, are intended for use with the V2C-Shield1 which provide an I2C interface on the headers.
--- hw/arm/mps2-tz.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
hw/arm/mps2-tz.c +18 -5
@@ -58,6 +58,7 @@#include "hw/arm/armsse.h" #include "hw/dma/pl080.h" #include "hw/ssi/pl022.h" +#include "hw/i2c/arm_sbcon_i2c.h" #include "hw/net/lan9118.h" #include "net/net.h" #include "hw/core/split-irq.h"
@@ -87,7 +88,7 @@ typedef struct {TZPPC ppc[5 ];TZMPC ssram_mpc[3 ];PL022State spi[5 ]; -UnimplementedDeviceState i2c[4 ]; +ArmSbconI2CState i2c[4 ];UnimplementedDeviceState i2s_audio;UnimplementedDeviceState gpio[4 ];UnimplementedDeviceState gfx;
@@ -365,6 +366,18 @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque,return sysbus_mmio_get_region (s,0 ); } +static MemoryRegion *make_i2c (MPS2TZMachineState *mms,void *opaque, +const char *name,hwaddr size) +{ +ArmSbconI2CState *i2c = opaque; +SysBusDevice *s; + +object_initialize_child (OBJECT (mms), name, i2c,TYPE_ARM_SBCON_I2C ); + s =SYS_BUS_DEVICE (i2c); +sysbus_realize (s, &error_fatal); +return sysbus_mmio_get_region (s,0 ); +} +static void mps2tz_common_init (MachineState *machine) {MPS2TZMachineState *mms =MPS2TZ_MACHINE (machine);
@@ -499,10 +512,10 @@ static void mps2tz_common_init(MachineState *machine) { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 }, { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000 }, { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000 }, - { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40207000, 0x1000 }, - { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40208000, 0x1000 }, - { "i2c2", make_unimp_dev, &mms->i2c[2], 0x4020c000, 0x1000 }, - { "i2c3", make_unimp_dev, &mms->i2c[3], 0x4020d000, 0x1000 }, + { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 }, + { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 }, + { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 }, + { "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000 }, }, }, { .name = "apb_ppcexp2",
Signature · 1 line
2.21.3
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
CC qga/qapi-generated/qga-qapi-commands.o CC qga/qapi-generated/qga-qapi-init-commands.o AR libqemuutil.a /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) CC qemu-img.o LINK elf2dmp GEN docs/interop/qemu-ga-ref.html AR libvhost-user.a GEN docs/interop/qemu-ga-ref.txt GEN docs/interop/qemu-ga-ref.7
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-keymap
LINK ivshmem-client/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK ivshmem-server/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-nbd
LINK qemu-storage-daemon/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-img/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-io
AS pc-bios/optionrom/multiboot.o/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
AS pc-bios/optionrom/linuxboot.o LINK qemu-edid CC pc-bios/optionrom/linuxboot_dma.o /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) AS pc-bios/optionrom/kvmvapic.o AS pc-bios/optionrom/pvh.o LINK fsdev/virtfs-proxy-helper LINK scsi/qemu-pr-helper
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
CC pc-bios/optionrom/pvh_main.o
BUILD pc-bios/optionrom/multiboot.img/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
BUILD pc-bios/optionrom/linuxboot.img BUILD pc-bios/optionrom/linuxboot_dma.img BUILD pc-bios/optionrom/kvmvapic.img --- BUILD pc-bios/optionrom/kvmvapic.raw SIGN pc-bios/optionrom/multiboot.bin SIGN pc-bios/optionrom/linuxboot.bin /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) SIGN pc-bios/optionrom/linuxboot_dma.bin SIGN pc-bios/optionrom/kvmvapic.bin BUILD pc-bios/optionrom/pvh.img BUILD pc-bios/optionrom/pvh.raw LINK virtiofsd SIGN pc-bios/optionrom/pvh.bin
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK vhost-user-input/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-ga/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
GEN x86_64-softmmu/hmp-commands.h
GEN x86_64-softmmu/hmp-commands-info.h
GEN x86_64-softmmu/config-devices.h
---
CC x86_64-softmmu/hw/display/vhost-user-gpu.o
CC x86_64-softmmu/hw/display/virtio-gpu-pci.o
CC x86_64-softmmu/hw/display/vhost-user-gpu-pci.o
/tmp/qemu-test/src/migration/ram.c:919:45: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
xbzrle_counters.encoding_rate = UINT64_MAX;
~ ^~~~~~~~~~/usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
---
1 error generated.
CC x86_64-softmmu/hw/display/virtio-vga.o
CC x86_64-softmmu/hw/display/vhost-user-vga.o/tmp/qemu-test/src/fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3483:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3606:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3760:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:3987:21: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4003:22: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!
/tmp/qemu-test/src/fpu/softfloat.c:4273:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!8 errors generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: migration/ram.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: fpu/softfloat.o] Error 1
CC x86_64-softmmu/hw/hyperv/hyperv.o
make: *** [Makefile:527: x86_64-softmmu/all] Error 2 Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>
sys.exit(main())
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=8c22585f28c04127b6fc465694eeb310', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-zd6vvg86/src/docker-src.2020-06-17-02.23.32.28692:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=8c22585f28c04127b6fc465694eeb310
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-zd6vvg86/src'
make: *** [docker-run-test-debug@fedora] Error 2
real 3m59.587s
user 0m7.859s
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]