From: Simon Glass Date: Tue, 7 May 2013 12:42:03 -0700 Subject: [U-Boot] [RFC PATCH v2 07/14] dm: Set up driver model after relocation In-Reply-To: <1367955730-31902-1-git-send-email-sjg@chromium.org> References: <1367955730-31902-1-git-send-email-sjg@chromium.org> Message-ID: <1367955730-31902-8-git-send-email-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 Make driver model available after relocation, by setting up data structures and scanning for devices using compiled-in platform_data and (when available) the device tree. Signed-off-by: Simon Glass --- Changes in v2: None common/board_r.c | 33 +++++++++++++++++++++++++++++++++ common/dm/lists.c | 2 ++ common/dm/root.c | 2 ++ 3 files changed, 37 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index f801e41..de1768b 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -34,6 +34,7 @@ #ifdef CONFIG_HAS_DATAFLASH #include #endif +#include #include #include #if defined(CONFIG_CMD_IDE) @@ -66,7 +67,9 @@ #ifdef CONFIG_X86 #include #endif +#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -269,6 +272,33 @@ static int initr_malloc(void) return 0; } +#ifdef CONFIG_DM +static int initr_dm(void) +{ + int ret; + + ret = dm_init(); + if (ret) { + debug("dm_init() failed: %d\n", ret); + return ret; + } + ret = dm_scan_platform_data(); + if (ret) { + debug("dm_scan_platform_data() failed: %d\n", ret); + return ret; + } +#ifdef CONFIG_OF_CONTROL + ret = dm_scan_fdt(gd->fdt_blob); + if (ret) { + debug("dm_scan_fdt() failed: %d\n", ret); + return ret; + } +#endif + + return 0; +} +#endif + __weak int power_init_board(void) { return 0; @@ -765,6 +795,9 @@ init_fnc_t init_sequence_r[] = { #endif initr_barrier, initr_malloc, +#ifdef CONFIG_DM + initr_dm, +#endif #ifdef CONFIG_ARCH_EARLY_INIT_R arch_early_init_r, #endif diff --git a/common/dm/lists.c b/common/dm/lists.c index 02bcb50..ec7825b 100644 --- a/common/dm/lists.c +++ b/common/dm/lists.c @@ -110,6 +110,7 @@ int lists_bind_drivers(struct device *parent) return result; } +#ifdef CONFIG_OF_CONTROL /** * driver_check_compatible() - Check if a driver is compatible with this node * @@ -179,3 +180,4 @@ int lists_bind_fdt(struct device *parent, const void *blob, int offset) return result; } +#endif diff --git a/common/dm/root.c b/common/dm/root.c index bba793a..b6733dd 100644 --- a/common/dm/root.c +++ b/common/dm/root.c @@ -92,6 +92,7 @@ int dm_scan_platform_data(void) return 0; } +#ifdef CONFIG_OF_CONTROL int dm_scan_fdt(const void *blob) { int offset = 0; @@ -112,6 +113,7 @@ int dm_scan_fdt(const void *blob) return ret; } +#endif U_BOOT_DRIVER(root_driver) = { .name = "root_driver", -- 1.8.2.1