1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 |
- #ifndef __fdtdec_h
- #define __fdtdec_h
- #include <libfdt.h>
- #include <pci.h>
- typedef phys_addr_t fdt_addr_t;
- typedef phys_size_t fdt_size_t;
- #ifdef CONFIG_PHYS_64BIT
- #define FDT_ADDR_T_NONE (-1ULL)
- #define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
- #define fdt_size_to_cpu(reg) be64_to_cpu(reg)
- #else
- #define FDT_ADDR_T_NONE (-1U)
- #define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
- #define fdt_size_to_cpu(reg) be32_to_cpu(reg)
- #endif
- struct fdt_memory {
- fdt_addr_t start;
- fdt_addr_t end;
- };
- #ifdef CONFIG_SPL_BUILD
- #define SPL_BUILD 1
- #else
- #define SPL_BUILD 0
- #endif
- struct fdt_resource {
- fdt_addr_t start;
- fdt_addr_t end;
- };
- enum fdt_pci_space {
- FDT_PCI_SPACE_CONFIG = 0,
- FDT_PCI_SPACE_IO = 0x01000000,
- FDT_PCI_SPACE_MEM32 = 0x02000000,
- FDT_PCI_SPACE_MEM64 = 0x03000000,
- FDT_PCI_SPACE_MEM32_PREF = 0x42000000,
- FDT_PCI_SPACE_MEM64_PREF = 0x43000000,
- };
- #define FDT_PCI_ADDR_CELLS 3
- #define FDT_PCI_SIZE_CELLS 2
- #define FDT_PCI_REG_SIZE \
- ((FDT_PCI_ADDR_CELLS + FDT_PCI_SIZE_CELLS) * sizeof(u32))
- struct fdt_pci_addr {
- u32 phys_hi;
- u32 phys_mid;
- u32 phys_lo;
- };
- static inline fdt_size_t fdt_resource_size(const struct fdt_resource *res)
- {
- return res->end - res->start + 1;
- }
- enum fdt_compat_id {
- COMPAT_UNKNOWN,
- COMPAT_NVIDIA_TEGRA20_EMC,
- COMPAT_NVIDIA_TEGRA20_EMC_TABLE,
- COMPAT_NVIDIA_TEGRA20_NAND,
- COMPAT_NVIDIA_TEGRA124_PMC,
- COMPAT_NVIDIA_TEGRA186_SDMMC,
- COMPAT_NVIDIA_TEGRA210_SDMMC,
- COMPAT_NVIDIA_TEGRA124_SDMMC,
- COMPAT_NVIDIA_TEGRA30_SDMMC,
- COMPAT_NVIDIA_TEGRA20_SDMMC,
- COMPAT_NVIDIA_TEGRA124_XUSB_PADCTL,
-
- COMPAT_NVIDIA_TEGRA210_XUSB_PADCTL,
-
- COMPAT_SMSC_LAN9215,
- COMPAT_SAMSUNG_EXYNOS5_SROMC,
- COMPAT_SAMSUNG_S3C2440_I2C,
- COMPAT_SAMSUNG_EXYNOS5_SOUND,
- COMPAT_WOLFSON_WM8994_CODEC,
- COMPAT_SAMSUNG_EXYNOS_USB_PHY,
- COMPAT_SAMSUNG_EXYNOS5_USB3_PHY,
- COMPAT_SAMSUNG_EXYNOS_TMU,
- COMPAT_SAMSUNG_EXYNOS_MIPI_DSI,
- COMPAT_SAMSUNG_EXYNOS_DWMMC,
- COMPAT_SAMSUNG_EXYNOS_MMC,
- COMPAT_MAXIM_MAX77686_PMIC,
- COMPAT_GENERIC_SPI_FLASH,
- COMPAT_MAXIM_98095_CODEC,
- COMPAT_SAMSUNG_EXYNOS5_I2C,
- COMPAT_SAMSUNG_EXYNOS_SYSMMU,
- COMPAT_INTEL_MICROCODE,
- COMPAT_AMS_AS3722,
- COMPAT_INTEL_QRK_MRC,
- COMPAT_ALTERA_SOCFPGA_DWMAC,
- COMPAT_ALTERA_SOCFPGA_DWMMC,
- COMPAT_ALTERA_SOCFPGA_DWC2USB,
- COMPAT_INTEL_BAYTRAIL_FSP,
- COMPAT_INTEL_BAYTRAIL_FSP_MDP,
- COMPAT_INTEL_IVYBRIDGE_FSP,
- COMPAT_SUNXI_NAND,
- COMPAT_COUNT,
- };
- #define MAX_PHANDLE_ARGS 16
- struct fdtdec_phandle_args {
- int node;
- int args_count;
- uint32_t args[MAX_PHANDLE_ARGS];
- };
- int fdtdec_parse_phandle_with_args(const void *blob, int src_node,
- const char *list_name,
- const char *cells_name,
- int cell_count, int index,
- struct fdtdec_phandle_args *out_args);
- int fdtdec_next_alias(const void *blob, const char *name,
- enum fdt_compat_id id, int *upto);
- enum fdt_compat_id fdtdec_lookup(const void *blob, int node);
- int fdtdec_next_compatible(const void *blob, int node,
- enum fdt_compat_id id);
- int fdtdec_next_compatible_subnode(const void *blob, int node,
- enum fdt_compat_id id, int *depthp);
- fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
- const char *prop_name, int index, int na, int ns,
- fdt_size_t *sizep, bool translate);
- fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
- int node, const char *prop_name, int index, fdt_size_t *sizep,
- bool translate);
- fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
- const char *prop_name, int index, fdt_size_t *sizep,
- bool translate);
- fdt_addr_t fdtdec_get_addr(const void *blob, int node,
- const char *prop_name);
- fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
- const char *prop_name, fdt_size_t *sizep);
- int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
- const char *prop_name, struct fdt_pci_addr *addr);
- int fdtdec_get_pci_vendev(const void *blob, int node,
- u16 *vendor, u16 *device);
- int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr,
- u32 *bar);
- s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
- s32 default_val);
- unsigned int fdtdec_get_uint(const void *blob, int node, const char *prop_name,
- unsigned int default_val);
- u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells);
- uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
- uint64_t default_val);
- int fdtdec_get_is_enabled(const void *blob, int node);
- int fdtdec_prepare_fdt(void);
- int fdtdec_check_fdt(void);
- int fdtdec_find_aliases_for_id(const void *blob, const char *name,
- enum fdt_compat_id id, int *node_list, int maxcount);
- int fdtdec_add_aliases_for_id(const void *blob, const char *name,
- enum fdt_compat_id id, int *node_list, int maxcount);
- int fdtdec_get_alias_seq(const void *blob, const char *base, int node,
- int *seqp);
- const char *fdtdec_get_chosen_prop(const void *blob, const char *name);
- int fdtdec_get_chosen_node(const void *blob, const char *name);
- const char *fdtdec_get_compatible(enum fdt_compat_id id);
- int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name);
- int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
- u32 *array, int count);
- int fdtdec_get_int_array_count(const void *blob, int node,
- const char *prop_name, u32 *array, int count);
- const u32 *fdtdec_locate_array(const void *blob, int node,
- const char *prop_name, int count);
- int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
- int fdtdec_get_child_count(const void *blob, int node);
- int fdtdec_get_config_int(const void *blob, const char *prop_name,
- int default_val);
- int fdtdec_get_config_bool(const void *blob, const char *prop_name);
- char *fdtdec_get_config_string(const void *blob, const char *prop_name);
- int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
- u8 *array, int count);
- const u8 *fdtdec_locate_byte_array(const void *blob, int node,
- const char *prop_name, int count);
- int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
- fdt_addr_t *basep, fdt_size_t *sizep);
- enum fmap_compress_t {
- FMAP_COMPRESS_NONE,
- FMAP_COMPRESS_LZO,
- };
- enum fmap_hash_t {
- FMAP_HASH_NONE,
- FMAP_HASH_SHA1,
- FMAP_HASH_SHA256,
- };
- struct fmap_entry {
- uint32_t offset;
- uint32_t length;
- uint32_t used;
- enum fmap_compress_t compress_algo;
- enum fmap_hash_t hash_algo;
- const uint8_t *hash;
- int hash_size;
- };
- int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
- struct fmap_entry *entry);
- int fdt_get_resource(const void *fdt, int node, const char *property,
- unsigned int index, struct fdt_resource *res);
- int fdt_get_named_resource(const void *fdt, int node, const char *property,
- const char *prop_names, const char *name,
- struct fdt_resource *res);
- int fdtdec_decode_memory_region(const void *blob, int node,
- const char *mem_type, const char *suffix,
- fdt_addr_t *basep, fdt_size_t *sizep);
- enum display_flags {
- DISPLAY_FLAGS_HSYNC_LOW = 1 << 0,
- DISPLAY_FLAGS_HSYNC_HIGH = 1 << 1,
- DISPLAY_FLAGS_VSYNC_LOW = 1 << 2,
- DISPLAY_FLAGS_VSYNC_HIGH = 1 << 3,
-
- DISPLAY_FLAGS_DE_LOW = 1 << 4,
- DISPLAY_FLAGS_DE_HIGH = 1 << 5,
-
- DISPLAY_FLAGS_PIXDATA_POSEDGE = 1 << 6,
-
- DISPLAY_FLAGS_PIXDATA_NEGEDGE = 1 << 7,
- DISPLAY_FLAGS_INTERLACED = 1 << 8,
- DISPLAY_FLAGS_DOUBLESCAN = 1 << 9,
- DISPLAY_FLAGS_DOUBLECLK = 1 << 10,
- };
- struct timing_entry {
- u32 min;
- u32 typ;
- u32 max;
- };
- struct display_timing {
- struct timing_entry pixelclock;
- struct timing_entry hactive;
- struct timing_entry hfront_porch;
- struct timing_entry hback_porch;
- struct timing_entry hsync_len;
- struct timing_entry vactive;
- struct timing_entry vfront_porch;
- struct timing_entry vback_porch;
- struct timing_entry vsync_len;
- enum display_flags flags;
- };
- int fdtdec_decode_display_timing(const void *blob, int node, int index,
- struct display_timing *config);
- int fdtdec_setup_memory_size(void);
- int fdtdec_setup_memory_banksize(void);
- int fdtdec_setup(void);
- #endif
|