mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH 07/11] ARM: rpi: Add Raspberry Pi Zero W mini-uart support
Date: Sat, 28 Nov 2020 22:39:30 +0100	[thread overview]
Message-ID: <20201128213934.681065-7-ahmad@a3f.at> (raw)
In-Reply-To: <20201128213934.681065-1-ahmad@a3f.at>

Unlike the Raspberry Pi 1 and Raspberry Pi Zero, the Raspberry Pi Zero W
has its console pins on the header connected to the mini-uart, not the
PL011. The secondary PL011 UART is connected to the bluetooth module.

Set the mini-uart as default console and disable the PL011. That way we
can use the Raspberry Pi 1 image for the Zero W as well.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 23 ++++++++++++++++++++++-
 drivers/of/base.c                         | 15 +++++++++++++++
 include/of.h                              |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index dba68d17992f..f1d8a4e0f609 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -173,6 +173,27 @@ static void rpi_0_init(void)
 	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 */
 static const struct rpi_model rpi_models_old_scheme[] = {
 	RPI_MODEL(0, "Unknown model", NULL),
@@ -208,7 +229,7 @@ static const struct rpi_model rpi_models_new_scheme[] = {
 	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_0_init),
+	RPI_MODEL(BCM2835_BOARD_REV_ZERO_W, 	"Zero W", 	rpi_0_w_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(0xf, "Unknown model", NULL),
diff --git a/drivers/of/base.c b/drivers/of/base.c
index dcb5ccd01844..4ff60aa81435 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2566,6 +2566,21 @@ int of_device_disable_path(const char *path)
 	return of_device_disable(node);
 }
 
+/**
+ * of_device_disable_path_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 60445729e81a..2104802df709 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);
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-11-28 21:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-28 21:39 [PATCH 01/11] Revert "ARM: dts: bcm2835-rpi: re-enable booting from SD card" Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 02/11] ARM: dts: rpi: drop unnecessary /chosen/stdout-path overrides Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 03/11] ARM: rpi: make functions in rpi-common.c static Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 04/11] ARM: rpi: move rpi_model_init() to postcore Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 05/11] ARM: rpi: support raspberry pi 1 and zero mini-uart Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 06/11] ARM: rpi: add new init function for Raspberry Pi Zero Ahmad Fatoum
2020-11-28 21:39 ` Ahmad Fatoum [this message]
2020-11-28 21:39 ` [PATCH 08/11] ARM: rpi: drop no longer needed environment Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 09/11] ARM: rpi: fix model description string Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 10/11] ARM: rpi: add new rpi boot target Ahmad Fatoum
2020-11-28 21:39 ` [PATCH 11/11] doc: bcm283x: document use of mini-uart on Raspberry Pi Zero W / CM3 Ahmad Fatoum
2020-11-29 19:50   ` Roland Hieber
2020-11-29 20:20     ` Ahmad Fatoum
2020-12-07  7:10     ` Sascha Hauer
2020-12-07 10:00       ` Ahmad Fatoum
2020-12-07 10:29         ` Sascha Hauer
2020-12-07 10:00   ` [PATCH] fixup! " Ahmad Fatoum

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=20201128213934.681065-7-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.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