From patchwork Mon Aug 31 16:03:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 258249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F103AC433E6 for ; Mon, 31 Aug 2020 07:52:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3B302098B for ; Mon, 31 Aug 2020 07:52:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="r8fd0yGM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgHaHv5 (ORCPT ); Mon, 31 Aug 2020 03:51:57 -0400 Received: from mail-eopbgr140050.outbound.protection.outlook.com ([40.107.14.50]:27033 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728033AbgHaHvu (ORCPT ); Mon, 31 Aug 2020 03:51:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O4kUjBRNu3m6/jip7mwakpFtQMPriZGsAw5oVlttiazDjcfrO+kiK6HFETdUx1Fd62+stObbG010IHxRI7Om6mLFWH/xf6dWc1cKMHrbOfes2SHBHZkp+QwG4rEpwwboeQBaBj/xSRUc8eahTdEgWjtS6CkRd4397tPl5369sOgXu4FRKt1sathF5GGu9xGICZe4RCqxkexuGnq6JLefTasd29wQJWAG5YpW5jnMDi4rogfsKa70NBbacn/zULssTsMRaNQYhkjtKJhJcpBMMGrGHj48FyDlhE7Kq2i404XaIyWMgLQrP9S2shqVTKpsVhx0m3NYLR6n634piqeYaw== 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=tRN/aDatBlziT9GOCprDl1KlggU+/D98hqEDzvOveqk=; b=cQI4HMgJfScQb4sRNHCv4vVlIGgRBhd7MEDUeIeBrxUC8Ha2ytNO9vAl9vpdN6oCGR4q1SsdNnry2MvlnsXtlMtnfNWbn2n/NGfn7V3CWtNNifE6ElKguiy0TdoLqcg5Ma+ZuFp8rH8hERxSMOgkbPBNpX8dDwjBBpp7mvzRfowpcAGIdqosbTH7LyC/H4oLNhEU3L+GTGGJxQzaYDDrqSuXeEKNJSVbG3g6AgnatbR8RLn51ZAjX3UgtkjxvQg8Eye07JOPxv4ouKrjFM+OmVAQoJYJ5Z8crz09rPfyMB+8G96srrqEYn1bbXe4GKBsSCNzijzL8y67rkg2voaKNg== 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=tRN/aDatBlziT9GOCprDl1KlggU+/D98hqEDzvOveqk=; b=r8fd0yGM4Di5CcRA1yDdMtVrkKFXv1sCAWPFnHU5yiyDDSae/g1flQfliCmvuuD/+fcuyVlb3LawPtRY8X3CzGipEbow5TfRUjSckDVNc1tEcdFZsf6XGQax61bB60ygEv+oYiz0hEWQ58WqPZcY7adn0KT3bxjxFNr9J5bWyW4= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6638.eurprd04.prod.outlook.com (2603:10a6:803:119::15) by VI1PR04MB5694.eurprd04.prod.outlook.com (2603:10a6:803:e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19; Mon, 31 Aug 2020 07:51:23 +0000 Received: from VE1PR04MB6638.eurprd04.prod.outlook.com ([fe80::ad7f:d95a:5413:a950]) by VE1PR04MB6638.eurprd04.prod.outlook.com ([fe80::ad7f:d95a:5413:a950%3]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 07:51:23 +0000 From: Robin Gong To: mark.rutland@arm.com, broonie@kernel.org, robh+dt@kernel.org, catalin.marinas@arm.com, vkoul@kernel.org, will.deacon@arm.com, shawnguo@kernel.org, festevam@gmail.com, s.hauer@pengutronix.de, martin.fuzzey@flowbird.group, u.kleine-koenig@pengutronix.de, dan.j.williams@intel.com, matthias.schiffer@ew.tq-group.com, frieder.schrempf@kontron.de, r.schwebel@pengutronix.de, Benjamin.Bara@skidata.com, Richard.Leitner@skidata.com Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, dmaengine@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v13 08/12] spi: imx: remove ERR009165 workaround on i.mx6ul Date: Tue, 1 Sep 2020 00:03:21 +0800 Message-Id: <1598889805-30399-9-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598889805-30399-1-git-send-email-yibin.gong@nxp.com> References: <1598889805-30399-1-git-send-email-yibin.gong@nxp.com> X-ClientProxiedBy: SG2PR02CA0104.apcprd02.prod.outlook.com (2603:1096:4:92::20) 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.67) by SG2PR02CA0104.apcprd02.prod.outlook.com (2603:1096:4:92::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3326.20 via Frontend Transport; Mon, 31 Aug 2020 07:51:16 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 40307eee-412b-4c05-f7f1-08d84d82a7c3 X-MS-TrafficTypeDiagnostic: VI1PR04MB5694: X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kMZrYZclqMNZiyJuzp8yYvXyomBEVwrUqPh9hsxvL3cmxNPBLagk5rnHTsY5CX65PA3oEjn1fmFqp9DZwJzOxVa359C5mFCtS58T4KqVhwkLZP+tf5+zZDOUvtm/+51BD9kjDnmaH+34aOWn4+lRNzSdpEsIMgevrAUWTaroNIF8IQsN7k2GMOcLW1YNi7Ywk1eGx9zQsIcjwZQE1oSDWOq8dBPIE9uoLqiRYZ8N44TQyy8HyTm4PUpAQN5ggYLQJ2ruUFR+pu3C4s9ocVHxALpEtUpRxpQTlMmtirB6rKi4HXuaQMyDqtrb3AM11yPzjCARwDvo+emGSBHQx9PjJZRDyp6MvXH4ljfyKQ6PGoCq8JJ5VR48a63qDzcqMkeqRo6S0cLnk0i73XMOxVdm6EsLpTvmNP10rfpSam2RuaKhncZ3JrIAGiGg755x5KQlJg3+W4U/MAumXFyQ4tS7Tw== 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; SFS:(4636009)(366004)(396003)(346002)(376002)(39860400002)(136003)(8676002)(2616005)(2906002)(36756003)(8936002)(86362001)(5660300002)(956004)(316002)(26005)(6506007)(478600001)(6666004)(83380400001)(6486002)(7416002)(66476007)(66946007)(66556008)(4326008)(186003)(16526019)(966005)(6512007)(52116002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3ju2NT4pfAc/8Ck6KZIXvr+mhGsmyLsUjBTKOuWVsd7UNvq0faHFv27u+i7O1WXnsKVr5/2eXCkJPabw7GANpzfxcu0+1CoU+LAtSLcw5Ceoeg9skWfOD1Oohw5gqe8gTgB0mwtCbKQ9QfcCD2+VC+cIYc5yB7+GmppnRzrepEE/2VwMQTmo7dEdFYERqdfAKN/FJODkWF/JRtVPw7cPrJ4OdwvgVFxNhVsJyO2lmH3yvwdEPSIoUryJOlEfSnADS4kWBpTR9qd87++FrU7PQ0HTcIQVrcSS/C44an+O300pVlMr2KGh67BWHtNHvowlDf0WMUbikGzVFHzNng9nct96tOPHHOjNyV/KKamFbK/MqmDyh/H0fg7mtGjRKo7TuGkuk7Z4WqausOaVrdm1mZMkiZwnb/SqpeBSpyW1DqSKDYj/xYRm2EOUNGEh78ba7+egug6fK9Zqo8TrbFm4pnN4C8fCIiwr/lxn+zdPoA5TI219MV397Mxi2RQLAFiqRjzG8eEX8ytgDh0YpmYHgJUfT92Nw8v5rJSR4BpQDFp8CTynEBgUG5dhNsQliO1y3m+tdHsSUURNAg8ukdsoF7nKs8IloymY1aXZ+1qu0lC/s+9Z924yZZeNUAjafAXwVIbfktu3psaOLbuWdi0RFg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40307eee-412b-4c05-f7f1-08d84d82a7c3 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6638.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 07:51:23.1358 (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: N1G8CvMoLugLteUBOXx/VKjSOINBEgTrXuJo4miQrYl3SrNSt1G13jr8D4JejpH3ntyuBxMcU5h/xYFAHTmTIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5694 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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 9edb259..2df2750 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -59,6 +59,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; @@ -78,6 +79,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; }; @@ -134,6 +140,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; @@ -593,8 +604,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); @@ -620,12 +637,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); @@ -1019,6 +1040,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", @@ -1042,6 +1080,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 */ } }; @@ -1054,6 +1095,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); @@ -1630,7 +1672,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;