1 /* 2 * Copyright (c) 2019 Alexander Wachter 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <soc.h> 8 #include <zephyr/drivers/hwinfo.h> 9 #include <string.h> 10 #include <zephyr/sys/byteorder.h> 11 12 struct imxrt_uid { 13 uint32_t id[2]; 14 }; 15 z_impl_hwinfo_get_device_id(uint8_t * buffer,size_t length)16ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) 17 { 18 struct imxrt_uid dev_id; 19 20 #ifdef CONFIG_SOC_SERIES_IMX_RT11XX 21 dev_id.id[0] = sys_cpu_to_be32(OCOTP->FUSEN[17].FUSE); 22 dev_id.id[1] = sys_cpu_to_be32(OCOTP->FUSEN[16].FUSE); 23 #else 24 dev_id.id[0] = sys_cpu_to_be32(OCOTP->CFG2); 25 dev_id.id[1] = sys_cpu_to_be32(OCOTP->CFG1); 26 #endif 27 28 if (length > sizeof(dev_id.id)) { 29 length = sizeof(dev_id.id); 30 } 31 32 memcpy(buffer, dev_id.id, length); 33 34 return length; 35 } 36