Commit 8993056fb3d4af4f0cd078df20130d4e7c35c2f7
Committed by
Tom Rini
1 parent
0aac10f2f9
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
add support for Raspberry Pi Zero W
Signed-off-by: Dmitry Korunov <dessel.k@gmail.com>
Showing 5 changed files with 76 additions and 1 deletions Inline Diff
arch/arm/dts/bcm2835-rpi-zero-w.dts
File was created | 1 | /dts-v1/; | |
2 | #include "bcm2835.dtsi" | ||
3 | #include "bcm2835-rpi.dtsi" | ||
4 | #include "bcm283x-rpi-smsc9512.dtsi" | ||
5 | #include "bcm283x-rpi-usb-host.dtsi" | ||
6 | |||
7 | / { | ||
8 | compatible = "raspberrypi,model-zero-w", "brcm,bcm2835"; | ||
9 | model = "Raspberry Pi Zero W"; | ||
10 | |||
11 | leds { | ||
12 | act { | ||
13 | gpios = <&gpio 47 0>; | ||
14 | }; | ||
15 | }; | ||
16 | }; | ||
17 | |||
18 | &uart1 { | ||
19 | pinctrl-names = "default"; | ||
20 | pinctrl-0 = <&uart1_gpio14>; | ||
21 | status = "okay"; | ||
22 | }; | ||
23 | |||
24 | &hdmi { | ||
25 | hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>; | ||
26 | }; | ||
27 |
arch/arm/mach-bcm283x/Kconfig
1 | config BCM2835 | 1 | config BCM2835 |
2 | bool "Broadcom BCM2835 SoC support" | 2 | bool "Broadcom BCM2835 SoC support" |
3 | depends on ARCH_BCM283X | 3 | depends on ARCH_BCM283X |
4 | select CPU_ARM1176 | 4 | select CPU_ARM1176 |
5 | 5 | ||
6 | config BCM2836 | 6 | config BCM2836 |
7 | bool "Broadcom BCM2836 SoC support" | 7 | bool "Broadcom BCM2836 SoC support" |
8 | depends on ARCH_BCM283X | 8 | depends on ARCH_BCM283X |
9 | select ARMV7_LPAE | 9 | select ARMV7_LPAE |
10 | select CPU_V7 | 10 | select CPU_V7 |
11 | 11 | ||
12 | config BCM2837 | 12 | config BCM2837 |
13 | bool "Broadcom BCM2837 SoC support" | 13 | bool "Broadcom BCM2837 SoC support" |
14 | depends on ARCH_BCM283X | 14 | depends on ARCH_BCM283X |
15 | 15 | ||
16 | config BCM2837_32B | 16 | config BCM2837_32B |
17 | bool "Broadcom BCM2837 SoC 32-bit support" | 17 | bool "Broadcom BCM2837 SoC 32-bit support" |
18 | depends on ARCH_BCM283X | 18 | depends on ARCH_BCM283X |
19 | select BCM2837 | 19 | select BCM2837 |
20 | select ARMV7_LPAE | 20 | select ARMV7_LPAE |
21 | select CPU_V7 | 21 | select CPU_V7 |
22 | 22 | ||
23 | config BCM2837_64B | 23 | config BCM2837_64B |
24 | bool "Broadcom BCM2837 SoC 64-bit support" | 24 | bool "Broadcom BCM2837 SoC 64-bit support" |
25 | depends on ARCH_BCM283X | 25 | depends on ARCH_BCM283X |
26 | select BCM2837 | 26 | select BCM2837 |
27 | select ARM64 | 27 | select ARM64 |
28 | 28 | ||
29 | menu "Broadcom BCM283X family" | 29 | menu "Broadcom BCM283X family" |
30 | depends on ARCH_BCM283X | 30 | depends on ARCH_BCM283X |
31 | 31 | ||
32 | choice | 32 | choice |
33 | prompt "Broadcom BCM283X board select" | 33 | prompt "Broadcom BCM283X board select" |
34 | optional | 34 | optional |
35 | 35 | ||
36 | config TARGET_RPI | 36 | config TARGET_RPI |
37 | bool "Raspberry Pi (all BCM2835 variants)" | 37 | bool "Raspberry Pi (all BCM2835 variants)" |
38 | help | 38 | help |
39 | Support for all ARM1176-/BCM2835-based Raspberry Pi variants, such as | 39 | Support for all ARM1176-/BCM2835-based Raspberry Pi variants, such as |
40 | the A, A+, B, B+, Compute Module, and Zero. This option cannot | 40 | the A, A+, B, B+, Compute Module, and Zero. This option cannot |
41 | support BCM2836/BCM2837-based Raspberry Pis such as the RPi 2 and | 41 | support BCM2836/BCM2837-based Raspberry Pis such as the RPi 2 and |
42 | RPi 3 due to different peripheral address maps. | 42 | RPi 3 due to different peripheral address maps. |
43 | 43 | ||
44 | This option creates a build targetting the ARM1176 ISA. | 44 | This option creates a build targetting the ARM1176 ISA. |
45 | select BCM2835 | 45 | select BCM2835 |
46 | 46 | ||
47 | config TARGET_RPI_0_W | ||
48 | bool "Raspberry Pi Zero W" | ||
49 | help | ||
50 | Support for all ARM1176-/BCM2835-based Raspberry Pi variants, such as | ||
51 | the RPi Zero model W. | ||
52 | |||
53 | This option assumes the VideoCore firmware is configured to use the | ||
54 | mini UART (rather than PL011) for the serial console. This is the | ||
55 | default on the RPi Zero W. To enable the UART console, the following | ||
56 | non-default option must be present in config.txt: enable_uart=1. | ||
57 | This is required for U-Boot to operate correctly, even if you only | ||
58 | care about the HDMI/usbkbd console. | ||
59 | |||
60 | This option creates a build targetting the ARMv7/AArch32 ISA. | ||
61 | select BCM2835 | ||
62 | |||
47 | config TARGET_RPI_2 | 63 | config TARGET_RPI_2 |
48 | bool "Raspberry Pi 2" | 64 | bool "Raspberry Pi 2" |
49 | help | 65 | help |
50 | Support for all BCM2836-based Raspberry Pi variants, such as | 66 | Support for all BCM2836-based Raspberry Pi variants, such as |
51 | the RPi 2 model B. | 67 | the RPi 2 model B. |
52 | 68 | ||
53 | This option also supports BCM2837-based variants such as the RPi 3 | 69 | This option also supports BCM2837-based variants such as the RPi 3 |
54 | Model B, when run in 32-bit mode, provided you have configured the | 70 | Model B, when run in 32-bit mode, provided you have configured the |
55 | VideoCore firmware to select the PL011 UART for the console by: | 71 | VideoCore firmware to select the PL011 UART for the console by: |
56 | a) config.txt should contain dtoverlay=pi3-miniuart-bt. | 72 | a) config.txt should contain dtoverlay=pi3-miniuart-bt. |
57 | b) You should run the following to tell the VC FW to process DT when | 73 | b) You should run the following to tell the VC FW to process DT when |
58 | booting, and copy u-boot.bin.img (rather than u-boot.bin) to the SD | 74 | booting, and copy u-boot.bin.img (rather than u-boot.bin) to the SD |
59 | card as the kernel image: | 75 | card as the kernel image: |
60 | 76 | ||
61 | path/to/kernel/scripts/mkknlimg --dtok u-boot.bin u-boot.bin.img | 77 | path/to/kernel/scripts/mkknlimg --dtok u-boot.bin u-boot.bin.img |
62 | 78 | ||
63 | This works as of firmware.git commit 046effa13ebc "firmware: | 79 | This works as of firmware.git commit 046effa13ebc "firmware: |
64 | arm_loader: emmc clock depends on core clock See: | 80 | arm_loader: emmc clock depends on core clock See: |
65 | https://github.com/raspberrypi/firmware/issues/572". | 81 | https://github.com/raspberrypi/firmware/issues/572". |
66 | 82 | ||
67 | This option creates a build targetting the ARMv7/AArch32 ISA. | 83 | This option creates a build targetting the ARMv7/AArch32 ISA. |
68 | select BCM2836 | 84 | select BCM2836 |
69 | 85 | ||
70 | config TARGET_RPI_3_32B | 86 | config TARGET_RPI_3_32B |
71 | bool "Raspberry Pi 3 32-bit build" | 87 | bool "Raspberry Pi 3 32-bit build" |
72 | help | 88 | help |
73 | Support for all BCM2837-based Raspberry Pi variants, such as | 89 | Support for all BCM2837-based Raspberry Pi variants, such as |
74 | the RPi 3 model B, in AArch32 (32-bit) mode. | 90 | the RPi 3 model B, in AArch32 (32-bit) mode. |
75 | 91 | ||
76 | This option assumes the VideoCore firmware is configured to use the | 92 | This option assumes the VideoCore firmware is configured to use the |
77 | mini UART (rather than PL011) for the serial console. This is the | 93 | mini UART (rather than PL011) for the serial console. This is the |
78 | default on the RPi 3. To enable the UART console, the following non- | 94 | default on the RPi 3. To enable the UART console, the following non- |
79 | default option must be present in config.txt: enable_uart=1. This is | 95 | default option must be present in config.txt: enable_uart=1. This is |
80 | required for U-Boot to operate correctly, even if you only care | 96 | required for U-Boot to operate correctly, even if you only care |
81 | about the HDMI/usbkbd console. | 97 | about the HDMI/usbkbd console. |
82 | 98 | ||
83 | This option creates a build targetting the ARMv7/AArch32 ISA. | 99 | This option creates a build targetting the ARMv7/AArch32 ISA. |
84 | select BCM2837_32B | 100 | select BCM2837_32B |
85 | 101 | ||
86 | config TARGET_RPI_3 | 102 | config TARGET_RPI_3 |
87 | bool "Raspberry Pi 3 64-bit build" | 103 | bool "Raspberry Pi 3 64-bit build" |
88 | help | 104 | help |
89 | Support for all BCM2837-based Raspberry Pi variants, such as | 105 | Support for all BCM2837-based Raspberry Pi variants, such as |
90 | the RPi 3 model B, in AArch64 (64-bit) mode. | 106 | the RPi 3 model B, in AArch64 (64-bit) mode. |
91 | 107 | ||
92 | This option assumes the VideoCore firmware is configured to use the | 108 | This option assumes the VideoCore firmware is configured to use the |
93 | mini UART (rather than PL011) for the serial console. This is the | 109 | mini UART (rather than PL011) for the serial console. This is the |
94 | default on the RPi 3. To enable the UART console, the following non- | 110 | default on the RPi 3. To enable the UART console, the following non- |
95 | default option must be present in config.txt: enable_uart=1. This is | 111 | default option must be present in config.txt: enable_uart=1. This is |
96 | required for U-Boot to operate correctly, even if you only care | 112 | required for U-Boot to operate correctly, even if you only care |
97 | about the HDMI/usbkbd console. | 113 | about the HDMI/usbkbd console. |
98 | 114 | ||
99 | At the time of writing, the VC FW requires a non-default option in | 115 | At the time of writing, the VC FW requires a non-default option in |
100 | config.txt to request the ARM CPU boot in 64-bit mode: | 116 | config.txt to request the ARM CPU boot in 64-bit mode: |
101 | arm_control=0x200 | 117 | arm_control=0x200 |
102 | 118 | ||
103 | The VC FW typically provides ARM "stub" code to set up the CPU and | 119 | The VC FW typically provides ARM "stub" code to set up the CPU and |
104 | quiesce secondary SMP CPUs. This is not currently true in 64-bit | 120 | quiesce secondary SMP CPUs. This is not currently true in 64-bit |
105 | mode. In order to boot U-Boot before the VC FW is enhanced, please | 121 | mode. In order to boot U-Boot before the VC FW is enhanced, please |
106 | see the commit description for the commit which added RPi3 support | 122 | see the commit description for the commit which added RPi3 support |
107 | for a workaround. Since the instructions are temporary, they are not | 123 | for a workaround. Since the instructions are temporary, they are not |
108 | duplicated here. The VC FW enhancement is tracked in | 124 | duplicated here. The VC FW enhancement is tracked in |
109 | https://github.com/raspberrypi/firmware/issues/579. | 125 | https://github.com/raspberrypi/firmware/issues/579. |
110 | 126 | ||
111 | This option creates a build targetting the ARMv8/AArch64 ISA. | 127 | This option creates a build targetting the ARMv8/AArch64 ISA. |
112 | select BCM2837_64B | 128 | select BCM2837_64B |
113 | 129 | ||
114 | endchoice | 130 | endchoice |
115 | 131 | ||
116 | config SYS_BOARD | 132 | config SYS_BOARD |
117 | default "rpi" | 133 | default "rpi" |
118 | 134 | ||
119 | config SYS_VENDOR | 135 | config SYS_VENDOR |
120 | default "raspberrypi" | 136 | default "raspberrypi" |
121 | 137 | ||
122 | config SYS_SOC | 138 | config SYS_SOC |
123 | default "bcm283x" | 139 | default "bcm283x" |
124 | 140 | ||
125 | config SYS_CONFIG_NAME | 141 | config SYS_CONFIG_NAME |
126 | default "rpi" | 142 | default "rpi" |
127 | 143 | ||
128 | endmenu | 144 | endmenu |
129 | 145 |
board/raspberrypi/rpi/rpi.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2012-2016 Stephen Warren | 2 | * (C) Copyright 2012-2016 Stephen Warren |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0 | 4 | * SPDX-License-Identifier: GPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <common.h> | 7 | #include <common.h> |
8 | #include <inttypes.h> | 8 | #include <inttypes.h> |
9 | #include <config.h> | 9 | #include <config.h> |
10 | #include <dm.h> | 10 | #include <dm.h> |
11 | #include <efi_loader.h> | 11 | #include <efi_loader.h> |
12 | #include <fdt_support.h> | 12 | #include <fdt_support.h> |
13 | #include <fdt_simplefb.h> | 13 | #include <fdt_simplefb.h> |
14 | #include <lcd.h> | 14 | #include <lcd.h> |
15 | #include <memalign.h> | 15 | #include <memalign.h> |
16 | #include <mmc.h> | 16 | #include <mmc.h> |
17 | #include <asm/gpio.h> | 17 | #include <asm/gpio.h> |
18 | #include <asm/arch/mbox.h> | 18 | #include <asm/arch/mbox.h> |
19 | #include <asm/arch/msg.h> | 19 | #include <asm/arch/msg.h> |
20 | #include <asm/arch/sdhci.h> | 20 | #include <asm/arch/sdhci.h> |
21 | #include <asm/global_data.h> | 21 | #include <asm/global_data.h> |
22 | #include <dm/platform_data/serial_bcm283x_mu.h> | 22 | #include <dm/platform_data/serial_bcm283x_mu.h> |
23 | #ifdef CONFIG_ARM64 | 23 | #ifdef CONFIG_ARM64 |
24 | #include <asm/armv8/mmu.h> | 24 | #include <asm/armv8/mmu.h> |
25 | #endif | 25 | #endif |
26 | #include <watchdog.h> | 26 | #include <watchdog.h> |
27 | 27 | ||
28 | DECLARE_GLOBAL_DATA_PTR; | 28 | DECLARE_GLOBAL_DATA_PTR; |
29 | 29 | ||
30 | /* From lowlevel_init.S */ | 30 | /* From lowlevel_init.S */ |
31 | extern unsigned long fw_dtb_pointer; | 31 | extern unsigned long fw_dtb_pointer; |
32 | 32 | ||
33 | /* TODO(sjg@chromium.org): Move these to the msg.c file */ | 33 | /* TODO(sjg@chromium.org): Move these to the msg.c file */ |
34 | struct msg_get_arm_mem { | 34 | struct msg_get_arm_mem { |
35 | struct bcm2835_mbox_hdr hdr; | 35 | struct bcm2835_mbox_hdr hdr; |
36 | struct bcm2835_mbox_tag_get_arm_mem get_arm_mem; | 36 | struct bcm2835_mbox_tag_get_arm_mem get_arm_mem; |
37 | u32 end_tag; | 37 | u32 end_tag; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | struct msg_get_board_rev { | 40 | struct msg_get_board_rev { |
41 | struct bcm2835_mbox_hdr hdr; | 41 | struct bcm2835_mbox_hdr hdr; |
42 | struct bcm2835_mbox_tag_get_board_rev get_board_rev; | 42 | struct bcm2835_mbox_tag_get_board_rev get_board_rev; |
43 | u32 end_tag; | 43 | u32 end_tag; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | struct msg_get_board_serial { | 46 | struct msg_get_board_serial { |
47 | struct bcm2835_mbox_hdr hdr; | 47 | struct bcm2835_mbox_hdr hdr; |
48 | struct bcm2835_mbox_tag_get_board_serial get_board_serial; | 48 | struct bcm2835_mbox_tag_get_board_serial get_board_serial; |
49 | u32 end_tag; | 49 | u32 end_tag; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct msg_get_mac_address { | 52 | struct msg_get_mac_address { |
53 | struct bcm2835_mbox_hdr hdr; | 53 | struct bcm2835_mbox_hdr hdr; |
54 | struct bcm2835_mbox_tag_get_mac_address get_mac_address; | 54 | struct bcm2835_mbox_tag_get_mac_address get_mac_address; |
55 | u32 end_tag; | 55 | u32 end_tag; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct msg_get_clock_rate { | 58 | struct msg_get_clock_rate { |
59 | struct bcm2835_mbox_hdr hdr; | 59 | struct bcm2835_mbox_hdr hdr; |
60 | struct bcm2835_mbox_tag_get_clock_rate get_clock_rate; | 60 | struct bcm2835_mbox_tag_get_clock_rate get_clock_rate; |
61 | u32 end_tag; | 61 | u32 end_tag; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #ifdef CONFIG_ARM64 | 64 | #ifdef CONFIG_ARM64 |
65 | #define DTB_DIR "broadcom/" | 65 | #define DTB_DIR "broadcom/" |
66 | #else | 66 | #else |
67 | #define DTB_DIR "" | 67 | #define DTB_DIR "" |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | /* | 70 | /* |
71 | * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ | 71 | * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ |
72 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 | 72 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 |
73 | * http://git.drogon.net/?p=wiringPi;a=blob;f=wiringPi/wiringPi.c;h=503151f61014418b9c42f4476a6086f75cd4e64b;hb=refs/heads/master#l922 | 73 | * http://git.drogon.net/?p=wiringPi;a=blob;f=wiringPi/wiringPi.c;h=503151f61014418b9c42f4476a6086f75cd4e64b;hb=refs/heads/master#l922 |
74 | * | 74 | * |
75 | * In http://lists.denx.de/pipermail/u-boot/2016-January/243752.html | 75 | * In http://lists.denx.de/pipermail/u-boot/2016-January/243752.html |
76 | * ("[U-Boot] [PATCH] rpi: fix up Model B entries") Dom Cobley at the RPi | 76 | * ("[U-Boot] [PATCH] rpi: fix up Model B entries") Dom Cobley at the RPi |
77 | * Foundation stated that the following source was accurate: | 77 | * Foundation stated that the following source was accurate: |
78 | * https://github.com/AndrewFromMelbourne/raspberry_pi_revision | 78 | * https://github.com/AndrewFromMelbourne/raspberry_pi_revision |
79 | */ | 79 | */ |
80 | struct rpi_model { | 80 | struct rpi_model { |
81 | const char *name; | 81 | const char *name; |
82 | const char *fdtfile; | 82 | const char *fdtfile; |
83 | bool has_onboard_eth; | 83 | bool has_onboard_eth; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static const struct rpi_model rpi_model_unknown = { | 86 | static const struct rpi_model rpi_model_unknown = { |
87 | "Unknown model", | 87 | "Unknown model", |
88 | DTB_DIR "bcm283x-rpi-other.dtb", | 88 | DTB_DIR "bcm283x-rpi-other.dtb", |
89 | false, | 89 | false, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static const struct rpi_model rpi_models_new_scheme[] = { | 92 | static const struct rpi_model rpi_models_new_scheme[] = { |
93 | [0x4] = { | 93 | [0x4] = { |
94 | "2 Model B", | 94 | "2 Model B", |
95 | DTB_DIR "bcm2836-rpi-2-b.dtb", | 95 | DTB_DIR "bcm2836-rpi-2-b.dtb", |
96 | true, | 96 | true, |
97 | }, | 97 | }, |
98 | [0x8] = { | 98 | [0x8] = { |
99 | "3 Model B", | 99 | "3 Model B", |
100 | DTB_DIR "bcm2837-rpi-3-b.dtb", | 100 | DTB_DIR "bcm2837-rpi-3-b.dtb", |
101 | true, | 101 | true, |
102 | }, | 102 | }, |
103 | [0x9] = { | 103 | [0x9] = { |
104 | "Zero", | 104 | "Zero", |
105 | DTB_DIR "bcm2835-rpi-zero.dtb", | 105 | DTB_DIR "bcm2835-rpi-zero.dtb", |
106 | false, | 106 | false, |
107 | }, | 107 | }, |
108 | [0xC] = { | ||
109 | "Zero W", | ||
110 | DTB_DIR "bcm2835-rpi-zero-w.dtb", | ||
111 | false, | ||
112 | }, | ||
108 | }; | 113 | }; |
109 | 114 | ||
110 | static const struct rpi_model rpi_models_old_scheme[] = { | 115 | static const struct rpi_model rpi_models_old_scheme[] = { |
111 | [0x2] = { | 116 | [0x2] = { |
112 | "Model B", | 117 | "Model B", |
113 | DTB_DIR "bcm2835-rpi-b.dtb", | 118 | DTB_DIR "bcm2835-rpi-b.dtb", |
114 | true, | 119 | true, |
115 | }, | 120 | }, |
116 | [0x3] = { | 121 | [0x3] = { |
117 | "Model B", | 122 | "Model B", |
118 | DTB_DIR "bcm2835-rpi-b.dtb", | 123 | DTB_DIR "bcm2835-rpi-b.dtb", |
119 | true, | 124 | true, |
120 | }, | 125 | }, |
121 | [0x4] = { | 126 | [0x4] = { |
122 | "Model B rev2", | 127 | "Model B rev2", |
123 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 128 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
124 | true, | 129 | true, |
125 | }, | 130 | }, |
126 | [0x5] = { | 131 | [0x5] = { |
127 | "Model B rev2", | 132 | "Model B rev2", |
128 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 133 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
129 | true, | 134 | true, |
130 | }, | 135 | }, |
131 | [0x6] = { | 136 | [0x6] = { |
132 | "Model B rev2", | 137 | "Model B rev2", |
133 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 138 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
134 | true, | 139 | true, |
135 | }, | 140 | }, |
136 | [0x7] = { | 141 | [0x7] = { |
137 | "Model A", | 142 | "Model A", |
138 | DTB_DIR "bcm2835-rpi-a.dtb", | 143 | DTB_DIR "bcm2835-rpi-a.dtb", |
139 | false, | 144 | false, |
140 | }, | 145 | }, |
141 | [0x8] = { | 146 | [0x8] = { |
142 | "Model A", | 147 | "Model A", |
143 | DTB_DIR "bcm2835-rpi-a.dtb", | 148 | DTB_DIR "bcm2835-rpi-a.dtb", |
144 | false, | 149 | false, |
145 | }, | 150 | }, |
146 | [0x9] = { | 151 | [0x9] = { |
147 | "Model A", | 152 | "Model A", |
148 | DTB_DIR "bcm2835-rpi-a.dtb", | 153 | DTB_DIR "bcm2835-rpi-a.dtb", |
149 | false, | 154 | false, |
150 | }, | 155 | }, |
151 | [0xd] = { | 156 | [0xd] = { |
152 | "Model B rev2", | 157 | "Model B rev2", |
153 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 158 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
154 | true, | 159 | true, |
155 | }, | 160 | }, |
156 | [0xe] = { | 161 | [0xe] = { |
157 | "Model B rev2", | 162 | "Model B rev2", |
158 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 163 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
159 | true, | 164 | true, |
160 | }, | 165 | }, |
161 | [0xf] = { | 166 | [0xf] = { |
162 | "Model B rev2", | 167 | "Model B rev2", |
163 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", | 168 | DTB_DIR "bcm2835-rpi-b-rev2.dtb", |
164 | true, | 169 | true, |
165 | }, | 170 | }, |
166 | [0x10] = { | 171 | [0x10] = { |
167 | "Model B+", | 172 | "Model B+", |
168 | DTB_DIR "bcm2835-rpi-b-plus.dtb", | 173 | DTB_DIR "bcm2835-rpi-b-plus.dtb", |
169 | true, | 174 | true, |
170 | }, | 175 | }, |
171 | [0x11] = { | 176 | [0x11] = { |
172 | "Compute Module", | 177 | "Compute Module", |
173 | DTB_DIR "bcm2835-rpi-cm.dtb", | 178 | DTB_DIR "bcm2835-rpi-cm.dtb", |
174 | false, | 179 | false, |
175 | }, | 180 | }, |
176 | [0x12] = { | 181 | [0x12] = { |
177 | "Model A+", | 182 | "Model A+", |
178 | DTB_DIR "bcm2835-rpi-a-plus.dtb", | 183 | DTB_DIR "bcm2835-rpi-a-plus.dtb", |
179 | false, | 184 | false, |
180 | }, | 185 | }, |
181 | [0x13] = { | 186 | [0x13] = { |
182 | "Model B+", | 187 | "Model B+", |
183 | DTB_DIR "bcm2835-rpi-b-plus.dtb", | 188 | DTB_DIR "bcm2835-rpi-b-plus.dtb", |
184 | true, | 189 | true, |
185 | }, | 190 | }, |
186 | [0x14] = { | 191 | [0x14] = { |
187 | "Compute Module", | 192 | "Compute Module", |
188 | DTB_DIR "bcm2835-rpi-cm.dtb", | 193 | DTB_DIR "bcm2835-rpi-cm.dtb", |
189 | false, | 194 | false, |
190 | }, | 195 | }, |
191 | [0x15] = { | 196 | [0x15] = { |
192 | "Model A+", | 197 | "Model A+", |
193 | DTB_DIR "bcm2835-rpi-a-plus.dtb", | 198 | DTB_DIR "bcm2835-rpi-a-plus.dtb", |
194 | false, | 199 | false, |
195 | }, | 200 | }, |
196 | }; | 201 | }; |
197 | 202 | ||
198 | static uint32_t revision; | 203 | static uint32_t revision; |
199 | static uint32_t rev_scheme; | 204 | static uint32_t rev_scheme; |
200 | static uint32_t rev_type; | 205 | static uint32_t rev_type; |
201 | static const struct rpi_model *model; | 206 | static const struct rpi_model *model; |
202 | 207 | ||
203 | #ifdef CONFIG_ARM64 | 208 | #ifdef CONFIG_ARM64 |
204 | static struct mm_region bcm2837_mem_map[] = { | 209 | static struct mm_region bcm2837_mem_map[] = { |
205 | { | 210 | { |
206 | .virt = 0x00000000UL, | 211 | .virt = 0x00000000UL, |
207 | .phys = 0x00000000UL, | 212 | .phys = 0x00000000UL, |
208 | .size = 0x3f000000UL, | 213 | .size = 0x3f000000UL, |
209 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | | 214 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
210 | PTE_BLOCK_INNER_SHARE | 215 | PTE_BLOCK_INNER_SHARE |
211 | }, { | 216 | }, { |
212 | .virt = 0x3f000000UL, | 217 | .virt = 0x3f000000UL, |
213 | .phys = 0x3f000000UL, | 218 | .phys = 0x3f000000UL, |
214 | .size = 0x01000000UL, | 219 | .size = 0x01000000UL, |
215 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | | 220 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
216 | PTE_BLOCK_NON_SHARE | | 221 | PTE_BLOCK_NON_SHARE | |
217 | PTE_BLOCK_PXN | PTE_BLOCK_UXN | 222 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
218 | }, { | 223 | }, { |
219 | /* List terminator */ | 224 | /* List terminator */ |
220 | 0, | 225 | 0, |
221 | } | 226 | } |
222 | }; | 227 | }; |
223 | 228 | ||
224 | struct mm_region *mem_map = bcm2837_mem_map; | 229 | struct mm_region *mem_map = bcm2837_mem_map; |
225 | #endif | 230 | #endif |
226 | 231 | ||
227 | int dram_init(void) | 232 | int dram_init(void) |
228 | { | 233 | { |
229 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1); | 234 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1); |
230 | int ret; | 235 | int ret; |
231 | 236 | ||
232 | BCM2835_MBOX_INIT_HDR(msg); | 237 | BCM2835_MBOX_INIT_HDR(msg); |
233 | BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY); | 238 | BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY); |
234 | 239 | ||
235 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); | 240 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
236 | if (ret) { | 241 | if (ret) { |
237 | printf("bcm2835: Could not query ARM memory size\n"); | 242 | printf("bcm2835: Could not query ARM memory size\n"); |
238 | return -1; | 243 | return -1; |
239 | } | 244 | } |
240 | 245 | ||
241 | gd->ram_size = msg->get_arm_mem.body.resp.mem_size; | 246 | gd->ram_size = msg->get_arm_mem.body.resp.mem_size; |
242 | 247 | ||
243 | return 0; | 248 | return 0; |
244 | } | 249 | } |
245 | 250 | ||
246 | static void set_fdtfile(void) | 251 | static void set_fdtfile(void) |
247 | { | 252 | { |
248 | const char *fdtfile; | 253 | const char *fdtfile; |
249 | 254 | ||
250 | if (env_get("fdtfile")) | 255 | if (env_get("fdtfile")) |
251 | return; | 256 | return; |
252 | 257 | ||
253 | fdtfile = model->fdtfile; | 258 | fdtfile = model->fdtfile; |
254 | env_set("fdtfile", fdtfile); | 259 | env_set("fdtfile", fdtfile); |
255 | } | 260 | } |
256 | 261 | ||
257 | /* | 262 | /* |
258 | * If the firmware provided a valid FDT at boot time, let's expose it in | 263 | * If the firmware provided a valid FDT at boot time, let's expose it in |
259 | * ${fdt_addr} so it may be passed unmodified to the kernel. | 264 | * ${fdt_addr} so it may be passed unmodified to the kernel. |
260 | */ | 265 | */ |
261 | static void set_fdt_addr(void) | 266 | static void set_fdt_addr(void) |
262 | { | 267 | { |
263 | if (env_get("fdt_addr")) | 268 | if (env_get("fdt_addr")) |
264 | return; | 269 | return; |
265 | 270 | ||
266 | if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) | 271 | if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) |
267 | return; | 272 | return; |
268 | 273 | ||
269 | env_set_hex("fdt_addr", fw_dtb_pointer); | 274 | env_set_hex("fdt_addr", fw_dtb_pointer); |
270 | } | 275 | } |
271 | 276 | ||
272 | /* | 277 | /* |
273 | * Prevent relocation from stomping on a firmware provided FDT blob. | 278 | * Prevent relocation from stomping on a firmware provided FDT blob. |
274 | */ | 279 | */ |
275 | unsigned long board_get_usable_ram_top(unsigned long total_size) | 280 | unsigned long board_get_usable_ram_top(unsigned long total_size) |
276 | { | 281 | { |
277 | if ((gd->ram_top - fw_dtb_pointer) > SZ_64M) | 282 | if ((gd->ram_top - fw_dtb_pointer) > SZ_64M) |
278 | return gd->ram_top; | 283 | return gd->ram_top; |
279 | return fw_dtb_pointer & ~0xffff; | 284 | return fw_dtb_pointer & ~0xffff; |
280 | } | 285 | } |
281 | 286 | ||
282 | static void set_usbethaddr(void) | 287 | static void set_usbethaddr(void) |
283 | { | 288 | { |
284 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1); | 289 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1); |
285 | int ret; | 290 | int ret; |
286 | 291 | ||
287 | if (!model->has_onboard_eth) | 292 | if (!model->has_onboard_eth) |
288 | return; | 293 | return; |
289 | 294 | ||
290 | if (env_get("usbethaddr")) | 295 | if (env_get("usbethaddr")) |
291 | return; | 296 | return; |
292 | 297 | ||
293 | BCM2835_MBOX_INIT_HDR(msg); | 298 | BCM2835_MBOX_INIT_HDR(msg); |
294 | BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS); | 299 | BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS); |
295 | 300 | ||
296 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); | 301 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
297 | if (ret) { | 302 | if (ret) { |
298 | printf("bcm2835: Could not query MAC address\n"); | 303 | printf("bcm2835: Could not query MAC address\n"); |
299 | /* Ignore error; not critical */ | 304 | /* Ignore error; not critical */ |
300 | return; | 305 | return; |
301 | } | 306 | } |
302 | 307 | ||
303 | eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac); | 308 | eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac); |
304 | 309 | ||
305 | if (!env_get("ethaddr")) | 310 | if (!env_get("ethaddr")) |
306 | env_set("ethaddr", env_get("usbethaddr")); | 311 | env_set("ethaddr", env_get("usbethaddr")); |
307 | 312 | ||
308 | return; | 313 | return; |
309 | } | 314 | } |
310 | 315 | ||
311 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 316 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
312 | static void set_board_info(void) | 317 | static void set_board_info(void) |
313 | { | 318 | { |
314 | char s[11]; | 319 | char s[11]; |
315 | 320 | ||
316 | snprintf(s, sizeof(s), "0x%X", revision); | 321 | snprintf(s, sizeof(s), "0x%X", revision); |
317 | env_set("board_revision", s); | 322 | env_set("board_revision", s); |
318 | snprintf(s, sizeof(s), "%d", rev_scheme); | 323 | snprintf(s, sizeof(s), "%d", rev_scheme); |
319 | env_set("board_rev_scheme", s); | 324 | env_set("board_rev_scheme", s); |
320 | /* Can't rename this to board_rev_type since it's an ABI for scripts */ | 325 | /* Can't rename this to board_rev_type since it's an ABI for scripts */ |
321 | snprintf(s, sizeof(s), "0x%X", rev_type); | 326 | snprintf(s, sizeof(s), "0x%X", rev_type); |
322 | env_set("board_rev", s); | 327 | env_set("board_rev", s); |
323 | env_set("board_name", model->name); | 328 | env_set("board_name", model->name); |
324 | } | 329 | } |
325 | #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ | 330 | #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ |
326 | 331 | ||
327 | static void set_serial_number(void) | 332 | static void set_serial_number(void) |
328 | { | 333 | { |
329 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_serial, msg, 1); | 334 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_serial, msg, 1); |
330 | int ret; | 335 | int ret; |
331 | char serial_string[17] = { 0 }; | 336 | char serial_string[17] = { 0 }; |
332 | 337 | ||
333 | if (env_get("serial#")) | 338 | if (env_get("serial#")) |
334 | return; | 339 | return; |
335 | 340 | ||
336 | BCM2835_MBOX_INIT_HDR(msg); | 341 | BCM2835_MBOX_INIT_HDR(msg); |
337 | BCM2835_MBOX_INIT_TAG_NO_REQ(&msg->get_board_serial, GET_BOARD_SERIAL); | 342 | BCM2835_MBOX_INIT_TAG_NO_REQ(&msg->get_board_serial, GET_BOARD_SERIAL); |
338 | 343 | ||
339 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); | 344 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
340 | if (ret) { | 345 | if (ret) { |
341 | printf("bcm2835: Could not query board serial\n"); | 346 | printf("bcm2835: Could not query board serial\n"); |
342 | /* Ignore error; not critical */ | 347 | /* Ignore error; not critical */ |
343 | return; | 348 | return; |
344 | } | 349 | } |
345 | 350 | ||
346 | snprintf(serial_string, sizeof(serial_string), "%016" PRIx64, | 351 | snprintf(serial_string, sizeof(serial_string), "%016" PRIx64, |
347 | msg->get_board_serial.body.resp.serial); | 352 | msg->get_board_serial.body.resp.serial); |
348 | env_set("serial#", serial_string); | 353 | env_set("serial#", serial_string); |
349 | } | 354 | } |
350 | 355 | ||
351 | int misc_init_r(void) | 356 | int misc_init_r(void) |
352 | { | 357 | { |
353 | set_fdt_addr(); | 358 | set_fdt_addr(); |
354 | set_fdtfile(); | 359 | set_fdtfile(); |
355 | set_usbethaddr(); | 360 | set_usbethaddr(); |
356 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 361 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
357 | set_board_info(); | 362 | set_board_info(); |
358 | #endif | 363 | #endif |
359 | set_serial_number(); | 364 | set_serial_number(); |
360 | 365 | ||
361 | return 0; | 366 | return 0; |
362 | } | 367 | } |
363 | 368 | ||
364 | static void get_board_rev(void) | 369 | static void get_board_rev(void) |
365 | { | 370 | { |
366 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_rev, msg, 1); | 371 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_rev, msg, 1); |
367 | int ret; | 372 | int ret; |
368 | const struct rpi_model *models; | 373 | const struct rpi_model *models; |
369 | uint32_t models_count; | 374 | uint32_t models_count; |
370 | 375 | ||
371 | BCM2835_MBOX_INIT_HDR(msg); | 376 | BCM2835_MBOX_INIT_HDR(msg); |
372 | BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV); | 377 | BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV); |
373 | 378 | ||
374 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); | 379 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
375 | if (ret) { | 380 | if (ret) { |
376 | printf("bcm2835: Could not query board revision\n"); | 381 | printf("bcm2835: Could not query board revision\n"); |
377 | /* Ignore error; not critical */ | 382 | /* Ignore error; not critical */ |
378 | return; | 383 | return; |
379 | } | 384 | } |
380 | 385 | ||
381 | /* | 386 | /* |
382 | * For details of old-vs-new scheme, see: | 387 | * For details of old-vs-new scheme, see: |
383 | * https://github.com/pimoroni/RPi.version/blob/master/RPi/version.py | 388 | * https://github.com/pimoroni/RPi.version/blob/master/RPi/version.py |
384 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=99293&p=690282 | 389 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=99293&p=690282 |
385 | * (a few posts down) | 390 | * (a few posts down) |
386 | * | 391 | * |
387 | * For the RPi 1, bit 24 is the "warranty bit", so we mask off just the | 392 | * For the RPi 1, bit 24 is the "warranty bit", so we mask off just the |
388 | * lower byte to use as the board rev: | 393 | * lower byte to use as the board rev: |
389 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250 | 394 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250 |
390 | * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594 | 395 | * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594 |
391 | */ | 396 | */ |
392 | revision = msg->get_board_rev.body.resp.rev; | 397 | revision = msg->get_board_rev.body.resp.rev; |
393 | if (revision & 0x800000) { | 398 | if (revision & 0x800000) { |
394 | rev_scheme = 1; | 399 | rev_scheme = 1; |
395 | rev_type = (revision >> 4) & 0xff; | 400 | rev_type = (revision >> 4) & 0xff; |
396 | models = rpi_models_new_scheme; | 401 | models = rpi_models_new_scheme; |
397 | models_count = ARRAY_SIZE(rpi_models_new_scheme); | 402 | models_count = ARRAY_SIZE(rpi_models_new_scheme); |
398 | } else { | 403 | } else { |
399 | rev_scheme = 0; | 404 | rev_scheme = 0; |
400 | rev_type = revision & 0xff; | 405 | rev_type = revision & 0xff; |
401 | models = rpi_models_old_scheme; | 406 | models = rpi_models_old_scheme; |
402 | models_count = ARRAY_SIZE(rpi_models_old_scheme); | 407 | models_count = ARRAY_SIZE(rpi_models_old_scheme); |
403 | } | 408 | } |
404 | if (rev_type >= models_count) { | 409 | if (rev_type >= models_count) { |
405 | printf("RPI: Board rev 0x%x outside known range\n", rev_type); | 410 | printf("RPI: Board rev 0x%x outside known range\n", rev_type); |
406 | model = &rpi_model_unknown; | 411 | model = &rpi_model_unknown; |
407 | } else if (!models[rev_type].name) { | 412 | } else if (!models[rev_type].name) { |
408 | printf("RPI: Board rev 0x%x unknown\n", rev_type); | 413 | printf("RPI: Board rev 0x%x unknown\n", rev_type); |
409 | model = &rpi_model_unknown; | 414 | model = &rpi_model_unknown; |
410 | } else { | 415 | } else { |
411 | model = &models[rev_type]; | 416 | model = &models[rev_type]; |
412 | } | 417 | } |
413 | 418 | ||
414 | printf("RPI %s (0x%x)\n", model->name, revision); | 419 | printf("RPI %s (0x%x)\n", model->name, revision); |
415 | } | 420 | } |
416 | 421 | ||
417 | #ifndef CONFIG_PL01X_SERIAL | 422 | #ifndef CONFIG_PL01X_SERIAL |
418 | static bool rpi_is_serial_active(void) | 423 | static bool rpi_is_serial_active(void) |
419 | { | 424 | { |
420 | int serial_gpio = 15; | 425 | int serial_gpio = 15; |
421 | struct udevice *dev; | 426 | struct udevice *dev; |
422 | 427 | ||
423 | /* | 428 | /* |
424 | * The RPi3 disables the mini uart by default. The easiest way to find | 429 | * The RPi3 disables the mini uart by default. The easiest way to find |
425 | * out whether it is available is to check if the RX pin is muxed. | 430 | * out whether it is available is to check if the RX pin is muxed. |
426 | */ | 431 | */ |
427 | 432 | ||
428 | if (uclass_first_device(UCLASS_GPIO, &dev) || !dev) | 433 | if (uclass_first_device(UCLASS_GPIO, &dev) || !dev) |
429 | return true; | 434 | return true; |
430 | 435 | ||
431 | if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5) | 436 | if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5) |
432 | return false; | 437 | return false; |
433 | 438 | ||
434 | return true; | 439 | return true; |
435 | } | 440 | } |
436 | 441 | ||
437 | /* Disable mini-UART I/O if it's not pinmuxed to our pins. | 442 | /* Disable mini-UART I/O if it's not pinmuxed to our pins. |
438 | * The firmware only enables it if explicitly done in config.txt: enable_uart=1 | 443 | * The firmware only enables it if explicitly done in config.txt: enable_uart=1 |
439 | */ | 444 | */ |
440 | static void rpi_disable_inactive_uart(void) | 445 | static void rpi_disable_inactive_uart(void) |
441 | { | 446 | { |
442 | struct udevice *dev; | 447 | struct udevice *dev; |
443 | struct bcm283x_mu_serial_platdata *plat; | 448 | struct bcm283x_mu_serial_platdata *plat; |
444 | 449 | ||
445 | if (uclass_get_device_by_driver(UCLASS_SERIAL, | 450 | if (uclass_get_device_by_driver(UCLASS_SERIAL, |
446 | DM_GET_DRIVER(serial_bcm283x_mu), | 451 | DM_GET_DRIVER(serial_bcm283x_mu), |
447 | &dev) || !dev) | 452 | &dev) || !dev) |
448 | return; | 453 | return; |
449 | 454 | ||
450 | if (!rpi_is_serial_active()) { | 455 | if (!rpi_is_serial_active()) { |
451 | plat = dev_get_platdata(dev); | 456 | plat = dev_get_platdata(dev); |
452 | plat->disabled = true; | 457 | plat->disabled = true; |
453 | } | 458 | } |
454 | } | 459 | } |
455 | #endif | 460 | #endif |
456 | 461 | ||
457 | int board_init(void) | 462 | int board_init(void) |
458 | { | 463 | { |
459 | #ifdef CONFIG_HW_WATCHDOG | 464 | #ifdef CONFIG_HW_WATCHDOG |
460 | hw_watchdog_init(); | 465 | hw_watchdog_init(); |
461 | #endif | 466 | #endif |
462 | #ifndef CONFIG_PL01X_SERIAL | 467 | #ifndef CONFIG_PL01X_SERIAL |
463 | rpi_disable_inactive_uart(); | 468 | rpi_disable_inactive_uart(); |
464 | #endif | 469 | #endif |
465 | 470 | ||
466 | get_board_rev(); | 471 | get_board_rev(); |
467 | 472 | ||
468 | gd->bd->bi_boot_params = 0x100; | 473 | gd->bd->bi_boot_params = 0x100; |
469 | 474 | ||
470 | return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD); | 475 | return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD); |
471 | } | 476 | } |
472 | 477 | ||
473 | /* | 478 | /* |
474 | * If the firmware passed a device tree use it for U-Boot. | 479 | * If the firmware passed a device tree use it for U-Boot. |
475 | */ | 480 | */ |
476 | void *board_fdt_blob_setup(void) | 481 | void *board_fdt_blob_setup(void) |
477 | { | 482 | { |
478 | if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) | 483 | if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) |
479 | return NULL; | 484 | return NULL; |
480 | return (void *)fw_dtb_pointer; | 485 | return (void *)fw_dtb_pointer; |
481 | } | 486 | } |
482 | 487 | ||
483 | int ft_board_setup(void *blob, bd_t *bd) | 488 | int ft_board_setup(void *blob, bd_t *bd) |
484 | { | 489 | { |
485 | /* | 490 | /* |
486 | * For now, we simply always add the simplefb DT node. Later, we | 491 | * For now, we simply always add the simplefb DT node. Later, we |
487 | * should be more intelligent, and e.g. only do this if no enabled DT | 492 | * should be more intelligent, and e.g. only do this if no enabled DT |
488 | * node exists for the "real" graphics driver. | 493 | * node exists for the "real" graphics driver. |
489 | */ | 494 | */ |
490 | lcd_dt_simplefb_add_node(blob); | 495 | lcd_dt_simplefb_add_node(blob); |
491 | 496 | ||
492 | #ifdef CONFIG_EFI_LOADER | 497 | #ifdef CONFIG_EFI_LOADER |
493 | /* Reserve the spin table */ | 498 | /* Reserve the spin table */ |
494 | efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0); | 499 | efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0); |
495 | #endif | 500 | #endif |
496 | 501 | ||
497 | return 0; | 502 | return 0; |
498 | } | 503 | } |
499 | 504 |
configs/rpi_0_w_defconfig
File was created | 1 | CONFIG_ARM=y | |
2 | CONFIG_ARCH_BCM283X=y | ||
3 | CONFIG_TARGET_RPI_0_W=y | ||
4 | CONFIG_DEFAULT_DEVICE_TREE="bcm2835-rpi-zero-w" | ||
5 | CONFIG_DISTRO_DEFAULTS=y | ||
6 | CONFIG_OF_BOARD_SETUP=y | ||
7 | # CONFIG_DISPLAY_CPUINFO is not set | ||
8 | # CONFIG_DISPLAY_BOARDINFO is not set | ||
9 | CONFIG_SYS_PROMPT="U-Boot> " | ||
10 | # CONFIG_CMD_IMLS is not set | ||
11 | # CONFIG_CMD_FLASH is not set | ||
12 | CONFIG_CMD_MMC=y | ||
13 | CONFIG_CMD_USB=y | ||
14 | # CONFIG_CMD_FPGA is not set | ||
15 | CONFIG_CMD_GPIO=y | ||
16 | CONFIG_DM_MMC=y | ||
17 | CONFIG_MMC_SDHCI=y | ||
18 | CONFIG_MMC_SDHCI_BCM2835=y | ||
19 | CONFIG_DM_ETH=y | ||
20 | CONFIG_USB=y | ||
21 | CONFIG_DM_USB=y | ||
22 | CONFIG_USB_STORAGE=y | ||
23 | CONFIG_USB_KEYBOARD=y | ||
24 | CONFIG_DM_VIDEO=y | ||
25 | CONFIG_SYS_WHITE_ON_BLACK=y | ||
26 | CONFIG_CONSOLE_SCROLL_LINES=10 | ||
27 | CONFIG_PHYS_TO_BUS=y | ||
28 | CONFIG_OF_LIBFDT_OVERLAY=y | ||
29 |
include/configs/rpi.h
1 | /* | 1 | /* |
2 | * (C) Copyright 2012-2016 Stephen Warren | 2 | * (C) Copyright 2012-2016 Stephen Warren |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0 | 4 | * SPDX-License-Identifier: GPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef __CONFIG_H | 7 | #ifndef __CONFIG_H |
8 | #define __CONFIG_H | 8 | #define __CONFIG_H |
9 | 9 | ||
10 | #include <linux/sizes.h> | 10 | #include <linux/sizes.h> |
11 | #include <asm/arch/timer.h> | 11 | #include <asm/arch/timer.h> |
12 | 12 | ||
13 | #if defined(CONFIG_TARGET_RPI_2) || defined(CONFIG_TARGET_RPI_3_32B) | 13 | #if defined(CONFIG_TARGET_RPI_2) || defined(CONFIG_TARGET_RPI_3_32B) |
14 | #define CONFIG_SKIP_LOWLEVEL_INIT | 14 | #define CONFIG_SKIP_LOWLEVEL_INIT |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | /* Architecture, CPU, etc.*/ | 17 | /* Architecture, CPU, etc.*/ |
18 | #define CONFIG_ARCH_CPU_INIT | 18 | #define CONFIG_ARCH_CPU_INIT |
19 | 19 | ||
20 | /* Use SoC timer for AArch32, but architected timer for AArch64 */ | 20 | /* Use SoC timer for AArch32, but architected timer for AArch64 */ |
21 | #ifndef CONFIG_ARM64 | 21 | #ifndef CONFIG_ARM64 |
22 | #define CONFIG_SYS_TIMER_RATE 1000000 | 22 | #define CONFIG_SYS_TIMER_RATE 1000000 |
23 | #define CONFIG_SYS_TIMER_COUNTER \ | 23 | #define CONFIG_SYS_TIMER_COUNTER \ |
24 | (&((struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR)->clo) | 24 | (&((struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR)->clo) |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * 2835 is a SKU in a series for which the 2708 is the first or primary SoC, | 28 | * 2835 is a SKU in a series for which the 2708 is the first or primary SoC, |
29 | * so 2708 has historically been used rather than a dedicated 2835 ID. | 29 | * so 2708 has historically been used rather than a dedicated 2835 ID. |
30 | * | 30 | * |
31 | * We don't define a machine type for bcm2709/bcm2836 since the RPi Foundation | 31 | * We don't define a machine type for bcm2709/bcm2836 since the RPi Foundation |
32 | * chose to use someone else's previously registered machine ID (3139, MX51_GGC) | 32 | * chose to use someone else's previously registered machine ID (3139, MX51_GGC) |
33 | * rather than obtaining a valid ID:-/ | 33 | * rather than obtaining a valid ID:-/ |
34 | * | 34 | * |
35 | * For the bcm2837, hopefully a machine type is not needed, since everything | 35 | * For the bcm2837, hopefully a machine type is not needed, since everything |
36 | * is DT. | 36 | * is DT. |
37 | */ | 37 | */ |
38 | #ifdef CONFIG_BCM2835 | 38 | #ifdef CONFIG_BCM2835 |
39 | #define CONFIG_MACH_TYPE MACH_TYPE_BCM2708 | 39 | #define CONFIG_MACH_TYPE MACH_TYPE_BCM2708 |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | /* Memory layout */ | 42 | /* Memory layout */ |
43 | #define CONFIG_NR_DRAM_BANKS 1 | 43 | #define CONFIG_NR_DRAM_BANKS 1 |
44 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 | 44 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 |
45 | #ifdef CONFIG_ARM64 | 45 | #ifdef CONFIG_ARM64 |
46 | #define CONFIG_SYS_TEXT_BASE 0x00080000 | 46 | #define CONFIG_SYS_TEXT_BASE 0x00080000 |
47 | #else | 47 | #else |
48 | #define CONFIG_SYS_TEXT_BASE 0x00008000 | 48 | #define CONFIG_SYS_TEXT_BASE 0x00008000 |
49 | #endif | 49 | #endif |
50 | #define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE | 50 | #define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE |
51 | /* | 51 | /* |
52 | * The board really has 256M. However, the VC (VideoCore co-processor) shares | 52 | * The board really has 256M. However, the VC (VideoCore co-processor) shares |
53 | * the RAM, and uses a configurable portion at the top. We tell U-Boot that a | 53 | * the RAM, and uses a configurable portion at the top. We tell U-Boot that a |
54 | * smaller amount of RAM is present in order to avoid stomping on the area | 54 | * smaller amount of RAM is present in order to avoid stomping on the area |
55 | * the VC uses. | 55 | * the VC uses. |
56 | */ | 56 | */ |
57 | #define CONFIG_SYS_SDRAM_SIZE SZ_128M | 57 | #define CONFIG_SYS_SDRAM_SIZE SZ_128M |
58 | #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \ | 58 | #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \ |
59 | CONFIG_SYS_SDRAM_SIZE - \ | 59 | CONFIG_SYS_SDRAM_SIZE - \ |
60 | GENERATED_GBL_DATA_SIZE) | 60 | GENERATED_GBL_DATA_SIZE) |
61 | #define CONFIG_SYS_MALLOC_LEN SZ_4M | 61 | #define CONFIG_SYS_MALLOC_LEN SZ_4M |
62 | #define CONFIG_SYS_MEMTEST_START 0x00100000 | 62 | #define CONFIG_SYS_MEMTEST_START 0x00100000 |
63 | #define CONFIG_SYS_MEMTEST_END 0x00200000 | 63 | #define CONFIG_SYS_MEMTEST_END 0x00200000 |
64 | #define CONFIG_LOADADDR 0x00200000 | 64 | #define CONFIG_LOADADDR 0x00200000 |
65 | 65 | ||
66 | /* Devices */ | 66 | /* Devices */ |
67 | /* GPIO */ | 67 | /* GPIO */ |
68 | #define CONFIG_BCM2835_GPIO | 68 | #define CONFIG_BCM2835_GPIO |
69 | /* LCD */ | 69 | /* LCD */ |
70 | #define CONFIG_LCD_DT_SIMPLEFB | 70 | #define CONFIG_LCD_DT_SIMPLEFB |
71 | #define CONFIG_VIDEO_BCM2835 | 71 | #define CONFIG_VIDEO_BCM2835 |
72 | 72 | ||
73 | #ifdef CONFIG_CMD_USB | 73 | #ifdef CONFIG_CMD_USB |
74 | #define CONFIG_TFTP_TSIZE | 74 | #define CONFIG_TFTP_TSIZE |
75 | #define CONFIG_MISC_INIT_R | 75 | #define CONFIG_MISC_INIT_R |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | /* Console UART */ | 78 | /* Console UART */ |
79 | #ifdef CONFIG_BCM2837 | 79 | #if defined (CONFIG_BCM2837) || defined(CONFIG_TARGET_RPI_0_W) |
80 | #define CONFIG_BCM283X_MU_SERIAL | 80 | #define CONFIG_BCM283X_MU_SERIAL |
81 | #else | 81 | #else |
82 | #define CONFIG_PL01X_SERIAL | 82 | #define CONFIG_PL01X_SERIAL |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | /* Console configuration */ | 85 | /* Console configuration */ |
86 | #define CONFIG_SYS_CBSIZE 1024 | 86 | #define CONFIG_SYS_CBSIZE 1024 |
87 | 87 | ||
88 | /* Environment */ | 88 | /* Environment */ |
89 | #define CONFIG_ENV_SIZE SZ_16K | 89 | #define CONFIG_ENV_SIZE SZ_16K |
90 | #define CONFIG_ENV_VARS_UBOOT_CONFIG | 90 | #define CONFIG_ENV_VARS_UBOOT_CONFIG |
91 | #define CONFIG_SYS_LOAD_ADDR 0x1000000 | 91 | #define CONFIG_SYS_LOAD_ADDR 0x1000000 |
92 | #define CONFIG_PREBOOT "usb start" | 92 | #define CONFIG_PREBOOT "usb start" |
93 | 93 | ||
94 | /* Shell */ | 94 | /* Shell */ |
95 | #define CONFIG_CMDLINE_EDITING | 95 | #define CONFIG_CMDLINE_EDITING |
96 | 96 | ||
97 | /* ATAGs support for bootm/bootz */ | 97 | /* ATAGs support for bootm/bootz */ |
98 | #define CONFIG_SETUP_MEMORY_TAGS | 98 | #define CONFIG_SETUP_MEMORY_TAGS |
99 | #define CONFIG_CMDLINE_TAG | 99 | #define CONFIG_CMDLINE_TAG |
100 | #define CONFIG_INITRD_TAG | 100 | #define CONFIG_INITRD_TAG |
101 | 101 | ||
102 | #include <config_distro_defaults.h> | 102 | #include <config_distro_defaults.h> |
103 | 103 | ||
104 | /* Environment */ | 104 | /* Environment */ |
105 | #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 105 | #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
106 | #define ENV_DEVICE_SETTINGS \ | 106 | #define ENV_DEVICE_SETTINGS \ |
107 | "stdin=serial,usbkbd\0" \ | 107 | "stdin=serial,usbkbd\0" \ |
108 | "stdout=serial,vidconsole\0" \ | 108 | "stdout=serial,vidconsole\0" \ |
109 | "stderr=serial,vidconsole\0" | 109 | "stderr=serial,vidconsole\0" |
110 | 110 | ||
111 | /* | 111 | /* |
112 | * Memory layout for where various images get loaded by boot scripts: | 112 | * Memory layout for where various images get loaded by boot scripts: |
113 | * | 113 | * |
114 | * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this. | 114 | * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this. |
115 | * | 115 | * |
116 | * fdt_addr_r simply shouldn't overlap anything else. However, the RPi's | 116 | * fdt_addr_r simply shouldn't overlap anything else. However, the RPi's |
117 | * binary firmware loads a DT to address 0x100, so we choose this address to | 117 | * binary firmware loads a DT to address 0x100, so we choose this address to |
118 | * match it. This allows custom boot scripts to pass this DT on to Linux | 118 | * match it. This allows custom boot scripts to pass this DT on to Linux |
119 | * simply by not over-writing the data at this address. When using U-Boot, | 119 | * simply by not over-writing the data at this address. When using U-Boot, |
120 | * U-Boot (and scripts it executes) typicaly ignore the DT loaded by the FW | 120 | * U-Boot (and scripts it executes) typicaly ignore the DT loaded by the FW |
121 | * and loads its own DT from disk (triggered by boot.scr or extlinux.conf). | 121 | * and loads its own DT from disk (triggered by boot.scr or extlinux.conf). |
122 | * | 122 | * |
123 | * pxefile_addr_r can be pretty much anywhere that doesn't conflict with | 123 | * pxefile_addr_r can be pretty much anywhere that doesn't conflict with |
124 | * something else. Put it low in memory to avoid conflicts. | 124 | * something else. Put it low in memory to avoid conflicts. |
125 | * | 125 | * |
126 | * kernel_addr_r must be within the first 128M of RAM in order for the | 126 | * kernel_addr_r must be within the first 128M of RAM in order for the |
127 | * kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will | 127 | * kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will |
128 | * decompress itself to 0x8000 after the start of RAM, kernel_addr_r | 128 | * decompress itself to 0x8000 after the start of RAM, kernel_addr_r |
129 | * should not overlap that area, or the kernel will have to copy itself | 129 | * should not overlap that area, or the kernel will have to copy itself |
130 | * somewhere else before decompression. Similarly, the address of any other | 130 | * somewhere else before decompression. Similarly, the address of any other |
131 | * data passed to the kernel shouldn't overlap the start of RAM. Pushing | 131 | * data passed to the kernel shouldn't overlap the start of RAM. Pushing |
132 | * this up to 16M allows for a sizable kernel to be decompressed below the | 132 | * this up to 16M allows for a sizable kernel to be decompressed below the |
133 | * compressed load address. | 133 | * compressed load address. |
134 | * | 134 | * |
135 | * scriptaddr can be pretty much anywhere that doesn't conflict with something | 135 | * scriptaddr can be pretty much anywhere that doesn't conflict with something |
136 | * else. Choosing 32M allows for the compressed kernel to be up to 16M. | 136 | * else. Choosing 32M allows for the compressed kernel to be up to 16M. |
137 | * | 137 | * |
138 | * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows | 138 | * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows |
139 | * for any boot script to be up to 1M, which is hopefully plenty. | 139 | * for any boot script to be up to 1M, which is hopefully plenty. |
140 | */ | 140 | */ |
141 | #define ENV_MEM_LAYOUT_SETTINGS \ | 141 | #define ENV_MEM_LAYOUT_SETTINGS \ |
142 | "fdt_high=ffffffff\0" \ | 142 | "fdt_high=ffffffff\0" \ |
143 | "initrd_high=ffffffff\0" \ | 143 | "initrd_high=ffffffff\0" \ |
144 | "fdt_addr_r=0x00000100\0" \ | 144 | "fdt_addr_r=0x00000100\0" \ |
145 | "pxefile_addr_r=0x00100000\0" \ | 145 | "pxefile_addr_r=0x00100000\0" \ |
146 | "kernel_addr_r=0x01000000\0" \ | 146 | "kernel_addr_r=0x01000000\0" \ |
147 | "scriptaddr=0x02000000\0" \ | 147 | "scriptaddr=0x02000000\0" \ |
148 | "ramdisk_addr_r=0x02100000\0" \ | 148 | "ramdisk_addr_r=0x02100000\0" \ |
149 | 149 | ||
150 | #define BOOT_TARGET_DEVICES(func) \ | 150 | #define BOOT_TARGET_DEVICES(func) \ |
151 | func(MMC, mmc, 0) \ | 151 | func(MMC, mmc, 0) \ |
152 | func(USB, usb, 0) \ | 152 | func(USB, usb, 0) \ |
153 | func(PXE, pxe, na) \ | 153 | func(PXE, pxe, na) \ |
154 | func(DHCP, dhcp, na) | 154 | func(DHCP, dhcp, na) |
155 | #include <config_distro_bootcmd.h> | 155 | #include <config_distro_bootcmd.h> |
156 | 156 | ||
157 | #define CONFIG_EXTRA_ENV_SETTINGS \ | 157 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
158 | "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ | 158 | "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ |
159 | ENV_DEVICE_SETTINGS \ | 159 | ENV_DEVICE_SETTINGS \ |
160 | ENV_MEM_LAYOUT_SETTINGS \ | 160 | ENV_MEM_LAYOUT_SETTINGS \ |
161 | BOOTENV | 161 | BOOTENV |
162 | 162 | ||
163 | 163 | ||
164 | #endif | 164 | #endif |
165 | 165 |