From patchwork Mon Feb 27 17:21:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153918 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 CB475C64ED8 for ; Mon, 27 Feb 2023 17:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbjB0RVy (ORCPT ); Mon, 27 Feb 2023 12:21:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjB0RVq (ORCPT ); Mon, 27 Feb 2023 12:21:46 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2063.outbound.protection.outlook.com [40.107.243.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF5923843; Mon, 27 Feb 2023 09:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwGgeL4hJfq8x+TRe5gJBkYtG2h7rCjoKbJ5A0l9+bHsG64aaSEBt8g6O7krOPxsGZzFGA7oGK/lMZRurmZ8gFBVNEVH60FN3tDEPV27R3ftzXyhEd4Zvkc1tSGzsjCNI8nJ9AntWjHUNEj6gYlWsqTOdKdcXAky5GIaQtZS1KkEX86NGPnu/+byzXqgJN+lXHxkuI57dWQVHEb5bVad5+3P9/CW/44Pgrj9pgY+lg37QcF4adYjUVib5Z3Em/PDZAIaBo8Z90VpPqXnhXdULSdH8zF7q+cl25BUrvi9EGYyNBfx50rsZGk27coZz/oeDyFsAZwej3kiHIgpmwKtWg== 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=S9z3h89NmWQPE45T7w8B5uzlawJkhoD5j8eX9+XZE78=; b=b1QgWkOPDEXpnPgyPm2BvXbaCzDMrxOi8rygCoqFPucd2jt1T+eIW1LnbuuJwKAsMPVH/2fVX2AMNyn8iwaY4e/4t4OlLNyZ0roa4WiJfv579Ey0w5j0A6abrePOr4z8rECU05WP/oKFzCUyDBhc3a0TpPDsKKpiT4mP4l3jkN+4SLATbEVONTj8kKbnvWECaGaI1aVWYIgFMC92+zITKOQMxN4LOGsiFU97Jm9C18jZ+MypQ86YqdL5aTw9l0748sj2ydEbahg4gjVZWOpm5GdcdbpS7CT3/iUq0ZlOHv91OOx+1Ffsjd/6FGl1zMOg43qfc39a5G71mAuN19jh4A== 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=S9z3h89NmWQPE45T7w8B5uzlawJkhoD5j8eX9+XZE78=; b=t/Zi+k5WEDp4q7w9A08ub1/+YkwiWMuNZpOAgQTs8QmHjj8PtzsGG5McbzByRFGgXe9uGrx0Z0VqeLDSJnNxg89cv6dCnHqLJUl2SoJyUheM4rV0saEJDVvg4AnZPgtbPhP1I4AdV5RV6kMjzdSnnJ6vb2hkIpAMikqRzf0Bx1cObCN9LGtxR53gQ16AYBechD0wnD/GF4LwNCJ0rKIYM9UjHcfSPvDd423tD4EceXimQJFWDODpECo9YCRovkmCuC8FKi7OOtwyEBDE/4hDvLWwA7k5q/FdphQkYNxC53AwskoNv9Xlx9RbVzoavqVisEqihT6H6nn3Xc9YFepFxg== Received: from MN2PR19CA0049.namprd19.prod.outlook.com (2603:10b6:208:19b::26) by DM6PR12MB4105.namprd12.prod.outlook.com (2603:10b6:5:217::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 17:21:40 +0000 Received: from BL02EPF0000C405.namprd05.prod.outlook.com (2603:10b6:208:19b:cafe::9d) by MN2PR19CA0049.outlook.office365.com (2603:10b6:208:19b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.21 via Frontend Transport; Mon, 27 Feb 2023 17:21:39 +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 BL02EPF0000C405.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 17:21:39 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.5; Mon, 27 Feb 2023 09:21:28 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 27 Feb 2023 09:21:27 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 09:21:22 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V6 1/3] spi: Add TPM HW flow flag Date: Mon, 27 Feb 2023 22:51:06 +0530 Message-ID: <20230227172108.8206-2-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227172108.8206-1-kyarlagadda@nvidia.com> References: <20230227172108.8206-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C405:EE_|DM6PR12MB4105:EE_ X-MS-Office365-Filtering-Correlation-Id: 4859cf62-c78f-452a-c939-08db18e71682 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wz8NP7+vrjPf3w3sU8vhsAC5McRDuNrFXPPgCnU3cwxwMw2+KJ+0HVHiRKPQQkgQBUBv5kaACifI+BXa6YV7sL0aLIPN5ww/5sCox5bif8PNR/X+ooSmgMAojcfSFYXELVqKzWVJdrFsW2bUhTATjRdemtPEn8Kx8f/BTC1RJ/Y1Wg2lMul+xaJkklU9pts0cchIsO5hLDBtVv/W7TIIU135JOJv9uD5i5iURumwshG+NgGsBAZIwXJbTJSIP93XeDd4Ry9AC9NofUX25o2ra8QbPztq59l8TxLQz+u8E/OeN+M5LcVgLM0HqupQfdCKwCv8Rh1IqrTtprCaFZ3dtkS/PXE/gSoWxRiTqkwFG4XhktfvN9IOvQzL6542ZhUoHYPQ46DZPPuMbxc3WfP0Xh421vn5y5QYcQuCLO41oP7ta2iM/R3gEkuwFlbnuPRz1ossFGvWVxlIJRWxUhULLgvgVnbipBFigiz9iOOJKSslns5HrJRWWd4sDY6jUTULEXfafBM1cnqio6Vqv/CEble3J9XajBxKj+9nk2GGw8CjmPAGbrMmsnHa66INSDVKrFOYD/mnhaCtoKc2xlEnGIfXZo1SvGUvkwxgH80bR0vplKz4XuTaw5vyT3R0hfMd+Yqzf1vU/r90y3lq62hFQrvDuzxX8jcCxoAGnmRxDlf08tUioZyQ4vqDAbDdwnGdvYm3jE6NssYc+7br69NXTbQGUNPOXL5qpJuan6q1xH6qJYiRWVrFhi7dU9/4xQ3U0iqx9GDqCn6f1kyuqOxC3A== 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)(376002)(136003)(39860400002)(346002)(396003)(451199018)(36840700001)(40470700004)(46966006)(7636003)(54906003)(110136005)(8936002)(316002)(82740400003)(36756003)(336012)(8676002)(26005)(186003)(478600001)(40460700003)(7696005)(921005)(356005)(86362001)(107886003)(6666004)(1076003)(2906002)(40480700001)(2616005)(5660300002)(82310400005)(7416002)(70586007)(70206006)(4326008)(83380400001)(426003)(36860700001)(41300700001)(47076005)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 17:21:39.5051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4859cf62-c78f-452a-c939-08db18e71682 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: BL02EPF0000C405.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4105 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 4fa26b9a3572..6b32c90e9e20 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 Mon Feb 27 17:21:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153919 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 AA805C64ED6 for ; Mon, 27 Feb 2023 17:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjB0RWC (ORCPT ); Mon, 27 Feb 2023 12:22:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbjB0RVw (ORCPT ); Mon, 27 Feb 2023 12:21:52 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2084.outbound.protection.outlook.com [40.107.237.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A22D123C4D; Mon, 27 Feb 2023 09:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/zAZVoT2HEp1omAKMFhPbbMtspq/4ErWlR9wAgIRhdYnDgE5VAyAcjIlPgE0jT04DqGloN+u5Ng2jOxbipTtP3MHu1iqX2Ph1foVUOo471G2wBtA0kpepx0EdUnozfIyQcPMfRMjcTrQ1QGm3N8sUUP3lIajC+i2D0Wk/paMY9bRBKOtbbBgIVxDv0Q6hs2NxKphb6tYrZbhfiD7EUWH3l018NuQVGXmMswItP+6mAxC6Tnr4d1hrRQczZ9/S6AoTI6H2BB4eclmFdPc503sT1RRcAUfT641B+yXH6h1lu5FylQmF9I46C40uV9OmeZzdp7L5ulPOea7jd9bbePow== 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=4CrWYrnQzjeqIgMM8PaaGIiWahYHga0PSrE4U2JWwo0=; b=NEGVTQ+MkCLRr0TWvHJfl1Ds8eqHMzhA/DJRa6cK8vK9+bw3ZdjqyysQ/T8oSVZ/ntp3CrhJ55sed2HVv5oSPNxtcfmV0THc56VhfDs/04wesZWxfDCOXPnaTWhKAmdZ1e533N8d950Y5K02N6VdEOS8LB9DwWOVYPKk2O0or1GWDNARUXH73i1y5wxg/vQd6mAhJj6GJuKYZcu7zYSbONt839g42jBve1qKPKxVaGKuMNQWJDxPdi0KkwLT7/xzZKP6SHE22+2NjDYWhLZIHPQ2KNUcOenXiYnRopxQnf91IuW8nLPnqTeAyRzDCqe3hbAOm0i24JQ2dFV/CFfv0Q== 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=4CrWYrnQzjeqIgMM8PaaGIiWahYHga0PSrE4U2JWwo0=; b=FGc2es3iU3yBxtF85+x8yiSs4dY1wrqpbTs1Smf9+yKcoQrbZllTkOw2s59yE+fWD9fHRkAc4pFiAOJjatcgw0r9Lo2MbKf89AVowfEcSR9SWQRoHPoXMwKYthu68poCwvzi1BeSVSp4sdqY6UNQLjcN2NdRmegxnm+OC85NCUjLP3FE4DtrLiATPtLli9tA3kUkLNOBXbsqeHArC2cTlzwfZLOPknPKNi0j9OfdBla+n2IhSuZ01D6BQWOM20v2kw76lvugJAIW1Tnhs1w/v/pulYiCSJuO/l1zl3Mo1T0w2Jhj5kmYRoxgEPZgUshQ3M387WPSI5ieFsuUhtUblw== Received: from BLAPR03CA0118.namprd03.prod.outlook.com (2603:10b6:208:32a::33) by IA1PR12MB6138.namprd12.prod.outlook.com (2603:10b6:208:3ea::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 17:21:46 +0000 Received: from BL02EPF0000C404.namprd05.prod.outlook.com (2603:10b6:208:32a:cafe::da) by BLAPR03CA0118.outlook.office365.com (2603:10b6:208:32a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29 via Frontend Transport; Mon, 27 Feb 2023 17:21:46 +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 BL02EPF0000C404.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 17:21:46 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.5; Mon, 27 Feb 2023 09:21:33 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 27 Feb 2023 09:21:32 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 09:21:27 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V6 2/3] tpm_tis-spi: Support hardware wait polling Date: Mon, 27 Feb 2023 22:51:07 +0530 Message-ID: <20230227172108.8206-3-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227172108.8206-1-kyarlagadda@nvidia.com> References: <20230227172108.8206-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C404:EE_|IA1PR12MB6138:EE_ X-MS-Office365-Filtering-Correlation-Id: e35bed4a-5d6a-4937-b5f5-08db18e71a91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +0WqTloj6SsLNVAMazZZ0if9/2xc3jvxhZSAj1z//UH4eHeIwPndLG+5hmJD6lJUyxByjVQ4X/CH2Sb7edlDSiJ45FbWMvGsTaCxuXeyz1Sk8A2HqyL0TVqmcF5xHLwqXCNFS2GNKjKIWw4qeD7ZzScH6ASUaL4zdh/SjyLBOj6Wq0F1XEnM/0JJCxFSXM4q6a1TZccT6rGaEGmv4JRG1SAbZhuNcoWUcJ6M18JT3sads6iPu5RHbtmaAy0oO9j3WDG82v1pd7A5HH+NnBmbK4a0Nyxx5wki8kxls93TFQyLOTzSTuQ8y8MOHoUdZvAZmRIQuovzM4ZCCDnDZYbsR2db4wICyuUQWkfvHQFRXRQMdoDfpfaOPg4pdke0lXYPq+pA+rwpVPJhqcgkZtTUji4yGRUPFTIbu6ZowPUYuSyQUwFE9bQ61sxiXZD9K6w1q2MBw6OFAiNTXMiieDpuO4t4tfdgLk1Bdrj4a9x6idHzADOx8WlptL2Xo5jaqGN9gqAhdBzJ+15IUCF2odEZWy9Gx5K0Kl0KkwEkFeenlXnlPJoyL/8g7xN4mGaZMZqwSjb61hAOyhd2AtoXCKpviTyC2Y0AyAsZJgTrPH6LSk3SfrYwlSCqZWimuu2CcorfdC/RqddspMVYNUPlEzGCCnUSNyXoaX/AdX6MnlayXtUtNjEx51Zj7PZpAXeH7uirxX09eIsJs9SBTntUysqDgJVLHBdDftJAedFHqLSyb5MnoFk6oFCUb2Iw6B4N15KAHCTBX2G8p0TmVMSO2ekQcQ== 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)(396003)(376002)(136003)(39860400002)(346002)(451199018)(40470700004)(36840700001)(46966006)(41300700001)(4326008)(70206006)(70586007)(83380400001)(8676002)(7636003)(36756003)(36860700001)(86362001)(82740400003)(2906002)(921005)(82310400005)(40480700001)(356005)(7416002)(5660300002)(8936002)(40460700003)(47076005)(2616005)(336012)(426003)(478600001)(7696005)(110136005)(107886003)(1076003)(54906003)(316002)(6666004)(186003)(26005)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 17:21:46.3295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e35bed4a-5d6a-4937-b5f5-08db18e71a91 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: BL02EPF0000C404.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6138 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 Tegra234 & Tegra241 implement TPM wait polling. Signed-off-by: Krishna Yarlagadda --- drivers/char/tpm/tpm_tis_spi_main.c | 92 ++++++++++++++++++++++++++++- 1 file changed, 90 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..5f66448ee09e 100644 --- a/drivers/char/tpm/tpm_tis_spi_main.c +++ b/drivers/char/tpm/tpm_tis_spi_main.c @@ -71,8 +71,74 @@ 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; + + 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) + return ret; + + if (in) { + memcpy(in, &phy->iobuf[4], transfer_len); + in += transfer_len; + } + + len -= transfer_len; + } + + 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 +206,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 Mon Feb 27 17:21:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153920 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 D3556C64ED6 for ; Mon, 27 Feb 2023 17:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjB0RWG (ORCPT ); Mon, 27 Feb 2023 12:22:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbjB0RV6 (ORCPT ); Mon, 27 Feb 2023 12:21:58 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2083.outbound.protection.outlook.com [40.107.93.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E68F223843; Mon, 27 Feb 2023 09:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FNZ9y9oHU1RLpObMFNCLHsM6Tgd24j5PiI/PjX68OStYi9ELhKqlDzEO4DpNg9cIRzFUOPcFLeYsKgox3XA3ciZFXLdWD0Q5i5QpahtJ/oRKeUBUD6UJvBGaH6sWPoisr83ENN8utnvSmguIx58PzU+66lpaAd/H0r4fJMBVP3bZsF07y+RLEUHtOEBKh4jcuzJE6OQ3JY0iKR1DIuaJxduXbfxbeSjlSdBizYYFQlpOOSeZyDDl8IYZnyGqo0d/ZrBZv2nRXxfybXLfn+JLUYRbIBGcHdpufrpPveydC4S88vqoCMDPRhHQjeFHCodFMp1naFXMoU/wlKXtuM02qg== 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=YvARMp4wlkj39NWdjhwDo4rztchb5d+OT9cAFalgSQY=; b=KQ4KPRG1eoOhNIVqn7MRKiHWexgtAPhj8UDpktrXrGlmueBoqLPw6T++qKt/Qq8JZhNMAc07NZig8oxgwsSHPX2Hq/xF5FQzJSJwDUr9RsPAV6SJjt1LQrRRd9HtNo3LZwhMCAINzYsfZA98bbSBSiCjRihEGPeBwmLFVyTvAD6/YxgzzBns5nvrpiUFMuJzIwYjv6bho7OipNOFPm3ng5GohDZSwMB5pobfqqBMNfiNZZD9j8X5b0VXnyqyRRqaYNyShJHXwk4Wv8B1ItTXFExmTJP93oiVMury0lbgnDDYsogxnZDlSpoR/FUJ/gsN7h5Uiu9DQIk7YogmojSXBA== 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=YvARMp4wlkj39NWdjhwDo4rztchb5d+OT9cAFalgSQY=; b=pdJTK01P0rsJy4xrHXqSCgWlrxr/gpNie4F1lhju8QNNw9vqM+FYQahbDgUXKWjAb2R/s7bY4xyNH2ITgMp96N52+ZRzbD70eqB3qiQpYqhnal6WhCyMnDvXTmzUTdy5Y02B+WFGwkN+h7Yc93mFQTwF1qKXXg/IQVRGML581K+TeJ+9CbaSDBjm1WleMZY817YVsyRkRk+p8QdtYD0PB3o0NIAQ4JohCTd1DlnOVixDtWAYnSk7irJLoqaXn/xGj+5/d4bDbRCv/LGXva+j5LOWrEfahP8MAqsfSr/wO2vbCbVQ4EANEysf2gFkE1vi7LmSgdy8lXP1yApW4JjwTg== Received: from MN2PR05CA0046.namprd05.prod.outlook.com (2603:10b6:208:236::15) by IA1PR12MB6628.namprd12.prod.outlook.com (2603:10b6:208:3a0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 17:21:53 +0000 Received: from BL02EPF0000C403.namprd05.prod.outlook.com (2603:10b6:208:236:cafe::5c) by MN2PR05CA0046.outlook.office365.com (2603:10b6:208:236::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.16 via Frontend Transport; Mon, 27 Feb 2023 17:21:52 +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 BL02EPF0000C403.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 17:21:52 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.5; Mon, 27 Feb 2023 09:21:37 -0800 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 27 Feb 2023 09:21:37 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 09:21:32 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V6 3/3] spi: tegra210-quad: Enable TPM wait polling Date: Mon, 27 Feb 2023 22:51:08 +0530 Message-ID: <20230227172108.8206-4-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227172108.8206-1-kyarlagadda@nvidia.com> References: <20230227172108.8206-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C403:EE_|IA1PR12MB6628:EE_ X-MS-Office365-Filtering-Correlation-Id: fbea1484-48d0-42b1-d071-08db18e71e38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kbu2qLZObvtXXbAEEVG87+r1AqHnYRLj2ZaCBnyCouRCzGSArWx/93QSPy85BrnBYWBkM3qtHySXlqsXmwy/QqrVRQEyWsc3J+71NT42mulvVrGqCuG7MIUVDbXUkNfqS0/Q9tw2CGyh4G73VMLTdm9g9/PLdOwoo3vB4DVG9cCZjZ0f2QbSXBqHEqCD7lz3AYedMKy9S7KT0KAOCX1qkVeWzBjjgNAhoIt04h90EquSYoHfEaZ1Jd0aLV0echo28ghqshoLHTqeHFJT+px+jZCWHxTH86i693K6dHAksofRg+gUeONMRpvPHO5+VPNcYD/+60UeLI7P+mXK+OOSPraBUgU1xRrGqp5wgc+Rkcu/FKkM+4h45gdP9ykcA8dzlfhb5FPrlpZFl8mjSVcO02tRzY1IQJN9pC1WosN1e4kZmsnkZXjeeBH/WmkaDZ3ZGeAdq47bq5NKVShCPU3PVuUBmYF/yi/jPGdOysH5vvLUjtAP70PoDGivF5dgHcelKA8Mj8vmwpEIfJxqTPmy4bRfmmgQjBTSpzi0wxNoOPlE+AFHRPjtCKF3imMh5FS+jpNgreMSlCBP0qabEOVNY6xyGr5Mq5vXkAbCstmc9SEngvkbE3nag9Jw4haghE6xgQpKeZ+IZnb9w9x9fKPtGvozmp28Ygb9WNt865h3gMcSngM00aAUzGfgeEGtBS0uN6vAR2Vtl9Gq2HPf9bypcSY80pJKxN+HUlGLQoPmnegi59m2/H2EaawWronrVY9wnYr21tEoneUosH8iE7Arkg== 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)(396003)(39860400002)(376002)(346002)(136003)(451199018)(40470700004)(36840700001)(46966006)(4326008)(70206006)(70586007)(83380400001)(41300700001)(36860700001)(47076005)(426003)(316002)(82740400003)(36756003)(8676002)(336012)(7636003)(54906003)(110136005)(8936002)(5660300002)(7416002)(356005)(7696005)(921005)(86362001)(40480700001)(478600001)(186003)(26005)(40460700003)(2906002)(2616005)(82310400005)(1076003)(6666004)(107886003)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 17:21:52.4421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbea1484-48d0-42b1-d071-08db18e71e38 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: BL02EPF0000C403.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6628 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Trusted Platform Module requires flow control. As defined in TPM interface specification, client would drive MISO line at same cycle as last address bit on MOSI. Tegra241 QSPI controller has TPM wait state detection feature which is enabled for TPM client devices reported in SPI device mode bits. Set half duplex flag for TPM device to detect and send entire message to controller in one shot. Signed-off-by: Krishna Yarlagadda Acked-by: Thierry Reding --- drivers/spi/spi-tegra210-quad.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index b967576b6c96..e1165584a20a 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -142,6 +142,7 @@ #define QSPI_GLOBAL_CONFIG 0X1a4 #define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1) #define QSPI_CMB_SEQ_ADDR 0x1a8 #define QSPI_ADDRESS_VALUE_SET(X) (((x) & 0xFFFF) << 0) @@ -164,6 +165,7 @@ struct tegra_qspi_soc_data { bool has_dma; bool cmb_xfer_capable; + bool support_tpm; unsigned int cs_count; }; @@ -1065,6 +1067,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, /* Enable Combined sequence mode */ val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG); + if (spi->mode & SPI_TPM_HW_FLOW) { + if (tqspi->soc_data->support_tpm) + val |= QSPI_TPM_WAIT_POLL_EN; + else + return -EIO; + } val |= QSPI_CMB_SEQ_EN; tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG); /* Process individual transfer list */ @@ -1192,6 +1200,8 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi, /* Disable Combined sequence mode */ val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG); val &= ~QSPI_CMB_SEQ_EN; + if (tqspi->soc_data->support_tpm) + val &= ~QSPI_TPM_WAIT_POLL_EN; tegra_qspi_writel(tqspi, val, QSPI_GLOBAL_CONFIG); list_for_each_entry(transfer, &msg->transfers, transfer_list) { struct spi_transfer *xfer = transfer; @@ -1450,24 +1460,28 @@ static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data) static struct tegra_qspi_soc_data tegra210_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = false, + .support_tpm = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, + .support_tpm = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .support_tpm = true, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra241_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .support_tpm = true, .cs_count = 4, };