Skip to content

Commit d4b7831

Browse files
committed
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200623' into staging
target-arm queue: * util/oslib-posix : qemu_init_exec_dir implementation for Mac * target/arm: Last parts of neon decodetree conversion * hw/arm/virt: Add 5.0 HW compat props * hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status * mps2: Add CMSDK APB watchdog, FPGAIO block, S2I devices and I2C devices * mps2: Add some unimplemented-device stubs for audio and GPIO * mps2-tz: Use the ARM SBCon two-wire serial bus interface * target/arm: Check supported KVM features globally (not per vCPU) * tests/qtest/arm-cpu-features: Add feature setting tests * arm/virt: Add memory hot remove support # gpg: Signature made Tue 23 Jun 2020 12:38:31 BST # gpg: using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE # gpg: issuer "[email protected]" # gpg: Good signature from "Peter Maydell <[email protected]>" [ultimate] # gpg: aka "Peter Maydell <[email protected]>" [ultimate] # gpg: aka "Peter Maydell <[email protected]>" [ultimate] # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE * remotes/pmaydell/tags/pull-target-arm-20200623: (42 commits) arm/virt: Add memory hot remove support tests/qtest/arm-cpu-features: Add feature setting tests target/arm: Check supported KVM features globally (not per vCPU) hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface hw/arm/mps2: Add audio I2S interface as unimplemented device hw/arm/mps2: Add I2C devices hw/arm/mps2: Add SPI devices hw/arm/mps2: Map the FPGA I/O block hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices hw/arm/mps2: Add CMSDK APB watchdog device hw/arm/mps2: Rename CMSDK AHB peripheral region hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string hw/i2c: Add header for ARM SBCon two-wire serial bus interface hw/i2c/versatile_i2c: Add SCL/SDA definitions hw/i2c/versatile_i2c: Add definitions for register addresses hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status target/arm: Remove dead code relating to SABA and UABA target/arm: Remove unnecessary gen_io_end() calls target/arm: Move some functions used only in translate-neon.inc.c to that file ... Signed-off-by: Peter Maydell <[email protected]>
2 parents d88d5a3 + 539533b commit d4b7831

27 files changed

