2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2012-08-05 16:07:22 +00:00
|
|
|
/*
|
rpi: BCM2837 and Raspberry Pi 3 32-bit support
The Raspberry Pi 3 contains a BCM2837 SoC. The BCM2837 is a BCM2836 with
the CPU complex swapped out for a quad-core ARMv8. This can operate in 32-
or 64-bit mode. 32-bit mode is the current default selected by the
VideoCore firmware on the Raspberry Pi 3. This patch adds a 32-bit port of
U-Boot for the Raspberry Pi 3.
>From U-Boot's perspective, the only delta between the RPi 2 and RPi 3 is a
change in usage of the SoC UARTs. On all previous Pis, the PL011 was the
only UART in use. The Raspberry Pi 3 adds a Bluetooth module which uses a
UART to connect to the SoC. By default, the PL011 is used for this purpose
since it has larger FIFOs than the other "mini" UART. However, this can
be configured via the VideoCore firmware's config.txt file. This patch
hard-codes use of the mini UART in the RPi 3 port. If your system uses the
PL011 UART for the console even on the RPi 3, please use the RPi 2 U-Boot
port instead. A future change might determine which UART to use at
run-time, thus allowing the RPi 2 and RPi 3 (32-bit) ports to be squashed
together.
The mini UART has some limitations. One externally visible issue in the
BCM2837 integration is that the UART divides the SoC's "core clock" to
generate the baud rate. The core clock is typically variable, and under
control of the VideoCore firmware for thermal management reasons. If the
VC FW does modify the core clock rate, UART communication will be
corrupted since the baud rate will vary from the expected value. This was
not an issue for the PL011 UART, since it is fed by a fixed 3MHz clock. To
work around this, the VideoCore firmware can be told not to modify the SoC
core clock. However, the only way this can happen and be thermally safe is
to limit the core clock to a low/minimum frequency. This leaves
performance on the table for use-cases that don't care about a UART
console. Consequently, use of the mini UART console must be explicitly
requested by entering the following line into config.txt:
enable_uart=1
A recent version of the VC firmware is required to ensure that the mini
UART is fully and correctly initialized by the VC FW; at least
firmware.git 046effa13ebc "firmware: arm_loader: emmc clock depends on
core clock See: https://github.com/raspberrypi/firmware/issues/572".
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-25 04:15:20 +00:00
|
|
|
* (C) Copyright 2012-2016 Stephen Warren
|
2012-08-05 16:07:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2013-05-27 18:31:18 +00:00
|
|
|
#include <config.h>
|
2014-09-22 23:30:56 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:46 +00:00
|
|
|
#include <env.h>
|
2016-11-02 09:36:20 +00:00
|
|
|
#include <efi_loader.h>
|
2014-07-13 20:01:51 +00:00
|
|
|
#include <fdt_support.h>
|
2015-02-03 11:32:31 +00:00
|
|
|
#include <fdt_simplefb.h>
|
2019-11-14 19:57:45 +00:00
|
|
|
#include <init.h>
|
2013-05-27 18:31:18 +00:00
|
|
|
#include <lcd.h>
|
2015-09-02 23:24:58 +00:00
|
|
|
#include <memalign.h>
|
2014-07-13 20:01:51 +00:00
|
|
|
#include <mmc.h>
|
2014-09-22 23:30:56 +00:00
|
|
|
#include <asm/gpio.h>
|
2013-01-29 16:37:37 +00:00
|
|
|
#include <asm/arch/mbox.h>
|
2017-04-05 22:23:36 +00:00
|
|
|
#include <asm/arch/msg.h>
|
2013-01-29 16:37:42 +00:00
|
|
|
#include <asm/arch/sdhci.h>
|
2012-08-05 16:07:22 +00:00
|
|
|
#include <asm/global_data.h>
|
rpi: BCM2837 and Raspberry Pi 3 32-bit support
The Raspberry Pi 3 contains a BCM2837 SoC. The BCM2837 is a BCM2836 with
the CPU complex swapped out for a quad-core ARMv8. This can operate in 32-
or 64-bit mode. 32-bit mode is the current default selected by the
VideoCore firmware on the Raspberry Pi 3. This patch adds a 32-bit port of
U-Boot for the Raspberry Pi 3.
>From U-Boot's perspective, the only delta between the RPi 2 and RPi 3 is a
change in usage of the SoC UARTs. On all previous Pis, the PL011 was the
only UART in use. The Raspberry Pi 3 adds a Bluetooth module which uses a
UART to connect to the SoC. By default, the PL011 is used for this purpose
since it has larger FIFOs than the other "mini" UART. However, this can
be configured via the VideoCore firmware's config.txt file. This patch
hard-codes use of the mini UART in the RPi 3 port. If your system uses the
PL011 UART for the console even on the RPi 3, please use the RPi 2 U-Boot
port instead. A future change might determine which UART to use at
run-time, thus allowing the RPi 2 and RPi 3 (32-bit) ports to be squashed
together.
The mini UART has some limitations. One externally visible issue in the
BCM2837 integration is that the UART divides the SoC's "core clock" to
generate the baud rate. The core clock is typically variable, and under
control of the VideoCore firmware for thermal management reasons. If the
VC FW does modify the core clock rate, UART communication will be
corrupted since the baud rate will vary from the expected value. This was
not an issue for the PL011 UART, since it is fed by a fixed 3MHz clock. To
work around this, the VideoCore firmware can be told not to modify the SoC
core clock. However, the only way this can happen and be thermally safe is
to limit the core clock to a low/minimum frequency. This leaves
performance on the table for use-cases that don't care about a UART
console. Consequently, use of the mini UART console must be explicitly
requested by entering the following line into config.txt:
enable_uart=1
A recent version of the VC firmware is required to ensure that the mini
UART is fully and correctly initialized by the VC FW; at least
firmware.git 046effa13ebc "firmware: arm_loader: emmc clock depends on
core clock See: https://github.com/raspberrypi/firmware/issues/572".
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-25 04:15:20 +00:00
|
|
|
#include <dm/platform_data/serial_bcm283x_mu.h>
|
ARM: add Raspberry Pi 3 64-bit config
On all Pis so far, the VC FW provides a short stub to set up the ARM CPU
before entering the kernel (a/k/a U-Boot for us). This feature is not
currently supported by the VC FW when booting in 64-bit mode. However,
this feature will likely appear in the near future, and this U-Boot port
assumes that such a feature is in place. Without that feature, or a
temporary workaround described below, U-Boot will not boot.
Once the VC FW does provide the ARM stub, u-boot.bin built for rpi_3 can
be used drectly as kernel7.img, in the same way as any other RPi port. The
following config.txt is required:
# Fix mini UART input frequency, and setup/enable up the UART.
# Without this option, U-Boot will not boot, even if you don't care
# about the serial console. This option will always be required for
# all RPi3 use-cases, unless the PL011 UART is used, which is not
# yet supported by rpi_3* builds of U-Boot.
enable_uart=1
# Boot in AArch64 (64-bit) mode.
# It is possible that a future VC FW will remove the need for this
# option, instead auto-setting 32-/64-bit mode based on the "kernel"
# filename present on the SD card.
arm_control=0x200
Prior to the VC FW providing the ARM boot stub, you can use the following
steps to build an equivalent stub into the U-Boot binary:
git clone https://github.com/swarren/rpi-3-aarch64-demo.git \
../rpi-3-aarch64-demo
(cd ../rpi-3-aarch64-demo && ./build.sh)
Build U-Boot for rpi_3 in the usual way
cat ../rpi-3-aarch64-demo/armstub64.bin u-boot.bin > u-boot.bin.stubbed
Use u-boot.bin.stubbed as kernel7.img on the Pi SD card.
In this case, the following additional entries are required in config.txt:
# Tell the FW to load the kernel image at address 0, the reset vector.
kernel_old=1
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2016-04-02 03:14:15 +00:00
|
|
|
#ifdef CONFIG_ARM64
|
|
|
|
#include <asm/armv8/mmu.h>
|
|
|
|
#endif
|
2017-02-10 16:28:05 +00:00
|
|
|
#include <watchdog.h>
|
2018-01-23 17:05:21 +00:00
|
|
|
#include <dm/pinctrl.h>
|
2012-08-05 16:07:22 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2019-11-19 15:01:02 +00:00
|
|
|
/* Assigned in lowlevel_init.S
|
|
|
|
* Push the variable into the .data section so that it
|
|
|
|
* does not get cleared later.
|
|
|
|
*/
|
|
|
|
unsigned long __section(".data") fw_dtb_pointer;
|
2016-11-11 10:59:07 +00:00
|
|
|
|
2017-04-05 22:23:45 +00:00
|
|
|
/* TODO(sjg@chromium.org): Move these to the msg.c file */
|
2013-01-29 16:37:37 +00:00
|
|
|
struct msg_get_arm_mem {
|
|
|
|
struct bcm2835_mbox_hdr hdr;
|
|
|
|
struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
|
|
|
|
u32 end_tag;
|
|
|
|
};
|
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
struct msg_get_board_rev {
|
|
|
|
struct bcm2835_mbox_hdr hdr;
|
|
|
|
struct bcm2835_mbox_tag_get_board_rev get_board_rev;
|
|
|
|
u32 end_tag;
|
|
|
|
};
|
|
|
|
|
2016-02-22 21:06:47 +00:00
|
|
|
struct msg_get_board_serial {
|
|
|
|
struct bcm2835_mbox_hdr hdr;
|
|
|
|
struct bcm2835_mbox_tag_get_board_serial get_board_serial;
|
|
|
|
u32 end_tag;
|
|
|
|
};
|
|
|
|
|
2014-09-27 02:51:39 +00:00
|
|
|
struct msg_get_mac_address {
|
|
|
|
struct bcm2835_mbox_hdr hdr;
|
|
|
|
struct bcm2835_mbox_tag_get_mac_address get_mac_address;
|
|
|
|
u32 end_tag;
|
|
|
|
};
|
|
|
|
|
2013-01-29 16:37:42 +00:00
|
|
|
struct msg_get_clock_rate {
|
|
|
|
struct bcm2835_mbox_hdr hdr;
|
|
|
|
struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
|
|
|
|
u32 end_tag;
|
|
|
|
};
|
|
|
|
|
2017-01-22 23:34:39 +00:00
|
|
|
#ifdef CONFIG_ARM64
|
|
|
|
#define DTB_DIR "broadcom/"
|
|
|
|
#else
|
|
|
|
#define DTB_DIR ""
|
|
|
|
#endif
|
|
|
|
|
2015-12-05 05:07:44 +00:00
|
|
|
/*
|
2018-11-16 12:06:05 +00:00
|
|
|
* https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
|
2015-12-05 05:07:44 +00:00
|
|
|
*/
|
2015-12-05 05:07:45 +00:00
|
|
|
struct rpi_model {
|
2014-11-19 04:40:21 +00:00
|
|
|
const char *name;
|
|
|
|
const char *fdtfile;
|
2014-12-06 03:56:46 +00:00
|
|
|
bool has_onboard_eth;
|
2015-12-05 05:07:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct rpi_model rpi_model_unknown = {
|
|
|
|
"Unknown model",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm283x-rpi-other.dtb",
|
2015-12-05 05:07:45 +00:00
|
|
|
false,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct rpi_model rpi_models_new_scheme[] = {
|
2018-04-06 08:45:49 +00:00
|
|
|
[0x0] = {
|
|
|
|
"Model A",
|
|
|
|
DTB_DIR "bcm2835-rpi-a.dtb",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
[0x1] = {
|
|
|
|
"Model B",
|
|
|
|
DTB_DIR "bcm2835-rpi-b.dtb",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
[0x2] = {
|
|
|
|
"Model A+",
|
|
|
|
DTB_DIR "bcm2835-rpi-a-plus.dtb",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
[0x3] = {
|
|
|
|
"Model B+",
|
|
|
|
DTB_DIR "bcm2835-rpi-b-plus.dtb",
|
|
|
|
true,
|
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x4] = {
|
2015-02-16 19:16:15 +00:00
|
|
|
"2 Model B",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2836-rpi-2-b.dtb",
|
2015-02-16 19:16:15 +00:00
|
|
|
true,
|
|
|
|
},
|
2018-04-06 08:45:49 +00:00
|
|
|
[0x6] = {
|
|
|
|
"Compute Module",
|
|
|
|
DTB_DIR "bcm2835-rpi-cm.dtb",
|
|
|
|
false,
|
|
|
|
},
|
2016-03-25 04:15:18 +00:00
|
|
|
[0x8] = {
|
|
|
|
"3 Model B",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2837-rpi-3-b.dtb",
|
2016-03-25 04:15:18 +00:00
|
|
|
true,
|
|
|
|
},
|
2015-12-05 05:07:46 +00:00
|
|
|
[0x9] = {
|
|
|
|
"Zero",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-zero.dtb",
|
2015-12-05 05:07:46 +00:00
|
|
|
false,
|
|
|
|
},
|
2018-04-06 08:45:49 +00:00
|
|
|
[0xA] = {
|
|
|
|
"Compute Module 3",
|
|
|
|
DTB_DIR "bcm2837-rpi-cm3.dtb",
|
|
|
|
false,
|
|
|
|
},
|
2017-11-26 09:38:53 +00:00
|
|
|
[0xC] = {
|
|
|
|
"Zero W",
|
|
|
|
DTB_DIR "bcm2835-rpi-zero-w.dtb",
|
|
|
|
false,
|
|
|
|
},
|
2018-03-15 14:05:37 +00:00
|
|
|
[0xD] = {
|
|
|
|
"3 Model B+",
|
|
|
|
DTB_DIR "bcm2837-rpi-3-b-plus.dtb",
|
|
|
|
true,
|
|
|
|
},
|
2018-11-16 12:07:39 +00:00
|
|
|
[0xE] = {
|
|
|
|
"3 Model A+",
|
|
|
|
DTB_DIR "bcm2837-rpi-3-a-plus.dtb",
|
|
|
|
false,
|
|
|
|
},
|
2019-01-30 22:24:44 +00:00
|
|
|
[0x10] = {
|
|
|
|
"Compute Module 3+",
|
|
|
|
DTB_DIR "bcm2837-rpi-cm3.dtb",
|
|
|
|
false,
|
|
|
|
},
|
2019-07-24 14:39:07 +00:00
|
|
|
[0x11] = {
|
|
|
|
"4 Model B",
|
|
|
|
DTB_DIR "bcm2711-rpi-4-b.dtb",
|
|
|
|
true,
|
|
|
|
},
|
2015-12-05 05:07:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct rpi_model rpi_models_old_scheme[] = {
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x2] = {
|
2016-01-29 08:35:52 +00:00
|
|
|
"Model B",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x3] = {
|
2016-01-29 08:35:52 +00:00
|
|
|
"Model B",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x4] = {
|
2016-01-29 08:35:52 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x5] = {
|
2016-01-29 08:35:52 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x6] = {
|
2016-01-29 08:35:52 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x7] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model A",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-a.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
false,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x8] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model A",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-a.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
false,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x9] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model A",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-a.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
false,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0xd] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0xe] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0xf] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model B rev2",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-rev2.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x10] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Model B+",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-plus.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
true,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x11] = {
|
2014-11-19 04:40:21 +00:00
|
|
|
"Compute Module",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-cm.dtb",
|
2014-12-06 03:56:46 +00:00
|
|
|
false,
|
2014-11-19 04:40:21 +00:00
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x12] = {
|
2014-12-24 03:01:43 +00:00
|
|
|
"Model A+",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-a-plus.dtb",
|
2014-12-24 03:01:43 +00:00
|
|
|
false,
|
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x13] = {
|
2015-04-13 03:43:25 +00:00
|
|
|
"Model B+",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-b-plus.dtb",
|
2015-04-13 03:43:25 +00:00
|
|
|
true,
|
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x14] = {
|
2015-04-13 03:43:25 +00:00
|
|
|
"Compute Module",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-cm.dtb",
|
2015-04-13 03:43:25 +00:00
|
|
|
false,
|
|
|
|
},
|
2015-12-05 05:07:44 +00:00
|
|
|
[0x15] = {
|
2015-10-14 15:17:54 +00:00
|
|
|
"Model A+",
|
2017-01-22 23:34:39 +00:00
|
|
|
DTB_DIR "bcm2835-rpi-a-plus.dtb",
|
2015-10-14 15:17:54 +00:00
|
|
|
false,
|
|
|
|
},
|
2014-11-19 04:40:21 +00:00
|
|
|
};
|
|
|
|
|
2015-12-05 05:07:45 +00:00
|
|
|
static uint32_t revision;
|
|
|
|
static uint32_t rev_scheme;
|
|
|
|
static uint32_t rev_type;
|
|
|
|
static const struct rpi_model *model;
|
2014-11-19 04:40:21 +00:00
|
|
|
|
2012-08-05 16:07:22 +00:00
|
|
|
int dram_init(void)
|
|
|
|
{
|
2015-07-24 07:22:12 +00:00
|
|
|
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1);
|
2013-01-29 16:37:37 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
BCM2835_MBOX_INIT_HDR(msg);
|
|
|
|
BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
|
|
|
|
|
|
|
|
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
|
|
|
|
if (ret) {
|
|
|
|
printf("bcm2835: Could not query ARM memory size\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
|
2012-08-05 16:07:22 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-09-09 16:31:56 +00:00
|
|
|
#ifdef CONFIG_OF_BOARD
|
|
|
|
int dram_init_banksize(void)
|
|
|
|
{
|
2019-12-05 17:53:13 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = fdtdec_setup_memory_banksize();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return fdtdec_setup_mem_size_base();
|
2019-09-09 16:31:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
static void set_fdtfile(void)
|
|
|
|
{
|
|
|
|
const char *fdtfile;
|
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("fdtfile"))
|
2014-11-19 04:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2015-12-05 05:07:45 +00:00
|
|
|
fdtfile = model->fdtfile;
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("fdtfile", fdtfile);
|
2014-11-19 04:40:21 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 10:59:07 +00:00
|
|
|
/*
|
|
|
|
* If the firmware provided a valid FDT at boot time, let's expose it in
|
|
|
|
* ${fdt_addr} so it may be passed unmodified to the kernel.
|
|
|
|
*/
|
|
|
|
static void set_fdt_addr(void)
|
|
|
|
{
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("fdt_addr"))
|
2016-11-11 10:59:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
2017-08-03 18:22:10 +00:00
|
|
|
env_set_hex("fdt_addr", fw_dtb_pointer);
|
2016-11-11 10:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prevent relocation from stomping on a firmware provided FDT blob.
|
|
|
|
*/
|
|
|
|
unsigned long board_get_usable_ram_top(unsigned long total_size)
|
|
|
|
{
|
|
|
|
if ((gd->ram_top - fw_dtb_pointer) > SZ_64M)
|
|
|
|
return gd->ram_top;
|
|
|
|
return fw_dtb_pointer & ~0xffff;
|
|
|
|
}
|
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
static void set_usbethaddr(void)
|
2014-09-27 02:51:39 +00:00
|
|
|
{
|
2015-07-24 07:22:12 +00:00
|
|
|
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1);
|
2014-09-27 02:51:39 +00:00
|
|
|
int ret;
|
|
|
|
|
2015-12-05 05:07:45 +00:00
|
|
|
if (!model->has_onboard_eth)
|
2014-12-06 03:56:46 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("usbethaddr"))
|
2014-11-19 04:40:21 +00:00
|
|
|
return;
|
2014-09-27 02:51:39 +00:00
|
|
|
|
|
|
|
BCM2835_MBOX_INIT_HDR(msg);
|
|
|
|
BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
|
|
|
|
|
|
|
|
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
|
|
|
|
if (ret) {
|
|
|
|
printf("bcm2835: Could not query MAC address\n");
|
|
|
|
/* Ignore error; not critical */
|
2014-11-19 04:40:21 +00:00
|
|
|
return;
|
2014-09-27 02:51:39 +00:00
|
|
|
}
|
|
|
|
|
2017-08-03 18:22:11 +00:00
|
|
|
eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
|
2014-09-27 02:51:39 +00:00
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
if (!env_get("ethaddr"))
|
|
|
|
env_set("ethaddr", env_get("usbethaddr"));
|
2016-02-03 15:08:09 +00:00
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-25 13:10:26 +00:00
|
|
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
|
|
|
static void set_board_info(void)
|
|
|
|
{
|
2015-12-05 05:07:45 +00:00
|
|
|
char s[11];
|
|
|
|
|
|
|
|
snprintf(s, sizeof(s), "0x%X", revision);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("board_revision", s);
|
2015-12-05 05:07:45 +00:00
|
|
|
snprintf(s, sizeof(s), "%d", rev_scheme);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("board_rev_scheme", s);
|
2015-12-05 05:07:45 +00:00
|
|
|
/* Can't rename this to board_rev_type since it's an ABI for scripts */
|
|
|
|
snprintf(s, sizeof(s), "0x%X", rev_type);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("board_rev", s);
|
|
|
|
env_set("board_name", model->name);
|
2015-08-25 13:10:26 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
|
|
|
|
|
2016-02-22 21:06:47 +00:00
|
|
|
static void set_serial_number(void)
|
|
|
|
{
|
|
|
|
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_serial, msg, 1);
|
|
|
|
int ret;
|
|
|
|
char serial_string[17] = { 0 };
|
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("serial#"))
|
2016-02-22 21:06:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
BCM2835_MBOX_INIT_HDR(msg);
|
|
|
|
BCM2835_MBOX_INIT_TAG_NO_REQ(&msg->get_board_serial, GET_BOARD_SERIAL);
|
|
|
|
|
|
|
|
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
|
|
|
|
if (ret) {
|
|
|
|
printf("bcm2835: Could not query board serial\n");
|
|
|
|
/* Ignore error; not critical */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-06 11:47:40 +00:00
|
|
|
snprintf(serial_string, sizeof(serial_string), "%016llx",
|
2016-02-22 21:06:47 +00:00
|
|
|
msg->get_board_serial.body.resp.serial);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("serial#", serial_string);
|
2016-02-22 21:06:47 +00:00
|
|
|
}
|
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
2016-11-11 10:59:07 +00:00
|
|
|
set_fdt_addr();
|
2014-11-19 04:40:21 +00:00
|
|
|
set_fdtfile();
|
|
|
|
set_usbethaddr();
|
2015-08-25 13:10:26 +00:00
|
|
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
|
|
|
set_board_info();
|
|
|
|
#endif
|
2016-02-22 21:06:47 +00:00
|
|
|
set_serial_number();
|
|
|
|
|
2014-09-27 02:51:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-19 04:40:21 +00:00
|
|
|
static void get_board_rev(void)
|
|
|
|
{
|
2015-07-24 07:22:12 +00:00
|
|
|
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_rev, msg, 1);
|
2014-11-19 04:40:21 +00:00
|
|
|
int ret;
|
2015-12-05 05:07:45 +00:00
|
|
|
const struct rpi_model *models;
|
|
|
|
uint32_t models_count;
|
2014-11-19 04:40:21 +00:00
|
|
|
|
|
|
|
BCM2835_MBOX_INIT_HDR(msg);
|
|
|
|
BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
|
|
|
|
|
|
|
|
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
|
|
|
|
if (ret) {
|
|
|
|
printf("bcm2835: Could not query board revision\n");
|
|
|
|
/* Ignore error; not critical */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-16 19:16:15 +00:00
|
|
|
/*
|
|
|
|
* For details of old-vs-new scheme, see:
|
|
|
|
* https://github.com/pimoroni/RPi.version/blob/master/RPi/version.py
|
|
|
|
* http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=99293&p=690282
|
|
|
|
* (a few posts down)
|
2015-03-24 05:00:25 +00:00
|
|
|
*
|
|
|
|
* For the RPi 1, bit 24 is the "warranty bit", so we mask off just the
|
|
|
|
* lower byte to use as the board rev:
|
|
|
|
* http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250
|
|
|
|
* http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594
|
2015-02-16 19:16:15 +00:00
|
|
|
*/
|
2015-12-05 05:07:45 +00:00
|
|
|
revision = msg->get_board_rev.body.resp.rev;
|
|
|
|
if (revision & 0x800000) {
|
|
|
|
rev_scheme = 1;
|
|
|
|
rev_type = (revision >> 4) & 0xff;
|
|
|
|
models = rpi_models_new_scheme;
|
|
|
|
models_count = ARRAY_SIZE(rpi_models_new_scheme);
|
|
|
|
} else {
|
|
|
|
rev_scheme = 0;
|
|
|
|
rev_type = revision & 0xff;
|
|
|
|
models = rpi_models_old_scheme;
|
|
|
|
models_count = ARRAY_SIZE(rpi_models_old_scheme);
|
2014-12-24 03:01:43 +00:00
|
|
|
}
|
2015-12-05 05:07:45 +00:00
|
|
|
if (rev_type >= models_count) {
|
|
|
|
printf("RPI: Board rev 0x%x outside known range\n", rev_type);
|
|
|
|
model = &rpi_model_unknown;
|
|
|
|
} else if (!models[rev_type].name) {
|
|
|
|
printf("RPI: Board rev 0x%x unknown\n", rev_type);
|
|
|
|
model = &rpi_model_unknown;
|
|
|
|
} else {
|
|
|
|
model = &models[rev_type];
|
2014-12-24 03:01:43 +00:00
|
|
|
}
|
2014-12-24 03:01:44 +00:00
|
|
|
|
2015-12-05 05:07:45 +00:00
|
|
|
printf("RPI %s (0x%x)\n", model->name, revision);
|
2014-11-19 04:40:21 +00:00
|
|
|
}
|
|
|
|
|
2016-09-26 12:26:50 +00:00
|
|
|
int board_init(void)
|
2016-08-15 15:48:51 +00:00
|
|
|
{
|
2017-02-10 16:28:05 +00:00
|
|
|
#ifdef CONFIG_HW_WATCHDOG
|
|
|
|
hw_watchdog_init();
|
|
|
|
#endif
|
2016-08-15 15:48:51 +00:00
|
|
|
|
2016-09-26 12:26:50 +00:00
|
|
|
get_board_rev();
|
|
|
|
|
|
|
|
gd->bd->bi_boot_params = 0x100;
|
|
|
|
|
2017-04-05 22:23:36 +00:00
|
|
|
return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
|
2016-08-15 15:48:51 +00:00
|
|
|
}
|
|
|
|
|
2017-04-02 08:25:20 +00:00
|
|
|
/*
|
|
|
|
* If the firmware passed a device tree use it for U-Boot.
|
|
|
|
*/
|
|
|
|
void *board_fdt_blob_setup(void)
|
|
|
|
{
|
|
|
|
if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
|
|
|
|
return NULL;
|
|
|
|
return (void *)fw_dtb_pointer;
|
|
|
|
}
|
|
|
|
|
2014-10-24 00:58:47 +00:00
|
|
|
int ft_board_setup(void *blob, bd_t *bd)
|
2013-05-27 18:31:18 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* For now, we simply always add the simplefb DT node. Later, we
|
|
|
|
* should be more intelligent, and e.g. only do this if no enabled DT
|
|
|
|
* node exists for the "real" graphics driver.
|
|
|
|
*/
|
|
|
|
lcd_dt_simplefb_add_node(blob);
|
2014-10-24 00:58:47 +00:00
|
|
|
|
2016-11-02 09:36:20 +00:00
|
|
|
#ifdef CONFIG_EFI_LOADER
|
|
|
|
/* Reserve the spin table */
|
2020-02-26 21:39:10 +00:00
|
|
|
efi_add_memory_map(0, CONFIG_RPI_EFI_NR_SPIN_PAGES,
|
|
|
|
EFI_RESERVED_MEMORY_TYPE, 0);
|
2016-11-02 09:36:20 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-24 00:58:47 +00:00
|
|
|
return 0;
|
2013-05-27 18:31:18 +00:00
|
|
|
}
|