From patchwork Wed Jun 20 07:34:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 10476779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B9F1C60532 for ; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB79728D9B for ; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FC8A28DA9; Wed, 20 Jun 2018 09:40:04 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable 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 4381028D9C for ; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750940AbeFTJjX (ORCPT ); Wed, 20 Jun 2018 05:39:23 -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-Google-Smtp-Source: ADUXVKIkUOUlbZvycuEnFK5UZg52pQWr8CDTRhUQSBINv5uvDzTpIkwxZLq5FSO9UiKqLc7T+jf6zA== 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 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: 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,