From patchwork Mon Jul 19 07:47:17 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: 479819 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3869724jao; Mon, 19 Jul 2021 00:18:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDmIv4JqEhM/tKWcVh81iIc5nUBxZM1tKcQVhJDeLWYnvzreMqUnH7FuUIg3jkrH3S+GQK X-Received: by 2002:a17:906:a0a:: with SMTP id w10mr25926172ejf.416.1626679136902; Mon, 19 Jul 2021 00:18:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626679136; cv=pass; d=google.com; s=arc-20160816; b=vBynXbEun9j3ArzXfrFx+VbFG3FHDGkZ9QO8oWLigRzVhi5UDEkjfHU+/tu0t1tEmw MHPOaEbVZJABnAotWElTrASNzBYrEzkNkypi6H9wuKgn5wOnf12/5X5rDNHyPcmITlx6 tQdjMmePZkPFeJUnl2TS3+KbirmbOh8NKUJdYPdBS7PnZ276F+p0rdbQX91C8H6YlNzs jJPpT7IV30Eaizm8r88wpSjNNpOeJhEDnYzCfO1+YEE4ourXOd33NQ+HyeYMNqPhhVOQ Byg7V79KMCXrtJfuX4j/WOratipvYD5np5FnWqZcJgCWbq10WAMzHPtrvj03m9bNPDpy QJVQ== 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=bPBhM/8bff1oh30XO2m9c66wmpgEucDGkpg41xIxVpw=; b=0FhLcqCU0vugGeim4UpUMII5krwUEJ7H3UWL6WPgEqlKxnQrBQyfBhB6i3hyltxrO/ Xrj+HauNpi0w434BfrU6B908uWsAOiNqxEIsgW4wzpGO4VjrOfp5yibpyf1BBf+ZU1Ky d+UvSZ991hp88CbmJ+STXNAmQAbvCif460W59cwNj8hftEQq6Pcw1wfDFuwbBXPHwCy4 9KD+6J+a2eORuSFtifbxUKNlnUJVbTeqYZ1wS3BJbL0murFuLxg/+m8WwTFT8LqactuO Ftu4oZjGDjK1XXo/6XmeedGrMpkXTf2CjRhprhnvbNuEAVMIVzMfAxflBPKW+IGs2pZB 1WpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b="I1YyQ52/"; 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 gf2si25138795ejb.500.2021.07.19.00.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 00:18:56 -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="I1YyQ52/"; 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 3606382C49; Mon, 19 Jul 2021 09:15: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="I1YyQ52/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0F0F482C79; Mon, 19 Jul 2021 09:14:49 +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-he1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::603]) (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 9014682C6E for ; Mon, 19 Jul 2021 09:14:43 +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=QnCkGKt4rxUjM/UJB2bGzqR30+P1xOM8M+bmDbNLepk4ZjC7Cd2DBUdz2qWCUeBEdjsv+p4S1jvhMUmXneGhmsBFIvd5SKf+3C+jyICPdEJWNcGmXHbnJbhWij7delIKzTA6v9xK33B6JsrvdRtp8BUXoYx1zKMr4n09Scs/pA83YFWZoJa6su+VrVLsIMnT33bYlRKOLGHfnaRmXzo1m4caAVlHHGm1HEztHGJRvFHKcuSxTYV5PK1omHrCQHxwEdaKLr8yHj4Bx/XVKPF3fKxW0cGvceVp6KRv63Ii6Amu+7ViL6z2G1Ct+4AvjEFCRTmZLnqmG8a6kfwHoOy+bw== 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=bPBhM/8bff1oh30XO2m9c66wmpgEucDGkpg41xIxVpw=; b=QWpZOm/q3bXUHNl4JBDw5Gf0x4dln4PN9LYq1htzXR6VsdgmwDcoe/vyhDycE5iiOX1aWtZjK4/wi/dQZGvpi98qvcaSQt5xAeRfH11s5eS2U6n+LRoXNhfEASkCvKOupjGv18TyvJclZW9WCAtibBYHwhWeF9sRZWSThITYZTEouTxdbvyq3q9Q37BSngyYE/TgCLDJLlKY4Iwpbyjy+n9RQS0//do3LEyFn6OjgYCUEnRtaxWsl9sDFLhvtZLjVnBxAJsd+FtvEZ9cO/u2pPE6sjmJr+CQKYPmFjsHVCFOcEDUz9biPpaEYj9UK2RAeb9vnn3gGBZi/g7LCofN3A== 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=bPBhM/8bff1oh30XO2m9c66wmpgEucDGkpg41xIxVpw=; b=I1YyQ52/Pg+N5ZoxPoSSNUIkFXo6Yg0ZgnhHGSqmbw4+2m8gheHSbx1JfXwanywrMUC1jL5AGbS9Ng3h4tfXIZIO3EuDEXtiGs5oaVP/p5sxd8qm/Cv7mmio4MHwN8oWdCbjXZzBHRK59EhcnFFPmlOJoQhP1EUGAwxJ/88qPrE= 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:14:42 +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:14:42 +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 27/44] arm: imx8ulp: add rdc support Date: Mon, 19 Jul 2021 15:47:17 +0800 Message-Id: <20210719074734.29170-28-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:14:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a9d0df3-cda2-4bea-6c0c-08d94a84e0eb 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:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ji1Fxwg1lU9RsNBqcy8FU1u4WrHOIEZTrbIq0oH/64pJ0gugvmRaJRho0G2u+pqk3wfHfJlPyWABkHGkt9EdFp+/zorVidGNu6uldUv78WrSN2naqAPSb2kgLtWIOvt83VKPf/HzleDNj5cHav5Yu5XsSv/0J62R9f8PqB8i8EzIggLO1kwBLV6UUw3d9zBYFVI3hADAWsTfv2Lj8vT1u8InioUY8ERYWqkHkg4WOhkzHv8MZuR2BsQQX2cVwm/MMkVBlKm+5Vq/KPqzEf1COmzEbxNUFvbHwYch0ki7NOATy5jWGLxNPFQCgn672GrOasAS89HKtnIOtZA31B4FSNggrsGEY3sS0L3IWNAiAFntRrJutB93Yavqblaq77J9kqlCa3vRVd3Pqq5KrqWHDDYW3IHrxoGifN/zWIL/y3jLmlDXmTIM/B87bYJ4/Lcwz9Wnwqn6OP1Or6ACdFiORTBMVEmoCog6wDDtuB0DDCBqLg21RBM8jFgB3fMcIUt0y4aUwE3Hm9O/xOHdNlaKSkCeoapiH+Kvr1k98ImFIy5UIq5CLN+HbL6oCLsRguWglhlaYeI/8GfWf9jMEvM+SMXzahqeqQ9KC9xlIRpF0FpTRLfiMrIQp7V7bdMNdJP7zQPd/AEFTDKkiboHLrGK4aC76U/6s2tLheAv0Ty32ofgvxOG/Tcp8JgfPdfypDogHM86L3JYTxT+/Cq95wkFj3Dg8mloE5r3rNCs6uNg+d8= 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: l/b6ghWzju+Dyoo8O5IYfKBMxMxJfFBN0SZ4Be20QJOOPZ/zcoYGb68rl6G0947EwpTlgmpS6fm8CPc8St+G9fU2AiimBxxFzJFqRDxBYaA0ewzxQpxoP739AAJbqCudVtO24gO7ztZ07M5niZGBaGo1HSZgzLo2Yk5BChmqK4fuVXo/VoGWnPq+EHIDQS5AbzAyOSQxGXaerPE60+ZWasGzR2myMTGVHBa79+zqnvR8gxQb17qiNCHwzVN0rzyHPe7YOHtCcO8DNyh766dr9jeIcC4giWhdPZDaefBCUQ7fKozeS49eif/QR4RtOyahd3ggqcIWSLGyzwgiiNMWcmoUoE7G/KndVa+cQiD3q1MRqjqAvbvP7XHiSYyXtypbtPagOHFCSyqMGSu6DwqJna0CqUhCxJvMtHJQomhmd7cmYUinRPgEKBChWdHQTxFJ0wC0/hVI0bt/Lc/tJccPWokMM5vu/NQQpVO3c6NGy7KRw3apihiyR2VLDLUXuDDPu/DaciBj3FmvweBEOBQeXop5QhEJrhAQP9CRTLIQOhTijzpoogj80iGFzjkm4y0Ogia6XeCBD6qpa+GroNbbM/Ir9UFZzUe2JWKvXIb9tE7irKJb8lFKIguGJhG4dhbtjB17pBhv54xtjdS6ExBpJ4GkeQZo3kcTcrUjmjcz0ykd9jKPu+NvbfWgZknyaojbgmcJCD0eoYW4Gv8gZgenYQYkMk/vet0M9kjdqVeLZxEVm+W+oQzl+lcIFAcnKa6CC2anyZm8j2zeXSICWnc1Ejs1DuQiUygeK1FY8nrQPhuRLCqQl/tynmyLYOIB5NRNus54VEVpREin53G9s5CKq8RX2ldZ4ZnYv6STK3YdoYUFmPbfflcoQmDj/q78mRraqfxBbOdOIYZ0OdFsqHZogIA51Cm/GI3O2EfDPtjuMgYPK5yRaedhcW9vqfL22scrjNGaLrcmivaK1zcu4OTxx6x5A0jAWqIOy4HsVizkyi3zTdOzzZtHJ6CygNDpmRtEsObeCCRVv5TotxSU+bmZ6aHwbBJw1vUNOEVJtRgKA1unRSNPIWa01Lx+6VtgFkyxaGmmg3BHL99AI/h6+eia6NvFK6PS49CB0TrTDjb4O3vDp3m8Diu8ndQXT/3J4TaZefPcsh5GFw+iZ4rB9z0f+kha8xXO8OIleLGqALrkzn2x1adAisI/QD093Xg2+8NaXu1yTiqppxHPhCO8fCOfA5PDzaXaRMY4uMAywFOTDlretBUy8fk9ZisBHvnz7BnzDjawTw/Tjc7HPm9O28LlEpjJwGdsyTEjxF66c7DtWZzHbNJnCr75dZJgKfM3UkA8 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a9d0df3-cda2-4bea-6c0c-08d94a84e0eb 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:14:42.1278 (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: k74lIO7Tf3SfTksgEmzeGoBkLiSMxfBzrq13zuwHwplR7irosXj4UFSfX5EkbHAjg6FEDazVAOXf1yxHy+DvBA== 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 There is xrdc inside i.MX8ULP, we need to configure permission to make sure AP non-secure world could access the resources. Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8ulp/sys_proto.h | 2 + arch/arm/mach-imx/imx8ulp/Makefile | 2 +- arch/arm/mach-imx/imx8ulp/rdc.c | 144 ++++++++++++++++++ 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-imx/imx8ulp/rdc.c -- 2.30.0 diff --git a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h index a8f632f45e..47ee46bdf4 100644 --- a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h @@ -13,4 +13,6 @@ extern unsigned long rom_pointer[]; ulong spl_romapi_raw_seekable_read(u32 offset, u32 size, void *buf); ulong spl_romapi_get_uboot_base(u32 image_offset, u32 rom_bt_dev); enum bt_mode get_boot_mode(void); +int xrdc_config_pdac(u32 bridge, u32 index, u32 dom, u32 perm); +int xrdc_config_pdac_openacc(u32 bridge, u32 index); #endif diff --git a/arch/arm/mach-imx/imx8ulp/Makefile b/arch/arm/mach-imx/imx8ulp/Makefile index 78c81d78bb..1ef6cd5c91 100644 --- a/arch/arm/mach-imx/imx8ulp/Makefile +++ b/arch/arm/mach-imx/imx8ulp/Makefile @@ -4,4 +4,4 @@ # obj-y += lowlevel_init.o -obj-y += soc.o clock.o iomux.o pcc.o cgc.o +obj-y += soc.o clock.o iomux.o pcc.o cgc.o rdc.o diff --git a/arch/arm/mach-imx/imx8ulp/rdc.c b/arch/arm/mach-imx/imx8ulp/rdc.c new file mode 100644 index 0000000000..7a098718da --- /dev/null +++ b/arch/arm/mach-imx/imx8ulp/rdc.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define XRDC_ADDR 0x292f0000 +#define MRC_OFFSET 0x2000 +#define MRC_STEP 0x200 + +#define SP(X) ((X) << 9) +#define SU(X) ((X) << 6) +#define NP(X) ((X) << 3) +#define NU(X) ((X) << 0) + +#define RWX 7 +#define RW 6 +#define R 4 +#define X 1 + +#define D7SEL_CODE (SP(RW) | SU(RW) | NP(RWX) | NU(RWX)) +#define D6SEL_CODE (SP(RW) | SU(RW) | NP(RWX)) +#define D5SEL_CODE (SP(RW) | SU(RWX)) +#define D4SEL_CODE SP(RWX) +#define D3SEL_CODE (SP(X) | SU(X) | NP(X) | NU(X)) +#define D0SEL_CODE 0 + +#define D7SEL_DAT (SP(RW) | SU(RW) | NP(RW) | NU(RW)) +#define D6SEL_DAT (SP(RW) | SU(RW) | NP(RW)) +#define D5SEL_DAT (SP(RW) | SU(RW) | NP(R) | NU(R)) +#define D4SEL_DAT (SP(RW) | SU(RW)) +#define D3SEL_DAT SP(RW) + +union dxsel_perm { + struct { + u8 dx; + u8 perm; + }; + + u32 dom_perm; +}; + +int xrdc_config_mrc_dx_perm(u32 mrc_con, u32 region, u32 dom, u32 dxsel) +{ + ulong w2_addr; + u32 val = 0; + + w2_addr = XRDC_ADDR + MRC_OFFSET + mrc_con * 0x200 + region * 0x20 + 0x8; + + val = (readl(w2_addr) & (~(7 << (3 * dom)))) | (dxsel << (3 * dom)); + writel(val, w2_addr); + + return 0; +} + +int xrdc_config_mrc_w0_w1(u32 mrc_con, u32 region, u32 w0, u32 size) +{ + ulong w0_addr, w1_addr; + + w0_addr = XRDC_ADDR + MRC_OFFSET + mrc_con * 0x200 + region * 0x20; + w1_addr = w0_addr + 4; + + if ((size % 32) != 0) + return -EINVAL; + + writel(w0 & ~0x1f, w0_addr); + writel(w0 + size - 1, w1_addr); + + return 0; +} + +int xrdc_config_mrc_w3_w4(u32 mrc_con, u32 region, u32 w3, u32 w4) +{ + ulong w3_addr = XRDC_ADDR + MRC_OFFSET + mrc_con * 0x200 + region * 0x20 + 0xC; + ulong w4_addr = w3_addr + 4; + + writel(w3, w3_addr); + writel(w4, w4_addr); + + return 0; +} + +int xrdc_config_pdac_openacc(u32 bridge, u32 index) +{ + ulong w0_addr; + u32 val; + + switch (bridge) { + case 3: + w0_addr = XRDC_ADDR + 0x1000 + 0x8 * index; + break; + case 4: + w0_addr = XRDC_ADDR + 0x1400 + 0x8 * index; + break; + case 5: + w0_addr = XRDC_ADDR + 0x1800 + 0x8 * index; + break; + default: + return -EINVAL; + } + writel(0xffffff, w0_addr); + + val = readl(w0_addr + 4); + writel(val | BIT(31), w0_addr + 4); + + return 0; +} + +int xrdc_config_pdac(u32 bridge, u32 index, u32 dom, u32 perm) +{ + ulong w0_addr; + u32 val; + + switch (bridge) { + case 3: + w0_addr = XRDC_ADDR + 0x1000 + 0x8 * index; + break; + case 4: + w0_addr = XRDC_ADDR + 0x1400 + 0x8 * index; + break; + case 5: + w0_addr = XRDC_ADDR + 0x1800 + 0x8 * index; + break; + default: + return -EINVAL; + } + val = readl(w0_addr); + writel((val & ~(0x7 << (dom * 3))) | (perm << (dom * 3)), w0_addr); + + val = readl(w0_addr + 4); + writel(val | BIT(31), w0_addr + 4); + + return 0; +}