qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "BALATON Zoltan" <balaton@eik.bme.hu>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 01/30] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels
Date: Fri, 7 Feb 2020 15:50:58 +0100	[thread overview]
Message-ID: <27d1f0e2-941c-11ca-d736-f25af055d9da@redhat.com> (raw)
In-Reply-To: <alpine.BSF.2.22.395.2002061320310.71431@zero.eik.bme.hu>

Hi Zoltan,

On 2/6/20 1:21 PM, BALATON Zoltan wrote:
> On Thu, 6 Feb 2020, Philippe Mathieu-Daudé wrote:
>> When booting without device tree, the Linux kernels uses the $R1
>> register to determine the machine type. The list of values is
>> registered at [1].
>>
>> There are two entries for the Raspberry Pi:
>>
>> - https://www.arm.linux.org.uk/developer/machines/list.php?mid=3138
>>  name: MACH_TYPE_BCM2708
>>  value: 0xc42 (3138)
>>  status: Active, not mainlined
>>  date: 15 Oct 2010
>>
>> - https://www.arm.linux.org.uk/developer/machines/list.php?mid=4828
>>  name: MACH_TYPE_BCM2835
>>  value: 4828
>>  status: Active, mainlined
>>  date: 6 Dec 2013
>>
>> QEMU always used the non-mainlined type MACH_TYPE_BCM2708.
>> The value 0xc43 is registered to 'MX51_GGC' (processor i.MX51), and
>> 0xc44 to 'Western Digital Sharespace NAS' (processor Marvell 88F5182).
>>
>> The Raspberry Pi foundation bootloader only sets the BCM2708 machine
>> type, see [2] or [3]:
>>
>> 133 9:
>> 134     mov r0, #0
>> 135     ldr r1, =3138       @ BCM2708 machine id
>> 136     ldr r2, atags       @ ATAGS
>> 137     bx  r4
>>
>> U-Boot only uses MACH_TYPE_BCM2708 (see [4]):
>>
>> 25 /*
>> 26  * 2835 is a SKU in a series for which the 2708 is the first or 
>> primary SoC,
>> 27  * so 2708 has historically been used rather than a dedicated 2835 ID.
>> 28  *
>> 29  * We don't define a machine type for bcm2709/bcm2836 since the RPi 
>> Foundation
>> 30  * chose to use someone else's previously registered machine ID 
>> (3139, MX51_GGC)
>> 31  * rather than obtaining a valid ID:-/
>> 32  *
>> 33  * For the bcm2837, hopefully a machine type is not needed, since 
>> everything
>> 34  * is DT.
>> 35  */
>>
>> While the definition MACH_BCM2709 with value 0xc43 was introduced in
>> a commit described "Add 2709 platform for Raspberry Pi 2" out of the
>> mainline Linux kernel, it does not seem used, and the platform is
>> introduced with Device Tree support anyway (see [5] and [6]).
>>
>> Remove the unused values (0xc43 introduced in commit 1df7d1f9303aef
>> "raspi: add raspberry pi 2 machine" and 0xc44 in commit bade58166f4
>> "raspi: Raspberry Pi 3 support"), keeping only MACH_TYPE_BCM2708.
>>
>> [1] https://www.arm.linux.org.uk/developer/machines/
>> [2] 
>> https://github.com/raspberrypi/tools/blob/920c7ed2e/armstubs/armstub7.S#L135 
>>
>> [3] 
>> https://github.com/raspberrypi/tools/blob/49719d554/armstubs/armstub7.S#L64 
>>
>> [4] 
>> https://gitlab.denx.de/u-boot/u-boot/blob/v2015.04/include/configs/rpi-common.h#L18 
>>
>> [5] 
>> https://github.com/raspberrypi/linux/commit/d9fac63adac#diff-6722037d79570df5b392a49e0e006573R526 
>>
>> [6] 
>> http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-February/001268.html 
>>
>>
>> Cc: Zoltán Baldaszti <bztemail@gmail.com>
>> Cc: Pekka Enberg <penberg@iki.fi>
>> Cc: Stephen Warren <swarren@nvidia.com>
>> Cc: Kshitij Soni <kshitij.soni@broadcom.com>
>> Cc: Michael Chan <michael.chan@broadcom.com>
>> Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
>> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/arm/raspi.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
>> index 3996f6c63a..ef76a27f33 100644
>> --- a/hw/arm/raspi.c
>> +++ b/hw/arm/raspi.c
>> @@ -29,8 +29,7 @@
>> #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by 
>> default */
>> #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
>>
>> -/* Table of Linux board IDs for different Pi versions */
>> -static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 
>> 0xc44};
> 
> Maybe worth a comment about why using this number (short, one line 
> version of commit message).

