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: 62007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2547788wrd; Mon, 27 Feb 2023 09:30:54 -0800 (PST) X-Google-Smtp-Source: AK7set/Jy8iXqV281tMvTGxZPWbSQw0pbOj1Q+vFRKKWEN9GZeutGNnqEnOVpmYLZ79VAy9eMirD X-Received: by 2002:a17:906:1093:b0:8b1:75a0:e5c6 with SMTP id u19-20020a170906109300b008b175a0e5c6mr36556741eju.18.1677519054448; Mon, 27 Feb 2023 09:30:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677519054; cv=pass; d=google.com; s=arc-20160816; b=Qyt9nVRxsY28wrn8pXtdcfEVHI+XtPfP7u9p+v7yPhGhE/qx6y+Ata6DENevN6rmX6 bJ+5a3XJfj3KEan9MEGxXoncv0+uSTzGsll8mQdYQKPVLVWXnZao6aaViKjzrOwPhshc DVkg6+rIz1Eu+HwuZ3Xty3ChV8DJrWYlMiWiQc+P5KfYF3rxzEnEo1zrWPd04LuqVF+G oDnxbD4W9n+KLZl0OwVNBfbJcA/y/9TykNsoPxCMJKCA3A0cbZ8V8WVInLD5Nc3DIvwQ dGDahxBUhR8tVOKCPf28p1a8EEcx7ULrS0NRQ5A6lrc12xp1tveMhN2MiUmsDcWVP8T9 RmqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=S9z3h89NmWQPE45T7w8B5uzlawJkhoD5j8eX9+XZE78=; b=CyoSKlj0WIZ9Gdcmb/vU6QNIpAxp7kDnhrPrLvzUPUZuzXghk9hjN3s7Yjx9bfaZMS 0FM5Dq5HtgIo71nwMWKt3m+T6VR50SzZfZTOV21ByncUpPSHCsYFt1CmRe992oaluDmt C9eBKhzNnGPZnWyM1AbN1yE390gd5HvEM5WBvGC+CERYxYkCWldKmYfcQvlCPebjxQgB 43DN7vtNi+nFtUk5dU0E3gCcpJH6XpStlDpcDit8pGN1/z2+qrlny5VxRI7filszLVo8 SThItKWpPvj1qNADGr7WrgkOn1V6krlI85JiZq9Ag3NnxiQKKheeXVly2s/7lvJH0q03 c4XA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="t/Zi+k5W"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn29-20020a1709070d1d00b008b32ee7dc53si12063380ejc.799.2023.02.27.09.30.31; Mon, 27 Feb 2023 09:30:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="t/Zi+k5W"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbjB0RV5 (ORCPT + 99 others); Mon, 27 Feb 2023 12:21:57 -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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759006219942418897?= X-GMAIL-MSGID: =?utf-8?q?1759006219942418897?= 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: 62008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2549156wrd; Mon, 27 Feb 2023 09:33:28 -0800 (PST) X-Google-Smtp-Source: AK7set9y1qaOjge01Gx6Gktx0PMqjH4tIfdhohBIPFHVLh811nQwddz1dv+KrxDsddjaAMKhPCvF X-Received: by 2002:aa7:cd89:0:b0:4af:69e2:529f with SMTP id x9-20020aa7cd89000000b004af69e2529fmr283686edv.27.1677519208572; Mon, 27 Feb 2023 09:33:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677519208; cv=pass; d=google.com; s=arc-20160816; b=svV/MqQM9Eesmx5bZAEI4BVB4r38/56xDySeJsbPpLagrFlEci0dICNilQ+F+01hWP FY7oNUwg2obncvtCP9JdCnQYV7UagOO6Xi4KK9KbTZLrC8V+ITuKYtLBSL3wKwS8RwmK GIZN0rhV1NGtoTgmhUhhhd2DpYqXQXknmJOUizSpkcebaps0qEgZMCgzJkdLflkgkrFS c2wy+dYisTynZ9fCa4QCVN/pruVLmhJPdFGWDTGBBkmKuN2OQmblUhaELRXMIrXwHTP0 4STtUOUyCtB/1rDL18fus6ew/W4nMKGiENTx0fN/RJ8ip32CQZprpatuTD5gyZVs83kG /fQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4CrWYrnQzjeqIgMM8PaaGIiWahYHga0PSrE4U2JWwo0=; b=DWpdhWgEVlLD/gCNs7Jl9TQexDsNuB1CmjUt6wW1DL0vXw7H8tmjVtgd3iq/vbiWFp UdZ0wHzcWmsX6pL04BCUkzvu9KvatOzUEucvBIXd5qoRfeMC7Hnp4z7ZlWzOcjbM08Jt 1hsiO0V5kFeIU1YnCjXamK4+A5fkzw9lEDBhEIV9QImamlzSodYOap581QmyQNNVgr3M WEvULpPz86XMkzbHmavN0a91O4CAueWs5tMafnwHBzn+NjGCubCIZT5u5Z+1TEHWKxq/ ri8M4SET0fSdjopcaZuk3TDp5z0UcEdoD7jk8RndIOsv9ehQusOVcrl3csZmX0+RYqtm vJRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=FGc2es3i; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020aa7d890000000b004acbcd255b1si8399470edq.198.2023.02.27.09.33.04; Mon, 27 Feb 2023 09:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=FGc2es3i; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230142AbjB0RWD (ORCPT + 99 others); Mon, 27 Feb 2023 12:22:03 -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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759006381836769323?= X-GMAIL-MSGID: =?utf-8?q?1759006381836769323?= 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: 62009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2550459wrd; Mon, 27 Feb 2023 09:35:55 -0800 (PST) X-Google-Smtp-Source: AK7set+dfZOtT26ywulKrnY9uiQ3aqW7cYVfyuadZOAt1BEY7lwoKhWFEUmrAbXuNrNpYyq0jGtP X-Received: by 2002:a17:906:3d7:b0:8b1:7e21:f0e9 with SMTP id c23-20020a17090603d700b008b17e21f0e9mr37812686eja.18.1677519355556; Mon, 27 Feb 2023 09:35:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677519355; cv=pass; d=google.com; s=arc-20160816; b=MrirP5ANLHd48nS6xrjAgflKvsjGpp4X4ubYbHLBkGx65KVdcCAtgJr69lAruQMIM9 oUENh0gdYwerRBecG2eDxwt/iwqI2bTNeY5yfzTcPnTWQd+XyKr5Tm+ZsCCUguICYyxq /XydH+bC9oIZAk7AYM+HQpi6Kz4RZMpExi980USMdbfLGZxFxDjrzhsg/BrEbE0B2WY3 mQ+WLIOIlmz1aAMTbnCILoPTmugQFOCBCUIN2Kcq9sNVKgpyrjAFXdxy8RZgUXiU4rpc vywn/U/1xIfWXhDOXoEzQX9cBTxRf1hBxWuT3RaO4S36WT3ieKspf4ENF9b06lz4f9XE XSoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YvARMp4wlkj39NWdjhwDo4rztchb5d+OT9cAFalgSQY=; b=JENN+JAGB22bQeu7ndZaQr9+5kRAraEmE4T6KWyOWg4HCzoBKi6FF8MHNH6IJ2JwSD LZew9PnIdCk2NkAILLN/+eA9Kjw6A5l7+r1RGubQf8838g4EmCrLtAFxv2PKkQvrKABG +qAv+05ZuSqhvacXhRgcUjrOQ7mMu5ETKtvKFkzaZx23rAsE5RQ6jFiz4H0L2izrHJer E04I2u+yJYIRHoQYDrbmH44FoT+Uxembr2CodEd0ZPs97Wa/NvKMK6cesvItSAFqNL5n Tp8Wq1S4v0YunSq6H625RvK8NE3tWBIxD4QmWA8A7FSautHYisaT4BbXibbnYWQtUZw4 XHuA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pdJTK01P; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn29-20020a1709070d1d00b008b32ee7dc53si12063380ejc.799.2023.02.27.09.35.32; Mon, 27 Feb 2023 09:35:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pdJTK01P; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229511AbjB0RWH (ORCPT + 99 others); Mon, 27 Feb 2023 12:22:07 -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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759006535994035913?= X-GMAIL-MSGID: =?utf-8?q?1759006535994035913?= 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, };