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 2964dbbd40SGerald Van Baren #include <fdt.h> 3064dbbd40SGerald Van Baren 313bed2aafSKumar Gala u32 fdt_getprop_u32_default(void *fdt, const char *path, const char *prop, 323bed2aafSKumar Gala const u32 dflt); 3356844a22SHeiko Schocher int fdt_chosen(void *fdt, int force); 342a1a2cb6SKumar Gala int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force); 35e93becf8SKumar Gala void do_fixup_by_path(void *fdt, const char *path, const char *prop, 36e93becf8SKumar Gala const void *val, int len, int create); 37e93becf8SKumar Gala void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop, 38e93becf8SKumar Gala u32 val, int create); 398ddb10eaSChunhe Lan 408ddb10eaSChunhe Lan static inline void do_fixup_by_path_string(void *fdt, const char *path, 418ddb10eaSChunhe Lan const char *prop, const char *status) 428ddb10eaSChunhe Lan { 438ddb10eaSChunhe Lan do_fixup_by_path(fdt, path, prop, status, strlen(status) + 1, 1); 448ddb10eaSChunhe Lan } 458ddb10eaSChunhe Lan 469eb77ceaSKumar Gala void do_fixup_by_prop(void *fdt, 479eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 489eb77ceaSKumar Gala const char *prop, const void *val, int len, 499eb77ceaSKumar Gala int create); 509eb77ceaSKumar Gala void do_fixup_by_prop_u32(void *fdt, 519eb77ceaSKumar Gala const char *pname, const void *pval, int plen, 529eb77ceaSKumar Gala const char *prop, u32 val, int create); 539eb77ceaSKumar Gala void do_fixup_by_compat(void *fdt, const char *compat, 549eb77ceaSKumar Gala const char *prop, const void *val, int len, int create); 559eb77ceaSKumar Gala void do_fixup_by_compat_u32(void *fdt, const char *compat, 569eb77ceaSKumar Gala const char *prop, u32 val, int create); 573c927281SKumar Gala int fdt_fixup_memory(void *blob, u64 start, u64 size); 58a6bd9e83SJohn Rigby int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks); 59ba37aa03SKumar Gala void fdt_fixup_ethernet(void *fdt); 6022fb2246SMatthias Fuchs int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, 6122fb2246SMatthias Fuchs const void *val, int len, int create); 62b8ec2385STimur Tabi void fdt_fixup_qe_firmware(void *fdt); 6364dbbd40SGerald Van Baren 6418e69a35SAnton Vorontsov #ifdef CONFIG_HAS_FSL_DR_USB 6518e69a35SAnton Vorontsov void fdt_fixup_dr_usb(void *blob, bd_t *bd); 6618e69a35SAnton Vorontsov #else 6718e69a35SAnton Vorontsov static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} 6818e69a35SAnton Vorontsov #endif /* CONFIG_HAS_FSL_DR_USB */ 6918e69a35SAnton Vorontsov 70929a2138SKim Phillips #if defined(CONFIG_SYS_FSL_SEC_COMPAT) 716b70ffb9SKim Phillips void fdt_fixup_crypto_node(void *blob, int sec_rev); 726b70ffb9SKim Phillips #else 736b70ffb9SKim Phillips static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {} 746b70ffb9SKim Phillips #endif 756b70ffb9SKim Phillips 768ab451c4SKumar Gala #ifdef CONFIG_PCI 778ab451c4SKumar Gala #include <pci.h> 788ab451c4SKumar Gala int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose); 798ab451c4SKumar Gala #endif 808ab451c4SKumar Gala 81e125a2ffSGerald Van Baren #ifdef CONFIG_OF_BOARD_SETUP 82e125a2ffSGerald Van Baren void ft_board_setup(void *blob, bd_t *bd); 83e125a2ffSGerald Van Baren void ft_cpu_setup(void *blob, bd_t *bd); 84e125a2ffSGerald Van Baren void ft_pci_setup(void *blob, bd_t *bd); 85e125a2ffSGerald Van Baren #endif 86e125a2ffSGerald Van Baren 8754f9c866SKumar Gala void set_working_fdt_addr(void *addr); 883082d234SKumar Gala int fdt_resize(void *blob); 89b3606f14STimur Tabi int fdt_increase_size(void *fdt, int add_len); 9054f9c866SKumar Gala 918a805df1SStefan Roese int fdt_fixup_nor_flash_size(void *blob); 9230d45c0dSStefan Roese 933c950e2eSAnatolij Gustschin void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size); 9449b97d9cSKumar Gala void fdt_del_node_and_alias(void *blob, const char *alias); 95a0342c08SKumar Gala u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr); 9675e73afdSKumar Gala int fdt_node_offset_by_compat_reg(void *blob, const char *compat, 9775e73afdSKumar Gala phys_addr_t compat_off); 98b4b847e9SKumar Gala int fdt_alloc_phandle(void *blob); 99f117c0f0SKumar Gala int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle); 1003c927cccSTimur Tabi unsigned int fdt_create_phandle(void *fdt, int nodeoffset); 101beca5a5fSAnatolij Gustschin int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); 1023c950e2eSAnatolij Gustschin 103bb682001STimur Tabi int fdt_verify_alias_address(void *fdt, int anode, const char *alias, 104bb682001STimur Tabi u64 addr); 105bb682001STimur Tabi u64 fdt_get_base_address(void *fdt, int node); 106bb682001STimur Tabi 107*2a523f52SShengzhou Liu enum fdt_status { 108*2a523f52SShengzhou Liu FDT_STATUS_OKAY, 109*2a523f52SShengzhou Liu FDT_STATUS_DISABLED, 110*2a523f52SShengzhou Liu FDT_STATUS_FAIL, 111*2a523f52SShengzhou Liu FDT_STATUS_FAIL_ERROR_CODE, 112*2a523f52SShengzhou Liu }; 113*2a523f52SShengzhou Liu int fdt_set_node_status(void *fdt, int nodeoffset, 114*2a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 115*2a523f52SShengzhou Liu static inline int fdt_status_okay(void *fdt, int nodeoffset) 116*2a523f52SShengzhou Liu { 117*2a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_OKAY, 0); 118*2a523f52SShengzhou Liu } 119*2a523f52SShengzhou Liu static inline int fdt_status_disabled(void *fdt, int nodeoffset) 120*2a523f52SShengzhou Liu { 121*2a523f52SShengzhou Liu return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_DISABLED, 0); 122*2a523f52SShengzhou Liu } 123*2a523f52SShengzhou Liu 124*2a523f52SShengzhou Liu int fdt_set_status_by_alias(void *fdt, const char* alias, 125*2a523f52SShengzhou Liu enum fdt_status status, unsigned int error_code); 126*2a523f52SShengzhou Liu static inline int fdt_status_okay_by_alias(void *fdt, const char* alias) 127*2a523f52SShengzhou Liu { 128*2a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_OKAY, 0); 129*2a523f52SShengzhou Liu } 130*2a523f52SShengzhou Liu static inline int fdt_status_disabled_by_alias(void *fdt, const char* alias) 131*2a523f52SShengzhou Liu { 132*2a523f52SShengzhou Liu return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0); 133*2a523f52SShengzhou Liu } 134*2a523f52SShengzhou Liu 13564dbbd40SGerald Van Baren #endif /* ifdef CONFIG_OF_LIBFDT */ 13664dbbd40SGerald Van Baren #endif /* ifndef __FDT_SUPPORT_H */ 137