tpr12/qt: changes to enable tpr12 on QT again
authorBadri S <badri@ti.com>
Mon, 23 Nov 2020 11:47:32 +0000 (17:17 +0530)
committerBadri S <badri@ti.com>
Wed, 2 Dec 2020 08:20:07 +0000 (13:50 +0530)
QT support is required for AR29xx bringup so
restored TPR12 QT platform support

Signed-off-by: Badri S <badri@ti.com>
13 files changed:
packages/ti/board/src/flash/board_flash.c
packages/ti/board/src/flash/include/board_flash.h
packages/ti/board/src/flash/nor/device/w25q16fwsf.h [new file with mode: 0644]
packages/ti/board/src/flash/nor/qspi/nor_qspi.h
packages/ti/board/utils/uniflash/target/src/qspi/qspi.h
packages/ti/boot/sbl/build/sbl_tpr12_test.mk [changed mode: 0755->0644]
packages/ti/boot/sbl/example/tpr12MulticoreApp/sbl_smp_multicore.c
packages/ti/boot/sbl/src/qspi/sbl_qspi_boardflash.c
packages/ti/build/makerules/env.mk
packages/ti/build/makerules/rules_66.mk
packages/ti/build/tpr12/linker_c66.cmd
packages/ti/build/tpr12/linker_c66_baremetal.cmd [new file with mode: 0644]
packages/ti/drv/spi/spi_component.mk

