All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 48/60] ARM: tegra: lay groundwork for board hook cleanup
Date: Tue, 19 Apr 2016 14:59:28 -0600	[thread overview]
Message-ID: <1461099580-3866-49-git-send-email-swarren@wwwdotorg.org> (raw)
In-Reply-To: <1461099580-3866-1-git-send-email-swarren@wwwdotorg.org>

From: Stephen Warren <swarren@nvidia.com>

Tegra's board2.c and spl.c implement the core U-Boot board initialization
hooks, and call a variety of other functions to initialize the system,
some of which are implemented by board-specific code. board2.c and spl.c
currently call a large variety of "hook" functions that boards can
customize, one per type of action that might be performed by a board. This
isn't very scalable, and leads to a lot of ifdefs in board2.c. This patch
creates yet more functions that board2.c ans spl.c will call, with the aim
that all other functionality will be migrated into those functions.

The new functions are added to a new header file to make it more obvious
which are "the new way" and which will eventually go away (board.h).

Two simple one-off cases are immediately converted to the new functions,
and the old functions removed. Other functions require a bit more work
and will be converted by separate patches.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/board2.c                  | 17 +++++++++++------
 arch/arm/mach-tegra/include/mach/board.h      |  7 -------
 arch/arm/mach-tegra/include/mach/board_init.h | 15 +++++++++++++++
 arch/arm/mach-tegra/spl.c                     |  4 ++++
 board/nvidia/nyan-big/nyan-big.c              |  2 +-
 board/nvidia/p2571/p2571.c                    |  7 ++-----
 6 files changed, 33 insertions(+), 19 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/board_init.h

diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index 2667efe5aa71..cf17f709d480 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -21,6 +21,7 @@
 #include <usb.h>
 #endif
 #include <mach/board.h>
+#include <mach/board_init.h>
 #ifdef CONFIG_TEGRA_MMC
 #include <mach/tegra_mmc.h>
 #endif
@@ -52,7 +53,6 @@ __weak void pin_mux_usb(void) {}
 __weak void pin_mux_spi(void) {}
 __weak void gpio_early_init_uart(void) {}
 __weak void pin_mux_display(void) {}
-__weak void start_cpu_fan(void) {}
 
 #if defined(CONFIG_TEGRA_NAND)
 __weak void pin_mux_nand(void)
@@ -100,7 +100,7 @@ __weak int tegra_lcd_pmic_init(int board_it)
 	return 0;
 }
 
-__weak int nvidia_board_init(void)
+__weak int tegra_board_init(void)
 {
 	return 0;
 }
@@ -174,16 +174,17 @@ int board_init(void)
 	/* prepare the WB code to LP0 location */
 	warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE);
 #endif
-	return nvidia_board_init();
+	return tegra_board_init();
 }
 
-#ifdef CONFIG_BOARD_EARLY_INIT_F
 static void __gpio_early_init(void)
 {
 }
 
 void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
 
+__weak void tegra_board_early_init_f(void) {}
+
 int board_early_init_f(void)
 {
 #if defined(CONFIG_TEGRA_DISCONNECT_UDC_ON_BOOT)
@@ -200,6 +201,8 @@ int board_early_init_f(void)
 #endif
 		arch_timer_init();
 
+	tegra_board_early_init_f();
+
 	pinmux_init();
 	board_init_uart_f();
 
@@ -209,7 +212,8 @@ int board_early_init_f(void)
 
 	return 0;
 }
-#endif	/* EARLY_INIT */
+
+__weak void tegra_board_late_init(void) {}
 
 int board_late_init(void)
 {
@@ -221,7 +225,8 @@ int board_late_init(void)
 		setenv("cpu_ns_mode", "");
 	}
 #endif
-	start_cpu_fan();
+
+	tegra_board_late_init();
 
 	return 0;
 }
