From e895a4b06f9062f052d438df7f4766b3decdb3d4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 23 Oct 2014 18:58:47 -0600 Subject: fdt: Allow ft_board_setup() to report failure This function can fail if the device tree runs out of space. Rather than silently booting with an incomplete device tree, allow the failure to be detected. Unfortunately this involves changing a lot of places in the code. I have not changed behvaiour to return an error where one is not currently returned, to avoid unexpected breakage. Eventually it would be nice to allow boards to register functions to be called to update the device tree. This would avoid all the many functions to do this. However it's not clear yet if this should be done using driver model or with a linker list. This work is left for later. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin --- include/fdt_support.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/fdt_support.h') diff --git a/include/fdt_support.h b/include/fdt_support.h index 55cef94..2e0adf3 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -64,7 +64,17 @@ static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {} int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose); #endif -void ft_board_setup(void *blob, bd_t *bd); +/** + * Add board-specific data to the FDT before booting the OS. + * + * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space. + * + * @param blob FDT blob to update + * @param bd_t Pointer to board data + * @return 0 if ok, or -FDT_ERR_... on error + */ +int ft_board_setup(void *blob, bd_t *bd); + /* * The keystone2 SOC requires all 32 bit aliased addresses to be converted * to their 36 physical format. This has to happen after all fdt nodes -- cgit v1.1 From a9e8e29101adcb0bfa1c39baba5fce6b9848678d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 23 Oct 2014 18:58:49 -0600 Subject: fdt: Export the fdt_find_or_add_subnode() function This function is useful for ensuring that a node exists. Export it so it can be used more widely. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin Reviewed-by: Tom Rini --- include/fdt_support.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/fdt_support.h') diff --git a/include/fdt_support.h b/include/fdt_support.h index 2e0adf3..9ada2e4 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -64,6 +64,8 @@ static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {} int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose); #endif +int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name); + /** * Add board-specific data to the FDT before booting the OS. * -- cgit v1.1 From 6f4dbc21e47c5c1dd191cbd2f0fb7252340e0dcb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 23 Oct 2014 18:58:53 -0600 Subject: fdt: Tidy up error handling in image_setup_libfdt() The message about needing to reset should be printed no matter what error is printed. Also, an error should always be printed. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin Reviewed-by: Tom Rini --- include/fdt_support.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/fdt_support.h') diff --git a/include/fdt_support.h b/include/fdt_support.h index 9ada2e4..a101306 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -70,6 +70,7 @@ int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name); * Add board-specific data to the FDT before booting the OS. * * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space. + * This function is called if CONFIG_OF_BOARD_SETUP is defined * * @param blob FDT blob to update * @param bd_t Pointer to board data -- cgit v1.1 From c654b5172a65faba2b541ee1fda1738534d47241 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 23 Oct 2014 18:58:54 -0600 Subject: fdt: Add ft_system_setup() function for system device tree additions Add an additional function for adding information to the device tree before booting. This permits additions which are not board-specific. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin Reviewed-by: Tom Rini --- include/fdt_support.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/fdt_support.h') diff --git a/include/fdt_support.h b/include/fdt_support.h index a101306..0fbc9bd 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -88,6 +88,18 @@ void ft_board_setup_ex(void *blob, bd_t *bd); void ft_cpu_setup(void *blob, bd_t *bd); void ft_pci_setup(void *blob, bd_t *bd); +/** + * Add system-specific data to the FDT before booting the OS. + * + * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space. + * This function is called if CONFIG_OF_SYSTEM_SETUP is defined + * + * @param blob FDT blob to update + * @param bd_t Pointer to board data + * @return 0 if ok, or -FDT_ERR_... on error + */ +int ft_system_setup(void *blob, bd_t *bd); + void set_working_fdt_addr(void *addr); int fdt_shrink_to_minimum(void *blob); int fdt_increase_size(void *fdt, int add_len); -- cgit v1.1