zephyr/drivers/hwinfo/hwinfo_litex.c
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00

28 lines
666 B
C

/*
* Copyright (c) 2019 Antmicro <www.antmicro.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT litex_dna0
#include <drivers/hwinfo.h>
#include <soc.h>
#include <string.h>
#include <device.h>
#include <sys/util.h>
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
{
uint32_t volatile *ptr = (uint32_t volatile *)(DT_INST_REG_ADDR(0));
ssize_t end = MIN(length, (DT_INST_REG_SIZE(0) / sizeof(uint32_t)));
for (int i = 0; i < end; i++) {
/* In LiteX even though registers are 32-bit wide, each one
contains meaningful data only in the lowest 8 bits */
buffer[i] = (uint8_t)(ptr[i] & 0xff);
}
return end;
}