diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-11-09 19:55:28 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-18 04:53:21 +0000 |
commit | b92073532056f5c11d2369177ac0cc9b22b38295 (patch) | |
tree | 826ca327bdf8e11c73633bde0c734a2e8c6ff364 | |
parent | 1cfb5293ebbc854ce997d798cc55158031ccba6b (diff) | |
download | chrome-ec-b92073532056f5c11d2369177ac0cc9b22b38295.tar.gz |
Revert "Add OTP support"
This reverts commit 1b25735b732e7766aceb3f060e4ca205aba6d358.
BUG=b:200823466
TEST=make buildall -j
Change-Id: I2e29902d7026c63f23871af0141a3ee7d319852d
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273456
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r-- | chip/g/usb.c | 2 | ||||
-rw-r--r-- | common/flash.c | 40 | ||||
-rw-r--r-- | common/system.c | 32 | ||||
-rw-r--r-- | include/config.h | 10 | ||||
-rw-r--r-- | include/flash.h | 7 | ||||
-rw-r--r-- | include/otp.h | 32 | ||||
-rw-r--r-- | include/system.h | 7 | ||||
-rw-r--r-- | include/usb_descriptor.h | 3 |
8 files changed, 32 insertions, 101 deletions
diff --git a/chip/g/usb.c b/chip/g/usb.c index 377eb8a470..d12566e701 100644 --- a/chip/g/usb.c +++ b/chip/g/usb.c @@ -1531,7 +1531,7 @@ static int usb_set_serial(const char *serialno) return EC_ERROR_INVAL; /* Convert into unicode usb string desc. */ - for (i = 0; i < CONFIG_SERIALNO_LEN; i++) { + for (i = 0; i < USB_STRING_LEN; i++) { sd->_data[i] = serialno[i]; if (serialno[i] == 0) break; diff --git a/common/flash.c b/common/flash.c index f2ab3dcd27..ae08fdbd5f 100644 --- a/common/flash.c +++ b/common/flash.c @@ -11,7 +11,6 @@ #include "gpio.h" #include "hooks.h" #include "host_command.h" -#include "otp.h" #include "rwsig.h" #include "shared_mem.h" #include "system.h" @@ -41,6 +40,7 @@ /* NOTE: It's not expected that RO and RW will support * differing PSTATE versions. */ #define PERSIST_STATE_VERSION 3 /* Expected persist_state.version */ +#define SERIALNO_MAX 28 /* Flags for persist_state.flags */ /* Protect persist state and RO firmware at boot */ @@ -53,11 +53,7 @@ struct persist_state { uint8_t flags; /* Lock flags (PERSIST_FLAG_*) */ uint8_t valid_fields; /* Flags for valid data. */ uint8_t reserved; /* Reserved; set 0 */ -#ifdef CONFIG_SERIALNO_LEN - uint8_t serialno[CONFIG_SERIALNO_LEN]; /* Serial number. */ -#else - uint8_t padding[4 % CONFIG_FLASH_WRITE_SIZE]; -#endif + uint8_t serialno[SERIALNO_MAX]; /* Serial number. */ }; /* written with flash_physical_write, need to respect alignment constraints */ #ifndef CHIP_FAMILY_STM32L /* STM32L1xx is somewhat lying to us */ @@ -226,11 +222,10 @@ static uint32_t flash_read_pstate(void) } } -#ifdef CONFIG_SERIALNO_LEN /** * Read and return persistent serial number. */ -const char *flash_read_pstate_serial(void) +static const char *flash_read_pstate_serial(void) { const struct persist_state *pstate = (const struct persist_state *) @@ -241,9 +236,8 @@ const char *flash_read_pstate_serial(void) return (const char *)(pstate->serialno); } - return NULL; + return 0; } -#endif /** * Write persistent state after erasing. @@ -324,14 +318,13 @@ static int flash_write_pstate(uint32_t flags) return flash_write_pstate_data(&newpstate); } -#ifdef CONFIG_SERIALNO_LEN /** * Write persistent serial number to pstate, erasing if necessary. * * @param serialno New iascii serial number to set in pstate. * @return EC_SUCCESS, or nonzero if error. */ -int flash_write_pstate_serial(const char *serialno) +static int flash_write_pstate_serial(const char *serialno) { int i; struct persist_state newpstate; @@ -348,18 +341,17 @@ int flash_write_pstate_serial(const char *serialno) validate_pstate_struct(&newpstate); /* Copy in serialno. */ - for (i = 0; i < CONFIG_SERIALNO_LEN - 1; i++) { + for (i = 0; i < SERIALNO_MAX - 1; i++) { newpstate.serialno[i] = serialno[i]; if (serialno[i] == 0) break; } - for (; i < CONFIG_SERIALNO_LEN; i++) + for (; i < SERIALNO_MAX; i++) newpstate.serialno[i] = 0; newpstate.valid_fields |= PSTATE_VALID_SERIALNO; return flash_write_pstate_data(&newpstate); } -#endif @@ -547,6 +539,24 @@ int flash_erase(int offset, int size) return flash_physical_erase(offset, size); } +const char *flash_read_serial(void) +{ +#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK) + return flash_read_pstate_serial(); +#else + return 0; +#endif +} + +int flash_write_serial(const char *serialno) +{ +#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK) + return flash_write_pstate_serial(serialno); +#else + return EC_ERROR_UNIMPLEMENTED; +#endif +} + int flash_protect_at_boot(uint32_t new_flags) { #ifdef CONFIG_FLASH_PSTATE diff --git a/common/system.c b/common/system.c index a636813e2b..0aba47d1fb 100644 --- a/common/system.c +++ b/common/system.c @@ -15,7 +15,6 @@ #include "host_command.h" #include "i2c.h" #include "lpc.h" -#include "otp.h" #include "rwsig.h" #include "spi_flash.h" #ifdef CONFIG_MPU @@ -1292,34 +1291,3 @@ int system_can_boot_ap(void) /* For fixed AC system */ return 1; } - -#ifdef CONFIG_SERIALNO_LEN -/* By default, read serial number from flash, can be overridden. */ -#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK) -__attribute__((weak)) -const char *board_read_serial(void) -{ - return flash_read_pstate_serial(); -} -#elif defined(CONFIG_OTP) -__attribute__((weak)) -const char *board_read_serial(void) -{ - return otp_read_serial(); -} -#endif - -#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK) -__attribute__((weak)) -int board_write_serial(const char *serialno) -{ - return flash_write_pstate_serial(serialno); -} -#elif defined(CONFIG_OTP) -__attribute__((weak)) -int board_write_serial(const char *serialno) -{ - return otp_write_serial(serialno); -} -#endif -#endif /* CONFIG_SERIALNO_LEN */ diff --git a/include/config.h b/include/config.h index 98331cb453..128c0dc88b 100644 --- a/include/config.h +++ b/include/config.h @@ -2658,9 +2658,6 @@ /* Support one-wire interface */ #undef CONFIG_ONEWIRE -/* Support One Time Protection structure */ -#undef CONFIG_OTP - /* Support PECI interface to x86 processor */ #undef CONFIG_PECI @@ -2924,9 +2921,6 @@ #undef CONFIG_RW_SIG_ADDR #undef CONFIG_RW_SIG_SIZE -/* Size of the serial number if needed */ -#undef CONFIG_SERIALNO_LEN - /****************************************************************************/ /* Shared objects library. */ @@ -4603,10 +4597,6 @@ #error "CONFIG_AUX_TIMER_PERIOD_MS must be at least 2x HOOK_TICK_INTERVAL_MS" #endif -#ifdef CONFIG_USB_SERIALNO -#define CONFIG_SERIALNO_LEN 28 -#endif - #ifndef CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ #define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ \ CONFIG_EC_MAX_SENSOR_FREQ_DEFAULT_MILLIHZ diff --git a/include/flash.h b/include/flash.h index e2c572d38f..0566c5914a 100644 --- a/include/flash.h +++ b/include/flash.h @@ -320,18 +320,17 @@ int flash_set_protect(uint32_t mask, uint32_t flags); * Get the serial number from flash. * * @return char * ascii serial number string. - * NULL if error. */ -const char *flash_read_pstate_serial(void); +const char *flash_read_serial(void); /** * Set the serial number in flash. * - * @param serialno ascii serial number string. + * @param serialno ascii serial number string < 30 char. * * @return success status. */ -int flash_write_pstate_serial(const char *serialno); +int flash_write_serial(const char *serialno); /** * Lock or unlock HW necessary for mapped storage read. diff --git a/include/otp.h b/include/otp.h deleted file mode 100644 index 7851411202..0000000000 --- a/include/otp.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* OTP memory module for Chrome EC */ - -#ifndef __CROS_EC_OTP_H -#define __CROS_EC_OTP_H - -/* - * OTP: One Time Programable memory is used for storing persistent data. - */ - -/** - * Set the serial number in OTP memory. - * - * @param serialno ascii serial number string. - * - * @return success status. - */ -int otp_write_serial(const char *serialno); - -/** - * Get the serial number from flash. - * - * @return char * ascii serial number string. - * NULL if error. - */ -const char *otp_read_serial(void); - -#endif /* __CROS_EC_OTP_H */ diff --git a/include/system.h b/include/system.h index 98b580e19a..bf9e19130a 100644 --- a/include/system.h +++ b/include/system.h @@ -270,15 +270,10 @@ int system_get_chip_unique_id(uint8_t **id); /** * Optional board-level callback functions to read a unique serial number per - * chip. Default implementation reads from flash/otp (flash/otp_read_serial). + * chip. Default implementation reads from flash (flash_read_serial). */ const char *board_read_serial(void) __attribute__((weak)); -/** - * Optional board-level callback functions to write a unique serial number per - * chip. Default implementation reads from flash/otp (flash/otp_write_serial). - */ -int board_write_serial(const char *serial) __attribute__((weak)); /* * Common bbram entries. Chips don't necessarily need to implement * all of these, error will be returned from system_get/set_bbram if diff --git a/include/usb_descriptor.h b/include/usb_descriptor.h index 153c648085..06dfdbc0ed 100644 --- a/include/usb_descriptor.h +++ b/include/usb_descriptor.h @@ -312,10 +312,11 @@ struct usb_setup_packet { #ifdef CONFIG_USB_SERIALNO /* String Descriptor for USB, for editable strings. */ +#define USB_STRING_LEN 28 struct usb_string_desc { uint8_t _len; uint8_t _type; - wchar_t _data[CONFIG_SERIALNO_LEN]; + wchar_t _data[USB_STRING_LEN]; }; #define USB_WR_STRING_DESC(str) \ (&(struct usb_string_desc) { \ |