You mean something like:

/* Registered machine type:
  * https://www.arm.linux.org.uk/developer/machines/list.php?mid=3138
  */

> 
> Regards,
> BALATON Zoltan
> 
>> +#define MACH_TYPE_BCM2708   3138 /* Linux board IDs */
>>
>> typedef struct RasPiState {
>>     BCM283XState soc;
>> @@ -116,7 +115,7 @@ static void setup_boot(MachineState *machine, int 
>> version, size_t ram_size)
>>     static struct arm_boot_info binfo;
>>     int r;
>>
>> -    binfo.board_id = raspi_boardid[version];
>> +    binfo.board_id = MACH_TYPE_BCM2708;
>>     binfo.ram_size = ram_size;
>>     binfo.nb_cpus = machine->smp.cpus;
>>
>>



  reply	other threads:[~2020-02-07 15:02 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06  1:17 [PATCH v2 00/30] hw/arm/raspi: Dynamically create machines based on the board revision Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 01/30] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels Philippe Mathieu-Daudé
2020-02-06 12:21   ` BALATON Zoltan
2020-02-07 14:50     ` Philippe Mathieu-Daudé [this message]
2020-02-07 22:19       ` BALATON Zoltan
2020-02-06  1:17 ` [PATCH v2 02/30] hw/arm/raspi: Correct the board descriptions Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 03/30] hw/arm/raspi: Extract the version from the board revision Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 04/30] hw/arm/raspi: Extract the RAM size " Philippe Mathieu-Daudé
2020-02-06 12:24   ` BALATON Zoltan
2020-02-06  1:17 ` [PATCH v2 05/30] hw/arm/raspi: Extract the processor type " Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 06/30] hw/arm/raspi: Trivial code movement Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 07/30] hw/arm/raspi: Make machines children of abstract RaspiMachineClass Philippe Mathieu-Daudé
2020-02-06 12:24   ` BALATON Zoltan
2020-02-06  1:17 ` [PATCH v2 08/30] hw/arm/raspi: Make board_rev a field of RaspiMachineClass Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 09/30] hw/arm/raspi: Let class_init() directly call raspi_machine_init() Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 10/30] hw/arm/raspi: Set default RAM size to size encoded in board revision Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 11/30] hw/arm/raspi: Extract the board model from the " Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 12/30] hw/arm/raspi: Use a unique raspi_machine_class_init() method Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 13/30] hw/arm/raspi: Extract the cores count from the board revision Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 14/30] hw/arm/bcm2836: Restrict BCM283XClass declaration to C source Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 15/30] hw/arm/bcm2836: QOM'ify more by adding class_init() to each SoC type Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 16/30] hw/arm/bcm2836: Introduce BCM283XClass::core_count Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 17/30] hw/arm/bcm2836: Only provide "enabled-cpus" property to multicore SoCs Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 18/30] hw/arm/bcm2836: Split out common realize() code Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 19/30] hw/arm/bcm2836: Introduce the BCM2835 SoC Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 20/30] hw/arm/raspi: Add the Raspberry Pi Zero machine Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 21/30] hw/arm/raspi: Add the Raspberry Pi B+ machine Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 22/30] tests/acceptance/boot_linux_console: Use raspi console model as key Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 23/30] tests/acceptance/boot_linux_console: Add raspi version=2 parameter Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 24/30] tests/acceptance/boot_linux_console: Test the raspi1 console Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 25/30] tests/acceptance/boot_linux_console: Test the raspi0 console Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 26/30] python/qemu/machine: Allow to use other serial consoles than default Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 27/30] tests/acceptance/boot_linux_console: Test the raspi1 AUX console Philippe Mathieu-Daudé
2020-02-06  1:17 ` [PATCH v2 28/30] tests/acceptance: Count Raspberry Pi logos displayed on framebuffer Philippe Mathieu-Daudé
2020-02-06  1:17 ` [NOTFORMERGE PATCH v2 29/30] hw/arm/bcm2836: Add the BCM2838 (ARMv8) Philippe Mathieu-Daudé
2020-02-06  1:17 ` [NOTFORMERGE PATCH v2 30/30] hw/arm/raspi: Add the Raspberry Pi 4 Philippe Mathieu-Daudé

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=27d1f0e2-941c-11ca-d736-f25af055d9da@redhat.com \
    --to=philmd@redhat.com \
    --cc=balaton@eik.bme.hu \
    --cc=f4bug@amsat.org \
    --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).