From: "Cédric Le Goater" <clg@kaod.org>
To: Kane Chen <kane_chen@aspeedtech.com>,
Peter Maydell <peter.maydell@linaro.org>,
Steven Lee <steven_lee@aspeedtech.com>,
Troy Lee <leetroy@gmail.com>,
Jamin Lin <jamin_lin@aspeedtech.com>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Joel Stanley <joel@jms.id.au>,
"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: troy_lee@aspeedtech.com
Subject: Re: [SPAM] [PATCH v4 5/5] hw/misc/aspeed_sbc: Add machine parameter to alias OTP drive property
Date: Tue, 22 Jul 2025 11:35:17 +0200 [thread overview]
Message-ID: <1b3c89d8-ec01-4ff0-9bbf-0bfcabf1cbb2@kaod.org> (raw)
In-Reply-To: <20250708055810.2868680-6-kane_chen@aspeedtech.com>
On 7/8/25 07:57, Kane Chen wrote:
> From: Kane-Chen-AS <kane_chen@aspeedtech.com>
>
> This patch adds a new machine parameter `otpmem` which creates a QOM
> property alias on the aspeed_sbc device for the OTP drive.
>
> Example usage:
>
> ./qemu-system-arm \
> -machine ast2600-evb,otpmem=otp-drive \
> -blockdev driver=file,filename=otpmem.img,node-name=otp \
> -global aspeed-otp.drive=otp \
> ...
>
> With this change, the specified alias name (e.g. "otp-drive") becomes
> available on the QOM path `/machine/soc/sbc/otp-drive`.
>
> Signed-off-by: Kane-Chen-AS <kane_chen@aspeedtech.com>
> ---
> hw/arm/aspeed.c | 20 ++++++++++++++++++++
> hw/misc/aspeed_sbc.c | 8 ++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c31bbe7701..8ec32369a6 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -48,6 +48,7 @@ struct AspeedMachineState {
> uint32_t uart_chosen;
> char *fmc_model;
> char *spi_model;
> + char *otpmem;
> uint32_t hw_strap1;
> };
>
> @@ -1424,6 +1425,21 @@ static void aspeed_set_bmc_console(Object *obj, const char *value, Error **errp)
> bmc->uart_chosen = val + ASPEED_DEV_UART0;
> }
>
> +static char *aspeed_get_otpmem(Object *obj, Error **errp)
> +{
> + AspeedMachineState *bmc = ASPEED_MACHINE(obj);
> +
> + return g_strdup(bmc->otpmem);
> +}
> +
> +static void aspeed_set_otpmem(Object *obj, const char *value, Error **errp)
> +{
> + AspeedMachineState *bmc = ASPEED_MACHINE(obj);
> +
> + g_free(bmc->otpmem);
> + bmc->otpmem = g_strdup(value);
> +}
> +
> static void aspeed_machine_class_props_init(ObjectClass *oc)
> {
> object_class_property_add_bool(oc, "execute-in-place",
> @@ -1445,6 +1461,10 @@ static void aspeed_machine_class_props_init(ObjectClass *oc)
> aspeed_set_spi_model);
> object_class_property_set_description(oc, "spi-model",
> "Change the SPI Flash model");
> + object_class_property_add_str(oc, "otpmem", aspeed_get_otpmem,
> + aspeed_set_otpmem);
> + object_class_property_set_description(oc, "otpmem",
> + "Set OTP Memory type");
> }
>
> static void aspeed_machine_class_init_cpus_defaults(MachineClass *mc)
> diff --git a/hw/misc/aspeed_sbc.c b/hw/misc/aspeed_sbc.c
> index b56a8b7678..b82c5e37cc 100644
> --- a/hw/misc/aspeed_sbc.c
> +++ b/hw/misc/aspeed_sbc.c
> @@ -209,10 +209,18 @@ static void aspeed_sbc_instance_init(Object *obj)
> {
> AspeedSBCClass *sc = ASPEED_SBC_GET_CLASS(obj);
> AspeedSBCState *s = ASPEED_SBC(obj);
> + char *otpname;
>
> if (sc->has_otp) {
> object_initialize_child(OBJECT(s), "otp", &s->otp,
> TYPE_ASPEED_OTP);
> + otpname = object_property_get_str(qdev_get_machine(),
> + "otpmem",> + &error_abort);
This is a hack and I would prefer to prevent device models from
accessing directly the machine.
It would have been nice to have a machine option, but since the
user can specify a file for the OTP backend from the command line,
let's leave it as is.
Thanks,
C.
> + if (strlen(otpname)) {
> + object_property_add_alias(obj, otpname,
> + OBJECT(&s->otp), "drive");
> + }
> }
> }
>
next prev parent reply other threads:[~2025-07-22 9:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 5:57 [PATCH v4 0/5] ASPEED OTP QEMU model: block backend, machine alias, SoC integration Kane Chen via
2025-07-08 5:57 ` [PATCH v4 1/5] hw/misc/aspeed_otp: Add ASPEED OTP memory device model Kane Chen via
2025-07-22 9:30 ` [SPAM] " Cédric Le Goater
2025-07-22 9:54 ` Cédric Le Goater
2025-07-22 9:59 ` Kane Chen
2025-07-08 5:57 ` [PATCH v4 2/5] hw/misc/aspeed_sbc: Connect ASPEED OTP memory device to SBC Kane Chen via
2025-07-08 5:57 ` [PATCH v4 3/5] hw/arm: Integrate ASPEED OTP memory support into AST2600 SoCs Kane Chen via
2025-07-08 5:57 ` [PATCH v4 4/5] hw/misc/aspeed_otp: Add 'drive' property to support block backend Kane Chen via
2025-07-22 9:30 ` [SPAM] " Cédric Le Goater
2025-07-22 10:27 ` Alex Bennée
2025-07-22 11:27 ` Cédric Le Goater
2025-07-08 5:57 ` [PATCH v4 5/5] hw/misc/aspeed_sbc: Add machine parameter to alias OTP drive property Kane Chen via
2025-07-22 9:35 ` Cédric Le Goater [this message]
2025-07-22 9:41 ` [SPAM] [PATCH v4 0/5] ASPEED OTP QEMU model: block backend, machine alias, SoC integration Cédric Le Goater
2025-07-22 10:03 ` Kane Chen
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=1b3c89d8-ec01-4ff0-9bbf-0bfcabf1cbb2@kaod.org \
--to=clg@kaod.org \
--cc=andrew@codeconstruct.com.au \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=kane_chen@aspeedtech.com \
--cc=leetroy@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=troy_lee@aspeedtech.com \
/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).