qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Sergey Kambalin <serg.oker@gmail.com>, qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org,
	Sergey Kambalin <sergey.kambalin@auriga.com>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH v6 11/41] Temporarily disable unimplemented rpi4b devices
Date: Mon, 26 Feb 2024 14:35:30 +0100	[thread overview]
Message-ID: <2ab7b523-816b-409b-a58a-f09e3f71ff8e@linaro.org> (raw)
In-Reply-To: <20240226000259.2752893-12-sergey.kambalin@auriga.com>

On 26/2/24 01:02, Sergey Kambalin wrote:
> This commit adds RPi4B device tree modifications:
> - disable pcie, rng200, thermal sensor and genet devices
>    (they're going to be re-enabled in the following commits)
> - create additional memory region in device tree
>    if RAM amount exceeds VC base address.

This patch really looks like a respin of
https://lore.kernel.org/qemu-devel/20201018205551.1537927-4-f4bug@amsat.org/

Keeping previous author S-o-b or adding a "based on work ..."
is usually welcomed.

> Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/raspi.c                  |  5 +--
>   hw/arm/raspi4b.c                | 62 +++++++++++++++++++++++++++++++++
>   include/hw/arm/raspi_platform.h |  4 +++
>   3 files changed, 67 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 8b1a046912..a7a662f40d 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -37,9 +37,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
>   #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
>   #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
>   
> -/* Registered machine type (matches RPi Foundation bootloader and U-Boot) */
> -#define MACH_TYPE_BCM2708   3138
> -
>   struct RaspiMachineState {
>       /*< private >*/
>       RaspiBaseMachineState parent_obj;
> @@ -75,7 +72,7 @@ static const struct {
>       [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
>   };
>   
> -static uint64_t board_ram_size(uint32_t board_rev)
> +uint64_t board_ram_size(uint32_t board_rev)
>   {
>       assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
>       return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE);
> diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
> index 36a4593928..49dec6e53a 100644
> --- a/hw/arm/raspi4b.c
> +++ b/hw/arm/raspi4b.c
> @@ -21,6 +21,7 @@
>   #include "hw/arm/boot.h"
>   #include "qom/object.h"
>   #include "hw/arm/bcm2838.h"
> +#include <libfdt.h>
>   
>   #define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b-2g")
>   OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
> @@ -30,6 +31,66 @@ struct Raspi4bMachineState {
>       BCM2838State soc;
>   };
>   
> +/*
> + * Add second memory region if board RAM amount exceeds VC base address
> + * (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf
> + * 1.2 Address Map)
> + */
> +static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
> +{
> +    int ret;
> +    uint32_t acells, scells;
> +    char *nodename = g_strdup_printf("/memory@%" PRIx64, mem_base);
> +
> +    acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells",
> +                                   NULL, &error_fatal);
> +    scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
> +                                   NULL, &error_fatal);
> +    if (acells == 0 || scells == 0) {
> +        fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
> +        ret = -1;
> +    } else {
> +        qemu_fdt_add_subnode(fdt, nodename);
> +        qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
> +        ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg",
> +                                           acells, mem_base,
> +                                           scells, mem_len);
> +    }
> +
> +    g_free(nodename);
> +    return ret;
> +}
> +
> +static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
> +{
> +    uint64_t ram_size;
> +
> +    /* Temporarily disable following devices until they are implemented */
> +    const char *nodes_to_remove[] = {
> +        "brcm,bcm2711-pcie",
> +        "brcm,bcm2711-rng200",
> +        "brcm,bcm2711-thermal",
> +        "brcm,bcm2711-genet-v5",
> +    };
> +
> +    for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) {
> +        const char *dev_str = nodes_to_remove[i];
> +
> +        int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
> +        if (offset >= 0) {
> +            if (!fdt_nop_node(fdt, offset)) {

Peter, I remember a discussion where you wre not keen on altering DTB
for non-Virt machines.

Since these devices are all implemented at the end of the series, why
not add the devices then the raspi4 board at the end, so this patch is
not even required?

Regards,

Phil.

> +                warn_report("bcm2711 dtc: %s has been disabled!", dev_str);
> +            }
> +        }
> +    }
> +
> +    ram_size = board_ram_size(info->board_id);
> +
> +    if (info->ram_size > UPPER_RAM_BASE) {
> +        raspi_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BASE);
> +    }
> +}



  reply	other threads:[~2024-02-26 13:36 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26  0:02 [PATCH v6 00/41] Raspberry Pi 4B machine Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 01/41] Split out common part of BCM283X classes Sergey Kambalin
