From patchwork Mon Feb 27 12:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153388 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 96213C64ED6 for ; Mon, 27 Feb 2023 12:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjB0MHh (ORCPT ); Mon, 27 Feb 2023 07:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjB0MHg (ORCPT ); Mon, 27 Feb 2023 07:07:36 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10hn2221.outbound.protection.outlook.com [52.100.155.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344351F5E0; Mon, 27 Feb 2023 04:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lDar4o0CSpj1j+Se1ThAL63mWwZQM9Il2ewVlfB+shmgH5XxL7I06UBMX7aFX60gyH6z+Rd3cDTApy92e6DV8k1kkZXOacATwZpaffgP27+7t46m9j1iz5rUKgsBnTjnKinR2wIXv/I45+rXgaNRYIy6SWbqXtbHewY+BCVMoVo7uh3mqQISbZ2C/fePvSIx+rc5uY+gboFwGI5z+nIpQWj0wh6lEcdbSYyx+DiGOQRCvfimp5/WkfglD9Mqhp1gnKxKwQOaOeoRLwkJShHAIGI7K3TUW1+2NPijKiKc9xP5P3epukRAGRwugb3EcY4ARVVOl0o7hINzxFmqGvCYQA== 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=np/+2zQ6xTl0FjueOGA5LwPrv0YonhgkJuXeMbKrIv1uo4LxbbqNLTGIMR0Db6jjsjl8HRc/WlIxruK/sjNOeq7BvTf8iWP9L+rhsGMRMujNhtFnrH5KuqhM1/o7vCYLiABm4C07KrYj0cEj6AYptcOLPYME84bZxrfkJxSA8na4CTzPFHZji5R5ETuTYjm5i/CBadbFUoyBdsrsmo12gYi0RSFhUlh2me+AQFZQI4l9NdyYXA+cIUGlL9cfbjopWFoclZYalQuwj509qofsIx7spLCnghc1CKVF5vHZVaZUTXzKnrIVSjnNI5fYf9K14GlfiGwLv7ImsJH1GqELiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=mRwtrm56hPNdpKqUMISXAdmKIQ9wmG+2YcNDbwXd9N3Jy7hsWlSBwAR2LiugJUASrpehoB4CT0NcWamgfhq1o7Jc9/dDKg8Cfxfjuo+863CGl6wBFgVE4XZ3YimrZ54UwdCoIl0k4uJ8Mj9KcJZACid5JMNBtmvYP0cLcTlDeuV5s07TriZRs2Cg4OUr3Maj2VjXprcDlA9PTmszfmyzgdliPth9Sgot4A2wdjXbfwx6yAswhf9d//poxokPKU+TWSU6DwhxXodzcQ1PN99cjOcRte8CJYTsnH5UFtGgTIt4zGLjqt8zSuPfSH9IuTav8VQ7CF+JY8atydQdeAs9yQ== Received: from BN8PR15CA0061.namprd15.prod.outlook.com (2603:10b6:408:80::38) by SA0PR12MB4592.namprd12.prod.outlook.com (2603:10b6:806:9b::16) 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 12:07:30 +0000 Received: from BN8NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::cd) by BN8PR15CA0061.outlook.office365.com (2603:10b6:408:80::38) 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 12:07:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT082.mail.protection.outlook.com (10.13.176.94) 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 12:07:30 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 27 Feb 2023 04:07:17 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) 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 04:07:16 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 04:07:11 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V5 1/3] spi: Add TPM HW flow flag Date: Mon, 27 Feb 2023 17:37:00 +0530 Message-ID: <20230227120702.13180-2-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227120702.13180-1-kyarlagadda@nvidia.com> References: <20230227120702.13180-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT082:EE_|SA0PR12MB4592:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ae2f2bf-144b-4120-ba0b-08db18bb33b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qDvvfn8y8N5JaMulu6MU/7Os6TEdEwqRVzH4KMpSkVSYPJPA1OHW7HWbs3u6vibFbBEnM2vFPJuPze8JJnp01SKXErkrTokUoOg6q/Dy4hoEnLJUICAVT4nZF+i2MKmDRoYte5ARVwPYSHQQzAYwwkBXajAnnoUnyf1Fh2vjjQXCUSQxMRz8SRnD2HzvN7jvxvBOnFavRvH44KMVkJCjX2CDbAF5NCyy5VNzok5z3YuwpOdAsGXA+U2SevNbLOdAJVuN6O6sJFv+kLqooqc44F6OaaOLzSwXCi7XZbu0BHriFKM5tqJDocVp8PXP22H5mw9EfmQrxVBbKH0Ae+EwaKkAQU94U5CLxsskJ5S41XulDFzFAGt+kkdGgYyHk8j5dPcSjRIQGcN4KOy1rWwLPw0AT482HFlyIdCestUcblkZ5zVURxoq3h0J+iJYVHH/VH2Wi2atyJMcmYjig0m7fuhTnN/i2Ls+3xPchuIvxtffVL7dzPQfZOalsie3+LLHI6c+4KC/qVP0sPjwhTYAeCsJ/zBaB45PJA+jS50rNZIrJeG/DsKXXVYBTLeg2t5M9cVMEZv0e9T/lnLUneSNKx9aLbvHvYvTNE8zoaCSHZoSh5b2qIvdMgwlDm38+r9mIzg8qAQCd/g5Yp8WJ/PLoIC586kM9swz0vpV0UNRJ0uvTkXceDwzXNc8I6BOEQkpB+xEDsbLA72/Rdnvkx+Yh0wXOgWqCL1hF9boi2pBIZ9jKPX1EjsQrzhA9KCgcdNSi6S6J3KRJ7nHbdiTvAAJdry8f57JNx/b6JDqGmjWLS6vCrhGZfKbBUdOXYmQ1SmYbbVY1l7dIr0++mynmvyqaA== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(39860400002)(346002)(136003)(376002)(5400799012)(451199018)(36840700001)(46966006)(40470700004)(2616005)(426003)(336012)(47076005)(478600001)(7696005)(40460700003)(110136005)(316002)(186003)(26005)(1076003)(54906003)(6666004)(107886003)(83380400001)(4326008)(70586007)(70206006)(41300700001)(7416002)(356005)(8676002)(34020700004)(5660300002)(8936002)(36860700001)(82740400003)(36756003)(7636003)(86362001)(82310400005)(921005)(40480700001)(2906002)(2101003)(83996005)(12100799018);DIR:OUT;SFP:1501; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 12:07:30.6459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ae2f2bf-144b-4120-ba0b-08db18bb33b4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4592 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 12:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153389 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 D72A1C7EE23 for ; Mon, 27 Feb 2023 12:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjB0MHp (ORCPT ); Mon, 27 Feb 2023 07:07:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjB0MHo (ORCPT ); Mon, 27 Feb 2023 07:07:44 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02hn2230.outbound.protection.outlook.com [52.100.158.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F08E1F5E2; Mon, 27 Feb 2023 04:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VEapMt7/slqri6kx+CDGjW020JCrD7qkVbdU5vKd3Q66BEcE7Pv3vItRf1/NIawrWQs2DD3rgyA9t5XulOxFr43/oEsmuVc5TsQNlb+koxx/c5pxdXpjEU9JIgjt74FDyzJuiF5Te0H1u5Ns7Z9P+FiLp0LO1zk2tzbqd9kr/BGH+WJL//mZMiHy1bddzJG6y2Yv4/79vaGCGW6o+6aeHGMjZsiG7tbiI2KlMylmK09DKcfcrBwP3nwWtxyRSNDOYd81HG9SZ7VU7KGPZlfCgFWV6wSfRJyAyYu3iW0/tOerOLzTbferHNpx4aXRxnl082IlGkdaB5mBjpw6V1aTqQ== 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=IlgwQbdujaGj9+38SrRlGzXn/YnDWsY1jjfqL94PiFU=; b=bQa02ksnvkrgM4hDUaEaQSW+jnC7K0F/Vpca2HUCbMsc7qJ+GU7atrA18FnGe16rYFOAmO3SUtaMZ8zJeuIMIsjyuy2g8WlD7EkoiLw1iogsMKRO/BUAvAPgfwty1H19oTr4uyh7kp1Pq+CGJFFo6aqOeOrveInPNOOqdtd+O0g+1dpD7lQKPuHRAsGQkajoWOdfOd38lrfVGWk2fW+e6YkEVPosoLgrhzMVW7SDLG27jmH+5DREqeCLYvblIwVL9ueeBeROxVtZ6gQpoJwpnM+L8jYGFgTzjOW2CszPjEgM0as4Aubl5NZoohmz7WrmDYbpok92xE9El0LVNgyuOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=IlgwQbdujaGj9+38SrRlGzXn/YnDWsY1jjfqL94PiFU=; b=ZdxZCvvrRnX+c5VCZ6KERr29zWDi/RSB1W5TcC8ecnqri0lZ+sHpLOPEWJ+RtFT1VTf3rJtbggQy/boMqiz1HTHlqxH+6xQwQm3GOQInRKZLu6vgNbXNz69x+BIrRDRkl7Zhgdqso88QxjgU8IBsogt3c3mAFrRvownPyxhohgR8GaMQaUFv58rtgLY+cI7GMBiliC6ME3bUlrzhZrHPbZqgRNHH3Jrpx4FJYxC0R5guiwzNbOuSh1hlofavlU7qVApHNGB1e+tlp9fSbjrWj94UVn9/hsHTq7LCF4cwy3rx7vmxnGXPxHcalwvrojGEXydkBuNRJwjwsOu1qEKsBg== Received: from BN9PR03CA0200.namprd03.prod.outlook.com (2603:10b6:408:f9::25) by DM4PR12MB5342.namprd12.prod.outlook.com (2603:10b6:5:39f::5) 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 12:07:34 +0000 Received: from BN8NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f9:cafe::7b) by BN9PR03CA0200.outlook.office365.com (2603:10b6:408:f9::25) 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 12:07:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT022.mail.protection.outlook.com (10.13.176.112) 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 12:07:34 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 27 Feb 2023 04:07:22 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) 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 04:07:21 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 04:07:17 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V5 2/3] tpm_tis-spi: Support hardware wait polling Date: Mon, 27 Feb 2023 17:37:01 +0530 Message-ID: <20230227120702.13180-3-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227120702.13180-1-kyarlagadda@nvidia.com> References: <20230227120702.13180-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT022:EE_|DM4PR12MB5342:EE_ X-MS-Office365-Filtering-Correlation-Id: 195d434c-5848-4a66-eadc-08db18bb35f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1tYyktesutHks6I2MOEEne3y10HBkWXvNPm4FfywCQkL9OyVWvw1kPpgvVxgTjBjbhn7pzHoBI8Iyhd2VxOvmvqV7Om+uQROhp2ichFVcP2kqM0RRHclj0yWjurRRlFUbMDSYj0ssgIZYzUgiOYWn/cgoJ7jrPtPuxacETpanqQe4EtvXTj8yHQIVqb74h0Xt4WumjYU8wzSVe1TXpi9/FVpF5rG0HNwvIGO2tu4T37qMPwyVIafm8zoiAJAsKAszGYYnUNocnb/kCj+OaH4mfmqicbUup8DJfu12yiJVAaObm+6WYZCZKLiV/u3+UWmMVrmTPYGlNQoZl7Ye4XDTUn9DlK1IYuMIxEoRR7euE7jpwqwyFtKRIOsopQGLdM4bjd7bJY8CgHE05McYPlhENFkKKozIZ9r/rk5M5+eaevU1U8i+ojfJ3BmN4Ky2J6hvt6JVLG3Gh2uIeXQG4nyx9rGdbsoRLF1yVlil4YWXpH6NkNGVtUYpX2M7Ubek1X5ASNS1xb1/En6hBOhHd1SS3548orpL6HVwR7Vcng2Fp2CMdgwepdNscJYYizPsJ1+ltMfxGM3uzD9RoG1jARxSrsiwl2VE9Cr5Vp9XWNxwhtTPC8rH1odC8FoT1HWZT3lzYYbds4L7DhSao0RQoMzaoEqC70D7nYSw9/kU3wwsei/e5U4CfKykEnm8HWnomqMd6pxKuGhh61S/y6KkGo/wNp1L/lZYvaTSs4H6b2LB4aQJDipglwqqknXquY/4OHd+TU+aVBlqmDRWHFzC6w727cuJ1diV7Jof9LIQQxQFf4xuLey4XsHQ8oeGcCZXXwHnveDxtgz2h7ZSN5Ucg2+pA== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199018)(5400799012)(46966006)(40470700004)(36840700001)(2906002)(1076003)(7416002)(5660300002)(8936002)(36756003)(54906003)(40460700003)(41300700001)(70206006)(70586007)(40480700001)(86362001)(8676002)(4326008)(921005)(356005)(478600001)(110136005)(7696005)(316002)(82740400003)(6666004)(7636003)(107886003)(36860700001)(82310400005)(26005)(186003)(34020700004)(2616005)(336012)(47076005)(83380400001)(426003)(2101003)(83996005)(12100799018);DIR:OUT;SFP:1501; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 12:07:34.4507 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 195d434c-5848-4a66-eadc-08db18bb35f6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5342 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 | 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 12:07:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Yarlagadda X-Patchwork-Id: 13153390 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 27402C7EE23 for ; Mon, 27 Feb 2023 12:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjB0MID (ORCPT ); Mon, 27 Feb 2023 07:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbjB0MIC (ORCPT ); Mon, 27 Feb 2023 07:08:02 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11hn2222.outbound.protection.outlook.com [52.100.172.222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E0D1F5D0; Mon, 27 Feb 2023 04:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DHrNTDNdpwxNuShTBCPVj8jdDcIwtGh9/PiqeXLjizxX8kyoHXauJjRxEpa74+4AnQZ83U2/psygiirBfF6XsAQrVtPm2uq/9GGb/4OKJllaBLbp+BcS8n9CTIR5l4By5u+P8hARRTWD1lTdIj7Kcww6uMy0v0AmuM42jQTRI+xMxB4o7kbFbXLx66mVv/5Mvrss358P2T8xxRJ1zDCvknK3/foIj7isF7r+/zTN4Xa+HAw6jAVHtP+UTGYDwqnra4TQ7nMpbMHgoW8o2dyJfk6QGfvdi6IbQgXoa9R6ap1dap6hM7QhUHT4Z81SHLUuYQk4IhkfTaJQVNI5kHRpCA== 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=HpKHpbqOPtWGpwP1tKVnq5lfCOEd70QTpkDFyU21Mqk=; b=XWck96eBJR1Q8Ka9wSpjXLUdjY3vfApQDmRQoeKCv39tiNPvVmGu6eWcGpmxquTEkhlvE+UjJWG0rx4k6Vse51yfooXmFtD/IZd5PHEjD1M2IFFQQBuya3QfewZo7+bBe68H+WdHm0b0iX2eMz78Uog5IdXxc1HiALX4mALB/qI6v6K2CxIpZ3AJwDQ/dfgh7i15IuLZhvRJZ4F7XtqR9zJE+rRATvX+XK7Q5Nesk77jVq11sUA+H+6JrzkiKLGqAMpQIvTy76p4UFlWkqQOnqioefPtCQAoQA6RWE+Xsk5E4qFcORly87MpDi8oVIiHp1PhEdLfw7PC5X+ASOA7/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=HpKHpbqOPtWGpwP1tKVnq5lfCOEd70QTpkDFyU21Mqk=; b=Nz2GWA5dJvSkrIgoQxUvTBgUTEeEykyiZx5b+zWU29vxldZNpQL2CfyNdNa/NTraeX8vJNQvmehDLPdpTRflpEE0hxtNWoFAxRgsw4pKnwL+ege3PaXE5MS1MJzL8KuLuykUz/Jtw/Zh+bpzCEW19dA1GaXEhO0vPQzJfvwBi/Do+rGHqAveQcCU5PZhEdP7KURUAIJ2tRzsc9HJwN76LLulo9G+PeQChpuTNcdMSXOBYmamqC/0XrKp8aM7yvBHD6WCRsPiDyeZDGErOw7xTS7YxVhcqjk/uNzt6f5BA0+nYIJjH3NfUBwaHAqzUg4lIbbwRuMiqUkzhmkcgmU3QA== Received: from BN9P223CA0008.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::13) by BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.28; Mon, 27 Feb 2023 12:07:40 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::d2) by BN9P223CA0008.outlook.office365.com (2603:10b6:408:10b::13) 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 12:07:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.14 via Frontend Transport; Mon, 27 Feb 2023 12:07:40 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 27 Feb 2023 04:07:27 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) 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 04:07:27 -0800 Received: from BUILDSERVER-IO-L4T.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Feb 2023 04:07:22 -0800 From: Krishna Yarlagadda To: , , , , , , , , , CC: , , , , Krishna Yarlagadda Subject: [Patch V5 3/3] spi: tegra210-quad: Enable TPM wait polling Date: Mon, 27 Feb 2023 17:37:02 +0530 Message-ID: <20230227120702.13180-4-kyarlagadda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227120702.13180-1-kyarlagadda@nvidia.com> References: <20230227120702.13180-1-kyarlagadda@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT046:EE_|BN9PR12MB5115:EE_ X-MS-Office365-Filtering-Correlation-Id: cfe91f0a-b878-4fda-ba07-08db18bb39a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NygylvNpcYHHmoGZzwUljsuhh4rqavwLGFnEj3xI58i45rSCKLNiZdztzqtRqFZk9eJT0HIlWzgxWokABoJDXU1CvTrTs/eH5px5MfCLz08ck3nALHyaC+NL4aDX1a06WHOyci2AXyFCR0UdAhN5AyOb/G3TT6dDAIzx28o/TBM2FzJIhzr9PZow8MArL8G2hr+Lqgy8UIpcb/ox9vQ2mwnJgSA2Y3Xi9NAqwCkeyUEZwEdAGC5b3UpzG+1038D/nV54r/f/7itd2GeDHXzh8TbJ9ww1bUZMTXc8yVN4xbLv2dykUOFRVUVg3MT7w4YcvKAh5WKMIsSLFqrwTjorqq30HDEWp95VQ08XWvWNBow4JYnICgm9ZsGISSriCVFvoOMGmUpTj68zJqGHxnd4Fl+n2jZ+meqQTgfriXXUVHZjIG6dSyJE+5TcXlRcZkRR8SLwz9b6zY80tT7TZ7IXb3tsK/HEqNDAuIPafqbF1NhkkDultN1JvR4T13mCwr0L2n5/BZXqaqO0usIRQ+TAbbOGaaXYh3d8yRo0cbJqpRTAmjUQC3KbPqD/0BeYWwqNUcX7u/FdnEldob+drw+lTh9s/M4CYNf3GJXPjO+LogUYYxFS59iw0UcC4OyuSWEcgel/65h4v7zQJ4ucJvySd2qhYfBPO7afHi7g8OB4GC5u++tk3rzmHYd0EscKVXozRtDvDE58vy56xVCwLc9i3+XA3mLLebF8L40UfJ/OVipm4T8h7v2BLQFB8+yjMIF8O7bAP5jWeN/hA4+ULZZB9GiICayTzGtn+CL/lEBb9GXHR3fqHrbzy9rStneWb1rweq2Wb+vynPPLUP/NXI1DBg== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(39860400002)(376002)(346002)(5400799012)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(186003)(7636003)(83380400001)(82740400003)(921005)(356005)(8936002)(4326008)(2906002)(70586007)(41300700001)(70206006)(7416002)(8676002)(36860700001)(5660300002)(34020700004)(7696005)(40480700001)(47076005)(478600001)(1076003)(426003)(26005)(336012)(6666004)(107886003)(2616005)(316002)(36756003)(110136005)(82310400005)(86362001)(54906003)(83996005)(2101003)(12100799018);DIR:OUT;SFP:1501; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 12:07:40.6008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfe91f0a-b878-4fda-ba07-08db18bb39a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5115 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 --- drivers/spi/spi-tegra210-quad.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index b967576b6c96..fe15fa6eecd1 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 tpm_wait_poll; unsigned int cs_count; }; @@ -991,6 +993,14 @@ static void tegra_qspi_dump_regs(struct tegra_qspi *tqspi) dev_dbg(tqspi->dev, "TRANS_STAT: 0x%08x | FIFO_STATUS: 0x%08x\n", tegra_qspi_readl(tqspi, QSPI_TRANS_STATUS), tegra_qspi_readl(tqspi, QSPI_FIFO_STATUS)); + dev_dbg(tqspi->dev, "GLOBAL_CFG: 0x%08x\n", + tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG)); + dev_dbg(tqspi->dev, "CMB_CMD: 0x%08x | CMB_CMD_CFG: 0x%08x\n", + tegra_qspi_readl(tqspi, QSPI_CMB_SEQ_CMD), + tegra_qspi_readl(tqspi, QSPI_CMB_SEQ_CMD_CFG)); + dev_dbg(tqspi->dev, "CMB_ADDR: 0x%08x | CMB_ADDR_CFG: 0x%08x\n", + tegra_qspi_readl(tqspi, QSPI_CMB_SEQ_ADDR), + tegra_qspi_readl(tqspi, QSPI_CMB_SEQ_ADDR_CFG)); } static void tegra_qspi_handle_error(struct tegra_qspi *tqspi) @@ -1065,6 +1075,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->tpm_wait_poll) + 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 +1208,7 @@ 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; + 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 +1467,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, + .tpm_wait_poll = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, + .tpm_wait_poll = false, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .tpm_wait_poll = true, .cs_count = 1, }; static struct tegra_qspi_soc_data tegra241_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .tpm_wait_poll = true, .cs_count = 4, };