mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
dm: ahci: Unwind the confusing init code
Two AHCI drivers use SCSI with CONFIG_DM_SCSI. The SCSI uclass calls scsi_low_level_init() which is implemented by ahci.c. If CONFIG_SCSI_AHCI_PLAT is defined it does one thing and if it is not it does something else. We don't need to call through scsi_low_level_init() to get the init completed. Instead, adjust the two drivers to call into AHCI directly. Drop the post-probe init in the SCSI uclass. This means that driver model doesn't need to use scsi_low_level_init(). It is a legacy function and driver model should use a driver's probe() method instead. While we are here, add a comment to the top of the file explaining what ahci.c does. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
* SPDX-License-Identifier: GPL-2.0+
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
*
|
*
|
||||||
* with the reference on libata and ahci drvier in kernel
|
* with the reference on libata and ahci drvier in kernel
|
||||||
|
*
|
||||||
|
* This driver provides a SCSI interface to SATA.
|
||||||
*/
|
*/
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
@@ -990,11 +992,8 @@ static int ahci_start_ports(struct ahci_uc_priv *uc_priv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_DM_SCSI)
|
#ifndef CONFIG_DM_SCSI
|
||||||
void scsi_low_level_init(int busdevfunc, struct udevice *dev)
|
|
||||||
#else
|
|
||||||
void scsi_low_level_init(int busdevfunc)
|
void scsi_low_level_init(int busdevfunc)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
struct ahci_uc_priv *uc_priv;
|
struct ahci_uc_priv *uc_priv;
|
||||||
|
|
||||||
@@ -1007,8 +1006,6 @@ void scsi_low_level_init(int busdevfunc)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return;
|
return;
|
||||||
ahci_init_one(dev);
|
ahci_init_one(dev);
|
||||||
# elif defined(CONFIG_DM_SCSI)
|
|
||||||
ahci_init_one(dev);
|
|
||||||
# else
|
# else
|
||||||
ahci_init_one(busdevfunc);
|
ahci_init_one(busdevfunc);
|
||||||
# endif
|
# endif
|
||||||
@@ -1017,6 +1014,23 @@ void scsi_low_level_init(int busdevfunc)
|
|||||||
|
|
||||||
ahci_start_ports(uc_priv);
|
ahci_start_ports(uc_priv);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SCSI_AHCI_PLAT
|
||||||
|
# if defined(CONFIG_DM_PCI) || defined(CONFIG_DM_SCSI)
|
||||||
|
int achi_init_one_dm(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return ahci_init_one(dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int achi_start_ports_dm(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct ahci_uc_priv *uc_priv = probe_ent;
|
||||||
|
|
||||||
|
return ahci_start_ports(uc_priv);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_AHCI_PLAT
|
#ifdef CONFIG_SCSI_AHCI_PLAT
|
||||||
int ahci_init(void __iomem *base)
|
int ahci_init(void __iomem *base)
|
||||||
|
@@ -81,7 +81,11 @@ static int dwc_ahci_probe(struct udevice *dev)
|
|||||||
writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
|
writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ahci_init(priv->base);
|
ret = ahci_init(priv->base);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return achi_start_ports_dm(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct udevice_id dwc_ahci_ids[] = {
|
static const struct udevice_id dwc_ahci_ids[] = {
|
||||||
|
@@ -116,7 +116,8 @@ static int sata_ceva_probe(struct udevice *dev)
|
|||||||
struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
|
struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
|
||||||
|
|
||||||
ceva_init_sata(plat->base);
|
ceva_init_sata(plat->base);
|
||||||
return 0;
|
|
||||||
|
return achi_init_one_dm(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct udevice_id sata_ceva_ids[] = {
|
static const struct udevice_id sata_ceva_ids[] = {
|
||||||
|
@@ -13,16 +13,8 @@
|
|||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <scsi.h>
|
#include <scsi.h>
|
||||||
|
|
||||||
static int scsi_post_probe(struct udevice *dev)
|
|
||||||
{
|
|
||||||
debug("%s: device %p\n", __func__, dev);
|
|
||||||
scsi_low_level_init(0, dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UCLASS_DRIVER(scsi) = {
|
UCLASS_DRIVER(scsi) = {
|
||||||
.id = UCLASS_SCSI,
|
.id = UCLASS_SCSI,
|
||||||
.name = "scsi",
|
.name = "scsi",
|
||||||
.post_probe = scsi_post_probe,
|
|
||||||
.per_device_platdata_auto_alloc_size = sizeof(struct scsi_platdata),
|
.per_device_platdata_auto_alloc_size = sizeof(struct scsi_platdata),
|
||||||
};
|
};
|
||||||
|
@@ -179,4 +179,18 @@ struct ahci_uc_priv {
|
|||||||
int ahci_init(void __iomem *base);
|
int ahci_init(void __iomem *base);
|
||||||
int ahci_reset(void __iomem *base);
|
int ahci_reset(void __iomem *base);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* achi_init_one_dm() - set up a single AHCI port
|
||||||
|
*
|
||||||
|
* @dev: Controller to init
|
||||||
|
*/
|
||||||
|
int achi_init_one_dm(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* achi_start_ports_dm() - start all AHCI ports for a controller
|
||||||
|
*
|
||||||
|
* @dev: Controller containing ports to start
|
||||||
|
*/
|
||||||
|
int achi_start_ports_dm(struct udevice *dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -171,9 +171,7 @@ struct scsi_platdata {
|
|||||||
unsigned long max_id;
|
unsigned long max_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_DM_SCSI)
|
#ifndef CONFIG_DM_SCSI
|
||||||
void scsi_low_level_init(int busdevfunc, struct udevice *dev);
|
|
||||||
#else
|
|
||||||
void scsi_low_level_init(int busdevfunc);
|
void scsi_low_level_init(int busdevfunc);
|
||||||
void scsi_init(void);
|
void scsi_init(void);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user