From patchwork Fri Apr 1 12:43:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 1612232 X-Patchwork-Delegate: simon.k.r.goldschmidt@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20210112.gappssmtp.com header.i=@semihalf-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=JTpBfSkZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KVLy32XFmz9srZ for ; Sat, 2 Apr 2022 00:44:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E0A25842FB; Fri, 1 Apr 2022 15:42:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20210112.gappssmtp.com header.i=@semihalf-com.20210112.gappssmtp.com header.b="JTpBfSkZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 45C2C842D3; Fri, 1 Apr 2022 14:44:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 903B8842B0 for ; Fri, 1 Apr 2022 14:44:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=pan@semihalf.com Received: by mail-wr1-x42d.google.com with SMTP id i4so4105844wrb.5 for ; Fri, 01 Apr 2022 05:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0XSZEXl8KoFP0DyTp8u5rayzDe+17Lb9u93hUKkGp9M=; b=JTpBfSkZEwNRWvQoDjt/3wNNvJKnwPM2Yy1Tus5onjRGOacrN7KzKuarrP1Mhez9y1 +4n+nmhKGzaTsN8PDD5o9O+coSJCXmIkePUUaNZ6evwpP5fWjrkd+dL+BaSpUKMUsDFf qf/dn0hOgq9CQeRzAbjr3jTXh1wdqIEYznKfd/jNvGgF/R/DKr8HclUnqM49Fh0+yr3t dHJREYkH+slWGbkv8u8vVYsMOPzTnLMYwF180qvaLF6YFIvcwoEpppZhiETJyCh3qpTX sUS4XCtXprV2tzYcBvm+hOoMvd3mLepTYugYR23EjZu+7w3xAWDHlGQaubC0KrKOgGI3 Ghqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0XSZEXl8KoFP0DyTp8u5rayzDe+17Lb9u93hUKkGp9M=; b=DVVkdeOBca5/Pi7jw1PJhpMC8YCSXU61tDE/nKJUTP+5AAoAwGCU+Z1KKmXbccSvqp I2572HqCQiWothfUcqd1RQwsrAnjaORYbie2qwTzTcRNZ/HbmPptq+wHexZpxuOyizIM FEtVvHcuVUH8CMpa2TQmRPJhIGi7xGQRV0raVEN7GCc5ApR984/pigU9090YsGVwSpRf 0MLa3X7Q7Nwta/lhDXC+vIDypGUrmRa4B2OHkPoXAZo8Xsp9YhKZuIeMQOTb49ZmQfqo hTtigSlG4vH2KF4vvPOmusYX1peDFep3BmtfYZacmt9rnMNCrbLe/tB7VrVtcK3cUkbw BWzg== X-Gm-Message-State: AOAM533+WXKCJyWqrBXq4pE7GAcqcr/3D/xpNpZ4M10BXjFpV7GwHVCx SuVx2iqbS8FZi5MemvQY/vjOaLBs1t2kaQ== X-Google-Smtp-Source: ABdhPJwuZ1+TAd6/o8OuSuzJ6JnErEI4CKEkwkzmfuJ3SvHchYVMsdgAT8HdNT5pxShvR//9da4iUQ== X-Received: by 2002:a05:6000:18a8:b0:203:eb58:9733 with SMTP id b8-20020a05600018a800b00203eb589733mr7728917wri.151.1648817055375; Fri, 01 Apr 2022 05:44:15 -0700 (PDT) Received: from localhost.localdomain ([85.191.191.191]) by smtp.gmail.com with ESMTPSA id o10-20020a5d47ca000000b00203fb25165esm2478175wrc.6.2022.04.01.05.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 05:44:15 -0700 (PDT) From: =?utf-8?q?Pawe=C5=82_Anikiel?= To: marex@denx.de, simon.k.r.goldschmidt@gmail.com, tien.fong.chee@intel.com, michal.simek@xilinx.com Cc: u-boot@lists.denx.de, sjg@chromium.org, festevam@denx.de, jagan@amarulasolutions.com, andre.przywara@arm.com, narmstrong@baylibre.com, pbrobinson@gmail.com, tharvey@gateworks.com, paul.liu@linaro.org, christianshewitt@gmail.com, adrian.fiergolski@fastree3d.com, marek.behun@nic.cz, wd@denx.de, elly.siew.chin.lim@intel.com, mw@semihalf.com, =?utf-8?q?Pawe=C5=82_Anikiel?= Subject: [PATCH 10/11] socfpga: arria10: Wait for fifo empty after writing bitstream Date: Fri, 1 Apr 2022 14:43:24 +0200 Message-Id: <20220401124325.1810108-11-pan@semihalf.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog In-Reply-To: <20220401124325.1810108-1-pan@semihalf.com> References: <20220401124325.1810108-1-pan@semihalf.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 01 Apr 2022 15:42:19 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean For some reason, on the Mercury+ AA1 module, calling fpgamgr_wait_early_user_mode immediately after writing the peripheral bitstream leaves the fpga in a broken state (ddr calibration hangs). Adding a delay before the first sync word is written seems to fix this. Inspecting the fpgamgr registers before and after the delay, imgcfg_FifoEmpty is the only bit that changes. Waiting for this bit (instead of a hardcoded delay) also fixes the issue. Signed-off-by: Paweł Anikiel Reviewed-by: Simon Glass --- drivers/fpga/socfpga_arria10.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c index 07bfe3060e..d8089122af 100644 --- a/drivers/fpga/socfpga_arria10.c +++ b/drivers/fpga/socfpga_arria10.c @@ -80,6 +80,13 @@ static int wait_for_user_mode(void) 1, FPGA_TIMEOUT_MSEC, false); } +static int wait_for_fifo_empty(void) +{ + return wait_for_bit_le32(&fpga_manager_base->imgcfg_stat, + ALT_FPGAMGR_IMGCFG_STAT_F2S_IMGCFG_FIFOEMPTY_SET_MSK, + 1, FPGA_TIMEOUT_MSEC, false); +} + int is_fpgamgr_early_user_mode(void) { return (readl(&fpga_manager_base->imgcfg_stat) & @@ -874,6 +881,7 @@ int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize, WATCHDOG_RESET(); } + wait_for_fifo_empty(); if (fpga_loadfs.rbfinfo.section == periph_section) { if (fpgamgr_wait_early_user_mode() != -ETIMEDOUT) {