int cros_ec_decode_ec_flash(const void *blob, struct fdt_cros_ec *config) { int flash_node, node; node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC); if (node < 0) { debug("Failed to find chrome-ec node'\n"); return -1; } flash_node = fdt_subnode_offset(blob, node, "flash"); if (flash_node < 0) { debug("Failed to find flash node\n"); return -1; } if (fdtdec_read_fmap_entry(blob, flash_node, "flash", &config->flash)) { debug("Failed to decode flash node in chrome-ec'\n"); return -1; } config->flash_erase_value = fdtdec_get_int(blob, flash_node, "erase-value", -1); for (node = fdt_first_subnode(blob, flash_node); node >= 0; node = fdt_next_subnode(blob, node)) { const char *name = fdt_get_name(blob, node, NULL); enum ec_flash_region region; if (0 == strcmp(name, "ro")) { region = EC_FLASH_REGION_RO; } else if (0 == strcmp(name, "rw")) { region = EC_FLASH_REGION_RW; } else if (0 == strcmp(name, "wp-ro")) { region = EC_FLASH_REGION_WP_RO; } else { debug("Unknown EC flash region name '%s'\n", name); return -1; } if (fdtdec_read_fmap_entry(blob, node, "reg", &config->region[region])) { debug("Failed to decode flash region in chrome-ec'\n"); return -1; } } return 0; }
static int get_mrc_entry(struct udevice **devp, struct fmap_entry *entry) { const void *blob = gd->fdt_blob; int node, spi_node, mrc_node; int upto; int ret; /* Find the flash chip within the SPI controller node */ upto = 0; spi_node = fdtdec_next_alias(blob, "spi", COMPAT_INTEL_ICH_SPI, &upto); if (spi_node < 0) return -ENOENT; node = fdt_first_subnode(blob, spi_node); if (node < 0) return -ECHILD; /* Find the place where we put the MRC cache */ mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache"); if (mrc_node < 0) return -EPERM; if (fdtdec_read_fmap_entry(blob, mrc_node, "rm-mrc-cache", entry)) return -EINVAL; if (devp) { debug("getting sf\n"); ret = uclass_get_device_by_of_offset(UCLASS_SPI_FLASH, node, devp); debug("ret = %d\n", ret); if (ret) return ret; } return 0; }