From patchwork Fri Apr 28 04:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 1774714 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=dRxkIdM9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q6yXH1jKDz23td for ; Fri, 28 Apr 2023 13:19:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC0BF863B9; Fri, 28 Apr 2023 05:18:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="dRxkIdM9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C52F863B5; Fri, 28 Apr 2023 05:18:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 69586863A5 for ; Fri, 28 Apr 2023 05:18:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=oss.nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@oss.nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D+GaCJ8gwnHoLP8ABc5U3BEDSytBN2tTNlI3iSpIiHtn0vcDRwZl9TFfcQtwZOr+arpAccDIJJjh27WEhLvK7NyC4AtVRpyG1qe13A5Y9hCGuAVl1AoeaaLsY5YrHbxTHS1ltLlsxnoxITeaXnDaTwGt6/TqUmUYe+kZ88ta85XcyKIdtjHqyegvLYXOhCJXLMy8smM431xctoZVRKHqdKEWrT7etby3tMyJAdmM5Wiw6mtDT+xS0wlmfQyM8bzg55t0JeypxpcLrq0zVOuV7pxk4xGlIE2+pR4pkvmwjWIKzLRa6IBklYDEvfKBbmbz4g4jeXmOOobNxowzOYa6sg== 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=WcGxC0oGKuTofvV3U0fMHDbVR3LcpNGMjR6tuU4uG0k=; b=eB09nMuArSNVqr+HeWPVzxGcB4rDeOemtdO6Fvo46GRoNPgPsBU+V+fyf+U6zPLJpXX+gKO8F+abvWiUAHGB8E4P+ybKbiC+VdqCp9I6TUrAzsDUGDa9YlZlv6QSHC1NRHtWhNMRONAGjb7Oj1pEusvnlBRYPr3zfoPXUGCH81u+wpYXCk2AlXMfWL1s7/9gYvtSCS3QhZ7EQF81fxBQorwxudmTCjObU/M70ZCfBZZYpRoOM+8pBn4f99oogDQ8iOK/s6YODVrbjfUGKoLnrTPUXZ0ioqJ0ApLP6B91ml8qwpoyGjDCAzBn9Y5VDLj5e3js0BkjE8Mi/y+A3K4eMA== 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=WcGxC0oGKuTofvV3U0fMHDbVR3LcpNGMjR6tuU4uG0k=; b=dRxkIdM96JpV6SmB8crf51npL2Meel1UIGtx3h+dd9q+XXSLxwWdNVYmqBFCVoCjlWLUMkNc5PQCVvKrkY3NbCdto60sWwHbOO+Wayb6qsLcnbrvvEQDjgKImO/y1+8oi8MSFVSBRx2OirjAVCrzFw1vMhWamPo7paYZ1GtcV/Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DBBPR04MB8009.eurprd04.prod.outlook.com (2603:10a6:10:1ef::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.23; Fri, 28 Apr 2023 03:18:09 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::b999:f2c6:a8cc:7b4]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::b999:f2c6:a8cc:7b4%5]) with mapi id 15.20.6340.022; Fri, 28 Apr 2023 03:18:08 +0000 From: "Peng Fan (OSS)" To: sbabic@denx.de, festevam@gmail.com Cc: u-boot@lists.denx.de, Peng Fan Subject: [PATCH 07/42] imx: imx8_cpu: support i.MX9 Date: Fri, 28 Apr 2023 12:08:12 +0800 Message-Id: <20230428040847.10841-8-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230428040847.10841-1-peng.fan@oss.nxp.com> References: <20230428040847.10841-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI1PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:1f6::14) 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-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|DBBPR04MB8009:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d90aa22-4b9d-4d95-f770-08db479730cf X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s3WyE8s9E6krZ1oUvSz8NP38jGn9Q204ldnCIiG9P+DXmoH648s8KP12KZ7ACd215HaVWWKhONugaca6zsgiu4lcW9ZvvFuZ/HYS7E5c02A8NezqvMpNGy4GS2dloUiAsjWj73WWLgRfqnfhTIVQXAWVX4rvW3qgely3zG04ejg1Na3bmpQU8LXl+iKcCHv07A0F6bHOF+EzhHQq6lu9MLSVWsHsTjQzuzOU5p2q3mabFKJZT9yF7beuwxu8cFo4pL9R+e+VcdkhWC5l0e35ArrgztABecgSOjqmbzzCeLWeTZPk+Sje+vrC9nOrkvOcqSnT2j+i1yWh9QcZDeVgttPsPCjjPrjLGRikrGfGHGl5cC9ExzJdZLmVJ3blZ2MOxtQF9L7bTDf6z6cmaVzdsfFrj/D/jI7RSpM/tXTHvhkjIT9JmcgsoLL+7HvfBKZhHRhhr5HeAKYF04rh5qOKss9T5Rx8j1sw6kvc/OTgXmKroXE8rJur1lkKTcA2YkJXJeCIB2vu9rtTDVmV8akc89Pv3sy3Eb+g6Wr9iwjsuFghQZyDil9uj8dVNIUukiYTxZzw805RM+6xcawPVhNf2oXGe1Ho4uMwv/Y6Sx8jGYjhx2YFpVlwkV3+b93Rr7Xd 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:(13230028)(4636009)(396003)(39860400002)(366004)(136003)(346002)(376002)(451199021)(8936002)(8676002)(5660300002)(83380400001)(66476007)(66556008)(66946007)(316002)(4326008)(38100700002)(41300700001)(38350700002)(2616005)(2906002)(478600001)(86362001)(52116002)(6512007)(26005)(186003)(1076003)(6506007)(6666004)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WgyZDw7PUnR2u2WqJW+tSNiyeNGjg7gDWnxKo6lWj5BNJPfD4PcigsOozF2TU9OrZdRo73rZn3v6G4oIHFcULmLuIofaHDs8WdGmWXoTOHlO1ZXGL0UEVoQo4WjZIe0clg/BsUWekNP8d0LgkbumjxyUjjhWLIC+OsOs7B43BccFFvP9LMf12CDUDJbhboA4J8qmB4snsYEzqPSoyzYG2Tz/h0GxSlrEQmCMve96FUVuPdAh2/ki6lyV6LxJ49uLWOjAa8b6Cq8v2T5F2/vl5dqB/SZgP3tQcFHrIlG1ZIiHZ+sIDczz8vtnNTRUXJz3PZPCtipKaw+AJ0y0fSCyYyO8L0GxBWpwGMa2z1UmQG7x09Zyt6wM/BbpoBsVDsWgMNKSc1GU6VXjzCLHkMj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QaK+QmJWJBVzkJ0uaLs3Y8gGgKcqYo2kI+qZ82pnTh66WMhJp++lVp52yJnClGpyWig3CAdgjIXXH4z6FCDVFhUvBOHBeO4/5Oqk9+ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d90aa22-4b9d-4d95-f770-08db479730cf X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 03:18:08.9553 (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: 4KbTs0tbm+6AkW8QzsucStVO1wwamPk3GXBIEkEETqY2uyURtL2if1i1Enh8tbhbINFPAxgsphAL5BCjbHOFkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB8009 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Peng Fan Add CPU_IMX Kconfig Support imx8_cpu driver for i.MX9 Signed-off-by: Peng Fan --- drivers/cpu/Kconfig | 6 +++ drivers/cpu/Makefile | 1 + drivers/cpu/imx8_cpu.c | 83 ++++++++++++++++++++++++++++-------------- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/drivers/cpu/Kconfig b/drivers/cpu/Kconfig index 3bf04105e5e..1c3c810651e 100644 --- a/drivers/cpu/Kconfig +++ b/drivers/cpu/Kconfig @@ -7,6 +7,12 @@ config CPU they can work correctly in the OS. This provides a framework for finding out information about available CPUs and making changes. +config CPU_IMX + bool "Enable i.MX CPU driver" + depends on CPU && ARM64 + help + Support CPU cores for SoCs of the i.MX series. + config CPU_MPC83XX bool "Enable MPC83xx CPU driver" depends on CPU && MPC83xx diff --git a/drivers/cpu/Makefile b/drivers/cpu/Makefile index 3b38ba9c589..d4bbf6fa5e0 100644 --- a/drivers/cpu/Makefile +++ b/drivers/cpu/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o obj-$(CONFIG_ARCH_AT91) += at91_cpu.o obj-$(CONFIG_ARCH_MEDIATEK) += mtk_cpu.o +obj-$(CONFIG_CPU_IMX) += imx8_cpu.o obj-$(CONFIG_CPU_MPC83XX) += mpc83xx_cpu.o obj-$(CONFIG_CPU_RISCV) += riscv_cpu.o obj-$(CONFIG_CPU_MICROBLAZE) += microblaze_cpu.o diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index e7f45e60dbd..2d3df419f1c 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -14,6 +14,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -27,30 +28,43 @@ struct cpu_imx_plat { u32 mpidr; }; -static const char *get_imx8_type(u32 imxtype) +static const char *get_imx_type_str(u32 imxtype) { switch (imxtype) { case MXC_CPU_IMX8QXP: case MXC_CPU_IMX8QXP_A0: - return "QXP"; + return "8QXP"; case MXC_CPU_IMX8QM: - return "QM"; + return "8QM"; + case MXC_CPU_IMX93: + return "93(52)";/* iMX93 Dual core with NPU */ default: return "??"; } } -static const char *get_imx8_rev(u32 rev) +static const char *get_imx_rev_str(u32 rev) { - switch (rev) { - case CHIP_REV_A: - return "A"; - case CHIP_REV_B: - return "B"; - case CHIP_REV_C: - return "C"; - default: - return "?"; + static char revision[4]; + + if (IS_ENABLED(CONFIG_IMX8)) { + switch (rev) { + case CHIP_REV_A: + return "A"; + case CHIP_REV_B: + return "B"; + case CHIP_REV_C: + return "C"; + default: + return "?"; + } + } else { + revision[0] = '1' + (((rev & 0xf0) - CHIP_REV_1_0) >> 4); + revision[1] = '.'; + revision[2] = '0' + (rev & 0xf); + revision[3] = '\0'; + + return revision; } } @@ -67,6 +81,8 @@ static void set_core_data(struct udevice *dev) } else if (device_is_compatible(dev, "arm,cortex-a72")) { plat->cpu_rsrc = SC_R_A72; plat->name = "A72"; + } else if (device_is_compatible(dev, "arm,cortex-a55")) { + plat->name = "A55"; } else { plat->cpu_rsrc = SC_R_A53; plat->name = "?"; @@ -109,7 +125,7 @@ static int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) if (size < 100) return -ENOSPC; - ret = snprintf(buf, size, "NXP i.MX8%s Rev%s %s at %u MHz", + ret = snprintf(buf, size, "NXP i.MX%s Rev%s %s at %u MHz", plat->type, plat->rev, plat->name, plat->freq_mhz); if (IS_ENABLED(CONFIG_IMX_SCU_THERMAL)) { @@ -174,7 +190,7 @@ static int cpu_imx_is_current(struct udevice *dev) return 0; } -static const struct cpu_ops cpu_imx8_ops = { +static const struct cpu_ops cpu_imx_ops = { .get_desc = cpu_imx_get_desc, .get_info = cpu_imx_get_info, .get_count = cpu_imx_get_count, @@ -182,21 +198,32 @@ static const struct cpu_ops cpu_imx8_ops = { .is_current = cpu_imx_is_current, }; -static const struct udevice_id cpu_imx8_ids[] = { +static const struct udevice_id cpu_imx_ids[] = { { .compatible = "arm,cortex-a35" }, { .compatible = "arm,cortex-a53" }, + { .compatible = "arm,cortex-a55" }, { .compatible = "arm,cortex-a72" }, { } }; -static ulong imx8_get_cpu_rate(struct udevice *dev) +static ulong imx_get_cpu_rate(struct udevice *dev) { struct cpu_imx_plat *plat = dev_get_plat(dev); + struct clk clk; ulong rate; int ret; - ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, - (sc_pm_clock_rate_t *)&rate); + if (IS_ENABLED(CONFIG_IMX8)) { + ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, + (sc_pm_clock_rate_t *)&rate); + } else { + ret = clk_get_by_index(dev, 0, &clk); + if (!ret) { + rate = clk_get_rate(&clk); + if (!rate) + ret = -EOPNOTSUPP; + } + } if (ret) { printf("Could not read CPU frequency: %d\n", ret); return 0; @@ -205,7 +232,7 @@ static ulong imx8_get_cpu_rate(struct udevice *dev) return rate; } -static int imx8_cpu_probe(struct udevice *dev) +static int imx_cpu_probe(struct udevice *dev) { struct cpu_imx_plat *plat = dev_get_plat(dev); u32 cpurev; @@ -213,9 +240,9 @@ static int imx8_cpu_probe(struct udevice *dev) set_core_data(dev); cpurev = get_cpu_rev(); plat->cpurev = cpurev; - plat->rev = get_imx8_rev(cpurev & 0xFFF); - plat->type = get_imx8_type((cpurev & 0xFF000) >> 12); - plat->freq_mhz = imx8_get_cpu_rate(dev) / 1000000; + plat->rev = get_imx_rev_str(cpurev & 0xFFF); + plat->type = get_imx_type_str((cpurev & 0xFF000) >> 12); + plat->freq_mhz = imx_get_cpu_rate(dev) / 1000000; plat->mpidr = dev_read_addr(dev); if (plat->mpidr == FDT_ADDR_T_NONE) { printf("%s: Failed to get CPU reg property\n", __func__); @@ -225,12 +252,12 @@ static int imx8_cpu_probe(struct udevice *dev) return 0; } -U_BOOT_DRIVER(cpu_imx8_drv) = { - .name = "imx8x_cpu", +U_BOOT_DRIVER(cpu_imx_drv) = { + .name = "imx_cpu", .id = UCLASS_CPU, - .of_match = cpu_imx8_ids, - .ops = &cpu_imx8_ops, - .probe = imx8_cpu_probe, + .of_match = cpu_imx_ids, + .ops = &cpu_imx_ops, + .probe = imx_cpu_probe, .plat_auto = sizeof(struct cpu_imx_plat), .flags = DM_FLAG_PRE_RELOC, };