diff options
| author | Simon Glass <[email protected]> | 2023-09-26 08:14:58 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-10-06 14:38:13 -0400 |
| commit | f69d3d6d10b15872a279aeb10b7c522627aff6c2 (patch) | |
| tree | fcabaf4a86164f385ede03b654bc69cbffb2a3ee /drivers/core/ofnode.c | |
| parent | 61fc132051740e0378a5e71f3db6cb1581e970fe (diff) | |
pci: serial: Support reading PCI-register size with base
The PCI helpers read only the base address for a PCI region. In some cases
the size is needed as well, e.g. to pass along to a driver which needs to
know the size of its register area.
Update the functions to allow the size to be returned. For serial, record
the information and provided it with the serial_info() call.
A limitation still exists in that the size is not available when OF_LIVE
is enabled, so take account of that in the tests.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'drivers/core/ofnode.c')
| -rw-r--r-- | drivers/core/ofnode.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 18d2eb0f118..29a42945102 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1270,7 +1270,8 @@ const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname, } int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, - const char *propname, struct fdt_pci_addr *addr) + const char *propname, struct fdt_pci_addr *addr, + fdt_size_t *size) { const fdt32_t *cell; int len; @@ -1298,14 +1299,18 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, (ulong)fdt32_to_cpu(cell[1]), (ulong)fdt32_to_cpu(cell[2])); if ((fdt32_to_cpu(*cell) & type) == type) { + const unaligned_fdt64_t *ptr; + addr->phys_hi = fdt32_to_cpu(cell[0]); addr->phys_mid = fdt32_to_cpu(cell[1]); addr->phys_lo = fdt32_to_cpu(cell[2]); + ptr = (const unaligned_fdt64_t *)(cell + 3); + if (size) + *size = fdt64_to_cpu(*ptr); break; } - cell += (FDT_PCI_ADDR_CELLS + - FDT_PCI_SIZE_CELLS); + cell += FDT_PCI_ADDR_CELLS + FDT_PCI_SIZE_CELLS; } if (i == num) { |