index d4d2e31840283a199a651843fc61cc63fd959c71..f814acbaff73b81e75a674f871ccae58cecc38f2 100644 (file)
-/*\r
- * Copyright (c) 2016-2020, Texas Instruments Incorporated\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * *  Redistributions of source code must retain the above copyright\r
- *    notice, this list of conditions and the following disclaimer.\r
- *\r
- * *  Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the\r
- *    documentation and/or other materials provided with the distribution.\r
- *\r
- * *  Neither the name of Texas Instruments Incorporated nor the names of\r
- *    its contributors may be used to endorse or promote products derived\r
- *    from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- */\r
-\r
-/**\r
- *\r
- * \file    board_flash.c\r
- *\r
- * \brief   This contains board flash common APIs.\r
- *\r
- ******************************************************************************/\r
-\r
-#include "board_cfg.h"\r
-#include "board_flash.h"\r
-\r
-/* This structure holds information about the flash devices on the board */\r
-Board_FlashInfo Board_flashInfo[MAX_BOARD_FLASH_INSTANCE_NUM] =\r
-{\r
-    {0, },\r
-};\r
-\r
-static uint32_t Board_getFlashIntf(uint32_t deviceId)\r
-{\r
-    uint32_t flashIntf = 0;\r
-\r
-    if((deviceId == BOARD_FLASH_ID_NORN25Q128) || \\r
-       (deviceId == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-       (deviceId == BOARD_FLASH_ID_W25X32VSFIG))\r
-    {\r
-        flashIntf = BOARD_FLASH_NOR_SPI;\r
-    }\r
-    else if((deviceId == BOARD_FLASH_ID_MT25QU512ABB) || \\r
-            (deviceId == BOARD_FLASH_ID_S25FL512S) || \\r
-            (deviceId == BOARD_FLASH_ID_S25FL256S) ||\r
-            (deviceId == BOARD_FLASH_ID_GD25B16CSAG) ||\r
-            (deviceId == BOARD_FLASH_ID_GD25B64CW2G) ||\r
-            (deviceId == BOARD_FLASH_ID_MX25V1635F))\r
-    {\r
-        flashIntf = BOARD_FLASH_NOR_QSPI;\r
-    }\r
-    else if(deviceId == BOARD_FLASH_ID_MT29W160EB)\r
-    {\r
-        flashIntf = BOARD_FLASH_NOR_GPMC;\r
-    }\r
-    else if(deviceId == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        flashIntf = BOARD_FLASH_NAND_GPMC;\r
-    }\r
-    else if((deviceId == BOARD_FLASH_ID_MT35XU512ABA1G12) || \\r
-            (deviceId == BOARD_FLASH_ID_MT35XU256ABA1G12) || \\r
-            (deviceId == BOARD_FLASH_ID_S28HS512T))\r
-    {\r
-        flashIntf = BOARD_FLASH_NOR_OSPI;\r
-    }\r
-    else if(BOARD_FLASH_ID_S71KS512S)\r
-    {\r
-        flashIntf = BOARD_FLASH_NOR_HPF;\r
-    }\r
-    else\r
-    {\r
-        /* Unknown flash type */\r
-        flashIntf = BOARD_FLASH_NOR_INTF_MAX;\r
-    }\r
-\r
-    return (flashIntf);\r
-}\r
-/******************************************************************************\r
- * BOARD_flashOpen\r
- ******************************************************************************/\r
-Board_flashHandle Board_flashOpen(uint32_t deviceId, uint32_t portNum, void *params)\r
-{\r
-    uint32_t           count;\r
-    Board_FlashInfo   *flashInfo;\r
-    uint32_t           flashIntf;\r
-\r
-    for (count = 0; count < MAX_BOARD_FLASH_INSTANCE_NUM; count++)\r
-    {\r
-        if (Board_flashInfo[count].flashHandle == 0)\r
-        {\r
-            flashInfo = &Board_flashInfo[count];\r
-            break;\r
-        }\r
-    }\r
-\r
-    if (count == MAX_BOARD_FLASH_INSTANCE_NUM)\r
-    {\r
-        return (0U);\r
-    }\r
-\r
-    flashIntf = Board_getFlashIntf(deviceId);\r
-\r
-#if defined (BOARD_NOR_FLASH_IN)\r
-    NOR_HANDLE         flashHandle;\r
-    NOR_Info          *norInfo;\r
-\r
-    if (                                                    \\r
-        (deviceId == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (deviceId == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (deviceId == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (deviceId == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (deviceId == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (deviceId == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (deviceId == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (deviceId == BOARD_FLASH_ID_MT35XU512ABA1G12)   || \\r
-        (deviceId == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (deviceId == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (deviceId == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (deviceId == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (deviceId == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (deviceId == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        /* Open the NOR flash */\r
-        flashHandle = NOR_open(flashIntf, portNum, params);\r
-        if (!flashHandle)\r
-        {\r
-            return 0;\r
-        }\r
-\r
-        norInfo = (NOR_Info *)flashHandle;\r
-        if (deviceId != norInfo->deviceId)\r
-        {\r
-\r
-            NOR_close(flashHandle);\r
-            return 0;\r
-        }\r
-\r
-        flashInfo->flashHandle     = flashHandle;\r
-        flashInfo->manufacturer_id = norInfo->manufacturerId;\r
-        flashInfo->device_id       = norInfo->deviceId;\r
-        flashInfo->type            = BOARD_FLASH_NOR;\r
-        flashInfo->block_count     = norInfo->blockCnt;\r
-        flashInfo->page_count      = norInfo->pageCnt;\r
-        flashInfo->page_size       = norInfo->pageSize;\r
-        flashInfo->sector_size     = norInfo->sectorSize;\r
-        flashInfo->blkErase_flag   = true; /* Default set to Block Erase */\r
-\r
-        return (Board_flashHandle)&(Board_flashInfo);\r
-    }\r
-#elif defined (BOARD_NAND_FLASH_IN)\r
-    NAND_HANDLE        flashHandle;\r
-    NAND_Info         *nandInfo;\r
-\r
-    if (deviceId == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        /* Open the Nand flash */\r
-        flashHandle = NAND_open(flashIntf, portNum, params);\r
-        if (!flashHandle)\r
-        {\r
-            return 0;\r
-        }\r
-        nandInfo = (NAND_Info *)flashHandle;\r
-\r
-        if (deviceId != nandInfo->deviceId)\r
-        {\r
-            NAND_close(flashHandle);\r
-            return 0;\r
-        }\r
-\r
-        flashInfo->flashHandle     = flashHandle;\r
-        flashInfo->manufacturer_id = nandInfo->manufacturerId;\r
-        flashInfo->device_id       = nandInfo->deviceId;\r
-        flashInfo->type            = BOARD_FLASH_NAND;\r
-        flashInfo->block_count     = nandInfo->blockCnt;\r
-        flashInfo->page_count      = nandInfo->pageCnt;\r
-        flashInfo->page_size       = nandInfo->pageSize;\r
-        flashInfo->spare_size      = nandInfo->spareSize;\r
-        flashInfo->bboffset        = nandInfo->bbOffset;\r
-        flashInfo->bblist          = nandInfo->bbList;\r
-\r
-        return (Board_flashHandle)(flashInfo);\r
-    }\r
-#endif\r
-\r
-    return 0;\r
-}\r
-\r
-/******************************************************************************\r
- * BOARD_flashClose\r
- ******************************************************************************/\r
-Board_flash_STATUS Board_flashClose(Board_flashHandle handle)\r
-{\r
-    Board_FlashInfo *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-#if defined(BOARD_NOR_FLASH_IN)\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        NOR_close(flashInfo->flashHandle);\r
-    }\r
-#elif defined (BOARD_NAND_FLASH_IN)\r
-    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        NAND_close(flashInfo->flashHandle);\r
-    }\r
-#endif\r
-\r
-    flashInfo->flashHandle = 0;\r
-\r
-    return BOARD_FLASH_EOK;\r
-}\r
-\r
-/******************************************************************************\r
- * BOARD_flashRead\r
- ******************************************************************************/\r
-Board_flash_STATUS Board_flashRead(Board_flashHandle  handle,\r
-                                   uint32_t           offset,\r
-                                   uint8_t           *buf,\r
-                                   uint32_t           len,\r
-                                   void              *params)\r
-{\r
-    Board_FlashInfo   *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    if (buf == NULL || len == 0)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-\r
-#if defined(BOARD_NOR_FLASH_IN)\r
-    uint32_t readMode = 0;\r
-\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        if (params)\r
-        {\r
-            readMode = *((uint32_t *)params);\r
-        }\r
-\r
-        if (NOR_read(flashInfo->flashHandle, offset, len, buf, readMode) \\r
-                   != NOR_PASS)\r
-        {\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-        return BOARD_FLASH_EOK;\r
-    }\r
-#elif defined (BOARD_NAND_FLASH_IN)\r
-    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        if (NAND_read(flashInfo->flashHandle, offset, len, buf) \\r
-            != NAND_PASS)\r
-        {\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-        return BOARD_FLASH_EOK;\r
-    }\r
-#endif\r
-\r
-    return BOARD_FLASH_EUNSUPPORTED;\r
-}\r
-\r
- /**\r
- *  \brief             This function computes the sector and page based on an offset\r
- *              This function also sets the blkErase_flag to false to support\r
- *              Sector erase. This flag is used by the Board_flashEraseBlk()\r
- *              to determine the erase type\r
- *\r
- *     \param          handle                  [IN]    Pointer to Board_FlashHandle.\r
- *              offset                 [IN]    Flash Offset to be computed to Sector\r
- *              sector              [IN]    Computed Sector number\r
- *              page                [IN]    Computed page number\r
- *              hybridSector_flag   [IN]       Flag to enable Hybrid Sector Erase\r
- *\r
- *  \return            Returns Board_flash_STATUS\r
- *\r
- */\r
-Board_flash_STATUS Board_flashOffsetToSectorPage(Board_flashHandle  handle,\r
-                                              uint32_t           offset,\r
-                                              uint32_t          *sector,\r
-                                              uint32_t          *page,\r
-                                              bool              hybridSector_flag)\r
-{\r
-    uint32_t leftover, block_count, sector_count, page_size, page_count;\r
-    Board_FlashInfo *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-    if ((flashInfo->device_id == BOARD_FLASH_ID_S25FL256S) && (hybridSector_flag == false))\r
-    {\r
-        /* In case of S25FL256S device if hybridSector_flag is not set indicating\r
-        uniform sector erase of 64KB, which is handled by Block erase */\r
-        return Board_flashOffsetToBlkPage(handle, offset, sector, page);\r
-    }\r
-\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)\r
-       )\r
-    {\r
-        block_count = flashInfo->block_count;\r
-        page_size      = flashInfo->page_size;\r
-        page_count     = flashInfo->page_count;\r
-       }\r
-    else\r
-    {\r
-        return BOARD_FLASH_EUNSUPPORTED;\r
-    }\r
-\r
-    sector_count = (page_count * page_size * block_count) / flashInfo->sector_size;\r
-\r
-    *sector   = offset / flashInfo->sector_size;\r
-    leftover  = offset % flashInfo->sector_size;\r
-    *page        = leftover / page_size;\r
-    if (leftover % page_size)\r
-    {\r
-        /* All writes must be page aligned for now */\r
-        return BOARD_FLASH_EUNSUPPORTED;\r
-    }\r
-    if (*sector > sector_count)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-    if (*page > page_count)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-\r
-    flashInfo->blkErase_flag = false; /* This flag to be set false for Sector erase */\r
-\r
-    return BOARD_FLASH_EOK;\r
-}\r
-\r
-/**\r
- *  \brief             This function computes the block and page number based on the\r
- *              offset. This function also sets the blkErase_flag to true to\r
- *              support Block erase. This flag is used by the\r
- *              Board_flashEraseBlk() to determine the erase type.\r
- *\r
- *     \param          handle                  [IN]    Pointer to Board_FlashHandle.\r
- *              offset                 [IN]    Flash Offset to be computed to Sector\r
- *              page                [IN]    Computed Page number\r
- *              page                [IN]    Computed page number\r
- *\r
- *  \return            Returns Board_flash_STATUS\r
- *\r
- */\r
-Board_flash_STATUS Board_flashOffsetToBlkPage(Board_flashHandle  handle,\r
-                                              uint32_t           offset,\r
-                                              uint32_t          *block,\r
-                                              uint32_t          *page)\r
-{\r
-    uint32_t leftover, block_size, block_count, page_size, page_count;\r
-    Board_FlashInfo *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        block_count = flashInfo->block_count;\r
-        page_size      = flashInfo->page_size;\r
-        page_count     = flashInfo->page_count;\r
-       }\r
-    else\r
-    {\r
-        return BOARD_FLASH_EUNSUPPORTED;\r
-    }\r
-\r
-    block_size = (page_count * page_size);\r
-\r
-    *block       = offset / block_size;\r
-    leftover  = offset % block_size;\r
-    *page        = leftover / page_size;\r
-    if (leftover % page_size)\r
-    {\r
-        /* All writes must be page aligned for now */\r
-        return BOARD_FLASH_EUNSUPPORTED;\r
-    }\r
-    if (*block > block_count)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-    if (*page > page_count)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-\r
-    flashInfo->blkErase_flag = true; /* This flag to be set true for Block erase */\r
-    return BOARD_FLASH_EOK;\r
-}\r
-\r
-/******************************************************************************\r
- * Computes a block and page based on an offset\r
- ******************************************************************************/\r
-Board_flash_STATUS Board_flashBlkPageToOffset(Board_flashHandle  handle,\r
-                                              uint32_t          *offset,\r
-                                              uint32_t           block,\r
-                                              uint32_t           page)\r
-{\r
-    uint32_t        block_count, page_size, page_count;\r
-    Board_FlashInfo *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        block_count = flashInfo->block_count;\r
-        page_size      = flashInfo->page_size;\r
-        page_count     = flashInfo->page_count;\r
-    }\r
-    else\r
-    {\r
-        return BOARD_FLASH_EUNSUPPORTED;\r
-    }\r
-\r
-    if (block >block_count || page > page_count)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-\r
-    *offset =   (block * (page_count * page_size)) + (page * page_size);\r
-\r
-    return BOARD_FLASH_EOK;\r
-}\r
-\r
-/******************************************************************************\r
- * BOARD_flashWrite\r
- ******************************************************************************/\r
-Board_flash_STATUS Board_flashWrite(Board_flashHandle  handle,\r
-                                    uint32_t           offset,\r
-                                    uint8_t           *buf,\r
-                                    uint32_t           len,\r
-                                    void              *params)\r
-{\r
-    Board_FlashInfo *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    if (buf == NULL || len == 0)\r
-    {\r
-        return BOARD_FLASH_EINVALID;\r
-    }\r
-\r
-#if defined(BOARD_NOR_FLASH_IN)\r
-    uint32_t writeMode = 0;\r
-\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        if (params)\r
-        {\r
-            writeMode = *((uint32_t *)params);\r
-        }\r
-\r
-        if (NOR_write(flashInfo->flashHandle, offset, len, buf,\r
-                 writeMode) != NOR_PASS)\r
-        {\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-        return BOARD_FLASH_EOK;\r
-    }\r
-#elif defined (BOARD_NAND_FLASH_IN)\r
-    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        if (NAND_write(flashInfo->flashHandle, offset, len, buf) != NAND_PASS)\r
-        {\r
-           return (BOARD_FLASH_EFAIL);\r
-        }\r
-        return BOARD_FLASH_EOK;\r
-    }\r
-#endif\r
-\r
-    return BOARD_FLASH_EUNSUPPORTED;\r
-}\r
-\r
-/**\r
- *  \brief  platform_device_erase_block\r
- *\r
- *  Board_flashEraseBlk supports Block and Sector erase based on the blkErase_flag\r
- *  This API expects blkErase_flag to be set to the appropriate Boolean value to\r
- *  determine the type of erase.\r
- *\r
- *  blkErase_flag is set in one of the Board_flashOffsetToSectorPage() or\r
- *  Board_flashOffsetToBlkPage() APIs for sector or block erase respectively.\r
- *\r
- *  \param\r
- *  handle  - Handle to the flash device\r
- *  blk_num - Block number to be erased when blkErase_flag=true\r
- *            Sector number to be erased when blkErase_flag=false\r
- *\r
- *\r
- ********************************************************************************/\r
-Board_flash_STATUS Board_flashEraseBlk(Board_flashHandle handle,\r
-                                       uint32_t          blk_num)\r
-{\r
-    Board_FlashInfo    *flashInfo;\r
-\r
-    if (!handle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    flashInfo = (Board_FlashInfo *)handle;\r
-    if (!flashInfo->flashHandle)\r
-    {\r
-        return BOARD_FLASH_EFAIL;\r
-    }\r
-\r
-    if (flashInfo->blkErase_flag)\r
-    {\r
-        if (blk_num > flashInfo->block_count)\r
-        {\r
-            return BOARD_FLASH_EFAIL;\r
-        }\r
-    }\r
-\r
-#if defined(BOARD_NOR_FLASH_IN)\r
-    if (                                                                \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \\r
-        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)\r
-       )\r
-    {\r
-        if (NOR_erase (flashInfo->flashHandle, blk_num, flashInfo->blkErase_flag) != NOR_PASS)\r
-        {\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-        return BOARD_FLASH_EOK;\r
-    }\r
-#elif defined (BOARD_NAND_FLASH_IN)\r
-    NAND_STATUS status;\r
-\r
-    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)\r
-    {\r
-        if (flashInfo->bblist[blk_num] == NAND_BAD_BLOCK)\r
-        {\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-\r
-        status = NAND_erase(flashInfo->flashHandle, blk_num);\r
-        if (status != NAND_PASS)\r
-        {\r
-            if (status == NAND_BLOCK_BAD)\r
-            {\r
-                flashInfo->bblist[blk_num] = NAND_BAD_BLOCK;\r
-            }\r
-            return (BOARD_FLASH_EFAIL);\r
-        }\r
-        else\r
-        {\r
-            return (BOARD_FLASH_EOK);\r
-        }\r
-    }\r
-#endif\r
-\r
-    return BOARD_FLASH_EUNSUPPORTED;\r
-}\r
-\r
+/*
+ * Copyright (c) 2016-2020, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/**
+ *
+ * \file    board_flash.c
+ *
+ * \brief   This contains board flash common APIs.
+ *
+ ******************************************************************************/
+
+#include "board_cfg.h"
+#include "board_flash.h"
+
+/* This structure holds information about the flash devices on the board */
+Board_FlashInfo Board_flashInfo[MAX_BOARD_FLASH_INSTANCE_NUM] =
+{
+    {0, },
+};
+
+static uint32_t Board_getFlashIntf(uint32_t deviceId)
+{
+    uint32_t flashIntf = 0;
+
+    if((deviceId == BOARD_FLASH_ID_NORN25Q128) || \
+       (deviceId == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+       (deviceId == BOARD_FLASH_ID_W25X32VSFIG))
+    {
+        flashIntf = BOARD_FLASH_NOR_SPI;
+    }
+    else if((deviceId == BOARD_FLASH_ID_MT25QU512ABB) || \
+            (deviceId == BOARD_FLASH_ID_S25FL512S) || \
+            (deviceId == BOARD_FLASH_ID_S25FL256S) ||
+            (deviceId == BOARD_FLASH_ID_GD25B16CSAG) ||
+            (deviceId == BOARD_FLASH_ID_GD25B64CW2G) ||
+            (deviceId == BOARD_FLASH_ID_W25Q16FWSF)  ||
+            (deviceId == BOARD_FLASH_ID_MX25V1635F))
+    {
+        flashIntf = BOARD_FLASH_NOR_QSPI;
+    }
+    else if(deviceId == BOARD_FLASH_ID_MT29W160EB)
+    {
+        flashIntf = BOARD_FLASH_NOR_GPMC;
+    }
+    else if(deviceId == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        flashIntf = BOARD_FLASH_NAND_GPMC;
+    }
+    else if((deviceId == BOARD_FLASH_ID_MT35XU512ABA1G12) || \
+            (deviceId == BOARD_FLASH_ID_MT35XU256ABA1G12) || \
+            (deviceId == BOARD_FLASH_ID_S28HS512T))
+    {
+        flashIntf = BOARD_FLASH_NOR_OSPI;
+    }
+    else if(BOARD_FLASH_ID_S71KS512S)
+    {
+        flashIntf = BOARD_FLASH_NOR_HPF;
+    }
+    else
+    {
+        /* Unknown flash type */
+        flashIntf = BOARD_FLASH_NOR_INTF_MAX;
+    }
+
+    return (flashIntf);
+}
+/******************************************************************************
+ * BOARD_flashOpen
+ ******************************************************************************/
+Board_flashHandle Board_flashOpen(uint32_t deviceId, uint32_t portNum, void *params)
+{
+    uint32_t           count;
+    Board_FlashInfo   *flashInfo;
+    uint32_t           flashIntf;
+
+    for (count = 0; count < MAX_BOARD_FLASH_INSTANCE_NUM; count++)
+    {
+        if (Board_flashInfo[count].flashHandle == 0)
+        {
+            flashInfo = &Board_flashInfo[count];
+            break;
+        }
+    }
+
+    if (count == MAX_BOARD_FLASH_INSTANCE_NUM)
+    {
+        return (0U);
+    }
+
+    flashIntf = Board_getFlashIntf(deviceId);
+
+#if defined (BOARD_NOR_FLASH_IN)
+    NOR_HANDLE         flashHandle;
+    NOR_Info          *norInfo;
+
+    if (                                                    \
+        (deviceId == BOARD_FLASH_ID_S25FL512S)           || \
+        (deviceId == BOARD_FLASH_ID_S25FL256S)           || \
+        (deviceId == BOARD_FLASH_ID_MT29W160EB)          || \
+        (deviceId == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (deviceId == BOARD_FLASH_ID_NORN25Q128)          || \
+        (deviceId == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (deviceId == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (deviceId == BOARD_FLASH_ID_MT35XU512ABA1G12)   || \
+        (deviceId == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (deviceId == BOARD_FLASH_ID_S71KS512S)           || \
+        (deviceId == BOARD_FLASH_ID_S28HS512T)           || \
+        (deviceId == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (deviceId == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (deviceId == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (deviceId == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        /* Open the NOR flash */
+        flashHandle = NOR_open(flashIntf, portNum, params);
+        if (!flashHandle)
+        {
+            return 0;
+        }
+
+        norInfo = (NOR_Info *)flashHandle;
+        if (deviceId != norInfo->deviceId)
+        {
+
+            NOR_close(flashHandle);
+            return 0;
+        }
+
+        flashInfo->flashHandle     = flashHandle;
+        flashInfo->manufacturer_id = norInfo->manufacturerId;
+        flashInfo->device_id       = norInfo->deviceId;
+        flashInfo->type            = BOARD_FLASH_NOR;
+        flashInfo->block_count     = norInfo->blockCnt;
+        flashInfo->page_count      = norInfo->pageCnt;
+        flashInfo->page_size       = norInfo->pageSize;
+        flashInfo->sector_size     = norInfo->sectorSize;
+        flashInfo->blkErase_flag   = true; /* Default set to Block Erase */
+
+        return (Board_flashHandle)&(Board_flashInfo);
+    }
+#elif defined (BOARD_NAND_FLASH_IN)
+    NAND_HANDLE        flashHandle;
+    NAND_Info         *nandInfo;
+
+    if (deviceId == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        /* Open the Nand flash */
+        flashHandle = NAND_open(flashIntf, portNum, params);
+        if (!flashHandle)
+        {
+            return 0;
+        }
+        nandInfo = (NAND_Info *)flashHandle;
+
+        if (deviceId != nandInfo->deviceId)
+        {
+            NAND_close(flashHandle);
+            return 0;
+        }
+
+        flashInfo->flashHandle     = flashHandle;
+        flashInfo->manufacturer_id = nandInfo->manufacturerId;
+        flashInfo->device_id       = nandInfo->deviceId;
+        flashInfo->type            = BOARD_FLASH_NAND;
+        flashInfo->block_count     = nandInfo->blockCnt;
+        flashInfo->page_count      = nandInfo->pageCnt;
+        flashInfo->page_size       = nandInfo->pageSize;
+        flashInfo->spare_size      = nandInfo->spareSize;
+        flashInfo->bboffset        = nandInfo->bbOffset;
+        flashInfo->bblist          = nandInfo->bbList;
+
+        return (Board_flashHandle)(flashInfo);
+    }
+#endif
+
+    return 0;
+}
+
+/******************************************************************************
+ * BOARD_flashClose
+ ******************************************************************************/
+Board_flash_STATUS Board_flashClose(Board_flashHandle handle)
+{
+    Board_FlashInfo *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+#if defined(BOARD_NOR_FLASH_IN)
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        NOR_close(flashInfo->flashHandle);
+    }
+#elif defined (BOARD_NAND_FLASH_IN)
+    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        NAND_close(flashInfo->flashHandle);
+    }
+#endif
+
+    flashInfo->flashHandle = 0;
+
+    return BOARD_FLASH_EOK;
+}
+
+/******************************************************************************
+ * BOARD_flashRead
+ ******************************************************************************/
+Board_flash_STATUS Board_flashRead(Board_flashHandle  handle,
+                                   uint32_t           offset,
+                                   uint8_t           *buf,
+                                   uint32_t           len,
+                                   void              *params)
+{
+    Board_FlashInfo   *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    if (buf == NULL || len == 0)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+
+#if defined(BOARD_NOR_FLASH_IN)
+    uint32_t readMode = 0;
+
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        if (params)
+        {
+            readMode = *((uint32_t *)params);
+        }
+
+        if (NOR_read(flashInfo->flashHandle, offset, len, buf, readMode) \
+                   != NOR_PASS)
+        {
+            return (BOARD_FLASH_EFAIL);
+        }
+        return BOARD_FLASH_EOK;
+    }
+#elif defined (BOARD_NAND_FLASH_IN)
+    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        if (NAND_read(flashInfo->flashHandle, offset, len, buf) \
+            != NAND_PASS)
+        {
+            return (BOARD_FLASH_EFAIL);
+        }
+        return BOARD_FLASH_EOK;
+    }
+#endif
+
+    return BOARD_FLASH_EUNSUPPORTED;
+}
+
+ /**
+ *  \brief             This function computes the sector and page based on an offset
+ *              This function also sets the blkErase_flag to false to support
+ *              Sector erase. This flag is used by the Board_flashEraseBlk()
+ *              to determine the erase type
+ *
+ *     \param          handle                  [IN]    Pointer to Board_FlashHandle.
+ *              offset                 [IN]    Flash Offset to be computed to Sector
+ *              sector              [IN]    Computed Sector number
+ *              page                [IN]    Computed page number
+ *              hybridSector_flag   [IN]       Flag to enable Hybrid Sector Erase
+ *
+ *  \return            Returns Board_flash_STATUS
+ *
+ */
+Board_flash_STATUS Board_flashOffsetToSectorPage(Board_flashHandle  handle,
+                                              uint32_t           offset,
+                                              uint32_t          *sector,
+                                              uint32_t          *page,
+                                              bool              hybridSector_flag)
+{
+    uint32_t leftover, block_count, sector_count, page_size, page_count;
+    Board_FlashInfo *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+    if ((flashInfo->device_id == BOARD_FLASH_ID_S25FL256S) && (hybridSector_flag == false))
+    {
+        /* In case of S25FL256S device if hybridSector_flag is not set indicating
+        uniform sector erase of 64KB, which is handled by Block erase */
+        return Board_flashOffsetToBlkPage(handle, offset, sector, page);
+    }
+
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)
+       )
+    {
+        block_count = flashInfo->block_count;
+        page_size      = flashInfo->page_size;
+        page_count     = flashInfo->page_count;
+       }
+    else
+    {
+        return BOARD_FLASH_EUNSUPPORTED;
+    }
+
+    sector_count = (page_count * page_size * block_count) / flashInfo->sector_size;
+
+    *sector   = offset / flashInfo->sector_size;
+    leftover  = offset % flashInfo->sector_size;
+    *page        = leftover / page_size;
+    if (leftover % page_size)
+    {
+        /* All writes must be page aligned for now */
+        return BOARD_FLASH_EUNSUPPORTED;
+    }
+    if (*sector > sector_count)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+    if (*page > page_count)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+
+    flashInfo->blkErase_flag = false; /* This flag to be set false for Sector erase */
+
+    return BOARD_FLASH_EOK;
+}
+
+/**
+ *  \brief             This function computes the block and page number based on the
+ *              offset. This function also sets the blkErase_flag to true to
+ *              support Block erase. This flag is used by the
+ *              Board_flashEraseBlk() to determine the erase type.
+ *
+ *     \param          handle                  [IN]    Pointer to Board_FlashHandle.
+ *              offset                 [IN]    Flash Offset to be computed to Sector
+ *              page                [IN]    Computed Page number
+ *              page                [IN]    Computed page number
+ *
+ *  \return            Returns Board_flash_STATUS
+ *
+ */
+Board_flash_STATUS Board_flashOffsetToBlkPage(Board_flashHandle  handle,
+                                              uint32_t           offset,
+                                              uint32_t          *block,
+                                              uint32_t          *page)
+{
+    uint32_t leftover, block_size, block_count, page_size, page_count;
+    Board_FlashInfo *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        block_count = flashInfo->block_count;
+        page_size      = flashInfo->page_size;
+        page_count     = flashInfo->page_count;
+       }
+    else
+    {
+        return BOARD_FLASH_EUNSUPPORTED;
+    }
+
+    block_size = (page_count * page_size);
+
+    *block       = offset / block_size;
+    leftover  = offset % block_size;
+    *page        = leftover / page_size;
+    if (leftover % page_size)
+    {
+        /* All writes must be page aligned for now */
+        return BOARD_FLASH_EUNSUPPORTED;
+    }
+    if (*block > block_count)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+    if (*page > page_count)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+
+    flashInfo->blkErase_flag = true; /* This flag to be set true for Block erase */
+    return BOARD_FLASH_EOK;
+}
+
+/******************************************************************************
+ * Computes a block and page based on an offset
+ ******************************************************************************/
+Board_flash_STATUS Board_flashBlkPageToOffset(Board_flashHandle  handle,
+                                              uint32_t          *offset,
+                                              uint32_t           block,
+                                              uint32_t           page)
+{
+    uint32_t        block_count, page_size, page_count;
+    Board_FlashInfo *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        block_count = flashInfo->block_count;
+        page_size      = flashInfo->page_size;
+        page_count     = flashInfo->page_count;
+    }
+    else
+    {
+        return BOARD_FLASH_EUNSUPPORTED;
+    }
+
+    if (block >block_count || page > page_count)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+
+    *offset =   (block * (page_count * page_size)) + (page * page_size);
+
+    return BOARD_FLASH_EOK;
+}
+
+/******************************************************************************
+ * BOARD_flashWrite
+ ******************************************************************************/
+Board_flash_STATUS Board_flashWrite(Board_flashHandle  handle,
+                                    uint32_t           offset,
+                                    uint8_t           *buf,
+                                    uint32_t           len,
+                                    void              *params)
+{
+    Board_FlashInfo *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    if (buf == NULL || len == 0)
+    {
+        return BOARD_FLASH_EINVALID;
+    }
+
+#if defined(BOARD_NOR_FLASH_IN)
+    uint32_t writeMode = 0;
+
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        if (params)
+        {
+            writeMode = *((uint32_t *)params);
+        }
+
+        if (NOR_write(flashInfo->flashHandle, offset, len, buf,
+                 writeMode) != NOR_PASS)
+        {
+            return (BOARD_FLASH_EFAIL);
+        }
+        return BOARD_FLASH_EOK;
+    }
+#elif defined (BOARD_NAND_FLASH_IN)
+    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        if (NAND_write(flashInfo->flashHandle, offset, len, buf) != NAND_PASS)
+        {
+           return (BOARD_FLASH_EFAIL);
+        }
+        return BOARD_FLASH_EOK;
+    }
+#endif
+
+    return BOARD_FLASH_EUNSUPPORTED;
+}
+
+/**
+ *  \brief  platform_device_erase_block
+ *
+ *  Board_flashEraseBlk supports Block and Sector erase based on the blkErase_flag
+ *  This API expects blkErase_flag to be set to the appropriate Boolean value to
+ *  determine the type of erase.
+ *
+ *  blkErase_flag is set in one of the Board_flashOffsetToSectorPage() or
+ *  Board_flashOffsetToBlkPage() APIs for sector or block erase respectively.
+ *
+ *  \param
+ *  handle  - Handle to the flash device
+ *  blk_num - Block number to be erased when blkErase_flag=true
+ *            Sector number to be erased when blkErase_flag=false
+ *
+ *
+ ********************************************************************************/
+Board_flash_STATUS Board_flashEraseBlk(Board_flashHandle handle,
+                                       uint32_t          blk_num)
+{
+    Board_FlashInfo    *flashInfo;
+
+    if (!handle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    flashInfo = (Board_FlashInfo *)handle;
+    if (!flashInfo->flashHandle)
+    {
+        return BOARD_FLASH_EFAIL;
+    }
+
+    if (flashInfo->blkErase_flag)
+    {
+        if (blk_num > flashInfo->block_count)
+        {
+            return BOARD_FLASH_EFAIL;
+        }
+    }
+
+#if defined(BOARD_NOR_FLASH_IN)
+    if (                                                                \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S25FL256S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT29W160EB)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25X32VSFIG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_NORN25Q128A13ESF40F) || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT25QU512ABB)        || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU512ABA1G12)       || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MT35XU256ABA1G12)    || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S71KS512S)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_S28HS512T)           || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B16CSAG)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_GD25B64CW2G)         || \
+        (flashInfo->device_id == BOARD_FLASH_ID_W25Q16FWSF)          || \
+        (flashInfo->device_id == BOARD_FLASH_ID_MX25V1635F)
+       )
+    {
+        if (NOR_erase (flashInfo->flashHandle, blk_num, flashInfo->blkErase_flag) != NOR_PASS)
+        {
+            return (BOARD_FLASH_EFAIL);
+        }
+        return BOARD_FLASH_EOK;
+    }
+#elif defined (BOARD_NAND_FLASH_IN)
+    NAND_STATUS status;
+
+    if (flashInfo->device_id == BOARD_FLASH_ID_MT29F4G08ABAEAWP)
+    {
+        if (flashInfo->bblist[blk_num] == NAND_BAD_BLOCK)
+        {
+            return (BOARD_FLASH_EFAIL);
+        }
+
+        status = NAND_erase(flashInfo->flashHandle, blk_num);
+        if (status != NAND_PASS)
+        {
+            if (status == NAND_BLOCK_BAD)
+            {
+                flashInfo->bblist[blk_num] = NAND_BAD_BLOCK;
+            }
+            return (BOARD_FLASH_EFAIL);
+        }
+        else
+        {
+            return (BOARD_FLASH_EOK);
+        }
+    }
+#endif
+
+    return BOARD_FLASH_EUNSUPPORTED;
+}
+
 
