From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 09 Apr 2026 15:55:16 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wApqm-00AJQA-1E for lore@lore.pengutronix.de; Thu, 09 Apr 2026 15:55:16 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1wApql-0006nN-0i for lore@pengutronix.de; Thu, 09 Apr 2026 15:55:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KET8C4dskbbSTlZIESNXADyFdhQUa1bg4gOI0NlymRA=; b=oRw5dmVTmu4vwcyu3vkTjOLSny j0sLnVLT4mkj+5aWNlUmwAUdN3XheJt75Z7ILUSoCDwjd4mLi/p1XV+ZvmKEjVFGhxgioCV2G/mdk gdmrgW3YRFhyF9LBWCnMnJSooIET9OaPDQQEw3/VUJGGUQbZwRFBx1TBh9kZLcfMRTMQvgyVxIGat U90d6f40UOtbzkt4dcVp5d+U09WifuwaZH7MFEPLwygaFsjvuJPoWhFveVJTZ7/XJy+QaLDvjPmGP ihOYcUv5LEfr6g2A+uBdkPff81x0ic994QXt5fwPKoyJLjS7OPYthwiLpot+SKAwoMV3oPzv2zqRT CidBGhpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wAppY-0000000Ab9f-1nca; Thu, 09 Apr 2026 13:54:00 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wApoX-0000000AaX8-3kUM for barebox@lists.infradead.org; Thu, 09 Apr 2026 13:53:26 +0000 Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1wApoL-0005uF-H2; Thu, 09 Apr 2026 15:52:45 +0200 From: Michael Tretter Date: Thu, 09 Apr 2026 15:52:48 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260409-socfpga-iossm-v1-v2-8-09effab91bc1@pengutronix.de> References: <20260409-socfpga-iossm-v1-v2-0-09effab91bc1@pengutronix.de> In-Reply-To: <20260409-socfpga-iossm-v1-v2-0-09effab91bc1@pengutronix.de> To: Sascha Hauer , BAREBOX Cc: Steffen Trumtrar , Michael Tretter X-Mailer: b4 0.14.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260409_065258_424120_7B7A1BF3 X-CRM114-Status: GOOD ( 15.54 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.0 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH v2 08/10] arm: socfgpa: iossm: extract initialization of one interface X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) Each memory interface of each instance has to be initialized. Extract the code that initializes exactly one interface to reduce the nesting level and make the code more readable. While at it, prepare the initialize function to handle situations which need a different initialization than full memory initialization like inline_ecc. Simplify the error handling and reporting, too. Signed-off-by: Michael Tretter --- Changes in v2: - none --- arch/arm/mach-socfpga/iossm_mailbox.c | 76 +++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-socfpga/iossm_mailbox.c b/arch/arm/mach-socfpga/iossm_mailbox.c index 67000d2cf300..6be1119724d6 100644 --- a/arch/arm/mach-socfpga/iossm_mailbox.c +++ b/arch/arm/mach-socfpga/iossm_mailbox.c @@ -526,43 +526,67 @@ static int io96b_poll_bist_mem_init_status(struct io96b_info *io96b_ctrl, return 0; } +static int bist_mem_init_by_addr(struct io96b_info *io96b_ctrl, + int instance, int interface, + phys_addr_t base_addr, phys_size_t size) +{ + phys_addr_t io96b_csr_addr = io96b_ctrl->io96b[instance].io96b_csr_addr; + struct io96b_mb_ctrl *mb_ctrl = &io96b_ctrl->io96b[instance].mb_ctrl; + struct io96b_mb_resp usr_resp; + bool bist_start = false; + int bist_error = 0; + u32 mem_init_status; + int ret = 0; + u32 mem_exp; + + pr_debug("%s: Start memory initialization BIST on full memory address", + __func__); + mem_exp = 0x40; + + ret = io96b_mb_req(io96b_csr_addr, + mb_ctrl->ip_type[interface], + mb_ctrl->ip_instance_id[interface], + CMD_TRIG_CONTROLLER_OP, BIST_MEM_INIT_START, + FIELD_PREP(GENMASK(5, 0), mem_exp), + FIELD_GET(GENMASK(31, 0), base_addr), + FIELD_GET(GENMASK(37, 32), base_addr), + 0, 0, 0, 0, &usr_resp); + if (ret) + return ret; + + mem_init_status = IOSSM_CMD_RESPONSE_DATA_SHORT(usr_resp.cmd_resp_status); + + bist_start = FIELD_GET(BIT(0), mem_init_status); + bist_error = FIELD_GET(GENMASK(2, 1), mem_init_status); + + if (!bist_start) { + pr_err("%s: Failed to initialize memory on IO96B_%d (Error 0x%x)\n", + __func__, instance, bist_error); + return -ENOEXEC; + } + + return io96b_poll_bist_mem_init_status(io96b_ctrl, instance, interface); +} + int io96b_bist_mem_init_start(struct io96b_info *io96b_ctrl) { - struct io96b_mb_resp usr_resp; int i, j; - bool bist_start; - u32 mem_init_status_intf; int ret = 0; - /* Full memory initialization BIST performed on all memory interface(s) */ + /* Memory initialization BIST performed on all memory interface(s) */ for (i = 0; i < io96b_ctrl->num_instance; i++) { for (j = 0; j < io96b_ctrl->io96b[i].mb_ctrl.num_mem_interface; j++) { - bist_start = false; - - /* Start memory initialization BIST on full memory address */ - io96b_mb_req(io96b_ctrl->io96b[i].io96b_csr_addr, - io96b_ctrl->io96b[i].mb_ctrl.ip_type[j], - io96b_ctrl->io96b[i].mb_ctrl.ip_instance_id[j], - CMD_TRIG_CONTROLLER_OP, BIST_MEM_INIT_START, - 0x40, 0, 0, 0, 0, 0, 0, &usr_resp); - mem_init_status_intf = IOSSM_CMD_RESPONSE_DATA_SHORT(usr_resp.cmd_resp_status); - - bist_start = mem_init_status_intf & BIT(0); - - if (!bist_start) { - pr_err("%s: Failed to initialized memory on IO96B_%d\n", - __func__, i); - pr_err("%s: BIST_MEM_INIT_START Error code 0x%x\n", - __func__, (mem_init_status_intf & GENMASK(2, 1)) > 0x1); - return -ENOEXEC; - } - - ret = io96b_poll_bist_mem_init_status(io96b_ctrl, i, j); - if (ret) + ret = bist_mem_init_by_addr(io96b_ctrl, i, j, 0x0, + io96b_ctrl->io96b[i].mb_ctrl.memory_size[j]); + if (ret) { + pr_err("%s: Memory init failed at Instance %d, Interface %d\n", + __func__, i, j); return ret; + } } pr_debug("%s: Memory initialized successfully on IO96B_%d\n", __func__, i); } + return 0; } -- 2.47.3