From patchwork Mon May 11 17:32:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 11540095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86F66186E for ; Mon, 11 May 2020 09:33:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64D2C2495C for ; Mon, 11 May 2020 09:33:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Z18v/fDu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbgEKJdH (ORCPT ); Mon, 11 May 2020 05:33:07 -0400 Received: from mail-eopbgr00074.outbound.protection.outlook.com ([40.107.0.74]:62113 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729305AbgEKJdG (ORCPT ); Mon, 11 May 2020 05:33:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IkAh9+MoLzJjTtIH9R9PMIb4T9GlDpaT5JLS2Zy9owHj3EZyq7WaIe5BGkpfauhV3rvqN5WH9LyOmXxFH0AvR60dNaC5A8imkWzBinGeN+yyf097wI/e66bh25AoGi/SjnmMSkRPF7RZUVOKJ72bsiPn2egCMMxOold9mj0tpS3Zxxksik57/5+qbrJYyFinIdV+DUTDlR+9KoQa1UelapvZ58GiygA3yvJDfH/8VldW1J7WXohK5aoD5+weRQww8xnoDXRfOEldeTDnbVg+s/GNRxPltWWtSXrdoQp+/rPwedrMmgp81r26k5BqAMjmwsinTAuzWRZ9p9Gd1d10/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DqmLvhcU+jWUPBsc+Lha7GCOZUjE8UdZPd2ceh3CHTM=; b=MDcH98dVTWSLKc4tKexz8ARlVX9N6SLPQFrvSOY4m4NFLYx4rVsZwuhVb4XNOKwP254sq46DPFCxHHTq/S17XlW+kX/LmiYkBG94Bhd+YB5pEICpGtYICYgk+srxIdfwhyshofi1ADgx6C/JHgHKzVYZiIHTGmupVTSIUVeCp6FytlXLxkMoI6Xy0kQXre6hK8+g0W3I3fcWtkflLyJrvml2cS+RG9GjZCn9YHv2pD8DFmltRZqiOxplRF9vlq3qx4CDBUe4VF33BrgGUHGmJS3L2m0RLqxXVphwqztVhoQXOo87/9mXviatlpzHTREYaHRhtYGVflFx/c2UepQehA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DqmLvhcU+jWUPBsc+Lha7GCOZUjE8UdZPd2ceh3CHTM=; b=Z18v/fDuhErIuTor3K0jjYK9ePx5hLYZMVQn4XS8FzD1+4u5bsiAdzFNvPo49X5cmL5jKTU/8VZG77FYhN33j1wkXL9cMl/qU1gY/Bm3Z8ojrDCDJimDJ+awvf9HNwyxQEzVaNsq0FeXt8XdTrKW5K/tXBbDxNHs154CRMCy2Yg= Authentication-Results: pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6638.eurprd04.prod.outlook.com (2603:10a6:803:119::15) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Mon, 11 May 2020 09:33:02 +0000 Received: from VE1PR04MB6638.eurprd04.prod.outlook.com ([fe80::d5f0:c948:6ab0:c2aa]) by VE1PR04MB6638.eurprd04.prod.outlook.com ([fe80::d5f0:c948:6ab0:c2aa%4]) with mapi id 15.20.2979.033; Mon, 11 May 2020 09:33:02 +0000 From: Robin Gong To: s.hauer@pengutronix.de, vkoul@kernel.org, shawnguo@kernel.org, u.kleine-koenig@pengutronix.de, robh+dt@kernel.org, festevam@gmail.com, dan.j.williams@intel.com, mark.rutland@arm.com, catalin.marinas@arm.com Cc: will.deacon@arm.com, l.stach@pengutronix.de, martin.fuzzey@flowbird.group, kernel@pengutronix.de, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, dmaengine@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v7 RESEND 08/13] spi: imx: remove ERR009165 workaround on i.mx6ul Date: Tue, 12 May 2020 01:32:31 +0800 Message-Id: <1589218356-17475-9-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589218356-17475-1-git-send-email-yibin.gong@nxp.com> References: <1589218356-17475-1-git-send-email-yibin.gong@nxp.com> X-ClientProxiedBy: SG2PR06CA0141.apcprd06.prod.outlook.com (2603:1096:1:1f::19) To VE1PR04MB6638.eurprd04.prod.outlook.com (2603:10a6:803:119::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by SG2PR06CA0141.apcprd06.prod.outlook.com (2603:1096:1:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 09:32:57 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0179bdb5-ac81-45f0-63de-08d7f58e4d12 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637:|VE1PR04MB6637: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LSFy9/2sBLH77vt4Yb9Dy+eUtR3QjNjtBoz1DMBUSoEYDtP4OscP3hg2bzjIhF1nUUdNNDr32Z8Pj1jogyPmPdA+uGLA8+FFHGYUmxQkavZez6CYanMNU576UuxnTFaxxKlREeTTRDov71aQ/wESCDllB+pRU2j9xo8Gw9S/TG9m0omSdOQFVXg4T7oSnV3D9AMr/oFwXmTAm08UgxViH6wAMcwsqwCeNR7NdF/ceBgGiyKJEjywKSkqOU6wYb7315Gf3CR75IYeOYpwR440fqpoTprw/sWLG5GIgICQ7lx6iUORkl6kLenFL2YduFDGLSRRj524lePJNz2wDh9mVaiw//BbHRaaw+HQP9Xe+Co77gq27QaJNsBnhyTC2UDt8nY1hwoJJpS5ViaAAfdWD4krzBbUsBuYoD1noBPPB2297qFlf5R0DHWtnThx/OLIQivrNHDGy3nXks0LYnGkUUyTOHvugOKKdDdexK8cC6/QsSSDFjB3SN+a1ESAj1encdaxRP8O6mqZiTPwDbUKfv132X5ceRByUOh9MhVsPiK9YVnYztJoBlGVC9XIU9F3ytEu4RRRXaCScwM9GDk1+SYIVBa0KQ2koUf93HUpO4s= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6638.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(136003)(376002)(346002)(396003)(366004)(33430700001)(8936002)(26005)(52116002)(6506007)(16526019)(2616005)(186003)(956004)(6666004)(6512007)(7416002)(5660300002)(2906002)(4326008)(6486002)(33440700001)(66476007)(8676002)(66946007)(66556008)(478600001)(86362001)(316002)(966005)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7uOLGZKMkzCdojMrw4J9pU04bVZWSfYm8deUHoqGyLPm2AwuNGssxk6iuMh/rlruJzFVm5cm4sw0kuvCEGnOjE8Us2h2OLYUdzfbabgYbWRuTh/LJHfSTA38nqg9e5tGJUCjbtCaVbPXfKBNc+FuKUpQw9wQWU8+Pjkq8GPRCIPwqf2Nzk5adfjUQ9J0jJJhRpm907Szlc37PpXzgC5gUgKDTe6mRcdO3m4GrIwaPbdX0/9di5qF/fHUI+aGK7mDESqcLrQjmR+izH8SZzOlAtspulTNUBt4W5sYboMA1ChADCx+tGbHBqd8GxhDJoAQbOedxiI5q54u7gGUbAedJcEQ/ezq30wfn7KRf5SpGvHoLiD3ZNkZscf/EOiMH20XelO3utwpDSm78l7THlSvyobLBWztzC8VIhOkj2Aqi1AiZAHCKEu9DLt9ZKpz4/QxGqEo3AyXZw2GQvvUONinYTPk5UvRZ2g+0DIxi+xFgpk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0179bdb5-ac81-45f0-63de-08d7f58e4d12 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 09:33:02.5125 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RNr9AV7u/9RjQxq77BwHEscpTgSj/og0+kUHXnpbV4IcsAezqeELraMMBV2untuEGgvWmmIRs205UxJSedwpfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org ERR009165 fixed on i.mx6ul/6ull/6sll. All other i.mx6/7 and i.mx8m/8mm still need this errata. Please refer to nxp official errata document from https://www.nxp.com/ . For removing workaround on those chips. Add new i.mx6ul type. Signed-off-by: Robin Gong Acked-by: Mark Brown --- drivers/spi/spi-imx.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 70df8e6..a57edcb 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -57,6 +57,7 @@ enum spi_imx_devtype { IMX35_CSPI, /* CSPI on all i.mx except above */ IMX51_ECSPI, /* ECSPI on i.mx51 */ IMX53_ECSPI, /* ECSPI on i.mx53 and later */ + IMX6UL_ECSPI, /* ERR009165 fix from i.mx6ul */ }; struct spi_imx_data; @@ -75,6 +76,11 @@ struct spi_imx_devtype_data { bool has_slavemode; unsigned int fifo_size; bool dynamic_burst; + /* + * ERR009165 fixed or not: + * https://www.nxp.com/docs/en/errata/IMX6DQCE.pdf + */ + bool tx_glitch_fixed; enum spi_imx_devtype devtype; }; @@ -131,6 +137,11 @@ static inline int is_imx51_ecspi(struct spi_imx_data *d) return d->devtype_data->devtype == IMX51_ECSPI; } +static inline int is_imx6ul_ecspi(struct spi_imx_data *d) +{ + return d->devtype_data->devtype == IMX6UL_ECSPI; +} + static inline int is_imx53_ecspi(struct spi_imx_data *d) { return d->devtype_data->devtype == IMX53_ECSPI; @@ -585,8 +596,14 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, ctrl |= mx51_ecspi_clkdiv(spi_imx, t->speed_hz, &clk); spi_imx->spi_bus_clk = clk; - /* ERR009165: work in XHC mode as PIO */ - ctrl &= ~MX51_ECSPI_CTRL_SMC; + /* + * ERR009165: work in XHC mode instead of SMC as PIO on the chips + * before i.mx6ul. + */ + if (spi_imx->usedma && spi_imx->devtype_data->tx_glitch_fixed) + ctrl |= MX51_ECSPI_CTRL_SMC; + else + ctrl &= ~MX51_ECSPI_CTRL_SMC; writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); @@ -612,12 +629,16 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, static void mx51_setup_wml(struct spi_imx_data *spi_imx) { + u32 tx_wml = 0; + + if (spi_imx->devtype_data->tx_glitch_fixed) + tx_wml = spi_imx->wml; /* * Configure the DMA register: setup the watermark * and enable DMA request. */ writel(MX51_ECSPI_DMA_RX_WML(spi_imx->wml - 1) | - MX51_ECSPI_DMA_TX_WML(0) | + MX51_ECSPI_DMA_TX_WML(tx_wml) | MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) | MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN | MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA); @@ -1009,6 +1030,23 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = { .devtype = IMX53_ECSPI, }; +static struct spi_imx_devtype_data imx6ul_ecspi_devtype_data = { + .intctrl = mx51_ecspi_intctrl, + .prepare_message = mx51_ecspi_prepare_message, + .prepare_transfer = mx51_ecspi_prepare_transfer, + .trigger = mx51_ecspi_trigger, + .rx_available = mx51_ecspi_rx_available, + .reset = mx51_ecspi_reset, + .setup_wml = mx51_setup_wml, + .fifo_size = 64, + .has_dmamode = true, + .dynamic_burst = true, + .has_slavemode = true, + .tx_glitch_fixed = true, + .disable = mx51_ecspi_disable, + .devtype = IMX6UL_ECSPI, +}; + static const struct platform_device_id spi_imx_devtype[] = { { .name = "imx1-cspi", @@ -1032,6 +1070,9 @@ static const struct platform_device_id spi_imx_devtype[] = { .name = "imx53-ecspi", .driver_data = (kernel_ulong_t) &imx53_ecspi_devtype_data, }, { + .name = "imx6ul-ecspi", + .driver_data = (kernel_ulong_t) &imx6ul_ecspi_devtype_data, + }, { /* sentinel */ } }; @@ -1044,6 +1085,7 @@ static const struct of_device_id spi_imx_dt_ids[] = { { .compatible = "fsl,imx35-cspi", .data = &imx35_cspi_devtype_data, }, { .compatible = "fsl,imx51-ecspi", .data = &imx51_ecspi_devtype_data, }, { .compatible = "fsl,imx53-ecspi", .data = &imx53_ecspi_devtype_data, }, + { .compatible = "fsl,imx6ul-ecspi", .data = &imx6ul_ecspi_devtype_data, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, spi_imx_dt_ids); @@ -1175,7 +1217,10 @@ static int spi_imx_dma_configure(struct spi_master *master) * For ERR009165 with tx_wml = 0 could enlarge burst size to fifo size * to speed up fifo filling as possible. */ - tx.dst_maxburst = spi_imx->devtype_data->fifo_size; + if (spi_imx->devtype_data->tx_glitch_fixed) + tx.dst_maxburst = spi_imx->wml; + else + tx.dst_maxburst = spi_imx->devtype_data->fifo_size; ret = dmaengine_slave_config(master->dma_tx, &tx); if (ret) { dev_err(spi_imx->dev, "TX dma configuration failed with %d\n", ret); @@ -1659,7 +1704,7 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ | SPI_NO_CS; if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) || - is_imx53_ecspi(spi_imx)) + is_imx53_ecspi(spi_imx) || is_imx6ul_ecspi(spi_imx)) spi_imx->bitbang.master->mode_bits |= SPI_LOOP | SPI_READY; spi_imx->spi_drctl = spi_drctl;