/*************************************************************************** * Copyright (c) 2003-2010, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: flash data store abstraction * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #ifndef __BSPI_FLASH_H__ #define __BSPI_FLASH_H__ #include "bsettop_types.h" /*************************************************************************** Summary: The SPI flash interface handle. Description: An opaque handle SPI device control. See Also: bspi_open() ****************************************************************************/ typedef struct bspi *bspi_t; /*************************************************************************** Summary: SPI flash settings structure. Description: SPI Flash configuration parameters for the attached flash type. See Also: bspi_identify() ****************************************************************************/ typedef struct bspi_settings_t { unsigned char se_cmd; /* Flash sector erase command */ unsigned int sector_size; /* Flash sector size */ unsigned int page_size; /* Flash page size (usually 0x100) */ unsigned int total_size; /* Flash size */ }bspi_settings_t; #ifdef __cplusplus extern "C" { #endif /*************************************************************************** Summary: Use RDID command to determine flash settings. Description: Uses RDID command to determine flash type and configure the settings structure. Returns: non-zero on failure. See Also: bspi_open(), ****************************************************************************/ bresult bspi_identify( bspi_settings_t *p_settings /* [out] SPI flash settings structure */ ); /*************************************************************************** Summary: Initialize and return SPI interface handle. Description: Initialize and return a SPI interface handle. This function expects the bspi_settings_t structure to be initialized. Returns: SPI interface handle, non-zero on failure. See Also: bspi_close(), bspi_identify(), ****************************************************************************/ bresult bspi_open( bspi_t *h_spi, /* [out] Return SPI handle */ bspi_settings_t *p_settings /* [in] SPI flash settings */ ); /*************************************************************************** Summary: Release SPI interface handle. Description: Release SPI interface handle and any other SPI flash resources. Returns: non-zero on failure. See Also: bspi_open(), ****************************************************************************/ bresult bspi_close( bspi_t h_spi /* [in] SPI handle */ ); /*************************************************************************** Summary: Reads a single byte from flash using the SPI interface, not memory mapped spi. Description: Reads a single byte from flash using the SPI interface, not the memory mapped SPI interface. It will disable the BSP (memory mapped SPI interface) temporarily. Returns: non-zero on failure. See Also: bspi_open(), ****************************************************************************/ bresult bspi_read( bspi_t h_spi, /* [in] SPI handle */ unsigned int offset, /* [in] Offset in bytes */ unsigned char *data /* [out] buffer to receive data */ ); /*************************************************************************** Summary: Erase flash sector at offset. Description: Erase flash sector at offset. It will disable the BSP (memory mapped SPI interface) temporarily. Returns: non-zero on failure. See Also: bspi_open(),bspi_page_program() ****************************************************************************/ bresult bspi_sector_erase( bspi_t h_spi, /* [in] SPI handle */ unsigned int offset /* [in] Offset in bytes */ ); /*************************************************************************** Summary: Program the flash page at offset with the data provided in the buffer. Description: Program the flash page at offset with the data provided in the buffer. It will disable the BSP (memory mapped SPI interface) temporarily. Returns: non-zero on failure. See Also: bspi_open(), bspi_sector_erase() ****************************************************************************/ bresult bspi_page_program( bspi_t h_spi, /* [in] SPI handle */ unsigned int offset, /* [in] Offset in bytes */ unsigned char *buf, /* [in] Data buffer to program */ int len /* [in] Size in bytes of data buffer */ ); /*************************************************************************** Summary: Flush BSPI interface. ****************************************************************************/ void bspi_flush(void); void mspi_enable_bspi(void); void mspi_disable_bspi(void); #ifdef __cplusplus } #endif #endif /* __BSPI_FLASH_H__ */