@@ -71,30 +71,9 @@ static int ast_copy_to_ahb(uint32_t reg, const void *src, uint32_t len)
/* SPI flash, use LPC->AHB bridge */
if ((reg >> 28) == (PNOR_AHB_ADDR >> 28)) {
- uint32_t chunk, off = reg - PNOR_AHB_ADDR + pnor_lpc_offset;
- int64_t rc;
-
- while(len) {
- /* Chose access size */
- if (len > 3 && !(off & 3)) {
- rc = lpc_write(OPAL_LPC_FW, off,
- *(uint32_t *)src, 4);
- chunk = 4;
- } else {
- rc = lpc_write(OPAL_LPC_FW, off,
- *(uint8_t *)src, 1);
- chunk = 1;
- }
- if (rc) {
- prerror("AST_IO: lpc_write.sb failure %lld"
- " to FW 0x%08x\n", rc, off);
- return rc;
- }
- len -= chunk;
- off += chunk;
- src += chunk;
- }
- return 0;
+ uint32_t off = reg - PNOR_AHB_ADDR + pnor_lpc_offset;
+
+ return lpc_fw_write(off, src, len);
}
/* Otherwise we don't do byte access (... yet) */
@@ -110,34 +89,9 @@ static int ast_copy_from_ahb(void *dst, uint32_t reg, uint32_t len)
/* SPI flash, use LPC->AHB bridge */
if ((reg >> 28) == (PNOR_AHB_ADDR >> 28)) {
- uint32_t chunk, off = reg - PNOR_AHB_ADDR + pnor_lpc_offset;
- int64_t rc;
-
- while(len) {
- uint32_t dat;
-
- /* Chose access size */
- if (len > 3 && !(off & 3)) {
- rc = lpc_read(OPAL_LPC_FW, off, &dat, 4);
- if (!rc)
- *(uint32_t *)dst = dat;
- chunk = 4;
- } else {
- rc = lpc_read(OPAL_LPC_FW, off, &dat, 1);
- if (!rc)
- *(uint8_t *)dst = dat;
- chunk = 1;
- }
- if (rc) {
- prerror("AST_IO: lpc_read.sb failure %lld"
- " to FW 0x%08x\n", rc, off);
- return rc;
- }
- len -= chunk;
- off += chunk;
- dst += chunk;
- }
- return 0;
+ uint32_t off = reg - PNOR_AHB_ADDR + pnor_lpc_offset;
+
+ return lpc_fw_read(off, dst, len);
}
/* Otherwise we don't do byte access (... yet) */
prerror("AST_IO: Attempted read bytes access to %08x\n", reg);
Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- hw/ast-bmc/ast-sf-ctrl.c | 58 +++++----------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-)