1 /*
2  * Copyright (c) 2020 ATL Electronics
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #define DT_DRV_COMPAT cypress_psoc6_uid
8 
9 #include <zephyr/device.h>
10 #include <zephyr/drivers/hwinfo.h>
11 #include <zephyr/init.h>
12 #include <soc.h>
13 #include <string.h>
14 
15 #include <cy_syslib.h>
16 
z_impl_hwinfo_get_device_id(uint8_t * buffer,size_t length)17 ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
18 {
19 	uint8_t *uid_addr = (uint8_t *) DT_INST_REG_ADDR(0);
20 
21 	if (buffer == NULL) {
22 		return 0;
23 	}
24 
25 	if (length > DT_INST_REG_SIZE(0)) {
26 		length = DT_INST_REG_SIZE(0);
27 	}
28 
29 	memcpy(buffer, uid_addr, length);
30 
31 	return length;
32 }
33