From patchwork Sat Aug 7 08:00:56 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: 493379 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp1030408jap; Sat, 7 Aug 2021 00:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJJSb2rV8FyZtNaunFBhQydaLnscPTtzItMhcBq0s3UwPwAKF6gFwqWl2ksxkF5Df/6CtG X-Received: by 2002:aa7:c782:: with SMTP id n2mr17682732eds.77.1628321541340; Sat, 07 Aug 2021 00:32:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628321541; cv=pass; d=google.com; s=arc-20160816; b=IpFTKJMh/2G+pGqxq0026Yxf3z0lFGS3mwP9QK/8SzwFLf5oaiEgxlJc36orK5RjvT fJZvTYZS2+um79aXKT3Tdc1LdfQQKZlB8KwuP93gxDwioUvB0pRkbtBBjfNMcNYc0wwo HteYusHHwAF39cdet2v93ISkXH7kW3mLMI1+e3eBLzRvJSGzcq9FIg+GZHaM558zq7jN zPh6cCzmrFyWJPKsFAt9T28DFQnM1nb38mnvbzttOC9aBANCQRLcL2dbP++L4b6acNdJ oaG55U/GOc6Da6PP5BKqu/A50/Zb3FPR/JC3A46x+vBqcQzGiRB2TTz9li6CqwUgddgi i2qw== 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=dUXldQkdI5KxeeA1Xq9zne1xiPuH5KmSc782BvKEZZPCwX81AcLBLFkJjf7ObP0SaY 8oqEKF/2lITpO4/L1BYv8GWn3im7sz87ed5PNM1KDzy3fl7RCzTgB+HLv7g38XfblEMb 0XM4xFwzQG5kRsCTCnrGPYtBWFW/AD/AEO7u+x2hJOtDlul961Bgn3g7zAIp6rfoIjaZ KeZwA59QZDKHZEK8up+xZKK4xMXdCjLi68uOUduSQffTZLAK4j+wsOKoJp7+ma2kGnhX cuCI4fby1T+ym7GYjj9BZJUVm8Jq66sCMkGbVHKHXFxUggucRbR4l7kLtkwP3+pnSquC n+XQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=bSpzinsH; 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 a1si470544edr.277.2021.08.07.00.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Aug 2021 00:32:21 -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=bSpzinsH; 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 04767832AA; Sat, 7 Aug 2021 09:29:42 +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="bSpzinsH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BC2C8325B; Sat, 7 Aug 2021 09:28:23 +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-he1eur04on0602.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::602]) (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 AE97083248 for ; Sat, 7 Aug 2021 09:27:52 +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=mJxtF7PIuIZQpfgtReRmltch+KudkXqjlT6iYcOmxkqsMk9u0BkZ7opsKWSVN0DT51StOZcgpCrkl2Mb/ftyo2jSwTwma8maXI/e3xywIO/qF5kcP72GmjKSjIjCVZrwl+89gHI2MnrNytpJxYQJfANUQLlb+T/Z9Zcz29et4NYr62Qpn1EpayE2zb507JvgtrBvSxnYZbBbfaiTxU1yEI0DluS/YgvRwM96jRwz+RvBXUAnb+1s36U5HT2+Fc9JwxvyF/RXM/DCPUHNY0BWuV2tuYqztReevCcVxdOi/DgTbRlJmogvujZrxU5hGnViS2oT+9FfNnGUKf9Y25b0nA== 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=mG+ADwn/T4s8qvS3xJppXVvVqcm58EobThUv4ldUMG4M4DIPp/ZFN6Cl9+SKiVjXnJsCNzqv2ocYwXVmCcj/NVW7BR8DYmFw0uMLAAcDp/BhvjQLFh6qp3aBLexA9rqFkGM+o1ifQ8buCHxVJx87csiGCcjCTxnNt8mOeTBpDfBH5TwHPej/lXuANHElaI3SFOU5bFjlnIYHbzX5Uuv/sYO8vsKozFvw1WKYFXrEdU8kv89nhKuErHxH8pejb5y14973s2f8JfJrZJ2PLuFmqtQSnP+kIXwinFWnb7BbY3eCKjG8ujDgpjSXXhmw/GttgC+FyamlmZXa1lyTPhozog== 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=bSpzinsHoxaLNW9YhsKoxXwCYAxDi12xZ/xly2w5W7AfosHYVfdGtD0hgsGZht+s+8yk7S/vDsgUdAGV9CfU8qBj+09hjfGjpORJvdAQmZlUcPqJZEAQLNFh768CD9hJ4pK5MpFJddBiek8o0twuRUpQ7bAiB/wni1b2nM2a6jk= 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 DB6PR0402MB2758.eurprd04.prod.outlook.com (2603:10a6:4:96::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16; Sat, 7 Aug 2021 07:27:51 +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:27:51 +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 27/44] arm: imx8ulp: add rdc support Date: Sat, 7 Aug 2021 16:00:56 +0800 Message-Id: <20210807080113.16020-28-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:27:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d753e60-b736-46a9-b6e7-08d95974dcea X-MS-TrafficTypeDiagnostic: DB6PR0402MB2758: 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: Rz5IfsU+Bs/P1isAPjPb6GIyyapHeXju5PTaqkosZOy1ywNMZH2+y8/2NKp3YIAls0QLlBhJ+ZgngAZP2q81QCKyFVzJ07YoZwEihAa4YVT/zG5lv170Ayo3J1qerCKGuTqEqRLWhlunqb+/ndN48tZtKUkc9XypQcAMC2KtjlV5GzKmLS67I3wa/9+KvXs24rZteeU9BCIGX09bu/T6pRWLRPvzeLeO+Pjwk+tlS5N5v5bnkhi7UtfVhsu1GnzZa+J9NMeYT/174IwI23f/rICSzdaIBdNBZMhWGYrzWu2HU0XqAYWjGS59rQfXuOM1+7apve+/m85YjFlW5Ypa5GoC9k/GS63Hb5eqvC7DyWAMt79gFHVdudkkZ11hF/xswsdC+w1pU7Dg5gTEinMgjEV1Yb287vI4l7wsDRvMDrlVuTz3nX7Tjbsaujt+M5zNTK9Q5TH5UFpCSJBLDrt0RxBGXmGHEyMstRXSiz10XqY3JDEop+XG59rKCXBxLxFCmGzpjTugh8ZUVmQB62hSYmRvuYHqJsa9y+acGz4+i8hLIfk1tGjO0bWvpUKNXMDaAqFtHf+CY2Mux0VCX55FUzRZHwcjnd5NkoXBu5Rj7pZDJQBX5vSr+dfQfPEuQDydRt08YbN7gvGZoPSXVXXw7UEemx5qNdw9d+RvMUGxxJUGvzyBJEqoJY9wduQKNSO72RhDc+q+l9gm6CY/wMJGz9ntqVrpeEGSQqeTptP6MzY= 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)(136003)(396003)(39860400002)(346002)(376002)(66946007)(66556008)(66476007)(8936002)(52116002)(5660300002)(6506007)(4326008)(6512007)(6666004)(38100700002)(2906002)(38350700002)(2616005)(8676002)(478600001)(956004)(1076003)(83380400001)(186003)(26005)(86362001)(6486002)(316002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6tKe9sdgmbw3Y0zHHaNbz4+vRhs9OeD0rB5KoofGEDihJTI1GlUd5hDS+4V/ue+rkRl+k4ik34JXV7WGKBWlfR2zhh8qx00/rfChlRUQzhUTnwoLFhjdIEXqHT965Ts83pcECH+OfjvVzRn+3ur95hNIVpFYXIu4oPerF2CQ2DJSe0Nybz0Z77lqZu5/3IWyMNOMM6W0C3KXodsFcU6EGrlinGgf0EFcVgaeTVoUF4U/xAln+WbPrimKGT98jSJrhvS8kUMdrUebo4aRxV7nFvdTf5lbWRJhjf3LbvKBZ+lFw6nTJCnvxIyCoj21sOoyB9t10o13hI1YXE++2jNAZqIAig/okOs79S5v3xD3+zxV+D/yL7/61BELxjAorCVF13CDf/jSelOLtkZFweihrHsNTwujAHLHPcFBEsgY0Silz0j1QOQ2Jis8tU4SXVzRxlldemTqz5P/SVMGkcbl2Ps5dsntBOPIy+kcNMvSAJvlC+EndzqZVy59wbY6c5ufX3Q/jYgpr2HLQ8GHTQ05o08Iok9OSeUvMTlGRWrGpjrzNTSDK8Hmp9dwSIW/6e16IFKDIjjDc5F5Ns69VUd3RK5Nnen8dI7TPYKGJhIJJv51RHIHaXkA7GC6HDqZ5Zm5d/JT+o5X/NlJr/3fZhte/ii+6SkcTnOflCHqm7ohx0xmwV56T/4QgpsqAcUgS9HI6bgNi/BASUlCohCE9FRZxnMeVcB7yDsdUWHlTeebV9hLxcD3pmC4DKOmShXIpwPtEdUitcJQPgY9wZQAy6HL0JwdF+SgCJZ5s+4aSFinKkE/Ovb672pV1PvgZ+LSVEBzOE92j88j/fJ4HstMvj0RF/k9LhAoyNAdNkKDwtyxmZCXufXWM6euls+XVvJRR2I4NTiKEh4jsQ2LIvMCYOmeu9DtFmZzXiQbCIKngFO2Lhl1D/Pr+G2iPR+y4Mq8bE9Mcy4LMxmb9i7kUEYvxaiu9GgulTwVrIOu+bYQ2rA7fglTlgUyYqkx+dj0Xm5y5j8H8L0ZWTj8l9N8OMdoEoQh3vHXolXWBkJ+yfO41sTtS/Z0PPchi40HTmcffxHQmQJ4sEssnUwNKHnaUQ5wSgT5pjv9dIiO3FJxFR3l66ra3O0yPwAl7iuBW7xJLHmbuw/JsTHJc8ltuCvP0pYZbiXXzVHxYsszxVXQ3DKi/IOsLVWjULeq5Ojhf6Tiyb1ofUnMIcZFQSrUwO/GCHJ2cqtSxeBLkkajfEEGbihK+19r6OKuWVqmbyuETb84iaPwS/+QKl4kbgoMoyNq01m9FuzyW4yP8vuXxt04opxWRupfXHLdwv/+DE5/rkLdfHjcWnho X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d753e60-b736-46a9-b6e7-08d95974dcea 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:27:50.9153 (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: 6rS25etWiGKSBAvZL9QRDkNOyANwLndMze/QSAguKmK2dQvqwr7lKK2OkAri+xzlRSb6xfc3l9ev7gpxPhhMFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0402MB2758 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; +}