From nobody Sat May 9 07:14:42 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2058.outbound.protection.outlook.com [40.107.92.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 861581DE8B7; Tue, 28 Jan 2025 06:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738046829; cv=fail; b=eHAPNKlAWnDhi+OSeT+pyrW+vO2Lxuvaw1x3BZHPt8ehiE1lU+Q7yjpwbzTbSe+aeqv3qQuZjsMqekl4U/o6wTeD84vsMS2i1eRMeMOmzVLyD9pRhqD4nnGD9D0M+/1IKOW0VHT5nSmnwdNGU0y9bB7FaCOE+v5QtSbi1QCF6qg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738046829; c=relaxed/simple; bh=yXHTdTa4K92+JoNLwaJAo4q9kctjo60AaQwpcgEFwjI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hnJUprZxmEuElUo+7a4dEMsY9YrzasXImVamVnCzrbJY9Ey1Rneh9IYVoqMR1Fo8tZOLKMHn6F+7C5cwhc1AEYH1oTy1wfbIZAQtF09+4jFsKO7w7JGO57uzJZMQv14Q2wmYQZ+rk70KedMtdB5Nbf/8lX3ENhulXttKGYCZfoI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oqMv6emH; arc=fail smtp.client-ip=40.107.92.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oqMv6emH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U8V1upFcRwWPbv3D6IUrhGnWx+sL5afvEOAbthxy7WkqgE9alzkMV3lY6DvJgxMzJq9r6/MdUCHFjwerkSZt6UtBuxVBPDILGq66FPdyg826czOkISa7q5NYinJYsKnRHzIzLa+gEnKHR0epL5YWohPI92nWok6XKCmUfthU7wpca572/eBY3OZ3mxn3tjQ1CstEqtvFsaK0IXmGrFLXjD8tNQ2DjBKDj7+93Eyv0qd6ZSOQjHYZShHXfk1eG42qmDaKx77KQihmDfD/SOj99mVL1xfEMo9vGLWhs60mit1VGbvf/hzp+1FS7cbZTaU6xcSjHTHNOqzyjNpLoRJJiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=b/u9lP0CA3PMTZR+28aiBZyr8tVQjJD0Y9Jj0cO3+ZM=; b=g1vZrRrfLCdkdIc2gkQICx2zDqKCBpxAp+69n1T9fEQosxkPFQz/S79pf5mikbvBpRLzku6UG0MATeRt/3f8d15//WpDN9Ouo20KTDtiQXv2U0YsdARlAS8vrZGlGmL0HBxvXWu+LspjVismX3BIdwzo/0wwVlrsoop7/ZuZdvUMLj879cxaZOFOM6YaUJynduR9TA2NpUA41PUGvPGmtsPH0aoRCrPjHytWcToiKeRJagXn+CNqmcbMxAzTwc1xa8vHOkbRs3iiQRQUKnGZ0/kctSKl8HFhlv+VY0/MVgoC/x+Akxf6PdJZmKEoPC/IWyeVNiXdeztn30p0JcjDuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=linuxfoundation.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 (0) 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=b/u9lP0CA3PMTZR+28aiBZyr8tVQjJD0Y9Jj0cO3+ZM=; b=oqMv6emHBr9Qe1QMSE7roLCZCXbWWPDbpamNG9C1rzMV757EO7PuzYFljwcNuBpW9guOlSQBrD2qdPqS4++HPd7ZrjeBOKNSsBjwbFqkw9nQ0RYhd6LBhzjCD9GacjbuCfeGVj16vwl6J2zRKQ+AfizUjvBNGsch9MFEPx0wdp9iaFAZ27RVZt3K0QitgLksHBG0Gj6UciEC/WuSTWRB1DK+cBzlykFfy+N8QqHpYe3KC3A/AJ6lzX9cJ16iWatLo5SYdVp06lejnaIxvsteksek+YTQKtiJSkOREL/4IWeA+RCnmTyWgU+GtC4LPrVIdaitKSr1nLcCrJl402BF+Q== Received: from SJ0PR03CA0038.namprd03.prod.outlook.com (2603:10b6:a03:33e::13) by CH3PR12MB8994.namprd12.prod.outlook.com (2603:10b6:610:171::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.23; Tue, 28 Jan 2025 06:47:01 +0000 Received: from SJ1PEPF000023CF.namprd02.prod.outlook.com (2603:10b6:a03:33e:cafe::6e) by SJ0PR03CA0038.outlook.office365.com (2603:10b6:a03:33e::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8377.23 via Frontend Transport; Tue, 28 Jan 2025 06:47:01 +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 SJ1PEPF000023CF.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.14 via Frontend Transport; Tue, 28 Jan 2025 06:47:01 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) 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.1544.4; Mon, 27 Jan 2025 22:46:54 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Mon, 27 Jan 2025 22:46:54 -0800 Received: from NV-2XGVVG3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.14 via Frontend Transport; Mon, 27 Jan 2025 22:46:49 -0800 From: Kartik Rajput To: , , , , , , , , , , , , , , , , Subject: [PATCH 1/2] dt-bindings: serial: Add bindings for nvidia,tegra264-utc Date: Tue, 28 Jan 2025 12:16:32 +0530 Message-ID: <20250128064633.12381-2-kkartik@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250128064633.12381-1-kkartik@nvidia.com> References: <20250128064633.12381-1-kkartik@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CF:EE_|CH3PR12MB8994:EE_ X-MS-Office365-Filtering-Correlation-Id: ad19736a-58e1-4919-c9c8-08dd3f6791d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024|13003099007|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IrICY+MEMmD5X2+qZpuXgc2e+ffKuPbkoAeEAtTQGHVxidoP+bbQmh+M3dY6?= =?us-ascii?Q?SJsTbc7Ux8HWYB0mgEadueD0dAeEB/s2AHWuea71MmdIYCejThrB8EWm6RAR?= =?us-ascii?Q?Efsf2hSX9YJ2JqufHDv2UIz1Eo0aIhc3gJ3uA7VXI/0UNX42cztDUgE+39gq?= =?us-ascii?Q?NaNV8h8Fz/euVv7bqIViN1txgeLAMt2XHR57bnNkrJf/oOWmlDpsZ3DhsYpZ?= =?us-ascii?Q?X+F/2LSD88mG0Mzw2+R2coHEWNFODtE34iPAbozpeLgzL1ez1OMBFhyjRGO0?= =?us-ascii?Q?Wmqi/r1rdPSzAjfsOH3uUQKIVBPV+ljWbxN7EjPKdYfTsddS276W/Yw+tEPP?= =?us-ascii?Q?cq2GN6ma9juiAYc6Jc8CuTxSvXzeJU1i1IWQAuw7GbW2kPxdSiKoh/Spg54n?= =?us-ascii?Q?/tbPeTHk9ITW7AYTZIlQL/0y4oqVzc//yf0fex+El0+K9ZxwVx1k6xC9ZA1D?= =?us-ascii?Q?Z/dq7K+EVQdbUYYmYZM9X5TY4aeCF43vNTz+FCmTMyZylG24DiGbhAggeP1G?= =?us-ascii?Q?OMhXqkWrHZx+BU7K3igIRurdbcYvetTJkJNl3hpfBBis6RKu+Xn6y9wKBjYN?= =?us-ascii?Q?i/3nIZ2IMADwxG5XNCGETB/wiFflEdniWS134wTUDzD1FWoiSfIWNX1vJHE1?= =?us-ascii?Q?qa0lCLjUDfOKZuJKjLZsYduz+W8CjhutpuL1W37pOm4h+KNlQS9ZW4OSFaX2?= =?us-ascii?Q?D0TmWXMqFEdS00JwzMpLDrAxxH+CWSEL9Jf91HzRHPgL4ippiSDHAzcYyG3D?= =?us-ascii?Q?i6OGiy1+YjhTnQQjh+ftbzjyP3MbLeUrgMb3VWR/m+rffygBVv39d/o24InV?= =?us-ascii?Q?pv8NVRQO5vgfw5u3DPrTsueYzHUt3z2961gfrJZghrijYqPSWz4XwlEut3PA?= =?us-ascii?Q?pLl9r9g32QBurwBmWLfEWEHX4a85PWfHwqasQbyzoDZ9hoabZs8o9N8WIk5c?= =?us-ascii?Q?lCqRuVvE9dAe7gHImQirKSytQl6eKLvPMxZ0C0GrdpHFsomRKpamtrnvalYH?= =?us-ascii?Q?a1rS7rZmQetJTlE5M1kfIRhCCmQnrYyF5v534q5dSce8cmJCZIHiTMuCMRHg?= =?us-ascii?Q?cKIWLQ/Q8hSA6HdqUX0cpywUPo5rPcSVMG+WYkl3cqFnvtSs/3GR+XL7ohqm?= =?us-ascii?Q?Kl4dVQry8ucVWbfOVJSK66BWpVkLGmd0Coxf6Jcd3JSb3h1rbRSmAqr0gE5n?= =?us-ascii?Q?P7z+QWxsD1pmedz7XQiryovfpdu4StffK4ZhWPh11BHoyjZsZb3fslxwNls1?= =?us-ascii?Q?BqzxScnCKui+4pGBiQl1SSIErSvDXfuoxsNzvON8a0yjNH1/nPfGISk0BnAb?= =?us-ascii?Q?u+h3pXbluygNmKkMf+mDvznecVUiEOaVoL2J5Jdj+YyFdGsbdHwGoPzJehoe?= =?us-ascii?Q?CKGRzxEzM1vmCtcFITpcAMXZRlo3QssNJJ5vMg0BxRTLy8louxdRDFjcPzi+?= =?us-ascii?Q?291XszQTsnLdbPFYis7ahP+FkFlbVAM2TAuGrMYr91xE2XTOBAO8l4m5AORG?= =?us-ascii?Q?XyICNHuZzjqhjykMtzoMjAH8BJNTANlNor1r?= 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:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024)(13003099007)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2025 06:47:01.6988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad19736a-58e1-4919-c9c8-08dd3f6791d4 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: SJ1PEPF000023CF.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8994 Content-Type: text/plain; charset="utf-8" The Tegra UTC (UART Trace Controller) is a HW based serial port that allows multiplexing multiple data streams of up to 16 UTC clients into a single hardware serial port. Add bindings for the Tegra UTC client device. Signed-off-by: Kartik Rajput --- .../bindings/serial/nvidia,tegra264-utc.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra26= 4-utc.yaml diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra264-utc.y= aml b/Documentation/devicetree/bindings/serial/nvidia,tegra264-utc.yaml new file mode 100644 index 000000000000..63ba3655451f --- /dev/null +++ b/Documentation/devicetree/bindings/serial/nvidia,tegra264-utc.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/serial/nvidia,tegra264-utc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra UART Trace Controller (UTC) client + +maintainers: + - Kartik Rajput + - Thierry Reding + - Jonathan Hunter + +description: + The Tegra UTC (UART Trace Controller) is a hardware controller that + allows multiple systems within the Tegra SoC to share a hardware UART + interface. It supports up to 16 clients, with each client having its own + interrupt and a FIFO buffer for both RX (receive) and TX (transmit), each + capable of holding 128 characters. + + The Tegra UTC uses 8-N-1 configuration and operates on a pre-configured + baudrate, which is configured by the bootloader. + +properties: + $nodename: + pattern: "^serial(@.*)?$" + + compatible: + const: nvidia,tegra264-utc + + reg: + items: + - description: Register region for TX client. + - description: Register region for RX client. + minItems: 2 + + reg-names: + items: + - const: tx + - const: rx + minItems: 2 + + interrupts: + maxItems: 1 + + current-speed: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This property specifies the baudrate at which the Tegra UTC is + operating. + + nvidia,utc-fifo-threshold: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + This property specifies the UTC TX and RX client FIFO threshold in + terms of occupancy. + + This property should have the same value as the burst size (number + of characters read by the Tegra UTC hardware at a time from each + client) which is configured by the bootloader. + +required: + - compatible + - reg + - reg-names + - interrupts + - current-speed + - nvidia,utc-fifo-threshold + +additionalProperties: false + +examples: + - | + #include + + tegra_utc: serial@c4e0000 { + compatible =3D "nvidia,tegra264-utc"; + reg =3D <0xc4e0000 0x8000>, <0xc4e8000 0x8000>; + reg-names =3D "tx", "rx"; + interrupts =3D ; + current-speed =3D <115200>; + nvidia,utc-fifo-threshold =3D <4>; + }; --=20 2.43.0 From nobody Sat May 9 07:14:42 2026 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFB131DED45; Tue, 28 Jan 2025 06:47:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738046831; cv=fail; b=oZcCPxy/4+gIMwk+uh9lCqswqpDtdCpH1a6vR7vDT1gFaINGlsavAMkOKq8mZkA4WDaHjRAEHiAyzQYRAfVpxk6VWmDAXTXGx3EhYxNX/p7PcT5a8YCtFcZraSe6VZCdR0m+rlexPw6VHFIFw+/ZvXNDIvoXohtu5wYoq05dCL4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738046831; c=relaxed/simple; bh=FDvWkK0pAX3M/K0fit89rVQ+m4JMQEjw6QKAaS3ndyE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f/SwCBztYJabLpZkah1LHnIokPzZ7aN6eawIzZy4B9tJusFdczEuw7LRNk39odOfdyD04uxhBPCA2S72a8Z4LW5EmRFcDKkhMeOP4UCMQ+gSu2IWsfPYX54QFS/Z7SsRTdVa8jbVG77rxFKrILvWhtTgl5WhtCJjfyyFQ3Eyc3M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=tQTTDC1P; arc=fail smtp.client-ip=40.107.244.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="tQTTDC1P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qgG0vfx/Zyx5fszzmr+F310K6ee2yVZbznXaJA2scl1aQXXx74C6yxXV7taeFW/Iyj2UV0MpBlcZaOf8byJD+L3JdKfYJY9U1v9IKJv5Uzlv9bEHcewTHoFRqTP4t8FgJyUK2fCn7sDxc1s0oOJKMqDuGzy0lNZmVPZ/qblTZCB+13rFTHO6kCkrEtBmOlnpkv2q8e9f3uSefS1me/ic+zZmntyKdM+RaqTE7VgkpfDmS4FfwVCC1p5ixxtK+r1oOaFxLMnSsRxv4zzZJPt9NgU2CNQ2G12F/x5dqvb8K8nJzwsmKRn5QzmcLFKIFA0ZQwvNbPBCd4ZsJblqU7NO4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wGxsOO59yMATV4oHZpZiBQH3SL8rPHhWV41cx3jS0JQ=; b=ZJ8QXBZrR99YykOH4+wzFnOJC+FXlUFsdXc8BP4+Be30pWyOUtwltfydGOralY3f2uoeWPCJTJ5jfoH1VKTF7NeOJ9snOR8sNPtjsCW3rbOPu8lKXi/3JdAh2KR+E0dxb9WBxDXKt2RbradKzn3C9ktiaEb7VdLB7BouDucNaMQDoo3D1TLsaT1LgkK0rltLXb7KglbhGKVPB0afSoRDSLIK5vLjWbbuNsrvUjpTpyyepdB58NEDNdCJQn3bamBUkGS5cGyG6dBR7Ci2P5OJCPlQwKVgyis5L+b1TDPLwzjnIB84VKc6wS+blKF9YI9LzXGA21NMD//FI4uW41JMdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=linuxfoundation.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 (0) 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=wGxsOO59yMATV4oHZpZiBQH3SL8rPHhWV41cx3jS0JQ=; b=tQTTDC1P+bakTdiq8qbwh6Rb1CQVOdHVdxgMgFAbT1Lwwkjan+hMYwF8piJF8/qhcmOG4QRy3IM9Pu9OdG8kxDV0WjxgUHR0hOHMEtgmpztnFUoe+HJj5SD3deu6fO82QFgbU8Z1S+Xw5nXrqMAUh3AKM2s9Bd7nzzxy8y39GkCV8mRq6hqMZFCv/5ntVuM5GqqtPADo+ISmIlR5f8bsq8Jcp7OrFopCil4z59riKDmJqwraVeIr8MsxaIMDJhwrnirF/Y+cPXf+2C3DnHstO6xaeDVP20P94Kcxn3i2b5UvrFgc0UDjXSkvbjhLGas59kawyJ7vnmzSlg5BhPZa8w== Received: from BYAPR07CA0106.namprd07.prod.outlook.com (2603:10b6:a03:12b::47) by MN2PR12MB4240.namprd12.prod.outlook.com (2603:10b6:208:1d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.22; Tue, 28 Jan 2025 06:47:02 +0000 Received: from SJ5PEPF00000209.namprd05.prod.outlook.com (2603:10b6:a03:12b:cafe::d6) by BYAPR07CA0106.outlook.office365.com (2603:10b6:a03:12b::47) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.20 via Frontend Transport; Tue, 28 Jan 2025 06:47:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SJ5PEPF00000209.mail.protection.outlook.com (10.167.244.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.14 via Frontend Transport; Tue, 28 Jan 2025 06:47:01 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 27 Jan 2025 22:47:00 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Mon, 27 Jan 2025 22:46:59 -0800 Received: from NV-2XGVVG3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.14 via Frontend Transport; Mon, 27 Jan 2025 22:46:54 -0800 From: Kartik Rajput To: , , , , , , , , , , , , , , , , Subject: [PATCH 2/2] serial: tegra-utc: Add driver for Tegra UART Trace Controller (UTC) Date: Tue, 28 Jan 2025 12:16:33 +0530 Message-ID: <20250128064633.12381-3-kkartik@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250128064633.12381-1-kkartik@nvidia.com> References: <20250128064633.12381-1-kkartik@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF00000209:EE_|MN2PR12MB4240:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a387a84-db57-44fb-dee5-08dd3f6791e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ws6pUNK03OQS0jTvUZcjdGMKIV/mBYoBsD5LOlBsPE85sncvxRvinEOdlgO9?= =?us-ascii?Q?JV4x6rwcsPhTfG9p5KmnMK5Jje1QQgOmcfz07sxYGSw4jO8v7BgIkVcn3Zww?= =?us-ascii?Q?A73Zeu0NYoiOGWPhndzdItsCQigU9dqMhFIWWGmYuakDOsRB6BkRJuIS8RI0?= =?us-ascii?Q?bLHAi5tyqVwBOR093sDJlUdWXK1kuu7XaELQGneO9Q9gfog0R94LORQohssS?= =?us-ascii?Q?TmO2M+GP82ReLVSO5x+YL2FrsAJGHV/3o8iHQjADAmV9N7Yu5pFBRhV5UCE3?= =?us-ascii?Q?eC8RrRRvu4uY6PjPtim6M+3NoRvhDkUXQf7U87cqm0wlriyqY+z4YPlyKQ39?= =?us-ascii?Q?gziSKKc5CKulKlLaXJdLIe33zpe3ezP/euSqdhWHxGh7JVceQKPug4pA6r1V?= =?us-ascii?Q?2xyJ/YAaDzLDwKI0mpd3k9P2PTVwJWJrCb6VRQqxMbx8sKSIGDlSw6gC7Gov?= =?us-ascii?Q?pnxTcQJiRNzR9TuFRDer5qObws0U2tguuCaU49YqvsBGgkJAApwWaVAwR5BZ?= =?us-ascii?Q?xXKojfi8vLfhN57dXB8f6J3Z93rZtJ/+VlHTMaGT32+59O1qaNDsuNyiybtc?= =?us-ascii?Q?PoKa7I0lbb7ytZOwHPT9wzAVvRNe4hDViz5dbh2jhq9hAeqeKJOWQJZCpYYM?= =?us-ascii?Q?vMCUD6urbdM8OWIqdGiQAB1n4nEcyuv4wzzfl+uJJrCfMTKlDiCrYMA5VHin?= =?us-ascii?Q?0uGqzIk4B+yjcbBjD3vt9P0z6EKn+5YOs0U3C7XiyXyPWfSJHwBVtKzNK7AQ?= =?us-ascii?Q?YAYN/8Pm6DW56XC5cbvrifG0zLWHQvGC6rK+1V8VB+7saQb1DeuB5NM3SYBK?= =?us-ascii?Q?O6NLKyowpM8vjMTqEpNIgDUb2iNXswVfkdft2EXm4ZSy2z3d0b7n+UDo0Ox/?= =?us-ascii?Q?+2IVIihoZAoVWkLUN0X0KyLBhEmwIy5kgu2kbiPUK9ranl//PEw52Nk3L0tE?= =?us-ascii?Q?QHVo960m1LQ75TzQ5HoNN4ByxkJQ/mAB7Wc1Hhx/YbuBFNk/HFt27CPef0gQ?= =?us-ascii?Q?mfL3plEZ4dX76yPK53zxnlryfmHr/94oGndPXLTPj028kDzNgI+1wuBZoO6G?= =?us-ascii?Q?ZVrlGa1dHDHSdMp1qCk7nZ5U6d1u4AN24M+MXHQXzDXyUgcC8ehhsiZsJbIQ?= =?us-ascii?Q?7vL0F0svgTQUNrgyx86Xo+fTBwtmRW7Tb2yjTUtCE1Hk/jWRxS1by/dv7pMZ?= =?us-ascii?Q?ZoNca5vgY1Z3ek7NfpQxUxZ31r68m04PECplsSEuGjqYpJuiLSuY+7RiWUyW?= =?us-ascii?Q?pP34elrsB0TJLR57KwL285ERqtneIqaRQM6bSQre4RIxQyOyuGmAe8lTuO0K?= =?us-ascii?Q?fOQNtdCP5SwhFcEamvEQJcXXlCOBrbM7Bis0N1ztUwNCOBATM/o7Rn4arNBd?= =?us-ascii?Q?KtvSKXVCZeCBorYK3xrAnmMpB/RYyZJVL0ujyTxnDt30LSRhyqoccD7LgiFO?= =?us-ascii?Q?Tp5XK1EbYJ2UA7Nf/SVpN6H7c8lKucbKdZG3tqv9h6lgzVMswr3Bx2einhh7?= =?us-ascii?Q?TfoMMRcqqjhPMsiwFDA8T/3s0z7zlb736gSq?= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2025 06:47:01.7977 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a387a84-db57-44fb-dee5-08dd3f6791e3 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.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF00000209.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4240 Content-Type: text/plain; charset="utf-8" The Tegra264 SoC supports the UART Trace Controller (UTC), which allows multiple firmware clients (up to 16) to share a single physical UART. Each client is provided with its own interrupt and has access to a 128-character wide FIFO for both transmit (TX) and receive (RX) operations. Add tegra-utc driver to support Tegra UART Trace Controller (UTC) client. Signed-off-by: Kartik Rajput --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/tegra-utc.c | 641 +++++++++++++++++++++++++++++++++ 3 files changed, 665 insertions(+) create mode 100644 drivers/tty/serial/tegra-utc.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 976dae3bb1bb..edc56a3c0ace 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -306,6 +306,29 @@ config SERIAL_TEGRA_TCU_CONSOLE =20 If unsure, say Y. =20 +config SERIAL_TEGRA_UTC + tristate "NVIDIA Tegra UART Trace Controller" + depends on ARCH_TEGRA || COMPILE_TEST + select SERIAL_CORE + help + Support for Tegra UTC (UART Trace controller) client serial port. + + UTC is a HW based serial port that allows multiplexing multiple data + streams of up to 16 UTC clients into a single hardware serial port. + +config SERIAL_TEGRA_UTC_CONSOLE + bool "Support for console on a Tegra UTC serial port" + depends on SERIAL_TEGRA_UTC + select SERIAL_CORE_CONSOLE + default SERIAL_TEGRA_UTC + help + If you say Y here, it will be possible to use a Tegra UTC client as + the system console (the system console is the device which receives + all kernel messages and warnings and which allows logins in single + user mode). + + If unsure, say Y. + config SERIAL_MAX3100 tristate "MAX3100/3110/3111/3222 support" depends on SPI diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 6ff74f0a9530..7190914ba707 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -86,6 +86,7 @@ obj-$(CONFIG_SERIAL_STM32) +=3D stm32-usart.o obj-$(CONFIG_SERIAL_SUNPLUS) +=3D sunplus-uart.o obj-$(CONFIG_SERIAL_TEGRA) +=3D serial-tegra.o obj-$(CONFIG_SERIAL_TEGRA_TCU) +=3D tegra-tcu.o +obj-$(CONFIG_SERIAL_TEGRA_UTC) +=3D tegra-utc.o obj-$(CONFIG_SERIAL_TIMBERDALE) +=3D timbuart.o obj-$(CONFIG_SERIAL_TXX9) +=3D serial_txx9.o obj-$(CONFIG_SERIAL_UARTLITE) +=3D uartlite.o diff --git a/drivers/tty/serial/tegra-utc.c b/drivers/tty/serial/tegra-utc.c new file mode 100644 index 000000000000..3d44e83f9302 --- /dev/null +++ b/drivers/tty/serial/tegra-utc.c @@ -0,0 +1,641 @@ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIA= TES. All rights reserved. +/* + * NVIDIA Tegra UTC (UART Trace Controller) driver. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TEGRA_UTC_ENABLE 0x0 +#define TEGRA_UTC_ENABLE_CLIENT_ENABLE BIT(0) + +#define TEGRA_UTC_FIFO_THRESHOLD 0x8 + +#define TEGRA_UTC_COMMAND 0xc +#define TEGRA_UTC_COMMAND_FLUSH BIT(1) +#define TEGRA_UTC_COMMAND_RESET BIT(0) + +#define TEGRA_UTC_DATA 0x20 + +#define TEGRA_UTC_FIFO_STATUS 0x100 +#define TEGRA_UTC_FIFO_TIMEOUT BIT(4) +#define TEGRA_UTC_FIFO_OVERFLOW BIT(3) +#define TEGRA_UTC_FIFO_REQ BIT(2) +#define TEGRA_UTC_FIFO_FULL BIT(1) +#define TEGRA_UTC_FIFO_EMPTY BIT(0) + +#define TEGRA_UTC_FIFO_OCCUPANCY 0x104 + +#define TEGRA_UTC_INTR_STATUS 0x108 +#define TEGRA_UTC_INTR_SET 0x10c +#define TEGRA_UTC_INTR_MASK 0x110 +#define TEGRA_UTC_INTR_CLEAR 0x114 +#define TEGRA_UTC_INTR_TIMEOUT BIT(4) +#define TEGRA_UTC_INTR_OVERFLOW BIT(3) +#define TEGRA_UTC_INTR_REQ BIT(2) +#define TEGRA_UTC_INTR_FULL BIT(1) +#define TEGRA_UTC_INTR_EMPTY BIT(0) + +#define UART_NR 16 + +struct tegra_utc_soc { + unsigned int fifosize; +}; + +struct tegra_utc_port { + const struct tegra_utc_soc *soc; +#if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) + struct console console; +#endif + struct uart_port port; + + void __iomem *rx_base; + void __iomem *tx_base; + + u32 tx_irqmask; + u32 rx_irqmask; + + u32 fifo_threshold; + u32 baudrate; + int irq; +}; + +static u32 tegra_utc_rx_readl(struct tegra_utc_port *tup, unsigned int off= set) +{ + void __iomem *addr =3D tup->rx_base + offset; + + return readl_relaxed(addr); +} + +static void tegra_utc_rx_writel(struct tegra_utc_port *tup, u32 val, unsig= ned int offset) +{ + void __iomem *addr =3D tup->rx_base + offset; + + writel_relaxed(val, addr); +} + +static u32 tegra_utc_tx_readl(struct tegra_utc_port *tup, unsigned int off= set) +{ + void __iomem *addr =3D tup->tx_base + offset; + + return readl_relaxed(addr); +} + +static void tegra_utc_tx_writel(struct tegra_utc_port *tup, u32 val, unsig= ned int offset) +{ + void __iomem *addr =3D tup->tx_base + offset; + + writel_relaxed(val, addr); +} + +static void tegra_utc_enable_tx_irq(struct tegra_utc_port *tup) +{ + tup->tx_irqmask =3D TEGRA_UTC_INTR_REQ; + + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_MASK); + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_SET); +} + +static void tegra_utc_disable_tx_irq(struct tegra_utc_port *tup) +{ + tup->tx_irqmask =3D 0x0; + + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_MASK); + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_SET); +} + +static void tegra_utc_stop_tx(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + tegra_utc_disable_tx_irq(tup); +} + +static void tegra_utc_init_tx(struct tegra_utc_port *tup) +{ + /* Disable TX. */ + tegra_utc_tx_writel(tup, 0x0, TEGRA_UTC_ENABLE); + + /* Update the FIFO Threshold. */ + tegra_utc_tx_writel(tup, tup->fifo_threshold, TEGRA_UTC_FIFO_THRESHOLD); + + /* Clear and mask all the interrupts. */ + tegra_utc_tx_writel(tup, TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_FULL | TEGRA= _UTC_INTR_EMPTY, + TEGRA_UTC_INTR_CLEAR); + tegra_utc_disable_tx_irq(tup); + + /* Enable TX. */ + tegra_utc_tx_writel(tup, TEGRA_UTC_ENABLE_CLIENT_ENABLE, TEGRA_UTC_ENABLE= ); +} + +static void tegra_utc_init_rx(struct tegra_utc_port *tup) +{ + tup->rx_irqmask =3D TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_TIMEOUT; + + tegra_utc_rx_writel(tup, TEGRA_UTC_COMMAND_RESET, TEGRA_UTC_COMMAND); + tegra_utc_rx_writel(tup, tup->fifo_threshold, TEGRA_UTC_FIFO_THRESHOLD); + + /* Clear all the pending interrupts. */ + tegra_utc_rx_writel(tup, TEGRA_UTC_INTR_TIMEOUT | TEGRA_UTC_INTR_OVERFLOW= | + TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_FULL | + TEGRA_UTC_INTR_EMPTY, TEGRA_UTC_INTR_CLEAR); + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_MASK); + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_SET); + + /* Enable RX. */ + tegra_utc_rx_writel(tup, TEGRA_UTC_ENABLE_CLIENT_ENABLE, TEGRA_UTC_ENABLE= ); +} + +static bool tegra_utc_tx_char(struct tegra_utc_port *tup, u8 c) +{ + if (tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_STATUS) & TEGRA_UTC_FIFO_FULL) + return false; + + tegra_utc_tx_writel(tup, c, TEGRA_UTC_DATA); + + return true; +} + +static bool tegra_utc_tx_chars(struct tegra_utc_port *tup) +{ + struct tty_port *tport =3D &tup->port.state->port; + u8 c; + + if (tup->port.x_char) { + if (!tegra_utc_tx_char(tup, tup->port.x_char)) + return true; + + tup->port.x_char =3D 0; + } + + if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(&tup->port)) { + tegra_utc_stop_tx(&tup->port); + return false; + } + + while (kfifo_peek(&tport->xmit_fifo, &c)) { + if (!tegra_utc_tx_char(tup, c)) + break; + + kfifo_skip(&tport->xmit_fifo); + } + + if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS) + uart_write_wakeup(&tup->port); + + if (kfifo_is_empty(&tport->xmit_fifo)) { + tegra_utc_stop_tx(&tup->port); + return false; + } + + return true; +} + +static void tegra_utc_rx_chars(struct tegra_utc_port *tup) +{ + struct tty_port *port =3D &tup->port.state->port; + unsigned int max_chars =3D 256; + unsigned int flag; + u32 status; + int sysrq; + u32 ch; + + while (--max_chars) { + status =3D tegra_utc_rx_readl(tup, TEGRA_UTC_FIFO_STATUS); + if (status & TEGRA_UTC_FIFO_EMPTY) + break; + + ch =3D tegra_utc_rx_readl(tup, TEGRA_UTC_DATA); + flag =3D TTY_NORMAL; + tup->port.icount.rx++; + + if (status & TEGRA_UTC_FIFO_OVERFLOW) + tup->port.icount.overrun++; + + uart_port_unlock(&tup->port); + sysrq =3D uart_handle_sysrq_char(&tup->port, ch & 0xff); + uart_port_lock(&tup->port); + + if (!sysrq) + tty_insert_flip_char(port, ch, flag); + } + + tty_flip_buffer_push(port); +} + +static irqreturn_t tegra_utc_isr(int irq, void *dev_id) +{ + struct tegra_utc_port *tup =3D dev_id; + unsigned long flags; + u32 status; + + uart_port_lock_irqsave(&tup->port, &flags); + + /* Process RX_REQ and RX_TIMEOUT interrupts. */ + do { + status =3D tegra_utc_rx_readl(tup, TEGRA_UTC_INTR_STATUS) & tup->rx_irqm= ask; + if (status) { + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_CLEAR); + tegra_utc_rx_chars(tup); + } + } while (status); + + /* Process TX_REQ interrupt. */ + do { + status =3D tegra_utc_tx_readl(tup, TEGRA_UTC_INTR_STATUS) & tup->tx_irqm= ask; + if (status) { + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_CLEAR); + tegra_utc_tx_chars(tup); + } + } while (status); + + uart_port_unlock_irqrestore(&tup->port, flags); + + return IRQ_HANDLED; +} + +static unsigned int tegra_utc_tx_empty(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + return tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_OCCUPANCY) ? 0 : TIOCSER_TE= MT; +} + +static void tegra_utc_set_mctrl(struct uart_port *port, unsigned int mctrl) +{ +} + +static unsigned int tegra_utc_get_mctrl(struct uart_port *port) +{ + return 0; +} + +static void tegra_utc_start_tx(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + if (tegra_utc_tx_chars(tup)) + tegra_utc_enable_tx_irq(tup); +} + +static void tegra_utc_stop_rx(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + tup->rx_irqmask =3D 0x0; + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_MASK); + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_SET); +} + +static void tegra_utc_hw_init(struct tegra_utc_port *tup) +{ + tegra_utc_init_tx(tup); + tegra_utc_init_rx(tup); +} + +static int tegra_utc_startup(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + int ret; + + tegra_utc_hw_init(tup); + + ret =3D request_irq(tup->irq, tegra_utc_isr, 0, dev_name(port->dev), tup); + if (ret < 0) { + dev_err(port->dev, "failed to register interrupt handler\n"); + return ret; + } + + return 0; +} + +static void tegra_utc_shutdown(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + tegra_utc_rx_writel(tup, 0x0, TEGRA_UTC_ENABLE); + free_irq(tup->irq, tup); +} + +static void tegra_utc_set_termios(struct uart_port *port, struct ktermios = *termios, + const struct ktermios *old) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + unsigned long flags; + + tty_termios_encode_baud_rate(termios, tup->baudrate, tup->baudrate); + termios->c_cflag &=3D ~(CSIZE | CSTOPB | PARENB | PARODD); + termios->c_cflag &=3D ~(CMSPAR | CRTSCTS); + termios->c_cflag |=3D CS8 | CLOCAL; + + uart_port_lock_irqsave(port, &flags); + uart_update_timeout(port, CS8, tup->baudrate); + uart_port_unlock_irqrestore(port, flags); +} + +#ifdef CONFIG_CONSOLE_POLL + +static int tegra_utc_poll_init(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + tegra_utc_hw_init(tup); + return 0; +} + +static int tegra_utc_get_poll_char(struct uart_port *port) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + while (tegra_utc_rx_readl(tup, TEGRA_UTC_FIFO_STATUS) & TEGRA_UTC_FIFO_EM= PTY) + cpu_relax(); + + return tegra_utc_rx_readl(tup, TEGRA_UTC_DATA); +} + +static void tegra_utc_put_poll_char(struct uart_port *port, unsigned char = ch) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + while (tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_STATUS) & TEGRA_UTC_FIFO_FU= LL) + cpu_relax(); + + tegra_utc_tx_writel(tup, ch, TEGRA_UTC_DATA); +} + +#endif + +static const struct uart_ops tegra_utc_uart_ops =3D { + .tx_empty =3D tegra_utc_tx_empty, + .set_mctrl =3D tegra_utc_set_mctrl, + .get_mctrl =3D tegra_utc_get_mctrl, + .stop_tx =3D tegra_utc_stop_tx, + .start_tx =3D tegra_utc_start_tx, + .stop_rx =3D tegra_utc_stop_rx, + .startup =3D tegra_utc_startup, + .shutdown =3D tegra_utc_shutdown, + .set_termios =3D tegra_utc_set_termios, +#ifdef CONFIG_CONSOLE_POLL + .poll_init =3D tegra_utc_poll_init, + .poll_get_char =3D tegra_utc_get_poll_char, + .poll_put_char =3D tegra_utc_put_poll_char, +#endif +}; + +#if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) +#define TEGRA_UTC_DEFAULT_FIFO_THRESHOLD 0x4 +#define TEGRA_UTC_EARLYCON_MAX_BURST_SIZE 128 + +static void tegra_utc_putc(struct uart_port *port, unsigned char c) +{ + writel(c, port->membase + TEGRA_UTC_DATA); +} + +static void tegra_utc_early_write(struct console *con, const char *s, unsi= gned int n) +{ + struct earlycon_device *dev =3D con->data; + + while (n) { + u32 burst_size =3D TEGRA_UTC_EARLYCON_MAX_BURST_SIZE; + + burst_size -=3D readl(dev->port.membase + TEGRA_UTC_FIFO_OCCUPANCY); + if (n < burst_size) + burst_size =3D n; + + uart_console_write(&dev->port, s, burst_size, tegra_utc_putc); + + n -=3D burst_size; + s +=3D burst_size; + } +} + +static int __init tegra_utc_early_console_setup(struct earlycon_device *de= vice, const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + /* Configure TX */ + writel(TEGRA_UTC_COMMAND_FLUSH | TEGRA_UTC_COMMAND_RESET, + device->port.membase + TEGRA_UTC_COMMAND); + writel(TEGRA_UTC_DEFAULT_FIFO_THRESHOLD, device->port.membase + TEGRA_UTC= _FIFO_THRESHOLD); + + /* Clear and mask all the interrupts. */ + writel(TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_FULL | TEGRA_UTC_INTR_EMPTY, + device->port.membase + TEGRA_UTC_INTR_CLEAR); + + writel(0x0, device->port.membase + TEGRA_UTC_INTR_MASK); + writel(0x0, device->port.membase + TEGRA_UTC_INTR_SET); + + /* Enable TX. */ + writel(TEGRA_UTC_ENABLE_CLIENT_ENABLE, device->port.membase + TEGRA_UTC_E= NABLE); + + device->con->write =3D tegra_utc_early_write; + + return 0; +} +OF_EARLYCON_DECLARE(tegra_utc, "nvidia,tegra264-utc", tegra_utc_early_cons= ole_setup); + +static void tegra_utc_console_putchar(struct uart_port *port, unsigned cha= r ch) +{ + struct tegra_utc_port *tup =3D container_of(port, struct tegra_utc_port, = port); + + tegra_utc_tx_writel(tup, ch, TEGRA_UTC_DATA); +} + +static void tegra_utc_console_write(struct console *cons, const char *s, u= nsigned int count) +{ + struct tegra_utc_port *tup =3D container_of(cons, struct tegra_utc_port, = console); + unsigned long flags; + int locked =3D 1; + + if (tup->port.sysrq || oops_in_progress) + locked =3D uart_port_trylock_irqsave(&tup->port, &flags); + else + uart_port_lock_irqsave(&tup->port, &flags); + + while (count) { + u32 burst_size =3D tup->soc->fifosize; + + burst_size -=3D tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_OCCUPANCY); + if (count < burst_size) + burst_size =3D count; + + uart_console_write(&tup->port, s, burst_size, tegra_utc_console_putchar); + + count -=3D burst_size; + s +=3D burst_size; + }; + + if (locked) + uart_port_unlock_irqrestore(&tup->port, flags); +} + +static int tegra_utc_console_setup(struct console *cons, char *options) +{ + struct tegra_utc_port *tup =3D container_of(cons, struct tegra_utc_port, = console); + + tegra_utc_init_tx(tup); + + return 0; +} +#endif + +static struct uart_driver tegra_utc_driver =3D { + .driver_name =3D "tegra-utc", + .dev_name =3D "ttyUTC", + .nr =3D UART_NR +}; + +static void tegra_utc_setup_port(struct device *dev, struct tegra_utc_port= *tup, + unsigned int index) +{ + tup->port.dev =3D dev; + tup->port.fifosize =3D tup->soc->fifosize; + tup->port.flags =3D UPF_BOOT_AUTOCONF; + tup->port.iotype =3D UPIO_MEM; + tup->port.ops =3D &tegra_utc_uart_ops; + tup->port.type =3D PORT_TEGRA_TCU; + tup->port.line =3D index; + tup->port.private_data =3D tup; + +#if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) + strscpy(tup->console.name, "ttyUTC", sizeof(tup->console.name)); + tup->console.write =3D tegra_utc_console_write; + tup->console.device =3D uart_console_device; + tup->console.setup =3D tegra_utc_console_setup; + tup->console.flags =3D CON_PRINTBUFFER | CON_CONSDEV | CON_ANYTIME; + tup->console.data =3D &tegra_utc_driver; +#endif +} + +static int tegra_utc_register_port(struct tegra_utc_port *tup) +{ + int ret; + + ret =3D uart_add_one_port(&tegra_utc_driver, &tup->port); + if (ret) + return ret; + +#if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) + register_console(&tup->console); +#endif + + return 0; +} + +static int tegra_utc_probe(struct platform_device *pdev) +{ + struct device_node *np =3D pdev->dev.of_node; + struct tegra_utc_port *tup; + int index; + int ret; + + index =3D of_alias_get_id(np, "serial"); + if (index < 0) { + dev_err(&pdev->dev, "failed to get alias id, err %d\n", index); + return index; + } + + tup =3D devm_kzalloc(&pdev->dev, sizeof(struct tegra_utc_port), GFP_KERNE= L); + if (!tup) + return -ENOMEM; + + ret =3D of_property_read_u32(np, "current-speed", &tup->baudrate); + if (ret) { + dev_err(&pdev->dev, "missing current-speed device-tree property\n"); + return ret; + } + + ret =3D of_property_read_u32(np, "nvidia,utc-fifo-threshold", &tup->fifo_= threshold); + if (ret) { + dev_err(&pdev->dev, "missing nvidia,fifo-threshold device-tree property\= n"); + return ret; + } + + tup->irq =3D platform_get_irq(pdev, 0); + if (tup->irq < 0) { + dev_err(&pdev->dev, "failed to get interrupt\n"); + return tup->irq; + } + + tup->soc =3D of_device_get_match_data(&pdev->dev); + + tup->tx_base =3D devm_platform_ioremap_resource_byname(pdev, "tx"); + if (IS_ERR(tup->tx_base)) + return PTR_ERR(tup->tx_base); + + tup->rx_base =3D devm_platform_ioremap_resource_byname(pdev, "rx"); + if (IS_ERR(tup->rx_base)) + return PTR_ERR(tup->rx_base); + + tegra_utc_setup_port(&pdev->dev, tup, index); + platform_set_drvdata(pdev, tup); + + return tegra_utc_register_port(tup); +} + +static void tegra_utc_remove(struct platform_device *pdev) +{ + struct tegra_utc_port *tup =3D platform_get_drvdata(pdev); + + uart_remove_one_port(&tegra_utc_driver, &tup->port); +} + +static const struct tegra_utc_soc tegra264_utc_soc =3D { + .fifosize =3D 128, +}; + +static const struct of_device_id tegra_utc_of_match[] =3D { + { .compatible =3D "nvidia,tegra264-utc", .data =3D &tegra264_utc_soc }, + {}, +}; +MODULE_DEVICE_TABLE(of, tegra_utc_of_match); + +static struct platform_driver tegra_utc_platform_driver =3D { + .probe =3D tegra_utc_probe, + .remove =3D tegra_utc_remove, + .driver =3D { + .name =3D "tegra-utc", + .of_match_table =3D tegra_utc_of_match, + }, +}; + +static int __init tegra_utc_init(void) +{ + int ret; + + ret =3D uart_register_driver(&tegra_utc_driver); + if (ret) + return ret; + + ret =3D platform_driver_register(&tegra_utc_platform_driver); + if (ret) { + uart_unregister_driver(&tegra_utc_driver); + return ret; + } + + return 0; +} +module_init(tegra_utc_init); + +static void __exit tegra_utc_exit(void) +{ + platform_driver_unregister(&tegra_utc_platform_driver); + uart_unregister_driver(&tegra_utc_driver); +} +module_exit(tegra_utc_exit); + +MODULE_AUTHOR("Kartik Rajput "); +MODULE_DESCRIPTION("Tegra UART Trace Controller"); +MODULE_LICENSE("GPL"); --=20 2.43.0