From patchwork Tue Oct 27 00:16:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1388232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKtvV72wyz9sRK for ; Tue, 27 Oct 2020 12:11:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=XCE88dHA; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CKtvV50dPzDqDl for ; Tue, 27 Oct 2020 12:11:34 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::102a; helo=mail-pj1-x102a.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=XCE88dHA; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CKsgz0HfvzDqRj for ; Tue, 27 Oct 2020 11:16:30 +1100 (AEDT) Received: by mail-pj1-x102a.google.com with SMTP id lt2so3914244pjb.2 for ; Mon, 26 Oct 2020 17:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2EfO8+CYp/iM5LR+84EQI+/Ow5RTSexTSMm2qW7MUr0=; b=XCE88dHAIjPF73zY+5kn9DZeQZz/HaKfkdl67ff3BV9EePjBjlTS4RPYgdqvcv+u1d WHTm4Ml1POlCNPcyk9QgJ2etsJEdqFx16hnq6+6wFsoZIBKbbdoZ8ucsd5+jcGdUlyhz wdwWtOZCPIewGzxHJZWuvqwF64dVbnA5bUpOVOapVPqZQs/Zz5YhUafEIK8G+qWa4ReH Sr5X9RDtxI7TTra6DdTlohfD6pBxFtqt4BrvCZI3UI3yVHQDhjaInLgqayDzd2UeVcAo xmOHCKB/p3IbXsSatx9UzcnLEY+JaIxoJT9w9QlwUFH8ok1bvnDjCXFQn0PQe52TKx3x fKDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2EfO8+CYp/iM5LR+84EQI+/Ow5RTSexTSMm2qW7MUr0=; b=N+EVE/BlMCM0IhV//mET8xuGDBbpDp/3qADDKFlJn7kwXO+LR+DvE/FU9zq7vwtrV/ UUnRTjrIDbQ8rCMCzHNOt6nD5B+cy40sFatWiO83IeTpbrl6etkoBczNz2BMLrtQrkin UcaMLFaQxb+nRP49tEdes7tLlEkmG56KQQbLmNTiUfzLAqOutuNKM7CciqPuCp4Hfi1P ElWbuipRQjP+Uk778PZoL3nGTx4sUpr/c9mR3qEnJ/49xlARPvpNzT1zrB8da/rCkxGA D5B8T0ybyMgsbl6CGsY18X5Uq+iiDVbS04HEkl+jsT8JJIBAHbZxO+nQTwyqYljeC5hk jWBA== X-Gm-Message-State: AOAM531tXCLgokbFayYZoZ8TbYLGOeQsYjOgbR8MBEdHFv+gs0WAFipv 6rj8Qh5lQAVC+LAOiJ6F72o+z+GcIvU= X-Google-Smtp-Source: ABdhPJwMiaTnYjJL2LiDbUhVJJDy+lR7FmnpCm6R9ADQKWPG5tmWpXZz6phWde2bV5olSXMKGtv58g== X-Received: by 2002:a17:90a:8596:: with SMTP id m22mr18450040pjn.42.1603757786899; Mon, 26 Oct 2020 17:16:26 -0700 (PDT) Received: from localhost.ibm.com (123-243-71-5.static.tpgi.com.au. [123.243.71.5]) by smtp.gmail.com with ESMTPSA id y8sm12926267pfg.104.2020.10.26.17.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 17:16:26 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 27 Oct 2020 11:16:10 +1100 Message-Id: <20201027001612.148724-2-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027001612.148724-1-oohall@gmail.com> References: <20201027001612.148724-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 2/4] hw/ast-sfc: Use lpc fw space copy functions X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Oliver O'Halloran Reviewed-by: Vasant Hegde --- hw/ast-bmc/ast-sf-ctrl.c | 58 +++++----------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) diff --git a/hw/ast-bmc/ast-sf-ctrl.c b/hw/ast-bmc/ast-sf-ctrl.c index 03cc44318e71..fc43040f574d 100644 --- a/hw/ast-bmc/ast-sf-ctrl.c +++ b/hw/ast-bmc/ast-sf-ctrl.c @@ -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);