Merge branch '2020-06-15-misc-bugfixes'
[oweals/u-boot.git] / cmd / cros_ec.c
index fb369a4e329a94978dd6a1871e8c22d62a31f85d..ce1f59a740c19cd46ec0d76fa0bc02d5f88f894e 100644 (file)
@@ -10,6 +10,8 @@
 #include <command.h>
 #include <cros_ec.h>
 #include <dm.h>
+#include <flash.h>
+#include <log.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 
@@ -23,11 +25,11 @@ static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"};
  * @param argv List of remaining parameters
  * @return flash region (EC_FLASH_REGION_...) or -1 on error
  */
-static int cros_ec_decode_region(int argc, char * const argv[])
+static int cros_ec_decode_region(int argc, char *const argv[])
 {
        if (argc > 0) {
                if (0 == strcmp(*argv, "rw"))
-                       return EC_FLASH_REGION_RW;
+                       return EC_FLASH_REGION_ACTIVE;
                else if (0 == strcmp(*argv, "ro"))
                        return EC_FLASH_REGION_RO;
 
@@ -50,7 +52,7 @@ static int cros_ec_decode_region(int argc, char * const argv[])
  *     (negative EC_RES_...)
  */
 static int do_read_write(struct udevice *dev, int is_write, int argc,
-                        char * const argv[])
+                        char *const argv[])
 {
        uint32_t offset, size = -1U, region_size;
        unsigned long addr;
@@ -92,7 +94,8 @@ static int do_read_write(struct udevice *dev, int is_write, int argc,
        return 0;
 }
 
-static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_cros_ec(struct cmd_tbl *cmdtp, int flag, int argc,
+                     char *const argv[])
 {
        struct udevice *dev;
        const char *cmd;
@@ -137,7 +140,6 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                }
                printf("rows     = %u\n", info.rows);
                printf("cols     = %u\n", info.cols);
-               printf("switches = %#x\n", info.switches);
        } else if (0 == strcmp("curimage", cmd)) {
                enum ec_current_image image;
 
@@ -150,7 +152,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                struct ec_response_vboot_hash hash;
                int i;
 
-               if (cros_ec_read_hash(dev, &hash)) {
+               if (cros_ec_read_hash(dev, EC_VBOOT_HASH_OFFSET_ACTIVE, &hash)) {
                        debug("%s: Could not read KBC hash\n", __func__);
                        return 1;
                }
@@ -177,7 +179,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        region = cros_ec_decode_region(argc - 2, argv + 2);
                        if (region == EC_FLASH_REGION_RO)
                                cmd = EC_REBOOT_JUMP_RO;
-                       else if (region == EC_FLASH_REGION_RW)
+                       else if (region == EC_FLASH_REGION_ACTIVE)
                                cmd = EC_REBOOT_JUMP_RW;
                        else
                                return CMD_RET_USAGE;