From patchwork Mon Sep 13 16:11:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 509799 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp701855jao; Mon, 13 Sep 2021 09:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgZXT1YdeHoNRbdogdmqDxyqfhgH1MTv1GDgBEzqUwp0i+S9+KpPqLlf227M5ZXv146aCD X-Received: by 2002:a5d:58e9:: with SMTP id f9mr12368194wrd.325.1631549658141; Mon, 13 Sep 2021 09:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631549658; cv=none; d=google.com; s=arc-20160816; b=dQ1ap6iPthin85QcYWgka0NMUCg9nL8n3zI/q5CgN+cv8lgij2J1KcEEGB0/35BKI2 agyoOZt2pRXF/Y8KVwKeNX/+GUUq+F/CnJKWmWPZ1k1w91F5A8aFh+hnwPUlJ/3jkCsj UwXEv0RaXnM4bSDCbG1I0BslKhIfGa1we8hKXgYpBOlgq9dgg2qkKEn/4a2JNGBiLRy+ 3bkVO6mBhw4gR8seVPGEbAuCLHKTH5LZumhNDH5uGl6xqlwVZsccNeBNg81ypCAa5hz6 8Tfp5PK0af/lHUFQjrGMk6Wms9uFcQiWkhJ3DhdHEnbfX3VtkS6eKMXkelLdKMzXJcnC JDNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4jqRbJzoQ0IV17bkefMOjWjU3QheqryLgpyvHJ/geYw=; b=aLEB8NuOuniQxP8Wsz0RNeP6Ts//Uf4txompFW9HDGtduSRzlJmsG5ZMXcI/n5PgtC RTodP0zSfzChFh69vrPwyJIfRvU7BXYCp2/cAvCxdzAxVrrDStmAfmskpzEYMjYDsru4 uiLfBy/kJp6lcQcvKN0+cjSKyusbrT4ykBgwNlK58mjrSIPhuoL9sxNUUJdsot3dXUmu 8lRWRqx/ZlrVSuHbyz+e/wErZ5Kd/yv3lWmZP+LF6wPrp1VWp07X8YFPBP2JMBsssreQ EfXR2tCpvZz38Ahe/KSTVZhrG8NSP3Xcxj6tQ6JXlk8g08PddlunGNrYW0rSyVRUbk8e MvOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NRqtTG1C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 128si8146552wmc.221.2021.09.13.09.14.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Sep 2021 09:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NRqtTG1C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPob0-0002Up-3q for patch@linaro.org; Mon, 13 Sep 2021 12:14:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPoYi-0000g1-6b for qemu-devel@nongnu.org; Mon, 13 Sep 2021 12:11:52 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:46971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPoYe-00080q-PT for qemu-devel@nongnu.org; Mon, 13 Sep 2021 12:11:51 -0400 Received: by mail-wr1-x42c.google.com with SMTP id x6so15527637wrv.13 for ; Mon, 13 Sep 2021 09:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4jqRbJzoQ0IV17bkefMOjWjU3QheqryLgpyvHJ/geYw=; b=NRqtTG1CAJo/taZuCWNCWtHR+5PlbhnzL5ikpWcLc8PgPstC4Bw9FSEL190tznCWVj twzs0czskOvEsdJiiohXJmOPr8qqWntn8Tq50/wVKomT5nXLduBwSRlB0GgaRRbcthr5 2ttzP5/KD0tQyzrSTv9rwT8ccxhcqFVLRukX4lB2nPIEtuYDDgY2lgoszEG+48rqwBx1 GAsyCbdpOjNicRhpzkV3c5ta8B1NfP9DG6tTVo+kfdklGMSfSyfhD85WuSTqySJJmY0Y kA5buCdeIiPct4CjYID3gkIEBySbZKYLZugX6hOwAaefrxCYwpspiKtgNwIoSQLaXBLu 7tfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4jqRbJzoQ0IV17bkefMOjWjU3QheqryLgpyvHJ/geYw=; b=ZN439qQzzuKl/i56NjrUcxGxx2VEV4Bi/tPkVYtMKQvHnP+qFwjcysne6K/Xvmdjkh g93cO4FN3w4baeRwiO5zCBUsbFmbaJiXczBrVGbibQ4+i0PXORS7lU2GWslVrdaDj7ap E4OKPnGC6/2PUcAT3DmTbabQYBY0wcKtqCfVZ6fJTLrTLg5y+vFU4fxukxmLL6leqYLJ p4ekzGimOvmMnpjQgaB8Y2reJ7z7C/YxJUpGWvcJs3XPdSE4rAqvc9jIqv2J1/qLKHkP 0YesiS0yqlFhdSG/csehdmrOXRWi3GtMAFvRKytab6Id3L3fhpYgxwCV+rQrNmgVh12e hO1g== X-Gm-Message-State: AOAM530l6BpIFOQ2sNBkjc+iunwZcwQgTvbwdWc3vXvGRIqZSXxmznDx y8S+qdE3q05hVk3jRsZ3AJM8b+9fkBp7dw== X-Received: by 2002:a5d:4d01:: with SMTP id z1mr12482758wrt.209.1631549507387; Mon, 13 Sep 2021 09:11:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y1sm7629265wmq.43.2021.09.13.09.11.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 09:11:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/23] hw/misc: zynq_slcr: Correctly compute output clocks in the reset exit phase Date: Mon, 13 Sep 2021 17:11:22 +0100 Message-Id: <20210913161144.12347-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913161144.12347-1-peter.maydell@linaro.org> References: <20210913161144.12347-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng As of today, when booting upstream U-Boot for Xilinx Zynq, the UART does not receive anything. Debugging shows that the UART input clock frequency is zero which prevents the UART from receiving anything as per the logic in uart_receive(). >From zynq_slcr_reset_exit() comment, it intends to compute output clocks according to ps_clk and registers. zynq_slcr_compute_clocks() is called to accomplish the task, inside which device_is_in_reset() is called to actually make the attempt in vain. Rework reset_hold() and reset_exit() so that in the reset exit phase, the logic can really compute output clocks in reset_exit(). With this change, upstream U-Boot boots properly again with: $ qemu-system-arm -M xilinx-zynq-a9 -m 1G -display none -serial null -serial stdio \ -device loader,file=u-boot-dtb.bin,addr=0x4000000,cpu-num=0 Fixes: 38867cb7ec90 ("hw/misc/zynq_slcr: add clock generation for uarts") Signed-off-by: Bin Meng Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Message-id: 20210901124521.30599-2-bmeng.cn@gmail.com Signed-off-by: Peter Maydell --- hw/misc/zynq_slcr.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c index 5086e6b7ed2..8b702859618 100644 --- a/hw/misc/zynq_slcr.c +++ b/hw/misc/zynq_slcr.c @@ -269,6 +269,21 @@ static uint64_t zynq_slcr_compute_clock(const uint64_t periods[], zynq_slcr_compute_clock((plls), (state)->regs[reg], \ reg ## _ ## enable_field ## _SHIFT) +static void zynq_slcr_compute_clocks_internal(ZynqSLCRState *s, uint64_t ps_clk) +{ + uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); + uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); + uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); + + uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; + + /* compute uartX reference clocks */ + clock_set(s->uart0_ref_clk, + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); + clock_set(s->uart1_ref_clk, + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); +} + /** * Compute and set the ouputs clocks periods. * But do not propagate them further. Connected clocks @@ -283,17 +298,7 @@ static void zynq_slcr_compute_clocks(ZynqSLCRState *s) ps_clk = 0; } - uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); - uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); - uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); - - uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; - - /* compute uartX reference clocks */ - clock_set(s->uart0_ref_clk, - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); - clock_set(s->uart1_ref_clk, - ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); + zynq_slcr_compute_clocks_internal(s, ps_clk); } /** @@ -416,7 +421,7 @@ static void zynq_slcr_reset_hold(Object *obj) ZynqSLCRState *s = ZYNQ_SLCR(obj); /* will disable all output clocks */ - zynq_slcr_compute_clocks(s); + zynq_slcr_compute_clocks_internal(s, 0); zynq_slcr_propagate_clocks(s); } @@ -425,7 +430,7 @@ static void zynq_slcr_reset_exit(Object *obj) ZynqSLCRState *s = ZYNQ_SLCR(obj); /* will compute output clocks according to ps_clk and registers */ - zynq_slcr_compute_clocks(s); + zynq_slcr_compute_clocks_internal(s, clock_get(s->ps_clk)); zynq_slcr_propagate_clocks(s); }