2024-02-27  8:45   ` Philippe Mathieu-Daudé
2024-02-26  0:02 ` [PATCH v6 02/41] Split out common part of peripherals Sergey Kambalin
2024-02-27  8:58   ` Philippe Mathieu-Daudé
2024-02-26  0:02 ` [PATCH v6 03/41] Split out raspi machine common part Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 04/41] Introduce BCM2838 SoC Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 05/41] Add GIC-400 to " Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 06/41] Add BCM2838 GPIO stub Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 07/41] Implement BCM2838 GPIO functionality Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 08/41] Connect SD controller to BCM2838 GPIO Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 09/41] Add GPIO and SD to BCM2838 periph Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 10/41] Introduce Raspberry PI 4 machine Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 11/41] Temporarily disable unimplemented rpi4b devices Sergey Kambalin
2024-02-26 13:35   ` Philippe Mathieu-Daudé [this message]
2024-02-26 13:39     ` Peter Maydell
2024-02-26 16:06       ` Philippe Mathieu-Daudé
2024-02-26 16:41         ` Peter Maydell
2024-02-27  4:54           ` Kambalin, Sergey
2024-02-26  0:02 ` [PATCH v6 12/41] Add memory region for BCM2837 RPiVid ASB Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 13/41] Add BCM2838 PCIE Root Complex Sergey Kambalin
2024-02-26 13:25   ` Philippe Mathieu-Daudé
2024-02-26  0:02 ` [PATCH v6 14/41] Add BCM2838 PCIE host Sergey Kambalin
2024-02-26 16:28   ` Philippe Mathieu-Daudé
2024-02-26  0:02 ` [PATCH v6 15/41] Enable BCM2838 PCIE Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 16/41] Add RPi4 RNG200 Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 17/41] Implement BCM2838 thermal sensor Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 18/41] Add clock_isp stub Sergey Kambalin
2024-02-26 16:06   ` Philippe Mathieu-Daudé
2024-02-26 16:19   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 19/41] Add GENET stub Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 20/41] Add GENET register structs. Part 1 Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 21/41] Add GENET register structs. Part 2 Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 22/41] Add GENET register structs. Part 3 Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 23/41] Add GENET register structs. Part 4 Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 24/41] Add GENET register access macros Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 25/41] Implement GENET register ops Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 26/41] Implement GENET MDIO Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 27/41] Implement GENET TX path Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 28/41] Implement GENET RX path Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 29/41] Enable BCM2838 GENET controller Sergey Kambalin
2024-02-26  0:02 ` [PATCH v6 30/41] Add Rpi4b boot tests Sergey Kambalin
2024-02-26 16:40   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 31/41] Add mailbox test stub Sergey Kambalin
2024-02-26 16:21   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 32/41] Add mailbox test constants Sergey Kambalin
2024-02-26 16:23   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 33/41] Add mailbox tests tags. Part 1 Sergey Kambalin
2024-02-26 16:23   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 34/41] Add mailbox tests tags. Part 2 Sergey Kambalin
2024-02-26 16:23   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 35/41] Add mailbox tests tags. Part 3 Sergey Kambalin
2024-02-26 16:24   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 36/41] Add mailbox property tests. Part 1 Sergey Kambalin
2024-02-26 16:24   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 37/41] Add mailbox property tests. Part 2 Sergey Kambalin
2024-02-26 16:24   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 38/41] Add mailbox property tests. Part 3 Sergey Kambalin
2024-02-26 16:24   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 39/41] Add missed BCM2835 properties Sergey Kambalin
2024-02-26 16:25   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 40/41] Append added properties to mailbox test Sergey Kambalin
2024-02-26 16:25   ` Peter Maydell
2024-02-26  0:02 ` [PATCH v6 41/41] Add RPi4B to raspi.rst Sergey Kambalin
2024-02-26 16:42   ` Peter Maydell
2024-02-26 16:43     ` Peter Maydell
2024-02-26 16:52       ` Philippe Mathieu-Daudé
2024-02-26 16:54         ` Peter Maydell
2024-02-26 18:09 ` [PATCH v6 00/41] Raspberry Pi 4B machine Peter Maydell
2024-02-27 11:26   ` Peter Maydell
2024-02-27 15:22 ` Peter Maydell
2024-02-27 17:25   ` Peter Maydell

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=2ab7b523-816b-409b-a58a-f09e3f71ff8e@linaro.org \
    --to=philmd@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=serg.oker@gmail.com \
    --cc=sergey.kambalin@auriga.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).