164dbbd40SGerald Van Baren /* 264dbbd40SGerald Van Baren * (C) Copyright 2007 364dbbd40SGerald Van Baren * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com 464dbbd40SGerald Van Baren * 51a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 664dbbd40SGerald Van Baren */ 764dbbd40SGerald Van Baren 864dbbd40SGerald Van Baren #ifndef __FDT_SUPPORT_H 964dbbd40SGerald Van Baren #define __FDT_SUPPORT_H 1064dbbd40SGerald Van Baren 1164dbbd40SGerald Van Baren #ifdef CONFIG_OF_LIBFDT 1264dbbd40SGerald Van Baren 1358864ddcSGerald Van Baren #include <libfdt.h> 1464dbbd40SGerald Van Baren 15*94fb182cSAlexander Graf u32 fdt_getprop_u32_default_node(const void *fdt, int off, int cell, 16*94fb182cSAlexander Graf const char *prop, const u32 dflt); 1707e12784SGabe Black u32 fdt_getprop_u32_default(const void *fdt, const char *path, 1807e12784SGabe Black const char *prop, const u32 dflt); 1956844a22SHeiko Schocher int fdt_chosen(void *fdt, int force); 202a1a2cb6SKumar Gala int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force); 21e93becf8SKumar Gala void do_fixup_by_path(void *fdt, const char *path, const char *prop, 22e93becf8SKumar Gala const void *val, int len, int create); 23e93becf8SKumar Gala void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop, 24e93becf8SKumar Gala u32 val, int create); 258ddb10eaSChunhe Lan 268ddb10eaSChunhe Lan static inline void do_fixup_by_path_string(void *fdt, const char *path, 278ddb10eaSChunhe Lan const char *prop, const char *status) 288ddb10eaSChunhe Lan { 298ddb10eaSChunhe Lan do_fixup_by_path(fdt, path, prop, status, strlen(status) + 1, 1); 308ddb10eaSChunhe Lan } 318ddb10eaSChunhe Lan 329eb77ceaSKumar Gala void do_fixup_by_prop(void *fdt, 339eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 349eb77ceaSKumar Gala const char *prop, const void *val, int len, 359eb77ceaSKumar Gala int create); 369eb77ceaSKumar Gala void do_fixup_by_prop_u32(void *fdt, 379eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 389eb77ceaSKumar Gala const char *prop, u32 val, int create); 399eb77ceaSKumar Gala void do_fixup_by_compat(void *fdt, const char *compat, 409eb77ceaSKumar Gala const char *prop, const void *val, int len, int create); 419eb77ceaSKumar Gala void do_fixup_by_compat_u32(void *fdt, const char *compat, 429eb77ceaSKumar Gala const char *prop, u32 val, int create); 433c927281SKumar Gala int fdt_fixup_memory(void *blob, u64 start, u64 size); 44a6bd9e83SJohn Rigby int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks); 45ba37aa03SKumar Gala void fdt_fixup_ethernet(void *fdt); 4622fb2246SMatthias Fuchs int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, 4722fb2246SMatthias Fuchs const void *val, int len, int create); 48b8ec2385STimur Tabi void fdt_fixup_qe_firmware(void *fdt); 4964dbbd40SGerald Van Baren 5079f49120Sramneek mehresh #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) 5118e69a35SAnton Vorontsov void fdt_fixup_dr_usb(void *blob, bd_t *bd); 5218e69a35SAnton Vorontsov #else 5318e69a35SAnton Vorontsov static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} 5479f49120Sramneek mehresh #endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */ 5518e69a35SAnton Vorontsov 56929a2138SKim Phillips #if defined(CONFIG_SYS_FSL_SEC_COMPAT) 576b70ffb9SKim Phillips void fdt_fixup_crypto_node(void *blob, int sec_rev); 586b70ffb9SKim Phillips #else 596b70ffb9SKim Phillips static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {} 606b70ffb9SKim Phillips #endif 616b70ffb9SKim Phillips 628ab451c4SKumar Gala #ifdef CONFIG_PCI 638ab451c4SKumar Gala #include <pci.h> 648ab451c4SKumar Gala int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose); 658ab451c4SKumar Gala #endif 668ab451c4SKumar Gala 67e125a2ffSGerald Van Baren void ft_board_setup(void *blob, bd_t *bd); 68e125a2ffSGerald Van Baren void ft_cpu_setup(void *blob, bd_t *bd); 69e125a2ffSGerald Van Baren void ft_pci_setup(void *blob, bd_t *bd); 70e125a2ffSGerald Van Baren 7154f9c866SKumar Gala void set_working_fdt_addr(void *addr); 723082d234SKumar Gala int fdt_resize(void *blob); 73b3606f14STimur Tabi int fdt_increase_size(void *fdt, int add_len); 7454f9c866SKumar Gala 758a805df1SStefan Roese int fdt_fixup_nor_flash_size(void *blob); 7630d45c0dSStefan Roese 773c950e2eSAnatolij Gustschin void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size); 7849b97d9cSKumar Gala void fdt_del_node_and_alias(void *blob, const char *alias); 798aa5ec6eSKim Phillips u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr); 8075e73afdSKumar Gala int fdt_node_offset_by_compat_reg(void *blob, const char *compat, 8175e73afdSKumar Gala phys_addr_t compat_off); 82b4b847e9SKumar Gala int fdt_alloc_phandle(void *blob); 83f117c0f0SKumar Gala int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle); 843c927cccSTimur Tabi unsigned int fdt_create_phandle(void *fdt, int nodeoffset); 85beca5a5fSAnatolij Gustschin int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); 863c950e2eSAnatolij Gustschin 87bb682001STimur Tabi int fdt_verify_alias_address(void *fdt, int anode, const char *alias, 88bb682001STimur Tabi u64 addr); 89bb682001STimur Tabi u64 fdt_get_base_address(void *fdt, int node); 90bb682001STimur Tabi 912a523f52SShengzhou Liu enum fdt_status { 922a523f52SShengzhou Liu FDT_STATUS_OKAY, 932a523f52SShengzhou Liu FDT_STATUS_DISABLED, 942a523f52SShengzhou Liu FDT_STATUS_FAIL, 952a523f52SShengzhou Liu FDT_STATUS_FAIL_ERROR_CODE, 962a523f52SShengzhou Liu }; 972a523f52SShengzhou Liu int fdt_set_node_status(void *fdt, int nodeoffset, 982a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 992a523f52SShengzhou Liu static inline int fdt_status_okay(void *fdt, int nodeoffset) 1002a523f52SShengzhou Liu { 1012a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_OKAY, 0); 1022a523f52SShengzhou Liu } 1032a523f52SShengzhou Liu static inline int fdt_status_disabled(void *fdt, int nodeoffset) 1042a523f52SShengzhou Liu { 1052a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_DISABLED, 0); 1062a523f52SShengzhou Liu } 1072a523f52SShengzhou Liu 1082a523f52SShengzhou Liu int fdt_set_status_by_alias(void *fdt, const char* alias, 1092a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 1102a523f52SShengzhou Liu static inline int fdt_status_okay_by_alias(void *fdt, const char* alias) 1112a523f52SShengzhou Liu { 1122a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_OKAY, 0); 1132a523f52SShengzhou Liu } 1142a523f52SShengzhou Liu static inline int fdt_status_disabled_by_alias(void *fdt, const char* alias) 1152a523f52SShengzhou Liu { 1162a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0); 1172a523f52SShengzhou Liu } 1182a523f52SShengzhou Liu 11964dbbd40SGerald Van Baren #endif /* ifdef CONFIG_OF_LIBFDT */ 12029a23f9dSHeiko Schocher 12129a23f9dSHeiko Schocher #ifdef USE_HOSTCC 12229a23f9dSHeiko Schocher int fdtdec_get_int(const void *blob, int node, const char *prop_name, 12329a23f9dSHeiko Schocher int default_val); 12429a23f9dSHeiko Schocher #endif 12564dbbd40SGerald Van Baren #endif /* ifndef __FDT_SUPPORT_H */ 126