lib: utils/fdt: Change addr and size to uint64_t

The maximum address and size encoded in DT are 64-bit numbers, so we
should use uint64_t for 'addr' and 'size' in fdt_get_node_addr_size().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
Bin Meng 2021-08-05 15:41:13 +08:00 committed by Anup Patel
parent d244f3dbd6
commit 47a47654e8
5 changed files with 17 additions and 16 deletions

View file

@ -43,8 +43,8 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff,
const char *prop, const char *cells_prop,
int index, struct fdt_phandle_args *out_args);
int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr,
unsigned long *size);
int fdt_get_node_addr_size(void *fdt, int node, uint64_t *addr,
uint64_t *size);
int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid);
@ -75,7 +75,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
unsigned long *out_addr, unsigned long *out_size,
u32 *out_first_hartid, u32 *out_hart_count);
int fdt_parse_compat_addr(void *fdt, unsigned long *addr,
int fdt_parse_compat_addr(void *fdt, uint64_t *addr,
const char *compatible);
#endif /* __FDT_HELPER_H__ */

View file

@ -120,7 +120,7 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff,
}
static int fdt_translate_address(void *fdt, uint64_t reg, int parent,
unsigned long *addr)
uint64_t *addr)
{
int i, rlen;
int cell_addr, cell_size;
@ -157,8 +157,7 @@ static int fdt_translate_address(void *fdt, uint64_t reg, int parent,
return 0;
}
int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr,
unsigned long *size)
int fdt_get_node_addr_size(void *fdt, int node, uint64_t *addr, uint64_t *size)
{
int parent, len, i, rc;
int cell_addr, cell_size;
@ -266,7 +265,7 @@ int fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset,
{
int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
if (nodeoffset < 0 || !uart || !fdt)
return SBI_ENODEV;
@ -304,7 +303,7 @@ int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset,
{
int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
if (nodeoffset < 0 || !uart || !fdt)
return SBI_ENODEV;
@ -338,7 +337,7 @@ int fdt_parse_sifive_uart_node(void *fdt, int nodeoffset,
{
int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
if (nodeoffset < 0 || !uart || !fdt)
return SBI_ENODEV;
@ -376,7 +375,7 @@ int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
{
int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
if (nodeoffset < 0 || !uart || !fdt)
return SBI_ENODEV;
@ -436,7 +435,7 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic)
{
int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
if (nodeoffset < 0 || !plic || !fdt)
return SBI_ENODEV;
@ -472,7 +471,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
u32 *out_first_hartid, u32 *out_hart_count)
{
const fdt32_t *val;
unsigned long reg_addr, reg_size;
uint64_t reg_addr, reg_size;
int i, rc, count, cpu_offset, cpu_intc_offset;
u32 phandle, hwirq, hartid, first_hartid, last_hartid;
u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT;
@ -535,7 +534,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
return 0;
}
int fdt_parse_compat_addr(void *fdt, unsigned long *addr,
int fdt_parse_compat_addr(void *fdt, uint64_t *addr,
const char *compatible)
{
int nodeoffset, rc;

View file

@ -71,15 +71,17 @@ static int sifive_gpio_init(void *fdt, int nodeoff, u32 phandle,
{
int rc;
struct sifive_gpio_chip *chip;
uint64_t addr;
if (SIFIVE_GPIO_CHIP_MAX <= sifive_gpio_chip_count)
return SBI_ENOSPC;
chip = &sifive_gpio_chip_array[sifive_gpio_chip_count];
rc = fdt_get_node_addr_size(fdt, nodeoff, &chip->addr, NULL);
rc = fdt_get_node_addr_size(fdt, nodeoff, &addr, NULL);
if (rc)
return rc;
chip->addr = addr;
chip->chip.driver = &fdt_gpio_sifive;
chip->chip.id = phandle;
chip->chip.ngpio = SIFIVE_GPIO_PINS_DEF;

View file

@ -16,7 +16,7 @@ static int sifive_test_reset_init(void *fdt, int nodeoff,
const struct fdt_match *match)
{
int rc;
unsigned long addr;
uint64_t addr;
rc = fdt_get_node_addr_size(fdt, nodeoff, &addr, NULL);
if (rc)

View file

@ -64,7 +64,7 @@ static int openpiton_early_init(bool cold_boot)
void *fdt;
struct platform_uart_data uart_data;
struct plic_data plic_data;
unsigned long clint_addr;
uint64_t clint_addr;
int rc;
if (!cold_boot)