diff mbox

[U-Boot,8/9] board: rpi: move uart deactivation to board_init

Message ID 20160926122651.22132-9-fvogt@suse.com
State Accepted
Commit d8396a3272edc4b8154d0c93ea9b40473b300739
Delegated to: Tom Rini
Headers show

Commit Message

Fabian Vogt Sept. 26, 2016, 12:26 p.m. UTC
When using OF_CONTROL, the disabled value of the mini UART platdata
gets reset after board_early_init_f. So move detection and disabling
to board_init and remove board_early_init_f.
This uses the first device using the mini uart driver, as this method
works reliably with different device trees or even no device tree at all.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
---
 board/raspberrypi/rpi/rpi.c | 40 ++++++++++++++++++++++++++--------------
 include/configs/rpi.h       |  1 -
 2 files changed, 26 insertions(+), 15 deletions(-)

Comments

Simon Glass Sept. 27, 2016, 12:35 a.m. UTC | #1
On 26 September 2016 at 06:26, Fabian Vogt <fvogt@suse.com> wrote:
> When using OF_CONTROL, the disabled value of the mini UART platdata
> gets reset after board_early_init_f. So move detection and disabling
> to board_init and remove board_early_init_f.
> This uses the first device using the mini uart driver, as this method
> works reliably with different device trees or even no device tree at all.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.com>
> ---
>  board/raspberrypi/rpi/rpi.c | 40 ++++++++++++++++++++++++++--------------
>  include/configs/rpi.h       |  1 -
>  2 files changed, 26 insertions(+), 15 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Nov. 29, 2016, 5:37 p.m. UTC | #2
On Mon, Sep 26, 2016 at 02:26:50PM +0200, Fabian Vogt wrote:

> When using OF_CONTROL, the disabled value of the mini UART platdata
> gets reset after board_early_init_f. So move detection and disabling
> to board_init and remove board_early_init_f.
> This uses the first device using the mini uart driver, as this method
> works reliably with different device trees or even no device tree at all.
> 
> Signed-off-by: Fabian Vogt <fvogt@suse.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 6245b36..09bfcc6 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -443,15 +443,6 @@  static void get_board_rev(void)
 	printf("RPI %s (0x%x)\n", model->name, revision);
 }
 
-int board_init(void)
-{
-	get_board_rev();
-
-	gd->bd->bi_boot_params = 0x100;
-
-	return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
-}
-
 #ifndef CONFIG_PL01X_SERIAL
 static bool rpi_is_serial_active(void)
 {
@@ -471,17 +462,38 @@  static bool rpi_is_serial_active(void)
 
 	return true;
 }
+
+/* Disable mini-UART I/O if it's not pinmuxed to our pins.
+ * The firmware only enables it if explicitly done in config.txt: enable_uart=1
+ */
+static void rpi_disable_inactive_uart(void)
+{
+	struct udevice *dev;
+	struct bcm283x_mu_serial_platdata *plat;
+
+	if (uclass_get_device_by_driver(UCLASS_SERIAL,
+					DM_GET_DRIVER(serial_bcm283x_mu),
+					&dev) || !dev)
+		return;
+
+	if (!rpi_is_serial_active()) {
+		plat = dev_get_platdata(dev);
+		plat->disabled = true;
+	}
+}
 #endif
 
-int board_early_init_f(void)
+int board_init(void)
 {
 #ifndef CONFIG_PL01X_SERIAL
-	/* Disable mini-UART I/O if it's not pinmuxed to our pins */
-	if (!rpi_is_serial_active())
-		serial_platdata.disabled = true;
+	rpi_disable_inactive_uart();
 #endif
 
-	return 0;
+	get_board_rev();
+
+	gd->bd->bi_boot_params = 0x100;
+
+	return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
 }
 
 int board_mmc_init(bd_t *bis)
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 8d4ad5d..e9c0417 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -16,7 +16,6 @@ 
 
 /* Architecture, CPU, etc.*/
 #define CONFIG_ARCH_CPU_INIT
-#define CONFIG_BOARD_EARLY_INIT_F
 
 /* Use SoC timer for AArch32, but architected timer for AArch64 */
 #ifndef CONFIG_ARM64