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>
-int ahci_link_up(struct ahci_probe_ent *probe_ent, int port)
+int ahci_link_up(struct ahci_uc_priv *probe_ent, int port)
static int ata_io_flush(u8 port);
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)
u16 *ataid[AHCI_MAX_PORTS];
#define writel_with_flush(a,b) do { writel(a,b); readl(b); } while (0)
return (i < timeout_msec) ? 0 : -1;
}
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)
-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
{
#if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI)
# ifdef CONFIG_DM_PCI
-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)
{
#if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI)
# if defined(CONFIG_DM_PCI)
- 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;
}
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
probe_ent->dev = dev;
probe_ent->host_flags = ATA_FLAG_SATA
int i, rc = 0;
u32 linkmap;
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;
}
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
probe_ent->host_flags = ATA_FLAG_SATA
| ATA_FLAG_NO_LEGACY
return (i < timeout_msec) ? 0 : -1;
}
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 =
int clk)
{
struct sata_host_regs *host_mmio =
-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;
{
u32 tmp, cap_save, num_ports;
int i, j, timeout = 1000;
-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;
{
struct sata_host_regs *host_mmio =
(struct sata_host_regs *)probe_ent->mmio_base;
static int ahci_init_one(int pdev)
{
int rc;
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
probe_ent->dev = pdev;
probe_ent->host_flags = ATA_FLAG_SATA
-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]);
u8 port, unsigned char *buf, int buf_len)
{
struct ahci_ioports *pp = &(probe_ent->port[port]);
#define AHCI_GET_CMD_SLOT(c) ((c) ? ffs(c) : 0)
#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)
{
u8 port, struct sata_fis_h2d *cfis,
u8 *buf, u32 buf_len, s32 is_write)
{
static void ahci_set_feature(u8 dev, u8 port)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
ahci_exec_ata_cmd(probe_ent, port, cfis, NULL, 0, READ_CMD);
}
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]);
u8 port)
{
struct ahci_ioports *pp = &(probe_ent->port[port]);
- struct ahci_probe_ent *probe_ent = NULL;
+ struct ahci_uc_priv *probe_ent = NULL;
#if defined(CONFIG_MX6)
if (!is_mx6dq() && !is_mx6dqp())
#if defined(CONFIG_MX6)
if (!is_mx6dq() && !is_mx6dqp())
- 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) {
linkmap = probe_ent->link_port_map;
if (0 == linkmap) {
int reset_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)) {
struct sata_host_regs *host_mmio;
if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 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;
if (NULL == probe_ent)
/* not initialized, so nothing to reset */
return 0;
static void dwc_ahsata_identify(int dev, u16 *id)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
static void dwc_ahsata_xfer_mode(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];
probe_ent->pio_mask = id[ATA_ID_PIO_MODES];
probe_ent->udma_mask = id[ATA_ID_UDMA_MODES];
static u32 dwc_ahsata_rw_cmd(int dev, u32 start, u32 blkcnt,
u8 *buffer, int is_write)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
void dwc_ahsata_flush_cache(int dev)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
static u32 dwc_ahsata_rw_cmd_ext(int dev, u32 start, lbaint_t blkcnt,
u8 *buffer, int is_write)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
u32 dwc_ahsata_rw_ncq_cmd(int dev, u32 start, lbaint_t blkcnt,
u8 *buffer, int is_write)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
void dwc_ahsata_flush_cache_ext(int dev)
{
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;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = &h2d;
u8 port = probe_ent->hard_port_no;
static void dwc_ahsata_init_wcache(int dev, u16 *id)
{
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;
if (ata_id_has_wcache(id) && ata_id_wcache_enabled(id))
probe_ent->flags |= SATA_FLAG_WCACHE;
int sata_port_status(int dev, int port)
{
struct sata_port_regs *port_mmio;
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;
if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1))
return -EINVAL;
if (sata_dev_desc[dev].priv == NULL)
return -ENODEV;
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;
port_mmio = (struct sata_port_regs *)probe_ent->port[port].port_mmio;
return readl(&(port_mmio->ssts)) & SATA_PORT_SSTS_DET_MASK;
ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer)
{
u32 rc;
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) {
u32 flags = probe_ent->flags;
if (sata_dev_desc[dev].lba48) {
u8 product[ATA_ID_PROD_LEN + 1] = { 0 };
u16 *id;
u64 n_sectors;
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]);
u8 port = probe_ent->hard_port_no;
struct blk_desc *pdev = &(sata_dev_desc[dev]);
+/**
+ * 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)
#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;
struct udevice *dev;
#else
pci_dev_t dev;