Skip to content

Commit 2a67bf6

Browse files
palitrini
authored andcommitted
pci: sh7751: Fix access to config space via PCI_CONF1_ADDRESS() macro
sh7751 platform uses standard format of Config Address for PCI Configuration Mechanism #1. Commit 72c2f4a ("pci: sh7751: Convert to DM and DT probing") which did conversion of PCI sh7751 driver to DM, broke access to config space as that commit somehow swapped device and function bits in config address. Fix all these issues by using new U-Boot macro PCI_CONF1_ADDRESS() which calculates Config Address correctly. Also remove nonsense function sh7751_pci_addr_valid() which was introduced in commit 72c2f4a ("pci: sh7751: Convert to DM and DT probing") probably due to workarounded issues with mixing/swapping device and function bits of config address which probably resulted in non-working access to some devices. With correct composing of config address there should not be such issue anymore. Signed-off-by: Pali Rohár <pali@kernel.org> Fixes: 72c2f4a ("pci: sh7751: Convert to DM and DT probing") Cc: Marek Vasut <marek.vasut+renesas@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
1 parent c49f1fa commit 2a67bf6

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

drivers/pci/pci_sh7751.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,13 @@
7474
#define p4_in(addr) (*addr)
7575
#define p4_out(data, addr) (*addr) = (data)
7676

77-
static int sh7751_pci_addr_valid(pci_dev_t d, uint offset)
78-
{
79-
if (PCI_FUNC(d))
80-
return -EINVAL;
81-
82-
return 0;
83-
}
84-
85-
static u32 get_bus_address(const struct udevice *dev, pci_dev_t bdf, u32 offset)
86-
{
87-
return BIT(31) | (PCI_DEV(bdf) << 8) | (offset & ~3);
88-
}
89-
9077
static int sh7751_pci_read_config(const struct udevice *dev, pci_dev_t bdf,
9178
uint offset, ulong *value,
9279
enum pci_size_t size)
9380
{
9481
u32 addr, reg;
95-
int ret;
9682

97-
ret = sh7751_pci_addr_valid(bdf, offset);
98-
if (ret) {
99-
*value = pci_get_ff(size);
100-
return 0;
101-
}
102-
103-
addr = get_bus_address(dev, bdf, offset);
83+
addr = PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset);
10484
p4_out(addr, SH7751_PCIPAR);
10585
reg = p4_in(SH7751_PCIPDR);
10686
*value = pci_conv_32_to_size(reg, offset, size);
@@ -113,13 +93,8 @@ static int sh7751_pci_write_config(struct udevice *dev, pci_dev_t bdf,
11393
enum pci_size_t size)
11494
{
11595
u32 addr, reg, old;
116-
int ret;
117-
118-
ret = sh7751_pci_addr_valid(bdf, offset);
119-
if (ret)
120-
return ret;
12196

122-
addr = get_bus_address(dev, bdf, offset);
97+
addr = PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset);
12398
p4_out(addr, SH7751_PCIPAR);
12499
old = p4_in(SH7751_PCIPDR);
125100
reg = pci_conv_size_to_32(old, value, offset, size);

0 commit comments

Comments
 (0)