int mkbp_tps65090_init(void) { const void *blob = gd->fdt_blob; int node, parent; node = fdtdec_next_compatible(blob, 0, COMPAT_TI_TPS65090); if (node < 0) { debug("%s: Node not found\n", __func__); return -ENOENT; } parent = fdt_parent_offset(blob, node); if (parent < 0) { debug("%s: Cannot find node parent\n", __func__); return -1; } if (fdt_node_check_compatible(blob, parent, fdtdec_get_compatible(COMPAT_GOOGLE_MKBP))) { debug("%s: TPS65090 not behind MKBP\n", __func__); return -ENOENT; } mkbp_dev = board_get_mkbp_dev(); if (!mkbp_dev) { debug("%s: no mkbp device: cannot init tps65090\n", __func__); return -1; } debug("%s: accessing tps65090 through MKBP\n", __func__); return 0; }
static int process_nodes(const void *fdt, int nodes[], unsigned int count) { unsigned int i; for (i = 0; i < count; i++) { enum fdt_compat_id id; int err; if (!fdtdec_get_is_enabled(fdt, nodes[i])) continue; id = fdtdec_lookup(fdt, nodes[i]); switch (id) { case COMPAT_NVIDIA_TEGRA124_XUSB_PADCTL: break; default: error("tegra-xusb-padctl: unsupported compatible: %s", fdtdec_get_compatible(id)); continue; } padctl->num_lanes = ARRAY_SIZE(tegra124_lanes); padctl->lanes = tegra124_lanes; padctl->num_functions = ARRAY_SIZE(tegra124_functions); padctl->functions = tegra124_functions; err = tegra_xusb_padctl_parse_dt(padctl, fdt, nodes[i]); if (err < 0) { error("tegra-xusb-padctl: failed to parse DT: %d", err); continue; } /* deassert XUSB padctl reset */ reset_set_enable(PERIPH_ID_XUSB_PADCTL, 0); err = tegra_xusb_padctl_config_apply(padctl, &padctl->config); if (err < 0) { error("tegra-xusb-padctl: failed to apply pinmux: %d", err); continue; } /* only a single instance is supported */ break; } return 0; }
/* * Make a test fdt * * @param fdt Device tree pointer * @param size Size of device tree blob * @param aliases Specifies alias assignments. Format is a list of items * separated by space. Items are #a where * # is the alias number * a is the node to point to * @param nodes Specifies nodes to generate (a=0, b=1), upper case * means to create a disabled node */ static int make_fdt(void *fdt, int size, const char *aliases, const char *nodes) { char name[20], value[20]; const char *s; int fd; CHECK(fdt_create(fdt, size)); CHECK(fdt_finish_reservemap(fdt)); CHECK(fdt_begin_node(fdt, "")); CHECK(fdt_begin_node(fdt, "aliases")); for (s = aliases; *s;) { sprintf(name, "i2c%c", *s); sprintf(value, "/i2c%d@0", s[1] - 'a'); CHECK(fdt_property_string(fdt, name, value)); s += 2 + (s[2] != '\0'); } CHECK(fdt_end_node(fdt)); for (s = nodes; *s; s++) { sprintf(value, "i2c%d@0", (*s & 0xdf) - 'A'); CHECK(fdt_begin_node(fdt, value)); CHECK(fdt_property_string(fdt, "compatible", fdtdec_get_compatible(COMPAT_UNKNOWN))); if (*s <= 'Z') CHECK(fdt_property_string(fdt, "status", "disabled")); CHECK(fdt_end_node(fdt)); } CHECK(fdt_end_node(fdt)); CHECK(fdt_finish(fdt)); CHECK(fdt_pack(fdt)); #if defined(DEBUG) && defined(CONFIG_SANDBOX) fd = os_open("/tmp/fdtdec-text.dtb", OS_O_CREAT | OS_O_WRONLY); if (fd == -1) { printf("Could not open .dtb file to write\n"); return -1; } os_write(fd, fdt, size); os_close(fd); #endif return 0; }