Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp145042imj; Wed, 13 Feb 2019 06:08:15 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaem3itfSfPbl+p2AC0u9guWKrtR+QWBBS08V9qf8hayyBiLvcmdtG+OHi16Ikp6jhIHNKl X-Received: by 2002:a17:902:a415:: with SMTP id p21mr723352plq.7.1550066895813; Wed, 13 Feb 2019 06:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550066895; cv=none; d=google.com; s=arc-20160816; b=lrnXFeWYy9LqsuOyBNiB6mdo6kyxi7N4AYzjIrswWoVt1VrKqc3aXsrTYDhqIEm/j7 dNU9RzNfVb2/RwbSV/zykhLxEWFYG39me1F+4cbik3wfHdyKThYTA4A1QHUfCkaRI60X 6e8a9UBO40RA1loIEXB6lcEl9q6fdqj0fvzK7ba7pts41btlJK97PeWNQidLoYDCm5NH ubLKsolzASmLPYfv6PG6McpdlDF6bByNSI1vyuEoKtpUvYcawTNPbxVB8/pQajpTrSlm ZJ8tlw8XemCn0MZ2qr9NuTicjbvz5wBHWb5TzSoYKwURuTQKYQqA7tAg+iGIKjB475wF Sulw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=LdotbfTAEmUXoCKivs7r4R0xmwabJi3UspttoM6IPwQ=; b=ZG+Kwp65LX9gz2hLwMqpEjATx+aX8OMUPy6eYW1AcYDT1aOWz4vqZSFjID2vHofPed tRUPdFxvCk3DTa0nRNkBMBfgH3Ga5x7BYIs0kHwele6rENxu6TckRrDy0jT9kAvfe0GB XCsYU6uzxmrz1EopSa6lZpOFk9+nyfnqK80EsJVv9obQLK4G1UJxp20BDXajN7m3c7rp OUVCPOSF7ZDNdFnwNA8/zX8sH1LYg5S6Y+oH9jfAT1pc9iJqx1dO1WlRI4pUgh/nK4Od cJ8XCOXbhFavePcE9m8vjnPO7cLI0xEq5j6gjjgrDvMrmUwAvtOzizXeB4qkbrj0U4I+ LxWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Qp+0P6fJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c142si16446154pfb.33.2019.02.13.06.07.57; Wed, 13 Feb 2019 06:08:15 -0800 (PST) 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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Qp+0P6fJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404114AbfBMMcC (ORCPT + 99 others); Wed, 13 Feb 2019 07:32:02 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:57612 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730650AbfBMMcC (ORCPT ); Wed, 13 Feb 2019 07:32:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=LdotbfTAEmUXoCKivs7r4R0xmwabJi3UspttoM6IPwQ=; b=Qp+0P6fJ6M66 JphzCT5I9cN4GxtO1VrykpREKY3gs6hqNB9ogw2ND8vzLL5UOl2sQw8NSANxKy3laJWGs8ekH/9hI znelbBye0n7vSnxvvNGz9ZZpAKbPlPPVcpqPxmY9yUO3bVwUeFut/hP/xk3kO+qa/YmQA66ON/B+S DmFKc=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1gtthl-0004JW-0R; Wed, 13 Feb 2019 12:31:57 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 8AC751128159; Wed, 13 Feb 2019 12:31:56 +0000 (GMT) From: Mark Brown To: Lanqing Liu Cc: Baolin Wang , Mark Brown , broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, lanqing.liu@unisoc.com, baolin.wang@linaro.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: Applied "spi: sprd: Add the SPI irq function for the SPI DMA mode" to the spi tree In-Reply-To: <11e55b5f9b0d83649a5b81c7e3fdb667cd3ddc5b.1550043082.git.baolin.wang@linaro.org> X-Patchwork-Hint: ignore Message-Id: <20190213123156.8AC751128159@debutante.sirena.org.uk> Date: Wed, 13 Feb 2019 12:31:56 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch spi: sprd: Add the SPI irq function for the SPI DMA mode has been applied to the spi tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From de082d866cced9e172ca909b084f91df631ae7fe Mon Sep 17 00:00:00 2001 From: Lanqing Liu Date: Wed, 13 Feb 2019 15:36:09 +0800 Subject: [PATCH] spi: sprd: Add the SPI irq function for the SPI DMA mode The SPI irq event will use to complete the SPI work in the SPI DMA mode, so this patch is a preparation for the following DMA mode support. Moreover the SPI interrupt can be fired when removing the SPI controller, so we should make sure the SPI controller has stopped the queue in remove function before freeing the SPI irq. Signed-off-by: Lanqing Liu Signed-off-by: Baolin Wang Signed-off-by: Mark Brown --- drivers/spi/spi-sprd.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c index 8daa24eec624..06578412b04d 100644 --- a/drivers/spi/spi-sprd.c +++ b/drivers/spi/spi-sprd.c @@ -133,6 +133,7 @@ struct sprd_spi { void __iomem *base; struct device *dev; struct clk *clk; + int irq; u32 src_clk; u32 hw_mode; u32 trans_len; @@ -141,6 +142,7 @@ struct sprd_spi { u32 hw_speed_hz; u32 len; int status; + struct completion xfer_completion; const void *tx_buf; void *rx_buf; int (*read_bufs)(struct sprd_spi *ss, u32 len); @@ -573,6 +575,48 @@ static int sprd_spi_transfer_one(struct spi_controller *sctlr, return ret; } +static irqreturn_t sprd_spi_handle_irq(int irq, void *data) +{ + struct sprd_spi *ss = (struct sprd_spi *)data; + u32 val = readl_relaxed(ss->base + SPRD_SPI_INT_MASK_STS); + + if (val & SPRD_SPI_MASK_TX_END) { + writel_relaxed(SPRD_SPI_TX_END_CLR, ss->base + SPRD_SPI_INT_CLR); + if (!(ss->trans_mode & SPRD_SPI_RX_MODE)) + complete(&ss->xfer_completion); + + return IRQ_HANDLED; + } + + if (val & SPRD_SPI_MASK_RX_END) { + writel_relaxed(SPRD_SPI_RX_END_CLR, ss->base + SPRD_SPI_INT_CLR); + complete(&ss->xfer_completion); + + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int sprd_spi_irq_init(struct platform_device *pdev, struct sprd_spi *ss) +{ + int ret; + + ss->irq = platform_get_irq(pdev, 0); + if (ss->irq < 0) { + dev_err(&pdev->dev, "failed to get irq resource\n"); + return ss->irq; + } + + ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq, + 0, pdev->name, ss); + if (ret) + dev_err(&pdev->dev, "failed to request spi irq %d, ret = %d\n", + ss->irq, ret); + + return ret; +} + static int sprd_spi_clk_init(struct platform_device *pdev, struct sprd_spi *ss) { struct clk *clk_spi, *clk_parent; @@ -633,11 +677,16 @@ static int sprd_spi_probe(struct platform_device *pdev) sctlr->max_speed_hz = min_t(u32, ss->src_clk >> 1, SPRD_SPI_MAX_SPEED_HZ); + init_completion(&ss->xfer_completion); platform_set_drvdata(pdev, sctlr); ret = sprd_spi_clk_init(pdev, ss); if (ret) goto free_controller; + ret = sprd_spi_irq_init(pdev, ss); + if (ret) + goto free_controller; + ret = clk_prepare_enable(ss->clk); if (ret) goto free_controller; @@ -688,6 +737,8 @@ static int sprd_spi_remove(struct platform_device *pdev) return ret; } + spi_controller_suspend(sctlr); + clk_disable_unprepare(ss->clk); pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); -- 2.20.1