
From: Simon Glass <sjg@chromium.org> Move pci_map_physmem(), pci_unmap_physmem(), and sandbox_set_enable_pci_map() from u-boot-sandbox.h to a new file sandbox_pci.h to simplify dependencies. Fix the header order in the PCI emul file while we are here. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/sandbox/cpu/mem.c | 1 + arch/sandbox/include/asm/sandbox_pci.h | 61 +++++++++++++++++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 50 +------------------ drivers/pci/pci-emul-uclass.c | 3 +- test/dm/pci.c | 1 + 5 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 arch/sandbox/include/asm/sandbox_pci.h diff --git a/arch/sandbox/cpu/mem.c b/arch/sandbox/cpu/mem.c index 4e9b629e3aa..b5c7ea6493d 100644 --- a/arch/sandbox/cpu/mem.c +++ b/arch/sandbox/cpu/mem.c @@ -13,6 +13,7 @@ #include <os.h> #include <asm/global_data.h> #include <asm/io.h> +#include <asm/sandbox_pci.h> #include <asm/state.h> #include <linux/list.h> diff --git a/arch/sandbox/include/asm/sandbox_pci.h b/arch/sandbox/include/asm/sandbox_pci.h new file mode 100644 index 00000000000..a4a4eaece8f --- /dev/null +++ b/arch/sandbox/include/asm/sandbox_pci.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2011 The Chromium OS Authors. + */ + +#ifndef _ASM_SANDBOX_PCI_H_ +#define _ASM_SANDBOX_PCI_H_ + +#include <asm/types.h> + +struct udevice; + +/** + * pci_map_physmem() - map a PCI device into memory + * + * This is used on sandbox to map a device into memory so that it can be + * used with normal memory access. After this call, some part of the device's + * internal structure becomes visible. + * + * This function is normally called from sandbox's map_sysmem() automatically. + * + * @paddr: Physical memory address, normally corresponding to a PCI BAR + * @lenp: On entry, the size of the area to map, On exit it is updated + * to the size actually mapped, which may be less if the device + * has less space + * @devp: Returns the device which mapped into this space + * @ptrp: Returns a pointer to the mapped address. The device's space + * can be accessed as @lenp bytes starting here + * Return: 0 if OK, -ve on error + */ +int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp, + struct udevice **devp, void **ptrp); + +/** + * pci_unmap_physmem() - undo a memory mapping + * + * This must be called after pci_map_physmem() to undo the mapping. + * + * @paddr: Physical memory address, as passed to pci_map_physmem() + * @len: Size of area mapped, as returned by pci_map_physmem() + * @dev: Device to unmap, as returned by pci_map_physmem() + * Return: 0 if OK, -ve on error + */ +int pci_unmap_physmem(const void *addr, unsigned long len, + struct udevice *dev); + +/** + * sandbox_set_enable_pci_map() - Enable / disable PCI address mapping + * + * Since address mapping involves calling every driver, provide a way to + * enable and disable this. It can be handled automatically by the emulator + * uclass, which knows if any emulators are currently active. + * + * If this is disabled, pci_map_physmem() will not be called from + * map_sysmem(). + * + * @enable: 0 to disable, 1 to enable + */ +void sandbox_set_enable_pci_map(int enable); + +#endif /* _ASM_SANDBOX_PCI_H_ */ diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 23eaa3a45e6..3c4347117d4 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -14,6 +14,8 @@ #ifndef _U_BOOT_SANDBOX_H_ #define _U_BOOT_SANDBOX_H_ +#include <linux/compiler_attributes.h> + /* board/.../... */ int board_init(void); @@ -26,54 +28,6 @@ int sandbox_lcd_sdl_early_init(void); struct udevice; -/** - * pci_map_physmem() - map a PCI device into memory - * - * This is used on sandbox to map a device into memory so that it can be - * used with normal memory access. After this call, some part of the device's - * internal structure becomes visible. - * - * This function is normally called from sandbox's map_sysmem() automatically. - * - * @paddr: Physical memory address, normally corresponding to a PCI BAR - * @lenp: On entry, the size of the area to map, On exit it is updated - * to the size actually mapped, which may be less if the device - * has less space - * @devp: Returns the device which mapped into this space - * @ptrp: Returns a pointer to the mapped address. The device's space - * can be accessed as @lenp bytes starting here - * Return: 0 if OK, -ve on error - */ -int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp, - struct udevice **devp, void **ptrp); - -/** - * pci_unmap_physmem() - undo a memory mapping - * - * This must be called after pci_map_physmem() to undo the mapping. - * - * @paddr: Physical memory address, as passed to pci_map_physmem() - * @len: Size of area mapped, as returned by pci_map_physmem() - * @dev: Device to unmap, as returned by pci_map_physmem() - * Return: 0 if OK, -ve on error - */ -int pci_unmap_physmem(const void *addr, unsigned long len, - struct udevice *dev); - -/** - * sandbox_set_enable_pci_map() - Enable / disable PCI address mapping - * - * Since address mapping involves calling every driver, provide a way to - * enable and disable this. It can be handled automatically by the emulator - * uclass, which knows if any emulators are currently active. - * - * If this is disabled, pci_map_physmem() will not be called from - * map_sysmem(). - * - * @enable: 0 to disable, 1 to enable - */ -void sandbox_set_enable_pci_map(int enable); - /** * sandbox_reset() - reset sandbox * diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index 166ee9fcd43..b0b229595ae 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -7,9 +7,10 @@ #include <dm.h> #include <fdtdec.h> #include <log.h> -#include <linux/libfdt.h> #include <pci.h> +#include <asm/sandbox_pci.h> #include <dm/lists.h> +#include <linux/libfdt.h> struct sandbox_pci_emul_priv { int dev_count; diff --git a/test/dm/pci.c b/test/dm/pci.c index bcd274d1879..4f7ee8ab845 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -5,6 +5,7 @@ #include <dm.h> #include <asm/io.h> +#include <asm/sandbox_pci.h> #include <asm/test.h> #include <dm/test.h> #include <test/test.h> -- 2.43.0