Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3225123pxj; Mon, 24 May 2021 01:28:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCKRtO8DE7rigOMT6So6tzrgpDGreZ4eu8G+IIBBsfSP5fHUfgN0+jYuv/JoOj1xEjFtR+ X-Received: by 2002:a17:906:4a06:: with SMTP id w6mr22406331eju.69.1621844931548; Mon, 24 May 2021 01:28:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1621844931; cv=pass; d=google.com; s=arc-20160816; b=ixpuA8Etus7v+tjmxM46CkS+fXJQRxH3M8UyDCM10PTrO8yJjo3EGcMcmbFTi8Y8rz dTzdaM7PrCKLyhasnA1QZn0gY9mxbCOk/tWsjB7jvjkAMYutc8ztNdcpLx/j6h0h+ihX A0AgrAeEZFCHZIHbmw/oZqLzzi39LdA9rxL95Hb8Ba2zCH6UNquI69x5A9AOkv99IrJ7 Tm2+WJqnNK8sNZ7fXQjo0YHm6pp/kPfincRwxjoAN9P64aGx2rB20Ke+U1iFKwcaEcSZ bdAud7LtmJqNyKz4uEyW3XBKeH3MsNlu/Quv7Y9s5mOT18hJLNT9a/0gm4WYx2f82AId pPxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=FHHagOW2yZ9HAMC/rwNEWlzWUrooJgb12nsEZyjkuZU=; b=pZ6Rgnogib0vcgHQlnIVVa4NToBbxwUCO24jQauEIAv0T5N9tydJwWMp4NicDNkgqk PzoA6z67QprCL9bGsINZbWYXpCFN9P9XaTf0MhkvEmDJRKVgRoDGQX+J+3CZSa4s2QKe maXQR/YGMPIXnA7ExwoWZ3Mv3HTEOgqZOtYqA36aomutVFHGf+yPZIK0nWyX4bS8mOQl 31KDM6Y0ewNmMLcGlr+OqGy6yhLYXuBmtp3qscoOx619RNMN/svaDuaDe5t/T2ZlSWeb Zdk1VkbxkMuYZNNEEVny7oX6JhXjFSaZaYP7wAb9OlAeOy1BNtxA9ZTSFqYWur4C1BO8 1MhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vaisala.com header.s=selector1 header.b=OPBkEQHP; arc=pass (i=1 spf=pass spfdomain=vaisala.com dkim=pass dkdomain=vaisala.com dmarc=pass fromdomain=vaisala.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=vaisala.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si12895046edd.354.2021.05.24.01.28.28; Mon, 24 May 2021 01:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@vaisala.com header.s=selector1 header.b=OPBkEQHP; arc=pass (i=1 spf=pass spfdomain=vaisala.com dkim=pass dkdomain=vaisala.com dmarc=pass fromdomain=vaisala.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=vaisala.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232347AbhEXI1C (ORCPT + 99 others); Mon, 24 May 2021 04:27:02 -0400 Received: from mail-db8eur05on2088.outbound.protection.outlook.com ([40.107.20.88]:25440 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232279AbhEXI1B (ORCPT ); Mon, 24 May 2021 04:27:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/HIThk3Ous0tkJhxHO4anCBzdFQ0YaQOX5bVf+bhTWYsSQ1G0R8FmAT9N1am4nR24Z1gTQU2pEB2B66ukpghSz0v/V0MvqD2OfUFjhSqSZ/Pr+quy78Wypl0P4ZfMgWuon4pebnOltJBiIHASFLRDPFrCgvgTlOPzuIoYo1tWHcqmkaEeSaJJPcL8zqYhJasWmgtRKFx12Z8SYyukn3V8GuMSwdweX5OckhMguIiItb7AYNpRdD92+UlKu7cc6UEsGE5MyPse9qlAOLs3EmvnghfnMjXYTv8/AUTTCGf01mN3IvnTD99D0N76/4nLxg5ZQLU4nuW9FSPM072nYt7A== 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=FHHagOW2yZ9HAMC/rwNEWlzWUrooJgb12nsEZyjkuZU=; b=B5GdYJpIX5rvhCuvLtKV2ClGzuQRRmzT1lJDSrNMAV4y+k4kjUWOPWYM0yXUJNJKGTJFIdw1g5rKuvPQFmSyHCfj1uWIAvabetn7d7Rp6d5dOZpg2Se9X8KHnSPcOopFqSIWEwIu+irU42Os2xdFVH+ImWK19Q5c9QvHsVNaDEZzIUpUp2ZwVelc0vVtaeFJ6PwwZZtOgvv5PwUVIXxw3buEigJYVpPX+VTJyFGfyYcq6zDFHV2bwwwBcyp+gXauCnelbMhM4QrjxtdcoCF/HIFn8fUy21JcCnv0BCnouzMPGd8NWvVIPpAj8W4JDZbQjrAMcPAooZD37JLbPwvjPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vaisala.com; dmarc=pass action=none header.from=vaisala.com; dkim=pass header.d=vaisala.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vaisala.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FHHagOW2yZ9HAMC/rwNEWlzWUrooJgb12nsEZyjkuZU=; b=OPBkEQHPlYcHn+eEOEoItbTsI8H1u3wxmJ7xjli7jga+UkXCrFiR5kBx5M03EaetkidI3fbw7ETc5h8YbbOGmZgjcqgZHHFN4jk8+FPY2KLCuG4fknxui4NSCFdu/CldeOid2hhISYJXpGj10V5PNXKEdmjjQwwA+hzYzRQJJ3PxW2z1lhxR2vrvOm/Ux+LR/3FmJ6I4GZSQA/4q9fpgwWOZBjsrOC5yap10BMMmAlNV0TO+QZsaG/eHw6z1aYn0R3omZxde7hMSsRVggLnE151XTyi52VLmWXA7Zh3+D0tZ3IoJtx6WWU4NCCm5JnUd01fHVmhzfmvm7tOJRBkiOQ== Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=vaisala.com; Received: from VI1PR0602MB3568.eurprd06.prod.outlook.com (2603:10a6:803:10::31) by VI1PR06MB6576.eurprd06.prod.outlook.com (2603:10a6:800:128::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.25; Mon, 24 May 2021 08:25:31 +0000 Received: from VI1PR0602MB3568.eurprd06.prod.outlook.com ([fe80::4ca5:d9e1:61cc:8113]) by VI1PR0602MB3568.eurprd06.prod.outlook.com ([fe80::4ca5:d9e1:61cc:8113%5]) with mapi id 15.20.4150.027; Mon, 24 May 2021 08:25:31 +0000 Subject: Re: [PATCH] spi: imx: add 16/32 bits per word support for slave mode To: Clark Wang , 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 References: <20210408103347.244313-1-xiaoning.wang@nxp.com> From: Tomas Melin Message-ID: <961ec8d9-d96e-2dce-f2d0-b10299e10afb@vaisala.com> Date: Mon, 24 May 2021 11:25:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 In-Reply-To: <20210408103347.244313-1-xiaoning.wang@nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [85.156.166.106] X-ClientProxiedBy: HE1PR0202CA0005.eurprd02.prod.outlook.com (2603:10a6:3:8c::15) To VI1PR0602MB3568.eurprd06.prod.outlook.com (2603:10a6:803:10::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.242.142] (85.156.166.106) by HE1PR0202CA0005.eurprd02.prod.outlook.com (2603:10a6:3:8c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Mon, 24 May 2021 08:25:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cd182b3-5eda-4b71-9525-08d91e8d7e86 X-MS-TrafficTypeDiagnostic: VI1PR06MB6576: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aaa1U4lpq3l5WM+iOOWenZzJVg+YOhfSFmEHfwT9WS+wOrnb9e3DMZ/A9//E/UH81d0jWpT+cd9vN1le/d1kb44HVsKYkwNM5rMuqDnEzYwDgNnSnDC/hVJP8ABLy3ZFXU+Epo/H/I3ll0MmkesMQOnRMJgeEJ0tBoLrG1yTNmhtnaXyUv0RNOwm0C/0ASLGEtgx+3iwq52/kmQYcA076JC+ZH9oDiYP/hWfGo2TNc8+1ow1itER5yPv/A9aFmgDU8vGtHGRkly0RejnGQ+G3YMpdSOn4NlE61HE8jX6OkWKys/o3vS+K2ZT4GPvxIgEdTvhK4qURlre0ro2aVn5Uu+rTD8qFhxgPpkVpWwvVKqrf9ACHkZywYMoWr8+/d+Oa/oucWEON96UiHXP8aOjK98rH1rwFNLmvN3j1pRvtoYAdmNx6XUKbl26mYJLwe4cjHPd68Ik59m2il7AbJTJQavFZ7ze5nQVozuQ0/EctDTeuxCOalvHa08ukUnAe0yCebnjUTx4sTyYlnYoOMmz/LKsr7n99hMJ9mJVzKh+1lp/SXFkQUSASy1nPHfkCsbCJOfkTyfbS/oCZPmIAYOGRv4WRWHiupvGSzCN9Hqq2Bj5CQ6nRRGARd92Qlks5TQMcDiL64WtejuoRbzEClhjpMG22XDIqwe8dy1P/rRYqkmpx8JOdFT/By12fTLr5nJ9jDnD7NUkR0hPjM5uccbxVE/MW6dkx5zxP4yRZsUGdbY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0602MB3568.eurprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(136003)(39850400004)(376002)(366004)(396003)(2906002)(83380400001)(16576012)(38100700002)(38350700002)(52116002)(16526019)(86362001)(36756003)(316002)(6486002)(186003)(31696002)(7416002)(8936002)(53546011)(31686004)(478600001)(66946007)(26005)(956004)(44832011)(8676002)(66476007)(5660300002)(4326008)(66556008)(2616005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?OXY5YXNMQTJHWGlVVGc3UGU5dDdzR1drQWlmV0hPaU5KdndST0NvdjFKbmxx?= =?utf-8?B?cWxPTktEZTIrMUg4QjNPMkdMbmZmVlVBRnNpMjFOMXRsWDdyc1pscjdMNXRI?= =?utf-8?B?K0IrOEZmRHpCNFlaVFAyS1duc3psWE4zQndBR3VvdVZiQmo2Mk03aTVxSzVh?= =?utf-8?B?Y29mOGpxajNFTnZhTWp5ODFDOFBWbG0vSE5KRnRXMit4cFZrY3F0ekFGYllm?= =?utf-8?B?ZGRpK1NiYXViNW51Y213VmlvbVdnK2J5N3hOY3lZTmpPbkdvaUZUbGRVTFlE?= =?utf-8?B?bVlFd0lUbDZkRksxMjJyMVd4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paSFZSV1NzSnVmOVJvYzJ4TkF5bllReFVMZkhUWWcv?= =?utf-8?B?M0NRZDNkUzVoWTdhOTZGcW56dml0ZHhkbHczU0xoTjlzNzFnb2R2OWR2clA0?= =?utf-8?B?MG9YK0FwbUptc1ljS1N1c3lkMGY5RHk0U1lQNTZYV0plZnd3a2Q2Z0tsblBU?= =?utf-8?B?dXlpdHZNb2FYaTRxM3NBNkEvQUJ4clhDSGZLaWlIMExoaFdFZW56MSt5VlIy?= =?utf-8?B?QUdIdzlVb1VIMis0YzlUVVBFR3IrTWdqY0l2U3ZhSXJxbjdWWjJDUWVZdmFF?= =?utf-8?B?UWNkbGlKRmNZckpVd1ZPN2plQzl1ejFkRHk5d3p0T1ByNE5wUENOVmRtbzg5?= =?utf-8?B?SUpwMWI0K1FSMU5jNjdGUXE5MW9yd0RzOHBGZjRTQkwxT0djTTdZTHVSYTFN?= =?utf-8?B?TXhEeVJZYWVKdDRjNGgzNE5oWURPUmhOM25vTTBSeXZlcC9ia3IveEZvZ2Vl?= =?utf-8?B?NnBLTWZWOUFPaXBLc1ZVd3piZmpMMm9XQW9BcGtacHhqUldLdjFBOFZ2eEha?= =?utf-8?Q?/Zvu90DHRBdVEZ5WiY2EGz8bjGjLfCKJbl8lnpS?= X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd182b3-5eda-4b71-9525-08d91e8d7e86 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0602MB3568.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 08:25:31.3815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qbgw1Uir3LcvoMzx+s3y+RksMazz030zgPLB7yJKBU8Eey85QmlUzUIal6EVOO0Wj6/KHSvfXbe0GovrUYvZew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB6576 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 4/8/21 1:33 PM, Clark Wang wrote: > 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); Would it be good to use available     spi_imx_buf_rx_u32     spi_imx_buf_rx_u16     spi_imx_buf_rx_u8 helpers here? thanks, Tomas > > 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; > } >