+1625
-1152
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ M: Peter Maydell <[email protected]>
842842
843843
S: Maintained
844844
F: hw/*/versatile*
845+
F: include/hw/i2c/arm_sbcon_i2c.h
845846
F: hw/misc/arm_sysctl.c
846847
F: docs/system/arm/versatile.rst
847848

hw/acpi/generic_event_device.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,33 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
193193
}
194194
}
195195

196+
static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev,
197+
DeviceState *dev, Error **errp)
198+
{
199+
AcpiGedState *s = ACPI_GED(hotplug_dev);
200+
201+
if ((object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) &&
202+
!(object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)))) {
203+
acpi_memory_unplug_request_cb(hotplug_dev, &s->memhp_state, dev, errp);
204+
} else {
205+
error_setg(errp, "acpi: device unplug request for unsupported device"
206+
" type: %s", object_get_typename(OBJECT(dev)));
207+
}
208+
}
209+
210+
static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev,
211+
DeviceState *dev, Error **errp)
212+
{
213+
AcpiGedState *s = ACPI_GED(hotplug_dev);
214+
215+
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
216+
acpi_memory_unplug_cb(&s->memhp_state, dev, errp);
217+
} else {
218+
error_setg(errp, "acpi: device unplug for unsupported device"
219+
" type: %s", object_get_typename(OBJECT(dev)));
220+
}
221+
}
222+
196223
static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
197224
{
198225
AcpiGedState *s = ACPI_GED(adev);
@@ -318,6 +345,8 @@ static void acpi_ged_class_init(ObjectClass *class, void *data)
318345
dc->vmsd = &vmstate_acpi_ged;
319346

320347
hc->plug = acpi_ged_device_plug_cb;
348+
hc->unplug_request = acpi_ged_unplug_request_cb;
349+
hc->unplug = acpi_ged_unplug_cb;
321350

322351
adevc->send_event = acpi_ged_send_event;
323352
}

hw/arm/Kconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ config HIGHBANK
5959
select ARM_TIMER # sp804
6060
select ARM_V7M
6161
select PL011 # UART
62-
select PL022 # Serial port
62+
select PL022 # SPI
6363
select PL031 # RTC
6464
select PL061 # GPIO
6565
select PL310 # cache controller
@@ -222,7 +222,7 @@ config STELLARIS
222222
select CMSDK_APB_WATCHDOG
223223
select I2C
224224
select PL011 # UART
225-
select PL022 # Serial port
225+
select PL022 # SPI
226226
select PL061 # GPIO
227227
select SSD0303 # OLED display
228228
select SSD0323 # OLED display
@@ -401,10 +401,12 @@ config MPS2
401401
select MPS2_FPGAIO
402402
select MPS2_SCC
403403
select OR_IRQ
404-
select PL022 # Serial port
404+
select PL022 # SPI
405405
select PL080 # DMA controller
406406
select SPLIT_IRQ
407407
select UNIMP
408+
select CMSDK_APB_WATCHDOG
409+
select VERSATILE_I2C
408410

409411
config FSL_IMX7
410412
bool

hw/arm/mps2-tz.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "hw/arm/armsse.h"
5959
#include "hw/dma/pl080.h"
6060
#include "hw/ssi/pl022.h"
61+
#include "hw/i2c/arm_sbcon_i2c.h"
6162
#include "hw/net/lan9118.h"
6263
#include "net/net.h"
6364
#include "hw/core/split-irq.h"
@@ -87,7 +88,7 @@ typedef struct {
8788
TZPPC ppc[5];
8889
TZMPC ssram_mpc[3];
8990
PL022State spi[5];
90-
UnimplementedDeviceState i2c[4];
91+
ArmSbconI2CState i2c[4];
9192
UnimplementedDeviceState i2s_audio;
9293
UnimplementedDeviceState gpio[4];
9394
UnimplementedDeviceState gfx;
@@ -365,6 +366,18 @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque,
365366
return sysbus_mmio_get_region(s, 0);
366367
}
367368

369+
static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque,
370+
const char *name, hwaddr size)
371+
{
372+
ArmSbconI2CState *i2c = opaque;
373+
SysBusDevice *s;
374+
375+
object_initialize_child(OBJECT(mms), name, i2c, TYPE_ARM_SBCON_I2C);
376+
s = SYS_BUS_DEVICE(i2c);
377+
sysbus_realize(s, &error_fatal);
378+
return sysbus_mmio_get_region(s, 0);
379+
}
380+
368381
static void mps2tz_common_init(MachineState *machine)
369382
{
370383
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
@@ -499,10 +512,10 @@ static void mps2tz_common_init(MachineState *machine)
499512
{ "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 },
500513
{ "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000 },
501514
{ "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000 },
502-
{ "i2c0", make_unimp_dev, &mms->i2c[0], 0x40207000, 0x1000 },
503-
{ "i2c1", make_unimp_dev, &mms->i2c[1], 0x40208000, 0x1000 },
504-
{ "i2c2", make_unimp_dev, &mms->i2c[2], 0x4020c000, 0x1000 },
505-
{ "i2c3", make_unimp_dev, &mms->i2c[3], 0x4020d000, 0x1000 },
515+
{ "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 },
516+
{ "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 },
517+
{ "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 },
518+
{ "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000 },
506519
},
507520
}, {
508521
.name = "apb_ppcexp2",

hw/arm/mps2.c

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@
3838
#include "hw/timer/cmsdk-apb-timer.h"
3939
#include "hw/timer/cmsdk-apb-dualtimer.h"
4040
#include "hw/misc/mps2-scc.h"
41+
#include "hw/misc/mps2-fpgaio.h"
42+
#include "hw/ssi/pl022.h"
43+
#include "hw/i2c/arm_sbcon_i2c.h"
4144
#include "hw/net/lan9118.h"
4245
#include "net/net.h"
46+
#include "hw/watchdog/cmsdk-apb-watchdog.h"
4347

4448
typedef enum MPS2FPGAType {
4549
FPGA_AN385,
@@ -65,8 +69,12 @@ typedef struct {
6569
MemoryRegion blockram_m2;
6670
MemoryRegion blockram_m3;
6771
MemoryRegion sram;
72+
/* FPGA APB subsystem */
6873
MPS2SCC scc;
74+
MPS2FPGAIO fpgaio;
75+
/* CMSDK APB subsystem */
6976
CMSDKAPBDualTimer dualtimer;
77+
CMSDKAPBWatchdog watchdog;
7078
} MPS2MachineState;
7179