diff --git a/arch/arm/mach-tegra/include/mach/board.h b/arch/arm/mach-tegra/include/mach/board.h
index f6688ef761e7..b12ec7eed25e 100644
--- a/arch/arm/mach-tegra/include/mach/board.h
+++ b/arch/arm/mach-tegra/include/mach/board.h
@@ -43,11 +43,4 @@ int tegra_lcd_pmic_init(int board_id);
  */
 int tegra_board_id(void);
 
-/**
- * nvidia_board_init() - perform any board-specific init
- *
- * @return 0 if OK, -ve on error
- */
-int nvidia_board_init(void);
-
 #endif
diff --git a/arch/arm/mach-tegra/include/mach/board_init.h b/arch/arm/mach-tegra/include/mach/board_init.h
new file mode 100644
index 000000000000..fe13b8e9439b
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/board_init.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef _MACH_BOARD_INIT_H
+#define _MACH_BOARD_INIT_H
+
+void tegra_spl_board_init(void);
+void tegra_board_early_init_f(void);
+int tegra_board_init(void);
+void tegra_board_late_init(void);
+
+#endif
diff --git a/arch/arm/mach-tegra/spl.c b/arch/arm/mach-tegra/spl.c
index 49af4119e927..35b538f0f614 100644
--- a/arch/arm/mach-tegra/spl.c
+++ b/arch/arm/mach-tegra/spl.c
@@ -14,9 +14,12 @@
 #include <asm/arch/tegra.h>
 #include <asm/spl.h>
 #include <mach/board.h>
+#include <mach/board_init.h>
 #include "apb_misc.h"
 #include "cpu.h"
 
+__weak void tegra_spl_board_init(void) {}
+
 void spl_board_init(void)
 {
 	struct apb_misc_pp_ctlr *apb_misc =
@@ -31,6 +34,7 @@ void spl_board_init(void)
 	gpio_early_init_uart();
 
 	clock_early_init();
+	tegra_spl_board_init();
 	preloader_console_init();
 }
 
diff --git a/board/nvidia/nyan-big/nyan-big.c b/board/nvidia/nyan-big/nyan-big.c
index fd9669ba0bb5..1af7f535f6d4 100644
--- a/board/nvidia/nyan-big/nyan-big.c
+++ b/board/nvidia/nyan-big/nyan-big.c
@@ -104,7 +104,7 @@ static void enable_required_clocks(void)
 		reset_set_enable(ids[i], 0);
 }
 
-int nvidia_board_init(void)
+int tegra_board_init(void)
 {
 	clock_start_periph_pll(PERIPH_ID_EXTPERIPH1, CLOCK_ID_OSC, 12000000);
 	clock_start_periph_pll(PERIPH_ID_I2S1, CLOCK_ID_OSC, 1500000);
diff --git a/board/nvidia/p2571/p2571.c b/board/nvidia/p2571/p2571.c
index 58e5c56c5b16..ae9b6aa2e54c 100644
--- a/board/nvidia/p2571/p2571.c
+++ b/board/nvidia/p2571/p2571.c
@@ -52,12 +52,9 @@ void pinmux_init(void)
 				   ARRAY_SIZE(p2571_drvgrps));
 }
 
