Generic Serial Flash Interface Intel® FPGA IP User Guide

ID 683419
Date 11/09/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

1.9.1. Driver API

Table 9.  intel_gsfi_get_info
Prototype: intel_gsfi_get_info (alt_flash_fd *fd, flash_region **info, int *number_of_regions
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • fd – pointer to the flash device structure
  • info – pointer to the flash region
  • number_of_regions - pointer to the number of regions
Return: Return 0 or otherwise return
  • EINVAL for Invalid argument
  • EIO for possible hardware problem
Description: Provide information about the flash devices. Returns the flash memory offset, flash memory size, number of flash device, number of sectors, and sector size values.
Table 10.  intel_gsfi_read
Prototype: intel_gsfi_read (alt_flash_dev *flash_info, int offset, void *dest_addr, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to flash device structure
  • offset – flash address
  • dest_addr – destination buffer
  • length – size of read data
Return: Return 0 for success and otherwise return:
  • EINVAL for invalid argument
  • ENODEV for no device detected
Description: Read data from selected address. This function copies data in the flash and passes it to the destination buffer.
Table 11.  intel_gsfi_erase_block
Prototype: intel_gsfi_erase_block (alt_flash_dev *flash_info, int block_offset)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • block_offset – byte-address offset, from the start of flash of the sector to be erased
Return: Return 0 for success and otherwise return:
  • EINVAD for invalid argument
  • ENODEV for no device detected
  • EIO for erase failed and sector might be protected
  • ETIME for timeout after Flash_Timeout
Description: Erase a single flash sector.
Table 12.  intel_gsfi_write_block
Prototype: intel_gsfi_write_block (alt_flash_dev *flash_info, int block_offset, int data_offset, const void *data, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • block_offset – byte-address offset, from the start of flash of the sector to be written
  • data_offset – byte offset (unaligned access) of write into memory
  • data – data to be written
  • length – size of writing
Return:

Return 0 for success and otherwise:

  • EINVAL for invalid argument
  • ENODEV for no device detected
  • EIO for write failed and sector might be protected
  • ETIME for timeout after Flash_Timeout
Description: Write one block/sector of data to the flash. The length of the write cannot spill into the adjacent sector, the function assumes the address is empty, otherwise you should erase it first.
Table 13.  intel_gsfi_write
Prototype: intel_gsfi_write (alt_flash_dev *flash_info, int offset, const void *src_addr, int length)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • offset – flash address (unaligned access) of write to flash memory
  • src_addr – source buffer
  • length – size of writing
Return: Return 0 for success and otherwise:
  • EINVAL for invalid argument
  • ENODEV for no device detected
  • EIO for write failed and sector might be protected
  • ETIME for timeout after Flash_Timeout
Description: Program the data into the flash at the selected address. This function automatically erases the block as needed.
Table 14.  intel_gsfi_lock
Prototype: intel_gsfi_lock (alt_flash_dev *flash_info, alt_u32 sectors_to_lock)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • sectors_to_lock – block protection settings
    • Bit 4 : Top/Bottom bit (TB) or Block Protection bit 4 (BP4)
    • Bit 3 : BP3
    • Bit 2 : BP2
    • Bit 1 : BP1
    • Bit 0 : BP0
Return: Return 0 for success and otherwise:
  • EINVAL for invalid argument
  • ENODEV for no device detected
  • ENOLCK for One-Time Programmable (OTP) TB bit write failed
  • EIO for sector protection failed
  • ETIME for timeout after Flash_Timeout
Description: Perform block protection on a range of the flash sectors. The protected flash sectors cannot be written or erased. Refer to the flash device datasheet for the protected area definitions.
Table 15.  intel_gsfi_chip_select
Prototype: intel_gsfi_chip_select (intel_gsfi_dev *flash_info, int flash_device)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • flash_device - flash device selection
    • 0x0 : First device
    • 0x1 : Second device
    • 0x2 : Third device
Return: Return 0 for success and otherwise:
  • EINVAL for invalid argument
  • ENODEV for no device detected
Description: Select the flash device.
Table 16.  intel_gsfi_config
Prototype: intel_gsfi_config (intel_gsfi_dev *flash_info, gsfi_config *setting)
Include: <intel_generic_serial_flash_interface_top.h>
Parameter:
  • flash_info – pointer to the flash device structure
  • setting - pointer to the configuration structure
Return: Return 0 for success and otherwise:
  • EINVAL for invalid argument
  • ENODEV for no device detected
Description: Configure:
  • tSHSL (CS high time) value 11
  • CS de-assert (CS active hold time) value11
  • CS assert (CS active setup time) value11
  • Baud rate divisor value11
  • Flash to support Quad I/O mode12
11 Refer to the respective registers in 1.5 Register Map for the input range.
12 Enable this feature by asserting to 1, otherwise disable with 0.