summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-06-14 21:28:32 -0600
committerSimon Glass <sjg@chromium.org>2017-07-11 10:08:19 -0600
commit2c9f9efb3d43568e5e5843c600e8bfc2d42ac23e (patch)
tree2481c6763c62a2b6119e2b1c3698d36b78200208
parent1dc64f6c00e89f11e3615403459207405ab0efda (diff)
dm: ahci: Rename struct ahci_probe_ent
This is not a very useful name since once it is probed it still hangs around. With driver model we will use uclass data for this, so rename the struct. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--board/highbank/ahci.c2
-rw-r--r--drivers/ata/ahci.c16
-rw-r--r--drivers/ata/dwc_ahsata.c74
-rw-r--r--include/ahci.h13
4 files changed, 58 insertions, 47 deletions
diff --git a/board/highbank/ahci.c b/board/highbank/ahci.c
index 1578a33fd1..dadfbdd315 100644
--- a/board/highbank/ahci.c
+++ b/board/highbank/ahci.c
@@ -172,7 +172,7 @@ static void cphy_override_lane(u8 port)
#define WAIT_MS_LINKUP 4
-int ahci_link_up(struct ahci_probe_ent *probe_ent, int port)
+int ahci_link_up(struct ahci_uc_priv *probe_ent, int port)
{
u32 tmp;
int j = 0;
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 2cc604b3f4..2caa29b4c5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -24,7 +24,7 @@
static int ata_io_flush(u8 port);
-struct ahci_probe_ent *probe_ent = NULL;
+struct ahci_uc_priv *probe_ent = NULL;
u16 *ataid[AHCI_MAX_PORTS];
#define writel_with_flush(a,b) do { writel(a,b); readl(b); } while (0)
@@ -109,7 +109,7 @@ static int waiting_for_cmd_completed(void __iomem *offset,
return (i < timeout_msec) ? 0 : -1;
}
-int __weak ahci_link_up(struct ahci_probe_ent *probe_ent, u8 port)
+int __weak ahci_link_up(struct ahci_uc_priv *probe_ent, u8 port)
{
u32 tmp;
int j = 0;
@@ -166,7 +166,7 @@ int ahci_reset(void __iomem *base)
return 0;
}
-static int ahci_host_init(struct ahci_probe_ent *probe_ent)
+static int ahci_host_init(struct ahci_uc_priv *probe_ent)
{
#if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI)
# ifdef CONFIG_DM_PCI
@@ -344,7 +344,7 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent)
}
-static void ahci_print_info(struct ahci_probe_ent *probe_ent)
+static void ahci_print_info(struct ahci_uc_priv *probe_ent)
{
#if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI)
# if defined(CONFIG_DM_PCI)
@@ -437,13 +437,13 @@ static int ahci_init_one(pci_dev_t dev)
#endif
int rc;
- probe_ent = malloc(sizeof(struct ahci_probe_ent));
+ probe_ent = malloc(sizeof(struct ahci_uc_priv));
if (!probe_ent) {
printf("%s: No memory for probe_ent\n", __func__);
return -ENOMEM;
}
- memset(probe_ent, 0, sizeof(struct ahci_probe_ent));
+ memset(probe_ent, 0, sizeof(struct ahci_uc_priv));
probe_ent->dev = dev;
probe_ent->host_flags = ATA_FLAG_SATA
@@ -1006,13 +1006,13 @@ int ahci_init(void __iomem *base)
int i, rc = 0;
u32 linkmap;
- probe_ent = malloc(sizeof(struct ahci_probe_ent));
+ probe_ent = malloc(sizeof(struct ahci_uc_priv));
if (!probe_ent) {
printf("%s: No memory for probe_ent\n", __func__);
return -ENOMEM;
}
- memset(probe_ent, 0, sizeof(struct ahci_probe_ent));
+ memset(probe_ent, 0, sizeof(struct ahci_uc_priv));
probe_ent->host_flags = ATA_FLAG_SATA
| ATA_FLAG_NO_LEGACY
diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index c306e927db..78572a5b73 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -100,7 +100,7 @@ static int waiting_for_cmd_completed(u8 *offset,
return (i < timeout_msec) ? 0 : -1;
}
-static int ahci_setup_oobr(struct ahci_probe_ent *probe_ent,
+static int ahci_setup_oobr(struct ahci_uc_priv *probe_ent,
int clk)
{
struct sata_host_regs *host_mmio =
@@ -112,7 +112,7 @@ static int ahci_setup_oobr(struct ahci_probe_ent *probe_ent,
return 0;
}
-static int ahci_host_init(struct ahci_probe_ent *probe_ent)
+static int ahci_host_init(struct ahci_uc_priv *probe_ent)
{
u32 tmp, cap_save, num_ports;
int i, j, timeout = 1000;
@@ -275,7 +275,7 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent)
return 0;
}
-static void ahci_print_info(struct ahci_probe_ent *probe_ent)
+static void ahci_print_info(struct ahci_uc_priv *probe_ent)
{
struct sata_host_regs *host_mmio =
(struct sata_host_regs *)probe_ent->mmio_base;
@@ -331,10 +331,10 @@ static void ahci_print_info(struct ahci_probe_ent *probe_ent)
static int ahci_init_one(int pdev)
{
int rc;
- struct ahci_probe_ent *probe_ent = NULL;
+ struct ahci_uc_priv *probe_ent = NULL;
- probe_ent = malloc(sizeof(struct ahci_probe_ent));
- memset(probe_ent, 0, sizeof(struct ahci_probe_ent));
+ probe_ent = malloc(sizeof(struct ahci_uc_priv));
+ memset(probe_ent, 0, sizeof(struct ahci_uc_priv));
probe_ent->dev = pdev;
probe_ent->host_flags = ATA_FLAG_SATA
@@ -361,7 +361,7 @@ err_out:
return rc;
}
-static int ahci_fill_sg(struct ahci_probe_ent *probe_ent,
+static int ahci_fill_sg(struct ahci_uc_priv *probe_ent,
u8 port, unsigned char *buf, int buf_len)
{
struct ahci_ioports *pp = &(probe_ent->port[port]);
@@ -408,7 +408,7 @@ static void ahci_fill_cmd_slot(struct ahci_ioports *pp, u32 cmd_slot, u32 opts)
#define AHCI_GET_CMD_SLOT(c) ((c) ? ffs(c) : 0)
-static int ahci_exec_ata_cmd(struct ahci_probe_ent *probe_ent,
+static int ahci_exec_ata_cmd(struct ahci_uc_priv *probe_ent,
u8 port, struct sata_fis_h2d *cfis,
u8 *buf, u32 buf_len, s32 is_write)
{
@@ -461,8 +461,8 @@ static int ahci_exec_ata_cmd(struct ahci_probe_ent *probe_ent,
static void ahci_set_feature(u8 dev, u8 port)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
@@ -476,7 +476,7 @@ static void ahci_set_feature(u8 dev, u8 port)
ahci_exec_ata_cmd(probe_ent, port, cfis, NULL, 0, READ_CMD);
}
-static int ahci_port_start(struct ahci_probe_ent *probe_ent,
+static int ahci_port_start(struct ahci_uc_priv *probe_ent,
u8 port)
{
struct ahci_ioports *pp = &(probe_ent->port[port]);
@@ -560,7 +560,7 @@ int init_sata(int dev)
{
int i;
u32 linkmap;
- struct ahci_probe_ent *probe_ent = NULL;
+ struct ahci_uc_priv *probe_ent = NULL;
#if defined(CONFIG_MX6)
if (!is_mx6dq() && !is_mx6dqp())
@@ -573,7 +573,7 @@ int init_sata(int dev)
ahci_init_one(dev);
- probe_ent = (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
linkmap = probe_ent->link_port_map;
if (0 == linkmap) {
@@ -597,7 +597,7 @@ int init_sata(int dev)
int reset_sata(int dev)
{
- struct ahci_probe_ent *probe_ent;
+ struct ahci_uc_priv *probe_ent;
struct sata_host_regs *host_mmio;
if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) {
@@ -605,7 +605,7 @@ int reset_sata(int dev)
return -1;
}
- probe_ent = (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
if (NULL == probe_ent)
/* not initialized, so nothing to reset */
return 0;
@@ -636,8 +636,8 @@ static void dwc_ahsata_print_info(int dev)
static void dwc_ahsata_identify(int dev, u16 *id)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -655,8 +655,8 @@ static void dwc_ahsata_identify(int dev, u16 *id)
static void dwc_ahsata_xfer_mode(int dev, u16 *id)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
probe_ent->pio_mask = id[ATA_ID_PIO_MODES];
probe_ent->udma_mask = id[ATA_ID_UDMA_MODES];
@@ -667,8 +667,8 @@ static void dwc_ahsata_xfer_mode(int dev, u16 *id)
static u32 dwc_ahsata_rw_cmd(int dev, u32 start, u32 blkcnt,
u8 *buffer, int is_write)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -698,8 +698,8 @@ static u32 dwc_ahsata_rw_cmd(int dev, u32 start, u32 blkcnt,
void dwc_ahsata_flush_cache(int dev)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -716,8 +716,8 @@ void dwc_ahsata_flush_cache(int dev)
static u32 dwc_ahsata_rw_cmd_ext(int dev, u32 start, lbaint_t blkcnt,
u8 *buffer, int is_write)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -753,8 +753,8 @@ static u32 dwc_ahsata_rw_cmd_ext(int dev, u32 start, lbaint_t blkcnt,
u32 dwc_ahsata_rw_ncq_cmd(int dev, u32 start, lbaint_t blkcnt,
u8 *buffer, int is_write)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -795,8 +795,8 @@ u32 dwc_ahsata_rw_ncq_cmd(int dev, u32 start, lbaint_t blkcnt,
void dwc_ahsata_flush_cache_ext(int dev)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
@@ -812,8 +812,8 @@ void dwc_ahsata_flush_cache_ext(int dev)
static void dwc_ahsata_init_wcache(int dev, u16 *id)
{
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
if (ata_id_has_wcache(id) && ata_id_wcache_enabled(id))
probe_ent->flags |= SATA_FLAG_WCACHE;
@@ -893,7 +893,7 @@ u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,
int sata_port_status(int dev, int port)
{
struct sata_port_regs *port_mmio;
- struct ahci_probe_ent *probe_ent = NULL;
+ struct ahci_uc_priv *probe_ent = NULL;
if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
return -EINVAL;
@@ -901,7 +901,7 @@ int sata_port_status(int dev, int port)
if (sata_dev_desc[dev].priv == NULL)
return -ENODEV;
- probe_ent = (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
port_mmio = (struct sata_port_regs *)probe_ent->port[port].port_mmio;
return readl(&(port_mmio->ssts)) & SATA_PORT_SSTS_DET_MASK;
@@ -926,8 +926,8 @@ ulong sata_read(int dev, ulong blknr, lbaint_t blkcnt, void *buffer)
ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer)
{
u32 rc;
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
u32 flags = probe_ent->flags;
if (sata_dev_desc[dev].lba48) {
@@ -953,8 +953,8 @@ int scan_sata(int dev)
u8 product[ATA_ID_PROD_LEN + 1] = { 0 };
u16 *id;
u64 n_sectors;
- struct ahci_probe_ent *probe_ent =
- (struct ahci_probe_ent *)sata_dev_desc[dev].priv;
+ struct ahci_uc_priv *probe_ent =
+ (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
u8 port = probe_ent->hard_port_no;
struct blk_desc *pdev = &(sata_dev_desc[dev]);
diff --git a/include/ahci.h b/include/ahci.h
index 4876b41e90..1f441d1c80 100644
--- a/include/ahci.h
+++ b/include/ahci.h
@@ -144,8 +144,19 @@ struct ahci_ioports {
u32 rx_fis;
};
-struct ahci_probe_ent {
+/**
+ * struct ahci_uc_priv - information about an AHCI controller
+ *
+ * When driver model is used, this is accessible using dev_get_uclass_priv(dev)
+ * where dev is the controller (although at present it sometimes stands alone).
+ */
+struct ahci_uc_priv {
#if defined(CONFIG_DM_PCI) || defined(CONFIG_DM_SCSI)
+ /*
+ * TODO(sjg@chromium.org): Drop this once this structure is only used
+ * in a driver-model context (i.e. attached to a device with
+ * dev_get_uclass_priv()
+ */
struct udevice *dev;
#else
pci_dev_t dev;