From patchwork Sat Aug 7 08:01:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 493382 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp1030831jap; Sat, 7 Aug 2021 00:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXBw1UKV6Db3Eg8YR90tlb+GlvHtTx8wB03Q+IDoS2Yu+n5PHxboFvKUNQzyIvTLutAQax X-Received: by 2002:a05:6402:d2:: with SMTP id i18mr17773510edu.17.1628321595076; Sat, 07 Aug 2021 00:33:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628321595; cv=pass; d=google.com; s=arc-20160816; b=ACR/eJN1KgZmJ+30sp39mizF1O56ZSctD7WRXi38fm3WaHXNRzoYYKTUF7KndGNjv8 R1yLrjeBie5IeekZnpjHEhv5DcpgOHptbcod/XL6uuxYaVPQkOLQOQtarjIO6wNqGKjM 7tr4Our7rCnkLaA9dub28mN2y9EEeb3Ao1FTip3vY5qp1cupa6ZC/LyrCa77HRwbyvUn z9I1ICXCe11W/B1zOkmjC8LhFWO9glggLKoVkP7IV6WywFq4AB/9f700ttQWJuu+1dfM NBkbqBEgGUQZuDjy2F629icEgrZBmHi4MNV4QbZ53hJy8q9D5ijqHR7pC39B+cnELrOW xG4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8xwnuBWKC4cMPv6Jh8UFOwbj+SWVlU+9n0TylTuQE9w=; b=G1eieX/q55mM7+J3pxz8OQzw3mIrQ7UjTKOW+GERVBX1Wo8B+Jb1wJAQ9Mb+LKt8Ym egp9HwD++sWaNiRyju3pQnh8bDxWWb3XXZ+Mwlk1ZpLZG098vXS8epcdsJIsicO6Ft9y 8u2lYdBz/0IzGtMwST97PGIjLZ845B3/psfnrayNiCB6h4B37njcjx3LKAcBWiEO8hou +KA+/8JyvsknLwmUQC1g7nSLWe0zEfmzSRSUC4ESXanFV97t8RRg1ITOc1oS5cks13n6 ZEAdW2X356uYwGDFRAp2eDpXwlXCz//HeAa675P5CouxJ9Q0lxMi7Y3wSuauTQmH7508 AaLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=YL0hAjrL; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ca23si11359659edb.460.2021.08.07.00.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Aug 2021 00:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=YL0hAjrL; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C0D2A832C7; Sat, 7 Aug 2021 09:30:08 +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="YL0hAjrL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 50E9E832AB; Sat, 7 Aug 2021 09:28:53 +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,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::623]) (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 840308327E for ; Sat, 7 Aug 2021 09:28:14 +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=RcTDjIxisafBWrlIN7t54kQ+7gkp065JsCmXe0eXrQm68F8scuIVak/UHjbYFJH9rmdgiTO0hH4o4LvxUQtAeJgJJ07xfpNl13b60qsjKw94vDbxmdCxO6jisQOc9celA84fSuUbSsskVZQH+ESJ8sCk3lk5SHMNeVcgxOm8tTnzJkLmx4Bkg3nNSSdip37IWj5Ac1HOEEFQavLfbrcRWw5xGQor/KnHY1Q26AEvZ7IRU8LLXcWGd3aj5KSP5fNniN1+614qIMCs8/I09ok+A3GE7g+odYy8t9kzRmX/FXBjazKi9oXm2qFujSJnquGh/XfzC1BNe5sXJb3fEMCB4Q== 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-SenderADCheck; bh=8xwnuBWKC4cMPv6Jh8UFOwbj+SWVlU+9n0TylTuQE9w=; b=EQ3T/ilsyWyt0S3gAJofyx5uHnD3KyUPSsUEeRkjKDSHKynP1Zqo7OgKg0pdMP1SPCF17A3X2nKOmF2R2hHNIVtotEU8Ga5h912pk0+7jBhy2ZD2eYcTl41fmqHoeju4HbX2yBhui9IBM7bSRZd6F3KL6J5hgDhOBHjd73DX5T6/EkB0ovLDbvHaQ+Viy+cTrlpyf6L+UJGk/QXZxNafURo+xIVMj3Fg4wINXWTpwrkUjxdb0qViOkfQ7Bf0OoH98hv31Lo/r8XrtKudLGUAsNwoVi4N+4/Q3PDF+lRAY8fc9WJfJiNtHWhy0DZ6+JcLJDDg8CqsOMCb0CP/I94DFQ== 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=8xwnuBWKC4cMPv6Jh8UFOwbj+SWVlU+9n0TylTuQE9w=; b=YL0hAjrLOJn6q8C30COoYUecrsK8jTZTTNFoMWqRsKTHHZHA4vY+YeE/cPAHUk9+/aMQ0rlmdg5AD+jeTrZhiidyHxXFRjgKEtI/T2tI217QtZ/fbhriQx6ZC7Vzt2TKZjIA5ctwZ5Or0ttD3wNV7+5eovTtviadD6CRYVVPir0= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none; denx.de; dmarc=none action=none header.from=oss.nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB8PR04MB6857.eurprd04.prod.outlook.com (2603:10a6:10:114::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Sat, 7 Aug 2021 07:28:12 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c445:d742:eb76:86dd]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c445:d742:eb76:86dd%9]) with mapi id 15.20.4394.019; Sat, 7 Aug 2021 07:28:11 +0000 From: "Peng Fan (OSS)" To: sbabic@denx.de, festevam@gmail.com Cc: u-boot@lists.denx.de, uboot-imx@nxp.com, Peng Fan Subject: [PATCH V5 35/44] arm: imx8ulp: add iomuxc support Date: Sat, 7 Aug 2021 16:01:04 +0800 Message-Id: <20210807080113.16020-36-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210807080113.16020-1-peng.fan@oss.nxp.com> References: <20210807080113.16020-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0133.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::13) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR01CA0133.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Sat, 7 Aug 2021 07:28:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fad35127-2ff9-4187-9655-08d95974e968 X-MS-TrafficTypeDiagnostic: DB8PR04MB6857: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R7v64+eSqJOErnD7eybcsnqUrioLa3j44OvmV/vLvRULT45l8m6DhZnpdSwIE9lcIXYpihRyw4suEYHoqkog8C7+Ht9iPkrWJMupYDB0SiOL76rjld0j8b9Pou2worZYPvLX1qgHeWRy8z0aKT7JqUpXo+KuDbY+to1sX3G2KB+TIxhemWaWsb/sQKOVP8q6+xohBWQfu+HJx/DCsfe7dkxpaNHJShieImodJpTu6jGVYvpeG7jKDAxw2gGzd0u/7PdG3uNKqe3H596IzyFxMeb+Ly4c9gwkoKweXzbA+K1+ZLP8pb3gSZRtY07IB0a0UYRf6lnDqbfQ/glPIkjxH52+ePVUjtFH4zQ/+8QKMW4lUNbQyjk+EONq03vnWauIjSsShzUlXITqluQApOkZKrrLnNdCrfwvZwzkPX/lKNimM//Ug+d7GW3JSxCpnvW8rkTxl5rKj7a1ObtZFx0nCx0G/SWDMstujxza/Tb2DhPDEEvwsu/9rDVFTtQ/7nmWjqdIkElF+o3Zrhd90A0XcG2YsDTg1GfDu6bvO9uvuX+JPO+mdnPMKV7OJULIPS4JZrAW3T4Ax0DgwtMkVCP3Fqj5j3ieXMgfImDxNVq5aSExSYamDS5xPvYdAnyK/7ecp8WA/lb1td/pITvbqJkdbR8Gs4TMT+QoubtWp/Tw8E+jnfh0OY4nRfNajAC0U65h4jYBBfsCvBVVo/zz7G26mtrETguYvvgSupI9z6gdQkU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(396003)(346002)(366004)(136003)(39860400002)(6486002)(956004)(8676002)(6506007)(26005)(4326008)(8936002)(66946007)(83380400001)(2906002)(2616005)(66556008)(66476007)(5660300002)(6512007)(1076003)(38100700002)(38350700002)(86362001)(186003)(478600001)(6666004)(52116002)(316002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fwTF+1ORL5dFh5TZ7crug2EH0UzfwIEYZi1gh2xJcnMRW+VZf/Agp2jcTYSQEW7xcEaq/nzoimZot7S74y7v/qWB5ge5K2flS/2A00NeWjejes2kvoVVBHHLlNZWTKoYPQN273/NJ5WINgTG41vaTRZhIsZoRAjWzZO5ikZxqDneCASoNklVsxVyTTAKElkYjJ6GbHlDtWpDH9pfzPDqduceIaS3GOzeyPUOYQUTz2ULShSvnaq2eyrv4YNkz5zlkMMROvL6G6OKFlHfrpHJzqLLMBrEi4HCTDu3RQivUCWabFVbLYahBBN9C4S0eNgQ8ZJ4jzDBY40zP5m7La8fSiW00dCuN21N0ZxuP/KR449Lgx1Ko6EI2FTTN1JwwToQZPV+1k/pWTWE5FjTXsbsRR1lRvJvH4K/Fqi8rqK61URyWTq26HZTkdt6nbw6KOwKm7wLMCNfLmdJVGg/pwQcTLvf99iaceBLTsIQh7NARCwzY+Hu4RKlkAARqO6mz+y2Tn2Hh/zRX0le2RVV/HaQUKo7kViITqZbai0JgDCrnmLG4Dl3WwMsAWZpTse6epNU1XnrsXquBomGFNdV8DsnEUhsgONcqjC1O6O5qhL32N32HzgBVS4dnq9yNGVGISHd8CSWvKgmrqCuvnGc+pNpovDy/bAL9nC0TdcdpMxT9nx/lRG9Oechw7as77c/l8562plWvqKpNMkpnW+9OoG9FmUUWPKh5iPDnOju4mxr293YEurtkJb0sr3wzrOIn8Owxm5dcHR8XO9VKo1W0kyqu7w0FPCyKV/PBuVpXksXdeGtkdARySK6ZHAowvmcjdoRieReCy/QFRDw3cOJJ2aNmIhp1dUrYQuY89LlOVGsrqw7OCWITzgKB3lyrjg7Qpf9CmIjUYkrN0qdjT6BJC7rNLpz2fwe5HeRcUJRHE61zV4fSTSfTvEfjBSuqs/XVUak7HqzgdlT9pEdzdoPRTW9vHplKBD8lXNqU0dGo1Xxb6BtPVy7g6eZosLKCcw2RRYsIGP/as+AnGsES/hqPhYoZczzYzlITTY4jbeP8G1uHKwhr8/6QNRP5ZHAm1+NioF9FDXh4jEgFzqVllOUIk6C2zHS8azNl+8EXyUqc1ozK3CHe5kg8p1bf/+RIFMErxIjliA71TuT3ceGsCRL2A/DnDT107nsyTb0a8YZetxZHM25ddNCbUo5mwxew6HWSISHTzMr8f7htIVkK9Q0sQpBhuFLFdyiq91DV0rgQixLc0WlZLbsqlRWDyIrblvIYrbeShNX/B9rWLIlI+1UFYo4X0zRp9ZvN94HPRRGkX5ZjrpTKmHLplfBMci1xZgGPvPd X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fad35127-2ff9-4187-9655-08d95974e968 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2021 07:28:11.8748 (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: O3GSZwSeU2JIGzKqoXpHvrIwkJtc+ERUCw+du4EvO24hwNitYz+L/Z0ql+GSiw91JKDoBBWMvwqNCRVv1DCcRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6857 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Peng Fan Add i.MX8ULP iomuxc support Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8ulp/iomux.h | 82 +++++++++++++++++++++++ arch/arm/mach-imx/imx8ulp/iomux.c | 56 +++++++++++++++- 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-imx8ulp/iomux.h -- 2.30.0 diff --git a/arch/arm/include/asm/arch-imx8ulp/iomux.h b/arch/arm/include/asm/arch-imx8ulp/iomux.h new file mode 100644 index 0000000000..0210489b1a --- /dev/null +++ b/arch/arm/include/asm/arch-imx8ulp/iomux.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 NXP + */ + +#ifndef __MACH_IMX8ULP_IOMUX_H__ +#define __MACH_IMX8ULP_IOMUX_H__ + +typedef u64 iomux_cfg_t; + +#define MUX_CTRL_OFS_SHIFT 0 +#define MUX_CTRL_OFS_MASK ((iomux_cfg_t)0xffff << MUX_CTRL_OFS_SHIFT) +#define MUX_SEL_INPUT_OFS_SHIFT 16 +#define MUX_SEL_INPUT_OFS_MASK ((iomux_cfg_t)0xffff << MUX_SEL_INPUT_OFS_SHIFT) + +#define MUX_MODE_SHIFT 32 +#define MUX_MODE_MASK ((iomux_cfg_t)0x3f << MUX_MODE_SHIFT) +#define MUX_SEL_INPUT_SHIFT 38 +#define MUX_SEL_INPUT_MASK ((iomux_cfg_t)0xf << MUX_SEL_INPUT_SHIFT) +#define MUX_PAD_CTRL_SHIFT 42 +#define MUX_PAD_CTRL_MASK ((iomux_cfg_t)0x7ffff << MUX_PAD_CTRL_SHIFT) + +#define MUX_PAD_CTRL(x) ((iomux_cfg_t)(x) << MUX_PAD_CTRL_SHIFT) + +#define IOMUX_PAD(pad_ctrl_ofs, mux_ctrl_ofs, mux_mode, sel_input_ofs, sel_input, pad_ctrl) \ + (((iomux_cfg_t)(mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) | \ + ((iomux_cfg_t)(mux_mode) << MUX_MODE_SHIFT) | \ + ((iomux_cfg_t)(pad_ctrl) << MUX_PAD_CTRL_SHIFT) | \ + ((iomux_cfg_t)(sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | \ + ((iomux_cfg_t)(sel_input) << MUX_SEL_INPUT_SHIFT)) + +#define NEW_PAD_CTRL(cfg, pad) (((cfg) & ~MUX_PAD_CTRL_MASK) | MUX_PAD_CTRL(pad)) + +#define IOMUX_CONFIG_MPORTS 0x20 +#define MUX_MODE_MPORTS ((iomux_v3_cfg_t)IOMUX_CONFIG_MPORTS << \ MUX_MODE_SHIFT) + +/* Bit definition below needs to be fixed acccording to ulp rm */ + +#define NO_PAD_CTRL BIT(18) +#define PAD_CTL_OBE_ENABLE BIT(17) +#define PAD_CTL_IBE_ENABLE BIT(16) +#define PAD_CTL_DSE BIT(6) +#define PAD_CTL_ODE BIT(5) +#define PAD_CTL_SRE_FAST (0 << 2) +#define PAD_CTL_SRE_SLOW BIT(2) +#define PAD_CTL_PUE BIT(1) +#define PAD_CTL_PUS_UP (BIT(0) | PAD_CTL_PUE) +#define PAD_CTL_PUS_DOWN ((0 << 0) | PAD_CTL_PUE) + +#define IOMUXC_PCR_MUX_ALT0 (0 << 8) +#define IOMUXC_PCR_MUX_ALT1 (1 << 8) +#define IOMUXC_PCR_MUX_ALT2 (2 << 8) +#define IOMUXC_PCR_MUX_ALT3 (3 << 8) +#define IOMUXC_PCR_MUX_ALT4 (4 << 8) +#define IOMUXC_PCR_MUX_ALT5 (5 << 8) +#define IOMUXC_PCR_MUX_ALT6 (6 << 8) +#define IOMUXC_PCR_MUX_ALT7 (7 << 8) +#define IOMUXC_PCR_MUX_ALT8 (8 << 8) +#define IOMUXC_PCR_MUX_ALT9 (9 << 8) +#define IOMUXC_PCR_MUX_ALT10 (10 << 8) +#define IOMUXC_PCR_MUX_ALT11 (11 << 8) +#define IOMUXC_PCR_MUX_ALT12 (12 << 8) +#define IOMUXC_PCR_MUX_ALT13 (13 << 8) +#define IOMUXC_PCR_MUX_ALT14 (14 << 8) +#define IOMUXC_PCR_MUX_ALT15 (15 << 8) + +#define IOMUXC_PSMI_IMUX_ALT0 (0x0) +#define IOMUXC_PSMI_IMUX_ALT1 (0x1) +#define IOMUXC_PSMI_IMUX_ALT2 (0x2) +#define IOMUXC_PSMI_IMUX_ALT3 (0x3) +#define IOMUXC_PSMI_IMUX_ALT4 (0x4) +#define IOMUXC_PSMI_IMUX_ALT5 (0x5) +#define IOMUXC_PSMI_IMUX_ALT6 (0x6) +#define IOMUXC_PSMI_IMUX_ALT7 (0x7) + +#define IOMUXC_PCR_MUX_ALT_SHIFT (8) +#define IOMUXC_PCR_MUX_ALT_MASK (0xF00) +#define IOMUXC_PSMI_IMUX_ALT_SHIFT (0) + +void imx8ulp_iomux_setup_pad(iomux_cfg_t pad); +void imx8ulp_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, unsigned int count); +#endif diff --git a/arch/arm/mach-imx/imx8ulp/iomux.c b/arch/arm/mach-imx/imx8ulp/iomux.c index c52ccdeaea..c6d20f5468 100644 --- a/arch/arm/mach-imx/imx8ulp/iomux.c +++ b/arch/arm/mach-imx/imx8ulp/iomux.c @@ -1,4 +1,58 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2020 NXP + * Copyright 2020-2021 NXP */ + +#include +#include +#include +#include + +static void *base = (void *)IOMUXC_BASE_ADDR; +static void *base_mports = (void *)(0x280A1000); + +/* + * configures a single pad in the iomuxer + */ +void imx8ulp_iomux_setup_pad(iomux_cfg_t pad) +{ + u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; + u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; + u32 sel_input_ofs = + (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; + u32 sel_input = + (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; + u32 pad_ctrl_ofs = mux_ctrl_ofs; + u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; + + if (mux_mode & IOMUX_CONFIG_MPORTS) { + mux_mode &= ~IOMUX_CONFIG_MPORTS; + base = base_mports; + } else { + base = (void *)IOMUXC_BASE_ADDR; + } + + __raw_writel(((mux_mode << IOMUXC_PCR_MUX_ALT_SHIFT) & + IOMUXC_PCR_MUX_ALT_MASK), base + mux_ctrl_ofs); + + if (sel_input_ofs) + __raw_writel((sel_input << IOMUXC_PSMI_IMUX_ALT_SHIFT), base + sel_input_ofs); + + if (!(pad_ctrl & NO_PAD_CTRL)) + __raw_writel(((mux_mode << IOMUXC_PCR_MUX_ALT_SHIFT) & + IOMUXC_PCR_MUX_ALT_MASK) | + (pad_ctrl & (~IOMUXC_PCR_MUX_ALT_MASK)), + base + pad_ctrl_ofs); +} + +/* configures a list of pads within declared with IOMUX_PADS macro */ +void imx8ulp_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count) +{ + iomux_cfg_t const *p = pad_list; + int i; + + for (i = 0; i < count; i++) { + imx8ulp_iomux_setup_pad(*p); + p++; + } +}