From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41782C433EF for ; Fri, 1 Apr 2022 13:44:40 +0000 (UTC) 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) 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=20Anikiel?= 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=20Anikiel?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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) { -- 2.35.1.1094.g7c7d902a7c-goog