From: Stefan Wahren <wahrenst@gmx.net>
To: Gregor Herburger <gregor.herburger@linutronix.de>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Eric Anholt <eric@anholt.net>
Cc: linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 3/4] firmware: raspberrypi: Add reboot mode support
Date: Tue, 30 Jun 2026 23:57:49 +0200 [thread overview]
Message-ID: <628b2768-80e6-4a7b-846f-d1124059f899@gmx.net> (raw)
In-Reply-To: <20260630-rpi-tryboot-v2-3-f68d2dc6aa27@linutronix.de>
Hi Gregor,
Am 30.06.26 um 22:59 schrieb Gregor Herburger:
> The Raspberry Pi firmware has a tryboot mode where it tries to boot from
> another partition. This can be used to create a A/B update schema.
>
> To enable this on the next boot the RPI_FIRMWARE_SET_REBOOT_FLAGS
> message must be send to the firmware.
>
> Add support for this by registering a reboot mode driver.
>
> Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de>
> ---
> drivers/firmware/Kconfig | 1 +
> drivers/firmware/raspberrypi.c | 23 +++++++++++++++++++++++
> include/soc/bcm2835/raspberrypi-firmware.h | 2 ++
> 3 files changed, 26 insertions(+)
>
> diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
> index bbd2155d84838..04bc8263e0017 100644
> --- a/drivers/firmware/Kconfig
> +++ b/drivers/firmware/Kconfig
> @@ -115,6 +115,7 @@ config ISCSI_IBFT
> config RASPBERRYPI_FIRMWARE
> tristate "Raspberry Pi Firmware Driver"
> depends on BCM2835_MBOX
> + select REBOOT_MODE
> help
> This option enables support for communicating with the firmware on the
> Raspberry Pi.
> diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
> index 0aa322e9a2e73..bba8d14604002 100644
> --- a/drivers/firmware/raspberrypi.c
> +++ b/drivers/firmware/raspberrypi.c
> @@ -14,6 +14,7 @@
> #include <linux/of.h>
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> +#include <linux/reboot-mode.h>
> #include <linux/slab.h>
> #include <soc/bcm2835/raspberrypi-firmware.h>
>
> @@ -29,6 +30,7 @@ struct rpi_firmware {
> struct mbox_client cl;
> struct mbox_chan *chan; /* The property channel. */
> struct completion c;
> + struct reboot_mode_driver reboot_mode;
> u32 enabled;
>
> struct kref consumers;
> @@ -273,10 +275,25 @@ static void devm_rpi_firmware_put(void *data)
> rpi_firmware_put(fw);
> }
>
> +static int rpi_firmware_reboot_mode_write(struct reboot_mode_driver *reboot,
> + unsigned int magic)
> +{
> + struct rpi_firmware *fw = container_of(reboot, struct rpi_firmware,
> + reboot_mode);
> + int ret = 0;
> +
> + if (magic)
> + ret = rpi_firmware_property(fw, RPI_FIRMWARE_SET_REBOOT_FLAGS,
> + &magic, sizeof(magic));
I think it's more elegant to check for !magic and return 0 directly. So
we can drop "ret".
> +
> + return ret;
> +}
> +
> static int rpi_firmware_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct rpi_firmware *fw;
> + int ret;
>
> /*
> * Memory will be freed by rpi_firmware_delete() once all users have
> @@ -306,6 +323,12 @@ static int rpi_firmware_probe(struct platform_device *pdev)
> rpi_register_hwmon_driver(dev, fw);
> rpi_register_clk_driver(dev);
>
> + fw->reboot_mode.dev = dev;
> + fw->reboot_mode.write = rpi_firmware_reboot_mode_write;
> + ret = devm_reboot_mode_register(dev, &fw->reboot_mode);
> + if (ret)
> + dev_err(dev, "Failed to register reboot mode: %d\n", ret);
I suggest to move all of this code into a function called
rpi_register_reboot_mode() ?
Best regards
> +
> return 0;
> }
>
> diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
> index 66cc5a426c3c5..f905bff0fb3ea 100644
> --- a/include/soc/bcm2835/raspberrypi-firmware.h
> +++ b/include/soc/bcm2835/raspberrypi-firmware.h
> @@ -81,6 +81,7 @@ enum rpi_firmware_property_tag {
> RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049,
> RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00030050,
> RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058,
> + RPI_FIRMWARE_GET_REBOOT_FLAGS = 0x00030064,
> RPI_FIRMWARE_NOTIFY_DISPLAY_DONE = 0x00030066,
> RPI_FIRMWARE_SET_CLOCK_STATE = 0x00038001,
> RPI_FIRMWARE_SET_CLOCK_RATE = 0x00038002,
> @@ -92,6 +93,7 @@ enum rpi_firmware_property_tag {
> RPI_FIRMWARE_SET_SDHOST_CLOCK = 0x00038042,
> RPI_FIRMWARE_SET_GPIO_CONFIG = 0x00038043,
> RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045,
> + RPI_FIRMWARE_SET_REBOOT_FLAGS = 0x00038064,
>
> /* Dispmanx TAGS */
> RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,
>
next prev parent reply other threads:[~2026-06-30 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 20:59 [PATCH v2 0/4] firmware: raspberrypi: Add support for the tryboot mode Gregor Herburger
2026-06-30 20:59 ` [PATCH v2 1/4] firmware: raspberrypi: reorder rpi_firmware_property_tag enum Gregor Herburger
2026-06-30 20:59 ` [PATCH v2 2/4] dt-bindings: raspberrypi,bcm2835-firmware: Include 'reboot-mode.yaml' Gregor Herburger
2026-07-01 7:24 ` Krzysztof Kozlowski
2026-06-30 20:59 ` [PATCH v2 3/4] firmware: raspberrypi: Add reboot mode support Gregor Herburger
2026-06-30 21:57 ` Stefan Wahren [this message]
2026-07-02 7:50 ` Gregor Herburger
2026-06-30 20:59 ` [PATCH v2 4/4] arm64: dts: broadcom: bcm2712: Add reboot modes to firmware node Gregor Herburger
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=628b2768-80e6-4a7b-846f-d1124059f899@gmx.net \
--to=wahrenst@gmx.net \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eric@anholt.net \
--cc=florian.fainelli@broadcom.com \
--cc=gregor.herburger@linutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=rjui@broadcom.com \
--cc=robh@kernel.org \
--cc=sbranden@broadcom.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