Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1794037ybb; Thu, 9 Apr 2020 09:08:27 -0700 (PDT) X-Google-Smtp-Source: APiQypL0xgmPS+kxQngurFYKd5tBlNGqtGS2ek9nlPGeNHzgRmgF3r2jxabE/aokRRJJl8UV5kuX X-Received: by 2002:a0c:f70d:: with SMTP id w13mr827883qvn.118.1586448507179; Thu, 09 Apr 2020 09:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586448507; cv=none; d=google.com; s=arc-20160816; b=oPVK7yH565W0bUC/lXjIf+287df5hRguprk57vTGeJEK65/x4kkHGG7whHeuiBjW4S A8d3lPV7I3GhkqTKe5rDLt/F69c7S6UcgmfAqSa26UJyNJXRJEcfL2PaAAnSsKjoO1te 9aAkA1YBCjetseIEkWwSzxVaB/JHbj8Ge5EqhNaqrgD8CJmNLSQCiuvW9GAa4dQFy2ug ZUx7jo76EBBnNxywsMbOgL5zb4+TmEWQyJcUVENe9zcQ/k/f8LbqkGtE/9fupeh4B6xh Dtj/igfBfd8b6qN/hLI6f2zk97kwi82aWPp55FAcj7nUW8ryBmNgcWua8udFnhwve55q 3egA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=sMtIMkVIC+33FHlf/WoN7CadYsshThIHUlKqlSSUY6s=; b=Pg3BHEfAeYYfIrv3QGazSxozxdbP1p/CakVPiVfwX4FlbRzaJ2lQAoHoHEPfedEE+t EqKJxZrE+Q/9UlXunB8B1HRpbUJjor0ieI3iGX1FuuIS019lWbzgsByVXGtoRDXw4Tq5 fX5u8wgAPVRKVAavdojEgL02fFKks/sx0R36KXRuitFQegtFB6ZE6Kxmc8ZefgF1z2bI jztW64GWWaii1u3qmQgR9Hm3imWpPGbW9aL/70uzfS7FsOot6IJDP7xKWFs8Ra88KTIr InFC/u8gMNWQ0EMRxV7AaMIs1LL4NiNzZL/hok/1TOnFFXY1bZkiTunjmv0sN32AbWeG bnvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b70si2554233qkc.338.2020.04.09.09.08.05; Thu, 09 Apr 2020 09:08:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728406AbgDIQFZ (ORCPT + 99 others); Thu, 9 Apr 2020 12:05:25 -0400 Received: from mail.secom.com.pl ([213.216.87.26]:43528 "EHLO mail.secom.com.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728167AbgDIQFZ (ORCPT ); Thu, 9 Apr 2020 12:05:25 -0400 Received: from localhost.localdomain (host-85.14.70.3.static.3s.pl [85.14.70.3]) by mail.secom.com.pl; Thu, 09 Apr 2020 18:05:02 +0200 From: =?UTF-8?q?Rafa=C5=82=20Hibner?= Cc: =?UTF-8?q?Rafa=C5=82=20Hibner?= , Alexandru Ardelean , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: spi-axi-spi-engine: Access register after clock initialization Date: Thu, 9 Apr 2020 17:56:21 +0200 Message-Id: <20200409155621.12174-1-rafal.hibner@secom.com.pl> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move register access after clock initialization. Clock "s_axi_aclk" is needed for register access. Without the clock running AXI bus hangs and causes kernel freeze. Cc: Alexandru Ardelean Signed-off-by: RafaƂ Hibner --- drivers/spi/spi-axi-spi-engine.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index eb9b78a90d..af86e6d6e1 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -489,22 +489,6 @@ static int spi_engine_probe(struct platform_device *pdev) spin_lock_init(&spi_engine->lock); - spi_engine->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(spi_engine->base)) { - ret = PTR_ERR(spi_engine->base); - goto err_put_master; - } - - version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION); - if (SPI_ENGINE_VERSION_MAJOR(version) != 1) { - dev_err(&pdev->dev, "Unsupported peripheral version %u.%u.%c\n", - SPI_ENGINE_VERSION_MAJOR(version), - SPI_ENGINE_VERSION_MINOR(version), - SPI_ENGINE_VERSION_PATCH(version)); - ret = -ENODEV; - goto err_put_master; - } - spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); if (IS_ERR(spi_engine->clk)) { ret = PTR_ERR(spi_engine->clk); @@ -525,6 +509,22 @@ static int spi_engine_probe(struct platform_device *pdev) if (ret) goto err_clk_disable; + spi_engine->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(spi_engine->base)) { + ret = PTR_ERR(spi_engine->base); + goto err_ref_clk_disable; + } + + version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION); + if (SPI_ENGINE_VERSION_MAJOR(version) != 1) { + dev_err(&pdev->dev, "Unsupported peripheral version %u.%u.%c\n", + SPI_ENGINE_VERSION_MAJOR(version), + SPI_ENGINE_VERSION_MINOR(version), + SPI_ENGINE_VERSION_PATCH(version)); + ret = -ENODEV; + goto err_ref_clk_disable; + } + writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET); writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); -- 2.24.1