diff options
-rw-r--r-- | chip/lm4/registers.h | 2 | ||||
-rw-r--r-- | chip/lm4/system.c | 33 | ||||
-rw-r--r-- | chip/stm32l/system.c | 16 | ||||
-rw-r--r-- | common/system_common.c | 14 | ||||
-rw-r--r-- | include/lpc_commands.h | 10 | ||||
-rw-r--r-- | include/system.h | 5 | ||||
-rw-r--r-- | util/ectool.c | 21 |
7 files changed, 101 insertions, 0 deletions
diff --git a/chip/lm4/registers.h b/chip/lm4/registers.h index 6f3843afd2..a572e763ed 100644 --- a/chip/lm4/registers.h +++ b/chip/lm4/registers.h @@ -185,6 +185,8 @@ static inline int lm4_fan_addr(int ch, int offset) #define LM4_FLASH_FMPPE2 LM4REG(0x400fe408) #define LM4_FLASH_FMPPE3 LM4REG(0x400fe40c) +#define LM4_SYSTEM_DID0 LM4REG(0x400fe000) +#define LM4_SYSTEM_DID1 LM4REG(0x400fe004) #define LM4_SYSTEM_RIS LM4REG(0x400fe050) #define LM4_SYSTEM_MISC LM4REG(0x400fe058) #define LM4_SYSTEM_RESC LM4REG(0x400fe05c) diff --git a/chip/lm4/system.c b/chip/lm4/system.c index 4915bb242f..56d0525c0a 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -182,3 +182,36 @@ uint32_t system_get_scratchpad(void) { return LM4_HIBERNATE_HIBDATA; } + + +const char *system_get_chip_vendor(void) +{ + return "ti"; +} + +const char *system_get_chip_name(void) +{ + if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10e20000) { + return "lm4fsxhh5bb"; + } else if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10e30000) { + return "lm4fs232h5bb"; + } else if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10e40000) { + return "lm4fs99h5bb"; + } else if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10e60000) { + return "lm4fs1ah5bb"; + } else { + return ""; + } +} + +const char *system_get_chip_revision(void) +{ + static char rev[3]; + + /* Extract the major[15:8] and minor[7:0] revisions. */ + rev[0] = 'A' + ((LM4_SYSTEM_DID0 >> 8) & 0xff); + rev[1] = '0' + (LM4_SYSTEM_DID0 & 0xff); + rev[2] = 0; + + return rev; +} diff --git a/chip/stm32l/system.c b/chip/stm32l/system.c index 649950abc6..aaa05253bd 100644 --- a/chip/stm32l/system.c +++ b/chip/stm32l/system.c @@ -111,3 +111,19 @@ uint32_t system_get_scratchpad(void) { return STM32L_RTC_BACKUP(0); } + + +const char *system_get_chip_vendor(void) +{ + return "stm"; +} + +const char *system_get_chip_name(void) +{ + return "stm32l151r8"; +} + +const char *system_get_chip_revision(void) +{ + return ""; +} diff --git a/common/system_common.c b/common/system_common.c index dfb571eb7c..eae6d51424 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -409,6 +409,20 @@ static enum lpc_status host_command_build_info(uint8_t *data) DECLARE_HOST_COMMAND(EC_LPC_COMMAND_GET_BUILD_INFO, host_command_build_info); +static enum lpc_status host_command_get_chip_info(uint8_t *data) +{ + struct lpc_response_get_chip_info *r = + (struct lpc_response_get_chip_info *)data; + + strzcpy(r->vendor, system_get_chip_vendor(), sizeof(r->vendor)); + strzcpy(r->name, system_get_chip_name(), sizeof(r->name)); + strzcpy(r->revision, system_get_chip_revision(), sizeof(r->revision)); + + return EC_LPC_RESULT_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_LPC_COMMAND_GET_CHIP_INFO, host_command_get_chip_info); + + #ifdef CONFIG_REBOOT_EC static void clean_busy_bits(void) { #ifdef CONFIG_LPC diff --git a/include/lpc_commands.h b/include/lpc_commands.h index 46212ff73e..aa35458953 100644 --- a/include/lpc_commands.h +++ b/include/lpc_commands.h @@ -194,6 +194,16 @@ struct lpc_response_get_build_info { } __attribute__ ((packed)); +/* Get chip info */ +#define EC_LPC_COMMAND_GET_CHIP_INFO 0x05 +struct lpc_response_get_chip_info { + /* Null-terminated strings */ + char vendor[32]; + char name[32]; + char revision[32]; /* Mask version */ +} __attribute__ ((packed)); + + /*****************************************************************************/ /* Flash commands */ diff --git a/include/system.h b/include/system.h index 61ec220974..799d324998 100644 --- a/include/system.h +++ b/include/system.h @@ -107,6 +107,11 @@ int system_set_scratchpad(uint32_t value); /* Returns the current scratchpad register value. */ uint32_t system_get_scratchpad(void); +/* Returns the chip info */ +const char *system_get_chip_vendor(void); +const char *system_get_chip_name(void); +const char *system_get_chip_revision(void); + /* TODO: request sleep. How do we want to handle transitioning * to/from low-power states? */ diff --git a/util/ectool.c b/util/ectool.c index 749eee2cb9..50f201b956 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -21,6 +21,8 @@ const char help_str[] = "Commands:\n" " battery\n" " Prints battery info\n" + " chipinfo\n" + " Prints chip info\n" " eventclear <mask>\n" " Clears EC host events flags where mask has bits set\n" " eventget\n" @@ -1225,6 +1227,24 @@ int cmd_battery(int argc, char *argv[]) return 0; } +int cmd_chipinfo(int argc, char *argv[]) +{ + struct lpc_response_get_chip_info info; + int rv; + + printf("Chip info:\n"); + + rv = ec_command(EC_LPC_COMMAND_GET_CHIP_INFO, + NULL, 0, &info, sizeof(info)); + if (rv) + return rv; + printf(" vendor: %s\n", info.vendor); + printf(" name: %s\n", info.name); + printf(" revision: %s\n", info.revision); + + return 0; +} + struct command { const char *name; int (*handler)(int argc, char *argv[]); @@ -1234,6 +1254,7 @@ struct command { const struct command commands[] = { {"autofanctrl", cmd_thermal_auto_fan_ctrl}, {"battery", cmd_battery}, + {"chipinfo", cmd_chipinfo}, {"eventclear", cmd_host_event_clear}, {"eventget", cmd_host_event_get_raw}, {"eventgetscimask", cmd_host_event_get_sci_mask}, |