diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2019-12-08 22:22:45 +1000 |
---|---|---|
committer | Oliver O'Halloran <oohall@gmail.com> | 2019-12-16 14:50:56 +1100 |
commit | 1b9a449d5d48de9520befd09892d85d6aec7ba62 (patch) | |
tree | d8fb15c0217cf0328a8afeb90cb03bac1dbbc8db /hw/lpc.c | |
parent | 0ed09ec18e3f856d5456908c4abe3649a025ea12 (diff) | |
download | skiboot-1b9a449d5d48de9520befd09892d85d6aec7ba62.zip skiboot-1b9a449d5d48de9520befd09892d85d6aec7ba62.tar.gz skiboot-1b9a449d5d48de9520befd09892d85d6aec7ba62.tar.bz2 |
opal-api: add endian conversions to most opal calls
This adds missing endian conversions to most calls, sufficient at least
to handle calls from a kernel booting on mambo.
Subsystems requiring more extensive changes (e.g., xive) will be done
with individual changes.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Diffstat (limited to 'hw/lpc.c')
-rw-r--r-- | hw/lpc.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -673,27 +673,36 @@ int64_t lpc_probe_read(enum OpalLPCAddressType addr_type, uint32_t addr, * existing Linux expectations */ static int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, - uint32_t addr, uint32_t *data, uint32_t sz) + uint32_t addr, __be32 *data, uint32_t sz) { struct proc_chip *chip; int64_t rc; + uint32_t tmp; chip = get_chip(chip_id); if (!chip || !chip->lpc) return OPAL_PARAMETER; - if (addr_type == OPAL_LPC_FW || sz == 1) - return __lpc_read(chip->lpc, addr_type, addr, data, sz, false); - *data = 0; - while(sz--) { - uint32_t byte; - - rc = __lpc_read(chip->lpc, addr_type, addr, &byte, 1, false); + if (addr_type == OPAL_LPC_FW) { + rc = __lpc_read(chip->lpc, addr_type, addr, &tmp, sz, false); if (rc) return rc; - *data = *data | (byte << (8 * sz)); - addr++; + + } else { + tmp = 0; + while (sz--) { + uint32_t byte; + + rc = __lpc_read(chip->lpc, addr_type, addr, &byte, 1, false); + if (rc) + return rc; + tmp = tmp | (byte << (8 * sz)); + addr++; + } } + + *data = cpu_to_be32(tmp); + return OPAL_SUCCESS; } |