From patchwork Fri Feb 24 15:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13151459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1378C61DA4 for ; Fri, 24 Feb 2023 15:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbjBXPuV (ORCPT ); Fri, 24 Feb 2023 10:50:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbjBXPuT (ORCPT ); Fri, 24 Feb 2023 10:50:19 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04A956CF29; Fri, 24 Feb 2023 07:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uki26hSNx4DrWWpthrLbL0vX937VuEXZ58Eb10PHPR8VbS3D9tr7iI2172QB/OsRyERimVlTLC0DoGpEGLDogOcYP2n7UXcrZeryWF9FKhpfhTBVdW1bX6xkP64VIOE4TYv5cl96nX5P1v26PF/siSbjsda7GQ82L8m2/B0FGnsZ+KERQzqgKtUKfwr5RI9/kvbEodIVQ4qCbh4Q8/LCYt/zhsHxJC+qGIwA08KwaAwkEVOV2S2rsUOYFuQ3ILNAbf6MhUgCkQH8eHN3I5ar2C8ajp6NZz5ar+JwxMQR+o8vwvGKdqubQXsZiNXwXWl7LPMQHzcSVzEPvUQuFpCx9Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x0cEiBaMNIgPRegxXaIJxXz2fOQimc4elvv1wRP+Co8=; b=CajXwa2tAMu2dbob6Z62w7RKJi9ElQyCEjusaMt/1dzNWW/cqtBGLARBCe6tfkbswGZHdZHbn4J6bRLqBd2/IrjaOkAH/yN04ehtq55/d/eOzYgCTw/O66na8BymY/TvxA4qEuA1nqDAUHSJ3QZbxTOKUT2YqTY6ykYXdxIU/6BEKSERC7YxKg8sQOFbvobxbbDJRulLEA/Kk2tVy/J57nWb6ZxoUI+8BMBHrnyUyXym/LD+TQ7uMzJXIxZUUZMtu54T8PFZdnIcCpfRAhKmZvmqKeBxtcD+WH7Fo0O6IXjCcnDD1NHpLGMljhUwZBNBrQigQCa/l9JjeqDhs5scFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x0cEiBaMNIgPRegxXaIJxXz2fOQimc4elvv1wRP+Co8=; b=iODJeHPIubZKzMRsZGcD49HvwP5UhNHtnxADuRrGalYTNU1d39wAqualIv0djd9RbWPtaAxB5V5n0ylO3J/b39t/gwjQucAFFhfeneJRGbMLECZW5VLCMK6/r16O4dsb8A/t6ne6qx3j/3adgomEZLQBl7AppwxcaIIIWVfRLHh8K1kPkRcx6qXu2EwFvqHSVhlPMvcoJrja17JejDwPf5gDWGOejlDMmEo5tOVMSp6O1rnoAwWbFYxOBB3LXrCvlda+54g1Ci5MGwzl7bnbqjaahTOaAyZo7/rTHhFjQ/kX8IDQUQpNbH3HvUOUEn7twK4iEhcB8eIYAxrDmiszbg== Received: from BN8PR15CA0052.namprd15.prod.outlook.com (2603:10b6:408:80::29) by DM6PR12MB4561.namprd12.prod.outlook.com (2603:10b6:5:2ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24; Fri, 24 Feb 2023 15:50:15 +0000 Received: from BL02EPF000108EA.namprd05.prod.outlook.com (2603:10b6:408:80:cafe::ea) by BN8PR15CA0052.outlook.office365.com (2603:10b6:408:80::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24 via Frontend Transport; Fri, 24 Feb 2023 15:50:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000108EA.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Fri, 24 Feb 2023 15:50:14 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:49:54 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:49:53 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 24 Feb 2023 07:49:49 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V4 1/3] spi: Add TPM HW flow flag Date: Fri, 24 Feb 2023 21:19:39 +0530 Message-ID: <20230224154941.68587-2-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230224154941.68587-1-kyarlagadda@nvidia.com> References: <20230224154941.68587-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000108EA:EE_|DM6PR12MB4561:EE_ X-MS-Office365-Filtering-Correlation-Id: e56d3671-0a6f-4d90-1730-08db167ed219 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wrqanw2pJRvFAGqIzmOZFFMUWC/V/CV4HYbavFUG7kvj/BKpCOADJ5fGGQtyXmhLB/J1yA2xTBFcSSAz+ymsWZCi/CqfkBYXwpxMvfIA56vMDnt4nW+LUwaHDRduwB8B+Gch83bum1EvkC8g6pjEnj6SQaxiyAJL/GzZvoAobp+b7WcWxUU6XcA00kfTe7LqKts6ZJQX4r2jAVy+gfKkAV7XcN3Cg2ZdUTiknG9Fvbt3MDkglYbfEC6Gw9aBxcZClPNr7FCnW2oTZvU8TtCOd2byCvM6hftoon1L0mfUcvLSTmPnvO7KUiUN5u2KdR8Yy4Xt8QNmr0WLxIIELfK41MgQ6oTI3c3d7SsnrITMo6ql+Ie1pHd1/T0XqOlB8pHGgWzrKR1pultCnccpJ9TWG1Brp0FsRGoq0X8NuZzmIHxQJbO+s2hK4v45EHg9YNqUwSZBunCUhDytJsRpoJv2n3sZC3Bhd45w//S2ssd/lAm/kZQTN5DazrosJsyZUtaGVN5k+16rQ/rN8lObEnFLyb/5KsmPVvzwSSrSdbjBKpHuIjJWdGl4H6SClllHSpe1mnBmMPjI0S+XTvGk6sb+WYtjxf73glwuHk/I/Q2kf3rPUf9xj5n5D3isivNh67Vezf+KAVled6zExpmlblf0cXQh891BVQmctqwD/QTNTLA3fsiM1GGoZazlEqfVw1n6R0dVsMPHpvtlx+TeqimRmO7s2DCNUxC5e63hBXBzERSgJlSwLAY2l4kLrwNSbBqAUZKGVImJ7P2yEdUF0neYvg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(7636003)(54906003)(8936002)(316002)(336012)(186003)(36756003)(26005)(478600001)(921005)(40460700003)(356005)(1076003)(7696005)(110136005)(86362001)(107886003)(6666004)(40480700001)(2906002)(2616005)(82310400005)(5660300002)(7416002)(82740400003)(41300700001)(426003)(36860700001)(47076005)(83380400001)(8676002)(70206006)(70586007)(4326008)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2023 15:50:14.7575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e56d3671-0a6f-4d90-1730-08db167ed219 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000108EA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4561 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org TPM spec defines flow control over SPI. Client device can insert a wait state on MISO when address is trasmitted by controller on MOSI. It can work only on full duplex. Half duplex controllers need to implement flow control in HW. Add a flag for TPM to indicate flow control is expected in controller. Signed-off-by: Krishna Yarlagadda --- include/linux/spi/spi.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 988aabc31871..b88494e31239 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -184,8 +184,9 @@ struct spi_device { u8 chip_select; u8 bits_per_word; bool rt; -#define SPI_NO_TX BIT(31) /* No transmit wire */ -#define SPI_NO_RX BIT(30) /* No receive wire */ +#define SPI_NO_TX BIT(31) /* No transmit wire */ +#define SPI_NO_RX BIT(30) /* No receive wire */ +#define SPI_TPM_HW_FLOW BIT(29) /* TPM flow control */ /* * All bits defined above should be covered by SPI_MODE_KERNEL_MASK. * The SPI_MODE_KERNEL_MASK has the SPI_MODE_USER_MASK counterpart, @@ -195,7 +196,7 @@ struct spi_device { * These bits must not overlap. A static assert check should make sure of that. * If adding extra bits, make sure to decrease the bit index below as well. */ -#define SPI_MODE_KERNEL_MASK (~(BIT(30) - 1)) +#define SPI_MODE_KERNEL_MASK (~(BIT(29) - 1)) u32 mode; int irq; void *controller_state; From patchwork Fri Feb 24 15:49:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13151460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E19F4C61DA3 for ; Fri, 24 Feb 2023 15:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbjBXPuX (ORCPT ); Fri, 24 Feb 2023 10:50:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjBXPuW (ORCPT ); Fri, 24 Feb 2023 10:50:22 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E40D866973; Fri, 24 Feb 2023 07:50:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KsGxCl6rfTU4tPRX8VSSuSw5stcZky6lp7hnJotxaVSIv6fruURmgqTqTQTGjDtNIOZcvZVTOkZCfDAr3AIDZCYygTbXKSGp55DK5386vC2/9X/mXFb8WKqy37MMKBzUhhw/V5L8Hs5Xxia5icO34HbwZ7A6bKapxIC4ihKDxXQn4dsIWqpfzY+q76cQ1/qkQny/hzUd3x21FF9u2D2civ5K7Javed9pTdkAqX/o8o+e0ttKiKWhJRtu/lIuWZ6l3CbvPD44nyPYLyKl5WTdReQ/4wv/V++t58dxOUsJNWGFuWFldrDeQ6XyeYhwsC7H61TG55X+d/XBeA2y+w6pEg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YzD8z7HwK+9VBLftUFJPu9vmJRdUl869K7Fizq2RcOc=; b=NjMUEnS0u7UjVBWeu/Kl0Q9cg7qUnGsZj7gAJBXz99VhOaPwcV9LQ4qTk/npRpiy4pzPNLyW7k/xjFRij61dGOzdj62ePAfHND2AP65nnhkg9cNKBQyzV7JkHvRcsCZBc+CQ9gs7oQ/oC1jgI1zjbL9x92m11BkTa4E6crk1+W4uD7MZfm3xylcu/PStqI4hxue83ufIBEq/XB1zfv4Gp+h+1qEzMwLQZzRrhexx78oWoQmLHn6SUVvpMQcWkFlVBkS5Or9QY8qBPrdjEw3H7inrQNwn8oXvc4C+vWPoPici7LXJj2dla3GupaOSEIvMz8j/YeK/9XGVsZOESm4g/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YzD8z7HwK+9VBLftUFJPu9vmJRdUl869K7Fizq2RcOc=; b=Ymm7gUDpYGff2w7FhQ2CP7sXQ/1zFCGrMOYxzx3G0vARO/jOTJXvtPwf3RaazKS/MK/EqQ/ds5PGz3tUsCN6/7z5y2IJLTlvIzlsMy0KoX8Iaq6TjILWW2gdJOeAPB1uEEJjq/NGlkiG3xUxL8vVYiaDcwwSe/bUYalMCeZ2Qh47AeGNFB2ycs8XiEiKnpGpMh1J09yYD80TuaS770xkQUDTU6g5o0pCzbt2tUZWqvBXLGu9mTAhLNvE408y00dXBph0iBXdsSaTqNhrqStGJF8yY/cTvpAdnGxzvieYsePqcZg/j3hqqoRNhx5Eb0T4o3hwoJOJ574ptb9tElULzw== Received: from BL1PR13CA0164.namprd13.prod.outlook.com (2603:10b6:208:2bd::19) by PH7PR12MB7356.namprd12.prod.outlook.com (2603:10b6:510:20f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24; Fri, 24 Feb 2023 15:50:17 +0000 Received: from BL02EPF000108E8.namprd05.prod.outlook.com (2603:10b6:208:2bd:cafe::27) by BL1PR13CA0164.outlook.office365.com (2603:10b6:208:2bd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.11 via Frontend Transport; Fri, 24 Feb 2023 15:50:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000108E8.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.16 via Frontend Transport; Fri, 24 Feb 2023 15:50:17 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:49:59 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:49:59 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 24 Feb 2023 07:49:54 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V4 2/3] tpm_tis-spi: Support hardware wait polling Date: Fri, 24 Feb 2023 21:19:40 +0530 Message-ID: <20230224154941.68587-3-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230224154941.68587-1-kyarlagadda@nvidia.com> References: <20230224154941.68587-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000108E8:EE_|PH7PR12MB7356:EE_ X-MS-Office365-Filtering-Correlation-Id: a67e445e-2180-4933-2976-08db167ed39c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: acvZsp0zHhi14oitGJhouD36fQ24dDAFTbk4Yl/8bBiUGBYUE0HHXsXASTEncZQPmbkjo5p0ko0cDbJTr4ju2cQAjWZjQNPrupfnCRQMv7/zQSYBDIVLZDwDA8gNSiRbMTHWE7ni6uPoHTuQJBzlWYNYttb1AzcS2AireZB5fxPk2pgoAOied0uj1OSLlrIInuPMHfgA2NukK755j/jgzzhtH1bkxvYNiSgGbR+xGcsttjLTfJ7hxSQcpPtBXXmuYHjRp/nSabrJVPyLyOqIAoqJeFCp+ZLZemU6sCcUvXyJXHrvQ1rrg1hH8KGw4uwhAQXCNHbMB70MNnE5Gv6eI5JGktIraSyF5XmiCnReO4vhqhJ0Jx8qdF36X8Di3HbC6pnrT2jpURNsLqcLlzgWfFN1G0g6Qg6I6qlbXKq/o55EM45C4FjGnZ7Sstq7LpQpzY2scZ9jgJdnnYjRft3G7EmTMhKN5GXnBovm3VIRxmK7TbQq9s9kq+CeQ+a0LmcwkhgH72xsKlJsRIlEucD4W+OaSGL/5ASEbwSoeu1xLEy+p7hK/nzow3/ZALPZjbnRAJM6JxQ5D3St7+QqhDdd8myKn0gMWtuWwvRY7z4VqtPd5nxFN5jMPu45IBebZkq9PWYNIMF08EHZLYd72ofe9xwpzmB4vStEAk4CjwZSRE8V/j/fN907VFgEXmlnmlxPC8mx++WIXW0LNcljXgwbx5mtygaqurtSBwTr3bmnGf/4rlR/YlUqUbfIA0WIBc+Sy2xsn8OrY6qmhvtXg0bpZpjmGGR8iX1oUuAUP9BekSB8G50tRmMmMoELbIftHmEs X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(376002)(136003)(396003)(346002)(451199018)(40470700004)(46966006)(36840700001)(36756003)(1076003)(6666004)(26005)(36860700001)(82740400003)(186003)(7636003)(83380400001)(426003)(47076005)(2616005)(336012)(107886003)(41300700001)(4326008)(5660300002)(8676002)(70206006)(70586007)(8936002)(2906002)(7416002)(40460700003)(478600001)(7696005)(921005)(356005)(316002)(40480700001)(86362001)(110136005)(54906003)(82310400005)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2023 15:50:17.2943 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a67e445e-2180-4933-2976-08db167ed39c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000108E8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7356 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org TPM devices raise wait signal on last addr cycle. This can be detected by software driver by reading MISO line on same clock which requires full duplex support. In case of half duplex controllers wait detection has to be implemented in HW. Support hardware wait state detection by sending entire message and let controller handle flow control. QSPI controller in Tegra236 & Tegra241 implement TPM wait polling. Signed-off-by: Krishna Yarlagadda --- drivers/char/tpm/tpm_tis_spi_main.c | 96 ++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c index a0963a3e92bd..b193c950f133 100644 --- a/drivers/char/tpm/tpm_tis_spi_main.c +++ b/drivers/char/tpm/tpm_tis_spi_main.c @@ -71,8 +71,78 @@ static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy, return 0; } -int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, - u8 *in, const u8 *out) +/* + * Half duplex controller with support for TPM wait state detection like + * Tegra241 need cmd, addr & data sent in single message to manage HW flow + * control. Each phase sent in different transfer for controller to idenity + * phase. + */ +int tpm_tis_spi_hw_flow_transfer(struct tpm_tis_data *data, u32 addr, u16 len, + u8 *in, const u8 *out) +{ + struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data); + struct spi_transfer spi_xfer[3]; + struct spi_message m; + u8 transfer_len; + int ret; + + spi_bus_lock(phy->spi_device->master); + + while (len) { + transfer_len = min_t(u16, len, MAX_SPI_FRAMESIZE); + + spi_message_init(&m); + phy->iobuf[0] = (in ? 0x80 : 0) | (transfer_len - 1); + phy->iobuf[1] = 0xd4; + phy->iobuf[2] = addr >> 8; + phy->iobuf[3] = addr; + + memset(&spi_xfer, 0, sizeof(spi_xfer)); + + spi_xfer[0].tx_buf = phy->iobuf; + spi_xfer[0].len = 1; + spi_message_add_tail(&spi_xfer[0], &m); + + spi_xfer[1].tx_buf = phy->iobuf + 1; + spi_xfer[1].len = 3; + spi_message_add_tail(&spi_xfer[1], &m); + + if (out) { + spi_xfer[2].tx_buf = &phy->iobuf[4]; + spi_xfer[2].rx_buf = NULL; + memcpy(&phy->iobuf[4], out, transfer_len); + out += transfer_len; + } + + if (in) { + spi_xfer[2].tx_buf = NULL; + spi_xfer[2].rx_buf = &phy->iobuf[4]; + } + + spi_xfer[2].len = transfer_len; + spi_message_add_tail(&spi_xfer[2], &m); + + reinit_completion(&phy->ready); + + ret = spi_sync_locked(phy->spi_device, &m); + if (ret < 0) + goto exit; + + if (in) { + memcpy(in, &phy->iobuf[4], transfer_len); + in += transfer_len; + } + + len -= transfer_len; + } + +exit: + spi_bus_unlock(phy->spi_device->master); + return ret; +} + +int tpm_tis_spi_sw_flow_transfer(struct tpm_tis_data *data, u32 addr, u16 len, + u8 *in, const u8 *out) { struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data); int ret = 0; @@ -140,6 +210,28 @@ int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, return ret; } +int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, + u8 *in, const u8 *out) +{ + struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data); + struct spi_controller *ctlr = phy->spi_device->controller; + + /* + * TPM flow control over SPI requires full duplex support. + * Send entire message to a half duplex controller to handle + * wait polling in controller. + * Set TPM HW flow control flag.. + */ + if (ctlr->flags & SPI_CONTROLLER_HALF_DUPLEX) { + phy->spi_device->mode |= SPI_TPM_HW_FLOW; + return tpm_tis_spi_hw_flow_transfer(data, addr, len, in, + out); + } else { + return tpm_tis_spi_sw_flow_transfer(data, addr, len, in, + out); + } +} + static int tpm_tis_spi_read_bytes(struct tpm_tis_data *data, u32 addr, u16 len, u8 *result, enum tpm_tis_io_mode io_mode) { From patchwork Fri Feb 24 15:49:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13151458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C334EC678DB for ; Fri, 24 Feb 2023 15:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbjBXPuV (ORCPT ); Fri, 24 Feb 2023 10:50:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjBXPuT (ORCPT ); Fri, 24 Feb 2023 10:50:19 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04hn2222.outbound.protection.outlook.com [52.100.163.222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E6496CF2E; Fri, 24 Feb 2023 07:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FnPy0ri7TiLxRf9TCjRcNgs8Ch/EF/n9dxvC8ULmRGKA531Zg2jU5RcAeHEv9ClhAe1y5WDNHf7FfS1RTnLyYCf9R4vvfON8zsT93Pd0cUTcrW108PTy0RpyVnbLpukjze/fEGhk8w9FhHzllFl+4aVTJzsfIpKMdz8bxwckA7Onur1o6k65g8uOYll74UU2zC4sssvaWlCloUo+Tjngaup6dgSI6yu4zIokXB2aHaRR8auwEpHbcuELq6gKoVH2BdPaA29ubaU5HOLCuA9J9jibMYaWPXVkRKl/jBnw2UNSZIvDcn84vzDmKW03mn3pM8GQ838Xgc1bQm4aXGoseA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=16STglZTI/DGYdzA7sqcyZCgku+uxhdaj2buTCIKCMo=; b=CZlDAlylNn6IYhA8kw1vCjdkxqCjHU+CEW11JjRv7XLnMoZ2DRRvQ0v0igAcC/gTBQ6XqbiB66w+3g0ujuF69e839H4AA+eLcPJ9FpzUdpuIbG0LRxJ1C5gMnOkLLpl+A74acLY0OYgw2Vh3ctcd0m0hWQo7wC2RBUNypCawTvZQWWEFAg7X7cMD9nCTCgaXE6NaXOPvsN+qWv9IVeFpmgvTPGq1Zo6OwLoYm1Uj/ip3GzvxxZ8d9hnQgwud3WDg8TbXbR1VbCPqZsUbX7KWQrxA4YJMewCsqymrnCfjt77MpATiKwvCYBzJYoPadr3qw6g6AKnFAI3D0UbbzJFGFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=16STglZTI/DGYdzA7sqcyZCgku+uxhdaj2buTCIKCMo=; b=QWgAUzAjTqo9ajFN5EfLaaQ5VSVE/IWqc8AmD29Dlj62pj6RUqnTpemQzcUC0PVtnjmXEMUNRDLwgRjBPF2yiSY+AnkMWJgH8y+oIeG+dobrlMvnUcOVY+7hAppKSAkzTc7bKDUPItTeS+WAgvorVfaWMsQSBLnvF8TEpse6uHouQS4WfBHc2i44NfY1Mho538/ya/vqTQo7KTOT8vlOgeVU8l6MZYNZa0hAzZgg/CULQz7PecD+nC3WGNMUaF2ipG4JR89OIzFQh20386B7HFojD1Zz+lrdUR7ceCNvmnylprON6MpiyhLKFAqoCb+muhhjVgduTidWxDvIpM1anw== Received: from DS7PR03CA0097.namprd03.prod.outlook.com (2603:10b6:5:3b7::12) by CY8PR12MB7729.namprd12.prod.outlook.com (2603:10b6:930:84::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24; Fri, 24 Feb 2023 15:50:14 +0000 Received: from DM6NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::77) by DS7PR03CA0097.outlook.office365.com (2603:10b6:5:3b7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24 via Frontend Transport; Fri, 24 Feb 2023 15:50:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT061.mail.protection.outlook.com (10.13.173.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.24 via Frontend Transport; Fri, 24 Feb 2023 15:50:13 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:50:04 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 24 Feb 2023 07:50:04 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Fri, 24 Feb 2023 07:49:59 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V4 3/3] spi: tegra210-quad: set half duplex flag Date: Fri, 24 Feb 2023 21:19:41 +0530 Message-ID: <20230224154941.68587-4-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230224154941.68587-1-kyarlagadda@nvidia.com> References: <20230224154941.68587-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT061:EE_|CY8PR12MB7729:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ca6ab6c-dbb9-43f1-b0e9-08db167ed175 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1UqUkIAo4S7/DdioFOd0C8fxdYvwS/t9m0TqNI4kqX3SLsNYio37WJxhZObSKJDH+aH9n90lMXpiWY+lFXyixz8xD9DwPmbujjrvFpdraqx5EopUdPH1b08SER66jw+nSJam+SAlOMevs/4pKS194zFgAAn51DRiWvYlaCzdA4CpR3mq3XVdquC/cJOtmtSajoyDt/aA3t7wbEFW6tPzWBLvYdcHv1YUE0BE6AyHeCEMzKFPscR5oI/mYmBzdfolnR1e8n40fDcihG8mtfc775KwD5BPeveZyt6H/1BkvRRQ3LCvuqOwMqnvAtSgcBkBYTmrRrtjrwwL7oyFic78MuDz+GtxoWIxoYNvCdoOTbNWMYiignmMu4EOR0fvq4cU8SGh9lXAqMHWJ2OxDp2wC3bAQoWE0qCb2WdwbFlgsN6bRhrTV8Q3V/mMRhSFuumkDjDZP4G8Nr9G5JcIecNEShOVGEIechBp7jsQqLVLgbAEQHBSjjJdzrKFfq1JX3zIzEYZAuNWwq27NSt8GViU7CAicwg1weeIgbtGmyWLCa++EX1/5nCefmkCekgtevhRqgUcYzTASiiUA3ILFNXVbAjDOk55yy3cNC6TAxaDA/GdiXyEARS4MVm5rpZKYNQxuIU4JxfR6V3UOXixXqSY7k0OIZ2F6Ha38X08sgTgrz44mjoGWt17psH2pjolzst4Dun2CjgBCy4/aAdH8euyBHXlMzoFeOCN/kGlFOeHuxNtKzU4EaPsuqDZlBVK0A8/1o057p7iatoKJuXpDthfvg6SZmaFRdyI5zhrXfO7SsL56YWWakkWMMS6jufH5mvTBF1XKxEF5KB7JV1jG4gWmQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199018)(5400799012)(46966006)(40470700004)(36840700001)(83380400001)(41300700001)(426003)(34020700004)(47076005)(36860700001)(70586007)(70206006)(8676002)(4326008)(82740400003)(316002)(186003)(36756003)(26005)(336012)(8936002)(7636003)(54906003)(110136005)(2616005)(5660300002)(82310400005)(7416002)(40460700003)(921005)(356005)(86362001)(7696005)(478600001)(4744005)(2906002)(40480700001)(107886003)(1076003)(6666004)(83996005)(2101003)(12100799015);DIR:OUT;SFP:1501; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2023 15:50:13.7492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ca6ab6c-dbb9-43f1-b0e9-08db167ed175 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7729 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Tegra QSPI controller only supports half duplex transfers. Set half duplex constrain flag. Signed-off-by: Krishna Yarlagadda --- drivers/spi/spi-tegra210-quad.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index 39dec2dc161b..fe15fa6eecd1 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -1553,6 +1553,7 @@ static int tegra_qspi_probe(struct platform_device *pdev) master->mode_bits = SPI_MODE_0 | SPI_MODE_3 | SPI_CS_HIGH | SPI_TX_DUAL | SPI_RX_DUAL | SPI_TX_QUAD | SPI_RX_QUAD; master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | SPI_BPW_MASK(8); + master->flags = SPI_CONTROLLER_HALF_DUPLEX; master->setup = tegra_qspi_setup; master->transfer_one_message = tegra_qspi_transfer_one_message; master->num_chipselect = 1;