debug("%s: Could not access LDO%d\n", __func__, index);
return ret;
}
+ } else if (!strcmp("sku", cmd)) {
+ ret = cros_ec_get_sku_id(dev);
+
+ if (ret >= 0) {
+ printf("%d\n", ret);
+ ret = 0;
+ } else {
+ printf("Error: %d\n", ret);
+ }
} else {
return CMD_RET_USAGE;
}
"crosec write <ro|rw> <addr> [<size>] Write EC image\n"
"crosec vbnvcontext [hexstring] Read [write] VbNvContext from EC\n"
"crosec ldo <idx> [<state>] Switch/Read LDO state\n"
+ "crosec sku Read board SKU ID\n"
"crosec test run tests on cros_ec\n"
"crosec version Read CROS-EC version"
);
return 0;
}
+int cros_ec_get_sku_id(struct udevice *dev)
+{
+ struct ec_sku_id_info *r;
+ int ret;
+
+ ret = ec_command_inptr(dev, EC_CMD_GET_SKU_ID, 0, NULL, 0,
+ (uint8_t **)&r, sizeof(*r));
+ if (ret != sizeof(*r))
+ return -ret;
+
+ return r->sku_id;
+}
+
int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size)
{
struct ec_params_vbnvcontext p;
len = sizeof(*resp);
break;
}
+ case EC_CMD_GET_SKU_ID: {
+ struct ec_sku_id_info *resp = resp_data;
+
+ resp->sku_id = 1234;
+ len = sizeof(*resp);
+ break;
+ }
default:
printf(" ** Unknown EC command %#02x\n", req_hdr->command);
return -1;
int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
uint32_t *offset, uint32_t *size);
+/**
+ * cros_ec_get_sku_id() - Read the SKU ID
+ *
+ * @dev: CROS-EC device
+ * return SKU ID, or -ve on error
+ */
+int cros_ec_get_sku_id(struct udevice *dev);
+
/**
* Read/write non-volatile data from/to a CROS-EC device.
*
return 0;
}
DM_TEST(dm_test_cros_ec_hello, UT_TESTF_SCAN_FDT);
+
+static int dm_test_cros_ec_sku_id(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev));
+ ut_asserteq(1234, cros_ec_get_sku_id(dev));
+
+ /* try the command */
+ console_record_reset();
+ ut_assertok(run_command("crosec sku", 0));
+ ut_assert_nextline("1234");
+ ut_assert_console_end();
+
+ return 0;
+}
+DM_TEST(dm_test_cros_ec_sku_id, UT_TESTF_SCAN_FDT);