From patchwork Thu Apr 7 14:39:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Krishna Potthuri X-Patchwork-Id: 8773521 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 861039F36E for ; Thu, 7 Apr 2016 14:39:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84E202026F for ; Thu, 7 Apr 2016 14:39:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A5432026C for ; Thu, 7 Apr 2016 14:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756420AbcDGOjo (ORCPT ); Thu, 7 Apr 2016 10:39:44 -0400 Received: from mail-bl2nam02on0042.outbound.protection.outlook.com ([104.47.38.42]:31487 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754468AbcDGOjn (ORCPT ); Thu, 7 Apr 2016 10:39:43 -0400 Received: from BL2NAM02FT014.eop-nam02.prod.protection.outlook.com (10.152.76.56) by BL2NAM02HT218.eop-nam02.prod.protection.outlook.com (10.152.77.3) with Microsoft SMTP Server (TLS) id 15.1.453.6; Thu, 7 Apr 2016 14:39:41 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT014.mail.protection.outlook.com (10.152.76.154) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Thu, 7 Apr 2016 14:39:41 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:41174 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1aoB5w-0003ST-9n; Thu, 07 Apr 2016 07:39:40 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aoB5w-0005f2-6r; Thu, 07 Apr 2016 07:39:40 -0700 Received: from xsj-pvapsmtp01 (smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u37EdYIc010373; Thu, 7 Apr 2016 07:39:34 -0700 Received: from [172.23.146.172] (helo=xhdl3764.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aoB5p-0005eM-RB; Thu, 07 Apr 2016 07:39:34 -0700 Received: by xhdl3764.xilinx.com (Postfix, from userid 14964) id 0A8BE1A203D6; Thu, 7 Apr 2016 20:09:33 +0530 (IST) From: P L Sai Krishna To: Michal Simek , Soren Brinkmann , David Woodhouse , "Brian Norris" , Mark Brown , "Javier Martinez Canillas" , Boris Brezillon , Stephen Warren , Geert Uytterhoeven , "Andrew F. Davis" , Marek Vasut , Jagan Teki , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= CC: , , , , "Harini Katakam" , Punnaiah Choudary Kalluri , Anirudha Sarangi , P L Sai Krishna Subject: [LINUX PATCH v2 3/3] spi:zynqmp:gqspi: Added separate dummy entry. Date: Thu, 7 Apr 2016 20:09:29 +0530 Message-ID: <1460039969-9835-3-git-send-email-lakshmis@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1460039969-9835-1-git-send-email-lakshmis@xilinx.com> References: <1460039969-9835-1-git-send-email-lakshmis@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22244.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(5008740100001)(189998001)(106466001)(52956003)(586003)(63266004)(4001430100002)(36386004)(1096002)(92566002)(76176999)(19580405001)(4326007)(6806005)(5001770100001)(2950100001)(48376002)(87936001)(90966002)(50986999)(50466002)(1220700001)(50226001)(36756003)(107886002)(5003940100001)(86362001)(45336002)(11100500001)(229853001)(42186005)(81166005)(33646002)(103686003)(2906002)(46386002)(19580395003)(47776003)(107986001)(921003)(1121003)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT218; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ba29837c-f3c5-4273-616f-08d35ef2742c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BL2NAM02HT218; X-Microsoft-Antispam-PRVS: <1ffaa568ac164bfdbbfecc06b456a287@BL2NAM02HT218.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13018025)(5005006)(13017025)(8121501046)(13023025)(13024025)(10201501046)(3002001); SRVR:BL2NAM02HT218; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT218; X-Forefront-PRVS: 0905A6B2C7 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2016 14:39:41.0877 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT218 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch sends dummy as a separate entry. Break the Address+Cmd+dummy transfer into multiple transfers. Address+Cmd as one transfer. Dummy cycles as another transfer. As per the controller spec, immediate data field of dummy entry in the GenFifo represent dummy cycles. Bus width for dummy cycles transfer should be same as Rx bus width. Signed-off-by: P L Sai Krishna --- v2: - Replaced dummy with dummy_cycles. drivers/spi/spi-zynqmp-gqspi.c | 57 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index aab9b49..a4b109e 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -134,6 +134,9 @@ #define GQSPI_SELECT_MODE_QUADSPI 0x4 #define GQSPI_DMA_UNALIGN 0x3 #define GQSPI_DEFAULT_NUM_CS 1 /* Default number of chip selects */ +#define GQSPI_RX_BUS_WIDTH_QUAD 0x4 +#define GQSPI_RX_BUS_WIDTH_DUAL 0x2 +#define GQSPI_RX_BUS_WIDTH_SINGLE 0x1 enum mode_type {GQSPI_MODE_IO, GQSPI_MODE_DMA}; @@ -169,6 +172,7 @@ struct zynqmp_qspi { u32 genfifobus; u32 dma_rx_bytes; dma_addr_t dma_addr; + u32 rx_bus_width; u32 genfifoentry; enum mode_type mode; }; @@ -541,6 +545,35 @@ static void zynqmp_qspi_filltxfifo(struct zynqmp_qspi *xqspi, int size) } /** + * zynqmp_qspi_preparedummy: Prepares the dummy entry + * + * @xqspi: Pointer to the zynqmp_qspi structure + * @transfer: It is a pointer to the structure containing transfer data. + * @genfifoentry: genfifoentry is pointer to the variable in which + * GENFIFO mask is returned to calling function + */ +static void zynqmp_qspi_preparedummy(struct zynqmp_qspi *xqspi, + struct spi_transfer *transfer, + u32 *genfifoentry) +{ + /* For dummy Tx and Rx are NULL */ + *genfifoentry &= ~(GQSPI_GENFIFO_TX | GQSPI_GENFIFO_RX); + + /* SPI mode */ + *genfifoentry &= ~GQSPI_GENFIFO_MODE_QUADSPI; + if (xqspi->rx_bus_width == GQSPI_RX_BUS_WIDTH_QUAD) + *genfifoentry |= GQSPI_GENFIFO_MODE_QUADSPI; + else if (xqspi->rx_bus_width == GQSPI_RX_BUS_WIDTH_DUAL) + *genfifoentry |= GQSPI_GENFIFO_MODE_DUALSPI; + else + *genfifoentry |= GQSPI_GENFIFO_MODE_SPI; + + /* Immediate data */ + *genfifoentry &= ~GQSPI_GENFIFO_IMM_DATA_MASK; + *genfifoentry |= transfer->dummy_cycles; +} + +/** * zynqmp_qspi_readrxfifo: Fills the RX FIFO as long as there is room in * the FIFO. * @xqspi: Pointer to the zynqmp_qspi structure @@ -771,7 +804,7 @@ static void zynqmp_qspi_txrxsetup(struct zynqmp_qspi *xqspi, *genfifoentry |= GQSPI_GENFIFO_TX; *genfifoentry |= zynqmp_qspi_selectspimode(xqspi, transfer->tx_nbits); - xqspi->bytes_to_transfer = transfer->len; + xqspi->bytes_to_transfer = transfer->len - (transfer->dummy_cycles/8); if (xqspi->mode == GQSPI_MODE_DMA) { config_reg = zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST); @@ -832,13 +865,19 @@ static int zynqmp_qspi_start_transfer(struct spi_master *master, if (xqspi->mode == GQSPI_MODE_DMA) transfer_len = xqspi->dma_rx_bytes; else - transfer_len = transfer->len; + transfer_len = transfer->len - (transfer->dummy_cycles/8); xqspi->genfifoentry = genfifoentry; if ((transfer_len) < GQSPI_GENFIFO_IMM_DATA_MASK) { genfifoentry &= ~GQSPI_GENFIFO_IMM_DATA_MASK; genfifoentry |= transfer_len; zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry); + if (transfer->dummy_cycles) { + zynqmp_qspi_preparedummy(xqspi, transfer, + &genfifoentry); + zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, + genfifoentry); + } } else { int tempcount = transfer_len; u32 exponent = 8; /* 2^8 = 256 */ @@ -979,6 +1018,8 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) struct zynqmp_qspi *xqspi; struct resource *res; struct device *dev = &pdev->dev; + struct device_node *nc; + u32 rx_bus_width; master = spi_alloc_master(&pdev->dev, sizeof(*xqspi)); if (!master) @@ -1039,6 +1080,18 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) goto clk_dis_all; } + xqspi->rx_bus_width = GQSPI_RX_BUS_WIDTH_SINGLE; + for_each_available_child_of_node(pdev->dev.of_node, nc) { + ret = of_property_read_u32(nc, "spi-rx-bus-width", + &rx_bus_width); + if (!ret) { + xqspi->rx_bus_width = rx_bus_width; + break; + } + } + if (ret) + dev_err(dev, "rx bus width not found\n"); + master->num_chipselect = GQSPI_DEFAULT_NUM_CS; master->setup = zynqmp_qspi_setup;