From patchwork Tue Jun 29 02:32:21 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: 468282 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4508095jao; Mon, 28 Jun 2021 19:04:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf5N/+bXRmWPZPKikSpMxBKDZTnJZiLfV2Bq+IkbcUNdo0QTAV8dnDbSe9hBHLbOefBXBK X-Received: by 2002:a05:6402:2927:: with SMTP id ee39mr38191078edb.367.1624932283577; Mon, 28 Jun 2021 19:04:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1624932283; cv=pass; d=google.com; s=arc-20160816; b=UaM3w3kTJE4Jf2C9Ioe2kAiA/eJbpy4UF+0V+XXZwMbBhKc6B1NJ6Jq2VH6vpG7n3e OC8mwF3EB+TzgVRt5628nw7aQNRnEIz6kEZnXXLj9lnpd9a5TOJKwXFB/LDG+LsLBauo WSCLyCMwACzVoX2QVAS+F/nm55/zf0CZhtq6jrMnP5Rq5iZKmz5Ibvv3r/T1TK5d/E5I gnRsduI8cHvCl1HBjhUysOGDgmx7QyNwfYg/419AxpFBaDf0a2QWBRMitEubc+jU4CCe tTeirlgQFyHlaMkoiBUJtRjy4YdRterhWALvCEiv4T0RH4s57V6ekglIWH+9stGrKc23 dfbg== 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=mfZehgm9vNXwwYkXyLE8OaZ1iBraOwHg3Gd7zYdu+IR8cN+Rod6H1LShEmfcG7RZA9 K2ZAo9l1MsQXpvH6/hM8x/AiC3IsmiaIS4Z1Vo7eicJAuf06j/HakGcLcYxK4/C/uRzw erFoOx61ivbgwZCGnbuPk+AP0Ff8/dqumuHtSJzg2rAKGFOu+aJBeJ9Cy83b7izhYTWL TlvXJlqcXlQ9vU8s3XQodyc9HgrrqN8Z+ELfenXiusOiffdu5MyCo1Slc32w0/a9lZV2 vj59kP7z/gWVZ4mnBGLn5Amk+96iKSuuDqUfJi0Qet6v+NZhIyW9Fp34c0783l65d1GG jxag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=UxADTBh4; 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 g7si15256993ejh.141.2021.06.28.19.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 19:04:43 -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=UxADTBh4; 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 95C148313A; Tue, 29 Jun 2021 04:01:12 +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="UxADTBh4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4ED7883135; Tue, 29 Jun 2021 04:00:35 +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 EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0610.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::610]) (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 BEAB282FE7 for ; Tue, 29 Jun 2021 04:00:20 +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=BohNnWo47r53tvyAgLbJvsWZeD9vvyGqiqL8QZd7nihQl/u/oHBTSKWaQuH/hC6lU3hsfTdK9uUTHzaPilHq/RDSfv19fmVGGTa+3N+Xnanwa4Ctr8K327kfBXAPCLykaxD2cFwXpEK0CPb56vvsqBlU7HBgOtkQoWYh1ObAFl6sOf44mQuoXxBLOFGdcyR/VHlQ7X4/iZF/yiD2vFKQXMlUiBmaLdAsbxljYDxnIyea6gPrR8mAD8meI1ICI/xcZaLwXsdefwepo3pNf2ZDXtKX8BgZS/xYbzmxRO9Rr+mz3Eg2ZN56VgvHOkCEAnJ+nYG2UMBDdHDBQVMGa46+zQ== 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=aVI2phPOjVJ4FVVtnG5spWbJ2xLZegoBzB5Y58o0g2ie4pYwpR64pZkvEMRe8jRO09CouMo4pj5Dg03Xus8FI4ShYvbdLjW6YqdCcAAF6hnF4u9Rcdvid4kptnf9nph+sDXED4fJoeUBd2e+qaBOkkkbS6ENWUkLW+fovqVmwfBDAlfjjppFfwgutDMV7fG7EF/9GzRRpanR2OG0u3R/WLm8TBxswYykww0sHydICI2nd3IFSB5iqg9GllOsXFa8mov0qaR0b95EidmQV4X3JCwiuyRNQYPeB1XRPBIfBG5ne3mAFo82DDkaJ2qBkbhkSggUn7dtVCT3VFPfAbf0uQ== 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=UxADTBh4nt7/d28h5L0kKOOZSHyaEA2oMSrW8x/hXc8V7Zg6rFuvJ1XYow3VIzu3HzoEId++nxHzl8EyrB1763rV5I2EbFfC75yXpaF1AhmtmjO3S8OFjHVtQdAtyDCgLCRnCBPzPlqYOhPVEr0BKkifN9is3sHh9QS7Fs48FeU= 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:19 +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:19 +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 27/46] arm: imx8ulp: add rdc support Date: Tue, 29 Jun 2021 10:32:21 +0800 Message-Id: <20210629023240.22394-28-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:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc7e5081-2e2c-43d1-8de1-08d93aa1a595 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:1332; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ju0XknCR3snK+hCpVnrTOEMLjRpqSQBRrSfBKZP0UfloEhTpDJw+xKqRdQipt3i2b1mNMoZywCP5Va9W8Ya2MbRXMxlnStu9wAuI1Te/G+FSxCasTxc0VVfAjw3uomgxVhadOHX7aHbvrSA7Wm75T0AzZPIZo+ON3O8Mfc5x+S4uRawvpcl94iO3UoWS209UsEv0Rhz9hTpZ+HF0k3Hk1AmeE+USCl6pLMqHS/6dwlr8vgb9HGTYzUX0t9OE/LJlAIOJpx7T6pmwGqV9akJT9LeRuRfOaDzTsyVj/ZtK+jzsXzkI4/GPftNaXqNW+HlaMs7xsTTjzC0CPr0diZwJ5b/qOQ+oviK2Fl3AVwQnKWvHG/yUtM98+3DNDY6vqCr/yaqcSES8Qb68jncZ2nIiq7K41jLdfKCb2dmVPEVuVyz//7HOjeiPzXwTvlrjuhGxnFzyY25TOJYB/QYyTYT0kkKBI69NbfWZqzsS9/WtcNAxvDUFqpFEK7QFSZOm6HRzrmqhGDuFQSHQKK5O+ntK9PHJd/6HHvM5T/CLelylzV57209RGK5WkJWt60BXLnEFWPtJP8t/Mwd/GM4AzzwFs6DeoesAuvEGqx0OAO4uuIlm4frmTJkQSX3+zjWtr+cxXCZcAtbaDsZycEKXXdi7flag5WHIKxW+0L95ZUuBcFWLbsoHI+L5c/wr4PjLuzqrPeyPHFyn4/8Gdf1pNfey5oIgymhxArw4wCxdv96EXAI= 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: 9iH7Je5eLpl/fNEjSq+I73QtdXBekOSx/5LfR3S+9loFUVDWD990gxOXPwjeLYkzhQPLlKcpmN1ZHMSl/vPljOT41jdG0ensUTplUVJB2id2waztlOJkJx0FZX9ED2kWGMm9O66qJfYB1C7jiYJhYSJR5vmmpKlW0ExTKxqG+c5FUhvziRIGsnRkc4w1J+QEhp0zlnSEffAMEkpV+9ROjHvDPha3ZPRU+HSwRwZVq6wlwKpg0pWutr7r/n1IFfEFJ8Smg/TR6+5jVjhhlrqpWIuZEycmG48bgFIRjJH/mm8NiE+PgJ52/DK9cHiZnnzw47MbqWs5nlKmMutbVR2gAeI4TKxqU8ThibegKgqQe8fKEptG5ioCbI084g4UUHUTQDFmu34NBneyFIyW1sGcHy1mTgoTbAH3/UZBLVNxWR9tBSz+Lhc6ZvMkJFcGR5SyRRTnYWa5kpMX9mkJwSkMG+YKYIoRUGwpH0pXPLB4ZOxYxMMyXgvN/xAx3gPYWImBVoV4n+06Rkjohv72aoI48tLPam+1syHcHqNzV/csqVBdJYd5QHuiHtBCqrefbEdIF3Wgz3CqCafg/bzlo2DWIwEwDFXFHU7qoZn4r8be8S0pqFl4eVkfygNm+AygxAnEDAu4CstmfNdnJ2imHbcOux4LbJppOlpGUcszrTBf7JsKeHXqo14MPAw23N6ybZvcWkut9Y/oiGDCle7ycwGxrebNRUTjQkSpBfbRklgapPMrqxCVi8UGTTLp1f9SD9Ae8ZhC9MkTgIWi0ADedInbX4ymu75wINgUQNB+zC9QHhU7BWj5h0jzXlbIAk3g61EqYuZncFhLJNs0htv8dqdVUOUzJXKIgIg8jMPc/yjlhA4t3cHScdkO7YFoLFCY5sNhTFqRpnTjAIvqo69RzJoDIJK2hQzY5+xIIHle1bFd0YVUjE/bRAym3qb+loKrqdckXEBgrYAzcdLNThSPR5tPNiT9Mg6Aos7qexB6rgdXCUFGda26LFb0iIwhBsIJ7f1PioCkdUmgcaWcWCzeb8UeqlJbFYtKUwXM+WiGw6ufL3dTMVy4JSb+GI3taBIJMdKeP/2jJy65t1NJ6awZbuRBTafQCpwk6cPxSW8yswxMP3w0/POwfAcVx3PJSH4v1smG0vNvr8fO47j1afq9D40Q5XnUa4MU3/t8rSXgQ+4Qp2/6dCcIkLkyQft2kV6k6Z3KmsVpLN3zm0YMWgVYu8/1hnhcWFLAq2++RLJQYYopyf2gtL8g4uD9lI+tGDH1MUfvivD2sASbngjCPKdKoAcZT1xrRQrrUrGmFfsCuMWDLb4DfMQ5eDSPvugr8aiKX9cg X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc7e5081-2e2c-43d1-8de1-08d93aa1a595 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:19.3712 (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: pq55fzU3msxsdjiNepOslObgWufKUllcxqyF2MbcNggLt3VUcOB6VVCL5diGqAU/3Egb0MzlpC9o3tHZmttXjw== 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 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; +}