summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-12-11 13:31:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-12-11 13:31:14 +0100
commit2eee1db406d961e61aaf7c12150c6bb835ab8c2f (patch)
tree8856f4a81afce77fec0fea01cedc695814c73d4b
parent5f2377ac5502559ecfb7d70c2c99e5d553de1cd5 (diff)
parentc06cd360830e83d4d916da3918a4f819d59230e9 (diff)
downloadbarebox-2eee1db406d961e61aaf7c12150c6bb835ab8c2f.tar.gz
barebox-2eee1db406d961e61aaf7c12150c6bb835ab8c2f.tar.xz
Merge branch 'for-next/rpi'
-rw-r--r--Documentation/boards/bcm2835.rst7
-rw-r--r--arch/arm/boards/raspberry-pi/Makefile1
-rwxr-xr-xarch/arm/boards/raspberry-pi/defaultenv-rpi/boot/rpi5
-rw-r--r--arch/arm/boards/raspberry-pi/env/init/bootargs-base3
-rw-r--r--arch/arm/boards/raspberry-pi/rpi-common.c86
-rw-r--r--arch/arm/boards/raspberry-pi/rpi.h24
-rw-r--r--arch/arm/configs/rpi_defconfig2
-rw-r--r--arch/arm/dts/bcm2835-rpi.dts14
-rw-r--r--arch/arm/dts/bcm2836-rpi-2.dts6
-rw-r--r--arch/arm/dts/bcm2837-rpi-3.dts6
-rw-r--r--arch/arm/mach-bcm283x/include/mach/platform.h1
-rw-r--r--drivers/of/base.c15
-rw-r--r--include/of.h1
13 files changed, 107 insertions, 64 deletions
diff --git a/Documentation/boards/bcm2835.rst b/Documentation/boards/bcm2835.rst
index c896871e0d..8af6a09c13 100644
--- a/Documentation/boards/bcm2835.rst
+++ b/Documentation/boards/bcm2835.rst
@@ -23,6 +23,13 @@ Raspberry Pi
kernel=barebox.img
enable_uart=1
+ If you want to use the mini-uart instead of the PL011, you may need to additionally set::
+
+ uart_2ndstage=1
+
+ This is required on boards, like the Raspberry Pi Zero W, that use the mini-uart as the
+ primary UART. It is needed on boards like the CM3 as well if the mini-uart is to be used.
+
(For more information, refer to the `documentation for config.txt`_.)
5. Connect to board's UART (115200 8N1);
diff --git a/arch/arm/boards/raspberry-pi/Makefile b/arch/arm/boards/raspberry-pi/Makefile
index a3e93eb73a..ddcf015f08 100644
--- a/arch/arm/boards/raspberry-pi/Makefile
+++ b/arch/arm/boards/raspberry-pi/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_MACH_RPI_COMMON) += rpi-common.o
lwl-y += lowlevel.o
+bbenv-y += defaultenv-rpi
diff --git a/arch/arm/boards/raspberry-pi/defaultenv-rpi/boot/rpi b/arch/arm/boards/raspberry-pi/defaultenv-rpi/boot/rpi
new file mode 100755
index 0000000000..bf81aeb87b
--- /dev/null
+++ b/arch/arm/boards/raspberry-pi/defaultenv-rpi/boot/rpi
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+global linux.bootargs.dyn.vc="${global.vc.bootargs}"
+global.bootm.image="/boot/${global.vc.kernel}"
+global.bootm.oftree=/vc.dtb
diff --git a/arch/arm/boards/raspberry-pi/env/init/bootargs-base b/arch/arm/boards/raspberry-pi/env/init/bootargs-base
deleted file mode 100644
index 416dc8a6f4..0000000000
--- a/arch/arm/boards/raspberry-pi/env/init/bootargs-base
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-global.linux.bootargs.base="console=ttyAMA0,115200"
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index d5995fb86d..e326732b3a 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -20,14 +20,25 @@
#include <generated/mach-types.h>
#include <linux/sizes.h>
#include <globalvar.h>
+#include <asm/system_info.h>
#include <mach/core.h>
#include <mach/mbox.h>
#include <mach/platform.h>
-#include "rpi.h"
#include "lowlevel.h"
+struct rpi_model {
+ const char *name;
+ void (*init)(void);
+};
+
+#define RPI_MODEL(_id, _name, _init) \
+ [_id] = { \
+ .name = _name,\
+ .init = _init,\
+ }
+
struct msg_get_arm_mem {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
@@ -85,7 +96,7 @@ static struct clk *rpi_register_firmware_clock(u32 clock_id, const char *name)
return clk_fixed(name, msg->get_clock_rate.body.resp.rate_hz);
}
-void rpi_set_usbethaddr(void)
+static void rpi_set_usbethaddr(void)
{
BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg);
int ret;
@@ -103,7 +114,16 @@ void rpi_set_usbethaddr(void)
eth_register_ethaddr(0, msg->get_mac_address.body.resp.mac);
}
-struct gpio_led rpi_leds[] = {
+static void rpi_set_usbotg(const char *alias)
+{
+ struct device_node *usb;
+
+ usb = of_find_node_by_alias(NULL, alias);
+ if (usb)
+ of_property_write_string(usb, "dr_mode", "otg");
+}
+
+static struct gpio_led rpi_leds[] = {
{
.gpio = -EINVAL,
.led = {
@@ -148,8 +168,35 @@ static void rpi_b_plus_init(void)
rpi_set_usbethaddr();
}
+static void rpi_0_init(void)
+{
+ rpi_leds[0].gpio = 47;
+ rpi_set_usbotg("usb0");
+}
+
+static void rpi_0_w_init(void)
+{
+ struct device_node *np;
+ int ret;
+
+ rpi_0_init();
+
+ np = of_find_node_by_path("/chosen");
+ if (!np)
+ return;
+
+ if (!of_device_enable_and_register_by_alias("serial1"))
+ return;
+
+ ret = of_property_write_string(np, "stdout-path", "serial1:115200n8");
+ if (ret)
+ return;
+
+ of_device_disable_by_alias("serial0");
+}
+
/* See comments in mbox.h for data source */
-const struct rpi_model rpi_models_old_scheme[] = {
+static const struct rpi_model rpi_models_old_scheme[] = {
RPI_MODEL(0, "Unknown model", NULL),
RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", rpi_b_init),
RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", rpi_b_init),
@@ -170,7 +217,7 @@ const struct rpi_model rpi_models_old_scheme[] = {
RPI_MODEL(BCM2835_BOARD_REV_A_PLUS_15, "Model A+", NULL),
};
-const struct rpi_model rpi_models_new_scheme[] = {
+static const struct rpi_model rpi_models_new_scheme[] = {
RPI_MODEL(BCM2835_BOARD_REV_A, "Model A", NULL ),
RPI_MODEL(BCM2835_BOARD_REV_B, "Model B", rpi_b_init ),
RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL ),
@@ -180,18 +227,18 @@ const struct rpi_model rpi_models_new_scheme[] = {
RPI_MODEL(BCM2835_BOARD_REV_CM1, "Compute Module", NULL ),
RPI_MODEL(0x7, "Unknown model", NULL),
RPI_MODEL(BCM2837_BOARD_REV_3_B, "Model 3B", rpi_b_init ),
- RPI_MODEL(BCM2835_BOARD_REV_ZERO, "Zero", rpi_b_plus_init),
+ RPI_MODEL(BCM2835_BOARD_REV_ZERO, "Zero", rpi_0_init),
RPI_MODEL(BCM2837_BOARD_REV_CM3, "Compute Module 3", NULL ),
RPI_MODEL(0xb, "Unknown model", NULL),
- RPI_MODEL(BCM2835_BOARD_REV_ZERO_W, "Zero W", rpi_b_plus_init),
- RPI_MODEL(BCM2837B0_BOARD_REV_3B_PLUS, "Model 3 B+", rpi_b_plus_init ),
- RPI_MODEL(BCM2837B0_BOARD_REV_3A_PLUS, "Nodel 3 A+", rpi_b_plus_init),
+ RPI_MODEL(BCM2835_BOARD_REV_ZERO_W, "Zero W", rpi_0_w_init),
+ RPI_MODEL(BCM2837B0_BOARD_REV_3B_PLUS, "Model 3B+", rpi_b_plus_init ),
+ RPI_MODEL(BCM2837B0_BOARD_REV_3A_PLUS, "Model 3A+", rpi_b_plus_init),
RPI_MODEL(0xf, "Unknown model", NULL),
RPI_MODEL(BCM2837B0_BOARD_REV_CM3_PLUS, "Compute Module 3+", NULL),
};
static int rpi_board_rev = 0;
-const struct rpi_model *model = NULL;
+static const struct rpi_model *model = NULL;
static void rpi_get_board_rev(void)
{
@@ -269,7 +316,6 @@ static void rpi_model_init(void)
return;
model->init();
- rpi_add_led();
}
static int rpi_mem_init(void)
@@ -291,6 +337,7 @@ static int rpi_postcore_init(void)
{
rpi_get_board_rev();
barebox_set_hostname("rpi");
+ rpi_model_init();
return 0;
}
@@ -337,6 +384,7 @@ static int rpi_console_clock_init(void)
if (IS_ERR(clk))
return PTR_ERR(clk);
+ clkdev_add_physbase(clk, BCM2835_MINIUART_BASE, NULL);
clkdev_add_physbase(clk, BCM2836_MINIUART_BASE, NULL);
clk = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
@@ -367,6 +415,8 @@ static int rpi_env_init(void)
return 0;
}
+ defaultenv_append_directory(defaultenv_rpi);
+
default_environment_path_set("/boot/barebox.env");
return 0;
@@ -403,6 +453,18 @@ static int rpi_vc_fdt_bootargs(void *fdt)
globalvar_add_simple("vc.bootargs", cmdline);
+ switch(cpu_architecture()) {
+ case CPU_ARCH_ARMv6:
+ globalvar_add_simple("vc.kernel", "kernel.img");
+ break;
+ case CPU_ARCH_ARMv7:
+ globalvar_add_simple("vc.kernel", "kernel7.img");
+ break;
+ case CPU_ARCH_ARMv8:
+ globalvar_add_simple("vc.kernel", "kernel7l.img");
+ break;
+ }
+
out:
if (root)
of_delete_node(root);
@@ -453,7 +515,7 @@ static int rpi_devices_init(void)
{
struct regulator *reg;
- rpi_model_init();
+ rpi_add_led();
bcm2835_register_fb();
armlinux_set_architecture(MACH_TYPE_BCM2708);
rpi_env_init();
diff --git a/arch/arm/boards/raspberry-pi/rpi.h b/arch/arm/boards/raspberry-pi/rpi.h
deleted file mode 100644
index b2a0401bd0..0000000000
--- a/arch/arm/boards/raspberry-pi/rpi.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __ARCH_ARM_BOARDS_RPI_H__
-#define __ARCH_ARM_BOARDS_RPI_H__
-
-#include <types.h>
-#include <led.h>
-
-#include <mach/mbox.h>
-
-#define RPI_MODEL(_id, _name, _init) \
- [_id] = { \
- .name = _name,\
- .init = _init,\
- }
-
-struct rpi_model {
- const char *name;
- void (*init)(void);
-};
-
-extern struct gpio_led rpi_leds[];
-
-void rpi_set_usbethaddr(void);
-
-#endif /* __ARCH_ARM_BOARDS_RPI_H__ */
diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
index dd5ca7585a..f42b8819af 100644
--- a/arch/arm/configs/rpi_defconfig
+++ b/arch/arm/configs/rpi_defconfig
@@ -23,7 +23,7 @@ CONFIG_BOOTM_OFTREE=y
CONFIG_BLSPEC=y
CONFIG_CONSOLE_ALLOW_COLOR=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/raspberry-pi/env"
+CONFIG_DEFAULT_ENVIRONMENT_PATH=""
CONFIG_CMD_DMESG=y
CONFIG_LONGHELP=y
CONFIG_CMD_IOMEM=y
diff --git a/arch/arm/dts/bcm2835-rpi.dts b/arch/arm/dts/bcm2835-rpi.dts
index 4f22750801..8d352a457d 100644
--- a/arch/arm/dts/bcm2835-rpi.dts
+++ b/arch/arm/dts/bcm2835-rpi.dts
@@ -1,19 +1,9 @@
#include <arm/bcm2835-rpi-a.dts>
-/ {
- chosen {
- stdout-path = &uart0;
- };
+&{/aliases} {
+ usb0 = &usb;
};
&{/memory@0} {
reg = <0x0 0x0>;
};
-
-&sdhci {
- status = "okay";
-};
-
-&sdhost {
- status = "disabled";
-};
diff --git a/arch/arm/dts/bcm2836-rpi-2.dts b/arch/arm/dts/bcm2836-rpi-2.dts
index c9c3892d6a..c9106515ee 100644
--- a/arch/arm/dts/bcm2836-rpi-2.dts
+++ b/arch/arm/dts/bcm2836-rpi-2.dts
@@ -1,11 +1,5 @@
#include <arm/bcm2836-rpi-2-b.dts>
-/ {
- chosen {
- stdout-path = &uart0;
- };
-};
-
&{/memory@0} {
reg = <0x0 0x0>;
};
diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts
index d66beddb22..e82d518fa5 100644
--- a/arch/arm/dts/bcm2837-rpi-3.dts
+++ b/arch/arm/dts/bcm2837-rpi-3.dts
@@ -1,11 +1,5 @@
#include <arm64/broadcom/bcm2837-rpi-3-b.dts>
-/ {
- chosen {
- stdout-path = &uart1;
- };
-};
-
&{/memory@0} {
reg = <0x0 0x0>;
};
diff --git a/arch/arm/mach-bcm283x/include/mach/platform.h b/arch/arm/mach-bcm283x/include/mach/platform.h
index d8561c1610..310f2463f2 100644
--- a/arch/arm/mach-bcm283x/include/mach/platform.h
+++ b/arch/arm/mach-bcm283x/include/mach/platform.h
@@ -32,6 +32,7 @@
#define BCM2835_PL011_BASE 0x20201000
#define BCM2836_PL011_BASE 0x3f201000
+#define BCM2835_MINIUART_BASE 0x20215040
#define BCM2836_MINIUART_BASE 0x3f215040
#endif
diff --git a/drivers/of/base.c b/drivers/of/base.c
index dcb5ccd018..edb0a8e71a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2567,6 +2567,21 @@ int of_device_disable_path(const char *path)
}
/**
+ * of_device_disable_by_alias - disable a devicenode by alias
+ * @alias - the alias of the device tree node to disable
+ */
+int of_device_disable_by_alias(const char *alias)
+{
+ struct device_node *node;
+
+ node = of_find_node_by_alias(NULL, alias);
+ if (!node)
+ return -ENODEV;
+
+ return of_device_disable(node);
+}
+
+/**
* of_get_reproducible_name() - get a reproducible name of a node
* @node: The node to get a name from
*
diff --git a/include/of.h b/include/of.h
index 399fb7c5ba..645f429bde 100644
--- a/include/of.h
+++ b/include/of.h
@@ -1006,6 +1006,7 @@ int of_device_enable(struct device_node *node);
int of_device_enable_path(const char *path);
int of_device_disable(struct device_node *node);
int of_device_disable_path(const char *path);
+int of_device_disable_by_alias(const char *alias);
phandle of_get_tree_max_phandle(struct device_node *root);
phandle of_node_create_phandle(struct device_node *node);