-/*
- * Routine: start_cpu_fan
- * Description: Enable/start PWM CPU fan on P2571
- */
-void start_cpu_fan(void)
+void tegra_board_late_init(void)
 {
+	/* Enable/start PWM CPU fan */
 	/* GPIO_PE4 is PS_VDD_FAN_ENABLE */
 	gpio_request(TEGRA_GPIO(E, 4), "FAN_VDD");
 	gpio_direction_output(TEGRA_GPIO(E, 4), 1);
-- 
2.8.1

  parent reply	other threads:[~2016-04-19 20:59 UTC|newest]

Thread overview: 177+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19 20:58 [U-Boot] [PATCH 00/60] ARM: tegra: cleanup part 1 Stephen Warren
2016-04-19 20:58 ` [U-Boot] [PATCH 01/60] ARM: tegra: remove unused definitions in headers Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-24 10:20   ` Wolfgang Denk
2016-04-25 19:34     ` Stephen Warren
2016-04-25 21:46       ` Wolfgang Denk
2016-04-25 22:00         ` Stephen Warren
2016-04-25 21:54       ` Simon Glass
2016-04-25 22:02         ` Stephen Warren
2016-04-25 22:15           ` Simon Glass
2016-04-25 22:16           ` Tom Rini
2016-04-19 20:58 ` [U-Boot] [PATCH 02/60] mmc: tegra: move pad init into MMC driver Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-24 10:20   ` Wolfgang Denk
2016-04-25 19:42     ` Stephen Warren
2016-04-25 21:52       ` Wolfgang Denk
2016-04-25 22:37         ` Tom Rini
2016-04-25 22:43           ` Stephen Warren
2016-04-25 23:05             ` Tom Rini
2016-04-25 23:11               ` Stephen Warren
2016-04-25 23:26                 ` Tom Rini
2016-04-25 23:34                   ` Stephen Warren
2016-04-26  0:14                     ` Tom Rini
2016-04-26 16:21                       ` Stephen Warren
2016-04-26 18:15                         ` Tom Rini
2016-04-26 18:09                     ` Wolfgang Denk
2016-04-19 20:58 ` [U-Boot] [PATCH 03/60] mmc: tegra: move header file to driver directory Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 04/60] mmc: tegra: move public header to arch/arm/mach-tegra/include Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 05/60] pwm: tegra: move header file to driver directory Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-24 10:20   ` Wolfgang Denk
2016-04-25 19:47     ` Stephen Warren
2016-04-19 20:58 ` [U-Boot] [PATCH 06/60] i2c: " Stephen Warren
2016-04-20  4:48   ` Heiko Schocher
2016-04-20 19:25   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 07/60] usb: " Stephen Warren
2016-04-20 19:25   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 08/60] video: " Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 09/60] ARM: tegra: correct 64-bit DT unit addresses Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 10/60] ARM: tegra: sort DT /aliases entries Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 11/60] ARM: tegra: add DT alias for GPIO controller Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 12/60] gpio: tegra: remove duplicate define Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 13/60] ARM: tegra: sort some board file include directives Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-24 10:20   ` Wolfgang Denk
2016-04-25 19:54     ` Stephen Warren
2016-04-25 21:59       ` Wolfgang Denk
2016-04-25 23:22         ` Tom Rini
2016-04-26 16:18           ` Stephen Warren
2016-04-26 18:13             ` Wolfgang Denk
2016-04-26 18:20               ` Wolfgang Denk
2016-04-26 18:15             ` Tom Rini
2016-04-26 20:44               ` Stephen Warren
2016-04-26 23:29                 ` Tom Rini
2016-04-26 16:23           ` Stephen Warren
2016-04-26 18:15             ` Tom Rini
2016-04-19 20:58 ` [U-Boot] [PATCH 14/60] ARM: tegra: use DT bindings for GPIO naming Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 15/60] gpio: tegra: header file split Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-20 22:01     ` Stephen Warren
2016-04-21 14:11       ` Simon Glass
2016-04-21 16:40         ` Stephen Warren
2016-04-21 16:51           ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 16/60] ARM: tegra: migrate TEGRA_GPIO to Kconfig Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 17/60] ARM: tegra: move apb_misc.h Stephen Warren
2016-04-20 19:26   ` Simon Glass
2016-04-20 21:56     ` Stephen Warren
2016-04-21 20:59       ` Simon Glass
2016-04-21 21:14         ` Stephen Warren
2016-04-19 20:58 ` [U-Boot] [PATCH 18/60] ARM: tegra: move fuse.h Stephen Warren
2016-04-22 18:30   ` Simon Glass
2016-04-19 20:58 ` [U-Boot] [PATCH 19/60] ARM: tegra: move gpu.h Stephen Warren
2016-04-22 18:30   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 20/60] ARM: tegra: move pmc.h Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 21/60] ARM: tegra: move scu.h Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 22/60] ARM: tegra: move warmboot.h Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 23/60] ARM: tegra: move xusb-padctl.h to <mach/> Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 24/60] ARM: tegra: unify+move {board, sys_proto}.h " Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 25/60] ARM: tegra: use consistently named include guards Stephen Warren
2016-04-22 18:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 26/60] ARM: tegra: delete unused headers Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 27/60] ARM: tegra: move emc.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 28/60] ARM: tegra: move sdram_param.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 29/60] ARM: tegra: move sysctr.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 30/60] ARM: tegra: remove pmu.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-22 20:42     ` Stephen Warren
2016-04-19 20:59 ` [U-Boot] [PATCH 31/60] ARM: tegra: move powergate.h to <mach/> Stephen Warren
2016-04-22 18:33   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 32/60] ARM: tegra: add SoC-specific include directory Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 33/60] ARM: tegra: fix bug in Tegra20 flow.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 34/60] ARM: tegra: move flow.h Stephen Warren
2016-04-22 18:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 35/60] nyan-big: remove direct MC register access Stephen Warren
2016-04-22 18:33   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 36/60] ARM: tegra: move mc.h Stephen Warren
2016-04-22 18:33   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 37/60] ARM: tegra: move SDIOCFG_DRV* to pinmux.h Stephen Warren
2016-04-23 17:14   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 38/60] ARM: tegra: remove tegra_get_chip() Stephen Warren
2016-04-23 17:14   ` Simon Glass
2016-04-25 19:25     ` Stephen Warren
2016-04-27 14:50       ` Simon Glass
2016-04-27 16:13         ` Stephen Warren
2016-04-29 14:02           ` Simon Glass
2016-04-29 16:27             ` Stephen Warren
2016-04-29 16:53               ` Simon Glass
2016-04-29 17:42                 ` Simon Glass
2016-04-29 19:21                   ` Stephen Warren
2016-05-01 19:16                     ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 39/60] ARM: tegra: remove get_num_cpus() Stephen Warren
2016-04-19 20:59 ` [U-Boot] [PATCH 40/60] ARM: tegra: remove gp_padctrl.h Stephen Warren
2016-05-07 22:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 41/60] ARM: tegra: remove tegra_get_sku_info() Stephen Warren
2016-05-07 22:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 42/60] ARM: tegra: move EMC code to tegra20/ directory Stephen Warren
2016-05-07 22:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 43/60] ARM: tegra: move PLLX configuration into SoC directories Stephen Warren
2016-05-07 22:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 44/60] ARM: tegra: remove tegra_get_chip_sku() Stephen Warren
2016-05-07 22:31   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 45/60] ARM: tegra: move custom pinmux.h to <mach/> Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 46/60] ARM: tegra: add pinmux APIs to replace funcmux Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 47/60] ARM: tegra: provide API for SPL code to init UART Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` Stephen Warren [this message]
2016-04-19 20:59 ` [U-Boot] [PATCH 49/60] ARM: tegra: convert boards to new hooks Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 50/60] ARM: tegra: remove unused includes Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 51/60] ARM: tegra: move SPL-specific GPIO device to spl.c Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 52/60] ARM: tegra: convert pin_mux_*() to new hooks Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 53/60] tegra: keyboard: move pinmux setup to board files Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 54/60] video: tegra: " Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 55/60] i2c: " Stephen Warren
2016-04-27 15:12   ` Simon Glass
2016-04-27 16:24     ` Stephen Warren
2016-04-27 16:58       ` Simon Glass
2016-04-27 17:16         ` Stephen Warren
2016-04-29 14:02           ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 56/60] ARM: tegra: remove funcmux API Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 57/60] ARM: tegra: don't access Boot Info Table from board code Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 58/60] ARM: tegra: clean up board include statements Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 59/60] ARM: tegra: unify+move tegra.h to mach-tegra/ Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-04-19 20:59 ` [U-Boot] [PATCH 60/60] ARM: tegra: move clock headers Stephen Warren
2016-05-07 22:32   ` Simon Glass
2016-05-07 22:32 ` [U-Boot] [PATCH 00/60] ARM: tegra: cleanup part 1 Simon Glass

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=1461099580-3866-49-git-send-email-swarren@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.