From patchwork Mon Apr 12 12:12: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: 419544 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp1661150jaj; Mon, 12 Apr 2021 04:46:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2fmU64MzrXhrL6B49n1ctdhpggtsoinS0zISsvD2YrntLDd3Enjl3qVPolWojHxuoG/ta X-Received: by 2002:a05:6402:26d3:: with SMTP id x19mr29195681edd.349.1618227966097; Mon, 12 Apr 2021 04:46:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618227966; cv=pass; d=google.com; s=arc-20160816; b=dnxCn7Ds2ibkb43WKHylFJhA9Bm1i6/Ud3E9P0AN4CFj7aAUeta+4X4YQtSOTERL00 z9/vowvgS4tkQdONqPbeCWh0ZoJOUUNIS6/QONTBulNR7yhOJPsmFvzHuHQbSdkHb4T7 O+YZtlCUlYu4xxyv2ShyZK8DN7yO7LyqqQHMUzoXw8pH8Yh4igxk0swA4mq4vFKk/msA DEivVpVC0wQaDA1W5dAtHd1f94FAVoygLm1/6f4Udsq2f59CzPeEsXXPHNYunMWosz2R anZimITw1FsM0zRoIJHTIY/bEt2ykhBkTWdQjlNTtT0Bba/rJmcGyFDeK5Z8WuX18AfK XZ6g== 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=uWr+6dQMk/lPIT+TbaYcwZijWLaTtuIjwWtCy3cpI6I=; b=R8U4ckFk2b9FV8zGOJVDAEBBgmILbEp6sEXaZ0dBQ/pGqpJlif2NeGVSdIA5V+pZpH 4GJOkzOeOtr3Y6+IJMZRPwgqsdfHfLFz4wghIZXinD6bwW3gsicox8h9c/K51z5YsVIs dOsE3RZEH/yM9JiOkLhXldjzsYDPqMj7//+wTpOlqeUWH6pNhLzjg5PUc9vct3X8r0yO Tx5JYPdxRrXtE6Vs10AYfd/Jz5aqbpQRR1JrdGG1FMk/nfIFSypRnEbexxjgjxpRykdx Pmwj7PbLx1wr1RlzBGb7L1/I5YJdSP0HTuSARjHb7TsRUm1Xjog+eskseyeMyCcS5b0T psFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=mNsjNUk8; 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 f7si8232907edd.474.2021.04.12.04.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 04:46:06 -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=mNsjNUk8; 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 5277682028; Mon, 12 Apr 2021 13:45:13 +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="mNsjNUk8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2537B8209D; Mon, 12 Apr 2021 13:44:42 +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=1.0 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 EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::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 3C20D8203E for ; Mon, 12 Apr 2021 13:42: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=Vsv7D+ljwrjxc5nXvkORlVEjTnW4blsBtriCZilG1V4Yeny+Ip1m5t7uSnymJZQCTZmL53np8H36nfe14JXbv6jGzLrtqceq95E2dLwWHDDFSu1JH8Zvgm4Fodoe6UG+9HVjhUplq5/feFkYydTy+okskmMpsTwdfci6EF7w7GAISNvo1TBcqK0Dm56po7OzhgQ8hK+q/PMHwtYTMkRklweDbnKY8UoGpXkuMv8oNGnvvCZVlNnoVHNqjc2sFe5niMTRzvJ8DhfIjaWT3FsVhFjUmVjtb2OJzEHdxjxY/y1sDkTwMnqx3s8HELM0HgMqhe1SWsfvl0rcrxKIS46TKg== 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=uWr+6dQMk/lPIT+TbaYcwZijWLaTtuIjwWtCy3cpI6I=; b=IRSE2DbSoTbKeTHpjiOyNMh/KOlLn8X2kw6yxeCpXlSVrp5lsb86tR1xK/5RtC9+Tz3jLS008S0/+PZSbsDmqzJXGlldMrKBLFrYXGYIrxMKHOgyELFAdAGqqUqe5juUMCNI+fxTINq20/+K9zEUyjKEZ5SG5MXd11v+Dfo5DnuVQ4PvZDpBrLxcutXJx3FQTEWLUEXl8EGOhV8OBNIr4nUnKxmB30UdlTMwq0CuO6OmVi3qxunW89ACml3Flh2hQQElaMSgSRWcQGdQIQSlgBhEyFtrESxfeeB2vAm3TTBIJ/m0ZfPp5Hkm6ZBIlP7mT5b30IBhlfKGhj999JCV+g== 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=uWr+6dQMk/lPIT+TbaYcwZijWLaTtuIjwWtCy3cpI6I=; b=mNsjNUk8LtpMWHoyP5tfPAK+Wf/3CT/Rvnsu4DIYatVgIdxlkKmNSOKl+lQu28HdV/lPbMQa7EaKPqoQ1OM/+Fy0SrUZzEx6dQhbl61QvvmRLPOto8elnfCUqedtLXGUA2ajREqackLZV0n8IBCCzFDAt3dwkhUR7dElIjlnerc= 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 DB7PR04MB4233.eurprd04.prod.outlook.com (2603:10a6:5:25::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Mon, 12 Apr 2021 11:42:39 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c57a:6964:f72c:21cf%11]) with mapi id 15.20.3999.032; Mon, 12 Apr 2021 11:42:39 +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 27/37] arm: imx8ulp: add xrdc support Date: Mon, 12 Apr 2021 20:12:56 +0800 Message-Id: <20210412121306.11484-28-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210412121306.11484-1-peng.fan@oss.nxp.com> References: <20210412121306.11484-1-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0009.apcprd04.prod.outlook.com (2603:1096:202:2::19) 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 HK2PR0401CA0009.apcprd04.prod.outlook.com (2603:1096:202:2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Mon, 12 Apr 2021 11:42:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91929db6-7de7-4dd8-c030-08d8fda81342 X-MS-TrafficTypeDiagnostic: DB7PR04MB4233: 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: oUgxpCzruuAS/tEBkVhL08icviCYo7QVZQWeOSwvjHsSJeX1gdPUefHg0JgKn7fGG0EmcT+YgCVcxRO9V1kPyVT46UPjRYQmFZZ9bO2sP0KgDT/L4bq9O7YVW7GMBF93RUtS8dxx2cGfmUy9y5buhdi0kpA4WhXsqyAJMzV4uc0Olz6aj4dkQ7AUYMVfHWbmeZIy2jinwWLZpSAEcLRtDIMhXNAa62NOXKjnhn+I6aqOSlGrSNT2sU7/la5LQpbmA2zdBQmGwYXrauPZUJt0Bg3Z6y1nvOXlPzzLd5mYmKBL/fO2awYHaLov+HI2wJEwnBIGBc9YqPV3V0hGDvo2tX/9GAeE99CL2rmXISGIHSTaE71d0u68yPB/gpyuSrDviec2It6Bs36I9WcgDu9ABIfuGMgnZvhMdgr1rmtKMzzTkbzF30R7ofC4KXCOyJy0vMydgyCxbVTjysFHPsp5o6u8TjSN8cdpWGS3XS7AMba2m8OYL5YjBWyMmThUJpOkelr2LVZEAb9srg3M9ksqIB5Y5MQkytaefV7xdtBUqc2MiSOMBotCaJ1WTsSagYI56wlr6e3BRA+B704si/jXDJpRqriist2rCc7XiRaj/KYUYW4jvjjXRGApcwxi3Mjttiyi0iKE7/II6nSLoXGV58QiLMNHtanCfZ8sOK2nKhs= 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)(376002)(396003)(39860400002)(136003)(346002)(366004)(52116002)(83380400001)(956004)(86362001)(2616005)(6506007)(66476007)(8676002)(66556008)(1076003)(2906002)(4326008)(16526019)(316002)(26005)(5660300002)(6512007)(186003)(8936002)(38350700002)(38100700002)(478600001)(6666004)(6486002)(66946007)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kFNrJopdGk+1jeIiK+neRQ0o/T20dZ1+2CaUI9MjaAejJUQtOXL7tOnooh9zfgLQMbJPRhRCedDM1+6aE2e+paFq4f0C9T5mlbYmPSb+tz/dnbcYLg8K+gF5F47qDz/BFfgYPvXHYN02v1KjT8bajlLxmoLu8eAI5isNlZIPwRYsVyyiTlMwSyauL545qEeA8bKioNiJZ//00APRs9GwzHiW461hFuIBGYrJaQo5qZ0peN8/mDlIoMM0jEHZyX5ygaqYIt8rIbh6D51/20rXkNhW9dp43Za+0ZY7nAcIqa3EVKMKAMpURgl9OTw9FxWUVkkLqY4eEmRLwKfsJ88ENuic/A1PODxXo2/DMrqGSkzX9SgJ6ebO42YE9YZdgMRR1KXU1Ly4kcyWq/82j0QK2kmi3ZzxlpDSAV4Qyd3q+C/sE91Q3jRqQzIbnbuxkSFovHgKbfEV8qjFxI86noyP1vWkgAVPovMbCYoXcC0e3NSQ2H8h6Oz5OGVLU4hXu8x82YWu01UVkz1IHLzH8c7F5LnV8ZoUjUArx2BY4hzpxGXlDX7n24/cENif2KFBWBOQDYoYDEQ85Ub/mGtbDI6w1NvOfRwA2/DpttUqx+x7PkwAKN0XcD2ef1mfyTb4apzWQBB9/m7vuFP57sdRPVztDwwpXjKiZGa+kTKt/+wsHXBAsBrslNgtXAzaxhp0DfqASaycctAmptUdJDLK0+mjktRXA384Y0VdVQSknIwfDDEilUcasaiZPAUHIfb6FwX9vu6Kmk+kavvh4z2Lfw89Lag45HvTqY+lvrn3rgpl//ovuQUefHD/oU36Mm2LmTIqwxa9bVfQHYk7ck6zMwqryao+v4rtcF5XfZU69PwCj5Pvs6lvBvN5HI1F5cWFX2b6NxxCp/hr3nKNw4ltDEbBx1uemr/eUCeoOBuviIIZZvPC9uE5y5yqvRqAK9zr0uVkfiiIBJJ/mO1THt/11BzYkYHSK1+QXNfwMuvEpWk4yDNxmdSl+nA1L41/RZoMuqVOef5716w7APDax9fNvMKCI6NcUnI8IOwLWcR7PWWM4vSJ/aE3DFo9SqnNeVA1qleks/wd9OPKlfEp45puZdU1BvKC/e0gUGuQuwyoEfe8Lpp/XQVA1b6pvkm95FPrsKdoWZrdZweiP3+dJDlBkszHxQ/wA4incEWm6TK5qzPzAZqr48NX+mvLrN1QyflrBxxPZURDWzgqUwdIToAZgHSh75ICq/wpIEvt0S+Gp2MkAQ4/CpX2Lk9Sa38emRfJmk3hEIzRm6lBs5DiibempK/Hi6TdPBBMJFsD18NTatneRFote8YT2V9n7RFtfr4g/LpF X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91929db6-7de7-4dd8-c030-08d8fda81342 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 11:42:39.3599 (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: odCRUsxBKhnvg/rctPqW/C1NhzJctHgUgs8oM49YVGk9SLO/HRbbpLI+VRlHgePn/a6VNgpX7XIfZs/3/K2yTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4233 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.102.4 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/xrdc.c | 144 ++++++++++++++++++ 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-imx/imx8ulp/xrdc.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..453589e6a2 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 xrdc.o diff --git a/arch/arm/mach-imx/imx8ulp/xrdc.c b/arch/arm/mach-imx/imx8ulp/xrdc.c new file mode 100644 index 0000000000..7a098718da --- /dev/null +++ b/arch/arm/mach-imx/imx8ulp/xrdc.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; +}