From patchwork Mon Jul 19 07:47:25 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: 479824 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3870705jao; Mon, 19 Jul 2021 00:20:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6+6klowSbn7fLqKt7utKCADeW/GLhqt/xfJd0IbH+KGmTmNeMfwZpn4wfRkRIfOkq05MT X-Received: by 2002:a17:906:546:: with SMTP id k6mr25500153eja.53.1626679228932; Mon, 19 Jul 2021 00:20:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626679228; cv=pass; d=google.com; s=arc-20160816; b=K75oWUeMDz8G5gjAlSKT1ptAP6FmOabT7d6t36zFETAAnEsnSVXSj6Vdmk+QRHqBMk G0p/2R47xhnpMkJjE5ifjGf3o1PzIviDw3VdfcJOMmMlcjadVai63xyUeavk6jGZ3Fzo 95/C8TSoGF83N54FwpbbTB+klHoas6snvExvN8MDE9vV4qr2HkFY/YeY1LxHVVRO0JA0 3NEcYpr6kiNEkTBSE1M+J6KbPFlPAJBDTXaA/yCnuQme8FgbNnV4oqPJCjqM6WgkpIhH 7x74JSNM1yFEkzlpKSPbk+PjVEBLLL49rv12TujtUX4qYINQ46xaRd4GcDK+zgE3k0oi WyYw== 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=TqypcW2JrG1so5p+udW/3wy3H9XiatWrG32zpVq0J8X4Y0fJjXN9l7yLdagcvPSt1u vbm0s8Y5fWqzgRNJt4TwokF4Aj4CvX1/bcPjyPLMgCw6ljoaimRRy+lD8tRvGBgXftlU iTF8t1JE5POTmqnJywH66ti+f6Ns8TPgJLKKL9orvYF6CQCrDVU5dM4lo7WfnU7ShoMP zGhPIBqiLbs42e+1pOrZ2mBWRVFFyzU4hrZzP+0ldB2e9GE6m5w4P3bn5ujucwfV8xgF af9lxMRnqg0nfidhuwvZtluKEGxfk/MQau0TDqThYwUNw8fEr2nMgqNIg5ylJEuvLE8k bNcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=guxlxpI6; 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 s8si19424618edr.527.2021.07.19.00.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 00:20:28 -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=guxlxpI6; 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 49AA782DBF; Mon, 19 Jul 2021 09:16: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=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="guxlxpI6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6ED2382C8D; Mon, 19 Jul 2021 09:15:10 +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.6 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-he1eur04on0612.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::612]) (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 2BA8E82C83 for ; Mon, 19 Jul 2021 09:15:05 +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=X5VNTV/39TZlokQzbw2R2RufUPo4SlzbK1rG8O/5alVTvfLZ3b7rEhemHK0G8wcURpyvNTH0Ak/Qu6UwGmod90LwdVHKil4iAAvqY3YbAN8EVNi2lqxmzulh3bTWvLUjEJJElEOzfr/77iA780iakvWg/1WSsPkCDNx2M13/hIKpdLO8oyuJDUmP9fZ3KRpzuj053qo2FyOk2/r4OMLU8Mivu2NXKu8SOvd12lRfdM64NRAc5NudO78pCD9/T+6n3RVEJhp/XPhZT+mySI1NiHfI092M5CgY9UPy5RG2sGeAwcTMoSHFBvCKbdysjodgA6paUz4ltW7LOTEEYS2LlQ== 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=R+BQ3faLEZ7P3J64/OJ24xEZ+FiEnBIu5xi2PQx1l6voV9eUoUfvhUP+/kCJVThMY8ypuxU4W06PUs50dJgDN80tSGEhAE6SGjgjENzgfYsYAO4NkYFk0v4/3gHGxeB91Z0Rrkb07aqMjOow+NwROnlqWZOdGAfnI52qO/nbpy/fCQTWoYs9+kn74+cS1DmVHVo7iWdaWzQw177v6xB9mB9UrTMbCfUjS4AemmSxuh1ipqIjl0PTZ58q7FvQzXC3G/4gXcE31q9c4AK8iaqbK9LQUY5RMN3MLqFcFNgoBsL0kAAzBUw3rXLcUU08rQN7pKCNhemmnmWgd/yFnCEV2Q== 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=guxlxpI6GWUkkSkeq7TsG23oXNORg27/9uewor1k0RAZADhWEknAHYq1sJa0cWkFXCf7SF+m4dXAbe46wbwx4BsJ+VWtyPEd4T1MzJVqsAh/ynhirlJtN2fMgryDqqvHFR6EyA7HctkwKJ+qM4kQ38t2cl3ydOiVE3bh/hloHNg= 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 DBAPR04MB7302.eurprd04.prod.outlook.com (2603:10a6:10:1a5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.25; Mon, 19 Jul 2021 07:15:03 +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.4331.032; Mon, 19 Jul 2021 07:15:03 +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 V3 35/44] arm: imx8ulp: add iomuxc support Date: Mon, 19 Jul 2021 15:47:25 +0800 Message-Id: <20210719074734.29170-36-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210719074734.29170-1-peng.fan@oss.nxp.com> References: <20210719074734.29170-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SGAP274CA0006.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::18) 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 SGAP274CA0006.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 07:15:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27c1a266-7d81-43ff-da5f-08d94a84edac X-MS-TrafficTypeDiagnostic: DBAPR04MB7302: 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: dyprZFFk3PSS2OhSBguHj4DKoBRU613lD5S+UPq8To+dztRIauSIUzwl7iZrKb7OShqGjcRV3pUcF65fGwWYdpJOJev0aqwVIBio9kkRKXS2v8QLsFj6lXc0oBqNVlQr/ILv7PQQQeZodeFUrpTbPxoEIz1LdGWORdCMLVz2A9rKD4a7w6t8HfEPNJ+bJ0cuyS73RWj4/TNygacu4wbujPYuEWLvRWNJ/KjwXsrRvVQEYYlyhFl3eD0ZkzT3TCI3uJYSb/sbIVVFfYMTsmb1kXQXflDVmIjFdeTvkrBp92Rpka7CDZnPy6zDpEkN0iJZtwYik3IUuvr8Hd1ryvUdC0WtjyG9HOVWinEe22quc01Dk8c0EyqCKroG1u14Lftxsi15wxH+CdDDXTiSKvpcuI8863zcqA9Ue5+LGy6ZfPQg0KecBRd4ebAnB1GQ2CNxgUeMXIESn+2vEu5c/kw8NIDW+kYgjw+fuTYmI2zbtotR7Mp+jHomMBQNqCXmUjAEZc0fB+KPS0z3kIzykFpJUG/7v2QZSFCulIdXsF6eu2Knwgs3Fj9oV/Z4y4r2KH28n+OpeBYOL/MfUFpSwSenimXrZkNWHECztiXxxsiITaCAJH9MZR9hHHdVOd6yonSU/iEcOmOzJIOhT/24kgOtizvp8N1VeGnHWkSjfHWmjV7rDvn84wd/2lxPTo/1S5wh3LBV5otRVo7XDyxTCTg8xKPwQ2edi3dfeej9pXKIau8= 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)(366004)(2906002)(1076003)(6506007)(8936002)(52116002)(186003)(26005)(86362001)(83380400001)(316002)(66556008)(5660300002)(2616005)(6666004)(6512007)(508600001)(8676002)(6486002)(66476007)(66946007)(4326008)(956004)(38350700002)(38100700002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RB/d9jiYUkCZB2lO67q8AeK5r6t99ymopkFov8Z1qErqFCwAfufmN5GE1xwb2RT7M1loRMkuhopc9LoiGxzQ4ucP37JB9N8uxH1kHg+CpsGQo6R/ucO1EcOXOFljduruw31rVzBR3P5Tv85KEQK0YcdjOGfh+UHJrIqHJRe0+pFWztJqvmWAMuGXBNHrAy3OJIabSBR5usMfZM9HKXHx4/FlwwBnfdxkBwovFe41Wgl4XdHewGh7b5+v/2357Re4yGcKiVr71ehvvZOAQXm6LSK59rUawKy2CCPZVt2apK2x3xr/k9iDy8wS/xmVKuHOvk8siJlMsjIw8OBgmCZeq2N3n7Q7DIaYWoqvxs2P5apBhr6TUUgBDQy1eOMcY/A0JjYKGXZ7tS8RSFTr9xitL9xwclirqa6qVQSBq3mVUAwnYBJsE0eKBxpdlKPyFY2VWiIC133su99ctzIDVLLR4kK5OhQpHNkvwx/v1PKD28b850RxdO9MK/XQQq/i0K57SABVmAhjv7kH/7YyOWmHXNcjX9jMm4cvHzs5E/Hd3vgI2zdbAmUZpMOldDPh65/N60++l+iArGsj+WzE/gF3bFMqkVOUfFVc0v4DtZhoQ/jeUy39cl2rHjlpL+tF6Om9vrtqMoxwjf85EDHVgz/roQeFrLASkkkgj0m5ZvPa/JTpSKtyduQYIhdEj/GR3ofQwKezuUi6LixCgA8NPZvS5SuTxglg0P69FQJX7WC6y8KfDsqFP+gJboYi+Zdv1iyV7wv4s98aBB2OJjcuEV2wYvFmCL7CZowfL+TZCgBltI95A9FwQfLf8cRbermtk+JA8k70ORsFCEM6oQKvnqj9DTLy08rxLuUv9nw5euH+k1qpFl9l4XsCmJmKtCjjNNQvUPci3pBUCULIerz2lJppx0vikusEz9JSi3CgRVZEI5CoFWwnc0TVXA1Cn2GGrqsL5K0U3m1nM5C0lwMfdfAsa3oBzrNXcEhA4or4DtBmMYJ8vCFJ7tACGmDULPxy5AM35+nBF6Y6DxKkoFWZBbcwvAMQF6EiOSI2pKqPTHHW2AqW64ZLkhJZ2fbrOyNs+KuN3PKIJWfz5GvI0kp93p/ecS2cYV0lU6BVi4/HtfdV0Op8E4KNs4l50wcWtyxQ5+AsvnlnsU3W3YUArLTf5B2jWgKELN5bBg+1icAYJgtA509xrxsnnuhiEE+NkFWdz73VysJJ/Edr2ntXeaohrjIDKxHPmi7R71DKYPD1CYtaoss8wGBk9wuLWwl7IZ/H9dOOkY1vPcc4faEwdqm7opSB/yF3t/0cvLgC7ZyM5i0vShQBrLASYFEySNa/Cd3PIsXv X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27c1a266-7d81-43ff-da5f-08d94a84edac X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 07:15:03.6881 (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: 08Y8fTT+eMlob7c2UX7rgMTZJ9A2BgZFDt6hBXsAet8HxoRvoHVDCHd91hYpsL7u9jvtgRcXzWVGvPr2XECN4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7302 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++; + } +}