From patchwork Tue Jun 29 02:32:29 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: 468286 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4509135jao; Mon, 28 Jun 2021 19:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNkvQFF/wnoX0kyM+fRli0jk2GNI/+QtOnoGGyNmoUmFu0NcaK0gwmjiCTiUf61hfSjY1M X-Received: by 2002:a05:6402:1d55:: with SMTP id dz21mr35972515edb.338.1624932374253; Mon, 28 Jun 2021 19:06:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1624932374; cv=pass; d=google.com; s=arc-20160816; b=oTG/zAEGb4IOBpXtlG44P1ICK0rhdoCm6ReXBI9lxlZlgh/Zknb/SYENfxJD2zE3ky JhuVbHkBhr/qZSwKFSUoAgB5xzzNy79y+KLi0SRxaq+j0mDU+in4Sc5FA8971obgRQ4f WlzSJ/6z0nonwvdTDygimwf5YvAX0HRPogQJzVOdoHZ7lJrpfP+RnoinMC28HwljxfNx XTOjlHCOZ/amid7sohTZ3Fb4QI1GPi5R+rOmakAwReKGcDgqTk74Lh3bZWAEn46lzIht Oskh97Mx/ZJ3LgTj89vyNsuQDmMIwnmINBWC6s5d6KVzWF8fJH6giqmdWY0mahOIfZ7/ JYuA== 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=t0nUfqYNy2nmfdMFkFIlR3GOz86IAcRsJQeHUv/ADS4=; b=rT+qm0xx75nyp44mT3LBeMpfqFMO3g6E3i+a6hEDGc5F3Xpvt5aNQ9XG44oDFLbizq 9zSwpXNtKjqUS5eQEsny599TobJsSbo8WmS4vmxqE1EEe8AfqZ/vGWLyVLbRX+Csgwgg 84sGlU84wQMVSbmeYQkg8wRdiIQ5SkYH1oOs34yMFLkXlxd6/nNkhYPlvCBYd9HRnYGJ /BQz9aG+3BG7k0SHEJDHbbHeNY3ipjl+7r7EEWzpow0/kdBVxZC9BKgeFD72tIl8T6Rj OO3VkPv5U1BGCoNsTx4Pe2TKiwXh67DiCEdOYfUUFIc77s166Qr9nGbYOL5joHQL15y4 OelQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=ezhPhzfb; 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 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id o8si17791319ejj.94.2021.06.28.19.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 19:06:14 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=ezhPhzfb; 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 85.214.62.61 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 BE3A283174; Tue, 29 Jun 2021 04:01:37 +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="ezhPhzfb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A79838313F; Tue, 29 Jun 2021 04:00:52 +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 EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::611]) (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 A0CBC83123 for ; Tue, 29 Jun 2021 04:00:41 +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=KyLMUlFtotJ/3C/pklCS1oNUn/WyqzfUhOeQgdon+YXGATCoWtQBAxAvCGLRfh8SxlJoe513kbksEtDpQfnWPniF2APSWqKMVmQTJvkAZTwrbCDomg9LXIzruDk7N16Tw2gNOvnIp2zUEoNrKYeiXK5CRBP+d5POhhcbpz9leF/YDkEMDiXstx0mx6No9uipfRFY7IEYTkLbXl59H5LkG3QLPTkqpBdnazdxbDLmg66+pZYzBMbfv6vZRRGl6UefPclcQACjnjRGka3FNDAl4nCW3LI3pbc4j6bU6cE7ICYIT8y8aq0FS2vP9hRGvROKMIZBi6jK13PJ4PW3Zx4YNA== 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=t0nUfqYNy2nmfdMFkFIlR3GOz86IAcRsJQeHUv/ADS4=; b=hvIFx1yYjL8ZLCs2x8c2KIc8whhb7M6KSYXx27O675L9VF7GuQPFuTh1w+ZpkEVLMY6wNNOO0TkW3AH7Z4kZVLIfGfxhsMt69D2K6n+A5+OGi4HamWWSD/he+uBedukEFKXcayncQ5YNlvOqLPhx3EV22P+zhn7sDraf4GLthdEuM9yidasFUh6GREtW2ono1Fdb+11fTg+RgvJM9e/sBcNl4DfMrd5BSoQdX8w5xnbAKIgjtHme/Qa2Vo7c/ccQl/W+GyCQmCnHEtAlJU4d7F9ZyRNKM2tix8GHn3AWqJD3MvkhgsSN+pcG+jHnfaD5+PB3BIzSL/wRRysORSfvfQ== 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=t0nUfqYNy2nmfdMFkFIlR3GOz86IAcRsJQeHUv/ADS4=; b=ezhPhzfbr5VqppBVsAW4rideZ0fJYDXVaq6vGDJ5sAhaDowqABgUpjrHpzQdl+wr9kzhHcRU3fLr55uIy/gV28jcNsh+ZpJHhM5dngKyaGBQFM6srA3cTNL7RT1ScpzX3IO4MAWi16fGdK5ysPcCagIQX/Qbc5gam6in1W3O4YA= 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 DB6PR04MB3126.eurprd04.prod.outlook.com (2603:10a6:6:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Tue, 29 Jun 2021 02:00:40 +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.4264.026; Tue, 29 Jun 2021 02:00:40 +0000 From: "Peng Fan (OSS)" To: sbabic@denx.de, festevam@gmail.com Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Peng Fan Subject: [PATCH V2 35/46] arm: imx8ulp: add iomuxc support Date: Tue, 29 Jun 2021 10:32:29 +0800 Message-Id: <20210629023240.22394-36-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210629023240.22394-1-peng.fan@oss.nxp.com> References: <20210629023240.22394-1-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR06CA0088.apcprd06.prod.outlook.com (2603:1096:3:14::14) 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 SG2PR06CA0088.apcprd06.prod.outlook.com (2603:1096:3:14::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Tue, 29 Jun 2021 02:00:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8fc7945-4501-4464-e3cd-08d93aa1b1ff X-MS-TrafficTypeDiagnostic: DB6PR04MB3126: 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-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xRwyRtSePcj9kjC5IrFl1IwF37eh60HwAwINQRwQPAnYaiLCuWgrD0rWEVNALPm3EHoiaWKon508YSuappBYquJW/oKCrVdIcyuGOsr0iaD0zVkHIuwFfHYJDSard8kKXpgVb8TMr5BB0AkenL8BWlQX0gBzT3CMuiChk+AcHvzI5SWWEeROINH7w4FxIKD6pxbUcrp64PsHZnxWPsHhdWyAgNRgSmxY7uiqtaWc4ZjAFKin7mejfkXF1qB7hkJnAjEcDxkacOeU5ana2/25ySnUog4Q4r5WkPF47eDzxZQzauP/Dc+JPtnRJE/mKcrpdryW8kjbuoaMcXShBsqCjM++v7hTL/o70Ab4W4+w550v+u1j9EpHQdU83w23RSxqOhF7mwdYuBZiPySLawi+QoKmjoE044tEe0mqrHeYQqCsg7QsmNMa7uw/DpsEHiOo0/aYXt0+T8bvSiLrM/by0Lxag5hwrwgEZSDdIIyAxJ9Ua+ERxioaneUb1ou2ap49f4IHJMS2E5MLDe8XUBNp9+5NJD7Q6BzQOTUx2eD+l5npo/Dh+ah6WCb/NaNLeLXUGp3My62ecUldt5hkdAbpKKbiC1g7RKBGkz88nv4GX1YSTpwCgZGij1/kCV4svwGQWIaHJJL85jsKaP9/lAjgPb2q9tvH85vA2iaBlqUdIs4bkVF7cZxeDwXg4o+TeSpRx52OK/0CovTPRh1r71msGHHfF6YBkgm5eg18QKi/bkU= 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)(39860400002)(346002)(366004)(376002)(396003)(136003)(66946007)(316002)(38100700002)(66476007)(52116002)(38350700002)(186003)(4326008)(956004)(6512007)(6486002)(2906002)(26005)(16526019)(66556008)(8936002)(86362001)(478600001)(5660300002)(6506007)(8676002)(6666004)(83380400001)(1076003)(2616005)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1/yP2PuoXR7RN2rPrIiHJCXCvbGy+3XEjMWj0TnYgvE2fcxMtKUWRr2wYJpznVc3pRP6k9zWaZE4RcIwR8oj2qhnTAUTEDbbs/1m0cqmfkg4K+QzIVu3hJ5+x1W7bCHdWjKI4cSqDp0morDuC7P7E6NzTAVPjIZ41BNKkaFA9IG0QizlD1BSsa9NyX4xvlp4ZIEqYvoh6VhmLHZEdX5Z8JEGIOnOfVsqrMcizfm2vh7sktqemFXHLI0fkrclFVQqVIOnwABjYOhobVYCVK/CfPa4wO8VjwEn/wKK/99ClKolhiqXNrVgP6Pyyya9hBIvINgM5QJ1NDtSf1ymJ2/ArVqtosKkdOy8tUopp4gPjAvbc8rAoMAOuYFcRJBfThUB8rxqzpMu1h8JOhguXtr4d/Gq5F0HEWeAMLH9qitEdSVaPdqys3eJVnSsTfYPwlCGm7IGbOv3H+LMGoELhvo/kUckzdJ21FYp5dLDFEb8xJLyykr4VMUHOKCOzJGJQ4jeQcYLpeVzBUO5m9RUI3Zzgzbx9Lv96s8g/vPRTAPH1HssML04emsqGbdOvxwbdk/BCYgoHKDtw8LJxOijkSc9XY8VCTHhvPaC4/TxgUqVRRbwtRcuosVLgQyIdvwlvPbuwC/bYGPeOC8GdACRUnO15Wen/ZikESfUhd7VHRP2AJYs7a0DeXNRm9amTAtYZQnvKTBhStPzeAHPb32/7qlBAZ4iq1Hci4oKtND5E/UBqGDjJMMXs3mC3sW/2fCfkx8EeCjyvzOF3c/OsLAz24IlAU3xlt6DeorqG0M70n6+bekSv572BSgvj1uRFRgkNKV5Wtn00GXQ4vI2AW1ggRUMPXqzeu6filMsa0w2LGb11tQt3W9T6YsSEutmstoslMF/BA2vpuDMThrw8Cghe33AAEtG5bA4qPYICxORCnP+oiQksiF/vPwinnlM4fBXNAvmiOFIjOn/ZVJMlb5zJDshHuEVI+vuwS429qfAFZ3rlYDhoZ1YC3V6aNcs5chzrRip61Nij/iznr2zHuwlzDBkXc47BvZETOwB+OlR2PwzhVA43Vp3Nhvzg4DkwoMnPnGmYAgtWjVC3/HN1pccbwnlce81E7EOqrOm+YnHurD38gPKXzEv4Px0jr8ehEifKdkj9pm64aOpOJUMpK3+1TGlZMLcpRE8dAD511JgZ6fNJD2wxwRIoKm/H33uzphrSvoYaN4fceCMBegl2c3KNXT//1oYHIgGrIOnu+Zbdzoa2KM2PZ+bazx+erHJnfDFxF+zhIAmdXwjKxR+gpzJMhUGzOJ5msedas/eZh7Sxe7+uBQhgfkCJ0SVJg9JqrVKitYB X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8fc7945-4501-4464-e3cd-08d93aa1b1ff X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2021 02:00:40.2067 (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: PBSAt0vydyojvH+SFs0VuzfBRsZmK1XzlrDUgi6+sQOF4LMRmAELJc74LsR7keubvIK7CWZhy2N5Qc6Pp7i74Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3126 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..3c8f2e067e --- /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 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++; + } +}