From patchwork Thu Apr 8 10:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12190575 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=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 0E9AAC433ED for ; Thu, 8 Apr 2021 10:34:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C4A161158 for ; Thu, 8 Apr 2021 10:34:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C4A161158 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=0wDLrGI9j3dsgZsQhfKO1YoOsNEu8w9eOocifbnGxC8=; b=EOXmXXHfTaIF7xeZjKHZjByBNs nCAWoBqLxExVFued9afFTiHlHTlNlREnz1bO2s01wkThyby/qrZIDaKX9ILUUs0TcRolOvan6D8ou 5RDyOka+r49mB6sUaWlP1QAvDRNwBdkTU0C9PXUChNshXJzbJ0QtoKp4OoHB78NUnVPuwAKz5wkFO 5NLZ+HczxQKYwkhmTbQ9IM8I2kvx9yqQAruf6BeOuHBDEnN9BZqfBxMBFlJRT5F1kJORFSeIMkIov Qvj67le8dq7D6AFZsdxwpBqjdDztXZYCzxaKka3lNUINgtvvfHDzFgdgF4Z1hAcRONSPZd7QkhCbG PAO2iZpQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lURyA-007eVK-Mw; Thu, 08 Apr 2021 10:33:03 +0000 Received: from mail-vi1eur05on2082.outbound.protection.outlook.com ([40.107.21.82] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lURy3-007eTq-Go for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 10:32:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WRPQJ0QQmtOCnBCgjXfVRzIp0kFbnOg0Tj2ZhapedsmW6e5aGAU8WwlyHojXX8LUbHEQPYOIsgxGzciF5tERK+esR8I9rAMr27pppmcvF8IIu1YDGOQAOvtf79I3p/VflzmOGMqW68IiyKGv9k8A7iMBN2TI3I5YDoz/C4WTlRsfVr78RyE00MFpByHIONOmCPgCoYnvo+MxQH9Yv0PW5UrzCGSuFpUiiQq8on+Z7hkY6iKFivlD+CCIIfcgVVH4WLIZQgw9zQ1gYdjcHkv4bBdpXzSq2iLLQCaXLi9ZTmYV3JJwKde9VoYsREeM6Sg6KrW+RDLeJLNF9Woo9pIr/w== 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=Txps5nmahOf5u3Q+w3JoCQTJBfXxPeXGk2BSAcV8q2I=; b=HVF/QFJl0OmnDAcRw6aD0D/kBPGwDFlYPVm2R1NnepZzejzj/fSUWkqYEyDbumIrfRBOseNtQDLbtPGwvulSqPU5HwyXwI48U7S9hlqmI97X5ku6IgKddrEe4hFOD0iBAAA8LVn12+l3DDJSgTY/w3kUDyTWUgQMdQNVXfw/Ocz4V8PxQEqbG2+bqtY0vqpwjRCijjMKQVy2szgVzL2dekW1Dt+8afPQGONvr/VU6cYZE6EJIYXfk3jlv7YrsVx9AY0tdME7tz4wLT+vW/PgYSNvFj4WR62Cxo7Ws7cFQKYCof+3YXU267u47vWi+giENaac99AJQyFjPkGYUp+Hag== 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=Txps5nmahOf5u3Q+w3JoCQTJBfXxPeXGk2BSAcV8q2I=; b=jsU5Z37veOr6QHPRhKTR630tUo+ALGONWhumWJkimZWuWlwR4pAANQ9jRAduQlgnqq4+PHtzxKc2M9Nz44SCstFiNMBeQUTczH04LNtWG11WQbpqPHRbQRDbmr3BYxnxlIy6H8iH2ADUsY9q+fYg5jwYIobGWB3M6mrNZTSTHD8= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) by AM6PR04MB4982.eurprd04.prod.outlook.com (2603:10a6:20b:5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Thu, 8 Apr 2021 10:32:51 +0000 Received: from AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::5cd9:3da7:144f:36f9]) by AM6PR04MB5623.eurprd04.prod.outlook.com ([fe80::5cd9:3da7:144f:36f9%3]) with mapi id 15.20.3999.035; Thu, 8 Apr 2021 10:32:50 +0000 From: Clark Wang To: broonie@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: imx: add 16/32 bits per word support for slave mode Date: Thu, 8 Apr 2021 18:33:46 +0800 Message-Id: <20210408103347.244313-1-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0017.apcprd04.prod.outlook.com (2603:1096:202:2::27) To AM6PR04MB5623.eurprd04.prod.outlook.com (2603:10a6:20b:a9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR0401CA0017.apcprd04.prod.outlook.com (2603:1096:202:2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 10:32:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e73e417b-5481-4f46-94e1-08d8fa79a853 X-MS-TrafficTypeDiagnostic: AM6PR04MB4982: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vR4+QQZ8cLXzqy+LGk02phLk0DY102yAEybP144AnB8XjMSEIQIaBToUfphohUt++XdmWIYVPpg3JPycrBknGEKiYpryDf1DAYmmqXtdLByP5+bWtsuM0KTdv5nYtvHHBBVsWAgUVlxtrZyA4eG7uO1MuLENw/i8RL7Oln3xZ666crQzhNeaVpm48++ACUKvNDvtacbputgfLLP4tfSyyVK27Q8YkGYxAPvE9wYKA84VlQ8i+FvQzpsyCXCmParkHaeo0u5Z24u5fHBiOwVpCM4MwU/TLpAH7WZYnndzZu1tApIIg894rUjUTvkvILQ8pXfagbjVCt7WxFkh4iJVSmU7GqvuwlzAiRJrObaZB5WhhXUzCs2VjkW6LUykw2RnDGpSRWA5KSnOps8HsfoSrajXBCZiC94hz71SqDd8sj0N9M1Nen6Ulsy1haDWbdDJyGiJuADck9EgrBps0w2FkGBVKJkJpFI7E5YYwiMLnvEWHza5dsqM+MjvbuTe37i562aLezTxfqf6shWTEwRhltM+OxSo7SpdhwZtyZjINd/OzEg2lQJYNfhnbejm1ffhuTT7vxcD8dKrSh8NSR9Knqk7oZZXhEcRA7FeYEuanjgNjTScGkTBBVJ0VqIE9fxSNDt9m5Key7MZ6lD6kSJAaXlT3fG2m5Htc4WEu39JATgV5Vlh2oYCR+BRRefEVrS3B4tv8Av9mvUGUlFH5bOakw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5623.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(136003)(39850400004)(396003)(6486002)(66556008)(38350700001)(66476007)(16526019)(86362001)(956004)(2616005)(66946007)(4326008)(8676002)(36756003)(5660300002)(6506007)(38100700001)(52116002)(26005)(69590400012)(2906002)(8936002)(83380400001)(6512007)(316002)(478600001)(1076003)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: F8NWHqYAdzMRoVlRR0hlMU7qbHBFmleui1IxaX0/OqVyRvUMM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3bxphWfYy5Nxmo1+EOtS3Lx/QsjpJnNQYACaKhuwxZHMalBFPrOmW6K3Azy0ecAGYSw2sWkSlfLlwt9JeraEJOGHbWq/67GG7pMJySnYanS0UP8AnESvzqMmOd4p9Fv78D25ZQOBGdjY0vDNZs6PR8Uu5njI1nffv3prm78DK3WZ8Z6rmMfr4x7k3zX1YM0Q+/RwTlyTjQHiF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e73e417b-5481-4f46-94e1-08d8fa79a853 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5623.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 10:32:49.9119 (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: VAWQ2KFVkrIKZNSN+hVn/Lzc38YtHF5tCREBIbEMOBDtTXGX7DQh2ou45mf3/SIf6rV1sbOwLfYa3+nbXnaQsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4982 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_113255_773039_FF1E8E59 X-CRM114-Status: GOOD ( 11.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Enable 16/32 bits per word support for spi-imx slave mode. It only support 8 bits per word in slave mode before. Signed-off-by: Clark Wang Reviewed-by: Haibo Chen --- drivers/spi/spi-imx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 4fe767acaca7..24ba7ab1b05d 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -386,7 +386,12 @@ static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx) static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx) { - u32 val = be32_to_cpu(readl(spi_imx->base + MXC_CSPIRXDATA)); + u32 val = readl(spi_imx->base + MXC_CSPIRXDATA); + + if (spi_imx->bits_per_word <= 8) + val = be32_to_cpu(val); + else if (spi_imx->bits_per_word <= 16) + val = (val << 16) | (val >> 16); if (spi_imx->rx_buf) { int n_bytes = spi_imx->slave_burst % sizeof(val); @@ -415,7 +420,11 @@ static void mx53_ecspi_tx_slave(struct spi_imx_data *spi_imx) if (spi_imx->tx_buf) { memcpy(((u8 *)&val) + sizeof(val) - n_bytes, spi_imx->tx_buf, n_bytes); - val = cpu_to_be32(val); + if (spi_imx->bits_per_word <= 8) + val = cpu_to_be32(val); + else if (spi_imx->bits_per_word <= 16) + val = (val << 16) | (val >> 16); + spi_imx->tx_buf += n_bytes; }