Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp545910imm; Wed, 20 Jun 2018 02:40:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJjj45f5eSpPdGQJ0nLaYaWzErAExDYpRTVc16Lq4XH+Gz7bWE7u39QFU3Kx914QsDDCGet X-Received: by 2002:a63:8048:: with SMTP id j69-v6mr18301449pgd.429.1529487622798; Wed, 20 Jun 2018 02:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529487622; cv=none; d=google.com; s=arc-20160816; b=oaCPdHVyGekQi9FfFD9IG+k3fG6qHJDwMZE1TcxpfsOZ2IwEk81sz0Yq8WBWGjcUwJ L2iNHvYTMii+LuCXaZG6tr9KYxCTCv9fHdyM0+Bf5xLSfBPenuy6CIUJKg2cFeRAyBJ7 hLYBvC92WovuL7WzIBqe35W30vsICVOaPJZX0cDnPu25gtvtlvink2+SULW6zj935XXi 8NuR8tAa9qcNMPxKS5RBloZpuj0jmG0/h+mszwsOOkqqKrmCEXjWd1xnUP21xXd1PDsM NJ8UWbMPt25QFa/8FGhktl1tfW2tChlRO0TqPhYBpivpjgBbNaNXwRkFM7ILOc1LE0hm 7G1g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=b7T5Eb7TPlBIKZUbHnEFXjjKePtflLcyXADjzmV9mDk=; b=ZKHuYupOrt21J/FT1+YFkzUa156N2mg1WGvrS/H1uMbzU7MOmj6rjAd2wqJlOFT4m/ 67z3pR1PX8Thve1igzKhjpaGBPcP+IdHw8wAyB8vdOfTzUnRwxERnkHWuHuBP74W1ZBZ ZAIDtMVC2BZwUGIb/FudQwdhjwPtsuFOKgdbAz+lnmNqqOpPUx+ws1iuFFi9HQxR5ngl GGs/UnH84ZKZ3CN792F216E+WFQP7FyX8TCM7LwHVcGq3AVcwZCMdNN0NWlh8z3gpOe9 5Y/VRTJeV4UN1dKbTYmn1PjYnV3EhWzuqZgGYr6G2x+LY8yK8u1eNVjm6x4ye8QM/BoY fKwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mADI+xRK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13-v6si1696377pgn.391.2018.06.20.02.40.08; Wed, 20 Jun 2018 02:40:22 -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=fail header.i=@gmail.com header.s=20161025 header.b=mADI+xRK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754648AbeFTJjZ (ORCPT + 99 others); Wed, 20 Jun 2018 05:39:25 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34974 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754346AbeFTI3g (ORCPT ); Wed, 20 Jun 2018 04:29:36 -0400 Received: by mail-lf0-f68.google.com with SMTP id i15-v6so3644240lfc.2; Wed, 20 Jun 2018 01:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b7T5Eb7TPlBIKZUbHnEFXjjKePtflLcyXADjzmV9mDk=; b=mADI+xRKT2F+s4FgsOdm/meJxWYnws7m/IZIlc0DAG7SFH37svYmernU4gq0T31O15 5fQNEgNzStsWnqTBI6sLPU5zYQjXoewqLjeRlk2fsi/xUFksqsQ5Cl8POHqJd1EMcU3A 3v6taKPiDvjBPXfifGosFguLL/e6ak8Sd97ard9nka/WpEe6FsSn+vieB9bCz7/ytM4G jZfCQBuvYvijXuJnltmnO57ursUHF5iSg1MndE2C40bl85NFX5Lh7u8N5iqmUKmFr+qq rvpUyVeSKSgBxp4coH1qPBxDNRMxUP8c7IjZukT91AGmG8XYdM2lcLv87glEyoXHAtnm +DnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=b7T5Eb7TPlBIKZUbHnEFXjjKePtflLcyXADjzmV9mDk=; b=hBbVg/2W1sUkNt9o7i8Bq7EHdw6ay8BvaRNlUzTqWW/pSXB7QIGWkPZqExTMYXhEs9 u8Oa9Ods1MI4m8DV0vucD/kLNldUQmAJyeAhOYcsQkSn+grx4dgoFQqd2/GdZDnWPCZC fogQ5PInoKDfiE9C4ZtZGIBgLzUGsv9tOjHYtTgTyXENkd9Yebb4qImZ8fJKFFPoPQ3D O2SRNik8g45lBnww3UXWjWLIay63iJOsYcLRiECw5L0fjPNKwOKjGBy2oLLxvAV4j7wt DPHq9MZmax4rfWl7lVWKRDdfgs6qlSxS9UftBqcA3KUtzoj589+YC0xJO8v2E4XM/s64 AH2A== X-Gm-Message-State: APt69E3ASpS/TK6v7Vd2PNac7f9luNYzWT7PQ/NB25EhgFgequERQyV6 7pEhk5XLUfy/aRkgJLLhmh/C0H3M X-Received: by 2002:a19:2182:: with SMTP id h124-v6mr1230242lfh.27.1529480107951; Wed, 20 Jun 2018 00:35:07 -0700 (PDT) Received: from localhost (87-57-30-174-static.dk.customer.tdc.net. [87.57.30.174]) by smtp.gmail.com with ESMTPSA id 4-v6sm274017ljc.1.2018.06.20.00.35.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 00:35:07 -0700 (PDT) From: Esben Haabendal To: Mark Brown , linux-spi@vger.kernel.org Cc: Kurt Kanzenbach , Angelo Dureghello , Nikita Yushchenko , Sanchayan Maity , Yuan Yao , linux-kernel@vger.kernel.org, Esben Haabendal , =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= Subject: [PATCH 10/12] spi: spi-fsl-dspi: XSPI FIFO handling (in TCFQ mode) Date: Wed, 20 Jun 2018 09:34:40 +0200 Message-Id: <20180620073442.20913-11-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620073442.20913-1-esben.haabendal@gmail.com> References: <20180620073442.20913-1-esben.haabendal@gmail.com> 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 From: Esben Haabendal This implements handling of split CMD and TX FIFO queues for XSPI when running in TCFQ mode. It should be simple to add it to EOQ mode also. Currently, EOQ mode is only used with coldfire. So if coldfire DSPI supports XSPI, XSPI FIFO handling should be added to EOQ mode also. Signed-off-by: Esben Haabendal Cc: Martin Hundebøll --- drivers/spi/spi-fsl-dspi.c | 55 +++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index ba83ff4512c9..67cd2e901255 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -215,15 +215,17 @@ struct fsl_dspi { struct fsl_dspi_dma *dma; }; -static u16 dspi_pop_tx(struct fsl_dspi *dspi) +static u32 dspi_pop_tx(struct fsl_dspi *dspi) { - u16 txdata = 0; + u32 txdata = 0; if (dspi->tx) { if (dspi->bytes_per_word == 1) txdata = *(u8 *)dspi->tx; - else /* dspi->bytes_per_word == 2 */ + else if (dspi->bytes_per_word == 2) txdata = *(u16 *)dspi->tx; + else /* dspi->bytes_per_word == 4 */ + txdata = *(u32 *)dspi->tx; dspi->tx += dspi->bytes_per_word; } dspi->len -= dspi->bytes_per_word; @@ -249,8 +251,10 @@ static void dspi_push_rx(struct fsl_dspi *dspi, u32 rxdata) if (dspi->bytes_per_word == 1) *(u8 *)dspi->rx = rxdata; - else /* dspi->bytes_per_word == 2 */ + else if (dspi->bytes_per_word == 2) *(u16 *)dspi->rx = rxdata; + else /* dspi->bytes_per_word == 4 */ + *(u32 *)dspi->rx = rxdata; dspi->rx += dspi->bytes_per_word; } @@ -564,12 +568,47 @@ static void fifo_write(struct fsl_dspi *dspi) regmap_write(dspi->regmap, SPI_PUSHR, dspi_pop_tx_pushr(dspi)); } +static void cmd_fifo_write(struct fsl_dspi *dspi) +{ + u16 cmd = dspi->tx_cmd; + + if (dspi->len > 0) + cmd |= SPI_PUSHR_CMD_CONT; + regmap_write(dspi->regmap_pushr, PUSHR_CMD, cmd); +} + +static void tx_fifo_write(struct fsl_dspi *dspi, u16 txdata) +{ + regmap_write(dspi->regmap_pushr, PUSHR_TX, txdata); +} + static void dspi_tcfq_write(struct fsl_dspi *dspi) { /* Clear transfer count */ dspi->tx_cmd |= SPI_PUSHR_CMD_CTCNT; - /* Write one entry to both TX FIFO and CMD FIFO simultaneously */ - fifo_write(dspi); + + if (dspi->devtype_data->xspi_mode && dspi->bits_per_word > 16) { + /* Write two TX FIFO entries first, and then the corresponding + * CMD FIFO entry. + */ + u32 data = dspi_pop_tx(dspi); + + if (dspi->cur_chip->ctar_val & SPI_CTAR_LSBFE(1)) { + /* LSB */ + tx_fifo_write(dspi, data & 0xFFFF); + tx_fifo_write(dspi, data >> 16); + } else { + /* MSB */ + tx_fifo_write(dspi, data >> 16); + tx_fifo_write(dspi, data & 0xFFFF); + } + cmd_fifo_write(dspi); + } else { + /* Write one entry to both TX FIFO and CMD FIFO + * simultaneously. + */ + fifo_write(dspi); + } } static u32 fifo_read(struct fsl_dspi *dspi) @@ -656,8 +695,10 @@ static int dspi_transfer_one_message(struct spi_master *master, dspi->bits_per_word = transfer->bits_per_word; if (transfer->bits_per_word <= 8) dspi->bytes_per_word = 1; - else + else if (transfer->bits_per_word <= 16) dspi->bytes_per_word = 2; + else + dspi->bytes_per_word = 4; regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, -- 2.17.1