index 2eeaa4394d2fb5bdf757961ca819d3b0029b2d07..2b2d4ac33485b4f665108eb81b4a042eabdbc9c7 100644 (file)
@@ -121,7 +121,7 @@ typedef int32_t Board_flash_STATUS;       /** Board Flash API return type */
 #define BOARD_FLASH_ID_MX25V1635F          (0x2315U)  /** Macronix 16Mbit NOR Flash **/
 #define BOARD_FLASH_ID_GD25B16CSAG         (0x4015U)  /** Giga device 16Mbit NOR Flash **/
 #define BOARD_FLASH_ID_GD25B64CW2G         (0x4017U)  /** Giga device 16Mbit NOR Flash **/
-#define BOARD_FLASH_ID_W25Q80VSFIG         (0x4014U)  /** Winbond flash model on QT **/
+#define BOARD_FLASH_ID_W25Q16FWSF          (0x6015U)  /** Winbond flash model on TPR12 QT **/
 
 /**
  * @brief      Board specific Flash Device Identifiers.
diff --git a/packages/ti/board/src/flash/nor/device/w25q16fwsf.h b/packages/ti/board/src/flash/nor/device/w25q16fwsf.h
new file mode 100644 (file)
index 0000000..44d3a11
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2020, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/**
+ *
+ * \file  w25q16fwsf.h
+ *
+ * \brief This file contains W25Q16FW NOR device definitions
+ *
+ *****************************************************************************/
+#ifndef _W25Q16FWSF_H_
+#define _W25Q16FWSF_H_
+
+#include <ti/drv/spi/SPI.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**************************************************************************
+ **                       Macro Definitions
+ **************************************************************************/
+
+/** Macro to enable 4 byte addressing */
+/* #define EXT_ADDRESS_ENABLE        (0U) */
+
+/** FLASH device specific items (note: sizes are in bytes) */
+#define NOR_BLOCK_SIZE              (64U * 1024U)
+#define NOR_SECTOR_SIZE             (4U * 1024U)
+#define NOR_SIZE                    ((16U/8U) * 1024U * 1024U)
+#define NOR_NUM_BLOCKS              (NOR_SIZE / NOR_BLOCK_SIZE)
+#define NOR_SIZE_2MBIT_FLASH        (2U * 1024U * 1024U)
+#define NOR_NUM_BLOCKS_2MBIT_FLASH  (NOR_SIZE_2MBIT_FLASH / NOR_BLOCK_SIZE)
+#define NOR_NUM_SECTORS             (NOR_SIZE / NOR_SECTOR_SIZE)
+#define NOR_PAGE_SIZE               (256U)
+#define NOR_NUM_PAGES_PER_SECTOR    (NOR_SECTOR_SIZE / NOR_PAGE_SIZE)
+#define NOR_NUM_PAGES_PER_BLOCK     (NOR_BLOCK_SIZE / NOR_PAGE_SIZE)
+
+/** Flash device commands */
+#define NOR_BE_SECTOR_NUM           (-1U)
+#define NOR_CMD_BULK_ERASE          (0xC7U)
+#define NOR_CMD_WRSR_S0_S7          (0x01U)
+#define NOR_CMD_WRSR_S8_S15         (0x31U)
+#define NOR_CMD_WRSR_S16_S23        (0x11U)
+#define NOR_CMD_WREN                (0x06U)
+#define NOR_CMD_RDSR_S0_S7          (0x05U)
+#define NOR_CMD_RDSR_S8_S15         (0x35U)
+#define NOR_CMD_RDSR_S16_S23        (0x15U)
+#define NOR_CMD_RDID                (0x9FU)
+
+/** Commands for 3 byte addressing */
+
+#define NOR_CMD_BLOCK_ERASE         (0xD8U)
+#define NOR_CMD_SECTOR_ERASE        (0x20U)
+#define NOR_CMD_READ                (0x03U)
+#define NOR_CMD_DUAL_READ           (0x3BU)
+#define NOR_CMD_QUAD_READ           (0x6BU)
+#define NOR_CMD_PAGE_PROG           (0x02U)
+#define NOR_CMD_QUAD_PAGE_PROG      (0x32U)
+
+/* \brief Read ID command definitions */
+#define NOR_RDID_NUM_BYTES          (0x3U)
+#define NOR_MANF_ID                 (0xEFU)   /* Manufacturer ID */
+#define NOR_MANF_ID_MX25V1635F      (0xC2U)   /* Manufacturer ID */
+#define NOR_DEVICE_ID               (0x6015U)  /* Device ID */
+#define NOR_DEVICE_ID_GD25B16CSAG   (0x4015U)  /* Device ID */
+#define NOR_DEVICE_ID_MX25V1635F    (0x2315U)  /* Device ID */
+
+/** Status Register, Write-in-Progress bit */
+#define NOR_SR_WIP                             (1U << 0U)
+#define NOR_SR_QE                              (1U << 1U)
+
+/** Dummy cycles for Read operation */
+#define NOR_SINGLE_READ_DUMMY_CYCLE    (0U)
+#define NOR_DUAL_READ_DUMMY_CYCLE      (8U)
+#define NOR_QUAD_READ_DUMMY_CYCLE      (8U)
+
+/** In Micro seconds */
+#define NOR_PAGE_PROG_TIMEOUT          (400U)
+#define NOR_SECTOR_ERASE_TIMEOUT       (600U * 1000U)
+#define NOR_WRR_WRITE_TIMEOUT          (600U * 1000U)
+#define NOR_BULK_ERASE_TIMEOUT     (110U * 1000U * 1000U)
+
+#define NOR_MANUFACTURE_ID          (0x01U)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _W25Q16FWSF_H_ */
+
+/* Nothing past this point */
index b72745230b84fc7927a14d3c6bd9ff9b53b0e72d..a72043629a6294039ec0971c516445809bf75864 100644 (file)
@@ -56,8 +56,10 @@ extern "C" {
 #include <ti/board/src/flash/nor/device/s25fl512s.h>
 #elif defined (iceK2G)
 #include <ti/board/src/flash/nor/device/s25fl256s.h>
-#elif defined (tpr12_evm) || defined (tpr12_qt)
+#elif defined (tpr12_evm)
 #include <ti/board/src/flash/nor/device/gd25b64cw2g.h>
+#elif defined (tpr12_qt)
+#include <ti/board/src/flash/nor/device/w25q16fwsf.h>
 #endif
 
 /**************************************************************************
index 80cd22452f02c42fd01d6482b1224f8a4584e3f6..b0e25243c3bfcfc98425db34abbcce3f8c409a70 100644 (file)
@@ -86,7 +86,7 @@ extern "C" {
 #elif defined(tpr12_evm)
 #define QSPI_FLASH_ID           BOARD_FLASH_ID_GD25B64CW2G
 #elif defined(tpr12_qt)
-#define QSPI_FLASH_ID           BOARD_FLASH_ID_W25Q80VSFIG
+#define QSPI_FLASH_ID           BOARD_FLASH_ID_W25Q16FWSF
 #endif
 
 #if !(defined(SOC_K2G) || defined(j721e_evm))
old mode 100755 (executable)
new mode 100644 (file)
index 2601f8f..3bd9710
@@ -24,14 +24,13 @@ PACKAGE_SRCS_COMMON = .
 INCLUDE_EXTERNAL_INTERFACES = pdk
 
 # List all the components required by the application
-COMP_LIST_COMMON = osal_nonos csl
+COMP_LIST_COMMON = $(PDK_COMMON_BAREMETAL_COMP)
 
 SRCS_COMMON += sbl_smp_multicore.c
 
 # asm files and linker scripts change due to different tool chains for R5 and A53
 ifeq ($(CORE),$(filter $(CORE), mcu1_0))
   SRCS_ASM_COMMON = sbl_smp_r5.asm
-  COMP_LIST_COMMON += uart board csl_init
 endif
 
 
index 711701bcf4a1f60a62f2d01181a985044240ca68..c5f7485a07ceccdd579ff5a90a642fa99ab160c6 100644 (file)
@@ -66,22 +66,40 @@ int main()
 
 int main()
 {
+#if !defined(tpr12_qt)
+    Board_initCfg boardCfg;
+
+    boardCfg = BOARD_INIT_PINMUX_CONFIG |
+        BOARD_INIT_MODULE_CLOCK |
+        BOARD_INIT_UART_STDIO;
     /* Board Init UART for logging. */
-    Board_init(BOARD_INIT_UART_STDIO);
+    Board_init(boardCfg);
     UART_printf("MPU SMP boot test\r\n");
+#endif
 
     CacheP_Inv((const void *)DSP_POKE_MEM_ADDR,sizeof(int));
-       while (*(DSP_POKE_MEM_ADDR) != DSP_CORE_UP_PATTERN)
-       {
+    while (*(DSP_POKE_MEM_ADDR) != DSP_CORE_UP_PATTERN)
+    {
         CacheP_Inv((const void *)DSP_POKE_MEM_ADDR,sizeof(int));
-       }
+    }
  
     /* Check if MPUs have run in AMP mode */
     if (*(DSP_POKE_MEM_ADDR) != DSP_CORE_UP_PATTERN)
+    {
+#if !defined(tpr12_qt)
         UART_printf("Some tests have failed\r\n");
+#else
+        printf("Some tests have failed\r\n");
+#endif
+    }
     else
+    {
+#if !defined(tpr12_qt)
         UART_printf("All tests have passed\r\n");
-
+#else
+        printf("All tests have passed\r\n");
+#endif
+    }
     return 0;
 }
 #endif
