From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.38.62; helo=nam02-bl2-obe.outbound.protection.outlook.com; envelope-from=vabhav.sharma@nxp.com; receiver=edk2-devel@lists.01.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0062.outbound.protection.outlook.com [104.47.38.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9BEA0222447B7 for ; Tue, 19 Dec 2017 20:37:15 -0800 (PST) Received: from CY1PR03CA0036.namprd03.prod.outlook.com (2603:10b6:600::46) by SN2PR03MB2367.namprd03.prod.outlook.com (2603:10b6:804:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 20 Dec 2017 04:42:01 +0000 Received: from BY2FFO11FD007.protection.gbl (2a01:111:f400:7c0c::118) by CY1PR03CA0036.outlook.office365.com (2603:10b6:600::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Wed, 20 Dec 2017 04:42:01 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD007.mail.protection.outlook.com (10.1.14.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 04:41:47 +0000 Received: from uefi-OptiPlex-790.ap.freescale.net ([10.232.132.56]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vBK4fsde019373; Tue, 19 Dec 2017 21:41:58 -0700 From: Vabhav To: , , , Date: Tue, 19 Dec 2017 22:10:08 +0530 Message-ID: <1513701611-19990-2-git-send-email-vabhav.sharma@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1513701611-19990-1-git-send-email-vabhav.sharma@nxp.com> References: <1513701611-19990-1-git-send-email-vabhav.sharma@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131582185079387441; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(346002)(39380400002)(39860400002)(396003)(376002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(110136005)(5660300001)(54906003)(16586007)(316002)(2950100002)(6666003)(15188155005)(16799955002)(2906002)(104016004)(8656006)(76176011)(51416003)(498600001)(53936002)(966005)(36756003)(48376002)(47776003)(50466002)(53376002)(4326008)(8936002)(305945005)(6306002)(81166006)(85426001)(50226002)(356003)(106466001)(105606002)(77096006)(575784001)(86362001)(2201001)(8676002)(81156014)(97736004)(68736007)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2367; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD007; 1:5hb403ALSH0SLKxe1t/DQ94j4+9AsAFbyHIsNqWeupzVNC6C2Fub1SSXK73cOYIN++I4Apvo+Hz/i83PnjPj/mCzqRJ2FrEFs33x4Z+dhehmJ9IO72OgXyV7DgAyF0ib MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: a3be4023-63f3-42cf-3531-08d54763fae4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603307); SRVR:SN2PR03MB2367; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 3:MHaQ9Cv9u15WhPUccTzVBCjgSGaH9rgn9AtyL0c+1Uns8vK+A7gUX8BqjkgP6EZxSQyW+R7N4q5EK8RJpPZ7MSnkU92jYbQz/s/W3b5pTW+x4SK68bGhCOjGWIvXLjfsnngmkWnPmnLogHMOsuqlLDwZyQVquC3DZh3Zn/ck2bD3T5JwkgIuEj6UM/RzSJuEXgda09Wu/ugQO00OWtugX7VN9378ikA4g0Di7sinDDQkxDmN/RQw5VA0ofS56HpJRy5Gwq67myugXPyEiofHbb2v2VZEnZzI04kapM/6RL1ZX7LCy0QwOiHuew2P57fWa7NPm7Z69LwRNAu+3EJ64MZIVCRiKf9FaMivii5ZrLw=; 25:cly8mdqaVqqK3fMh+UVwvYh4y6WdQkzzcG1xBwgX3889zlfhBVq0LZITZAvMMf1pkI3bsnEBMd1z5aiUplBtYq9nwbYsYtQwAKM77VIU5ETfw4HYqbFoCVREIxn/AVNdsspSJ/3NcdJRPCWDsGDfZKoSSd5ASEnOIaTNTRYB/m6K5prCigcr5ARxb/0QhxEiJfTNPTiKhfwdPZba+r9C53eNn2Iqb0+a6jAy6vWCWG676SgYhzQr/7DEqEcr7DLVcFQbT/6pJtqD6sIdi5frnKGjt97qdUWA21jZxhEicDXhQ2JlyPwJ6x0ra9YoTluMADPs7tX/tv4sasmpkfXRmQ== X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN2PR03MB2367: X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 31:xQ1GdMaHEaH+h/99Sy7OZ35YnVgFb3rdqTmL6gvvcZ+/UGtcCcNl81CNSoMdkqMMj+WifyUO8gFByWh1pZPmMoXfVgHT8HMVNEM1qWnlQgAKlprAFob23f3etacm9KEdMVDRaR0jBo+/G0vhmhp4pLNevCTE0mhAyj3uZF3gkUvQequB+GtZKcOozfJFAWu8xGcxJzFmHejErz9h1IGu2QJAJ202mq0rEWv3cIW55u0=; 4:dCPU3rKDuhITWH0DoqkcpDfn5quGUKyZlGy0QlkR3uINP2Rs7ZinPnjTKVzwEEZo7v3sMhW/ZfYS2JIcjc0u68hGXQS8W4sn9SwjpuE334vawx9/YDReOgLIneTDOimWNjtcCbW0sxVfw54FW64P1l3Pz62PiC3YBGo6fcYuPRfKG2qDS9imb8weNwlOBc1iWW2pWto5S3++5GjAzYXhEX82k5vE1Sn5Q8dP1EGqA3hsbmuoCq9oihDzKKIu+XHaCIhfWMMKfxN5zjryMxo1ps/NdOFl+9RKdrhRnuWjU17FyUJw2OE0ESabJt3Kd9N7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(10201501046)(3231023)(93006095)(93001095)(3002001)(6055026)(6096035)(20161123556025)(20161123559100)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123563025)(20161123565025)(20161123561025)(201708071742011); SRVR:SN2PR03MB2367; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:SN2PR03MB2367; X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2367; 23:XjZmbCc36p+CK7iPu58lfg3GuTwYC5fH0jaw1OZp5?= =?us-ascii?Q?YyLV90Txo90cW90nU2CB0d2L1wPpUdQj0Jnbrp03YVcDG/XrrEsOF8W2BhvG?= =?us-ascii?Q?u5O5GbcVj6T0uZSkFJVAO5bV9JnEEm5WWAEgniwk2n1JrRxd529mKflWnYSq?= =?us-ascii?Q?armenHA/v3p8k6fTHs1/7KHpPXACY0Ls1N4rYbEfAUsF4ZV0dKPbQT5wfp64?= =?us-ascii?Q?OD1qwzyXTUgMF8gjQIB0oE9wubZv6HW4te/tFRi7Cn/mqEBC3Tt6iq1p2sVD?= =?us-ascii?Q?4DPqHGtII1W7bfKSi6CmA8ew3K294SwsnHxJHF4WH33CyHjwC0g9eT8birS2?= =?us-ascii?Q?sNEuaBhMerqMWZk4v9VJiOh8hvShepz2mD5B/V2+UIIlixP0ThzZdLEUq8Jq?= =?us-ascii?Q?w18qXs2eiX8uVCA3Mimr57sw4JOIrPrm3+cLV6h1VxUzzb2vCL5VEetogxHz?= =?us-ascii?Q?v3FS7w+e/+xMxD3ZgRNTs7qglc8l2QaMOsUnbM/DalOYyS83VVmV6dFkuJLV?= =?us-ascii?Q?TbljVziq/6yf96F8TDasfGagI3/a4vy/6kju/hvPnALp/bVIHVT1Jfd6B4Lp?= =?us-ascii?Q?jkycuEqh+xt1lMV9rAHqCmqbxahq1UWI0cQcn4nOLT7dFc6GVHrB7mltMXCs?= =?us-ascii?Q?q27IFDvp2651QsmKRFBDI3whTdiLrr2TTMJuHeD/9k11KDRETo5nJE+2nErc?= =?us-ascii?Q?vNoHFU7TtPrsLNxQA7gNbtgI9XVePI1eQTiJl45PAepc8U0XLEnmWJGJlnxp?= =?us-ascii?Q?PhNksZ3eU8jLxyar0OrxpnEvlLdhNWCaUMdiG3YYvCxm5JixejCp7XgLgwiP?= =?us-ascii?Q?SiSBqM1159A20wC10coU27g2dwuALzMOpte08b4VsHtSFHFBSlEM2gRYFBTA?= =?us-ascii?Q?AeiJiFVzLX69A2GQzNx9jUFTA8kBq8nILg03xcrD3tztc7CNkz01UmSP2XAo?= =?us-ascii?Q?lDoWyyMEwgHRiEgIYL1oAIa64D61JN2OGiN9AaRhjE8IPU58mYmLwzdERrKN?= =?us-ascii?Q?xhg7gsf6SLOCkZmS0jZq8FOpEmZD5uOzpdwMKbKscCTT5wGCTHVf/V0qsGku?= =?us-ascii?Q?Yx20+eTHYvfgRAe7vP1LfNFz9kQHrEi5/xnYLetQIWyfcJ+Z27KRN9J0xl0S?= =?us-ascii?Q?TYIOK2qL2myYZddcx57Vf8v3q8GdqnVaHlRepYIYfSn3z7sq+3NfJHs5uO7k?= =?us-ascii?Q?CeCl3KFF3zXanucLpDLO1gEMWFosA9dibNBJdRSKWYSzZT35hNGHGtVbg5IK?= =?us-ascii?Q?qqrrvNscVGMtOIEzrk=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 6:annC8qdfQOZFTzYlP2rq2ws5pn9ORjo1vcfsnEQ7E63h54lU8Rwgkjr/xHtAh/NMWNHu+fUrRL4lwHdS4iHxg0dcJ/0RjF/kWMaMTy8jeClAFW8BmslpBt+J3CSSgNcTvD9rrgsPu1hgfaiaQkhb6dmLrJKEnBp6XjVmzJMJfSSw4Um++dhuO9IvhGLHoXhbdrmOREsshJV30saNwDUlMAhtWOA20IK+q8DJplPDe5KlDjxtEl4WbS0YD4LszwF3rGg2Bq75H3gAQLA/8fch+r96+BiG8cBKaLCDLuElHFxtkGnO9S75EaU0cMLDswLwvtrsR7WipCYXiGNAzZ6Hlw==; 5:FYeI83drRW9HSHPze+Tut+fAsBcWPmHxFiRlZwLV1nV3YYI+iUg24OBl+4ptDfEzcQeheDO9xKliCZif0vB26vpUp2hcQVNa1pu9PgOVBqhqmtLMaIrMkv0pPQkJMD3peiHpeDrjMFNTg353VJIW6L7ujo1xSlpc+yyurreW+mQ=; 24:Gj8wj6rPOQGdhYeIegZQnUFdLUlt6oDzQCKq8tnIJ5HYPIZvaHsu2yvvgnuV9WBU8TGowkzldLJPViF/63hMtutuSOkzVRmMrzzu6cyO7hI=; 7:BJpq8w2RL4249h4L7JT9Nj9Ip9QvrOcpGoEGgDJ+tZi7hAbAn24KtDVvxVJZ/3EGUmmfNzSgXMmq8utbvvPVNIbeSF3aUtsugJk6p9R9Fdy5M4h/eTIWo4V1tMNNEKFv7Tvx3hVBbaDlJgJCryl8pZUwfgFuJhsBlJlsz8t4zYocazyqeOzRcNgUQtNSAZvo5FSucGaWeu0rTe6HBvdpiTi4kaYv3OltfYl9H4XlRiW2kI+gTKO5R93+O2qAu3VQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 04:41:47.7515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3be4023-63f3-42cf-3531-08d54763fae4 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2367 Subject: [PATCH edk2-platforms v2 1/4] Platform/NXP : Add Integrated flash controller library support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Dec 2017 04:37:16 -0000 Content-Type: text/plain On NXP Layerscape SoCs,NOR Flash device interfacing is via IFC and IfcFlashLib provides helper functions to be used by NXP NOR flash library Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Vabhav --- Platform/NXP/Include/Library/Ifc.h | 147 +++++++++++++++++++++ Platform/NXP/Include/Library/IfcBase.h | 139 +++++++++++++++++++ .../Include/Library/IfcBoardSpecificLib.h | 50 +++++++ Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc | 2 + Platform/NXP/Library/IfcFlashLib/IfcFlashLib.c | 70 ++++++++++ Platform/NXP/Library/IfcFlashLib/IfcFlashLib.inf | 33 +++++ Platform/NXP/NxpQoriqLs.dec | 1 + 7 files changed, 442 insertions(+) create mode 100755 Platform/NXP/Include/Library/Ifc.h create mode 100644 Platform/NXP/Include/Library/IfcBase.h create mode 100755 Platform/NXP/LS1043aRdbPkg/Include/Library/IfcBoardSpecificLib.h create mode 100644 Platform/NXP/Library/IfcFlashLib/IfcFlashLib.c create mode 100644 Platform/NXP/Library/IfcFlashLib/IfcFlashLib.inf diff --git a/Platform/NXP/Include/Library/Ifc.h b/Platform/NXP/Include/Library/Ifc.h new file mode 100755 index 0000000..dd36fd8 --- /dev/null +++ b/Platform/NXP/Include/Library/Ifc.h @@ -0,0 +1,147 @@ +/** @Ifc.h + + Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+ Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __IFC_H__ +#define __IFC_H__ + +#include +#include +#include +#include +#include +#include +#include + +#define IFC_BANK_COUNT 4 + +#define IFC_CSPR_REG_LEN 148 +#define IFC_AMASK_REG_LEN 144 +#define IFC_CSOR_REG_LEN 144 +#define IFC_FTIM_REG_LEN 576 + +#define IFC_CSPR_USED_LEN sizeof (IFC_CSPR) * \ + IFC_BANK_COUNT + +#define IFC_AMASK_USED_LEN sizeof (IFC_AMASK) * \ + IFC_BANK_COUNT + +#define IFC_CSOR_USED_LEN sizeof (IFC_CSOR) * \ + IFC_BANK_COUNT + +#define IFC_FTIM_USED_LEN sizeof (IFC_FTIM) * \ + IFC_BANK_COUNT + +typedef enum { + IFC_CS0 = 0, + IFC_CS1, + IFC_CS2, + IFC_CS3, + IFC_CS4, + IFC_CS5, + IFC_CS6, + IFC_CS7, +} IFC_CHIP_SEL; + +typedef enum { + IFC_FTIM0 = 0, + IFC_FTIM1, + IFC_FTIM2, + IFC_FTIM3, +} IFC_FTIMS; + +typedef struct { + UINT32 CsprExt; + UINT32 Cspr; + UINT32 Res; +} IFC_CSPR; + +typedef struct { + UINT32 Amask; + UINT32 Res[0x2]; +} IFC_AMASK; + +typedef struct { + UINT32 Csor; + UINT32 CsorExt; + UINT32 Res; +} IFC_CSOR; + +typedef struct { + UINT32 Ftim[4]; + UINT32 Res[0x8]; +}IFC_FTIM ; + +/* + * IFC controller NOR Machine registers + */ +typedef struct { + UINT32 NorEvterStat; + UINT32 Res1[0x2]; + UINT32 NorEvterEn; + UINT32 Res2[0x2]; + UINT32 NorEvterIntrEn; + UINT32 Res3[0x2]; + UINT32 NorErattr0; + UINT32 NorErattr1; + UINT32 NorErattr2; + UINT32 Res4[0x4]; + UINT32 NorCr; + UINT32 Res5[0xEF]; +} IFC_NOR; + +/* + * IFC Controller Registers + */ +typedef struct { + UINT32 IfcRev; + UINT32 Res1[0x2]; + IFC_CSPR CsprCs[IFC_BANK_COUNT]; + UINT8 Res2[IFC_CSPR_REG_LEN - IFC_CSPR_USED_LEN]; + IFC_AMASK AmaskCs[IFC_BANK_COUNT]; + UINT8 Res3[IFC_AMASK_REG_LEN - IFC_AMASK_USED_LEN]; + IFC_CSOR CsorCs[IFC_BANK_COUNT]; + UINT8 Res4[IFC_CSOR_REG_LEN - IFC_CSOR_USED_LEN]; + IFC_FTIM FtimCs[IFC_BANK_COUNT]; + UINT8 Res5[IFC_FTIM_REG_LEN - IFC_FTIM_USED_LEN]; + UINT32 RbStat; + UINT32 RbMap; + UINT32 WpMap; + UINT32 IfcGcr; + UINT32 Res7[0x2]; + UINT32 CmEvter_stat; + UINT32 Res8[0x2]; + UINT32 CmEvterEn; + UINT32 Res9[0x2]; + UINT32 CmEvterIntrEn; + UINT32 Res10[0x2]; + UINT32 CmErattr0; + UINT32 CmErattr1; + UINT32 Res11[0x2]; + UINT32 IfcCcr; + UINT32 IfcCsr; + UINT32 DdrCcrLow; + UINT32 Res12[0x2EA]; + IFC_NOR IfcNor; +} IFC_REGS; + +typedef struct { + UINT32 Ftim[IFC_BANK_COUNT]; + UINT32 CsprExt; + UINT32 Cspr; + UINT32 Csor; + UINT32 Amask; +} IfcTimings; + +#endif //__IFC_H__ diff --git a/Platform/NXP/Include/Library/IfcBase.h b/Platform/NXP/Include/Library/IfcBase.h new file mode 100644 index 0000000..7020a29 --- /dev/null +++ b/Platform/NXP/Include/Library/IfcBase.h @@ -0,0 +1,139 @@ +/** @IfcLib.h + + Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __IFC_COMMON_H__ +#define __IFC_COMMON_H__ + +#define NOR_FLASH_DEVICE_COUNT 1 + +#define MAX_RETRY_COUNT 150000 + +/* + * CSPR - Chip Select Property Register + */ + +#define IFC_CSPR_BA 0xFFFF0000 +#define IFC_CSPR_BA_SHIFT 16 +#define IFC_CSPR_PORT_SIZE 0x00000180 +#define IFC_CSPR_PORT_SIZE_SHIFT 7 + +// Port Size 8 bit +#define IFC_CSPR_PORT_SIZE_8 0x00000080 + +// Port Size 16 bit +#define IFC_CSPR_PORT_SIZE_16 0x00000100 + +// Port Size 32 bit +#define IFC_CSPR_PORT_SIZE_32 0x00000180 + +// Write Protect +#define IFC_CSPR_WP 0x00000040 +#define IFC_CSPR_WP_SHIFT 6 + +// Machine Select +#define IFC_CSPR_MSEL 0x00000006 +#define IFC_CSPR_MSEL_SHIFT 1 + +// NOR +#define IFC_CSPR_MSEL_NOR 0x00000000 + +// Bank Valid +#define IFC_CSPR_V 0x00000001 +#define IFC_CSPR_V_SHIFT 0 + +/* + * Chip Select Option Register - NOR Flash Mode + */ + +// Enable Address shift Mode +#define IFC_CSOR_NOR_ADM_SHFT_MODE_EN 0x80000000 + +// Page Read Enable from NOR device +#define IFC_CSOR_NOR_PGRD_EN 0x10000000 + +// AVD Toggle Enable during Burst Program +#define IFC_CSOR_NOR_AVD_TGL_PGM_EN 0x01000000 + +// Address Data Multiplexing Shift +#define IFC_CSOR_NOR_ADM_MASK 0x0003E000 +#define IFC_CSOR_NOR_ADM_SHIFT_SHIFT 13 +#define IFC_CSOR_NOR_ADM_SHIFT(n) ((n) << IFC_CSOR_NOR_ADM_SHIFT_SHIFT) + +// Type of the NOR device hooked +#define IFC_CSOR_NOR_NOR_MODE_AYSNC_NOR 0x00000000 +#define IFC_CSOR_NOR_NOR_MODE_AVD_NOR 0x00000020 + +// Time for Read Enable High to Output High Impedance +#define IFC_CSOR_NOR_TRHZ_MASK 0x0000001C +#define IFC_CSOR_NOR_TRHZ_SHIFT 2 +#define IFC_CSOR_NOR_TRHZ_20 0x00000000 +#define IFC_CSOR_NOR_TRHZ_40 0x00000004 +#define IFC_CSOR_NOR_TRHZ_60 0x00000008 +#define IFC_CSOR_NOR_TRHZ_80 0x0000000C +#define IFC_CSOR_NOR_TRHZ_100 0x00000010 + +// Buffer control disable +#define IFC_CSOR_NOR_BCTLD 0x00000001 + +/* + * FTIM0 - NOR Flash Mode + */ +#define IFC_FTIM0_NOR 0xF03F3F3F +#define IFC_FTIM0_NOR_TACSE_SHIFT 28 +#define IFC_FTIM0_NOR_TACSE(n) ((n) << IFC_FTIM0_NOR_TACSE_SHIFT) +#define IFC_FTIM0_NOR_TEADC_SHIFT 16 +#define IFC_FTIM0_NOR_TEADC(n) ((n) << IFC_FTIM0_NOR_TEADC_SHIFT) +#define IFC_FTIM0_NOR_TAVDS_SHIFT 8 +#define IFC_FTIM0_NOR_TAVDS(n) ((n) << IFC_FTIM0_NOR_TAVDS_SHIFT) +#define IFC_FTIM0_NOR_TEAHC_SHIFT 0 +#define IFC_FTIM0_NOR_TEAHC(n) ((n) << IFC_FTIM0_NOR_TEAHC_SHIFT) + +/* + * FTIM1 - NOR Flash Mode + */ +#define IFC_FTIM1_NOR 0xFF003F3F +#define IFC_FTIM1_NOR_TACO_SHIFT 24 +#define IFC_FTIM1_NOR_TACO(n) ((n) << IFC_FTIM1_NOR_TACO_SHIFT) +#define IFC_FTIM1_NOR_TRAD_NOR_SHIFT 8 +#define IFC_FTIM1_NOR_TRAD_NOR(n) ((n) << IFC_FTIM1_NOR_TRAD_NOR_SHIFT) +#define IFC_FTIM1_NOR_TSEQRAD_NOR_SHIFT 0 +#define IFC_FTIM1_NOR_TSEQRAD_NOR(n) ((n) << IFC_FTIM1_NOR_TSEQRAD_NOR_SHIFT) + +/* + * FTIM2 - NOR Flash Mode + */ +#define IFC_FTIM2_NOR 0x0F3CFCFF +#define IFC_FTIM2_NOR_TCS_SHIFT 24 +#define IFC_FTIM2_NOR_TCS(n) ((n) << IFC_FTIM2_NOR_TCS_SHIFT) +#define IFC_FTIM2_NOR_TCH_SHIFT 18 +#define IFC_FTIM2_NOR_TCH(n) ((n) << IFC_FTIM2_NOR_TCH_SHIFT) +#define IFC_FTIM2_NOR_TWPH_SHIFT 10 +#define IFC_FTIM2_NOR_TWPH(n) ((n) << IFC_FTIM2_NOR_TWPH_SHIFT) +#define IFC_FTIM2_NOR_TWP_SHIFT 0 +#define IFC_FTIM2_NOR_TWP(n) ((n) << IFC_FTIM2_NOR_TWP_SHIFT) + +/* Convert an address into the right format for the CSPR Registers */ +#define IFC_CSPR_PHYS_ADDR(x) (((UINTN)x) & 0xffff0000) + +/* + * Address Mask Register + */ +#define IFC_AMASK_MASK 0xFFFF0000 +#define IFC_AMASK_SHIFT 16 +#define IFC_AMASK(n) (IFC_AMASK_MASK << \ + (HighBitSet32(n) - IFC_AMASK_SHIFT)) + +VOID IfcNorInit(VOID); + +#endif //__IFC_COMMON_H__ diff --git a/Platform/NXP/LS1043aRdbPkg/Include/Library/IfcBoardSpecificLib.h b/Platform/NXP/LS1043aRdbPkg/Include/Library/IfcBoardSpecificLib.h new file mode 100755 index 0000000..aaef340 --- /dev/null +++ b/Platform/NXP/LS1043aRdbPkg/Include/Library/IfcBoardSpecificLib.h @@ -0,0 +1,50 @@ +/** IfcBoardSpecificLib.h + IFC Flash Board Specific library + + Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#ifndef __IFC__BOARD_SPECIFIC_LIB_H__ +#define __IFC__BOARD_SPECIFIC_LIB_H__ + +// On board flash support,endianness +#define NOR_SUPPORT +#define IFC_REG_BASE 0x1530000 +#define IFC_NOR_BUF_BASE 0x60000000 + +// On board Inegrated flash Controller chip select configuration +#define IFC_NOR_CS IFC_CS0 + +// board-specific NOR flash timing +#define NOR_FTIM0 (IFC_FTIM0_NOR_TACSE(0x1) | \ + IFC_FTIM0_NOR_TEADC(0x1) | \ + IFC_FTIM0_NOR_TAVDS(0x0) | \ + IFC_FTIM0_NOR_TEAHC(0xc)) +#define NOR_FTIM1 (IFC_FTIM1_NOR_TACO(0x1c) | \ + IFC_FTIM1_NOR_TRAD_NOR(0xb) |\ + IFC_FTIM1_NOR_TSEQRAD_NOR(0x9)) +#define NOR_FTIM2 (IFC_FTIM2_NOR_TCS(0x1) | \ + IFC_FTIM2_NOR_TCH(0x4) | \ + IFC_FTIM2_NOR_TWPH(0x8) | \ + IFC_FTIM2_NOR_TWP(0x10)) +#define NOR_FTIM3 0x0 + +#define NOR_CSPR (IFC_CSPR_PHYS_ADDR(IFC_NOR_BUF_BASE) \ + | IFC_CSPR_PORT_SIZE_16 \ + | IFC_CSPR_MSEL_NOR \ + | IFC_CSPR_V) + +#define NOR_CSPR_EXT 0x0 +#define NOR_AMASK IFC_AMASK(128*1024*1024) +#define NOR_CSOR (IFC_CSOR_NOR_ADM_SHIFT(4) | \ + IFC_CSOR_NOR_TRHZ_80) + +#endif //__IFC__BOARD_SPECIFIC_LIB_H__ diff --git a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc index 1951e82..7a72338 100644 --- a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc +++ b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc @@ -47,12 +47,14 @@ # gNxpQoriqLsTokenSpaceGuid.PcdSerdes2Enabled|FALSE gNxpQoriqLsTokenSpaceGuid.PcdPlatformFreqDiv|0x1 + gNxpQoriqLsTokenSpaceGuid.PcdIfcNorEnabled|1 # # Big Endian IPs # gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian|TRUE gNxpQoriqLsTokenSpaceGuid.PcdWdogBigEndian|TRUE + gNxpQoriqLsTokenSpaceGuid.PcdIfcBigEndian|TRUE # # I2C controller Pcds diff --git a/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.c b/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.c new file mode 100644 index 0000000..c9e8bc4 --- /dev/null +++ b/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.c @@ -0,0 +1,70 @@ +/** @IfcFlashLib.c + + Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +// Include board specific file for Flash timing +#include + +#ifdef NOR_SUPPORT +VOID +GetIfcNorFlashInfo ( + IN NorFlashInfo *NorFlashInfo + ) +{ + NorFlashInfo->IfcRegs = (IFC_REGS*) IFC_REG_BASE; + NorFlashInfo->ChipSelect = IFC_NOR_CS; + return ; +} + +VOID +GetIfcNorFlashTimings ( + IN IfcTimings * NorIfcTimings + ) +{ + NorIfcTimings->Ftim[0] = NOR_FTIM0; + NorIfcTimings->Ftim[1] = NOR_FTIM1; + NorIfcTimings->Ftim[2] = NOR_FTIM2; + NorIfcTimings->Ftim[3] = NOR_FTIM3; + NorIfcTimings->Cspr = NOR_CSPR; + NorIfcTimings->CsprExt = NOR_CSPR_EXT; + NorIfcTimings->Amask = NOR_AMASK; + NorIfcTimings->Csor = NOR_CSOR; + return ; +} + +VOID IfcNorWrite32 (VOID *a, UINT32 v) { + + if (FixedPcdGetBool (PcdIfcBigEndian)) { + BeMmioWrite32 ((UINTN)a, v); + } else { + MmioWrite32 ((UINTN)a, v); + } + +} + +FLASH_DATA +IfcNorFlashData ( + FLASH_DATA Value + ) +{ + + if (FixedPcdGetBool (PcdIfcBigEndian)) { + return SwapBytes16 (Value); + } else { + return Value; + } + +} +#endif //NOR_SUPPORT diff --git a/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.inf b/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.inf new file mode 100644 index 0000000..8447c7f --- /dev/null +++ b/Platform/NXP/Library/IfcFlashLib/IfcFlashLib.inf @@ -0,0 +1,33 @@ +#/** IfcFlashLib.inf +# +# Component description file for IFC FLASH Library +# +# Copyright 2017 NXP +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = IfcFlashLib + FILE_GUID = 8ecefc8f-a2c4-4091-b80f-92da7c4ab37f + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = IfcFlashLib + +[Sources.common] + IfcFlashLib.c + +[Packages] + MdePkg/MdePkg.dec + Platform/NXP/NxpQoriqLs.dec + +[Pcd] + gNxpQoriqLsTokenSpaceGuid.PcdIfcBigEndian diff --git a/Platform/NXP/NxpQoriqLs.dec b/Platform/NXP/NxpQoriqLs.dec index fd07eee..e773bcd 100644 --- a/Platform/NXP/NxpQoriqLs.dec +++ b/Platform/NXP/NxpQoriqLs.dec @@ -240,6 +240,7 @@ gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian|FALSE|BOOLEAN|0x0000311 gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|FALSE|BOOLEAN|0x00000312 gNxpQoriqLsTokenSpaceGuid.PcdWdogBigEndian|FALSE|BOOLEAN|0x00000313 + gNxpQoriqLsTokenSpaceGuid.PcdIfcBigEndian|FALSE|BOOLEAN|0x00000314 # # System ID Eeprom Pcds -- 1.9.1