7280
#define TYPE_MPS2_MACHINE "mps2"
@@ -111,6 +119,7 @@ static void mps2_common_init(MachineState *machine)
111119
MemoryRegion *system_memory = get_system_memory();
112120
MachineClass *mc = MACHINE_GET_CLASS(machine);
113121
DeviceState *armv7m, *sccdev;
122+
int i;
114123

115124
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
116125
error_report("This board can only be used with CPU %s",
@@ -210,10 +219,11 @@ static void mps2_common_init(MachineState *machine)
210219
*/
211220
create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
212221
0x40000000, 0x00010000);
213-
create_unimplemented_device("CMSDK peripheral region @0x40010000",
222+
create_unimplemented_device("CMSDK AHB peripheral region @0x40010000",
214223
0x40010000, 0x00010000);
215224
create_unimplemented_device("Extra peripheral region @0x40020000",
216225
0x40020000, 0x00010000);
226+
217227
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
218228
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
219229

@@ -225,7 +235,6 @@ static void mps2_common_init(MachineState *machine)
225235
*/
226236
Object *orgate;
227237
DeviceState *orgate_dev;
228-
int i;
229238

230239
orgate = object_new(TYPE_OR_IRQ);
231240
object_property_set_int(orgate, 6, "num-lines", &error_fatal);
@@ -262,7 +271,6 @@ static void mps2_common_init(MachineState *machine)
262271
*/
263272
Object *orgate;
264273
DeviceState *orgate_dev;
265-
int i;
266274

267275
orgate = object_new(TYPE_OR_IRQ);
268276
object_property_set_int(orgate, 10, "num-lines", &error_fatal);
@@ -298,25 +306,74 @@ static void mps2_common_init(MachineState *machine)
298306
default:
299307
g_assert_not_reached();
300308
}
309+
for (i = 0; i < 4; i++) {
310+
static const hwaddr gpiobase[] = {0x40010000, 0x40011000,
311+
0x40012000, 0x40013000};
312+
create_unimplemented_device("cmsdk-ahb-gpio", gpiobase[i], 0x1000);
313+
}
301314

