Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1440443ybn; Wed, 25 Sep 2019 18:34:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMLoHhEsVOm+gHRtrqcj8FwCqNIj2eSonQJ3pKFMsr07UiqB/WCmv/zVHPS/AI9z4XRJ69 X-Received: by 2002:a17:906:b259:: with SMTP id ce25mr930890ejb.229.1569461668941; Wed, 25 Sep 2019 18:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569461668; cv=none; d=google.com; s=arc-20160816; b=FSVog6PlrIsAfzwCPOTivdnc0t6AiBKRB9Ps+XpTbHyA13jowWcnRH29u/OjB3EQMO TEv/Sk/XnErerjw4fjMCZWiq+WlSaTBrEimcJHKiVoJ6DbAzf8WVpT71OPrijOu5DcF/ ec6boJSOaomN89SM18KF5tVO+6wEalrIsvQYIh075cw6r2KGUuyBZqQFDmBccj2vAoLF PRiWDoZjCw5wM+uoDNY1xfH8r5lZQvXo+HHWUUzMf3luJUriDRRf0n6eqBvnkQPEe6Lx HrW/MoaqW9EEf9idN+D4TCm1xylYqkJuhWcdHkC+4S+Juuld4nngOjH6vQY7ttBuqO3Y qOTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=a5ziLufIxYb6XAKGSgd/zUbYRGQzSpTXW84x6NJSdgs=; b=eMgGZ0XmD1Oeh0da0O9arPSt5qsTeTWcu1U0dzFjlm2dm9kJ63o39VnNlT7OxSEC/8 ds2SdVnsgozr1lqsljDm6j1TwcR/pK9wr8TuXVlp7LMSQW2H7B0ZHd0y+++QuzwtyH3f d3zgGk9vYN84hfyIbYJO2HE52xVwGb0FsPY28OhCctrZaSWLlHlqAwPCMOiXL1VLEGDy pkpd1qHRWQkMJVa7TFY33zpJ7aWvodIuMvfhpcGNMaX8zdxICSpe2FQGEtyLnpA1LomB FT5Xoh+BaplPuX6ZC3tTf0/3D5jnnr/hcWI34B6GSjGvHfULqv5T+yyeN34Y6Dmoj41Y aUJA== 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 x25si450605edd.350.2019.09.25.18.34.05; Wed, 25 Sep 2019 18:34:28 -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 S2504601AbfIXLGH (ORCPT + 99 others); Tue, 24 Sep 2019 07:06:07 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:49980 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440787AbfIXLGG (ORCPT ); Tue, 24 Sep 2019 07:06:06 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 46cyzc5kdSz1rfPb; Tue, 24 Sep 2019 13:06:04 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 46cyzc5Ccnz1qqkG; Tue, 24 Sep 2019 13:06:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id KSEhBv7eP1Lw; Tue, 24 Sep 2019 13:06:03 +0200 (CEST) X-Auth-Info: eyM5Q0Dr3N3YNpW8ob4ovzSqRloWo3F6apmpXF6YFyQ= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 24 Sep 2019 13:06:03 +0200 (CEST) From: Lukasz Majewski To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, krzk@kernel.org, Lukasz Majewski Subject: [PATCH 2/2] spi: Introduce dspi_slave_abort() function for NXP's dspi SPI driver Date: Tue, 24 Sep 2019 13:05:47 +0200 Message-Id: <20190924110547.14770-3-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190924110547.14770-1-lukma@denx.de> References: <20190924110547.14770-1-lukma@denx.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change provides the dspi_slave_abort() function, which is a callback for slave_abort() method of SPI controller generic driver. As in the SPI slave mode the transmission is driven by master, any distortion may cause the slave to enter undefined internal state. To avoid this problem the dspi_slave_abort() terminates all pending and ongoing DMA transactions (with sync) and clears internal FIFOs. Signed-off-by: Lukasz Majewski --- drivers/spi/spi-fsl-dspi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index bec758e978fb..2c0f211eed87 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -1006,6 +1006,25 @@ static void dspi_init(struct fsl_dspi *dspi) SPI_CTARE_FMSZE(0) | SPI_CTARE_DTCP(1)); } +static int dspi_slave_abort(struct spi_master *master) +{ + struct fsl_dspi *dspi = spi_master_get_devdata(master); + + /* + * Terminate all pending DMA transactions for the SPI working + * in SLAVE mode. + */ + dmaengine_terminate_sync(dspi->dma->chan_rx); + dmaengine_terminate_sync(dspi->dma->chan_tx); + + /* Clear the internal DSPI RX and TX FIFO buffers */ + regmap_update_bits(dspi->regmap, SPI_MCR, + SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, + SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); + + return 0; +} + static int dspi_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1030,6 +1049,7 @@ static int dspi_probe(struct platform_device *pdev) ctlr->dev.of_node = pdev->dev.of_node; ctlr->cleanup = dspi_cleanup; + ctlr->slave_abort = dspi_slave_abort; ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; pdata = dev_get_platdata(&pdev->dev); -- 2.20.1