From patchwork Fri Apr 8 14:09:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12806745 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0089C433EF for ; Fri, 8 Apr 2022 13:28:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.301578.514763 (Exim 4.92) (envelope-from ) id 1ncofI-0007SV-EH; Fri, 08 Apr 2022 13:28:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 301578.514763; Fri, 08 Apr 2022 13:28:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ncofI-0007SM-Ax; Fri, 08 Apr 2022 13:28:40 +0000 Received: by outflank-mailman (input) for mailman id 301578; Fri, 08 Apr 2022 13:28:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ncofH-0007Q5-QF for xen-devel@lists.xenproject.org; Fri, 08 Apr 2022 13:28:39 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on060d.outbound.protection.outlook.com [2a01:111:f400:fe0d::60d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cb634302-b73f-11ec-8fbc-03012f2f19d4; Fri, 08 Apr 2022 15:28:36 +0200 (CEST) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM7PR04MB6949.eurprd04.prod.outlook.com (2603:10a6:20b:102::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 13:28:35 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6%8]) with mapi id 15.20.5144.022; Fri, 8 Apr 2022 13:28:35 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cb634302-b73f-11ec-8fbc-03012f2f19d4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IgV6tA+oAktRtC0SX5nswa3Ede+qtHd29x2XLTuzyg9SqXkrhVkQ89L9IzMCK2k7m3RzPulMQn3oLiPDQDSagYt6aTo2UMue3ettaM4QMpBfn+rLNn7rn0BK93vp77xyKCbd6H68BgiBT032AGC9vuUzXOrA/qI8kfhp5S+ezMrOyYC1+ZE2rb2WxsAtWQk2wHnhw2rRf8k6wdm0IGAfMgaISp5jxLk1vxd5TiMMtmaejy/IGm9R80VIv7MDJ0HNGAfM77WTGUutcQ6oOI10UoD7TBiRUkudRZ0pX80Y1ct7zJZ22XVsK+12qpHMfGDvcQQYHKi9G04sHFq5gQ7Uyw== 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=TWdVjcMnWozl05+E5IE0z2YpFwdCyGDLKaNm3kllK3o=; b=b0oeQrA8HWaYJsezh5fv6z6tLGxZBNsqFciYSXa6BJwtpBB0CdElBOBrvlbptQNA8PbR+1CNtaC7lVEGtuZuAdwbao4Ud6DWBZfmKhHQ5Uu8Ko4x771cTsAgMx6WNvdP4ELBA5zwPXlbYzbioT/Nl0Z3C9xQaufBRyElH0Oz4pcIik95uFRl3hzdnFomoxQwXGVa9Nr0moTo3Crg9EsD8xi/7NbUoIZNpaopuonz3eCHflXhiCcrs+dRK6mL3ST6ZPYN73eSET4Mp/qhCnmIJ4eglHtrem9rliLBNxV9jy1a0h6lZI/VdZJZz/sd673jrB0zYcz2M7bSBBSvkQybqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TWdVjcMnWozl05+E5IE0z2YpFwdCyGDLKaNm3kllK3o=; b=XEsmLXPo1OfGZ51nWzjqAEvRlsoTMjRSwB/+gTrLJodkxtVMLb7Pj/PjtYT5m+M9ZwPIKib/qYjke5WWgyA/PmKNmvqL/J7FROgUeOztCCYUVjBGfQKw6UlB3d4b6mdmpSKQGW5Ny5s8vRKq9riuW0I/yqTsQ/fVMSy4TPdE56I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Peng Fan (OSS)" To: sstabellini@kernel.org, julien@xen.org, Volodymyr_Babchuk@epam.com, bertrand.marquis@arm.com Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com, jbeulich@suse.com, wl@xen.org, xen-devel@lists.xenproject.org, van.freenix@gmail.com, michal.orzel@arm.com, Peng Fan Subject: [PATCH V4 2/2] xen/arm: Add i.MX lpuart early printk support Date: Fri, 8 Apr 2022 22:09:32 +0800 Message-Id: <20220408140932.17968-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220408140932.17968-1-peng.fan@oss.nxp.com> References: <20220408140932.17968-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::21) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 276d5a56-f2ed-4806-745e-08da1963ae6f X-MS-TrafficTypeDiagnostic: AM7PR04MB6949:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CuRccfkGa8G7dSKUcJIB8EaN0pQaI0Mf1TOie2vdOu2OGU4sUl7A5YQIxs9heLjNOlYVQmLM1YQ1GifWJiD4ZHTZM5pW8COZOIhBy9lkT9uVEk93plHmktGhYDa0J1I8icItQBWClus3BeKNNEcuAX0I0z/1sGOaHD3E0gI00COiCV7WVF1Osr6CXjd1CQVsFvynzGB4qWb26HY4lbkNFcKMNACiQjqePEa0yKjkTixXRApGtd3f2Q4GP7NDkoDAkDlhbG3lLcJOlxxgp7fbIehSAiw0Ak8/tVvYajlxr/HanXGtNCbqc13Parkxox7RnTFUMo/9H5INDQqbcfbTh8I47vLnG6fFI3uMXkMacIuDIFcXhNa1gfZ3dHoJD3WK1w7QascMO7MgZnOlA9XB2ABT1EyPgsxBge1gipzBY9r/y25BfGn3xQ5HNXr1I7iI+DE0R7SNkbwyS0uA2bO8/q8fvxXdwecbTSe3B9e0N8Se4pecTrDG2rl+YcLEGqY5ab2nxst71LjFSwn2NMecGwO2AAgKSSAdxV2PIwC6j1ZPjG+U6AwYbiIwVFnuw0BPICrVgpbC7i6C8Xk5NZ2o/M+vDHvs4ppv+Qrw7h3oxzvxXw1q+rp3X+BlmLd0KVdK602Q6Py7wGuQOv0KOtdtWcy/rmwtOe9zIqE9hPA/LhHPa8dRCZremis2v2/08Oqnr3lF0Vlpdn4U+EW2spa5F+qP1GUnJTgg/i+DgNRB4ps= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(6512007)(8676002)(52116002)(6666004)(6506007)(4326008)(508600001)(2906002)(5660300002)(86362001)(7416002)(38100700002)(2616005)(186003)(26005)(38350700002)(1076003)(66556008)(316002)(66946007)(66476007)(8936002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9mQntZZUvJi9RKLkVNwEtI+rvB+CcydTnBNwFneojYNHNejyhA7oRIhVQwQBTv9Ze81jbiG979pLZZ0WQWzXS1H3rFBpLggiX9Lzx3IqEVHrwQMX2yLZCAB6euxHDfOwF2UjY+yVdh2KV68WQ+Hxgm99Ij2YsFuuP+h2A7UnHhSQKPBfgy/xP6+5eFZIupJzmZS3puqbF0YzgeLjt3SfRd0AsmzczNB0oHXVBuoFPzGXOlje0mwLxVIjrs0LDvqD9zJ8pIqkqWXyO1oCqeMNSxI1k37b8H4BByx1isaeLSbX8+V8PIvX8s2qYMyO/1mK1Hj59vOWhAeA9+22k2AwXvZPpFjFncy5vwgNgn/x6ckNVLWfEWKsmofqB6XZGOhPN2eYI7mJZvTIRtzu0grCmYfy7KM9f3rEJ990/yozS4f2rJe+0r+l3nmGxMkY/JOPgpg+ZMjRJHyr1GC2kTpHep7htKl1hKRtz0zH+hGl8NrEg50YkdVvyWPAaWL0WSSs7gFZSTBWXHKbQm7oqWJkxckC3K7lCvzSbgH8GUxKZMFeffcDT2yklus6DqmUM61KH7d5Ng/SqAlCnEjwCmlY6mM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WI5WK88yO7HR5e3KnBWbzLiG5HC1ebZZ7s/hkFJoeLQKBIUkETwYTUQMCgdZ7C/HylQmV+Aw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 276d5a56-f2ed-4806-745e-08da1963ae6f X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 13:28:35.0342 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f9SRG9vMeGFDDYZHVSn9mS1/pKGA7C91mgHlxoHea8w5V0zFaDEL3TiSWgFUVZyId1IUa1i5SGofEGyjazWaUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6949 From: Peng Fan Signed-off-by: Peng Fan --- xen/arch/arm/Kconfig.debug | 14 +++++++ xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug index 35ccd13273..842d768280 100644 --- a/xen/arch/arm/Kconfig.debug +++ b/xen/arch/arm/Kconfig.debug @@ -58,6 +58,16 @@ choice This option is preferred over the platform specific options; the platform specific options are deprecated and will soon be removed. + config EARLY_UART_CHOICE_IMX_LPUART + select EARLY_UART_IMX_LPUART + depends on ARM_64 + bool "Early printk via i.MX LPUART" + help + Say Y here if you wish the early printk to direct their + output to a i.MX LPUART. You can use this option to + provide the parameters for the i.MX LPUART rather than + selecting one of the platform specific options below if + you know the parameters for the port. config EARLY_UART_CHOICE_MESON select EARLY_UART_MESON depends on ARM_64 @@ -186,6 +196,9 @@ config EARLY_UART_CADENCE config EARLY_UART_EXYNOS4210 select EARLY_PRINTK bool +config EARLY_UART_IMX_LPUART + select EARLY_PRINTK + bool config EARLY_UART_MESON select EARLY_PRINTK bool @@ -283,6 +296,7 @@ config EARLY_PRINTK_INC default "debug-8250.inc" if EARLY_UART_8250 default "debug-cadence.inc" if EARLY_UART_CADENCE default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210 + default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART default "debug-meson.inc" if EARLY_UART_MESON default "debug-mvebu.inc" if EARLY_UART_MVEBU default "debug-pl011.inc" if EARLY_UART_PL011 diff --git a/xen/arch/arm/arm64/debug-imx-lpuart.inc b/xen/arch/arm/arm64/debug-imx-lpuart.inc new file mode 100644 index 0000000000..f68252da86 --- /dev/null +++ b/xen/arch/arm/arm64/debug-imx-lpuart.inc @@ -0,0 +1,52 @@ +/* + * xen/arch/arm/arm64/debug-imx-lpuart.inc + * + * i.MX8QM specific debug code + * + * Peng Fan + * Copyright 2022 NXP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +.macro early_uart_init wb wc wd +/* Already initialized in bootloader */ +.endm + +/* + * Wait LPUART to be ready to transmit + * rb: register which contains the UART base address + * rc: scratch register + */ +.macro early_uart_ready xb, c +1: + ldr w\c, [\xb, #UARTSTAT] /* <- Flag register */ + tst w\c, #UARTSTAT_TDRE /* Check FIFO EMPTY bit */ + beq 1b /* Wait for the UART to be ready */ +.endm + +/* + * LPUART transmit character + * rb: register which contains the UART base address + * rt: register which contains the character to transmit + */ +.macro early_uart_transmit xb, wt + str \wt, [\xb, #UARTDATA] /* -> Data Register */ +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */