mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 22:03:15 +00:00
ea3ee193cb
Compiling with gcc 13 results in an error:
drivers/axi/axi-emul-uclass.c:16:5: warning: conflicting types for
‘axi_sandbox_get_emul’ due to enum/integer mismatch; have
‘int(struct udevice *, ulong, enum axi_size_t, struct udevice **)’
{aka ‘int(struct udevice *, long unsigned int, enum axi_size_t,
struct udevice **)’} [-Wenum-int-mismatch]
16 | int axi_sandbox_get_emul(struct udevice *bus, ulong address,
| ^~~~~~~~~~~~~~~~~~~~
In file included from drivers/axi/axi-emul-uclass.c:14:
./arch/sandbox/include/asm/axi.h:48:5: note: previous declaration of
‘axi_sandbox_get_emul’ with type ‘int(struct udevice *, ulong, uint,
struct udevice **)’ {aka ‘int(struct udevice *, long unsigned int,
unsigned int, struct udevice **)’}
48 | int axi_sandbox_get_emul(struct udevice *bus, ulong address, uint length,
| ^~~~~~~~~~~~~~~~~~~~
Adjust the header definition to match the implementation.
Define the size parameter as constant.
Fixes: 9a8bcabd8a
("axi: Add AXI sandbox driver and simple emulator")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2018
|
|
* Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
|
*/
|
|
|
|
#define LOG_CATEGORY UCLASS_AXI_EMUL
|
|
|
|
#include <common.h>
|
|
#include <axi.h>
|
|
#include <dm.h>
|
|
#include <log.h>
|
|
#include <dm/device-internal.h>
|
|
#include <asm/axi.h>
|
|
|
|
int axi_sandbox_get_emul(struct udevice *bus, ulong address,
|
|
const enum axi_size_t size, struct udevice **emulp)
|
|
{
|
|
struct udevice *dev;
|
|
u32 reg[2];
|
|
uint offset;
|
|
|
|
switch (size) {
|
|
case AXI_SIZE_8:
|
|
offset = 1;
|
|
break;
|
|
case AXI_SIZE_16:
|
|
offset = 2;
|
|
break;
|
|
case AXI_SIZE_32:
|
|
offset = 4;
|
|
break;
|
|
default:
|
|
debug("%s: Unknown AXI transfer size '%d'", bus->name, size);
|
|
offset = 0;
|
|
}
|
|
|
|
/*
|
|
* Note: device_find_* don't activate the devices; they're activated
|
|
* as-needed below.
|
|
*/
|
|
for (device_find_first_child(bus, &dev);
|
|
dev;
|
|
device_find_next_child(&dev)) {
|
|
int ret;
|
|
|
|
ret = dev_read_u32_array(dev, "reg", reg, ARRAY_SIZE(reg));
|
|
if (ret) {
|
|
debug("%s: Could not read 'reg' property of %s\n",
|
|
bus->name, dev->name);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Does the transfer's address fall into this device's address
|
|
* space?
|
|
*/
|
|
if (address >= reg[0] && address <= reg[0] + reg[1] - offset) {
|
|
/* If yes, activate it... */
|
|
if (device_probe(dev)) {
|
|
debug("%s: Could not activate %s\n",
|
|
bus->name, dev->name);
|
|
return -ENODEV;
|
|
}
|
|
|
|
/* ...and return it */
|
|
*emulp = dev;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
return -ENODEV;
|
|
}
|
|
|
|
int axi_get_store(struct udevice *dev, u8 **storep)
|
|
{
|
|
struct axi_emul_ops *ops = axi_emul_get_ops(dev);
|
|
|
|
if (!ops->get_store)
|
|
return -ENOSYS;
|
|
|
|
return ops->get_store(dev, storep);
|
|
}
|
|
|
|
UCLASS_DRIVER(axi_emul) = {
|
|
.id = UCLASS_AXI_EMUL,
|
|
.name = "axi_emul",
|
|
};
|