/**
 * @file hv_drv_FlashDB.c
 * @brief flash driver file for get param .
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-06-19
 * @copyright Copyright(c),2023-6, Hiview Software. All rights reserved.
 * </table>
 */

#include "hv_comm_DataType.h"
#include "hv_drv_FlashDB.h"

static void Hv_Drv_FlashDB_GetN25Q(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd    = N25Q_ReadIDCmd;
    pstFlashAttr->FlashReadIdMultiIoCmd     = N25Q_MultiReadIDCmd;
    pstFlashAttr->FlashSectionEraseCmd      = N25Q_SectorErase;
    pstFlashAttr->FlashMultiSectionEraseCmd = N25Q_MultiSectorErase;
    pstFlashAttr->FlashChipEraseCmd         = N25Q_ChipErase;
    pstFlashAttr->FlashProgStandardCmd      = N25Q_PageProg;
    pstFlashAttr->FlashProgDualCmd          = N25Q_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd          = N25Q_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd           = N25Q_PageProgQpi;
    pstFlashAttr->FlashReadStandardCmd      = N25Q_PageRead;
    pstFlashAttr->FlashReadDualCmd          = N25Q_PageReadDual;
    pstFlashAttr->FlashReadQuadCmd          = N25Q_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd           = N25Q_PageReadQpi;
    pstFlashAttr->FlashReadStatusCmd        = N25Q_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd           = N25Q_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth          = N25Q_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual            = N25Q_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi             = N25Q_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycleFastDual        = N25Q_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad        = N25Q_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashEraseCompltWait      = N25Q_Flash_ReadBusyCompltWait;
    return;
}

static void Hv_Drv_FlashDB_GetMT25(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd    = MT25_ReadIDCmd;
    pstFlashAttr->FlashReadIdMultiIoCmd     = MT25_MultiReadIDCmd;
    pstFlashAttr->FlashSectionEraseCmd      = MT25_SectorErase;
    pstFlashAttr->FlashMultiSectionEraseCmd = MT25_MultiSectorErase;
    pstFlashAttr->FlashChipEraseCmd         = MT25_ChipErase;
    pstFlashAttr->FlashProgStandardCmd      = MT25_PageProg;
    pstFlashAttr->FlashProgDualCmd          = MT25_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd          = MT25_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd           = MT25_PageProgQpi;
    pstFlashAttr->FlashReadStandardCmd      = MT25_PageRead;
    pstFlashAttr->FlashReadDualCmd          = MT25_PageReadDual;
    pstFlashAttr->FlashReadQuadCmd          = MT25_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd           = MT25_PageReadQpi;
    pstFlashAttr->FlashReadStatusCmd        = MT25_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd           = MT25_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth          = MT25_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual            = MT25_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi             = MT25_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycleFastDual        = MT25_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad        = MT25_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashEraseCompltWait      = MT25_Flash_ReadBusyCompltWait;
    return;
}

static void Hv_Drv_FlashDB_GetP25Q(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd    = P25Q_ReadIDCmd;
    pstFlashAttr->FlashReadIdMultiIoCmd     = P25Q_ReadIDDual;
    pstFlashAttr->FlashSectionEraseCmd      = P25Q_SectorErase;
    pstFlashAttr->FlashChipEraseCmd         = P25Q_ChipErase;
    pstFlashAttr->FlashProgStandardCmd      = P25Q_PageProg;
    pstFlashAttr->FlashProgDualCmd          = P25Q_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd          = P25Q_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd           = P25Q_PageProgQpi;
    pstFlashAttr->FlashReadStandardCmd      = P25Q_PageRead;
    pstFlashAttr->FlashReadDualCmd          = P25Q_PageReadDual;
    pstFlashAttr->FlashReadQuadCmd          = P25Q_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd           = P25Q_PageReadQpi;
    pstFlashAttr->FlashReadStatusCmd        = P25Q_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd           = P25Q_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth          = P25Q_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual            = P25Q_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi             = P25Q_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycleFastDual        = P25Q_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad        = P25Q_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashQuadEnable           = P25Q_Flash_QuadEnable;
    pstFlashAttr->FlashQuadDisable          = P25Q_Flash_QuadDisable;
    pstFlashAttr->FlashEraseCompltWait      = P25Q_Flash_ReadBusyCompltWait;
    return;
}

