From patchwork Wed Jul 17 10:23:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Bansal X-Patchwork-Id: 1133231 X-Patchwork-Delegate: prabhakar@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="le8n16Kv"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45pYJj0TbLz9s3Z for ; Wed, 17 Jul 2019 20:23:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id AF0E9C21DDC; Wed, 17 Jul 2019 10:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 851F3C21D4A; Wed, 17 Jul 2019 10:23:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4D3D5C21C29; Wed, 17 Jul 2019 10:23:43 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80071.outbound.protection.outlook.com [40.107.8.71]) by lists.denx.de (Postfix) with ESMTPS id C5F92C21C27 for ; Wed, 17 Jul 2019 10:23:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gxa+QEulwbbGXm4K+JImgJLOu2qQHx6w4B68dCkxg3WOplsMQ8Cbbu4+xcrflJ+m59x0e1SgDzZ6bg4DfZ5Wd74k+TdMUl3PccLKNljHuA0An3KmReVZy6IsF5OjM/s7T48DJagH7lMmkk/GFbIQMKF0IkpW+hL44h9Y5TbQu+chkqBAA17IVSVJtK6ElQTdfANFXWK66NOfo6X2r+iro3VpSt3/ndynvdYYi5XHsUjAMNTa8uogWL9FjykXl79WDpOkgf9jHzc8pPUQ1rsDDR/CJ5Xsv4nSMEWpEz1/T90rzzoANYDzsBHPNJNwPjqsqZEOQPFACJNoBqeatKdhbw== 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=H4BkGc+neWUT7VcbScMvlzNs1Q2rXvczk5tqqeHgGGY=; b=gFmtug/aZHBef+rLMX+OYLjMHfdPYBqWjTmihXZGkERuNCj+X9pitjB9urIFt2MrMVuNx4m9cJrHlv/qB7E1hZZ8wncNLqw4GVJZjQxD5bcHyVRERyEv2I6FCOHF1Qw81KNrR7S3pDnlEtksV9/Yk1nowOzsjfuYxMsCZoPDdEqJppYxv+JvP38QtElMKEItFV647O9CN5XaU4rZx42aOrhfdY6GBGrd4/sJRA5VCtLvyh2gsWwbP2GDI7htZ+f6U6M8g5MGfcxSKyd2JFPG45iNDYgx0VnNdYBn7ezk4umpYMUDSpzqQ8ohfqdO8wY072fPsVk1fkCrWL2cqjRL+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H4BkGc+neWUT7VcbScMvlzNs1Q2rXvczk5tqqeHgGGY=; b=le8n16Kv0On7FdHr0hvvyiJB3oyphpSSiciYzAa+OOLW8+/l3jVj4bLV4Gdnlgq7iOeeUHJn1WfL7nlNY+UNgplhuaGRcYhh3wAwGNoek+3MxN7oNgynXyeRjKwhcq+GC0ORTTOVQpThjuGD6DCemEwLTsLCwjKivE6ZZIWp4Zo= Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com (10.168.65.10) by VI1PR0401MB2430.eurprd04.prod.outlook.com (10.169.134.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Wed, 17 Jul 2019 10:23:41 +0000 Received: from VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::6c7e:a751:af2:8d78]) by VI1PR0401MB2496.eurprd04.prod.outlook.com ([fe80::6c7e:a751:af2:8d78%6]) with mapi id 15.20.2094.011; Wed, 17 Jul 2019 10:23:41 +0000 From: Pankaj Bansal To: Prabhakar Kushwaha , Meenakshi Aggarwal Thread-Topic: [PATCH v2] board: fsl: lx2160a: implement board_fix_fdt Thread-Index: AQHVPIm01Pr7Yf8gRUmxDUC7EF1Ngw== Date: Wed, 17 Jul 2019 10:23:41 +0000 Message-ID: <20190717154553.25482-1-pankaj.bansal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR01CA0129.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::23) To VI1PR0401MB2496.eurprd04.prod.outlook.com (2603:10a6:800:56::10) x-mailer: git-send-email 2.17.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=pankaj.bansal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.69] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1718cd65-817a-4f5d-8c9f-08d70aa0d6fc x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR0401MB2430; x-ms-traffictypediagnostic: VI1PR0401MB2430: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01018CB5B3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(376002)(346002)(396003)(366004)(199004)(189003)(53936002)(71190400001)(71200400001)(44832011)(4326008)(316002)(66946007)(102836004)(6512007)(6436002)(99286004)(6486002)(6506007)(2616005)(110136005)(54906003)(66556008)(64756008)(66446008)(66476007)(476003)(478600001)(186003)(2906002)(25786009)(36756003)(486006)(14454004)(8676002)(3846002)(6116002)(50226002)(81156014)(6636002)(86362001)(81166006)(8936002)(52116002)(26005)(68736007)(305945005)(1076003)(7736002)(386003)(5660300002)(256004)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2430; H:VI1PR0401MB2496.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: GDSxYgvAIMXtMjznBBjmISkD5QxKungjv+rqbCGtkoEmeAoTwyPcUo7NH3+fCerxrXfP0VDSnkn2jz4kAA64ViYvpwYTbA/cuckk42wG/CgKvNki8sq5xCSyGMj4DpSP4PEUj90MK2Zw4BIqNWBgFVe9SwaYbXjdq7smdKV3rvoMyfUISjiWMd+Zkn+6Au997kbcZQ/oKyTq7C6l79ujVC6V0UC5yYD1QW0P+OBXRtEnpI0zQzypTm5La8KhnWCJr2V/wO1Ues0mIohskDc3qPvfNw67lB8a95Er95EaV+yBAuxOG7TiNjk/X/y5NWIbeS5KlTFGwSB7/Byz9AGfVcfJDKE8J+2QQyx1pcWLpt6FgT1RRoPdlzZTYPrBoEy6zwf/zAbkWa0WOTMzw8dXCk1EsFmDhB04QswbGqRyMiE= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1718cd65-817a-4f5d-8c9f-08d70aa0d6fc X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2019 10:23:41.6246 (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: pankaj.bansal@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2430 Cc: "u-boot@lists.denx.de" , Varun Sethi Subject: [U-Boot] [PATCH v2] board: fsl: lx2160a: implement board_fix_fdt X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" In lx2160a rev2 the pcie controller has been changed. Therefore, we need to change the device tree nodes of pcie controllers so that new controller can be probed. It involves changing the "compatible" field as well as registers names'. we are keeping same device tree for lx2160a rev1 and rev2, therefore we change the device tree nodes as part of fdt fixups. These changes would only be applied if the soc revision is not rev1. Signed-off-by: Pankaj Bansal --- Notes: V2: - explained the patch requirements and patch changes. board/freescale/lx2160a/lx2160a.c | 67 +++++++++++++++++++++++++++++ configs/lx2160aqds_tfa_defconfig | 1 + configs/lx2160ardb_tfa_defconfig | 1 + 3 files changed, 69 insertions(+) diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index addc829e5d..1182c4a1e6 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include "../common/qixis.h" @@ -108,6 +110,71 @@ int board_early_init_f(void) return 0; } +#ifdef CONFIG_OF_BOARD_FIXUP +int board_fix_fdt(void *fdt) +{ + char *reg_names, *reg_name; + int names_len, old_name_len, new_name_len, remaining_names_len; + struct str_map { + char *old_str; + char *new_str; + } reg_names_map[] = { + { "ccsr", "dip" }, + { "pf_ctrl", "ctrl" } + }; + int off = -1, i; + + if (IS_SVR_REV(get_svr(), 1, 0)) + return 0; + + off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie"); + while (off != -FDT_ERR_NOTFOUND) { + fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie", + strlen("fsl,ls-pcie") + 1); + + reg_names = fdt_getprop(fdt, off, "reg-names", &names_len); + if (!reg_names) + continue; + + reg_name = reg_names; + remaining_names_len = names_len - (reg_name - reg_names); + for (i = 0; (i < ARRAY_SIZE(reg_names_map)) && names_len; i++) { + old_name_len = strlen(reg_names_map[i].old_str); + new_name_len = strlen(reg_names_map[i].new_str); + if (memcmp(reg_name, reg_names_map[i].old_str, + old_name_len) == 0) { + /* first only leave required bytes for new_str + * and copy rest of the string after it + */ + memcpy(reg_name + new_name_len, + reg_name + old_name_len, + remaining_names_len - old_name_len); + /* Now copy new_str */ + memcpy(reg_name, reg_names_map[i].new_str, + new_name_len); + names_len -= old_name_len; + names_len += new_name_len; + } + + reg_name = memchr(reg_name, '\0', remaining_names_len); + if (!reg_name) + break; + + reg_name += 1; + + remaining_names_len = names_len - + (reg_name - reg_names); + } + + fdt_setprop(fdt, off, "reg-names", reg_names, names_len); + off = fdt_node_offset_by_compatible(fdt, off, + "fsl,lx2160a-pcie"); + } + + return 0; +} +#endif + #if defined(CONFIG_TARGET_LX2160AQDS) void esdhc_dspi_status_fixup(void *blob) { diff --git a/configs/lx2160aqds_tfa_defconfig b/configs/lx2160aqds_tfa_defconfig index d68b40de3f..0eca208020 100644 --- a/configs/lx2160aqds_tfa_defconfig +++ b/configs/lx2160aqds_tfa_defconfig @@ -9,6 +9,7 @@ CONFIG_SEC_FIRMWARE_ARMV8_PSCI=y CONFIG_AHCI=y CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_BOOTDELAY=10 CONFIG_USE_BOOTARGS=y diff --git a/configs/lx2160ardb_tfa_defconfig b/configs/lx2160ardb_tfa_defconfig index 94f58a832f..dedb6c747e 100644 --- a/configs/lx2160ardb_tfa_defconfig +++ b/configs/lx2160ardb_tfa_defconfig @@ -10,6 +10,7 @@ CONFIG_SEC_FIRMWARE_ARMV8_PSCI=y CONFIG_AHCI=y CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_BOOTDELAY=10 CONFIG_USE_BOOTARGS=y