]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/misc/cros_ec.c
cros_ec: Drop old EC version support from EC driver
[karo-tx-uboot.git] / drivers / misc / cros_ec.c
index 301e8ebbf57babe28ff1de3b218ceab7b11c0024..f95bfe73900f9a418061bcadd0eef2fbc918402b 100644 (file)
@@ -132,10 +132,6 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
        uint8_t *din;
        int len;
 
-       if (cmd_version != 0 && !dev->cmd_version_is_supported) {
-               debug("%s: Command version >0 unsupported\n", __func__);
-               return -1;
-       }
        len = send_command(dev, cmd, cmd_version, dout, dout_len,
                                &din, din_len);
 
@@ -510,14 +506,9 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
                /* It appears to understand new version commands */
                dev->cmd_version_is_supported = 1;
        } else {
-               dev->cmd_version_is_supported = 0;
-               if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req,
-                             sizeof(req), (uint8_t **)&resp,
-                             sizeof(*resp)) < 0) {
-                       debug("%s: Failed both old and new command style\n",
-                               __func__);
-                       return -1;
-               }
+               printf("%s: ERROR: old EC interface not supported\n",
+                      __func__);
+               return -1;
        }
 
        return 0;
@@ -958,6 +949,56 @@ int cros_ec_decode_region(int argc, char * const argv[])
        return -1;
 }
 
+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;
+}
+
 /**
  * Perform a flash read or write command
  *