From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: [PATCH 3/4] hw/arm/mps2-tz.c: Mark internal-only I2C buses as 'full'
Date: Fri, 3 Sep 2021 16:14:34 +0100 [thread overview]
Message-ID: <20210903151435.22379-4-peter.maydell@linaro.org> (raw)
In-Reply-To: <20210903151435.22379-1-peter.maydell@linaro.org>
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 <peter.maydell@linaro.org>
---
hw/arm/mps2-tz.c | 57 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 43 insertions(+), 14 deletions(-)
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index 746ba3cc59e..f40e854dec7 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -375,6 +375,7 @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno)
/* Union describing the device-specific extra data we pass to the devfn. */
typedef union PPCExtraData {
+ bool i2c_internal;
} PPCExtraData;
/* Most of the devices in the AN505 FPGA image sit behind
@@ -711,6 +712,20 @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque,
object_initialize_child(OBJECT(mms), name, i2c, TYPE_ARM_SBCON_I2C);
s = SYS_BUS_DEVICE(i2c);
sysbus_realize(s, &error_fatal);
+
+ /*
+ * If this is an internal-use-only i2c bus, mark it full
+ * so that user-created i2c devices are not plugged into it.
+ * If we implement models of any on-board i2c devices that
+ * plug in to one of the internal-use-only buses, then we will
+ * need to create and plugging those in here before we mark the
+ * bus as full.
+ */
+ if (extradata->i2c_internal) {
+ BusState *qbus = qdev_get_child_bus(DEVICE(i2c), "i2c");
+ qbus_mark_full(qbus);
+ }
+
return sysbus_mmio_get_region(s, 0);
}
@@ -921,10 +936,14 @@ static void mps2tz_common_init(MachineState *machine)
{ "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000, { 36, 37, 44 } },
{ "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000, { 38, 39, 45 } },
{ "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000, { 40, 41, 46 } },
- { "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 },
+ { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000, {},
+ { .i2c_internal = true /* touchscreen */ } },
+ { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000, {},
+ { .i2c_internal = true /* audio conf */ } },
+ { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000, {},
+ { .i2c_internal = false /* shield 0 */ } },
+ { "i2c3", make_i2c, &mms->i2c[3], 0x4020d000, 0x1000, {},
+ { .i2c_internal = false /* shield 1 */ } },
},
}, {
.name = "apb_ppcexp2",
@@ -965,15 +984,20 @@ static void mps2tz_common_init(MachineState *machine)
}, {
.name = "apb_ppcexp1",
.ports = {
- { "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000 },
- { "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000 },
+ { "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000, {},
+ { .i2c_internal = true /* touchscreen */ } },
+ { "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000, {},
+ { .i2c_internal = true /* audio conf */ } },
{ "spi0", make_spi, &mms->spi[0], 0x41202000, 0x1000, { 52 } },
{ "spi1", make_spi, &mms->spi[1], 0x41203000, 0x1000, { 53 } },
{ "spi2", make_spi, &mms->spi[2], 0x41204000, 0x1000, { 54 } },
- { "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000 },
- { "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000 },
+ { "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000, {},
+ { .i2c_internal = false /* shield 0 */ } },
+ { "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000, {},
+ { .i2c_internal = false /* shield 1 */ } },
{ /* port 7 reserved */ },
- { "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000 },
+ { "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000, {},
+ { .i2c_internal = true /* DDR4 EEPROM */ } },
},
}, {
.name = "apb_ppcexp2",
@@ -1015,15 +1039,20 @@ static void mps2tz_common_init(MachineState *machine)
}, {
.name = "apb_ppcexp1",
.ports = {
- { "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000 },
- { "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000 },
+ { "i2c0", make_i2c, &mms->i2c[0], 0x49200000, 0x1000, {},
+ { .i2c_internal = true /* touchscreen */ } },
+ { "i2c1", make_i2c, &mms->i2c[1], 0x49201000, 0x1000, {},
+ { .i2c_internal = true /* audio conf */ } },
{ "spi0", make_spi, &mms->spi[0], 0x49202000, 0x1000, { 53 } },
{ "spi1", make_spi, &mms->spi[1], 0x49203000, 0x1000, { 54 } },
{ "spi2", make_spi, &mms->spi[2], 0x49204000, 0x1000, { 55 } },
- { "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000 },
- { "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000 },
+ { "i2c2", make_i2c, &mms->i2c[2], 0x49205000, 0x1000, {},
+ { .i2c_internal = false /* shield 0 */ } },
+ { "i2c3", make_i2c, &mms->i2c[3], 0x49206000, 0x1000, {},
+ { .i2c_internal = false /* shield 1 */ } },
{ /* port 7 reserved */ },
- { "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000 },
+ { "i2c4", make_i2c, &mms->i2c[4], 0x49208000, 0x1000, {},
+ { .i2c_internal = true /* DDR4 EEPROM */ } },
},
}, {
.name = "apb_ppcexp2",
--
2.20.1
next prev parent reply other threads:[~2021-09-03 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 15:14 [PATCH 0/4] Support marking individual qbus buses as 'full' Peter Maydell
2021-09-03 15:14 ` [PATCH 1/4] qdev: Support marking individual " Peter Maydell
2021-09-04 8:48 ` Richard Henderson
2021-09-03 15:14 ` [PATCH 2/4] hw/arm/mps2-tz.c: Add extra data parameter to MakeDevFn Peter Maydell
2021-09-04 8:52 ` Richard Henderson
2021-09-03 15:14 ` Peter Maydell [this message]
2021-09-04 8:53 ` [PATCH 3/4] hw/arm/mps2-tz.c: Mark internal-only I2C buses as 'full' Richard Henderson
2021-09-03 15:14 ` [PATCH 4/4] hw/arm/mps2.c: " Peter Maydell
2021-09-04 8:54 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210903151435.22379-4-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).