From patchwork Wed Apr 27 08:12:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yao yuan X-Patchwork-Id: 8953521 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 09917BF29F for ; Wed, 27 Apr 2016 08:37:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCEBD20114 for ; Wed, 27 Apr 2016 08:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86AF6200F0 for ; Wed, 27 Apr 2016 08:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750721AbcD0IhO (ORCPT ); Wed, 27 Apr 2016 04:37:14 -0400 Received: from mail-bn1bon0145.outbound.protection.outlook.com ([157.56.111.145]:62680 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750747AbcD0IhK (ORCPT ); Wed, 27 Apr 2016 04:37:10 -0400 X-Greylist: delayed 894 seconds by postgrey-1.27 at vger.kernel.org; Wed, 27 Apr 2016 04:37:10 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freescale.onmicrosoft.com; s=selector1-freescale-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=H5VZPK8rc1Kt35eDndfqxiNHq6FBQNZr8PHxw1KWh2w=; b=W7O43NmzJQE95/0X/x//X+QBtFDls04gjceHhoePa67DR46PfyGppo0Jaz/GV9JFDpjTr5IXION97ZLck+fJ3ph2tslM4K5raY/awSewnztTHnUW0Ku/e0ByvO3AXCdZD+BFMV3S167WPRS++mnGI7WQk1yFJvzdxT7Z8z+UDQ0= Received: from BLUPR03CA009.namprd03.prod.outlook.com (10.255.124.26) by BY1PR0301MB0870.namprd03.prod.outlook.com (10.160.194.140) with Microsoft SMTP Server (TLS) id 15.1.466.19; Wed, 27 Apr 2016 08:22:11 +0000 Received: from BL2FFO11FD035.protection.gbl (10.255.124.4) by BLUPR03CA009.outlook.office365.com (10.255.124.26) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Wed, 27 Apr 2016 08:22:11 +0000 Authentication-Results: spf=neutral (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Neutral (protection.outlook.com: 192.88.168.50 is neither permitted nor denied by domain of freescale.com) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD035.mail.protection.outlook.com (10.173.161.131) with Microsoft SMTP Server (TLS) id 15.1.477.4 via Frontend Transport; Wed, 27 Apr 2016 08:22:11 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u3R8M1Da010064; Wed, 27 Apr 2016 01:22:07 -0700 From: Yuan Yao To: , , , , , , , CC: , Subject: [PATCH 1/2] spi: spi-fsl-dspi: replace regmap R/W with internal implementation Date: Wed, 27 Apr 2016 16:12:35 +0800 Message-ID: <1461744756-31481-2-git-send-email-yao.yuan@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1461744756-31481-1-git-send-email-yao.yuan@freescale.com> References: <1461744756-31481-1-git-send-email-yao.yuan@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(199003)(189002)(2950100001)(92566002)(105586002)(230783001)(2906002)(586003)(50986999)(19580405001)(50226002)(104016004)(77096005)(5008740100001)(19580395003)(5003940100001)(76176999)(36756003)(50466002)(5001770100001)(86362001)(81166005)(11100500001)(189998001)(6806005)(48376002)(4326007)(87936001)(2201001)(1096002)(106466001)(229853001)(33646002)(1220700001)(47776003)(7059030)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0301MB0870; H:tx30smr01.am.freescale.net; FPR:; SPF:Neutral; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD035; 1:vbezGbF5XvYIuTFczs1rkZ/Fjqln9+uBmQXZ+dlN+GXEv7boQHh61epRMoMkTka41vPelmEUckwBE9N6+0vEedFxF/f3QsVdH3BDJ+jOQ7S5DaUZzA/hB3P4CXdo8jzjTF5sNiL6TL5GqZ9rd4znr5oEPr293wpMYEmlaoIm9pXguLSStWAqA9IXsVOy1qHO43nnZ5gcqRGzZJGwyA5FWk/9i6/SypItqkEbzEszJP2YoXoSB6BABvnrRqbF04Znye6Ljhrlvu0huwIdN0EaBAVJgQ7IELr79M0KHLe5hLiSNyW7f+G+RP9hn/1XHa9w3ptsMpELVPlqAOf/sR2rUniA/5Xln5/qkVGnBhu7BNprZbqXkXVol1yznMkkk8OHXSM2ym8D3BDTqXsBQrf5OsD5jBaWn7Hc9qGknehvRQVxMm3BG1mCJ3ke15tXgw8jMZO+EnXmaevFMPml3dMNu0dqF7oMNYYXUIQAFGw8lv/OwHSnprfk1idASrSJGICynHXr2e9HxFCT/Y7af7f77Xk1r3TZx1E0Au8S2UbfDDz02ft8YD50RASCtgyihrGQ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 25eb64de-9fd1-4026-18f0-08d36e7507f3 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0870; 2:GQ+FIFkpW6m9j4q1YHs0BvUsxbZN6+1HOkx1WzVQc0WD/vD0ynIiCmadOn7PD8WWRsTJV3TtkwzLFs7FvtV9VbfF1XIY9zm+1CjtDN7pV7vPC9lu8BvFA7HB+a5FuBuIIqsd2GmoOWfIvTdGYMkZdV4KgHxFiv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9eCDCXPk/WmTlf4JSQIhvU0QkA8hH8HfBo+5wZm7CBRMF4q/tCs0eRrui+WjZfvcdMdPEv3OyQ8kArK6iP6clrZF9bvMdwyf3s5CEgBPOUksU5ZSiqgCAmp9LBJtdQoPSiqEdGGR8; 4:3RqlVEOy7MeNAIagQ26QXlk5FbnNGZ24D9gbVWR57/XmuAia2VW85m72NKen7U+rSbJjhL0AJSwTeKF0XleM6zc1X3qAGVXN4GiDp4ctEtkG0xIqNFGvjFRXuQU3fYYzBWz/gdjhDATaihCO0ekrzGfELekcB+8qERiaLXjEUqYbCoJcdXz3ABwWJVcFv/dfS3UQT0PA5lYhV4sUmZvsJDDxeuPEXzK8hl16j7C7EUTbZmOIiFuIFflWhG2+aHD9L0OGshIdN2ukNv2seAreNPFPM9G4d7cu9EOsErf51tx4J+kbo3g1d8VBfL5rtCEIj5BkISDKF/UFpJnImIxEClr70Jrwe1DtnVUSOWcIos+lD6M/a/zh+NjGABWBfQesvdcRhxH8WtY+Gb7DmqTfOLcbW7PGrR+DX/nIkx4/NLK2jJKd0sBwIxnmb8KVzC+nFWevI7JNqN9nXInD3q81BzUPWAQjmWiKaqTP 0wWTyCLHrBpUY1yRs40qI7EtgNEm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521072)(601004)(2401047)(13017025)(5005006)(13018025)(13023025)(13024025)(8121501046)(13015025)(10201501046)(3002001)(6055026); SRVR:BY1PR0301MB0870; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0301MB0870; X-Forefront-PRVS: 0925081676 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0301MB0870; 23:3TCKIpAhj2KA1fXnHdQJXpaY7Vmgcmn7wwIiDfY?= =?us-ascii?Q?dNc87yu74x7N34jlsx7cTiwIbI4IYdcbwhvJejKYgjw7BCJ1ay7wqFUjaFd5?= =?us-ascii?Q?C4L/+eF3Ij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liFJo2/KDCTmK7Fr?= =?us-ascii?Q?Qukr9B1ddzio3CqlEn8On1FMuTJbDEdUSjwjmj1/+/YF+OA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB0870; 5:3vUomtLWbLtp/u6NTTdE6vSCMYh07MOPcJmLISYQVqcFIKdVVY1WCpv7G9bbdZoIrwiMcjppskjfWtteSKCyvLpPVL5KgiTDARS2Qk6gwj6ZeYkui0w4UQVwJ283+s6Gf/9ikLAm07xhDQDniXLQJzkWf6PmcCDylST3SITKGts687yIyGMrp7AjOtr/aRiE; 24:7QDf6wImDr4rNGfYj6U3sFfNVii7RBSbbrB875nYBctf96m8TGF+c7Q/zEIdT8e1LR6IYjOGyMgq1lh/aFXlmfdyzxI5zi8RbzStiTrfKq0=; 7:lWT55QLhb1Bt67JMP2DxZprAPticiNcXsrUS4ve3xdbVKcLILMAPvATyi8F3tOO++zCpGPgygXZyRdMYnqQuqeDlchsztDMclGkJkKGogj82/j4i+S7eXumy20v9h7eko9EvIyuHZsfQc7uSLMtBUedG0QYLAvSxz+Zf6GGQtQr84JkggjcQpvmyNig3+RQOMlZb+2YhZmE7QZx4fHMDw5kVhA69ReBbIwEA4lqghyU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2016 08:22:11.1257 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB0870 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Yuan Yao The qSPI controller's endian is independent of the CPU core's endian. For eg, Core on NXP LS1043A SoC is little endian but DSPI is big endian whereas Core on LS2080A SoC is little endian and DSPI also is little endian on the same core. At first we use regmap to cover this issue. But the regmap is designed too large and complex. The issue for regmap often effect the DSPI's stability. DSPI driver just only need a effective way to R/W the controller register with BE or LE mode. So it's better to packaging a sample function. This will make the DSPI driver more stability and high effective. Signed-off-by: Yuan Yao --- drivers/spi/spi-fsl-dspi.c | 99 +++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 9e9dadb..9a61572 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -143,7 +142,7 @@ struct fsl_dspi { struct spi_master *master; struct platform_device *pdev; - struct regmap *regmap; + void __iomem *iobase; int irq; struct clk *clk; @@ -165,13 +164,46 @@ struct fsl_dspi { u32 waitflags; u32 spi_tcnt; + bool big_endian; }; +/* + * R/W functions for big- or little-endian registers: + * The qSPI controller's endian is independent of the CPU core's endian. + */ +static void dspi_writel(struct fsl_dspi *d, u32 val, u32 offset) +{ + if (d->big_endian) + iowrite32be(val, d->iobase + offset); + else + iowrite32(val, d->iobase + offset); +} + +static u32 dspi_readl(struct fsl_dspi *d, u32 offset) +{ + if (d->big_endian) + return ioread32be(d->iobase + offset); + else + return ioread32(d->iobase + offset); +} + +static void dspi_updatel(struct fsl_dspi *d, u32 mask, u32 val, u32 offset) +{ + u32 tmp, orig; + + orig = dspi_readl(d, offset); + + tmp = orig & ~mask; + tmp |= val & mask; + + dspi_writel(d, tmp, offset); +} + static inline int is_double_byte_mode(struct fsl_dspi *dspi) { unsigned int val; - regmap_read(dspi->regmap, SPI_CTAR(0), &val); + val = dspi_readl(dspi, SPI_CTAR(0)); return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1; } @@ -270,7 +302,7 @@ static void dspi_data_from_popr(struct fsl_dspi *dspi, int rx_word) u16 d; unsigned int val; - regmap_read(dspi->regmap, SPI_POPR, &val); + val = dspi_readl(dspi, SPI_POPR); d = SPI_POPR_RXDATA(val); if (!(dspi->dataflags & TRAN_STATE_RX_VOID)) @@ -294,8 +326,8 @@ static int dspi_eoq_write(struct fsl_dspi *dspi) */ if (tx_word && (dspi->len == 1)) { dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; - regmap_update_bits(dspi->regmap, SPI_CTAR(0), - SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); + dspi_updatel(dspi, SPI_FRAME_BITS_MASK, + SPI_FRAME_BITS(8), SPI_CTAR(0)); tx_word = 0; } @@ -309,7 +341,7 @@ static int dspi_eoq_write(struct fsl_dspi *dspi) } else if (tx_word && (dspi->len == 1)) dspi_pushr |= SPI_PUSHR_EOQ; - regmap_write(dspi->regmap, SPI_PUSHR, dspi_pushr); + dspi_writel(dspi, dspi_pushr, SPI_PUSHR); tx_count++; } @@ -343,8 +375,8 @@ static int dspi_tcfq_write(struct fsl_dspi *dspi) if (tx_word && (dspi->len == 1)) { dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; - regmap_update_bits(dspi->regmap, SPI_CTAR(0), - SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); + dspi_updatel(dspi, SPI_FRAME_BITS_MASK, + SPI_FRAME_BITS(8), SPI_CTAR(0)); tx_word = 0; } @@ -353,7 +385,7 @@ static int dspi_tcfq_write(struct fsl_dspi *dspi) if ((dspi->cs_change) && (!dspi->len)) dspi_pushr &= ~SPI_PUSHR_CONT; - regmap_write(dspi->regmap, SPI_PUSHR, dspi_pushr); + dspi_writel(dspi, dspi_pushr, SPI_PUSHR); return tx_word + 1; } @@ -378,7 +410,7 @@ static int dspi_transfer_one_message(struct spi_master *master, enum dspi_trans_mode trans_mode; u32 spi_tcr; - regmap_read(dspi->regmap, SPI_TCR, &spi_tcr); + spi_tcr = dspi_readl(dspi, SPI_TCR); dspi->spi_tcnt = SPI_TCR_GET_TCNT(spi_tcr); message->actual_length = 0; @@ -407,21 +439,19 @@ static int dspi_transfer_one_message(struct spi_master *master, if (!dspi->tx) dspi->dataflags |= TRAN_STATE_TX_VOID; - regmap_write(dspi->regmap, SPI_MCR, dspi->cur_chip->mcr_val); - regmap_update_bits(dspi->regmap, SPI_MCR, - SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, - SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); - regmap_write(dspi->regmap, SPI_CTAR(0), - dspi->cur_chip->ctar_val); + dspi_writel(dspi, dspi->cur_chip->mcr_val, SPI_MCR); + dspi_updatel(dspi, SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, + SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, SPI_MCR); + dspi_writel(dspi, dspi->cur_chip->ctar_val, SPI_CTAR(0)); trans_mode = dspi->devtype_data->trans_mode; switch (trans_mode) { case DSPI_EOQ_MODE: - regmap_write(dspi->regmap, SPI_RSER, SPI_RSER_EOQFE); + dspi_writel(dspi, SPI_RSER_EOQFE, SPI_RSER); dspi_eoq_write(dspi); break; case DSPI_TCFQ_MODE: - regmap_write(dspi->regmap, SPI_RSER, SPI_RSER_TCFQE); + dspi_writel(dspi, SPI_RSER_TCFQE, SPI_RSER); dspi_tcfq_write(dspi); break; default: @@ -525,14 +555,14 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id) u32 spi_tcnt, tcnt_diff; int tx_word; - regmap_read(dspi->regmap, SPI_SR, &spi_sr); - regmap_write(dspi->regmap, SPI_SR, spi_sr); + spi_sr = dspi_readl(dspi, SPI_SR); + dspi_writel(dspi, spi_sr, SPI_SR); if (spi_sr & (SPI_SR_EOQF | SPI_SR_TCFQF)) { tx_word = is_double_byte_mode(dspi); - regmap_read(dspi->regmap, SPI_TCR, &spi_tcr); + spi_tcr = dspi_readl(dspi, SPI_TCR); spi_tcnt = SPI_TCR_GET_TCNT(spi_tcr); /* * The width of SPI Transfer Counter in SPI_TCR is 16bits, @@ -569,10 +599,10 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id) if (!dspi->len) { if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) { - regmap_update_bits(dspi->regmap, - SPI_CTAR(0), - SPI_FRAME_BITS_MASK, - SPI_FRAME_BITS(16)); + dspi_updatel(dspi, + SPI_FRAME_BITS_MASK, + SPI_FRAME_BITS(16), + SPI_CTAR(0)); dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM; } @@ -636,13 +666,6 @@ static int dspi_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(dspi_pm, dspi_suspend, dspi_resume); -static const struct regmap_config dspi_regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - .max_register = 0x88, -}; - static int dspi_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -700,13 +723,7 @@ static int dspi_probe(struct platform_device *pdev) goto out_master_put; } - dspi->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base, - &dspi_regmap_config); - if (IS_ERR(dspi->regmap)) { - dev_err(&pdev->dev, "failed to init regmap: %ld\n", - PTR_ERR(dspi->regmap)); - return PTR_ERR(dspi->regmap); - } + dspi->iobase = base; dspi->irq = platform_get_irq(pdev, 0); if (dspi->irq < 0) { @@ -730,6 +747,8 @@ static int dspi_probe(struct platform_device *pdev) } clk_prepare_enable(dspi->clk); + dspi->big_endian = of_property_read_bool(np, "big-endian"); + master->max_speed_hz = clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor;