164dbbd40SGerald Van Baren /* 264dbbd40SGerald Van Baren * (C) Copyright 2007 364dbbd40SGerald Van Baren * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com 464dbbd40SGerald Van Baren * 564dbbd40SGerald Van Baren * See file CREDITS for list of people who contributed to this 664dbbd40SGerald Van Baren * project. 764dbbd40SGerald Van Baren * 864dbbd40SGerald Van Baren * This program is free software; you can redistribute it and/or 964dbbd40SGerald Van Baren * modify it under the terms of the GNU General Public License as 1064dbbd40SGerald Van Baren * published by the Free Software Foundation; either version 2 of 1164dbbd40SGerald Van Baren * the License, or (at your option) any later version. 1264dbbd40SGerald Van Baren * 1364dbbd40SGerald Van Baren * This program is distributed in the hope that it will be useful, 1464dbbd40SGerald Van Baren * but WITHOUT ANY WARRANTY; without even the implied warranty of 1564dbbd40SGerald Van Baren * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1664dbbd40SGerald Van Baren * GNU General Public License for more details. 1764dbbd40SGerald Van Baren * 1864dbbd40SGerald Van Baren * You should have received a copy of the GNU General Public License 1964dbbd40SGerald Van Baren * along with this program; if not, write to the Free Software 2064dbbd40SGerald Van Baren * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 2164dbbd40SGerald Van Baren * MA 02111-1307 USA 2264dbbd40SGerald Van Baren */ 2364dbbd40SGerald Van Baren 2464dbbd40SGerald Van Baren #ifndef __FDT_SUPPORT_H 2564dbbd40SGerald Van Baren #define __FDT_SUPPORT_H 2664dbbd40SGerald Van Baren 2764dbbd40SGerald Van Baren #ifdef CONFIG_OF_LIBFDT 2864dbbd40SGerald Van Baren 2912e06fe0SKim Phillips #include <libfdt_env.h> 3064dbbd40SGerald Van Baren #include <fdt.h> 3164dbbd40SGerald Van Baren 3207e12784SGabe Black u32 fdt_getprop_u32_default(const void *fdt, const char *path, 3307e12784SGabe Black const char *prop, const u32 dflt); 3456844a22SHeiko Schocher int fdt_chosen(void *fdt, int force); 352a1a2cb6SKumar Gala int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force); 36e93becf8SKumar Gala void do_fixup_by_path(void *fdt, const char *path, const char *prop, 37e93becf8SKumar Gala const void *val, int len, int create); 38e93becf8SKumar Gala void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop, 39e93becf8SKumar Gala u32 val, int create); 408ddb10eaSChunhe Lan 418ddb10eaSChunhe Lan static inline void do_fixup_by_path_string(void *fdt, const char *path, 428ddb10eaSChunhe Lan const char *prop, const char *status) 438ddb10eaSChunhe Lan { 448ddb10eaSChunhe Lan do_fixup_by_path(fdt, path, prop, status, strlen(status) + 1, 1); 458ddb10eaSChunhe Lan } 468ddb10eaSChunhe Lan 479eb77ceaSKumar Gala void do_fixup_by_prop(void *fdt, 489eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 499eb77ceaSKumar Gala const char *prop, const void *val, int len, 509eb77ceaSKumar Gala int create); 519eb77ceaSKumar Gala void do_fixup_by_prop_u32(void *fdt, 529eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 539eb77ceaSKumar Gala const char *prop, u32 val, int create); 549eb77ceaSKumar Gala void do_fixup_by_compat(void *fdt, const char *compat, 559eb77ceaSKumar Gala const char *prop, const void *val, int len, int create); 569eb77ceaSKumar Gala void do_fixup_by_compat_u32(void *fdt, const char *compat, 579eb77ceaSKumar Gala const char *prop, u32 val, int create); 583c927281SKumar Gala int fdt_fixup_memory(void *blob, u64 start, u64 size); 59a6bd9e83SJohn Rigby int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks); 60ba37aa03SKumar Gala void fdt_fixup_ethernet(void *fdt); 6122fb2246SMatthias Fuchs int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, 6222fb2246SMatthias Fuchs const void *val, int len, int create); 63b8ec2385STimur Tabi void fdt_fixup_qe_firmware(void *fdt); 6464dbbd40SGerald Van Baren 6579f49120Sramneek mehresh #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) 6618e69a35SAnton Vorontsov void fdt_fixup_dr_usb(void *blob, bd_t *bd); 6718e69a35SAnton Vorontsov #else 6818e69a35SAnton Vorontsov static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} 6979f49120Sramneek mehresh #endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */ 7018e69a35SAnton Vorontsov 71929a2138SKim Phillips #if defined(CONFIG_SYS_FSL_SEC_COMPAT) 726b70ffb9SKim Phillips void fdt_fixup_crypto_node(void *blob, int sec_rev); 736b70ffb9SKim Phillips #else 746b70ffb9SKim Phillips static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {} 756b70ffb9SKim Phillips #endif 766b70ffb9SKim Phillips 778ab451c4SKumar Gala #ifdef CONFIG_PCI 788ab451c4SKumar Gala #include <pci.h> 798ab451c4SKumar Gala int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose); 808ab451c4SKumar Gala #endif 818ab451c4SKumar Gala 82e125a2ffSGerald Van Baren #ifdef CONFIG_OF_BOARD_SETUP 83e125a2ffSGerald Van Baren void ft_board_setup(void *blob, bd_t *bd); 84e125a2ffSGerald Van Baren void ft_cpu_setup(void *blob, bd_t *bd); 85e125a2ffSGerald Van Baren void ft_pci_setup(void *blob, bd_t *bd); 86e125a2ffSGerald Van Baren #endif 87e125a2ffSGerald Van Baren 8854f9c866SKumar Gala void set_working_fdt_addr(void *addr); 893082d234SKumar Gala int fdt_resize(void *blob); 90b3606f14STimur Tabi int fdt_increase_size(void *fdt, int add_len); 9154f9c866SKumar Gala 928a805df1SStefan Roese int fdt_fixup_nor_flash_size(void *blob); 9330d45c0dSStefan Roese 943c950e2eSAnatolij Gustschin void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size); 9549b97d9cSKumar Gala void fdt_del_node_and_alias(void *blob, const char *alias); 96*8aa5ec6eSKim Phillips u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr); 9775e73afdSKumar Gala int fdt_node_offset_by_compat_reg(void *blob, const char *compat, 9875e73afdSKumar Gala phys_addr_t compat_off); 99b4b847e9SKumar Gala int fdt_alloc_phandle(void *blob); 100f117c0f0SKumar Gala int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle); 1013c927cccSTimur Tabi unsigned int fdt_create_phandle(void *fdt, int nodeoffset); 102beca5a5fSAnatolij Gustschin int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); 1033c950e2eSAnatolij Gustschin 104bb682001STimur Tabi int fdt_verify_alias_address(void *fdt, int anode, const char *alias, 105bb682001STimur Tabi u64 addr); 106bb682001STimur Tabi u64 fdt_get_base_address(void *fdt, int node); 107bb682001STimur Tabi 1082a523f52SShengzhou Liu enum fdt_status { 1092a523f52SShengzhou Liu FDT_STATUS_OKAY, 1102a523f52SShengzhou Liu FDT_STATUS_DISABLED, 1112a523f52SShengzhou Liu FDT_STATUS_FAIL, 1122a523f52SShengzhou Liu FDT_STATUS_FAIL_ERROR_CODE, 1132a523f52SShengzhou Liu }; 1142a523f52SShengzhou Liu int fdt_set_node_status(void *fdt, int nodeoffset, 1152a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 1162a523f52SShengzhou Liu static inline int fdt_status_okay(void *fdt, int nodeoffset) 1172a523f52SShengzhou Liu { 1182a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_OKAY, 0); 1192a523f52SShengzhou Liu } 1202a523f52SShengzhou Liu static inline int fdt_status_disabled(void *fdt, int nodeoffset) 1212a523f52SShengzhou Liu { 1222a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_DISABLED, 0); 1232a523f52SShengzhou Liu } 1242a523f52SShengzhou Liu 1252a523f52SShengzhou Liu int fdt_set_status_by_alias(void *fdt, const char* alias, 1262a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 1272a523f52SShengzhou Liu static inline int fdt_status_okay_by_alias(void *fdt, const char* alias) 1282a523f52SShengzhou Liu { 1292a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_OKAY, 0); 1302a523f52SShengzhou Liu } 1312a523f52SShengzhou Liu static inline int fdt_status_disabled_by_alias(void *fdt, const char* alias) 1322a523f52SShengzhou Liu { 1332a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0); 1342a523f52SShengzhou Liu } 1352a523f52SShengzhou Liu 13664dbbd40SGerald Van Baren #endif /* ifdef CONFIG_OF_LIBFDT */ 13764dbbd40SGerald Van Baren #endif /* ifndef __FDT_SUPPORT_H */ 138