aboutsummaryrefslogtreecommitdiff
path: root/hw/lpc.c
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2019-12-08 22:22:45 +1000
committerOliver O'Halloran <oohall@gmail.com>2019-12-16 14:50:56 +1100
commit1b9a449d5d48de9520befd09892d85d6aec7ba62 (patch)
treed8fb15c0217cf0328a8afeb90cb03bac1dbbc8db /hw/lpc.c
parent0ed09ec18e3f856d5456908c4abe3649a025ea12 (diff)
downloadskiboot-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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/hw/lpc.c b/hw/lpc.c
index ec5146f..abf5497 100644
--- a/hw/lpc.c
+++ b/hw/lpc.c
@@ -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;
}