From: Igor Velkov <[email protected]> The generic AHCI driver calls board_ahci_enable() before it probes each controller, but does not tell it which one. Board code that sets up a controller can only use a fixed address, as the Armada 38x code does with the address of its first controller.
Pass the device being probed and declare the function in ahci.h. The existing implementations do not use the argument yet. Signed-off-by: Igor Velkov <[email protected]> --- arch/arm/mach-mvebu/cpu.c | 2 +- arch/mips/mach-octeon/cpu.c | 3 ++- board/Marvell/mvebu_armada-37xx/board.c | 3 ++- drivers/ata/ahci_generic.c | 4 ++-- include/ahci.h | 10 ++++++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c index a1eb6927c3e..09a0292699c 100644 --- a/arch/arm/mach-mvebu/cpu.c +++ b/arch/arm/mach-mvebu/cpu.c @@ -607,7 +607,7 @@ static void ahci_mvebu_regret_option(void __iomem *base) writel(0x80, base + AHCI_VENDOR_SPECIFIC_0_DATA); } -int board_ahci_enable(void) +int board_ahci_enable(struct udevice *dev) { ahci_mvebu_mbus_config((void __iomem *)MVEBU_SATA0_BASE); ahci_mvebu_regret_option((void __iomem *)MVEBU_SATA0_BASE); diff --git a/arch/mips/mach-octeon/cpu.c b/arch/mips/mach-octeon/cpu.c index c771da61a68..049b5f05337 100644 --- a/arch/mips/mach-octeon/cpu.c +++ b/arch/mips/mach-octeon/cpu.c @@ -3,6 +3,7 @@ * Copyright (C) 2020-2022 Marvell International Ltd. */ +#include <ahci.h> #include <dm.h> #include <dm/uclass.h> #include <env.h> @@ -457,7 +458,7 @@ int arch_misc_init(void) return 0; } -int board_ahci_enable(void) +int board_ahci_enable(struct udevice *dev) { cvmx_sata_uctl_shim_cfg_t shim_cfg; diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index c30fca6cffd..126f5d78262 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -4,6 +4,7 @@ */ #include <config.h> +#include <ahci.h> #include <dm.h> #include <dm/device-internal.h> #include <env.h> @@ -190,7 +191,7 @@ int board_late_init(void) #endif /* Board specific AHCI / SATA enable code */ -int board_ahci_enable(void) +int board_ahci_enable(struct udevice *ahci_dev) { struct udevice *dev; int ret; diff --git a/drivers/ata/ahci_generic.c b/drivers/ata/ahci_generic.c index 6e5a6cbafd8..8a21d70c68a 100644 --- a/drivers/ata/ahci_generic.c +++ b/drivers/ata/ahci_generic.c @@ -11,7 +11,7 @@ * Dummy implementation that can be overwritten by a board * specific function */ -__weak int board_ahci_enable(void) +__weak int board_ahci_enable(struct udevice *dev) { return 0; } @@ -36,7 +36,7 @@ static int generic_ahci_probe(struct udevice *dev) * Board specific SATA / AHCI enable code, e.g. enable the * AHCI power or deassert reset */ - board_ahci_enable(); + board_ahci_enable(dev); ahci_probe_scsi(dev, (ulong)dev_remap_addr(dev)); diff --git a/include/ahci.h b/include/ahci.h index 470cda006de..76f4e3ef5c8 100644 --- a/include/ahci.h +++ b/include/ahci.h @@ -278,4 +278,14 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base); */ int ahci_probe_scsi_pci(struct udevice *ahci_dev); +/** + * board_ahci_enable() - board specific setup of an AHCI controller + * + * Called by the generic AHCI driver before it probes each controller. + * + * @ahci_dev: AHCI controller being probed + * Return: 0 if OK, -ve on error + */ +int board_ahci_enable(struct udevice *ahci_dev); + #endif -- 2.43.0