315+
/* CMSDK APB subsystem */
302316
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
303317
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
304-
305318
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
306319
TYPE_CMSDK_APB_DUALTIMER);
307320
qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
308321
sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
309322
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
310323
qdev_get_gpio_in(armv7m, 10));
311324
sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000);
312-
325+
object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
326+
TYPE_CMSDK_APB_WATCHDOG);
327+
qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ);
328+
sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
329+
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
330+
qdev_get_gpio_in_named(armv7m, "NMI", 0));
331+
sysbus_mmio_map(SYS_BUS_DEVICE(&mms->watchdog), 0, 0x40008000);
332+
333+
/* FPGA APB subsystem */
313334
object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC);
314335
sccdev = DEVICE(&mms->scc);
315336
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
316337
qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
317338
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
318339
sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal);
319340
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
341+
object_initialize_child(OBJECT(mms), "fpgaio",
342+
&mms->fpgaio, TYPE_MPS2_FPGAIO);
343+
qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", 25000000);
344+
sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal);
345+
sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0x40028000);
346+
sysbus_create_simple(TYPE_PL022, 0x40025000, /* External ADC */
347+
qdev_get_gpio_in(armv7m, 22));
348+
for (i = 0; i < 2; i++) {
349+
static const int spi_irqno[] = {11, 24};
350+
static const hwaddr spibase[] = {0x40020000, /* APB */
351+
0x40021000, /* LCD */
352+
0x40026000, /* Shield0 */
353+
0x40027000}; /* Shield1 */
354+
DeviceState *orgate_dev;
355+
Object *orgate;
356+
int j;
357+
358+
orgate = object_new(TYPE_OR_IRQ);
359+
object_property_set_int(orgate, 2, "num-lines", &error_fatal);
360+
orgate_dev = DEVICE(orgate);
361+
qdev_realize(orgate_dev, NULL, &error_fatal);
362+
qdev_connect_gpio_out(orgate_dev, 0,
363+
qdev_get_gpio_in(armv7m, spi_irqno[i]));
364+
for (j = 0; j < 2; j++) {
365+
sysbus_create_simple(TYPE_PL022, spibase[2 * i + j],
366+
qdev_get_gpio_in(orgate_dev, j));
367+
}
368+
}
369+
for (i = 0; i < 4; i++) {
370+
static const hwaddr i2cbase[] = {0x40022000, /* Touch */
371+
0x40023000, /* Audio */
372+
0x40029000, /* Shield0 */
373+
0x4002a000}; /* Shield1 */
374+
sysbus_create_simple(TYPE_ARM_SBCON_I2C, i2cbase[i], NULL);
375+
}
376+
create_unimplemented_device("i2s", 0x40024000, 0x400);
320377

321378
/* In hardware this is a LAN9220; the LAN9118 is software compatible
322379
* except that it doesn't support the checksum-offload feature.

hw/arm/realview.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "hw/cpu/a9mpcore.h"
2727
#include "hw/intc/realview_gic.h"
2828
#include "hw/irq.h"
29+
#include "hw/i2c/arm_sbcon_i2c.h"
2930

3031
#define SMP_BOOT_ADDR 0xe0000000
3132
#define SMP_BOOTREG_ADDR 0x10000030
@@ -282,7 +283,7 @@ static void realview_init(MachineState *machine,
282283
}
283284
}
284285

285-
dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
286+
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
286287
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
287288
i2c_create_slave(i2c, "ds1338", 0x68);
288289

hw/arm/versatilepb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "sysemu/sysemu.h"
1919
#include "hw/pci/pci.h"
2020
#include "hw/i2c/i2c.h"
21+
#include "hw/i2c/arm_sbcon_i2c.h"
2122
#include "hw/irq.h"
2223
#include "hw/boards.h"
2324
#include "exec/address-spaces.h"
@@ -314,7 +315,7 @@ static void versatile_init(MachineState *machine, int board_id)
314315
/* Add PL031 Real Time Clock. */
315316
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
316317

317-
dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
318+
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL);
318319
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
319320
i2c_create_slave(i2c, "ds1338", 0x68);
320321

hw/arm/vexpress.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "hw/char/pl011.h"
4343
#include "hw/cpu/a9mpcore.h"
4444
#include "hw/cpu/a15mpcore.h"
45+
#include "hw/i2c/arm_sbcon_i2c.h"
4546

4647
#define VEXPRESS_BOARD_ID 0x8e0
4748
#define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024)
@@ -640,7 +641,7 @@ static void vexpress_common_init(MachineState *machine)
640641
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
641642
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
642643

643-
dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL);
644+
dev = sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NULL);
644645
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
645646
i2c_create_slave(i2c, "sii9022", 0x39);
646647

0 commit comments

Comments
 (0)