diff options
Diffstat (limited to 'arch/arm/include/asm/arch-meson')
| -rw-r--r-- | arch/arm/include/asm/arch-meson/boot.h | 14 | ||||
| -rw-r--r-- | arch/arm/include/asm/arch-meson/sm.h | 48 |
2 files changed, 61 insertions, 1 deletions
diff --git a/arch/arm/include/asm/arch-meson/boot.h b/arch/arm/include/asm/arch-meson/boot.h index c67d12d06c9..a11dfde719e 100644 --- a/arch/arm/include/asm/arch-meson/boot.h +++ b/arch/arm/include/asm/arch-meson/boot.h @@ -21,4 +21,18 @@ int meson_get_boot_device(void); int meson_get_soc_rev(char *buff, size_t buff_len); +/** + * meson_get_socinfo - retrieve cpu_id of the Amlogic SoC + * + * The value in the following format is read from register: + * +-----------+------------+------------+------------+ + * | family_id | package_id | chip_rev | layout_rev | + * +-----------+------------+------------+------------+ + * | 31 24 | 23 16 | 15 8 | 7 0 | + * +-----------+------------+------------+------------+ + * + * Return: 4 bytes value of cpu_id on success or 0 on failure. + */ +u32 meson_get_socinfo(void); + #endif /* __MESON_BOOT_H__ */ diff --git a/arch/arm/include/asm/arch-meson/sm.h b/arch/arm/include/asm/arch-meson/sm.h index 4b1d564bc48..4d614955fc2 100644 --- a/arch/arm/include/asm/arch-meson/sm.h +++ b/arch/arm/include/asm/arch-meson/sm.h @@ -6,6 +6,8 @@ #ifndef __MESON_SM_H__ #define __MESON_SM_H__ +#include <asm/types.h> + /** * meson_sm_read_efuse - read efuse memory into buffer * @@ -27,16 +29,60 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size); ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size); #define SM_SERIAL_SIZE 12 +#define MESON_CPU_ID_SZ 4 +#define MESON_CHIP_ID_SZ 16 + +/** + * union meson_cpu_id - Amlogic cpu_id. + * @raw: buffer to hold the cpu_id value as sequential bytes. + * @val: cpu_id represented as 32 bit value. + */ +union meson_cpu_id { + u8 raw[MESON_CPU_ID_SZ]; + u32 val; +}; + +/** + * struct meson_sm_chip_id - Amlogic chip_id. + * @cpu_id: cpu_id value, which is distinct from socinfo in that the order of + * PACK & MINOR bytes are swapped according to Amlogic chip_id format. + * @serial: 12 byte unique SoC number, identifying particular die, read + * usually from efuse OTP storage. Serial comes in little-endian + * order. + */ +struct meson_sm_chip_id { + union meson_cpu_id cpu_id; + u8 serial[SM_SERIAL_SIZE]; +}; /** - * meson_sm_get_serial - read chip unique id into buffer + * meson_sm_get_serial - read chip unique serial (OTP data) into buffer * * @buffer: pointer to buffer * @size: buffer size. + * + * Serial is returned in big-endian order. + * * @return: zero on success or -errno on failure */ int meson_sm_get_serial(void *buffer, size_t size); +/** + * meson_sm_get_chip_id - read Amlogic chip_id + * + * @chip_id: pointer to buffer capable to hold the struct meson_sm_chip_id + * + * Amlogic SoCs support 2 versions of chip_id. Function requests the newest + * one (v2), but if chip_id v2 is not supported, then secure monitor returns + * v1. All differences between v1 and v2 versions are handled by this function + * and chip_id is returned in unified format. + * + * chip_id contains serial, which is returned here in little-endian order. + * + * @return: 0 on success or -errno on failure + */ +int meson_sm_get_chip_id(struct meson_sm_chip_id *chip_id); + enum { REBOOT_REASON_COLD = 0, REBOOT_REASON_NORMAL = 1, |
