summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-10-22 16:22:08 +0200
committerStefan Roese <sr@denx.de>2021-11-03 06:45:26 +0100
commitdaa9bfdb9cff9cc7ff0ad93383bbaf2bd618ab5e (patch)
treee8ca69b07b0c55d9791dfbeb1b22b60b189e5f0e /drivers
parenta79115dde373f7cdb181040dd6489fd0b21bfbd2 (diff)
downloadu-boot-daa9bfdb9cff9cc7ff0ad93383bbaf2bd618ab5e.tar.gz
u-boot-daa9bfdb9cff9cc7ff0ad93383bbaf2bd618ab5e.tar.bz2
u-boot-daa9bfdb9cff9cc7ff0ad93383bbaf2bd618ab5e.zip
pci: pci_mvebu: Fix write_config() with PCI_SIZE_8 or PCI_SIZE_16
Current implementation of write_config() is broken for PCI_SIZE_8 or PCI_SIZE_16 as it always uses writel(), which means that write operation is always 32-bit, so upper 24 bits for PCI_SIZE_8 and upper 16 bits for PCI_SIZE_16 are cleared. Fix this by using writeb() and writew(), respectively. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/pci_mvebu.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c
index 0c1d7cd770..8175511514 100644
--- a/drivers/pci/pci_mvebu.c
+++ b/drivers/pci/pci_mvebu.c
@@ -211,8 +211,19 @@ static int mvebu_pcie_write_config(struct udevice *bus, pci_dev_t bdf,
writel(PCIE_CONF_ADDR(bdf, offset), pcie->base + PCIE_CONF_ADDR_OFF);
/* write data */
- data = pci_conv_size_to_32(0, value, offset, size);
- writel(data, pcie->base + PCIE_CONF_DATA_OFF);
+ switch (size) {
+ case PCI_SIZE_8:
+ writeb(value, pcie->base + PCIE_CONF_DATA_OFF + (offset & 3));
+ break;
+ case PCI_SIZE_16:
+ writew(value, pcie->base + PCIE_CONF_DATA_OFF + (offset & 2));
+ break;
+ case PCI_SIZE_32:
+ writel(value, pcie->base + PCIE_CONF_DATA_OFF);
+ break;
+ default:
+ return -EINVAL;
+ }
return 0;
}