From patchwork Thu Sep 26 10:51:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162353 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 9C62413B1 for ; Thu, 26 Sep 2019 10:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70705222C2 for ; Thu, 26 Sep 2019 10:52:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="c/BVvjXq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfIZKwV (ORCPT ); Thu, 26 Sep 2019 06:52:21 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:38576 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbfIZKwU (ORCPT ); Thu, 26 Sep 2019 06:52:20 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAlgbm010047; Thu, 26 Sep 2019 06:52:15 -0400 Received: from nam03-co1-obe.outbound.protection.outlook.com (mail-co1nam03lp2058.outbound.protection.outlook.com [104.47.40.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hjwy7yu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GGdxjHLor+KCFK+WfJwcdljsjDQ8TBtD50AlCuICq3GF9mCZgGw3Ky58wVdoL8dVipGRX+mXSIXagNZ5mScgphh5c4/ufCAMPPEg45Fn6yvZLS6vF61d6YDKcs7C+qjVJYyBK7acjRtYcSQJpv80yfMArB8UYQzxMtbRUEROAe7bWzJ3BMkGhLffkDM8vzgE4F9Ufs8kG+4LyDbByaO9RDjQtl/EtAg3jtj4Qg4ZwYQvKQrsB9C12FsUwLeOHyHP+cwZOohpssSz21olO+cW93EvnEVo3k+NH+N4P2sCLt2lfHe4VqrwbZwhdcDXlWTQBCHQ5SEUMKGiTHQ9VRKf5w== 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=N//v9tP42mO82MASuaLghoW7AUmfw1VhX5gXorThYfI=; b=CHxzx3pylJo7Ec+t56RLya6ibPAWvrq4G/mObPNwcU3TD6U0EJA6lUdFFZ3N2aSrxtuHuzumXv4WzHaR9YxmFU/HUmYHVXeVvWue/MhaZ4cwH+aw+qLo+g5NHVbq6OAzHkoPpWBN28wL45LZcagEYqlPHEYHEzFDurfUJGJYrZ/Fw+lk+v97vLr6C8fbaAnjmIViS29VLP2rmsgyK80Uz4QBhGtx0wusyVzWzn19lyZqN9smIa18K7cwM0pJJgu/8cvivE+6+MloYXYbWzSxQsJYycg1YSqt1zt+EAhmiurOWYEpZN2tDJPnSVD5c2bxH9Tf0RclLV44JLY0JY9PSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N//v9tP42mO82MASuaLghoW7AUmfw1VhX5gXorThYfI=; b=c/BVvjXq77/r+f97P1/SbEANYpgxMVz5eK+tIbCd8RAheVIUOX5N3h5Oae0rLvpDmvmlfy6Aj/00CB4QzyShKenELVLz/2h63NL7vbDbeYrRdUAVPVyKpM5dVVNw1Ni4WV+aSXjBUuhMHwKWZTmnt7uX68uHcCs/MlSS8RI4w3s= Received: from BY5PR03CA0005.namprd03.prod.outlook.com (2603:10b6:a03:1e0::15) by MWHPR03MB3182.namprd03.prod.outlook.com (2603:10b6:301:42::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Thu, 26 Sep 2019 10:52:12 +0000 Received: from SN1NAM02FT033.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::207) by BY5PR03CA0005.outlook.office365.com (2603:10b6:a03:1e0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16 via Frontend Transport; Thu, 26 Sep 2019 10:52:12 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT033.mail.protection.outlook.com (10.152.72.133) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:11 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqBLC014754 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:11 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:10 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 01/19] spi: move `cs_change_delay` backwards compat logic outside switch Date: Thu, 26 Sep 2019 13:51:29 +0300 Message-ID: <20190926105147.7839-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(346002)(396003)(136003)(376002)(189003)(199004)(26005)(47776003)(106002)(305945005)(54906003)(8676002)(7636002)(478600001)(2870700001)(7416002)(4744005)(316002)(110136005)(2906002)(4326008)(50466002)(8936002)(1076003)(186003)(446003)(426003)(11346002)(486006)(6666004)(356004)(336012)(2201001)(2616005)(476003)(126002)(107886003)(48376002)(36756003)(5660300002)(246002)(44832011)(76176011)(70206006)(86362001)(7696005)(70586007)(50226002)(51416003)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB3182;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d110576b-0f0a-497c-4c02-08d7426f95cc X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:MWHPR03MB3182; X-MS-TrafficTypeDiagnostic: MWHPR03MB3182: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: wgeW8tUdjEp5GCGFO/VF0/yaBgCHBK180e6fWlZb20lYTySWcnCa+Ks92PYVpKdoyWPa9ZLXJXkymhqQc7qNV7+ivyqYW9+md9nhKJeIBR3Dem1bslF/wjO8R/dM9YufphvI6fQkUG8TtDdLDjKg+8uR/oB9HTytAAk0Fbu+ynQGyNlMEAM3ulaAnCryMfF6HTtua6z4nVz1xvzSH+x8G4B+0aDleCvjOa7R49Y8LsVplmmcBER/4eI9UHq/W1Gtcc8POG1gKI2IV+bSe6ZfwYwYYiBaItJOCz0mPGsZLHD1a9CEsT1JxXTlRNWqidAmTzOD2hBgLA8OlLx+H2HVB9MCdr0v/0JGGE+VVqhxZTDkAGVOK/ND71CjLkosrIjoQJDMExAT0sb8aAw54+Zlb7NrHJSundtcnmLsTBK9pD0= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:11.6940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d110576b-0f0a-497c-4c02-08d7426f95cc X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3182 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260102 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The `cs_change_delay` backwards compatibility value could be moved outside of the switch statement. The only reason to do it, is to make the next patches easier to diff. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 75ac046cae52..c90e02e6d62f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1114,16 +1114,15 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, u32 hz; /* return early on "fast" mode - for everything but USECS */ - if (!delay && unit != SPI_DELAY_UNIT_USECS) + if (!delay) { + if (unit == SPI_DELAY_UNIT_USECS) + _spi_transfer_delay_ns(10000); return; + } switch (unit) { case SPI_DELAY_UNIT_USECS: - /* for compatibility use default of 10us */ - if (!delay) - delay = 10000; - else - delay *= 1000; + delay *= 1000; break; case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ break; From patchwork Thu Sep 26 10:51:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162453 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 BAD5713B1 for ; Thu, 26 Sep 2019 10:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86780222C2 for ; Thu, 26 Sep 2019 10:54:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="fktm5wD+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726950AbfIZKyB (ORCPT ); Thu, 26 Sep 2019 06:54:01 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:3998 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbfIZKw1 (ORCPT ); Thu, 26 Sep 2019 06:52:27 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqK8u018025; Thu, 26 Sep 2019 06:52:20 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2056.outbound.protection.outlook.com [104.47.49.56]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hkcq42j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5uUbUH2lplTyKi4fff4mZSP/fInkilfDjx7kdQRDO+6Z+9nzPo/iL/IyhUVFAj4M28sPNfqohH8ISAAG/hbGfs/MwbezyYBZd7g6QEEUQis+yQLS9Xed/5qmbni/eZfk56W3ovFBlaKlsP9wRBgJ/ldFUppzJoXpwVcNJs08gettUacU54qrBXAX41Fq8xlSH+t0gLIgYEc5OEshnu5G8EOUdY/fgF2j9PlZ2uqTBaFXm2mZKCDCVlP/9jmdvjFbZ2aDkgg2gVwOsHFTKKu3b7lHLgplkLmGjNiipa7nPuuuRnKpOeWiWBFGeEdxkSMVHzhlmnd8AM+Sj9YqJiC/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=ESeHHXBfFrG988glXvaIvhiPmUc6BnNdkc+lsz3piTo=; b=UnbQFKsCJHyZ/B91BHq+K2LpR5oCd1k0uiB00hFhajBqG5Zry5npY18NxPhXJkaip72KWeKiKpokc7ynJ2FUspMw8KrLF1AcGPUVR1I4J7xX5K8/Vepjrgy+NDCA+repJ7ElhNDJvkMhUFc43LTOxbIyHIyICl2WU687Xo39afUqbXnsCI65oX93jR+PU/ndd9TJj8QXidmcspn1+HUNq43ek6kb4OJgph3NR9Kdn4OO8r+Z7WiPUuKcqRmOSGpMSeixhALgHdACvteCZCTjauhu6Ip95HhJbVMQ8NAY9oxdk3oi480smhhzuhZlb2tcVhR3L9wSfp5Qwh5gLg6wkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESeHHXBfFrG988glXvaIvhiPmUc6BnNdkc+lsz3piTo=; b=fktm5wD+UKwEVefxVl/w+1UZzNnnRvPZAAJDmtdAh8QFaga8O0Mofv8m0MPL3GNpkJbiu7f5pd1JJCZ4jhNhIW93j4iBqOf3DxDm/okeGN43W9oGo6uvRCtE7Y2DviJ9dT9FsxUc1p8PKeTC0OGTeDgP0WadeQ0yYdUdf7Tx+OQ= Received: from BN6PR03CA0079.namprd03.prod.outlook.com (2603:10b6:405:6f::17) by BN8PR03MB4708.namprd03.prod.outlook.com (2603:10b6:408:6d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 10:52:14 +0000 Received: from SN1NAM02FT022.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::203) by BN6PR03CA0079.outlook.office365.com (2603:10b6:405:6f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:14 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT022.mail.protection.outlook.com (10.152.72.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:14 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqD6s014763 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:13 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:13 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 02/19] spi: introduce spi_delay struct as "value + unit" & spi_delay_exec() Date: Thu, 26 Sep 2019 13:51:30 +0300 Message-ID: <20190926105147.7839-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(346002)(39860400002)(376002)(199004)(189003)(2870700001)(246002)(476003)(51416003)(7416002)(14444005)(107886003)(11346002)(126002)(486006)(336012)(54906003)(426003)(110136005)(7636002)(305945005)(8936002)(50226002)(50466002)(7696005)(106002)(8676002)(446003)(4326008)(2616005)(186003)(47776003)(316002)(2906002)(26005)(5660300002)(478600001)(86362001)(70206006)(44832011)(1076003)(6666004)(356004)(48376002)(76176011)(2201001)(70586007)(36756003)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN8PR03MB4708;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7a26c2ea-a270-4637-f7f1-08d7426f975f X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:BN8PR03MB4708; X-MS-TrafficTypeDiagnostic: BN8PR03MB4708: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Vk8BOIpZ8upk4WghlPYBlqIKReD/m6fkX0WLyTwMRB+G/1HqVM5ORg80Y6W2Er5GJwWkC/9ezV03TupxXGAOS8BbbOk3TzQqPa4WY9lgp5m6U3RvoY7WG6WAU3qFbfaif3meB+fME7EAPiXcaRfr3Zb6AUdgRLwPq9zUbcyC9vDMh6yH3AhJcSpnHk2Lfm2n15KN7b4xPLl8wMn770kSwjg2xbVFL1hi7myl5xgya8BEq9rFMzJaLiYEgl9iRTsK2GOmquy7KqEkr1iDx71akPmlEUMeM1N1EZmNiPCP1v6+12t74XKe+9ml/EneypcQ/9gvGCm1vbNXInAH8sXbAl7L9BA+Q6h8m+V5MkLeNUl8A0n/yJSyTTsaHxkLc3bQx0MbFNpUc7efe02OGlRCawo1bvakTucwX1OSfZIdilo= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:14.3365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a26c2ea-a270-4637-f7f1-08d7426f975f X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR03MB4708 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org There are plenty of delays that have been introduced in SPI core. Most of them are in micro-seconds, some need to be in nano-seconds, and some in clock-cycles. For some of these delays (related to transfers & CS timing) it may make sense to have a `spi_delay` struct that abstracts these a bit. The important element of these delays [for unification] seems to be the `unit` of the delay. It looks like micro-seconds is good enough for most people, but every-once in a while, some delays seem to require other units of measurement. This change adds the `spi_delay` struct & a `spi_delay_exec()` function that processes a `spi_delay` object/struct to execute the delay. It's a copy of the `cs_change_delay` mechanism, but without the default for 10 uS. The clock-cycle delay unit is a bit special, as it needs to be bound to an `spi_transfer` object to execute. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 51 +++++++++++++++++++++++++++++++++++++++++ include/linux/spi/spi.h | 18 ++++++++++++--- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c90e02e6d62f..1883de8ffa82 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1106,6 +1106,57 @@ static void _spi_transfer_delay_ns(u32 ns) } } +static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) +{ + u32 delay = _delay->value; + u32 unit = _delay->unit; + u32 hz; + + if (!delay) + return 0; + + switch (unit) { + case SPI_DELAY_UNIT_USECS: + delay *= 1000; + break; + case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ + break; + case SPI_DELAY_UNIT_SCK: + /* clock cycles need to be obtained from spi_transfer */ + if (!xfer) + return -EINVAL; + /* if there is no effective speed know, then approximate + * by underestimating with half the requested hz + */ + hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; + if (!hz) + return -EINVAL; + delay *= DIV_ROUND_UP(1000000000, hz); + break; + default: + return -EINVAL; + } + + return delay; +} + +int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) +{ + int delay; + + if (!_delay) + return -EINVAL; + + delay = _spi_delay_to_ns(_delay, xfer); + if (delay < 0) + return delay; + + _spi_transfer_delay_ns(delay); + + return 0; +} +EXPORT_SYMBOL_GPL(spi_delay_exec); + static void _spi_transfer_cs_change_delay(struct spi_message *msg, struct spi_transfer *xfer) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index af4f265d0f67..c18cfa7cda35 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -89,6 +89,21 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, #define SPI_STATISTICS_INCREMENT_FIELD(stats, field) \ SPI_STATISTICS_ADD_TO_FIELD(stats, field, 1) +/** + * struct spi_delay - SPI delay information + * @value: Value for the delay + * @unit: Unit for the delay + */ +struct spi_delay { +#define SPI_DELAY_UNIT_USECS 0 +#define SPI_DELAY_UNIT_NSECS 1 +#define SPI_DELAY_UNIT_SCK 2 + u16 value; + u8 unit; +}; + +extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); + /** * struct spi_device - Controller side proxy for an SPI slave device * @dev: Driver model representation of the device. @@ -834,9 +849,6 @@ struct spi_transfer { u16 delay_usecs; u16 cs_change_delay; u8 cs_change_delay_unit; -#define SPI_DELAY_UNIT_USECS 0 -#define SPI_DELAY_UNIT_NSECS 1 -#define SPI_DELAY_UNIT_SCK 2 u32 speed_hz; u16 word_delay; From patchwork Thu Sep 26 10:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162449 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 BE59013B1 for ; Thu, 26 Sep 2019 10:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8002D207E0 for ; Thu, 26 Sep 2019 10:54:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="3/l/VCH+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbfIZKw0 (ORCPT ); Thu, 26 Sep 2019 06:52:26 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:3596 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbfIZKwZ (ORCPT ); Thu, 26 Sep 2019 06:52:25 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqKSO030417; Thu, 26 Sep 2019 06:52:20 -0400 Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2056.outbound.protection.outlook.com [104.47.38.56]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VivbJmud6ByJYrDBdzWcC+RpIVURhbJeNQcgbGstohXF2t9luMDHYQJAE9rKqi+edbOhv0JjwADBknRSdR3NBlSKSPT+8phFJbA1u95j689HgnRlA8/zx7L2R8XHUFXY7K97B0F66LhGuzpj2rqsGspBDoXQY4ET63M5vQggmbaUsVfM15ZwDIAlNlRhun3VG0sv5YHMfe0/tItpNOSiF75QdPDc0QfAo2fvLPhcLGL2a9VigdhBkht+ATwGaU5uXicTT3zy5iGsDRO9fDcbtTu48W4jsk/v3LBzCeHOXRd/X+q7km9gL9qFqJSF1d0NtOONj6oC8fLo5REupirLug== 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=xaM1SxqT2GWMH5PNNJdquphJwaB2Lq4IgSpM3l/5FJI=; b=YDmEQEffZaPcuBTpOZ9RwDjNSXtmrm+Ybo9E1knbWtdXsZdChiZjvzCyhkB3TtDomhImWyG05L6+4XAEyY5lvk4pxJsqUzlpQYnqTvf4URfD1rkZiElVhOMhY6bULfrcMi8neQ3OaAVagv9JVoT3J3wJTArjClA0AKb5r7JLRZu9NTYlKw7twz1x/eyNUau9GLmIgwzqgeaJpR7A/W+Q67PKZdbM3l6HvhNURg49IFJ4oaBe8MAyVYrbh9tmSB1NZh/6uHbHLK0Dvd18GgsS7QvYh56Yo+eHrbRED7naPwEP7Ec8O0bLbNTMzhaJhAza5ja4j/W9aZWz6BUpP91wNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xaM1SxqT2GWMH5PNNJdquphJwaB2Lq4IgSpM3l/5FJI=; b=3/l/VCH+BCngiD77hSFqSVpj4jdDFTcqvWu3pavKiwmio4deOFUNawIEM2ZmbH72a5rHC/K++uXBZwHGE/wI0DYVRSkrQByZLpQ6hs660+UH+Kxb8HPhwo9e818mb9WAo8eJygmEOZSpCeWUJTpRQxSUAVPClbJye632MQQ9ITA= Received: from BYAPR03CA0015.namprd03.prod.outlook.com (2603:10b6:a02:a8::28) by BN6PR03MB2737.namprd03.prod.outlook.com (2603:10b6:404:5c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Thu, 26 Sep 2019 10:52:17 +0000 Received: from BL2NAM02FT060.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BYAPR03CA0015.outlook.office365.com (2603:10b6:a02:a8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:17 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT060.mail.protection.outlook.com (10.152.76.124) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:16 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqGeE014768 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:16 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:16 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 03/19] spi: make `cs_change_delay` the first user of the `spi_delay` logic Date: Thu, 26 Sep 2019 13:51:31 +0300 Message-ID: <20190926105147.7839-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(39860400002)(396003)(136003)(346002)(376002)(199004)(189003)(486006)(2616005)(126002)(476003)(44832011)(106002)(356004)(6666004)(51416003)(426003)(2201001)(47776003)(5660300002)(316002)(48376002)(446003)(86362001)(11346002)(50226002)(14444005)(1076003)(7696005)(4326008)(107886003)(336012)(186003)(246002)(76176011)(110136005)(50466002)(478600001)(26005)(54906003)(8676002)(7416002)(8936002)(70586007)(7636002)(36756003)(2906002)(70206006)(305945005)(2870700001)(81973001)(2101003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2737;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e7f4c9c-8ec1-49e6-be27-08d7426f98cb X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:BN6PR03MB2737; X-MS-TrafficTypeDiagnostic: BN6PR03MB2737: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: h5VDl3iQaXPEaXDE/NSUW4iDltv336fvMRQJRkcBZFn9Il1sFWm1rxvF/+F2Qh6T39fs2IWi0F3v21EJAjJeBLF/33esh84BNlhDlPVfGO09Crcg/zaoyCTMrhbNL/sbB9DnItNH4kNsrAzLLNzjSdfN0xmkHiavIHgzIYvAGvImzBDh2MagAAsIAaKxS7ekRcuv/yefflWj9SL9WcxJyjtEEStyZ/pJEXAsQwMKWb0UP9ROjWm4KQH7FFTfvFfNyExSO5iyC24+UjTQ4OuiHRyfm4eFZZrP266gRNGTmNMOHclOIHDTE6LQLl4Od8/IZO3iE7RLPqdThzZ7FslPQVWQa2pVmu/0c/sAPtEO70AV09DswN03AMRNSsa5iTwkcqV1yjZYMX0YLJ+Hz12MWXrH2mCfWarxVe7F9KRlvn4= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:16.7936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e7f4c9c-8ec1-49e6-be27-08d7426f98cb X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2737 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Since the logic for `spi_delay` struct + `spi_delay_exec()` has been copied from the `cs_change_delay` logic, it's natural to make this delay, the first user. The `cs_change_delay` logic requires that the default remain 10 uS, in case it is unspecified/unconfigured. So, there is some special handling needed to do that. The ADIS library is one of the few users of the new `cs_change_delay` parameter for an spi_transfer. The introduction of the `spi_delay` struct, requires that the users of of `cs_change_delay` get an update. This change also updates the ADIS library. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/adis.c | 24 ++++++++++++------------ drivers/spi/spi.c | 28 +++++++--------------------- include/linux/spi/spi.h | 4 +--- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c index 1631c255deab..2cd2cc2316c6 100644 --- a/drivers/iio/imu/adis.c +++ b/drivers/iio/imu/adis.c @@ -39,24 +39,24 @@ int adis_write_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 4, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 6, .bits_per_word = 8, @@ -139,16 +139,16 @@ int adis_read_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->read_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 4, .rx_buf = adis->rx, @@ -156,8 +156,8 @@ int adis_read_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->read_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .rx_buf = adis->rx + 2, .bits_per_word = 8, diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1883de8ffa82..d0bf0ffca042 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1160,9 +1160,9 @@ EXPORT_SYMBOL_GPL(spi_delay_exec); static void _spi_transfer_cs_change_delay(struct spi_message *msg, struct spi_transfer *xfer) { - u32 delay = xfer->cs_change_delay; - u32 unit = xfer->cs_change_delay_unit; - u32 hz; + u32 delay = xfer->cs_change_delay.value; + u32 unit = xfer->cs_change_delay.unit; + int ret; /* return early on "fast" mode - for everything but USECS */ if (!delay) { @@ -1171,27 +1171,13 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, return; } - switch (unit) { - case SPI_DELAY_UNIT_USECS: - delay *= 1000; - break; - case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ - break; - case SPI_DELAY_UNIT_SCK: - /* if there is no effective speed know, then approximate - * by underestimating with half the requested hz - */ - hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; - delay *= DIV_ROUND_UP(1000000000, hz); - break; - default: + ret = spi_delay_exec(&xfer->cs_change_delay, xfer); + if (ret) { dev_err_once(&msg->spi->dev, "Use of unsupported delay unit %i, using default of 10us\n", - xfer->cs_change_delay_unit); - delay = 10000; + unit); + _spi_transfer_delay_ns(10000); } - /* now sleep for the requested amount of time */ - _spi_transfer_delay_ns(delay); } /* diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index c18cfa7cda35..9ded3f44d58e 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -754,7 +754,6 @@ extern void spi_res_release(struct spi_controller *ctlr, * @cs_change: affects chipselect after this transfer completes * @cs_change_delay: delay between cs deassert and assert when * @cs_change is set and @spi_transfer is not the last in @spi_message - * @cs_change_delay_unit: unit of cs_change_delay * @delay_usecs: microseconds to delay after this transfer before * (optionally) changing the chipselect status, then starting * the next transfer or completing this @spi_message. @@ -847,8 +846,7 @@ struct spi_transfer { u8 bits_per_word; u8 word_delay_usecs; u16 delay_usecs; - u16 cs_change_delay; - u8 cs_change_delay_unit; + struct spi_delay cs_change_delay; u32 speed_hz; u16 word_delay; From patchwork Thu Sep 26 10:51:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162365 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 094DA14ED for ; Thu, 26 Sep 2019 10:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DACFC217F4 for ; Thu, 26 Sep 2019 10:52:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="N3aOFs6l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbfIZKw3 (ORCPT ); Thu, 26 Sep 2019 06:52:29 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:5492 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfIZKw2 (ORCPT ); Thu, 26 Sep 2019 06:52:28 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqMeI030420; Thu, 26 Sep 2019 06:52:22 -0400 Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2054.outbound.protection.outlook.com [104.47.38.54]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GENUyd3ZZNkXXbymvp/jy5CqfC4j6woQH4t4b/Cf16WqJsY6QonnkixpqdAqwCeauBc3ntGHDfvNtB17Xmbv3UYfPLPaTklb+ojARe3Wcu40WvnvGfdFGWykvkgDBIG+m22pLupjwa+RGkOlrPtoBIr0PYeza34ejdU94DlNq9wYLRO9kmnBiUsvY4UelUSWjiUtoisJxwkmZ3YprGy9py1Y49ZxF/0s2vazE+A78KNpikh6qQ6UJlh099LHX2cx/Qop9GFgr0n5aV5DHGptGtVvVsvlWnB8k+9dvty+di0OSbwB1OcwlLYZfnLQ0fai21J5/E3ARdsDMuiFXKhRoA== 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=WYcLfPlSWsVcRSi6vEDtOApg72ktL+WvUv8x/fiP8Jg=; b=QkPJaJlYTqvDSxXGzxB7F4pofN1/2yMd8TrMvkB97m3pz+QWilrWsEH31zEeZbVptzqDYCIs4AOH6jdTIOHfgIPgYl+5T6Z04R2auYvy4ktjMqzzGE8nbr2rz730Ov4DsxzRS7AV2K7Mdawv/cin5Gpdv+QBrb5qk7V6U71hjOJnubQN60B7CIG4k68K9sidky5KP8bF168op5sjqMmapc5Lft3BoMiEiLJgfHxVoN3+YVSKdglcf54BME+sIVPHve+lWz7OiAyQtf+gTidFmmSRAvI65NckbFZcVmHVvQlRl9PWNqnrHhHZGXrBXzLFdxd+ph4piJ3pv0JtAT0yTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WYcLfPlSWsVcRSi6vEDtOApg72ktL+WvUv8x/fiP8Jg=; b=N3aOFs6lBo5LOjVWtzZV0hzM5j5mJgjZ2wbax4yULG5laZvnbYMGwZFZYu0GRYKx28hO0ZPSdJ/JSlX878dY4qlU70+F5JIB0h0XOPVOV+oha0AhiYrnNBQNQiBkk1XCkyr+/ZbRbvyk0n6fqwBybhgpFCNsBs5sLhEb6D5Au4w= Received: from BN3PR03CA0090.namprd03.prod.outlook.com (2a01:111:e400:7a4d::50) by MN2PR03MB5182.namprd03.prod.outlook.com (2603:10b6:208:1e7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 10:52:19 +0000 Received: from BL2NAM02FT025.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::204) by BN3PR03CA0090.outlook.office365.com (2a01:111:e400:7a4d::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.26 via Frontend Transport; Thu, 26 Sep 2019 10:52:19 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT025.mail.protection.outlook.com (10.152.77.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:19 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqJpv014772 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:19 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:18 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 04/19] spi: sprd: convert transfer word delay to spi_delay struct Date: Thu, 26 Sep 2019 13:51:32 +0300 Message-ID: <20190926105147.7839-5-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(396003)(376002)(39860400002)(136003)(199004)(189003)(47776003)(11346002)(2906002)(36756003)(446003)(486006)(126002)(51416003)(76176011)(26005)(476003)(2616005)(4326008)(426003)(336012)(2870700001)(8936002)(50226002)(8676002)(246002)(478600001)(48376002)(107886003)(186003)(7696005)(70206006)(106002)(54906003)(50466002)(316002)(44832011)(110136005)(70586007)(7416002)(86362001)(7636002)(305945005)(2201001)(1076003)(6666004)(356004)(5660300002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR03MB5182;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af374764-9f02-4518-cb77-08d7426f9a6c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:MN2PR03MB5182; X-MS-TrafficTypeDiagnostic: MN2PR03MB5182: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: f8M3VKK/ang1Ln6X5JxNcK9SAl0aWH+C+OY73EpWi9ldf/+I4D8uluHOtIteieCPDAWkS2hK9fGfsUiTPsOHM5M1PdtMFrIuZvo2xzB2tYixKEeQhD3ReD9JwXhJFcGK8xyKjXL0+d4Zl0iuIfNTAauWQE8qS2BlelMWRQcYgzyghxM1McVaQc+c9AVYJvQgf4InZTla1FD2PnDeT7Hwg4xGtpbA6Nyf2QAlJpg7CL3ixA/QU0T4nIB2AHv/qmawL0h7NpltBT0WciG7o+vA8kaC4020EzCVF5yVtgzJY/hqXRsk5JYHRKk1Oo3MMm5v0WHwdCydWRH5S2w6q7/lUp6jhXQ8LgCeXAE/9ZWezhCt0JrZaOiFyoS5zmwpZNLQiYN7tI9AO9c8quJP07I39yC3eF1A38bENpeQJZG5mjA= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:19.5278 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af374764-9f02-4518-cb77-08d7426f9a6c X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5182 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The Spreadtrum SPI driver is the only user of the `word_delay` field in the `spi_transfer` struct. This change converts the field to use the `spi_delay` struct. This also enforces the users to specify the delay unit to be `SPI_DELAY_UNIT_SCK`. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-sprd.c | 15 ++++++++++++--- include/linux/spi/spi.h | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c index 1b7eebb72c07..7e72e8facff7 100644 --- a/drivers/spi/spi-sprd.c +++ b/drivers/spi/spi-sprd.c @@ -669,11 +669,15 @@ static void sprd_spi_set_speed(struct sprd_spi *ss, u32 speed_hz) writel_relaxed(clk_div, ss->base + SPRD_SPI_CLKD); } -static void sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) +static int sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) { + struct spi_delay *d = &t->word_delay; u16 word_delay, interval; u32 val; + if (d->unit != SPI_DELAY_UNIT_SCK) + return -EINVAL; + val = readl_relaxed(ss->base + SPRD_SPI_CTL7); val &= ~(SPRD_SPI_SCK_REV | SPRD_SPI_NG_TX | SPRD_SPI_NG_RX); /* Set default chip selection, clock phase and clock polarity */ @@ -686,7 +690,7 @@ static void sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) * formula as below per datasheet: * interval time (source clock cycles) = interval * 4 + 10. */ - word_delay = clamp_t(u16, t->word_delay, SPRD_SPI_MIN_DELAY_CYCLE, + word_delay = clamp_t(u16, d->value, SPRD_SPI_MIN_DELAY_CYCLE, SPRD_SPI_MAX_DELAY_CYCLE); interval = DIV_ROUND_UP(word_delay - 10, 4); ss->word_delay = interval * 4 + 10; @@ -711,6 +715,8 @@ static void sprd_spi_init_hw(struct sprd_spi *ss, struct spi_transfer *t) val &= ~SPRD_SPI_DATA_LINE2_EN; writel_relaxed(val, ss->base + SPRD_SPI_CTL7); + + return 0; } static int sprd_spi_setup_transfer(struct spi_device *sdev, @@ -719,13 +725,16 @@ static int sprd_spi_setup_transfer(struct spi_device *sdev, struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); u8 bits_per_word = t->bits_per_word; u32 val, mode = 0; + int ret; ss->len = t->len; ss->tx_buf = t->tx_buf; ss->rx_buf = t->rx_buf; ss->hw_mode = sdev->mode; - sprd_spi_init_hw(ss, t); + ret = sprd_spi_init_hw(ss, t); + if (ret) + return ret; /* Set tansfer speed and valid bits */ sprd_spi_set_speed(ss, t->speed_hz); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 9ded3f44d58e..16397b210e0c 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -759,7 +759,7 @@ extern void spi_res_release(struct spi_controller *ctlr, * the next transfer or completing this @spi_message. * @word_delay_usecs: microseconds to inter word delay after each word size * (set by bits_per_word) transmission. - * @word_delay: clock cycles to inter word delay after each word size + * @word_delay: inter word delay to be introduced after each word size * (set by bits_per_word) transmission. * @effective_speed_hz: the effective SCK-speed that was used to * transfer this transfer. Set to 0 if the spi bus driver does @@ -847,8 +847,8 @@ struct spi_transfer { u8 word_delay_usecs; u16 delay_usecs; struct spi_delay cs_change_delay; + struct spi_delay word_delay; u32 speed_hz; - u16 word_delay; u32 effective_speed_hz; From patchwork Thu Sep 26 10:51:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162447 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 875F313B1 for ; Thu, 26 Sep 2019 10:53:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CEA5222C2 for ; Thu, 26 Sep 2019 10:53:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="GiAG1xXz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbfIZKwa (ORCPT ); Thu, 26 Sep 2019 06:52:30 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:7268 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfIZKwa (ORCPT ); Thu, 26 Sep 2019 06:52:30 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqOMk018153; Thu, 26 Sep 2019 06:52:24 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2057.outbound.protection.outlook.com [104.47.49.57]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hkcq42n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gR8zBNS0wbljdByvXEakEGRty63II+RZq2/KQE2Cd22XARWP+xtFam1t4k837lJvYsw7S/hoCjkHUJmkQrO37Kj091fPMYtd8pW0Nfgey2gGDlZlbKKhnd4kZNnbrLeVRNN55CpEF8RY79ZbYxCmQIk6t8/7auk7ac9XwxsA9yROchG6f7c4UTqc4nnLftY7ugvssJe28npLcBC7RR2C+xQrhIyaYy4roSpATaVBBPJ71gWJouM0ZG/ff+C/CN4ZYP5xZLXhpHhs8zOsbbnRj7S8Ry0NAPGLU6ddKzCVvl7gQm+1DzgMuxrSg0FTNW5oKMZuSkbqh+eRs/SbfjvOIQ== 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=4tAthPJJ00Md+QA2VffHOABt3RVqF/+sx3EiB52xHYc=; b=NhNCQXHOXiAzkKIjcza33fSbEtYNX/wuMIh2U/lA1ZSqUzestapjUk8fqT0eNAV2zpiWamfse7Webdg3ftt0fpF9AaaRun6T94MFMqBFHNhwpz8DMTzzc7x1LBFjqGEvXrvC17IZRdvBHE1JH9Ox5DbjQqkzlrBOaMK9UcizqGB4RvcYhiWcF5bi7yKTJ3i+FEywI2UKnaCIrsuMNZc6E/KGa0xBAPplEFoOMJw13xH2xL3CI+IecjIHUX5FX7UiZsqdXEipXydyxvLsfeDgxhqU6n159eplvnNFLw7vyVAgcJJb//yUi7uf3SMqbIEyvn/A3G1evjb7cal1wBz5Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4tAthPJJ00Md+QA2VffHOABt3RVqF/+sx3EiB52xHYc=; b=GiAG1xXzfAAGZWwS2CyyRhpjH3rrMgkYfFXtYttpzIUYM4jMxQRBsNOG01w0hjA2MNj1SvUHIaRCVXDCXn7RBZ8SlhnB1iKzbWcwOCDqak3INA/VvFtZg4Kt+dVnoilRuS/2Q5DeWGQ4r5tPXz1dlZ/aJsbWZzRlS+GxXz1KONY= Received: from BN6PR03CA0062.namprd03.prod.outlook.com (2603:10b6:404:4c::24) by DM6PR03MB4060.namprd03.prod.outlook.com (2603:10b6:5:58::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Thu, 26 Sep 2019 10:52:22 +0000 Received: from BL2NAM02FT006.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::205) by BN6PR03CA0062.outlook.office365.com (2603:10b6:404:4c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:22 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT006.mail.protection.outlook.com (10.152.76.239) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:22 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqMua014780 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:22 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:21 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 05/19] spi: orion: use new `word_delay` field for SPI transfers Date: Thu, 26 Sep 2019 13:51:33 +0300 Message-ID: <20190926105147.7839-6-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(136003)(39860400002)(376002)(396003)(199004)(189003)(7696005)(4326008)(6666004)(2870700001)(8936002)(426003)(47776003)(50226002)(336012)(356004)(8676002)(478600001)(246002)(26005)(50466002)(106002)(54906003)(1076003)(110136005)(36756003)(7416002)(316002)(305945005)(107886003)(186003)(70206006)(70586007)(7636002)(11346002)(446003)(5660300002)(2616005)(48376002)(476003)(2906002)(76176011)(86362001)(51416003)(44832011)(486006)(2201001)(126002)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB4060;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bcd76e0-d2ef-4d25-ce3e-08d7426f9c17 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:DM6PR03MB4060; X-MS-TrafficTypeDiagnostic: DM6PR03MB4060: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 1OpzoA/edLOxmzdA6HaYRvqMt+AdjAuHaf1Wo9pE/7s6BSHpEE6gjpkdbi4YTOwp6YCNldkig8xenRErpwgJHZLzVnPLtuY885zLnKJ9HiRizMCZza/9v3ghV+a7mcvkf0/Zyfq7AGseddy6d7LeG1FTerIPbXACigxSS3MZHCIJVDar/CEVhaepbpP92VeNqOAS6HPvvtZGd1VgRU05vrA/tkJcEyHtyHWcU6Hg0xeDObiRcBHYmPNH2B/1+03Bg/1jPwfhheyR9eSItvHBZFroWJZNxc+udFgpkzryaTSKaEfD52hk3cLjTykdgb1GnhtMKy1lgcuVQzpHTD4XM6Rweeil4Rbtxg1/mQQss0okN9AcIwpVGYUukzsCQNTbRVs4/jao1onxR+DuSp5DB1YbNvhYt6MaplKuHy/f+T8= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:22.3242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bcd76e0-d2ef-4d25-ce3e-08d7426f9c17 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4060 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=844 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The `word_delay` field had it's type changed to `struct spi_delay`. This allows users to specify nano-second or clock-cycle delays (if needed). Converting to use `word_delay` is straightforward: it just uses the new `spi_delay_exec()` routine, that handles the `unit` part. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-orion.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 6643ccdc2508..756c37e32dfe 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -467,8 +467,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) if (orion_spi_write_read_8bit(spi, &tx, &rx) < 0) goto out; count--; - if (xfer->word_delay_usecs) - udelay(xfer->word_delay_usecs); + spi_delay_exec(&xfer->word_delay, xfer); } while (count); } else if (word_len == 16) { const u16 *tx = xfer->tx_buf; @@ -478,8 +477,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) if (orion_spi_write_read_16bit(spi, &tx, &rx) < 0) goto out; count -= 2; - if (xfer->word_delay_usecs) - udelay(xfer->word_delay_usecs); + spi_delay_exec(&xfer->word_delay, xfer); } while (count); } From patchwork Thu Sep 26 10:51:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162445 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 8176413B1 for ; Thu, 26 Sep 2019 10:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5733C207E0 for ; Thu, 26 Sep 2019 10:53:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="AU6fKjkK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbfIZKxt (ORCPT ); Thu, 26 Sep 2019 06:53:49 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:9508 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfIZKwc (ORCPT ); Thu, 26 Sep 2019 06:52:32 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqK8w018025; Thu, 26 Sep 2019 06:52:27 -0400 Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2051.outbound.protection.outlook.com [104.47.45.51]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hkcq42r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuiObLVFWIH8R+zPSXWYQTaB/IS6BTeVLQfwDz/Uw5dF/Ky1axR9tb0HBdobg9jn2d8Lm3x3kCRPFiZqWGeizN3hHUfcUNO6JpFWJ1kuemLAmk9GNnZpcaZETIlnFYFe8H6g7kCIU23R+Gqt5nBKJF0F1UKuOeU6/GzUHG4jXzVSQx9QEe0WavgdpEVe9cJEAqKerNqTb6RFKzT2NiW+nZx/t1KxTRXMaaQCUI9+Dq3ss68Wi5Fam1hu9FVnPoeuOoTM5Ew0tiIeSKRZGcjWa6YDpcf7fF66cJCKt2xVFnIz7V6QeEsSt47T7nSZrhQThOGfNnt8dXUo8QDlJSFpRQ== 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=jZSDTjpFf1yZc16/IDU9rKofLB8/ySMkTzgyv2YEtVU=; b=ILhWqc7/I//UxjXMhmx25943O+u0JUQXD32he69xBgvy6tEnN08QorUT8VERVyI43Di8Rb7Vf27z2cxy9Cx96uONTQI2b1vrJGLKfdwJVuvUU8+qW4R30qGWVlFsWAvg+svnEarewQM02RL5R8coUAZVAZkN2rj8yMQ3ec37VpNkJxIq09X0/fnTMM6xU9ylECLaP278dtGv0bhJpJezlAekpIkuiAMpB56xuzz5/Q4QOYZr6ET3vI15LgxtfAvKzTkHOqtK/xJRM2OvAnrE47umrNPZoSNzJmyoyriScWPy0x5HJlUimVGa1tyI4zz2sP4yhQBzbUTMLPj5Z2zPjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZSDTjpFf1yZc16/IDU9rKofLB8/ySMkTzgyv2YEtVU=; b=AU6fKjkKbLy4QQlyboEYZfdDek4Atj5xRo0308bLyckSBzGk6/ZBSRLudYK5h/BT4UxPMiLsIdKFepaz/5fbCa+CrGlMf9VYADK1gBhPDMavN/OXJcAtYIvnWPiOJbNtsETnK3XPrp3jWyE22Eq8JlMFzTIZcR6Gt7r+eeEttmk= Received: from BY5PR03CA0006.namprd03.prod.outlook.com (2603:10b6:a03:1e0::16) by DM6PR03MB4586.namprd03.prod.outlook.com (2603:10b6:5:10d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16; Thu, 26 Sep 2019 10:52:25 +0000 Received: from BL2NAM02FT063.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::203) by BY5PR03CA0006.outlook.office365.com (2603:10b6:a03:1e0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16 via Frontend Transport; Thu, 26 Sep 2019 10:52:25 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT063.mail.protection.outlook.com (10.152.77.121) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:25 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqO36014783 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:24 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:24 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 06/19] spi: spidev: use new `word_delay` field for spi transfers Date: Thu, 26 Sep 2019 13:51:34 +0300 Message-ID: <20190926105147.7839-7-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(396003)(136003)(346002)(39860400002)(199004)(189003)(7636002)(486006)(316002)(446003)(54906003)(110136005)(4326008)(107886003)(47776003)(5660300002)(6666004)(70586007)(14444005)(1076003)(106002)(356004)(8676002)(86362001)(246002)(70206006)(478600001)(50226002)(186003)(36756003)(76176011)(7696005)(476003)(8936002)(2201001)(26005)(44832011)(7416002)(48376002)(2616005)(336012)(426003)(51416003)(11346002)(2906002)(305945005)(2870700001)(126002)(50466002)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB4586;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17d4d245-1810-453e-f709-08d7426f9dca X-MS-TrafficTypeDiagnostic: DM6PR03MB4586: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4qMMVN+5h7/8qNcUAsVm+uWzMw8tFPuL6L5ti0nKyORksrCX6oeHwITN1XMyL/b8YKREkY0TIx467Z950EDJyVK8tTMZt3mfHYKB8X1mm/V55z9lgBxk14qn0yx95WeU88gf77gJFM2Z+IR0ont/twN3V1zDuPNu0xHtO28gdr30KBudn9s3WRGLUwjrlCM+ka1a0ZyB+3KZEiGwG7Uf51KXWAXUY8nw+b7H6CfbNHCEHm+I5BHHteTov0lnuEUOqQRlHtwi5rwrAjWs4AJV7uehy+hdTviXaUWL7cNAdBJAj62+Cq9ug2CC+xTAMSlDlMKa62g0uCCIANwnT6I/B1nFqTQ8VrgUj1MmVCr6YIvUP3n4fufq7e+jF4YV8ZiqduO+fiYNMYLClVRPeZMCGS03nAKI0FZQ0HRaTGqNdr4= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:25.1781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17d4d245-1810-453e-f709-08d7426f9dca X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4586 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=808 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The `word_delay` field had it's type changed to `struct spi_delay`. This allows users to specify nano-second or clock-cycle delays (if needed). Converting to use `word_delay` is straightforward: it's just assigning the value to `word_delay.value` and hard-coding the `word_delay.unit` to `SPI_DELAY_UNIT_USECS` This keeps the uapi for spidev un-changed. Changing it can be part of another changeset and discussion. Signed-off-by: Alexandru Ardelean --- drivers/spi/spidev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 255786f2e844..495319c2fa11 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -267,7 +267,8 @@ static int spidev_message(struct spidev_data *spidev, k_tmp->bits_per_word = u_tmp->bits_per_word; k_tmp->delay_usecs = u_tmp->delay_usecs; k_tmp->speed_hz = u_tmp->speed_hz; - k_tmp->word_delay_usecs = u_tmp->word_delay_usecs; + k_tmp->word_delay.value = u_tmp->word_delay_usecs; + k_tmp->word_delay.unit = SPI_DELAY_UNIT_USECS; if (!k_tmp->speed_hz) k_tmp->speed_hz = spidev->speed_hz; #ifdef VERBOSE From patchwork Thu Sep 26 10:51:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162371 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 3729E13B1 for ; Thu, 26 Sep 2019 10:52:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0266F217F4 for ; Thu, 26 Sep 2019 10:52:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="0ZE4dl97" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726470AbfIZKwf (ORCPT ); Thu, 26 Sep 2019 06:52:35 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:48994 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbfIZKwf (ORCPT ); Thu, 26 Sep 2019 06:52:35 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqQhH002867; Thu, 26 Sep 2019 06:52:29 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2050.outbound.protection.outlook.com [104.47.49.50]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hj96rbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDLW/tGwdIAyE9HGxZyehcMBMae/sQ0ZFMe4A0Yv+pJkMOiMJeE+MjSAYM9eBHIFlAXi++ega0Emp/9XLwFvZQDTcObS1R5oNLls9ncJzagbCmCo1C6RnFgkFkncphW8QwcFF61XlXdMbsZ9F8Mo5edNbFJT0Gt2GP/OcyTPCjKEg6LGSdEnhytx/JlRqPplHFvKWF6wjWqYytWUqBhCM0vV5lAL3kuj9vGT+30ktsMSIEEMX8YZQ1yo4uzeXZG9mE+qFhHz1jYyakhR1D9XWDlyb8/qaXTT6nCrl6QBfA9Xf0ZoazlO10Uj01X27VB4rFoR41iMoGEccvwmT2rHPw== 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=3IA+1Fc7lyDOHCZvoYR1tS+uwKA95J512v8EqcOR0dI=; b=OeghTfIcM/0pdQT4k+rZ2Th/hnDcnLHzYCD1bCjdgExpjx4VYvgl+ysEUK6QePAafNlRj8XBcVarc3VADh80brJUswAt+lpcqAlw4nFGeua4Dy7wJ8aH5R4yLgwskqkqUrLhAvwg6tmRCEqa1sto0xKEsLhOnXhQDamm4WV+OQ6easdq0MdPEh4AkjQiGHP09KW7vlcLbGgfmJAmVBZPpTnvz4RB39tdioQseQeTKbHyvruULmDe9mU7p9PHCf4Dfc+LSQePDPOvu0Xmt9AowxYRP5v4XoMrNaHio3KndE0ChpjSwf5AkWLFtLF6soMlRogG0qDs+s9KhqZdsfC2UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3IA+1Fc7lyDOHCZvoYR1tS+uwKA95J512v8EqcOR0dI=; b=0ZE4dl978d07kvBUlFeWYo2lEPgbGAfXjfQKkwCXPCQyPyuGmgR+4VJf1q1ol3j9c3W9iWzKjJRYgegUPLyty2SuibXC2iZ3S0BJ8fm8Ss5lNI/Xml4ctC0KHnHQ3y1J8TSekApuWu7KvTKQc7AMSTciHU+iKfaAGySTVIap7G8= Received: from CH2PR03CA0026.namprd03.prod.outlook.com (2603:10b6:610:59::36) by DM6PR03MB5049.namprd03.prod.outlook.com (2603:10b6:5:1ee::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 10:52:28 +0000 Received: from BL2NAM02FT027.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by CH2PR03CA0026.outlook.office365.com (2603:10b6:610:59::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16 via Frontend Transport; Thu, 26 Sep 2019 10:52:28 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT027.mail.protection.outlook.com (10.152.77.160) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:27 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqReg014787 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:27 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:27 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 07/19] spi: core,atmel: convert `word_delay_usecs` -> `word_delay` for spi_device Date: Thu, 26 Sep 2019 13:51:35 +0300 Message-ID: <20190926105147.7839-8-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(396003)(136003)(189003)(199004)(54906003)(47776003)(48376002)(86362001)(2201001)(50466002)(7636002)(2616005)(44832011)(446003)(11346002)(486006)(336012)(126002)(476003)(426003)(2870700001)(305945005)(7416002)(76176011)(51416003)(2906002)(186003)(7696005)(26005)(5660300002)(1076003)(106002)(6666004)(316002)(478600001)(70586007)(70206006)(356004)(8676002)(246002)(8936002)(36756003)(50226002)(14444005)(4326008)(107886003)(110136005)(81973001)(142933001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB5049;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d80d7d5c-58f0-4981-dd3f-08d7426f9f5f X-MS-TrafficTypeDiagnostic: DM6PR03MB5049: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0xsCoYiglvStMp0h95uj3P3leALEqEgF5SZgI+MqY6OCwl1wzIdPk8xIitHIfopJqrwK1l67ngFraTMoEdifc2p2jCSWYDDuB5eXRE+oPRFuW4Lii9jOdttgwi0zUSz9Qz/iCHd+yeq3esKW3r3Ta3FLMe6lXxx/fMhV+mgc7PriqRscTOlxN/ni1TqNRQMr5uMh/83LgehMKUykexnZjDwsePd2eBhvxChphyy/SDvP1qmtJzFhBbnD9BwRIOG+0MHc9bpkFfcziTpS+qm6zKybhBSiA6x5hl9s9A1J6S8LO8HZPmsx4mdw3RpR+muD88G7iFnNh0GoXrX0QHzahwnZhlyEp7Logc3LYBX8ZzgK73nn8qyWNk54PsN2qL7lo4NqL9sK5nl+vdtg69PvuK+MYb/vTIaXtXrRjy+RmUg= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:27.8297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d80d7d5c-58f0-4981-dd3f-08d7426f9f5f X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB5049 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This change does a conversion from the `word_delay_usecs` -> `word_delay` for the `spi_device` struct. This allows users to specify inter-word delays in other unit types (nano-seconds or clock cycles), depending on how users want. The Atmel SPI driver is the only current user of the `word_delay_usecs` field (from the `spi_device` struct). So, it needed a slight conversion to use the `word_delay` as an `spi_delay` struct. In SPI core, the only required mechanism is to update the `word_delay` information per `spi_transfer`. This requires a bit more logic than before, because it needs that both delays be converted to a common unit (nano-seconds) for comparison. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-atmel.c | 26 ++++++++++++++++++++++++-- drivers/spi/spi.c | 24 ++++++++++++++++++++++-- include/linux/spi/spi.h | 7 ++----- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index f00b367523cd..f04b92791515 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1172,12 +1172,31 @@ atmel_spi_pdc_interrupt(int irq, void *dev_id) return ret; } +static int atmel_word_delay_csr(struct spi_device *spi, struct atmel_spi *as) +{ + struct spi_delay *delay = &spi->word_delay; + u32 value = delay->value; + + switch (delay->unit) { + case SPI_DELAY_UNIT_NSECS: + value /= 1000; + break; + case SPI_DELAY_UNIT_USECS: + break; + default: + return -EINVAL; + } + + return (as->spi_clk / 1000000 * value) >> 5; +} + static int atmel_spi_setup(struct spi_device *spi) { struct atmel_spi *as; struct atmel_spi_device *asd; u32 csr; unsigned int bits = spi->bits_per_word; + int word_delay_csr; as = spi_master_get_devdata(spi->master); @@ -1201,11 +1220,14 @@ static int atmel_spi_setup(struct spi_device *spi) */ csr |= SPI_BF(DLYBS, 0); + word_delay_csr = atmel_word_delay_csr(spi, as); + if (word_delay_csr < 0) + return word_delay_csr; + /* DLYBCT adds delays between words. This is useful for slow devices * that need a bit of time to setup the next transfer. */ - csr |= SPI_BF(DLYBCT, - (as->spi_clk / 1000000 * spi->word_delay_usecs) >> 5); + csr |= SPI_BF(DLYBCT, word_delay_csr); asd = spi->controller_state; if (!asd) { diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d0bf0ffca042..ba8731b77753 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3159,6 +3159,26 @@ void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold, } EXPORT_SYMBOL_GPL(spi_set_cs_timing); +static int _spi_xfer_word_delay_update(struct spi_transfer *xfer, + struct spi_device *spi) +{ + int delay1, delay2; + + delay1 = _spi_delay_to_ns(&xfer->word_delay, xfer); + if (delay1 < 0) + return delay1; + + delay2 = _spi_delay_to_ns(&spi->word_delay, xfer); + if (delay2 < 0) + return delay2; + + if (delay1 < delay2) + memcpy(&xfer->word_delay, &spi->word_delay, + sizeof(xfer->word_delay)); + + return 0; +} + static int __spi_validate(struct spi_device *spi, struct spi_message *message) { struct spi_controller *ctlr = spi->controller; @@ -3294,8 +3314,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) return -EINVAL; } - if (xfer->word_delay_usecs < spi->word_delay_usecs) - xfer->word_delay_usecs = spi->word_delay_usecs; + if (_spi_xfer_word_delay_update(xfer, spi)) + return -EINVAL; } message->status = -EINPROGRESS; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 16397b210e0c..e7ec0be16a82 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -138,7 +138,7 @@ extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); * the spi_master. * @cs_gpiod: gpio descriptor of the chipselect line (optional, NULL when * not using a GPIO line) - * @word_delay_usecs: microsecond delay to be inserted between consecutive + * @word_delay: delay to be inserted between consecutive * words of a transfer * * @statistics: statistics for the spi_device @@ -188,7 +188,7 @@ struct spi_device { const char *driver_override; int cs_gpio; /* LEGACY: chip select gpio */ struct gpio_desc *cs_gpiod; /* chip select gpio desc */ - uint8_t word_delay_usecs; /* inter-word delay */ + struct spi_delay word_delay; /* inter-word delay */ /* the statistics */ struct spi_statistics statistics; @@ -757,8 +757,6 @@ extern void spi_res_release(struct spi_controller *ctlr, * @delay_usecs: microseconds to delay after this transfer before * (optionally) changing the chipselect status, then starting * the next transfer or completing this @spi_message. - * @word_delay_usecs: microseconds to inter word delay after each word size - * (set by bits_per_word) transmission. * @word_delay: inter word delay to be introduced after each word size * (set by bits_per_word) transmission. * @effective_speed_hz: the effective SCK-speed that was used to @@ -844,7 +842,6 @@ struct spi_transfer { #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ u8 bits_per_word; - u8 word_delay_usecs; u16 delay_usecs; struct spi_delay cs_change_delay; struct spi_delay word_delay; From patchwork Thu Sep 26 10:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162437 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 3D7D014ED for ; Thu, 26 Sep 2019 10:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11E02207E0 for ; Thu, 26 Sep 2019 10:53:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="EdjAJCQq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726509AbfIZKwm (ORCPT ); Thu, 26 Sep 2019 06:52:42 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:53674 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbfIZKwl (ORCPT ); Thu, 26 Sep 2019 06:52:41 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqQVD030649; Thu, 26 Sep 2019 06:52:32 -0400 Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2058.outbound.protection.outlook.com [104.47.48.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hjwy806-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7IulQTIYHTudY0wcQfSs9t66Hb0z6Dd+1k3kiY8bIletInBaAmNtQhP5luhdeZIRUlSd8U54HM0pBgJx3QfBmYvzQp1QYz5z03usT8bfSJFph/UzZ5u5u1IIuL+sEFMjluHQr3J/QGeTA1C8Xie2DOaSvQL2gkUGNcJUQ9kY57R7qB2pw7k7SVIkoa5noC0H0P1W5UhSGo6PRHBNX184P0OqxZqDI1LXr0eEF5WYoLfTBLnM4pSmcHBeY8WGH+dwPIZ/0lJi961jTy1zTdQNR5EyfD/ZkhnYvDuPiBqnnRfRFhlwb5J9XPIJVLCEQEH2U9lv/VnsFXhvBW51u+y+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=9CWvHi3MVOMNti6mf1Jdx+KB+lbj6H+wU8H+9trT/bw=; b=lie9FEhDCWOD6yhUJlYn+4s8hQtSBqrDOcQbFoBezhCDsgh8Kmb8v7oltEq1qFyDwHnsdtGNrhrPeSbgA0Gs49lw+qvs1aiuqvPsWtIYeEdianYkFT71NZ2mAzGrB5M9IueMWLk8UWaRHmyKUDwFoXDsN+lUWSARtd+Ck6WoCe+E1G+UbvtEQPAnTgxjDqhxs8JlFGxVN57mjJe9yplYbC2FcHuKQHOVfuVbEDjoWB7j8sT6zxDM6XNRPxWfcoa+QOXHf4QV4SAu6VlNUU8NW08qoISI9huhPE3PZb0SWgfIPXGnqITGnaSYUAeEPLiy0jG15DOBfHpu78/VpayLxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9CWvHi3MVOMNti6mf1Jdx+KB+lbj6H+wU8H+9trT/bw=; b=EdjAJCQq4dzkEGM7hxrshiRwwIyElYOb6cyHpNBXE2jmjnq79eTSScSM2ibs7aHw4mHgAA82cowKWKd8jyRXnL0an1ThvTVJnM8gdLDf2IOjZLlpzMsVWelf3+S0IDDqNOm7WP/Z4qn6P9aw/TbB/jvnIazzvaeWQDmHqx8BSMY= Received: from BN3PR03CA0091.namprd03.prod.outlook.com (2a01:111:e400:7a4d::51) by SN6PR03MB4576.namprd03.prod.outlook.com (2603:10b6:805:102::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 10:52:30 +0000 Received: from BL2NAM02FT025.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BN3PR03CA0091.outlook.office365.com (2a01:111:e400:7a4d::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Thu, 26 Sep 2019 10:52:30 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT025.mail.protection.outlook.com (10.152.77.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:30 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqUBl014790 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:30 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:29 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 08/19] spi: introduce `delay` field for `spi_transfer` + spi_transfer_delay_exec() Date: Thu, 26 Sep 2019 13:51:36 +0300 Message-ID: <20190926105147.7839-9-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(396003)(39860400002)(346002)(199004)(189003)(48376002)(476003)(2616005)(50466002)(7416002)(50226002)(26005)(7696005)(446003)(426003)(11346002)(7636002)(486006)(126002)(51416003)(44832011)(76176011)(47776003)(8676002)(186003)(336012)(246002)(86362001)(305945005)(8936002)(2201001)(4326008)(316002)(70586007)(70206006)(54906003)(106002)(110136005)(5660300002)(36756003)(1076003)(356004)(6666004)(2906002)(107886003)(2870700001)(478600001)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR03MB4576;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09268031-e77d-4fd7-a3b0-08d7426fa0fa X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:SN6PR03MB4576; X-MS-TrafficTypeDiagnostic: SN6PR03MB4576: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: oW47sOtv14BqCWXczt5YE4mV7B1/+7MZU/WrNXicUO/0SUvXR/wo5i6Z5pGG3ZOezc69mbzZ1CY4MCRA0E5JA3XWkUciH++qk6u8Eclmzqw0nV04zGNacOcPKnQkfuhri5MH64Cd9MHlXl8Tw+26QpZenYW5xZhkXRYIkneiKP3N0S8xESBR0IEqDneR9a9U+am1VK/00vrAjhWOVOr4NTex0z8VkGFz2iYng4O5nJ0yjUoIlBINW2wzzGtP4pH4jxDMczynvdCsrvDmPG+PbUHJHBVXmOXGoeWUyCcYY6fotDZEji+zKycBnv9wSoFWK45ueMxOtPTFPwtb1meaHiXbV7J8Hngab9qncq4YEihZmiOK7h9Buq5/rO/JvYgD7eLIhw2V/XR303LSm1KSinhsWSHudYAiOsD5QY4Y7P4= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:30.5007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09268031-e77d-4fd7-a3b0-08d7426fa0fa X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4576 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The change introduces the `delay` field to the `spi_transfer` struct as an `struct spi_delay` type. This intends to eventually replace `delay_usecs`. But, since there are many users of `delay_usecs`, this needs some intermediate work. A helper called `spi_transfer_delay_exec()` is also added, which maintains backwards compatibility with `delay_usecs`, by assigning the value to `delay` if non-zero. This should maintain backwards compatibility with current users of `udelay_usecs`. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 6 +++--- include/linux/spi/spi.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ba8731b77753..489eb64d9ee0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1238,8 +1238,7 @@ static int spi_transfer_one_message(struct spi_controller *ctlr, if (msg->status != -EINPROGRESS) goto out; - if (xfer->delay_usecs) - _spi_transfer_delay_ns(xfer->delay_usecs * 1000); + spi_transfer_delay_exec(xfer); if (xfer->cs_change) { if (list_is_last(&xfer->transfer_list, @@ -2904,10 +2903,11 @@ struct spi_replaced_transfers *spi_replace_transfers( /* add to list */ list_add(&xfer->transfer_list, rxfer->replaced_after); - /* clear cs_change and delay_usecs for all but the last */ + /* clear cs_change and delay for all but the last */ if (i) { xfer->cs_change = false; xfer->delay_usecs = 0; + xfer->delay.value = 0; } } diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index e7ec0be16a82..2cee9ac35737 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -754,6 +754,9 @@ extern void spi_res_release(struct spi_controller *ctlr, * @cs_change: affects chipselect after this transfer completes * @cs_change_delay: delay between cs deassert and assert when * @cs_change is set and @spi_transfer is not the last in @spi_message + * @delay: delay to be introduced after this transfer before + * (optionally) changing the chipselect status, then starting + * the next transfer or completing this @spi_message. * @delay_usecs: microseconds to delay after this transfer before * (optionally) changing the chipselect status, then starting * the next transfer or completing this @spi_message. @@ -843,6 +846,7 @@ struct spi_transfer { #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ u8 bits_per_word; u16 delay_usecs; + struct spi_delay delay; struct spi_delay cs_change_delay; struct spi_delay word_delay; u32 speed_hz; @@ -942,6 +946,20 @@ spi_transfer_del(struct spi_transfer *t) list_del(&t->transfer_list); } +static inline int +spi_transfer_delay_exec(struct spi_transfer *t) +{ + struct spi_delay d; + + if (t->delay_usecs) { + d.value = t->delay_usecs; + d.unit = SPI_DELAY_UNIT_USECS; + return spi_delay_exec(&d, NULL); + } + + return spi_delay_exec(&t->delay, t); +} + /** * spi_message_init_with_transfers - Initialize spi_message and append transfers * @m: spi_message to be initialized From patchwork Thu Sep 26 10:51:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162377 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 BC52F13B1 for ; Thu, 26 Sep 2019 10:52:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 883FC222C2 for ; Thu, 26 Sep 2019 10:52:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="c7NhsIgH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfIZKwp (ORCPT ); Thu, 26 Sep 2019 06:52:45 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:16080 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726498AbfIZKwn (ORCPT ); Thu, 26 Sep 2019 06:52:43 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqMeL030420; Thu, 26 Sep 2019 06:52:35 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2053.outbound.protection.outlook.com [104.47.49.53]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOc5DTXxtUBJLeskdoZmAAtQG2vtqkTWOZ1N3iPFgr1Pb5ySd00o7oa/LAV5fUaYkqaRv8ClGw8c3NiWFUzefI90vZZ7OyL4yUpPb3/mhA8YCRhMmx7vhNHEmTZdsNArSCBCkjGZJSnNmLbPUlYtsveg3ILHefL/CVM0089h0rks1gXyHrPPGNd44kg9uzS1ZWGS2X2Zf/OxampHtLhAiy4dzNp146GjW2YjJtmhTjt467F166nq56jFH1bWOkxRU9SohbI2IOoTTfT023yiaLBYTZqCJ54mUoFdwq63JYuVbWhxob6rNrzIV5I+b6fH6A4HZS8i9ihxhopwQzX2eQ== 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=hi4om57DIw0BkZGNRK8c0W8ocv9K0HrzmvBKt34fAOQ=; b=CQZWTFK0RQMI7CysHgSH/h5Cx4fT9epwGHnF1GhND3OsIBxu7Z3YBgzfVEWi0vWyZL+hbmEU3uJ8x4Jp4iMwND34OSYcIm2YT71estnjWkk1iRuAd7jJI9cf5B2PXtYqhczQJMoq5Q0CAVBRfvyEadRcM/DHn5MNmgnk2oRCf3TQE63i5CA+9zUIrKA1zzxrcfIEdGJ5LSJ5u7ytfhPdiRYr9j5bJSppXZT/wU6Mf8ULYaJ17Fo61jlGn0rfqdqisNO4FtCH+IRxHqwPxBioJC+2JYQxpk57C33liq0siwkf9I6kShln87ZGxY8Rn9x6vQK1NnKGLixZpPXv9iFQMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hi4om57DIw0BkZGNRK8c0W8ocv9K0HrzmvBKt34fAOQ=; b=c7NhsIgHJimMC95917bN4VMuD2OihPYyHsy11YH7t2y2WNVKDg7mxskQcwFZChnFfcUquP7YEc8d+I26/CPvhM3FazApSyIROnf2k0WdgmjMQq8rR73RrL1hSubXjhfFqbDcrIJTaLnB8Bty4UvYRsTUFXSfGb+freUzfi/vdM0= Received: from BY5PR03CA0007.namprd03.prod.outlook.com (2603:10b6:a03:1e0::17) by BY5PR03MB5063.namprd03.prod.outlook.com (2603:10b6:a03:1e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 10:52:33 +0000 Received: from CY1NAM02FT056.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::206) by BY5PR03CA0007.outlook.office365.com (2603:10b6:a03:1e0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16 via Frontend Transport; Thu, 26 Sep 2019 10:52:33 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by CY1NAM02FT056.mail.protection.outlook.com (10.152.74.160) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:33 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqWOn014797 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:32 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:32 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 09/19] spi: use new `spi_transfer_delay_exec` helper where straightforward Date: Thu, 26 Sep 2019 13:51:37 +0300 Message-ID: <20190926105147.7839-10-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(136003)(346002)(39860400002)(396003)(199004)(189003)(8936002)(36756003)(478600001)(316002)(356004)(246002)(70206006)(70586007)(8676002)(110136005)(50226002)(107886003)(14444005)(4326008)(336012)(11346002)(126002)(305945005)(476003)(426003)(2616005)(2870700001)(446003)(486006)(44832011)(7636002)(7416002)(86362001)(47776003)(2201001)(48376002)(50466002)(106002)(1076003)(5660300002)(186003)(7696005)(26005)(51416003)(2906002)(76176011)(54906003)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY5PR03MB5063;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cdd76148-8bed-41ab-d5c7-08d7426fa2b9 X-MS-TrafficTypeDiagnostic: BY5PR03MB5063: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UWXpvjyW279mmV4e2q+THXrQk9jfMW5a/FRkOpVit7UsSuhdbYvV0Of0md+AivUhJ7Nofj0SKqhZVonyN2/D/YMZ0a/qkzMyB0wFuVyB9/UJyzAqipL9VaJ0khpaOwKXj+oOwsNPqb/S46GzzACG1/txEiKrN85gYfVnMRPR3ELWbFw7J9xCS1jeG9k10FUNFsi7FYgmSeesyiDSuTFbM98SRBORyN8CBYbbwtvtO70jQT/ONrYo81EbC2fRg9+cAb5hN9iEt2pKtv/6lB+v+1AuN5ayfpjPl0VLqf8OvGMPeRdM/lAfspXWfChu8f489hZGHOB5PRkyjjTP+HgLNrGTvMeuNkPLbdR+d7/lXYo+xYgyj3UZrXSNljp7hYf/IOAmYbCfXPd5btP3v8ycGkt4fi85BjJfuFdN1+91gbc= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:33.3764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cdd76148-8bed-41ab-d5c7-08d7426fa2b9 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5063 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org For many places in the spi drivers, using the new `spi_transfer_delay` helper is straightforward. It's just replacing: ``` if (t->delay_usecs) udelay(t->delay_usecs); ``` with `spi_transfer_delay(t)` which handles both `delay_usecs` and the new `delay` field. This change replaces in all places (in the spi drivers) where this change is simple. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-atmel.c | 3 +-- drivers/spi/spi-bcm63xx-hsspi.c | 3 +-- drivers/spi/spi-cavium.c | 3 +-- drivers/spi/spi-fsl-dspi.c | 3 +-- drivers/spi/spi-fsl-espi.c | 3 +-- drivers/spi/spi-fsl-spi.c | 3 +-- drivers/spi/spi-mpc512x-psc.c | 3 +-- drivers/spi/spi-mpc52xx-psc.c | 3 +-- drivers/spi/spi-omap-100k.c | 3 +-- drivers/spi/spi-pl022.c | 25 +++++++++++-------------- drivers/spi/spi-sc18is602.c | 3 +-- drivers/spi/spi-sh-hspi.c | 3 +-- drivers/spi/spi-topcliff-pch.c | 7 +------ drivers/spi/spi-txx9.c | 3 +-- drivers/spi/spi-xcomm.c | 3 +-- 15 files changed, 25 insertions(+), 46 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index f04b92791515..2f7388e53b82 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1389,8 +1389,7 @@ static int atmel_spi_one_transfer(struct spi_master *master, && as->use_pdc) atmel_spi_dma_unmap_xfer(master, xfer); - if (xfer->delay_usecs) - udelay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); if (xfer->cs_change) { if (list_is_last(&xfer->transfer_list, diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index 9a06ffdb73b8..949b59b6449f 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -291,8 +291,7 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master, msg->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (t->cs_change) bcm63xx_hsspi_set_cs(bs, spi->chip_select, false); diff --git a/drivers/spi/spi-cavium.c b/drivers/spi/spi-cavium.c index 5aaf21582cb5..6854c3ce423b 100644 --- a/drivers/spi/spi-cavium.c +++ b/drivers/spi/spi-cavium.c @@ -119,8 +119,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, *rx_buf++ = (u8)v; } - if (xfer->delay_usecs) - udelay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); return xfer->len; } diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 53335ccc98f6..736071e2b9d8 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -752,8 +752,7 @@ static int dspi_transfer_one_message(struct spi_master *master, dspi->waitflags = 0; } - if (transfer->delay_usecs) - udelay(transfer->delay_usecs); + spi_transfer_delay_exec(transfer); } out: diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index f20326714b9d..732bf3195917 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -427,8 +427,7 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans) ret = fsl_espi_bufs(spi, trans); - if (trans->delay_usecs) - udelay(trans->delay_usecs); + spi_transfer_delay_exec(trans); return ret; } diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 1d9b33aa1a3b..139ab57aec99 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -417,8 +417,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master, } m->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (cs_change) { ndelay(nsecs); diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index a337b842ae8c..ea1b07953d38 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -311,8 +311,7 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master, break; m->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (cs_change) mpc512x_psc_spi_deactivate_cs(spi); diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index c7e478b9b586..17935e71b02f 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c @@ -234,8 +234,7 @@ static void mpc52xx_psc_spi_work(struct work_struct *work) break; m->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (cs_change) mpc52xx_psc_spi_deactivate_cs(spi); diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c index b955ca8796d2..89608eb55f1f 100644 --- a/drivers/spi/spi-omap-100k.c +++ b/drivers/spi/spi-omap-100k.c @@ -321,8 +321,7 @@ static int omap1_spi100k_transfer_one_message(struct spi_master *master, } } - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); /* ignore the "leave it on after last xfer" hint */ diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 7fedea67159c..3024c30e7f2e 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -485,12 +485,11 @@ static void giveback(struct pl022 *pl022) struct spi_transfer, transfer_list); /* Delay if requested before any change in chip select */ - if (last_transfer->delay_usecs) - /* - * FIXME: This runs in interrupt context. - * Is this really smart? - */ - udelay(last_transfer->delay_usecs); + /* + * FIXME: This runs in interrupt context. + * Is this really smart? + */ + spi_transfer_delay_exec(last_transfer); if (!last_transfer->cs_change) { struct spi_message *next_msg; @@ -1401,12 +1400,11 @@ static void pump_transfers(unsigned long data) previous = list_entry(transfer->transfer_list.prev, struct spi_transfer, transfer_list); - if (previous->delay_usecs) - /* - * FIXME: This runs in interrupt context. - * Is this really smart? - */ - udelay(previous->delay_usecs); + /* + * FIXME: This runs in interrupt context. + * Is this really smart? + */ + spi_transfer_delay_exec(previous); /* Reselect chip select only if cs_change was requested */ if (previous->cs_change) @@ -1520,8 +1518,7 @@ static void do_polling_transfer(struct pl022 *pl022) previous = list_entry(transfer->transfer_list.prev, struct spi_transfer, transfer_list); - if (previous->delay_usecs) - udelay(previous->delay_usecs); + spi_transfer_delay_exec(previous); if (previous->cs_change) pl022_cs_control(pl022, SSP_CHIP_SELECT); } else { diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c index 11acddc83304..5497eeb3bf3e 100644 --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c @@ -211,8 +211,7 @@ static int sc18is602_transfer_one(struct spi_master *master, } status = 0; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); } m->status = status; spi_finalize_current_message(master); diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c index 7f73f91d412a..a62034e2a7cb 100644 --- a/drivers/spi/spi-sh-hspi.c +++ b/drivers/spi/spi-sh-hspi.c @@ -190,8 +190,7 @@ static int hspi_transfer_one_message(struct spi_controller *ctlr, msg->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (cs_change) { ndelay(nsecs); diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index f88cbb94ce12..223353fa2d8a 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -1229,12 +1229,7 @@ static void pch_spi_process_messages(struct work_struct *pwork) "%s:data->current_msg->actual_length=%d\n", __func__, data->current_msg->actual_length); - /* check for delay */ - if (data->cur_trans->delay_usecs) { - dev_dbg(&data->master->dev, "%s:delay in usec=%d\n", - __func__, data->cur_trans->delay_usecs); - udelay(data->cur_trans->delay_usecs); - } + spi_transfer_delay_exec(data->cur_trans); spin_lock(&data->lock); diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c index 51759d3fd45f..83daaa597acc 100644 --- a/drivers/spi/spi-txx9.c +++ b/drivers/spi/spi-txx9.c @@ -248,8 +248,7 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m) len -= count * wsize; } m->actual_length += t->len; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); if (!cs_change) continue; diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index a3496c46cc1b..1d9b3f03d986 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -188,8 +188,7 @@ static int spi_xcomm_transfer_one(struct spi_master *master, } status = 0; - if (t->delay_usecs) - udelay(t->delay_usecs); + spi_transfer_delay_exec(t); is_first = false; } From patchwork Thu Sep 26 10:51:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162435 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 4E75517EE for ; Thu, 26 Sep 2019 10:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C67E207E0 for ; Thu, 26 Sep 2019 10:53:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="z5t9C7+w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbfIZKwp (ORCPT ); Thu, 26 Sep 2019 06:52:45 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:55238 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfIZKwo (ORCPT ); Thu, 26 Sep 2019 06:52:44 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqaKX006040; Thu, 26 Sep 2019 06:52:38 -0400 Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2056.outbound.protection.outlook.com [104.47.32.56]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hj96rc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jp9mDqsO1ULkQD+isvsrtAzz+YdH6U3AzGC9EXC6RCvxzqMLH+Wyc9AXBYdyeK+lGu97tVrmxhk0hQR/4ejyWdQox4N9dGU+Ry+I4Xw5tUz83ErcaU9Me1GEaedR7teVlNDZTlXk/y14CfBqGZ0y7Gn304aHUWMOQTij+RwOsKqsbx1bGLjCq72T8jipOXyECGHYzd4BIwJVh2VfPJ+rHQGZw9T6DJytaeDcBnJdUlg/bUWYcnqlSF8EHmMmwDPxEZbntKZ54TCGkwpMYbb+lbt6WQWtkItVf3pLZfv6DOb1GF9G6hWmbFeoioJ6BZSADCHNyog6SyGm6oT41gNVjQ== 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=zQjYpYv97m4TZLPufi3D9ESbTPdJRj3NrXmqIglhcCY=; b=dhtokO2NKe9a5aVEsRNkjScnmdkCGJF/C8GMecegzCLdKXiHPlwLzwlfhxTqWyAcw6Ipu5FFHLZFNYw8PiQe/ZKf5F6B1SGr1XAFBT+OC0KU4qIM23Niv0C8jMVaxpzYfwTvNkluTgEukJPR2j87VcyWYgKngidZA/MdO22hy+G8PonQomeqTKQ1Pb7Xnz9S1FOC7X0PIxqbOH3qGw65E3biCF6sJ8gZPoIvNBETUecAB4paXyUvsEgsRu3JanyeqfjNDV/MQgcNMb8uZdNGQOaF1q62CkUNdoAtdFnjDKXRLk6lZ6CVs3+q1rCuDNUpWMyvs0XlqHFbmK4QW4R79A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zQjYpYv97m4TZLPufi3D9ESbTPdJRj3NrXmqIglhcCY=; b=z5t9C7+wBEZsd/KTgyFW5lNEU+uR+bbLhCSmYs3nWxxJFyg/sMINCCMWAT/2H4h8RUKQwscdeVg4LQr342MgzSjQep2ZNrJau016s0gL8eFkVO8iJBJtPdICZuFUfLex8vWZ/TjqnWEs5fYHxbASi/XBya2qjMdmMHe7PjxvMa8= Received: from BN3PR03CA0105.namprd03.prod.outlook.com (2603:10b6:400:4::23) by CO2PR03MB2262.namprd03.prod.outlook.com (2603:10b6:102:e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.22; Thu, 26 Sep 2019 10:52:36 +0000 Received: from CY1NAM02FT009.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::201) by BN3PR03CA0105.outlook.office365.com (2603:10b6:400:4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:36 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by CY1NAM02FT009.mail.protection.outlook.com (10.152.75.12) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:35 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqZC6014810 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:35 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:35 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 10/19] spi: tegra114: use `spi_transfer_delay_exec` helper Date: Thu, 26 Sep 2019 13:51:38 +0300 Message-ID: <20190926105147.7839-11-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(396003)(136003)(39860400002)(376002)(189003)(199004)(5660300002)(11346002)(186003)(426003)(336012)(446003)(47776003)(246002)(86362001)(8676002)(356004)(2201001)(7696005)(51416003)(76176011)(70586007)(26005)(8936002)(1076003)(36756003)(7416002)(50226002)(316002)(2616005)(478600001)(476003)(126002)(305945005)(70206006)(2870700001)(7636002)(2906002)(486006)(48376002)(50466002)(44832011)(107886003)(4326008)(106002)(54906003)(110136005)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2262;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7adebd68-1379-459c-4a9f-08d7426fa43d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:CO2PR03MB2262; X-MS-TrafficTypeDiagnostic: CO2PR03MB2262: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:751; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: FOnZWXI7wTpVDeZ0tQB/JJaFJT2QCblRFy+VOS87TJQr9kJtSg2gpTnkrwITwIHYPq01Te6Iq3KSwybUTWEPlOG9xyVE1m6r9NEoWB9aUY3lue/9io26QZo1o/82y5fmupke25GHXiG/gEipGB2EsMFUHND3Snz8XKMoSu7fTga+VXnGTP+4e+4/vr3Y5MoQmaFUIa5WEYXZbSRmZDQFT05S4vDwQQB4673NFkWlgAjUWIRnf6T2KTJUW1A+88RhZ4imj+6ZOH/hE6/oG71A2beRZWTlNmK92t+lHE9SKB0eG7d3etuTyI8xEUZk8VyXW//7NktIwyRpnKlB59jOrEubyaGw9J37Mdo4pfEv1WR0GP/s3QmO0N020DjMjEZ9gpGimJv+7Yt8fQ6rWQeOwAMcHfA0GlkIV07eHTt/5EY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:35.9186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7adebd68-1379-459c-4a9f-08d7426fa43d X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2262 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The tegra114 driver has a weird/separate `tegra_spi_transfer_delay()` function that does 2 delays: one mdelay() and one udelay(). This was introduced via commit f4fade12d506e14867a2b0a5e2f7aaf227297d8b ("spi/tegra114: Correct support for cs_change"). There doesn't seem to be a mention in that commit message to suggest a specific need/use-case for having the 2 delay calls. For the most part, udelay() should be sufficient. This change replaces it with the new `spi_transfer_delay_exec()`, which should do the same thing. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-tegra114.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index 39374c2edcf3..8133dc49d34f 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -984,17 +984,6 @@ static int tegra_spi_setup(struct spi_device *spi) return 0; } -static void tegra_spi_transfer_delay(int delay) -{ - if (!delay) - return; - - if (delay >= 1000) - mdelay(delay / 1000); - - udelay(delay % 1000); -} - static void tegra_spi_transfer_end(struct spi_device *spi) { struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); @@ -1098,7 +1087,7 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, complete_xfer: if (ret < 0 || skip) { tegra_spi_transfer_end(spi); - tegra_spi_transfer_delay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); goto exit; } else if (list_is_last(&xfer->transfer_list, &msg->transfers)) { @@ -1106,11 +1095,11 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, tspi->cs_control = spi; else { tegra_spi_transfer_end(spi); - tegra_spi_transfer_delay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); } } else if (xfer->cs_change) { tegra_spi_transfer_end(spi); - tegra_spi_transfer_delay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); } } From patchwork Thu Sep 26 10:51:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162379 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 583F213B1 for ; Thu, 26 Sep 2019 10:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D75E217F4 for ; Thu, 26 Sep 2019 10:52:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="SFceQgge" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbfIZKwr (ORCPT ); Thu, 26 Sep 2019 06:52:47 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:18718 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbfIZKwr (ORCPT ); Thu, 26 Sep 2019 06:52:47 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqbYg018188; Thu, 26 Sep 2019 06:52:41 -0400 Received: from nam03-co1-obe.outbound.protection.outlook.com (mail-co1nam03lp2054.outbound.protection.outlook.com [104.47.40.54]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hkcq434-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PnZTgvniy2TAyRo4p6Ffs4QNWURMQ78EYY283xmjr0+U2jTHmJX5jBh691W0FSilAddCJBwvXYDx68ssEHq+ZCL9Vd2mpyg8DOttLE5ibJUcyJdXHygwOWbG1ZgbwjvEAfO0hPgChJFcNx+JDPZPjQOfj3H9k/gL3IYhCMspmQh4QPMNW0mHOdvEzAwFSbhYy2Ztg8QQzbzfp+J0rxn28psIMJPJpnXPkb8rTIDcqRrNsRHpqGoC0itRzeKjpPLiVqre6qaIjkeO4AfqMblFT8o0205LHi6Dt4+dxLUtZpHPX1XWsrCyZwj1y4OvuDJISOT69AmcYR+ofMfIEXoxlQ== 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=w05f36Wri849xiCzTE3iZCvCsD7YL9/WVdiYhFde67U=; b=hqsikHl2pUjBMRGE4ScjjgC6OeyUVXg8SqeHJ/yzOMIAeUuR8LNkowL1PGjHQe0VokDp7t69nxHnVlZjGVIkM4a61uPLqd640i7/M7AOsWmSgpZJAyr6uQqEaiytnlpB5IpFmPZ0zBWTZhyo3qdjt6HZ46tHjXkdTcbM2VBSUaw5q0G9sWd5nrxomr/gE+D8GInz+U1pBp08ziNiq6OYY6na4e0f9zj4RMk1A3aWEYcaYAod8Ncs/LN0Y0SwCg55o1OR3S53iX3Ktb1/nc7n1vLfqaPrACy4nYuzPP66PVSdmOqBj5DFbbbseOhZBQhPrAJKKRfCBAOWtem9DrHbLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w05f36Wri849xiCzTE3iZCvCsD7YL9/WVdiYhFde67U=; b=SFceQggewwmjjS+NFQPNar42HYkuNKq0ckzW+vOm71vdQWefv8t41Ey3soUDqXj6YIUNqWauMpvxZ303kIWNaeazfel+95FfmJQJmqtt+lsRNoMPI3dhmbNJ7FtGj4S4G/A6AFEwlsefY5vg5OvL1VMtyUdAa+t5WTRswD/AJ0w= Received: from BY5PR03CA0011.namprd03.prod.outlook.com (2603:10b6:a03:1e0::21) by CH2PR03MB5176.namprd03.prod.outlook.com (2603:10b6:610:97::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 10:52:39 +0000 Received: from CY1NAM02FT060.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::208) by BY5PR03CA0011.outlook.office365.com (2603:10b6:a03:1e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:39 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by CY1NAM02FT060.mail.protection.outlook.com (10.152.74.252) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:38 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqcBE014819 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:38 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:37 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 11/19] spi: tegra20-sflash: use to new `spi_transfer_delay_exec` Date: Thu, 26 Sep 2019 13:51:39 +0300 Message-ID: <20190926105147.7839-12-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(136003)(396003)(39860400002)(376002)(189003)(199004)(106002)(110136005)(54906003)(246002)(1076003)(8676002)(2870700001)(2906002)(356004)(316002)(4326008)(107886003)(7416002)(446003)(476003)(26005)(426003)(126002)(44832011)(478600001)(48376002)(86362001)(186003)(76176011)(336012)(50466002)(7696005)(36756003)(486006)(51416003)(305945005)(7636002)(2201001)(70206006)(8936002)(2616005)(11346002)(50226002)(47776003)(70586007)(5660300002)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CH2PR03MB5176;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d447ccc-1b0a-4503-925a-08d7426fa601 X-MS-TrafficTypeDiagnostic: CH2PR03MB5176: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o/vWeW8jf3g2DylBRygCIbbuFONlhFA5jOhue7SIyFpZHZlTJqOCC5AiIvsCG4L4414W8ALLDkyMKlHIPjrPnX6o2TD/DqfGHRCGwvScegDQ08mXawM4AJfMlcg8Nauwx+PTewcJ1yibydyFwfO0ecVSJyDhWtCC9vOuG82dYo4YmFad/3W6B/dBjxFypOMe9f2yabYt8X2lj3kMsIPcm2ybJV+436YtO38HiENxUqDE0x2bMhDUUmzIZ81+CwNSzGUszXSHwTNdJPZ6T13fG6U7IouXmoEjd1O10ifJBoo4UopmAp/+TBRWoiuUd1Jm0dCeUed3Me+yMxdewq3EYlOS4GXEO0Bne3WiaglKVx+mXgdaDkqG4EFMnwgtC+ICcsi9bR5AcYGprYuN2id9lfOxfgbz13jN2IGFUrrXIeA= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:38.8817 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d447ccc-1b0a-4503-925a-08d7426fa601 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR03MB5176 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This conversion to the spi_transfer_delay_exec() helper is not straightforward, as it seems that when a delay is present, the controller issues a command, and then a delay is followed. This change adds support for the new `delay` field which is of type `spi_delay` and keeps backwards compatibility with the old `delay_usecs` field. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-tegra20-sflash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c index cd714a4f52c6..ff1933e55830 100644 --- a/drivers/spi/spi-tegra20-sflash.c +++ b/drivers/spi/spi-tegra20-sflash.c @@ -341,10 +341,11 @@ static int tegra_sflash_transfer_one_message(struct spi_master *master, goto exit; } msg->actual_length += xfer->len; - if (xfer->cs_change && xfer->delay_usecs) { + if (xfer->cs_change && + (xfer->delay_usecs || xfer->delay.value)) { tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND); - udelay(xfer->delay_usecs); + spi_transfer_delay_exec(xfer); } } ret = 0; From patchwork Thu Sep 26 10:51:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162427 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 84D9F13B1 for ; Thu, 26 Sep 2019 10:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59354217F4 for ; Thu, 26 Sep 2019 10:53:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="xIMV4E33" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbfIZKxj (ORCPT ); Thu, 26 Sep 2019 06:53:39 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:58164 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbfIZKwt (ORCPT ); Thu, 26 Sep 2019 06:52:49 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqSbm003879; Thu, 26 Sep 2019 06:52:44 -0400 Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2059.outbound.protection.outlook.com [104.47.36.59]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hj96rch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DzvZ5yhm/S0nInjkC2xtfK8k9BwenpYcSE1xmRiLk628OLZoASjIK5wgsWi4Tinq4hb6EZM97moqouqfjFvXSV1HtZuMUqrWX75phwnqUwbCgWRHyelMZRmd94HWaT1qLeWkBcvuvIwQsAqaquftq6rFsJlZEnWSzXgWhaVY1EUlpEgaCt1XZd0iUu8FOt27QotBrzS545OggN944AlFUWrqeeliddZNkCahdHAxeSGdfd3P+UdB3wO/9YkU0EgwsfWrB89mwHs8eFrG5sMA3kh1B7LQktJLo3GArwMEcO6ADoH7Nys2YKz1vCeYl9k3haif5F8ZfxnRZIIrXFrPVg== 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=8eZVsTNwzDgCxa0wjOHr/PorZMO2qAzcIXvyuqXf5D8=; b=NODGpkYVaPFGyL2UIEkH9wZDXAfY/JdyqFi+dLJBt53zNKmLZoPZ4Dk/PCVpVmLRZDzL9CVdmO/EMupkjBiDBAJs134w5GDmg3Ur9Ukj3KRHDawTuahBdH63z2HrLns4aGcX0IrO5UCshN+DkVXwagI5UR198jPkkk3cKGFqtEoNoPfIEjNfhPNMYBIz5kJCVf4PUXE0hpUVn/vT4XwCnQopPpt9TiHH/I0+o3re04DOEQ9Rk5AYKKsj8S2GFJvEmNp6uIgsx7OwgjhoTqNXWfkbbzXVIpYhRUzvrnaNlZIj/MFjNwQeveVpqskIgigRJvA0bZdHQcjLv1G7SZDkfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8eZVsTNwzDgCxa0wjOHr/PorZMO2qAzcIXvyuqXf5D8=; b=xIMV4E33Fz/2wyvrAF3SJVw4lO0thekKhLXBu3oNhexc6jGtp6vIOqOgwKJeW0A/mIHNPFvE/LRo8uVK+wO9dZZFmA09stbm8m9IhFXNOWT51bAgKy9pDXXluALTc0MmiohPLmzQ7xCa/c0r2q2XUQg/p1mUUJ3qykVBBGy2yYI= Received: from BN6PR03CA0023.namprd03.prod.outlook.com (2603:10b6:404:23::33) by MWHPR03MB3136.namprd03.prod.outlook.com (2603:10b6:301:3c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Thu, 26 Sep 2019 10:52:42 +0000 Received: from SN1NAM02FT059.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::203) by BN6PR03CA0023.outlook.office365.com (2603:10b6:404:23::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.22 via Frontend Transport; Thu, 26 Sep 2019 10:52:41 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT059.mail.protection.outlook.com (10.152.72.177) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:41 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqf3H014837 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:41 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:40 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 12/19] spi: spi-loopback-test: use new `delay` field Date: Thu, 26 Sep 2019 13:51:40 +0300 Message-ID: <20190926105147.7839-13-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(39860400002)(346002)(396003)(199004)(189003)(126002)(2201001)(8936002)(476003)(86362001)(2906002)(5660300002)(1076003)(11346002)(48376002)(426003)(486006)(106002)(70586007)(50226002)(36756003)(2616005)(446003)(478600001)(336012)(8676002)(47776003)(7636002)(356004)(44832011)(51416003)(70206006)(50466002)(76176011)(305945005)(7696005)(186003)(4326008)(110136005)(26005)(7416002)(107886003)(316002)(246002)(2870700001)(54906003)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB3136;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34e14b9f-4c75-4790-0342-08d7426fa7b2 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:MWHPR03MB3136; X-MS-TrafficTypeDiagnostic: MWHPR03MB3136: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: RHBTwGjh3Oq37W1evFD1OFrktx8f3wyESOMTmDe2w+9oaH+jOb91DsgfgXHv0gkNZ3X38piiEhFRJ05Y1XXb9onuaah/ftqNx6uC7ZjYMoWADGtWDirlYbF1pThrNrd7HfFULqwYB+82HS2rAFu8ycjYXxxT5tXZmemPCpZeBpMFlcvCKC4VHfuKl3aOKSuAFpSsVMfXuuNjYyMA4qKbnK57pDgqON/w9i4LvWuDdBxPISPFs5AjX2mWmx43z3z9ZsMgnqX76gFjCBy4kJnH91vV7yAyAvgI8BVaWlSQUAequyJhmVApPGe8+zx8W2bUAAaLp3oaosMdDVkgLPzVO75aWEGDySRSe8tiggAvNdqJFoNXm7Y5E+tt6XhaGYYgNhbHkPCHvvdkvR47oWZkhW0Wh09nS3H69ltJlF+FJNo= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:41.7207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34e14b9f-4c75-4790-0342-08d7426fa7b2 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3136 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=959 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This change replaces the use of the `delay_usecs` field with the new `delay` field. The code/test still uses micro-seconds, but they are now configured and used via the `struct spi_delay` format of the `delay` field. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-loopback-test.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index 6f18d4952767..b6d79cd156fb 100644 --- a/drivers/spi/spi-loopback-test.c +++ b/drivers/spi/spi-loopback-test.c @@ -298,12 +298,18 @@ static struct spi_test spi_tests[] = { { .tx_buf = TX(0), .rx_buf = RX(0), - .delay_usecs = 1000, + .delay = { + .value = 1000, + .unit = SPI_DELAY_UNIT_USECS, + }, }, { .tx_buf = TX(0), .rx_buf = RX(0), - .delay_usecs = 1000, + .delay = { + .value = 1000, + .unit = SPI_DELAY_UNIT_USECS, + }, }, }, }, @@ -537,7 +543,7 @@ static int spi_test_check_elapsed_time(struct spi_device *spi, unsigned long long nbits = (unsigned long long)BITS_PER_BYTE * xfer->len; - delay_usecs += xfer->delay_usecs; + delay_usecs += xfer->delay.value; if (!xfer->speed_hz) continue; estimated_time += div_u64(nbits * NSEC_PER_SEC, xfer->speed_hz); From patchwork Thu Sep 26 10:51:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162425 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 D756C17EE for ; Thu, 26 Sep 2019 10:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB9DC217F4 for ; Thu, 26 Sep 2019 10:53:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="sTb4qL/S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbfIZKxd (ORCPT ); Thu, 26 Sep 2019 06:53:33 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:21918 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbfIZKww (ORCPT ); Thu, 26 Sep 2019 06:52:52 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqM3x030423; Thu, 26 Sep 2019 06:52:48 -0400 Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2053.outbound.protection.outlook.com [104.47.44.53]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3m0ZnZER1ZaiNM8rnCmi/MqNrnMQZp1MMEyi3AiUCKbzB8QPXIGnnVam/GNhCP2pFSlQBqGtrS6hraHqeQz2NRtETsmn1uTqX1x1nzn/CQx+IhnkY5jVsiLE87J82lNRPxcSYU114nRFlSN+ewHdBIK3z0vFGlnc5RC5g49jrNy7FsiZS8/lNDCsan9FzYEd0vK+rEE0XlIhdQzYZnBEOD7k2U+tgnNDK2kuv/25gB/HdmGxgyfhrpTTNzs20ArGqR5v4q5CRuSJIWTV9WyLNHLcNTwxw01+iMSzxMeoDLc4kbORM06rL5Fr+DbxDWHRBUhlfUazeKCEz1I58jDIg== 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=wcho7dNaBtNYW5hFLUgvhiw90bmxoe0Gvww+cecPTYg=; b=d8niedwgn16EW3N4Pmp2WNWT0PiIYVne7bgQXcCDtH8sf2HZ/UsH7upWF/ikgl2JGfvNrMr0RlwgNQefsQV3T1JADjQj90pM73gJ7TJOuSYAak/1P0p6GLDE2/tF3m8JGyybtEM23U7OnjG13IcuzVFJKumCedg6RWk6F1g79KStW2OFrREHuD83Lm1fLJ3qP/whmkJSNTA1hOEFDe2yHL16a5EBIPU3d7hvw7pWZe7zrAM9TiM5sO69o11k/I1KonNSKojAO4f42j5wREqwHpaNX3VcmzoKWRrONMIyxZwdUeEBrUVr0Gi6VWODcF/VztLWlg38wpMGjfyThO6ymg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wcho7dNaBtNYW5hFLUgvhiw90bmxoe0Gvww+cecPTYg=; b=sTb4qL/SquBZ8FylMgWah2HVCIAfx5mvffizLU5NK2DuDHbr/oHo5bZcmb520ZB7P1yIrFp3muL1uPALVJD9MSLVYEOxzg7Dwiq5civVN53uvmMxBmzTBicugkGPsqRkPwrF1ePWmdQDUvMB3Q/aR2CVB4xdaykMUhOfbxSHaco= Received: from BN6PR03CA0089.namprd03.prod.outlook.com (2603:10b6:405:6f::27) by CY1PR0301MB0604.namprd03.prod.outlook.com (2a01:111:e400:4c29::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 10:52:45 +0000 Received: from SN1NAM02FT064.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::209) by BN6PR03CA0089.outlook.office365.com (2603:10b6:405:6f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.22 via Frontend Transport; Thu, 26 Sep 2019 10:52:44 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT064.mail.protection.outlook.com (10.152.72.143) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:44 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqiHD014894 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:44 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:43 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 13/19] spi: spidev: use new `delay` field for spi transfers Date: Thu, 26 Sep 2019 13:51:41 +0300 Message-ID: <20190926105147.7839-14-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(396003)(39860400002)(136003)(376002)(199004)(189003)(186003)(26005)(486006)(36756003)(11346002)(446003)(50226002)(2616005)(5660300002)(476003)(44832011)(126002)(47776003)(86362001)(426003)(336012)(2906002)(7696005)(51416003)(76176011)(246002)(356004)(478600001)(50466002)(70586007)(70206006)(8676002)(48376002)(1076003)(305945005)(316002)(7416002)(106002)(2870700001)(7636002)(2201001)(107886003)(54906003)(4326008)(110136005)(8936002)(14444005)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0301MB0604;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cddd51b3-c296-451b-90c7-08d7426fa97c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:CY1PR0301MB0604; X-MS-TrafficTypeDiagnostic: CY1PR0301MB0604: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: YufJBGxFPPMJPMmc09AVYgY/HUOtN0M0vT1+HXb2AFjl8jDH5T2lCKDBeDnoEdnGiNeVJ9PFafEcaKfqzNMPlGnCjhN3BL5yl/NmO0Ek75wPC3fgkEadIFNBW0n20oOfTbmeFK2MDl32LD7t0vFqQpuAX76TLm1qBnJCKDUKKqqRSY0tdQwWNtFzN5KWwl3lfLaMwMoC6VH+b0S1mF9r/9ZLWSiDW0KMl5/F1dBm780guPfGgkrTylt9OfENv9Rpr60qeU0SOZALuqu4K66C8ujYXbVrs/uHFNnSmx5e/hc56uxsoMhXDv2n20kPii1c/dNTKjNgTwyl05BfxFyZtIlmEgpMt7rTspKrmL/3qbz5DKHVrNcLuniNVT7EUtaPurEgHztyHf87b/WmolqmgrWlDmzUSlEWpLTGkpCE7H0= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:44.7149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cddd51b3-c296-451b-90c7-08d7426fa97c X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0604 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=720 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The `delay` field has type `struct spi_delay`. This allows users to specify nano-second or clock-cycle delays (if needed). Converting to use `delay` is straightforward: it's just assigning the value to `delay.value` and hard-coding the `delay.unit` to `SPI_DELAY_UNIT_USECS`. This keeps the uapi for spidev un-changed. Changing it can be part of another changeset and discussion. Signed-off-by: Alexandru Ardelean --- drivers/spi/spidev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 495319c2fa11..6b6afd27f4a1 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -265,7 +265,8 @@ static int spidev_message(struct spidev_data *spidev, k_tmp->tx_nbits = u_tmp->tx_nbits; k_tmp->rx_nbits = u_tmp->rx_nbits; k_tmp->bits_per_word = u_tmp->bits_per_word; - k_tmp->delay_usecs = u_tmp->delay_usecs; + k_tmp->delay.value = u_tmp->delay_usecs; + k_tmp->delay.unit = SPI_DELAY_UNIT_USECS; k_tmp->speed_hz = u_tmp->speed_hz; k_tmp->word_delay.value = u_tmp->word_delay_usecs; k_tmp->word_delay.unit = SPI_DELAY_UNIT_USECS; From patchwork Thu Sep 26 10:51:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162383 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 55EAF13B1 for ; Thu, 26 Sep 2019 10:52:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35571217F4 for ; Thu, 26 Sep 2019 10:52:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="qC1YoG+C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726631AbfIZKw4 (ORCPT ); Thu, 26 Sep 2019 06:52:56 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:22842 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbfIZKwy (ORCPT ); Thu, 26 Sep 2019 06:52:54 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqb1c030478; Thu, 26 Sep 2019 06:52:48 -0400 Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2055.outbound.protection.outlook.com [104.47.38.55]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKXBjKZhf+7CvPcKNNBxDbww/X7zvH/wKvJD6uXQy3cgk/yLFiJz2Pra6mxsZF9vEj+MbvsPLvzBx0iNqdG6mlPgHuRNFMhvFKp0+eJyt5rBvRPFRp0KgCu/+y3Mp8DcCAMRHHTD55+yexdUQcLO00vXFXSsi4htHCe5iSCegQYzA5PWOstuRsx9IcaqJJK5zhixTBTmFQOkzBO4YUYz8tOCkb28ZACAVrCuA9hY6TTbm89+Xv0zn+ggenAaUKM1f4Ov+H7MvaBvZBjBf1D0gYo8b38gpnBBrToSSzegJcdSoE+CWTaT/kWMxeFWxWHdzHFLGbKufME8msxMYRzI8g== 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=f+7423BkJzCqmsqWEghpVVLVCR2CrstT6eNiTJOyxnE=; b=dH2Gd0CpyL+zjF1I/CWeawl9xM9OoalifbnHLwbeRfAdsYTSXJZrwJKirN/loJXpWdO+pQfjTahYdpbwx08bipwxxP6K1QKog5WrJCl3jXoezR7EeMLxl7Py1EB/XrLJrvvdqeIqaj7wsZh0ab1Tu9H31tQO0YOh8G1tmrmYBxEORsoULWDPh0nWV8RL2WdeS4egr7OTnbo32NF9+noo5iqwV/M8VaxochUcscO7tkXYcfmCu8BLnVbrtaKoIwKCS3cW1nzjcovzA0ViK9VgyB+IycDCtr1p/mHeJ4O2/Zy2MMEPmRqdylzCi3i7CVBiBU4g6G1j66sljhBmvEaiUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f+7423BkJzCqmsqWEghpVVLVCR2CrstT6eNiTJOyxnE=; b=qC1YoG+CmNSUft8H0NpTD9ncgZqWTF4XqFDPcqkiZTc2NsSI+gHJxTAUKi+GHfqDoy2LEhjm2S0C8zNQNUH/TKn8Bv6s6vZWyMlCyJUA+VPfN1Xg88TsYnGiYNy7jEy2FDtAKIuT+EmlrovN3y2UlMKRYujwWFOxiScthDY0z2M= Received: from CH2PR03CA0010.namprd03.prod.outlook.com (2603:10b6:610:59::20) by MN2PR03MB4622.namprd03.prod.outlook.com (2603:10b6:208:af::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16; Thu, 26 Sep 2019 10:52:47 +0000 Received: from BL2NAM02FT032.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::201) by CH2PR03CA0010.outlook.office365.com (2603:10b6:610:59::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:47 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT032.mail.protection.outlook.com (10.152.77.169) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:46 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqkhH014966 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:46 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:46 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 14/19] spi: tegra114: change format for `spi_set_cs_timing()` function Date: Thu, 26 Sep 2019 13:51:42 +0300 Message-ID: <20190926105147.7839-15-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(396003)(39860400002)(136003)(346002)(199004)(189003)(106002)(2870700001)(7416002)(1076003)(54906003)(2906002)(110136005)(2201001)(316002)(26005)(186003)(7696005)(8676002)(76176011)(486006)(44832011)(2616005)(476003)(305945005)(50466002)(126002)(8936002)(7636002)(36756003)(51416003)(478600001)(11346002)(446003)(426003)(246002)(50226002)(336012)(47776003)(70206006)(5660300002)(70586007)(356004)(107886003)(86362001)(6666004)(48376002)(4326008)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR03MB4622;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 263be4c1-063f-4292-0d11-08d7426faac3 X-MS-TrafficTypeDiagnostic: MN2PR03MB4622: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j9B5FSEobqYjrsQz7No1xzG+bqPZR3VfPsOcL1S77b6q/AeynTF/mjYyegk+CVOZYm/iAWgnTBqPsnW48EqKwY8jg/Mg+7ldTEqXftoxwndGIE53VbB6NpFjFr5c0O2Ma8AOP2ZXrae/SWN9wuviQRVN4gscvFEHMFzEmfBx+6e91ZUA4lSRSt41y6rxKvurAAyo7Elp/O7Nb4oMokqH+n+Ri0l70bHQV0ZyTx/oRsEe3Z0Mq0TI+h0HOspRcp/VThr/BkHzLQDu35gicJDa7RPyZbEVWpOUd+dA3qiweo2eAgX4OkI7SxR87k14C18+Ye7J1E6YZ5n0i4InvFqBlaKpQ54Yir7YF91m4w7uQiYbadAF5pi3u5NbItM868ng2yx+x0+fDxTnBAiLcLQr92+8H1KT8mA7DSOyqEgf1Kc= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:46.9366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 263be4c1-063f-4292-0d11-08d7426faac3 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4622 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The initial version of `spi_set_cs_timing()` was implemented with consideration only for clock-cycles as delay. For cases like `CS setup` time, it's sometimes needed that micro-seconds (or nano-seconds) are required, or sometimes even longer delays, for cases where the device needs a little longer to start transferring that after CS is asserted. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-tegra114.c | 22 ++++++++++++++++++++-- drivers/spi/spi.c | 16 ++++++++++------ include/linux/spi/spi.h | 9 ++++++--- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index 8133dc49d34f..e6a450d9b4f0 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -723,15 +723,31 @@ static void tegra_spi_deinit_dma_param(struct tegra_spi_data *tspi, dma_release_channel(dma_chan); } -static void tegra_spi_set_hw_cs_timing(struct spi_device *spi, u8 setup_dly, - u8 hold_dly, u8 inactive_dly) +static int tegra_spi_set_hw_cs_timing(struct spi_device *spi, + struct spi_delay *setup, + struct spi_delay *hold, + struct spi_delay *inactive) { struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); + u8 setup_dly, hold_dly, inactive_dly; u32 setup_hold; u32 spi_cs_timing; u32 inactive_cycles; u8 cs_state; + if ((setup && setup->unit != SPI_DELAY_UNIT_SCK) || + (hold && hold->unit != SPI_DELAY_UNIT_SCK) || + (inactive && inactive->unit != SPI_DELAY_UNIT_SCK)) { + dev_err(&spi->dev, + "Invalid delay unit %d, should be SPI_DELAY_UNIT_SCK\n", + SPI_DELAY_UNIT_SCK); + return -EINVAL; + } + + setup_dly = setup ? setup->value : 0; + hold_dly = hold ? hold->value : 0; + inactive_dly = inactive ? inactive->value : 0; + setup_dly = min_t(u8, setup_dly, MAX_SETUP_HOLD_CYCLES); hold_dly = min_t(u8, hold_dly, MAX_SETUP_HOLD_CYCLES); if (setup_dly && hold_dly) { @@ -758,6 +774,8 @@ static void tegra_spi_set_hw_cs_timing(struct spi_device *spi, u8 setup_dly, tspi->spi_cs_timing2 = spi_cs_timing; tegra_spi_writel(tspi, spi_cs_timing, SPI_CS_TIMING2); } + + return 0; } static u32 tegra_spi_setup_transfer_one(struct spi_device *spi, diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 489eb64d9ee0..122af2264bfe 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3147,15 +3147,19 @@ EXPORT_SYMBOL_GPL(spi_setup); /** * spi_set_cs_timing - configure CS setup, hold, and inactive delays * @spi: the device that requires specific CS timing configuration - * @setup: CS setup time in terms of clock count - * @hold: CS hold time in terms of clock count - * @inactive_dly: CS inactive delay between transfers in terms of clock count + * @setup: CS setup time specified via @spi_delay + * @hold: CS hold time specified via @spi_delay + * @inactive: CS inactive delay between transfers specified via @spi_delay + * + * Return: zero on success, else a negative error code. */ -void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold, - u8 inactive_dly) +int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup, + struct spi_delay *hold, struct spi_delay *inactive) { if (spi->controller->set_cs_timing) - spi->controller->set_cs_timing(spi, setup, hold, inactive_dly); + return spi->controller->set_cs_timing(spi, setup, hold, + inactive); + return -ENOTSUPP; } EXPORT_SYMBOL_GPL(spi_set_cs_timing); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 2cee9ac35737..592e50aae998 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -517,8 +517,8 @@ struct spi_controller { * to configure specific CS timing through spi_set_cs_timing() after * spi_setup(). */ - void (*set_cs_timing)(struct spi_device *spi, u8 setup_clk_cycles, - u8 hold_clk_cycles, u8 inactive_clk_cycles); + int (*set_cs_timing)(struct spi_device *spi, struct spi_delay *setup, + struct spi_delay *hold, struct spi_delay *inactive); /* bidirectional bulk transfers * @@ -1007,7 +1007,10 @@ static inline void spi_message_free(struct spi_message *m) kfree(m); } -extern void spi_set_cs_timing(struct spi_device *spi, u8 setup, u8 hold, u8 inactive_dly); +extern int spi_set_cs_timing(struct spi_device *spi, + struct spi_delay *setup, + struct spi_delay *hold, + struct spi_delay *inactive); extern int spi_setup(struct spi_device *spi); extern int spi_async(struct spi_device *spi, struct spi_message *message); From patchwork Thu Sep 26 10:51:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162421 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 9781317EE for ; Thu, 26 Sep 2019 10:53:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7680C222C2 for ; Thu, 26 Sep 2019 10:53:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="l4SqQqdX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbfIZKxA (ORCPT ); Thu, 26 Sep 2019 06:53:00 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:26050 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbfIZKxA (ORCPT ); Thu, 26 Sep 2019 06:53:00 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqKSU030417; Thu, 26 Sep 2019 06:52:52 -0400 Received: from nam04-bn3-obe.outbound.protection.outlook.com (mail-bn3nam04lp2050.outbound.protection.outlook.com [104.47.46.50]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hku7cd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GRtO6w60aNbFp3TT9ehI0QDcdriSii7OmoP7pbB90WIlynXJcU1SveHrodbsyW9PiCTgNVe0/32mLMZFcHERskClkMyjaCpE/oJ7yH/PSimhbFieXcpDD77btdnprbrXf2dhQ63vVaRPfWjNUG+9CkzONhQ6wv+TYqipBYcxWqi76kYjyAI3bJdt8u72jYHP/YxA4QD+NFU+Jfz+RntU2wcly5QZyd8fjmddAQLNbkLq39TF582J1AQxMoFg2Fttn6a7WNv5WbqL3IYWesKboafN5aFx/VNdz8edms5jaMhim7xx5Oyhz4lrHkxSO4qxd/2mtDxIeYYEk8BNqrsbTA== 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=ImRrYAaX+dFz2bnSYmZEgeSfh2qEMepCcdCui+I1eOk=; b=hH5+lkbwBGJNhMZKkEnQMF5cgoSSSpK7kFR+0kupEjRgU/1p8TMSRdHNHWpUQM7AtWAYReFOETA4o4LvbRwLjiXplGlDSSTM1gQqmLP2oVwpZF5RUIpgsTm5tedcMkRItYUCci7oISXm5QcSxVkz60Uat/8IWaX1zyWxE6Y6jSyZhnJsRkf7asu0RbB76vJ3aIgtwABz1oy4wbZpl8AKn8nJ6iS38uPyqqufWWI+IOw3GjKF6o8EvyQjt9URgCTy6cF/V7gpfZXdQQAHWPqprC7UUgsbc+UUMVlPN+MADSqk4B5qc5AVcoK5glDbP+Vg+prrVxGr890jZxnv6p4QXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImRrYAaX+dFz2bnSYmZEgeSfh2qEMepCcdCui+I1eOk=; b=l4SqQqdXCc2sLHZdU54mNU3ApjHQwCwuYuJUdjReLzcUaHEANc28A2m32bjXc5kCq8sPNW7u/jBJqgGoMkcd5ESvDSuzkGF3i8emHNuKVfyNgiAR1EvPuJ8ptY6XalG0Ai5qTirc0ESWgYfv6+Dr94Vr64YxBzLXBamW8ks07SA= Received: from BN6PR03CA0110.namprd03.prod.outlook.com (2603:10b6:404:10::24) by CH2PR03MB5206.namprd03.prod.outlook.com (2603:10b6:610:a3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15; Thu, 26 Sep 2019 10:52:50 +0000 Received: from BL2NAM02FT053.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::207) by BN6PR03CA0110.outlook.office365.com (2603:10b6:404:10::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Thu, 26 Sep 2019 10:52:49 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT053.mail.protection.outlook.com (10.152.76.225) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:49 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqnuF014980 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:49 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:48 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 15/19] spi: implement SW control for CS times Date: Thu, 26 Sep 2019 13:51:43 +0300 Message-ID: <20190926105147.7839-16-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(376002)(39860400002)(346002)(199004)(189003)(1076003)(48376002)(486006)(14444005)(2870700001)(476003)(426003)(107886003)(126002)(11346002)(446003)(2616005)(2906002)(336012)(186003)(2201001)(7416002)(110136005)(70206006)(246002)(70586007)(316002)(5660300002)(356004)(6666004)(44832011)(50466002)(76176011)(26005)(47776003)(106002)(54906003)(86362001)(8676002)(305945005)(478600001)(8936002)(4326008)(36756003)(51416003)(7696005)(50226002)(7636002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CH2PR03MB5206;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef1151ee-04fd-4914-63fd-08d7426fac5f X-MS-TrafficTypeDiagnostic: CH2PR03MB5206: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NauOqDgkbibQYnjg0zeKUOHxhe/3K5kIpt49QHuAZ/KEb/XHmNQH68VcyzEgvK5ROYjXo0LooNGqrlpSmfoIHdzNqnXQU7n1uYHCNsmkrJHt2ZHCUezllJsngUYRCgl6wWBTjhZb3Ni6/0b4fY63h6jvZocsHWWEh0Owuln0jLj5q5bWfubI1QZxyPYgGiJl3XG2jkbZSQN1wO72m8hGalrDfSpwAHp5V4XXJ0Ox+5ppmsvR2Qz42+Ci7EEJfMgoiw98k5BSCRGCkxer5bweV0d3OD/xoHk7MXr0PYK5PVU+Zoonn93UKIOd69SlrjmEsIN5MsOWGDkwB0ktin4oaOdsoU9HRgHlUkjkKp6vgEoyFu34QDzWnferhw5BHYnCEfalIgR0nBLd7WmfMjhyWTGifaM+AAq7JGTGzjI7VcY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:49.6289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef1151ee-04fd-4914-63fd-08d7426fac5f X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR03MB5206 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This change implements CS control for setup, hold & inactive delays. The `cs_setup` delay is completely new, and can help with cases where asserting the CS, also brings the device out of power-sleep, where there needs to be a longer (than usual), before transferring data. The `cs_hold` time can overlap with the `delay` (or `delay_usecs`) from an SPI transfer. The main difference is that `cs_hold` implies that CS will be de-asserted. The `cs_inactive` delay does not have a clear use-case yet. It has been implemented mostly because the `spi_set_cs_timing()` function implements it. To some degree, this could overlap or replace `cs_change_delay`, but this will require more consideration/investigation in the future. All these delays have been added to the `spi_controller` struct, as they would typically be configured by calling `spi_set_cs_timing()` after an `spi_setup()` call. Software-mode for CS control, implies that the `set_cs_timing()` hook has not been provided for the `spi_controller` object. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 45 ++++++++++++++++++++++++++++++++++++++++- include/linux/spi/spi.h | 5 +++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 122af2264bfe..61ef286f954a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -775,6 +775,15 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n) static void spi_set_cs(struct spi_device *spi, bool enable) { + bool enable1 = enable; + + if (!spi->controller->set_cs_timing) { + if (enable1) + spi_delay_exec(&spi->controller->cs_setup, NULL); + else + spi_delay_exec(&spi->controller->cs_hold, NULL); + } + if (spi->mode & SPI_CS_HIGH) enable = !enable; @@ -800,6 +809,11 @@ static void spi_set_cs(struct spi_device *spi, bool enable) } else if (spi->controller->set_cs) { spi->controller->set_cs(spi, !enable); } + + if (!spi->controller->set_cs_timing) { + if (!enable1) + spi_delay_exec(&spi->controller->cs_inactive, NULL); + } } #ifdef CONFIG_HAS_DMA @@ -3156,10 +3170,39 @@ EXPORT_SYMBOL_GPL(spi_setup); int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup, struct spi_delay *hold, struct spi_delay *inactive) { + size_t len; + if (spi->controller->set_cs_timing) return spi->controller->set_cs_timing(spi, setup, hold, inactive); - return -ENOTSUPP; + + if ((setup && setup->unit == SPI_DELAY_UNIT_SCK) || + (hold && hold->unit == SPI_DELAY_UNIT_SCK) || + (inactive && inactive->unit == SPI_DELAY_UNIT_SCK)) { + dev_err(&spi->dev, + "Clock-cycle delays for CS not supported in SW mode\n"); + return -ENOTSUPP; + } + + len = sizeof(struct spi_delay); + + /* copy delays to controller */ + if (setup) + memcpy(&spi->controller->cs_setup, setup, len); + else + memset(&spi->controller->cs_setup, 0, len); + + if (hold) + memcpy(&spi->controller->cs_hold, hold, len); + else + memset(&spi->controller->cs_hold, 0, len); + + if (inactive) + memcpy(&spi->controller->cs_inactive, inactive, len); + else + memset(&spi->controller->cs_inactive, 0, len); + + return 0; } EXPORT_SYMBOL_GPL(spi_set_cs_timing); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 592e50aae998..66031c8d0093 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -602,6 +602,11 @@ struct spi_controller { /* Optimized handlers for SPI memory-like operations. */ const struct spi_controller_mem_ops *mem_ops; + /* CS delays */ + struct spi_delay cs_setup; + struct spi_delay cs_hold; + struct spi_delay cs_inactive; + /* gpio chip select */ int *cs_gpios; struct gpio_desc **cs_gpiods; From patchwork Thu Sep 26 10:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162419 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 4E2AD14ED for ; Thu, 26 Sep 2019 10:53:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2324D222C5 for ; Thu, 26 Sep 2019 10:53:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="HsUiIvlZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726698AbfIZKxE (ORCPT ); Thu, 26 Sep 2019 06:53:04 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:27418 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbfIZKxB (ORCPT ); Thu, 26 Sep 2019 06:53:01 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqe71018255; Thu, 26 Sep 2019 06:52:54 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2051.outbound.protection.outlook.com [104.47.49.51]) by mx0b-00128a01.pphosted.com with ESMTP id 2v6hkcq43m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KHEOSFfaKE9xKCR0Uzt+ow/B9WfDr6o1VQp7GJ4Gpj5fN8TMxdOKtIBG9yPdCJ1e2+98fw6YFQ0XvGtbzeaz2mNG6GH4PHDS75AggKd0C43xNmm5tmkr5QJod1QQP5GMDJZxUnZCSrcdl1DUf02wdzh4SIFA/Sqs7GuqOG7AFVeFED9wVAiep4PF6iL/thJwMiDUH5YTeGVUPmL/0+ZMZsHQyED5J78RSZX7WsQ981I2OUG+ohTufHT8nngq4enhwzVowWgu2IdDGNUlnioMjDItC+R2EdT1fo1kLeZT7Lljl24fyt7eQgHSxRtmbZkVQW8TfX93EoBdOXbfddhcEQ== 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=CH9GMibfHC0zvMX/0AfhkRSackA+ifnakTtFod6XjxY=; b=mL10DK1LK/8EFxr+GwzG+v6gC/CXsQ6vJfDOfVI7MBmnIXn1mXMG+qt6aTXJhmm80uZLHMKGh5QJNEGacJy3dnmbNUViIKoG7RnOBij+Ni4UQA3HEKZR2LYF95T4vDDFAmrpzHvypP6PV1YMIusYLg3TlJQ6HgUGOzP/YPpsanrvy3HsD+6xB038boMTcvhvdyAB9MhDdel4w7WJ9On926gr3+Pmb6wiRJgtOJD4TTtteCTl2PRGuDNocebGUSBNi1hvWE5Z+Vdgc8r2jnd47mqOhBatvuKpnGqwXfvrs0I0EbnfqDrRACy+Mq1C1GVxc/HVOjwZPSBunYbBGb3g5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CH9GMibfHC0zvMX/0AfhkRSackA+ifnakTtFod6XjxY=; b=HsUiIvlZ/CeqTpJCFnIGG+EL4Z82bsh+qr72mwHOcjv+Pha0iFvlcWk807UXWE+ClmJ+9UZhNLPD58vbJUVpl2f2l4TyOHXqaASzykTzf3jidKTM694an/EnI1KTDwF2wgK5MRwAqcPkDR5XUNJLZ2e37RDz46VBCEypJtO4BUM= Received: from CH2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:610:59::28) by CY4PR03MB2694.namprd03.prod.outlook.com (2603:10b6:903:6f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.25; Thu, 26 Sep 2019 10:52:52 +0000 Received: from BL2NAM02FT027.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::205) by CH2PR03CA0018.outlook.office365.com (2603:10b6:610:59::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.21 via Frontend Transport; Thu, 26 Sep 2019 10:52:52 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT027.mail.protection.outlook.com (10.152.77.160) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:52 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqqRq015006 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:52 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:51 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 16/19] spi: spi-fsl-espi: convert transfer delay to `spi_delay` format Date: Thu, 26 Sep 2019 13:51:44 +0300 Message-ID: <20190926105147.7839-17-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(39860400002)(136003)(346002)(199004)(189003)(186003)(50466002)(1076003)(305945005)(4326008)(6666004)(2616005)(476003)(5660300002)(7416002)(356004)(50226002)(7636002)(14444005)(36756003)(486006)(70586007)(246002)(336012)(107886003)(48376002)(44832011)(54906003)(110136005)(47776003)(76176011)(8676002)(70206006)(2201001)(86362001)(2906002)(446003)(2870700001)(11346002)(426003)(8936002)(126002)(7696005)(51416003)(26005)(106002)(478600001)(316002)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB2694;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab0e4cd8-fa2e-4fa8-9925-08d7426fae10 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328);SRVR:CY4PR03MB2694; X-MS-TrafficTypeDiagnostic: CY4PR03MB2694: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: JUjwhn46bIImS7X6KYliVUVYSUp4eESYcLHQ6ymJpzypJDIKz1y46keRMUO3dUoldNMhYeUUkLJoDwVL2tk3PFUnSl0cDa9szjDSZZpmd7Tl6PlfclM9ysAmOdXQC11Lnx7+PVJcdhPRI5DZxCI3FIW6ZbO5kS77k4i4sWGfW9k5sVaSWDtNLhDpxXE/GY0kK+od0hGp9+/dgBv43Svtk0B7y+8QAWkGjEF1f2a5bcy5OYvdOERcEmNdiYnNI5h9MTfItB0FL6obbMhwPGFu53gNEjndrOxTeI15mCO5Gdizm6LaIORDqQVwiaXK/G5JQ2h9K3kO7I3nuar2k/11DmLmhUynG8G1Ko+GtBmgBbB8SIcq+dGg9H4f/GExjEIIl9shWtUGIFnsPNF8sW6q7SHcqns0rQULH+sXInv/VsM= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:52.4730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab0e4cd8-fa2e-4fa8-9925-08d7426fae10 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2694 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The way the max delay is computed for this controller, it looks like it is searching for the max delay from an SPI message a using that. No idea if this is valid. But this change should support both `delay_usecs` and the new `delay` data which is of `spi_delay` type. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-fsl-espi.c | 16 +++++++++++++--- drivers/spi/spi.c | 9 +++++---- include/linux/spi/spi.h | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 732bf3195917..e60581283a24 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -436,6 +436,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, struct spi_message *m) { unsigned int delay_usecs = 0, rx_nbits = 0; + unsigned int delay_nsecs = 0, delay_nsecs1 = 0; struct spi_transfer *t, trans = {}; int ret; @@ -444,8 +445,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, goto out; list_for_each_entry(t, &m->transfers, transfer_list) { - if (t->delay_usecs > delay_usecs) - delay_usecs = t->delay_usecs; + if (t->delay_usecs) { + if (t->delay_usecs > delay_usecs) { + delay_usecs = t->delay_usecs; + delay_nsecs = delay_usecs * 1000; + } + } else { + delay_nsecs1 = spi_delay_to_ns(&t->delay, t); + if (delay_nsecs1 > delay_nsecs) + delay_nsecs = delay_nsecs1; + } if (t->rx_nbits > rx_nbits) rx_nbits = t->rx_nbits; } @@ -456,7 +465,8 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = m->frame_length; trans.speed_hz = t->speed_hz; trans.bits_per_word = t->bits_per_word; - trans.delay_usecs = delay_usecs; + trans.delay.value = delay_nsecs; + trans.delay.unit = SPI_DELAY_UNIT_NSECS; trans.rx_nbits = rx_nbits; if (trans.len) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 61ef286f954a..1f0b55c9e2e8 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1120,7 +1120,7 @@ static void _spi_transfer_delay_ns(u32 ns) } } -static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) +int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) { u32 delay = _delay->value; u32 unit = _delay->unit; @@ -1153,6 +1153,7 @@ static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) return delay; } +EXPORT_SYMBOL_GPL(spi_delay_to_ns); int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) { @@ -1161,7 +1162,7 @@ int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) if (!_delay) return -EINVAL; - delay = _spi_delay_to_ns(_delay, xfer); + delay = spi_delay_to_ns(_delay, xfer); if (delay < 0) return delay; @@ -3211,11 +3212,11 @@ static int _spi_xfer_word_delay_update(struct spi_transfer *xfer, { int delay1, delay2; - delay1 = _spi_delay_to_ns(&xfer->word_delay, xfer); + delay1 = spi_delay_to_ns(&xfer->word_delay, xfer); if (delay1 < 0) return delay1; - delay2 = _spi_delay_to_ns(&spi->word_delay, xfer); + delay2 = spi_delay_to_ns(&spi->word_delay, xfer); if (delay2 < 0) return delay2; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 66031c8d0093..3bc5912fca36 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -102,6 +102,7 @@ struct spi_delay { u8 unit; }; +extern int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer); extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); /** From patchwork Thu Sep 26 10:51:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162415 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 4F2FC14ED for ; Thu, 26 Sep 2019 10:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 242F1217F4 for ; Thu, 26 Sep 2019 10:53:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="8A1QXtNg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbfIZKxF (ORCPT ); Thu, 26 Sep 2019 06:53:05 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:2494 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbfIZKxD (ORCPT ); Thu, 26 Sep 2019 06:53:03 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqQVI030649; Thu, 26 Sep 2019 06:52:58 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2050.outbound.protection.outlook.com [104.47.49.50]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hjwy81d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:52:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vc8wJnKFPXus7ru8slLpkicgVv3DnDF//aPeWAVbB/WAWbISB9TMiinZLdfwbqTMas+dJe+mzTrgXbLogXDC0nFv0bur+Zlh3mFh16aFPhEoWbK/IRrQvqP1aLPazFH4Y6oShShMdU3XwGFYuxXGvodhNMujQOZ7+p5Rdet5o7NFVpvyO9YUvPVl1V3g73GiDYxwsKPJOtRAR6LzB04Nv7Bdhntg7taBxyhhq9soJUY4iumgXqKVroB4J2vLKHZjDUv402JJOJSsDLBvCVXNeokIbGEMTmclm+6Ja0Mu9snnGM9BF5cbqyHKwYL8PFo8B39nMR/7KMbhAdDtGN4R3A== 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=gaq6GJvrfAbArqIKMG6ZTPuXJwHsd+6DYuWvpf67NJ0=; b=XqjS5SC3bWy37iPXayunkvGaV/ahWd5nL43Ug3U8Q2IAKbgSp1aOPXRhnVkTaYweDo9LqqAwdriwiDIG4zrroFU7jv3zXTx1tqQFovPngy6ZR4zvXqRxywhU/qUcGRjDqK1ROe33mPkzBz/g7jA823fS0ongxkD6Vcl4MQ7Tr2qR/6tGXvuviPvw3NhTUNJQCNslCtfrobgxuF94kS+OaKwYKBaut/9V8LtPJP2Z3G2Yx/J4kbpg+LpRBk2ML4b0oM/K9hSFBx3PVVHVPXFLcA8EY7ZSJ9DI3b2pXrrT8XW6jTi0JcMW/jnZknvYpQUGNz/E1fkjE31KlFMSgG3rVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gaq6GJvrfAbArqIKMG6ZTPuXJwHsd+6DYuWvpf67NJ0=; b=8A1QXtNgvs9PPTcCp2JWej2TDlEu/c7Cw6JKY5OxFO6fVwFV5Gi791fwK4K4m4hR9QMrf/vm3JW0uNO99UiBT9QPpE79A3wBfSBlnO4M9nWV4QMzLe4j7y0poRDellFke1Z4Pgx18PoOCA8CONdnLq0w7aigaFP2S4ExVQIE/XI= Received: from DM6PR03CA0001.namprd03.prod.outlook.com (2603:10b6:5:40::14) by CY1PR03MB2186.namprd03.prod.outlook.com (2a01:111:e400:c61a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.25; Thu, 26 Sep 2019 10:52:55 +0000 Received: from BL2NAM02FT062.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::203) by DM6PR03CA0001.outlook.office365.com (2603:10b6:5:40::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15 via Frontend Transport; Thu, 26 Sep 2019 10:52:55 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT062.mail.protection.outlook.com (10.152.77.57) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:55 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqsj4015019 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:54 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:54 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 17/19] spi: spi-falcon: extend warning to `delay` as well Date: Thu, 26 Sep 2019 13:51:45 +0300 Message-ID: <20190926105147.7839-18-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(136003)(39860400002)(199004)(189003)(186003)(305945005)(1076003)(4326008)(356004)(6666004)(50466002)(2616005)(48376002)(476003)(5660300002)(7416002)(50226002)(7636002)(14444005)(76176011)(486006)(70586007)(246002)(44832011)(336012)(107886003)(36756003)(54906003)(51416003)(110136005)(47776003)(8676002)(2201001)(70206006)(86362001)(446003)(2906002)(2870700001)(11346002)(426003)(8936002)(126002)(26005)(7696005)(4744005)(106002)(478600001)(316002)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR03MB2186;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d6a6781-a876-4aef-3236-08d7426fafb5 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:CY1PR03MB2186; X-MS-TrafficTypeDiagnostic: CY1PR03MB2186: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: E9nvNEsDhwSVt2ElO3T1lc5nRRqzW14bUeiCw4RJETlcYyj7C5BDjI4qPlX4CQwcY7ai3BMG68KIL7fikyhGy1Y4FuhIQG9GIC8Jqks+hbOu6kOzEzVcEyRQQ4c2Z68V5dmBgqG1kosMnqGuzsxnyHU0EM2YL4yWC0F8PkRanZuLjKC7Jgn05yYoUe5fxqOpMVsqQh38mciwd2rdfMFa2IuLCmML09km3zAbQzhdnVM9ea9xfLoKRuWDcl42TQSsdnQ3HU28RVSUTQ+/o1QsVMBG3uZNufHWnRXkxs5MZGtU0IPFgk1YAMn32S7K/VVxp5DY+F03Gdydom0904Oclkl0sYa6lWfN2MwyH+Ot2RjE14+l/Wjlg1zXsNireaP9883qiPg7al6cqFXP3qAXquxg9UTfsbEVgyLDFDt2yeA= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:55.2334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d6a6781-a876-4aef-3236-08d7426fafb5 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB2186 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxlogscore=864 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The WARN_ON macro prints a warning in syslog if `delay_usecs` is non-zero. However, with the new intermediate `delay`, the warning should also be printed. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-falcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c index 00f46c816a56..d3336a63f462 100644 --- a/drivers/spi/spi-falcon.c +++ b/drivers/spi/spi-falcon.c @@ -377,7 +377,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master, m->actual_length += t->len; - WARN_ON(t->delay_usecs || t->cs_change); + WARN_ON(t->delay_usecs || t->delay.value || t->cs_change); spi_flags = 0; } From patchwork Thu Sep 26 10:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162403 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 E4F2614ED for ; Thu, 26 Sep 2019 10:53:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA358222C2 for ; Thu, 26 Sep 2019 10:53:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="kfG1XAWU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726740AbfIZKxG (ORCPT ); Thu, 26 Sep 2019 06:53:06 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:3786 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfIZKxF (ORCPT ); Thu, 26 Sep 2019 06:53:05 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqQhO002867; Thu, 26 Sep 2019 06:53:00 -0400 Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2059.outbound.protection.outlook.com [104.47.49.59]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hj96rdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:53:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eUhI8mxrofhjo5uXfi0LGBSIfQmDo9CMgybqoxUDe9g10B0SkLSFck9HZnpd9gZ7NuUAr2EcYldUyQS9fBIQNjj2O5OdzQ6Mx/Jd+2sQ//zkJC7SL1gnei8IJJBBfKyZ/pYb4UYGXg3zyJXP6cZjDvYRqcMYwoBZxQSXLDjkPtjTfkYmiub8IRSxGNA813DkIwwspLlTHkSNthLiFclj+S9/kD6bR4frcT+zt/IX/vNC8UIaC6wM13FiUPR5OJwhEdBmqwvySspF/kvuRZskguNGG0U+8RRT2nduoNHdPPvHqz/UyXRsowLJ7GKhRej3+a1qh59qaUbfKb0U0Z6rpg== 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=InhT3tLFpAEPqc/cBRcMPhOccnv8KIq0Uf1g4BCMzws=; b=Vslx9Geq18nRPCpBEdj7Dc4N7hTuF4fmwnIg/8nmVwVftPVFuOB2Nw0e6XgOTvisyuMtdOH4/Gr9+Nv60/tqAdz8bMUot8CskteeqsVk9HZKPT4bXdbkSqs2tCd5bRgQvyv0DJrSLXSYtMX5NYfDil4YJs1PM0ERyhCvU0jRehI5a/17M39dUfREhreW+pGG7A/yH/FVJyW0IyOZK96Lp2VQGcbg/LiPYS1vPJosfVf6KYvOdEd6HyvaRgcmGhusjpbr4kYjD95dPzLnCXvN+cntvDVmUvVs3eB1tgLPPjERr4XCgJ3IrelB0Kw6Otwn2Ic4LbgmT83AmrI0WBnAOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=InhT3tLFpAEPqc/cBRcMPhOccnv8KIq0Uf1g4BCMzws=; b=kfG1XAWU1j2OslvqSYvGlcAri7o4aK4r7vpUAtw3H/1RG+gzLcRhxWwYbsyKKD08Xwcw+jbbGfQNuFK4MB+JqyWmIaVbMYFgxNosonBH0ZQYXv4JJTCguCFlwj3j3EpUZ67F40OjRv5OSwk6BQyEBGwauZ7bSjcLitjZnVIJK+M= Received: from BN6PR03CA0113.namprd03.prod.outlook.com (2603:10b6:404:10::27) by DM6PR03MB4954.namprd03.prod.outlook.com (2603:10b6:5:1e4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.23; Thu, 26 Sep 2019 10:52:58 +0000 Received: from SN1NAM02FT060.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::201) by BN6PR03CA0113.outlook.office365.com (2603:10b6:404:10::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 10:52:58 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT060.mail.protection.outlook.com (10.152.72.192) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:52:58 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAqve5015026 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:52:57 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:52:57 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 18/19] spi: bcm63xx: extend error condition to `delay` as well Date: Thu, 26 Sep 2019 13:51:46 +0300 Message-ID: <20190926105147.7839-19-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(136003)(396003)(39860400002)(199004)(189003)(478600001)(1076003)(186003)(2906002)(14444005)(26005)(7636002)(2870700001)(4744005)(305945005)(336012)(44832011)(51416003)(7696005)(76176011)(356004)(7416002)(47776003)(476003)(2616005)(126002)(6666004)(486006)(446003)(11346002)(54906003)(8936002)(426003)(70206006)(50226002)(2201001)(36756003)(110136005)(86362001)(316002)(70586007)(246002)(8676002)(106002)(50466002)(5660300002)(48376002)(4326008)(107886003)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB4954;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 809b12ea-04c1-460c-15c0-08d7426fb195 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:DM6PR03MB4954; X-MS-TrafficTypeDiagnostic: DM6PR03MB4954: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: sTE0/mSZJdSrWM8Hq/uCy5abrdUYtv7PlPtp1EocLW22OkiD/evwpKwTDMAYkCqiuYdQuKDXrW9azdZCTZC39N+h3MpcuujLTbXH5ZAa/te8ycAsXpE4HgcoG7wIVgTmM58neddJwx9Wy8XAI8e+9t7JWLLvM+F+64QOI5wfcArGKEAL9eU+UgAC8l6PXYlBsRhhdiayAzC2tqfEzrNk85pp+Wgoe1XvGADIF8GeYf0MdMxwTZ1FI9Tfw2GLkFGYhtl5SU4CURwDc7IqB2+ZL00ASH//Ih+dZFg4PHInAc+B19jecHO3Gx8PlR2ToI6FhepWNtv9CDBK9XBaSaReKJMaqVuCu2tdkVGowpTAPSZpwr9Nng3MBOareS13QbROfZLeKY1D/AU4X+M0lhg+5Un8pY/uprwUr7Y7cko3mZw= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:52:58.3084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 809b12ea-04c1-460c-15c0-08d7426fb195 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4954 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=844 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The driver errors out if `delay_usecs` is non-zero. This error condition should be extended to the new `delay` field, to account for when it will be used. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-bcm63xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index df1c94a131e6..4e582acda709 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c @@ -368,7 +368,7 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master, } /* CS will be deasserted directly after transfer */ - if (t->delay_usecs) { + if (t->delay_usecs || t->delay.value) { dev_err(&spi->dev, "unable to keep CS asserted after transfer\n"); status = -EINVAL; goto exit; From patchwork Thu Sep 26 10:51:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11162391 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 7B6A114ED for ; Thu, 26 Sep 2019 10:53:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F073217F4 for ; Thu, 26 Sep 2019 10:53:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="RmPEwbWS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbfIZKxJ (ORCPT ); Thu, 26 Sep 2019 06:53:09 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:5568 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfIZKxJ (ORCPT ); Thu, 26 Sep 2019 06:53:09 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QAqdX9002555; Thu, 26 Sep 2019 06:53:03 -0400 Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2053.outbound.protection.outlook.com [104.47.32.53]) by mx0a-00128a01.pphosted.com with ESMTP id 2v6hjwy81m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 06:53:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EKSl4n0YPLkUt72zZb/+mZBRoeCwuRso5EiibWhRe/7s31ePgVUkRyOW+zgwQlV+YorvCHRGHX49xxSUoxs88qDCWeD6lqOid1Ec8MYLMOgWQJ1VLz/z9GR563MFA2feKdY89v8eFpWl1+L91D0vqP6zisyx8EkM7Joo2uwpw/pEp+vejrDDM2sXSluO8r6pUMc8Mj50SQkWZtS+qtpsGdU6HP2KNLkm54UnknMOv1mKxyEHJQLl9DdaX7iv7w6UfhT2bV/n6SUllqzir+rmWIdEbOBuiDZwvAv9LFPwP1XHlMmmnMxmqx0HAbIO8nwuXGWsPRhXBQ7MZdGba/LLLw== 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=up797fUmJmr8mxk7XBoVCZkF3leVVxVqShL+Y1oR7d8=; b=cO/z6CcF22BFEo9LPQ+DXrN9oAidACnEDnUPwf+rRQPZhVf/W95b8Hel04NndNDMj/bwqA1Q45TZBMkr4GwUMUgjMTryplhuSF5YSoSu5bfVTLEj+i6D7l5vZsm1k4Dw+h96/6NZBj7SgkjF60ucVz3vzc/JrjXVkuKZMBJvVTCWV3jofok/Lf8y0mlGPJT67QxQzhpzav3kfmNPYW0x4YMsaZUT8ub6ixBEnoI2UoybgeH53jUy4I7zTUtHS0umeuzTc+ITHmwQ6rvQOR4b0c9LnaHEq9sSNbe61ufNl+A29/y/dnhEfU2KmNwdBNsGrbYTQ3Uy4B6y9lBObHgwpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=up797fUmJmr8mxk7XBoVCZkF3leVVxVqShL+Y1oR7d8=; b=RmPEwbWS37F5ODyf4zyKloCU6nSnJra7vsFe+6b2N8qXOV9Zk3C92z5r7S5aEthPv6xDAUYFdmj0GvvPmsn4MTJZYBpWJKTmFmpTLgqAdVdckdwq3QqX5D+EGE6W4OUBbw4g0Qa3kLjzX5BT/8pN96lBkY/KPrbUBXZ6xcYcoqU= Received: from BN6PR03CA0099.namprd03.prod.outlook.com (2603:10b6:404:10::13) by BN8PR03MB5041.namprd03.prod.outlook.com (2603:10b6:408:d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 10:53:01 +0000 Received: from SN1NAM02FT041.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::209) by BN6PR03CA0099.outlook.office365.com (2603:10b6:404:10::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.16 via Frontend Transport; Thu, 26 Sep 2019 10:53:01 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by SN1NAM02FT041.mail.protection.outlook.com (10.152.72.217) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2284.25 via Frontend Transport; Thu, 26 Sep 2019 10:53:00 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8QAr0iF015043 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 26 Sep 2019 03:53:00 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 26 Sep 2019 06:53:00 -0400 From: Alexandru Ardelean To: , , , , , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 19/19] spi: spi-axi: extend support for the `delay` field Date: Thu, 26 Sep 2019 13:51:47 +0300 Message-ID: <20190926105147.7839-20-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190926105147.7839-1-alexandru.ardelean@analog.com> References: <20190926105147.7839-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(136003)(396003)(39860400002)(376002)(189003)(199004)(47776003)(36756003)(1076003)(5660300002)(356004)(6666004)(70586007)(70206006)(2201001)(86362001)(50466002)(107886003)(4326008)(426003)(76176011)(246002)(8936002)(305945005)(51416003)(7696005)(7636002)(8676002)(478600001)(106002)(476003)(11346002)(446003)(336012)(486006)(126002)(2616005)(186003)(2870700001)(26005)(2906002)(54906003)(110136005)(316002)(48376002)(7416002)(50226002)(44832011)(81973001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN8PR03MB5041;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4ac0901-315a-4c45-fa61-08d7426fb322 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:BN8PR03MB5041; X-MS-TrafficTypeDiagnostic: BN8PR03MB5041: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0172F0EF77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: dNDNWcgcjGpxgeOh6yaA00CMdmbPs2AFT0h4cVxEmSpLDWmSH7JeCX3/aGbe1pZrXD7R8La2OlAamdi9LLXnm+oMGd+fisVlKFftHrhmJn1uBdgGyJHm4ZGMY60wc/WbgGjXxjUJD4IErAuiaL3u+1wUR2wllApBoeFctz40C9kbC3oKuCPDFfpov++c7q/7DDMs+PcVJKjgbHfcZjcTMmE16okXQbVkU4sG59jq5kdwivwhf4krAUQN6a4+k9VjBmdvXzuhahzz4t7XL5MNDig7GvJNywHcC8ySzAusqHljo+9yO0/v6qX9e4NeZTDv3j18AIBJ90LlvGrmpqDsv4ahCecru+6QWypwXWFiUReNN7XZ22k5w1AQvp1WexrPTKkAo2EZhXhWvlesJnoyif+IvyGjnPUxkxxbanvX68E= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 10:53:00.9130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4ac0901-315a-4c45-fa61-08d7426fb322 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR03MB5041 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_05:2019-09-25,2019-09-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909260103 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The AXI SPI engine driver uses the `delay_usecs` field from `spi_transfer` to configure delays, which the controller will execute. This change extends the logic to also include the `delay` value, in case it is used (instead if `delay_usecs`). Signed-off-by: Alexandru Ardelean --- drivers/spi/spi-axi-spi-engine.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 3b1833e6c7ad..111d3b83285f 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -163,10 +163,21 @@ static void spi_engine_gen_xfer(struct spi_engine_program *p, bool dry, } static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry, - struct spi_engine *spi_engine, unsigned int clk_div, unsigned int delay) + struct spi_engine *spi_engine, unsigned int clk_div, + struct spi_transfer *xfer) { unsigned int spi_clk = clk_get_rate(spi_engine->ref_clk); unsigned int t; + int delay; + + if (xfer->delay_usecs) { + delay = xfer->delay_usecs; + } else { + delay = spi_delay_to_ns(&xfer->delay, xfer); + if (delay < 0) + return; + delay /= 1000; + } if (delay == 0) return; @@ -218,8 +229,7 @@ static int spi_engine_compile_message(struct spi_engine *spi_engine, spi_engine_gen_cs(p, dry, spi, true); spi_engine_gen_xfer(p, dry, xfer); - spi_engine_gen_sleep(p, dry, spi_engine, clk_div, - xfer->delay_usecs); + spi_engine_gen_sleep(p, dry, spi_engine, clk_div, xfer); cs_change = xfer->cs_change; if (list_is_last(&xfer->transfer_list, &msg->transfers))