static void Hv_Drv_FlashDB_GetW25Q(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd    = W25Q_ReadIDCmd;
    pstFlashAttr->FlashReadIdMultiIoCmd     = W25Q_ReadIDDual;
    pstFlashAttr->FlashSectionEraseCmd      = W25Q_SectorErase;
    pstFlashAttr->FlashMultiSectionEraseCmd = W25Q_MultiSectorErase;
    pstFlashAttr->FlashChipEraseCmd         = W25Q_ChipErase;
    pstFlashAttr->FlashProgStandardCmd      = W25Q_PageProg;
    pstFlashAttr->FlashProgDualCmd          = W25Q_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd          = W25Q_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd           = W25Q_PageProgQpi;
    pstFlashAttr->FlashReadStandardCmd      = W25Q_PageRead;
    pstFlashAttr->FlashReadDualCmd          = W25Q_PageReadDual;
    pstFlashAttr->FlashReadQuadCmd          = W25Q_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd           = W25Q_PageReadQpi;
    pstFlashAttr->FlashReadStatusCmd        = W25Q_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd           = W25Q_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth          = W25Q_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual            = W25Q_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi             = W25Q_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycleFastDual        = W25Q_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad        = W25Q_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashEraseCompltWait      = W25Q_Flash_ReadBusyCompltWait;
    return;
}

static void Hv_Drv_FlashDB_GetGD25(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd    = GD25_ReadIDCmd;
    pstFlashAttr->FlashSectionEraseCmd      = GD25_SectorErase;
    pstFlashAttr->FlashMultiSectionEraseCmd = GD25_MultiSectorErase;
    pstFlashAttr->FlashChipEraseCmd         = GD25_ChipErase;
    pstFlashAttr->FlashProgStandardCmd      = GD25_PageProg;
    pstFlashAttr->FlashProgDualCmd          = GD25_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd          = GD25_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd           = GD25_PageProgQpi;
    pstFlashAttr->FlashReadStandardCmd      = GD25_PageRead;
    pstFlashAttr->FlashReadDualCmd          = GD25_PageReadDual;
    pstFlashAttr->FlashReadQuadCmd          = GD25_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd           = GD25_PageReadQpi;
    pstFlashAttr->FlashReadStatusCmd        = GD25_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd           = GD25_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth          = GD25_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual            = GD25_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi             = GD25_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycleFastDual        = GD25_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad        = GD25_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashQuadEnable           = GD25_Flash_QuadEnable;
    pstFlashAttr->FlashQuadDisable          = GD25_Flash_QuadDisable;
    pstFlashAttr->FlashEraseCompltWait      = GD25_Flash_ReadBusyCompltWait;
    return;

}

