From patchwork Wed Aug 29 06:47:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Ziswiler X-Patchwork-Id: 10579553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2ABCF1709 for ; Wed, 29 Aug 2018 06:53:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A652ABF1 for ; Wed, 29 Aug 2018 06:53:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 059162ABFA; Wed, 29 Aug 2018 06:53:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C9BB2ABF1 for ; Wed, 29 Aug 2018 06:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727204AbeH2Ksm (ORCPT ); Wed, 29 Aug 2018 06:48:42 -0400 Received: from mout.perfora.net ([74.208.4.194]:49933 "EHLO mout.perfora.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbeH2Ksm (ORCPT ); Wed, 29 Aug 2018 06:48:42 -0400 X-Greylist: delayed 308 seconds by postgrey-1.27 at vger.kernel.org; Wed, 29 Aug 2018 06:48:42 EDT Received: from localhost.localdomain.toradex.int ([46.140.72.82]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPA (Nemesis) id 0LqSvP-1fQXKt30Zl-00e17f; Wed, 29 Aug 2018 08:48:03 +0200 From: Marcel Ziswiler To: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marcel Ziswiler , Thierry Reding , Jonathan Hunter , Mark Brown , linux-spi@vger.kernel.org, Laxman Dewangan Subject: [PATCH] spi: tegra20-slink: explicitly enable/disable clock Date: Wed, 29 Aug 2018 08:47:57 +0200 Message-Id: <20180829064757.16349-1-marcel@ziswiler.com> X-Mailer: git-send-email 2.14.4 X-Provags-ID: V03:K1:cNhlCHERXxyGCqfAPozMapag1n5OMvTxWI0pa8MQr/hvYFVWHm3 GUPgZlcOwcZArl9THwHJ4r+aqM5fcYzX9upAoUqcX+Ku7YzWNJiUFHfQ7pnqPyVcwfg1uUH IupEXCDYiLIMlCwXKJCaS/rmLR3WyiVyeJ0WiWgHfZ86I734ESJA2Do0ZqffKsKSX1xuclV D/wcjTOPOpFAhiFfWzrIg== X-UI-Out-Filterresults: notjunk:1;V01:K0:kTv16MdQKgo=:twVCsBHBqs8BJiC8eBrYar u9nhQDOsR+L7PSA0P2YMKL06jBDY1rS5yI9tBmtzwxaNre01VBjp0LMIJ6UHLrmYvsVAA4cbW cnnaG9LeIMVFsyllWKvQSo/xA4F59PylbokpDvup8jlvmG++XP0v/Wjgc7GnQ8gML5FzxckYc v1WxKIe0T+/+dUw2hSBZ80h15D+NnT4YykK+PEEOY9Pguq/f4j2/mzPdFdjtmDuE998COVjAZ +ExqTgY+LcdQQ4cI8eHMhZ+DKHPALihp+s4+ouNPFNN9oduFhaFpuriPL9KNU5c/Bp6Q7Hxa5 dyS80N5VUfk2+O4SVFacOFziFOrdU3l13SGdepjsUFfuMKYQqSkwiA8K9+toDcitT0CQwgIvM 51FfLrUWGU3igh6bwOYCAxr7fJKe29ygbt4Er4GWuDQLyEGB1BinhZ0HAhTRdfvVPF/XtOoEP E1b1okdMvNcXv7mLsBrWCqNwDJOz76dyj5VSrHPp/VHx3QRoQIQ30PaUyrQ9cDyWgtpnrJlo6 KBxhjCa9ylZ36ud8hYExYvAYX9mUv3vVuqDHUiDu/UUPYWNh4m6R58w7gbCc5NQhV4rovCc/r ElJ+XfbcqABopnDVOiFjiHU8pJ9xxBbuoB0ggXve/9MpVN3DnsdO8KxMgcMLKQal5EdTS60w5 l/30MtHUzX2Ih6YKhvRJ/YHB3HJadCErzdbfy8PpLO08C6ARESLfcpDxhNf6Lwutt6F4= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marcel Ziswiler Depending on the SPI instance one may get an interrupt storm upon requesting resp. interrupt unless the clock is explicitly enabled beforehand. This has been observed trying to bring up instance 4 on T20. Signed-off-by: Marcel Ziswiler --- drivers/spi/spi-tegra20-slink.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index 6f7b946b5ced..1427f343b39a 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c @@ -1063,6 +1063,24 @@ static int tegra_slink_probe(struct platform_device *pdev) goto exit_free_master; } + /* disabled clock may cause interrupt storm upon request */ + tspi->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(tspi->clk)) { + ret = PTR_ERR(tspi->clk); + dev_err(&pdev->dev, "Can not get clock %d\n", ret); + goto exit_free_master; + } + ret = clk_prepare(tspi->clk); + if (ret < 0) { + dev_err(&pdev->dev, "Clock prepare failed %d\n", ret); + goto exit_free_master; + } + ret = clk_enable(tspi->clk); + if (ret < 0) { + dev_err(&pdev->dev, "Clock enable failed %d\n", ret); + goto exit_free_master; + } + spi_irq = platform_get_irq(pdev, 0); tspi->irq = spi_irq; ret = request_threaded_irq(tspi->irq, tegra_slink_isr, @@ -1071,14 +1089,7 @@ static int tegra_slink_probe(struct platform_device *pdev) 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, NULL); - 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_clk_disable; } tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi"); @@ -1138,6 +1149,8 @@ static int tegra_slink_probe(struct platform_device *pdev) tegra_slink_deinit_dma_param(tspi, true); exit_free_irq: free_irq(spi_irq, tspi); +exit_clk_disable: + clk_disable(tspi->clk); exit_free_master: spi_master_put(master); return ret; @@ -1150,6 +1163,8 @@ static int tegra_slink_remove(struct platform_device *pdev) free_irq(tspi->irq, tspi); + clk_disable(tspi->clk); + if (tspi->tx_dma_chan) tegra_slink_deinit_dma_param(tspi, false);