index a26dbb58aed205ce80fc30ed85d1abeaa0512014..2ec42441d5251ff0eec6c3869e31b6f2f212b651 100644 (file)
 #if defined(tpr12_evm)
 #define QSPI_FLASH_ID           BOARD_FLASH_ID_GD25B64CW2G
 #elif defined(tpr12_qt)
-#define QSPI_FLASH_ID           BOARD_FLASH_ID_W25Q80VSFIG
+#define QSPI_FLASH_ID           BOARD_FLASH_ID_W25Q16FWSF
 #endif
 
+#if defined(tpr12_qt)
+#undef  QSPI_OFFSET_SI
+#define QSPI_OFFSET_SI              (0x80000U)
+#endif
+
+
 /* QSPI Flash Read Sector API. */
 static int32_t SBL_QSPI_ReadSectors(void *dstAddr,
                              void *srcOffsetAddr,
index 4e42b290392ef06fb97185c71c0491fd9d8eba7c..f031908dd57f693f780714f11d389152466196f9 100644 (file)
@@ -335,7 +335,7 @@ ifeq ($(BUILD_OS_TYPE),baremetal)
         CONFIG_BLD_LNK_r5f   = $(pdk_PATH)/ti/build/$(SOC)/linker_r5.lds
     endif
     ifeq ($(CONFIG_BLD_XDC_c66),)
-        CONFIG_BLD_LNK_c66   = $(pdk_PATH)/ti/build/$(SOC)/linker_c66.cmd
+        CONFIG_BLD_LNK_c66   = $(pdk_PATH)/ti/build/$(SOC)/linker_c66_baremetal.cmd
     endif
   endif
 endif
index b46f8dec68877b1eb27a91a28d3fadccee376742..ded83cb14ae027ea7a92a806e0415d7b77a9a8f3 100644 (file)
@@ -158,6 +158,10 @@ ifneq ($(XDC_CFG_FILE_$(CORE)),)
   _CFLAGS += $(CFLAGS_XDCINTERNAL) $(CFLAGS_FOR_REENTRANCY_SUPPORT)
 endif
 
+ifeq ($(XDC_CFG_FILE_$(CORE)),)
+  LNKFLAGS_INTERNAL_COMMON += -u CSL_Entry
+endif
+
 # Decide the compile mode
 COMPILEMODE = -fc
 ifeq ($(CPLUSPLUS_BUILD), yes)
index f4ebae7462654c545d53a98ab484e766c716ec8a..5a40e926fbd4ee8e8852e0fdb6fc8319ed6689ea 100644 (file)
@@ -71,8 +71,6 @@ SECTIONS
     /* hard addresses forces vecs to be allocated there */
     .vecs:  {. = align(32); } > 0x00800000
 
-    .csl_vect: load >  L2SRAM
-
     .fardata:  {} > L2SRAM
     .const:    {} > L2SRAM
     .switch:   {} > L2SRAM
diff --git a/packages/ti/build/tpr12/linker_c66_baremetal.cmd b/packages/ti/build/tpr12/linker_c66_baremetal.cmd
new file mode 100644 (file)
index 0000000..f997d80
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define L1P_CACHE_SIZE (16*1024)
+#define L1D_CACHE_SIZE (16*1024)
+
+MEMORY
+{
+PAGE 0:
+
+#if (L1P_CACHE_SIZE < 0x8000)
+    L1PSRAM:        o = 0x00E00000, l = (0x00008000 - L1P_CACHE_SIZE)
+#endif
+#if (L1D_CACHE_SIZE < 0x8000)
+    L1DSRAM:        o = 0x00F00000, l = (0x00008000 - L1D_CACHE_SIZE)
+#endif
+    L2SRAM:   o = 0x00800000, l = 0x00060000
+    L3SRAM:   o = 0x88000000, l = 0x00390000
+    HWA_RAM:  o = 0x82000000, l = 0x00020000
+
+    /* PAGEs 1 and onwards are for overlay purposes for memory optimization.
+       Some examples:
+       1. Overlay one-time only text with uninitialized data.
+       2. Overlay L1PSRAM data path processing fast code and use copy tables
+          to page in (before entering data path) and out of L1PSRAM (when entering
+          sleep/low power).
+    */
+PAGE 1:
+    L3SRAM:   o = 0x88000000, l = 0x00390000
+}
+
+-stack  0x2000                              /* SOFTWARE STACK SIZE           */
+-heap   0x2000                              /* HEAP AREA SIZE                */
+
+
+SECTIONS
+{
+    /* hard addresses forces vecs to be allocated there */
+    .csl_vect: {. = align(32); } > 0x00800000
+
+    .fardata:  {} > L2SRAM
+    .const:    {} > L2SRAM
+    .switch:   {} > L2SRAM
+    .cio:      {} > L2SRAM
+    .data:     {} > L2SRAM
+    .sysmem:   {} > L2SRAM
+
+    GROUP
+    {
+    .rodata:
+    .bss:
+    .neardata:
+    } > L2SRAM
+    .stack:    {} > L2SRAM
+    .cinit:    {} > L2SRAM
+    .far:      {} > L2SRAM
+
+    .text: {} > L2SRAM
+}
+
index a2b8b076ec14ca8cd018bf109a7f9bc78b271ff4..9d648b5d18d47f6201152262f5d031085ee508c6 100644 (file)
@@ -789,7 +789,7 @@ export QSPI_FileFlashWrite_Dma_TestApp_XDC_CONFIGURO
 export QSPI_FileFlashWrite_Dma_TestApp_MAKEFILE
 QSPI_FileFlashWrite_Dma_TestApp_PKG_LIST = QSPI_FileFlashWrite_Dma_TestApp
 QSPI_FileFlashWrite_Dma_TestApp_INCLUDE = $(QSPI_FileFlashWrite_Dma_TestApp_PATH)
-QSPI_FileFlashWrite_Dma_TestApp_BOARDLIST = tpr12_evm
+QSPI_FileFlashWrite_Dma_TestApp_BOARDLIST = tpr12_evm tpr12_qt
 export QSPI_FileFlashWrite_Dma_TestApp_BOARDLIST
 QSPI_FileFlashWrite_Dma_TestApp_$(SOC)_CORELIST = $(drvspi_$(SOC)_CORELIST)