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 0DA8BC433EF for ; Thu, 26 May 2022 14:39:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 985408428F; Thu, 26 May 2022 16:38:47 +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="AcM/260W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D5F883E1B; Thu, 26 May 2022 16:38:21 +0200 (CEST) Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (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 7C7A584367 for ; Thu, 26 May 2022 16:38:03 +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-lf1-x129.google.com with SMTP id u30so2616448lfm.9 for ; Thu, 26 May 2022 07:38:03 -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=Xn81WVd68Atlv/lAn26qnJ0Y8IPYRHlcumn69t8jsdc=; b=AcM/260WU/dv3QdFgR73bZIXC39BSZWxvlcfKgcy8aySI9m3B0pcwi1EE+vQ1JvAiw k1PmI/J/CI3MdrdqE3Ki3DERQkXuX1KthdXggeEG4PMPZIdNwVN316xWh3ISU8v0SzLm MeMFdMep/U9dEqMmnyD0sz6qAoIGWpyYmgxlqgy/nB97JN9iHotDOYGdOjsgj/vjdcRi /ArR7vRkAnCdhE56OJ9XAVKaqS03QYzzTd9CmqH+cW7rpRIsoz+Eh6+67z90Fbh/dIWf +jADujt16j0Wwcqcm8VdxbCjgzx7hf46Gs4gl/h4jyN8XeUoWmOBoyloKVW++NygRQ1a vieA== 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=Xn81WVd68Atlv/lAn26qnJ0Y8IPYRHlcumn69t8jsdc=; b=2qTHrp7cHh5GSAfSy8anVc5Dok3vYEAveC2hqvSbQFylgyjlCYeWUBm/pVNhV/RUq6 3zt3skv486zKugzuCHXf5E97VmVs8Ciqrdo6uQJUxzbj1YHfQ3xNnwQ8AALZvUips4z2 MA6RsRUBUzkgkCh/bOl1SxplezBrCfKfSG6/tcQlNhwemLt5QzamgfGdwhA3RO+/VGy+ 9+pd0L+QX4FGN8Fr1RxgKXSiGEcMu2V5j30W4G6+B4trNSztmq8Nawa+kX7xqV25YqpF hdtXZmM6fUNJq0w6YR1wCqHLpVnSfmyQqFop5ZIauvo5V19RKiborPC6Q8G5d8dE+lMw AzTw== X-Gm-Message-State: AOAM531VDZrc7GYvVlDRvo8DJChJDw84zdeKsM1DZUAbAEDqdwnW5rnD +Taf4mLAfzWu5gWghQxYW7Ud+w== X-Google-Smtp-Source: ABdhPJxiIqNjPZbcJuuZfWsEBee1VLxkjLinmoDE9YR8vi51vWSRlTCbd5ZAbYa0AIjI7kyHx1Snlg== X-Received: by 2002:a05:6512:e86:b0:478:6841:2c9d with SMTP id bi6-20020a0565120e8600b0047868412c9dmr16543241lfb.560.1653575883230; Thu, 26 May 2022 07:38:03 -0700 (PDT) Received: from panikiel.wifi.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id s28-20020a05651c049c00b0024f3d1daea2sm464194ljc.42.2022.05.26.07.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 07:38:02 -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 v2 10/11] socfpga: arria10: Wait for fifo empty after writing bitstream Date: Thu, 26 May 2022 16:37:14 +0200 Message-Id: <20220526143715.277342-11-pan@semihalf.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220526143715.277342-1-pan@semihalf.com> References: <20220526143715.277342-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.36.1.124.g0e6072fb45-goog