diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/ahci.c | 14 | ||||
-rw-r--r-- | drivers/gpio/da8xx_gpio.c | 14 | ||||
-rw-r--r-- | drivers/nvme/nvme.c | 32 | ||||
-rw-r--r-- | drivers/phy/phy-uclass.c | 30 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_legacy.c | 2 |
5 files changed, 67 insertions, 25 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 21a89eba5a..d10f9f0bf8 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -50,6 +50,8 @@ struct ahci_uc_priv *probe_ent = NULL; #define WAIT_MS_FLUSH 5000 #define WAIT_MS_LINKUP 200 +#define AHCI_CAP_S64A BIT(31) + __weak void __iomem *ahci_port_base(void __iomem *base, u32 port) { return base + 0x100 + (port * 0x80); @@ -503,9 +505,15 @@ static int ahci_fill_sg(struct ahci_uc_priv *uc_priv, u8 port, } for (i = 0; i < sg_count; i++) { - ahci_sg->addr = - cpu_to_le32((unsigned long) buf + i * MAX_DATA_BYTE_COUNT); - ahci_sg->addr_hi = 0; + /* We assume virt=phys */ + phys_addr_t pa = (unsigned long)buf + i * MAX_DATA_BYTE_COUNT; + + ahci_sg->addr = cpu_to_le32(lower_32_bits(pa)); + ahci_sg->addr_hi = cpu_to_le32(upper_32_bits(pa)); + if (ahci_sg->addr_hi && !(uc_priv->cap & AHCI_CAP_S64A)) { + printf("Error: DMA address too high\n"); + return -1; + } ahci_sg->flags_size = cpu_to_le32(0x3fffff & (buf_len < MAX_DATA_BYTE_COUNT ? (buf_len - 1) diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c index bd79448164..0a50c68d72 100644 --- a/drivers/gpio/da8xx_gpio.c +++ b/drivers/gpio/da8xx_gpio.c @@ -342,13 +342,6 @@ int gpio_free(unsigned int gpio) } #endif -static int _gpio_direction_output(struct davinci_gpio *bank, unsigned int gpio, int value) -{ - clrbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); - gpio_set_value(gpio, value); - return 0; -} - static int _gpio_direction_input(struct davinci_gpio *bank, unsigned int gpio) { setbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); @@ -377,6 +370,13 @@ static int _gpio_get_dir(struct davinci_gpio *bank, unsigned int gpio) return in_le32(&bank->dir) & (1U << GPIO_BIT(gpio)); } +static int _gpio_direction_output(struct davinci_gpio *bank, unsigned int gpio, + int value) +{ + clrbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); + _gpio_set_value(bank, gpio, value); + return 0; +} #ifndef CONFIG_DM_GPIO void gpio_info(void) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index ee6b581d9e..f915817aaa 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -123,6 +123,9 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2, } *prp2 = (ulong)dev->prp_pool; + flush_dcache_range((ulong)dev->prp_pool, (ulong)dev->prp_pool + + dev->prp_entry_num * sizeof(u64)); + return 0; } @@ -580,14 +583,19 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) static int nvme_get_info_from_identify(struct nvme_dev *dev) { - ALLOC_CACHE_ALIGN_BUFFER(char, buf, sizeof(struct nvme_id_ctrl)); - struct nvme_id_ctrl *ctrl = (struct nvme_id_ctrl *)buf; + struct nvme_id_ctrl *ctrl; int ret; int shift = NVME_CAP_MPSMIN(dev->cap) + 12; + ctrl = memalign(dev->page_size, sizeof(struct nvme_id_ctrl)); + if (!ctrl) + return -ENOMEM; + ret = nvme_identify(dev, 0, 1, (dma_addr_t)(long)ctrl); - if (ret) + if (ret) { + free(ctrl); return -EIO; + } dev->nn = le32_to_cpu(ctrl->nn); dev->vwc = ctrl->vwc; @@ -618,6 +626,7 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev) dev->max_transfer_shift = 20; } + free(ctrl); return 0; } @@ -658,16 +667,21 @@ static int nvme_blk_probe(struct udevice *udev) struct blk_desc *desc = dev_get_uclass_platdata(udev); struct nvme_ns *ns = dev_get_priv(udev); u8 flbas; - ALLOC_CACHE_ALIGN_BUFFER(char, buf, sizeof(struct nvme_id_ns)); - struct nvme_id_ns *id = (struct nvme_id_ns *)buf; struct pci_child_platdata *pplat; + struct nvme_id_ns *id; + + id = memalign(ndev->page_size, sizeof(struct nvme_id_ns)); + if (!id) + return -ENOMEM; memset(ns, 0, sizeof(*ns)); ns->dev = ndev; /* extract the namespace id from the block device name */ ns->ns_id = trailing_strtol(udev->name) + 1; - if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id)) + if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id)) { + free(id); return -EIO; + } memcpy(&ns->eui64, &id->eui64, sizeof(id->eui64)); flbas = id->flbas & NVME_NS_FLBAS_LBA_MASK; @@ -686,6 +700,7 @@ static int nvme_blk_probe(struct udevice *udev) memcpy(desc->product, ndev->serial, sizeof(ndev->serial)); memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev)); + free(id); return 0; } @@ -705,9 +720,8 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr, u16 lbas = 1 << (dev->max_transfer_shift - ns->lba_shift); u64 total_lbas = blkcnt; - if (!read) - flush_dcache_range((unsigned long)buffer, - (unsigned long)buffer + total_len); + flush_dcache_range((unsigned long)buffer, + (unsigned long)buffer + total_len); c.rw.opcode = read ? nvme_cmd_read : nvme_cmd_write; c.rw.flags = 0; diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index a0ac30aa71..e201a90c8c 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -108,35 +108,55 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, int generic_phy_init(struct phy *phy) { - struct phy_ops const *ops = phy_dev_ops(phy->dev); + struct phy_ops const *ops; + + if (!phy) + return 0; + ops = phy_dev_ops(phy->dev); return ops->init ? ops->init(phy) : 0; } int generic_phy_reset(struct phy *phy) { - struct phy_ops const *ops = phy_dev_ops(phy->dev); + struct phy_ops const *ops; + + if (!phy) + return 0; + ops = phy_dev_ops(phy->dev); return ops->reset ? ops->reset(phy) : 0; } int generic_phy_exit(struct phy *phy) { - struct phy_ops const *ops = phy_dev_ops(phy->dev); + struct phy_ops const *ops; + + if (!phy) + return 0; + ops = phy_dev_ops(phy->dev); return ops->exit ? ops->exit(phy) : 0; } int generic_phy_power_on(struct phy *phy) { - struct phy_ops const *ops = phy_dev_ops(phy->dev); + struct phy_ops const *ops; + + if (!phy) + return 0; + ops = phy_dev_ops(phy->dev); return ops->power_on ? ops->power_on(phy) : 0; } int generic_phy_power_off(struct phy *phy) { - struct phy_ops const *ops = phy_dev_ops(phy->dev); + struct phy_ops const *ops; + + if (!phy) + return 0; + ops = phy_dev_ops(phy->dev); return ops->power_off ? ops->power_off(phy) : 0; } diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index 08764ee6f2..202e5ab1d3 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c @@ -277,7 +277,7 @@ static int virtio_pci_notify(struct udevice *udev, struct virtqueue *vq) static int virtio_pci_bind(struct udevice *udev) { - static int num_devs; + static unsigned int num_devs; char name[20]; /* Create a unique device name for PCI type devices */ |