static void Hv_Drv_FlashDB_GetMX25(FlashAttribute* pstFlashAttr)
{
    pstFlashAttr->FlashReadIdStandardCmd                = MX25_ReadIDCmd;
    pstFlashAttr->FlashSectionEraseCmd                  = MX25_SectorErase;
    pstFlashAttr->FlashSectionEraseCmd_4ByteAddr        = MX25_SectorErase_4ByteAddr;
    pstFlashAttr->FlashMultiSectionEraseCmd             = MX25_MultiSectorErase;
    pstFlashAttr->FlashMultiSectionEraseCmd_4ByteAddr   = MX25_MultiSectorErase_4ByteAddr;
    pstFlashAttr->FlashChipEraseCmd                     = MX25_ChipErase;
    pstFlashAttr->FlashProgStandardCmd                  = MX25_PageProg;
    pstFlashAttr->FlashProgStandardCmd_4ByteAddr        = MX25_PageProg_4ByteAddr;
    pstFlashAttr->FlashProgDualCmd                      = MX25_PageProgDual;
    pstFlashAttr->FlashProgQuadCmd                      = MX25_PageProgQuad;
    pstFlashAttr->FlashProgQpiCmd                       = MX25_PageProgQpi;
    pstFlashAttr->FlashProgQpiCmd_4ByteAddr             = MX25_PageProgQpi_4ByteAddr;
    pstFlashAttr->FlashProg4xIoCmd                      = MX25_PageProg4xIo;
    pstFlashAttr->FlashProg4xIoCmd_4ByteAddr            = MX25_PageProg4xIo_4ByteAddr;
    pstFlashAttr->FlashReadStandardCmd                  = MX25_PageRead;
    pstFlashAttr->FlashReadStandardCmd_4ByteAddr        = MX25_PageRead_4ByteAddr;
    pstFlashAttr->FlashReadDualCmd                      = MX25_PageReadDual;
    pstFlashAttr->FlashReadDualCmd_4ByteAddr            = MX25_PageReadDual_4ByteAddr;
    pstFlashAttr->FlashReadQuadCmd                      = MX25_PageReadQuad;
    pstFlashAttr->FlashReadQpiCmd                       = MX25_PageReadQpi;
    pstFlashAttr->FlashReadQpiCmd_4ByteAddr             = MX25_PageReadQpi_4ByteAddr;
    pstFlashAttr->FlashRead4xIoCmd                      = MX25_PageRead4xIo;
    pstFlashAttr->FlashRead4xIoCmd_4ByteAddr            = MX25_PageRead4xIo_4ByteAddr;
    pstFlashAttr->FlashReadStatusCmd                    = MX25_Flash_ReadStatus;
    pstFlashAttr->FlashWriteEnCmd                       = MX25_Flash_WriteEn;
    pstFlashAttr->FlashInstruWidth                      = MX25_Flash_InstruWidth;
    pstFlashAttr->FlashCycleDual                        = MX25_Flash_WaitCycleDual;
    pstFlashAttr->FlashCycleQpi                         = MX25_Flash_WaitCycleQpi;
    pstFlashAttr->FlashCycle4xIo                        = MX25_Flash_WaitCycle4xIo;
    pstFlashAttr->FlashCycleFastDual                    = MX25_Flash_WaitCycleFastDual;
    pstFlashAttr->FlashCycleFastQuad                    = MX25_Flash_WaitCycleFastQuad;
    pstFlashAttr->FlashQuadEnable                       = MX25_Flash_QuadEnable;
    pstFlashAttr->FlashQuadDisable                      = MX25_Flash_QuadDisable;
    pstFlashAttr->FlashEraseCompltWait                  = MX25_Flash_ReadBusyCompltWait;
    return;
}

Status Hv_Drv_FlashDB_GetAttribute(FlashAttribute* pstFlashAttr, FlashModel enFlashModel)
{
    if (enFlashModel == FLASH_N25Q)
    {
        Hv_Drv_FlashDB_GetN25Q(pstFlashAttr);
    }
    else if (enFlashModel == FLASH_MT25)
    {
        Hv_Drv_FlashDB_GetMT25(pstFlashAttr);
    }
    else if (enFlashModel == FLASH_P25Q)
    {
        Hv_Drv_FlashDB_GetP25Q(pstFlashAttr);
    }
    else if (enFlashModel == FLASH_W25Q)
    {
        Hv_Drv_FlashDB_GetW25Q(pstFlashAttr);
    }
    else if (enFlashModel == FLASH_GD25)
    {
        Hv_Drv_FlashDB_GetGD25(pstFlashAttr);
    }
    else if (enFlashModel == FLASH_MX25)
    {
        Hv_Drv_FlashDB_GetMX25(pstFlashAttr);
    }
    return HV_SUCCESS;
}

