From: Simon Glass Date: Sun, 19 Mar 2017 12:59:27 -0600 Subject: [U-Boot] [PATCH 08/16] dm: sandbox: Convert to using driver-model baord init In-Reply-To: <20170319185935.20950-1-sjg@chromium.org> References: <20170319185935.20950-1-sjg@chromium.org> Message-ID: <20170319185935.20950-9-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Adjust the existing hooks to use a driver instead. Signed-off-by: Simon Glass --- arch/Kconfig | 3 +++ board/sandbox/sandbox.c | 44 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 76c690f667..f07070db18 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -64,6 +64,9 @@ config SANDBOX bool "Sandbox" select BOARD_LATE_INIT select SUPPORT_OF_CONTROL + select BOARD + select SPL_BOARD + select BOARD_ENABLE select DM select DM_KEYBOARD select DM_SPI_FLASH diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index b41e9decb3..1eea20cbcb 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -41,12 +42,6 @@ unsigned long timer_read_counter(void) } #endif -int dram_init(void) -{ - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; - return 0; -} - #ifdef CONFIG_BOARD_LATE_INIT int board_late_init(void) { @@ -63,3 +58,40 @@ int board_late_init(void) return 0; } #endif + +static int sandbox_phase(struct udevice *dev, enum board_phase_t phase) +{ + struct sandbox_state *state = state_get_current(); + + switch (phase) { + case BOARD_F_DRAM_INIT: + gd->ram_size = state->ram_size; + return 0; + default: + return -ENOSYS; + } + + return 0; +} + +static int sandbox_board_probe(struct udevice *dev) +{ + return board_support_phase(dev, BOARD_F_DRAM_INIT); +} + +static const struct board_ops sandbox_board_ops = { + .phase = sandbox_phase, +}; + +/* Name this starting with underscore so it will be called last */ +U_BOOT_DRIVER(_sandbox_board_drv) = { + .name = "sandbox_board", + .id = UCLASS_BOARD, + .ops = &sandbox_board_ops, + .probe = sandbox_board_probe, + .flags = DM_FLAG_PRE_RELOC, +}; + +U_BOOT_DEVICE(sandbox_board) = { + .name = "sandbox_board", +}; -- 2.12.0.367.g23dc2f6d3c-goog