Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp270660ybi; Wed, 29 May 2019 21:04:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIRr4fTG9B2A8+xmZZVqB4YqLbOqsA5vxwN+jVD+Ea/K9F7T2BHa8p7Ir2ASW49W6RoTSX X-Received: by 2002:a17:90a:f48a:: with SMTP id bx10mr1816065pjb.118.1559189099540; Wed, 29 May 2019 21:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189099; cv=none; d=google.com; s=arc-20160816; b=JBZKmrIgefOYBMZMBpjHOjuenj7061LG49+hVquufq8td35sL9cpvu26eYK3Ic/7zS qM7YfqsCGVvMOxDloGK81Bt1xf9RBWa/WJCvoPhxvBOMRD2AiZ6LN/G0XUm3F931wmim d3rzh/eOe1h7J7m+NI3Cfi6l4bdsen1y0oElCDEjks5LDzU3x6VfPMbHFbWUm285DDLq 7pD9ZIynrTzLNGbJ3S1JLQ+JNxKLs6xMLDg0VtQ+JIaSb+9+OxLzfjDN54EIi8I/Qc/u sdnnGkQo1IwYjz8utQdjnMLkuHK0G5SMuvLC/YruGr1n3lMJcOfGzhJ5G/LQjVWuuION bb2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=47KRLW8DWkf16aVsbaiF6gWhslWB8+UA3JL8k+whWqE=; b=MZkP8xndWUNz0UrDnowNN5oC7gO0Uc/jyG5+qJVI5WUX4lEy1vvigZLSSYYjVRa1Ab LkZiVU0L71nQHUfpY1dj5i7D6NFY7j6HEJH4FB64Bfix+SN7kvcZW4MEsZB+RLAT8PaY 4h6Dz6YNOz2IadvHKciSx6P7rNX5CmlN9Zfgq91sVPGCjMYdGJKaVmy0KLE+FAxgrEUP aliGAEr+C/4TEuK5bgsrtM6ohKYJnjASaV498Psk2Dho4O52OmtZ0Rbx4WukpWHRnBh1 LvLTOT3Nt2rXg2f564omX1KK6OQYkWwIKl4aIOMVvyP/uf8dsr5ScD6PU3tVcxCNNPbl BT6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v8CkNfM7; 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 c17si2066253pgd.368.2019.05.29.21.04.42; Wed, 29 May 2019 21:04:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=v8CkNfM7; 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 S1731594AbfE3EDb (ORCPT + 99 others); Thu, 30 May 2019 00:03:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731345AbfE3DR5 (ORCPT ); Wed, 29 May 2019 23:17:57 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7D0924745; Thu, 30 May 2019 03:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186276; bh=LzKJXOeiQ17vHM3+ckSUF66amKUIRGoN2NeYO7IoEGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v8CkNfM7+8d7l8hhBw0dDUrC404EwLqzfRs1FRr+vsn78EHQb9i6HU2OLf3/a1j2r NGZfoXAJ3ax1t6dP0mwxqsmYgw6cozLIV6s6Y6TGYoL4m4O1rDIOwJCikyOmfYXCKT x4i5h6jrmBA21f1G8ZcF0vRvVb8IOeTOHyTZ+EmE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sowjanya Komatineni , Mark Brown , Sasha Levin Subject: [PATCH 4.19 218/276] spi: tegra114: reset controller on probe Date: Wed, 29 May 2019 20:06:16 -0700 Message-Id: <20190530030538.756988156@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 019194933339b3e9b486639c8cb3692020844d65 ] Fixes: SPI driver can be built as module so perform SPI controller reset on probe to make sure it is in valid state before initiating transfer. Signed-off-by: Sowjanya Komatineni Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-tegra114.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index a76acedd7e2f4..a1888dc6a938a 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -1067,27 +1067,19 @@ static int tegra_spi_probe(struct platform_device *pdev) spi_irq = platform_get_irq(pdev, 0); tspi->irq = spi_irq; - ret = request_threaded_irq(tspi->irq, tegra_spi_isr, - tegra_spi_isr_thread, IRQF_ONESHOT, - dev_name(&pdev->dev), tspi); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", - tspi->irq); - goto exit_free_master; - } tspi->clk = devm_clk_get(&pdev->dev, "spi"); if (IS_ERR(tspi->clk)) { dev_err(&pdev->dev, "can not get clock\n"); ret = PTR_ERR(tspi->clk); - goto exit_free_irq; + goto exit_free_master; } tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi"); if (IS_ERR(tspi->rst)) { dev_err(&pdev->dev, "can not get reset\n"); ret = PTR_ERR(tspi->rst); - goto exit_free_irq; + goto exit_free_master; } tspi->max_buf_size = SPI_FIFO_DEPTH << 2; @@ -1095,7 +1087,7 @@ static int tegra_spi_probe(struct platform_device *pdev) ret = tegra_spi_init_dma_param(tspi, true); if (ret < 0) - goto exit_free_irq; + goto exit_free_master; ret = tegra_spi_init_dma_param(tspi, false); if (ret < 0) goto exit_rx_dma_free; @@ -1117,18 +1109,32 @@ static int tegra_spi_probe(struct platform_device *pdev) dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); goto exit_pm_disable; } + + reset_control_assert(tspi->rst); + udelay(2); + reset_control_deassert(tspi->rst); tspi->def_command1_reg = SPI_M_S; tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1); pm_runtime_put(&pdev->dev); + ret = request_threaded_irq(tspi->irq, tegra_spi_isr, + tegra_spi_isr_thread, IRQF_ONESHOT, + dev_name(&pdev->dev), tspi); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", + tspi->irq); + goto exit_pm_disable; + } master->dev.of_node = pdev->dev.of_node; ret = devm_spi_register_master(&pdev->dev, master); if (ret < 0) { dev_err(&pdev->dev, "can not register to master err %d\n", ret); - goto exit_pm_disable; + goto exit_free_irq; } return ret; +exit_free_irq: + free_irq(spi_irq, tspi); exit_pm_disable: pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) @@ -1136,8 +1142,6 @@ static int tegra_spi_probe(struct platform_device *pdev) tegra_spi_deinit_dma_param(tspi, false); exit_rx_dma_free: tegra_spi_deinit_dma_param(tspi, true); -exit_free_irq: - free_irq(spi_irq, tspi); exit_free_master: spi_master_put(master); return ret; -- 2.20.1