Skip to content

Commit 68e5795

Browse files
committed
hw/arm/mps2-tz.c: Mark internal-only I2C buses as 'full'
The various MPS2 boards have multiple I2C buses: typically a bus dedicated to the audio configuration, one for the LCD touchscreen controller, one for a DDR4 EEPROM, and two which are connected to the external Shield expansion connector. Mark the buses which are used only for board-internal devices as 'full' so that if the user creates i2c devices on the commandline without specifying a bus name then they will be connected to the I2C controller used for the Shield connector, where guest software will expect them. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-id: [email protected]
1 parent e6f79ac commit 68e5795

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

hw/arm/mps2-tz.c

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno)
375375

376376
/* Union describing the device-specific extra data we pass to the devfn. */
377377
typedef union PPCExtraData {
378+
bool i2c_internal;
378379
} PPCExtraData;
379380

380381
/* Most of the devices in the AN505 FPGA image sit behind
@@ -711,6 +712,20 @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque,
711712
object_initialize_child(OBJECT(mms), name, i2c, TYPE_ARM_SBCON_I2C);
712713
s = SYS_BUS_DEVICE(i2c);
713714
sysbus_realize(s, &error_fatal);
715+
716+
/*
717+
* If this is an internal-use-only i2c bus, mark it full
718+
* so that user-created i2c devices are not plugged into it.
719+
* If we implement models of any on-board i2c devices that
720+
* plug in to one of the internal-use-only buses, then we will
721+
* need to create and plugging those in here before we mark the
722+
* bus as full.
723+
*/
724+
if (extradata->i2c_internal) {
725+
BusState *qbus = qdev_get_child_bus(DEVICE(i2c), "i2c");
726+
qbus_mark_full(qbus);
727+
}
728+
714729
return sysbus_mmio_get_region(s, 0);
715730
}
716731

@@ -921,10 +936,14 @@ static void mps2tz_common_init(MachineState *machine)
921936
{ "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000, { 36, 37, 44 } },
922937
{ "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000, { 38, 39, 45 } },
923938
{ "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000, { 40, 41, 46 } },
924-
{ "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 },
925-
{ "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 },
926-
{ "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 },
927-
{ "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000 },
939+
{ "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000, {},
940+
{ .i2c_internal = true /* touchscreen */ } },
941+
{ "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000, {},
942+
{ .i2c_internal = true /* audio conf */ } },
943+
{ "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000, {},
944+
{ .i2c_internal = false /* shield 0 */ } },
945+
{ "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000, {},
946+
{ .i2c_internal = false /* shield 1 */ } },
928947
},
929948
}, {
930949
.name = "apb_ppcexp2",
@@ -965,15 +984,20 @@ static void mps2tz_common_init(MachineState *machine)
965984
}, {
966985
.name = "apb_ppcexp1",
967986
.ports = {
968-
{ "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000 },
969-
{ "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000 },
987+
{ "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000, {},
988+
{ .i2c_internal = true /* touchscreen */ } },
989+
{ "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000, {},
990+
{ .i2c_internal = true /* audio conf */ } },
970991
{ "spi0", make_spi, &mms->spi[0], 0x41202000, 0x1000, { 52 } },
971992
{ "spi1", make_spi, &mms->spi[1], 0x41203000, 0x1000, { 53 } },
972993
{ "spi2", make_spi, &mms->spi[2], 0x41204000, 0x1000, { 54 } },
973-
{ "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000 },
974-
{ "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000 },
994+
{ "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000, {},
995+
{ .i2c_internal = false /* shield 0 */ } },
996+
{ "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000, {},
997+
{ .i2c_internal = false /* shield 1 */ } },
975998
{ /* port 7 reserved */ },
976-
{ "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000 },
999+
{ "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000, {},
1000+
{ .i2c_internal = true /* DDR4 EEPROM */ } },
9771001
},
9781002
}, {
9791003
.name = "apb_ppcexp2",
@@ -1015,15 +1039,20 @@ static void mps2tz_common_init(MachineState *machine)
10151039
}, {
10161040
.name = "apb_ppcexp1",
10171041
.ports = {
1018-
{ "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000 },
1019-
{ "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000 },
1042+
{ "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000, {},
1043+
{ .i2c_internal = true /* touchscreen */ } },
1044+
{ "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000, {},
1045+
{ .i2c_internal = true /* audio conf */ } },
10201046
{ "spi0", make_spi, &mms->spi[0], 0x49202000, 0x1000, { 53 } },
10211047
{ "spi1", make_spi, &mms->spi[1], 0x49203000, 0x1000, { 54 } },
10221048
{ "spi2", make_spi, &mms->spi[2], 0x49204000, 0x1000, { 55 } },
1023-
{ "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000 },
1024-
{ "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000 },
1049+
{ "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000, {},
1050+
{ .i2c_internal = false /* shield 0 */ } },
1051+
{ "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000, {},
1052+
{ .i2c_internal = false /* shield 1 */ } },
10251053
{ /* port 7 reserved */ },
1026-
{ "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000 },
1054+
{ "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000, {},
1055+
{ .i2c_internal = true /* DDR4 EEPROM */ } },
10271056
},
10281057
}, {
10291058
.name = "apb_ppcexp2",

0 commit comments

Comments
 (0)