PMSIS BSP
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Flash

Content

 Hyperflash
 

Data Structures

struct  pi_flash_conf
 Flash configuration structure. More...
 
struct  pi_flash_info
 Parameter for FLASH_IOCTL_INFO command. More...
 

Enumerations

enum  pi_flash_ioctl_e
 Command ID for pi_flash_ioctl. More...
 

Functions

int pi_flash_open (struct pi_device *device)
 Open a flash device. More...
 
static void pi_flash_close (struct pi_device *device)
 Close an opened flash device. More...
 
static int32_t pi_flash_ioctl (struct pi_device *device, uint32_t cmd, void *arg)
 Control device. More...
 
static void pi_flash_reg_set (struct pi_device *device, uint32_t reg_addr, uint8_t *value)
 Set flash register. More...
 
static void pi_flash_reg_get (struct pi_device *device, uint32_t reg_addr, uint8_t *value)
 Get flash register. More...
 
static void pi_flash_reg_set_async (struct pi_device *device, uint32_t reg_addr, uint8_t *value, pi_task_t *task)
 Set flash register asynchronously. More...
 
static void pi_flash_reg_get_async (struct pi_device *device, uint32_t reg_addr, uint8_t *value, pi_task_t *task)
 Get flash register asynchronously. More...
 
static void pi_flash_read (struct pi_device *device, uint32_t pi_flash_addr, void *data, uint32_t size)
 Enqueue a read copy to the flash (from flash to processor). More...
 
static void pi_flash_program (struct pi_device *device, uint32_t pi_flash_addr, const void *data, uint32_t size)
 Enqueue a write copy to the flash (from processor to flash). More...
 
static void pi_flash_erase_chip (struct pi_device *device)
 Erase the whole flash. More...
 
static void pi_flash_erase_sector (struct pi_device *device, uint32_t pi_flash_addr)
 Erase a sector. More...
 
static void pi_flash_erase (struct pi_device *device, uint32_t pi_flash_addr, int size)
 Erase an area in the flash. More...
 
static void pi_flash_read_async (struct pi_device *device, uint32_t pi_flash_addr, void *data, uint32_t size, pi_task_t *task)
 Enqueue an asynchronous read copy to the flash (from flash to processor). More...
 
static void pi_flash_program_async (struct pi_device *device, uint32_t pi_flash_addr, const void *data, uint32_t size, pi_task_t *task)
 Enqueue an asynchronous write copy to the flash (from processor to flash). More...
 
static void pi_flash_erase_chip_async (struct pi_device *device, pi_task_t *task)
 Erase the whole flash asynchronously. More...
 
static void pi_flash_erase_sector_async (struct pi_device *device, uint32_t pi_flash_addr, pi_task_t *task)
 Erase a sector asynchronously. More...
 
static void pi_flash_erase_async (struct pi_device *device, uint32_t pi_flash_addr, int size, pi_task_t *task)
 Erase an area in the flash asynchronously. More...
 

Description

The flash driver provides support for transferring data between an external flash chip (e.g. Hyperflash or SPI flash) and the processor running this driver.

Enumeration Type Documentation

Enumerator
PI_FLASH_IOCTL_INFO 
Command for getting flash information. The argument

must be a pointer to a variable of type struct pi_flash_info so that the call is returning information there.

Function Documentation

static void pi_flash_close ( struct pi_device *  device)
inlinestatic

This function can be called to close an opened flash device once it is not needed anymore, in order to free all allocated resources. Once this function is called, the device is not accessible anymore and must be opened again before being used.

Parameters
deviceThe device structure of the device to close.
static void pi_flash_erase ( struct pi_device *  device,
uint32_t  pi_flash_addr,
int  size 
)
inlinestatic

This will erase the specified area. The duration of this operation may be long and may be retrieved from the datasheet. If the flash only supports sector erasing, all the sectors partially or entirely covered by this aread will be erased. The caller is blocked until the operation is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
pi_flash_addrThe address of the area to be erased.
sizeThe size of the area to be erased.
static void pi_flash_erase_async ( struct pi_device *  device,
uint32_t  pi_flash_addr,
int  size,
pi_task_t *  task 
)
inlinestatic

This will erase the specified area. The duration of this operation may be long and may be retrieved from the datasheet. If the flash only supports sector erasing, all the sectors partially or entirely covered by this aread will be erased. A task must be specified in order to specify how the caller should be notified when the transfer is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
pi_flash_addrThe address of the area to be erased.
sizeThe size of the area to be erased.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static void pi_flash_erase_chip ( struct pi_device *  device)
inlinestatic

This will erase the entire flash. The duration of this operation may be long and may be retrieved from the datasheet. The caller is blocked until the operation is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
static void pi_flash_erase_chip_async ( struct pi_device *  device,
pi_task_t *  task 
)
inlinestatic

This will erase the entire flash. The duration of this operation may be long and may be retrieved from the datasheet. A task must be specified in order to specify how the caller should be notified when the transfer is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static void pi_flash_erase_sector ( struct pi_device *  device,
uint32_t  pi_flash_addr 
)
inlinestatic

This will erase one sector. The duration of this operation may be long and may be retrieved from the datasheet. The caller is blocked until the operation is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
pi_flash_addrThe address of the sector to be erased.
static void pi_flash_erase_sector_async ( struct pi_device *  device,
uint32_t  pi_flash_addr,
pi_task_t *  task 
)
inlinestatic

This will erase one sector. The duration of this operation may be long and may be retrieved from the datasheet. A task must be specified in order to specify how the caller should be notified when the transfer is finished.

Parameters
deviceThe device descriptor of the flash chip on which to do the operation.
pi_flash_addrThe address of the sector to be erased.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static int32_t pi_flash_ioctl ( struct pi_device *  device,
uint32_t  cmd,
void *  arg 
)
inlinestatic

This can be called to configure and control the device after it has been opened.

Parameters
deviceThe device structure of the device to control.
cmdThe command to execute on the device.
argThe argument to the command. The size and meaning of this parameter depends on the command which is passed.
int pi_flash_open ( struct pi_device *  device)

This function must be called before the flash device can be used. It will do all the needed configuration to make it usable and initialize the handle used to refer to this opened device when calling other functions. The configuration associated to the device must specify the exact model of flash which must be opened.

Parameters
deviceA pointer to the device structure of the device to open. This structure is allocated by the called and must be kept alive until the device is closed.
Returns
0 if the operation is successfull, -1 if there was an error.
static void pi_flash_program ( struct pi_device *  device,
uint32_t  pi_flash_addr,
const void *  data,
uint32_t  size 
)
inlinestatic

The copy will make a write transfer from one of the processor memory areas to the flash. The locations in the flash being written should have first been erased. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceThe device descriptor of the flash chip on which to do the copy.
pi_flash_addrThe address of the copy in the flash.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy
static void pi_flash_program_async ( struct pi_device *  device,
uint32_t  pi_flash_addr,
const void *  data,
uint32_t  size,
pi_task_t *  task 
)
inlinestatic

The copy will make a write transfer from one of the processor memory areas to the flash. The locations in the flash being written should have first been erased. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceThe device descriptor of the flash chip on which to do the copy.
pi_flash_addrThe address of the copy in the flash.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static void pi_flash_read ( struct pi_device *  device,
uint32_t  pi_flash_addr,
void *  data,
uint32_t  size 
)
inlinestatic

The copy will make a transfer between the flash and one of the processor memory areas. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceThe device descriptor of the flash chip on which to do the copy.
pi_flash_addrThe address of the copy in the flash.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy
static void pi_flash_read_async ( struct pi_device *  device,
uint32_t  pi_flash_addr,
void *  data,
uint32_t  size,
pi_task_t *  task 
)
inlinestatic

The copy will make a transfer between the flash and one of the processor memory areas. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceThe device descriptor of the flash chip on which to do the copy.
pi_flash_addrThe address of the copy in the flash.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static void pi_flash_reg_get ( struct pi_device *  device,
uint32_t  reg_addr,
uint8_t *  value 
)
inlinestatic

This can be called to get a flash register. The list of registers is specific to each flash, see the documentation of the flash for more information.

Parameters
deviceThe device structure of the flash.
reg_addrThe register address.
valueA pointer to the value where the read value will be stored. The size of this variable depends on the register being accessed.
static void pi_flash_reg_get_async ( struct pi_device *  device,
uint32_t  reg_addr,
uint8_t *  value,
pi_task_t *  task 
)
inlinestatic

This can be called to get a flash register. The list of registers is specific to each flash, see the documentation of the flash for more information. A task must be specified in order to specify how the caller should be notified when the operation is finished.

Parameters
deviceThe device structure of the flash.
reg_addrThe register address.
valueA pointer to the value where the read value will be stored. The size of this variable depends on the register being accessed.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
static void pi_flash_reg_set ( struct pi_device *  device,
uint32_t  reg_addr,
uint8_t *  value 
)
inlinestatic

This can be called to set a flash register. This must be used carefully as this can disturb the behavior of the other calls. The list of registers is specific to each flash, see the documentation of the flash for more information.

Parameters
deviceThe device structure of the flash.
reg_addrThe register address.
valueA pointer to the value to be set. The size of this variable depends on the register being accessed.
static void pi_flash_reg_set_async ( struct pi_device *  device,
uint32_t  reg_addr,
uint8_t *  value,
pi_task_t *  task 
)
inlinestatic

This can be called to set a flash register. This must be used carefully as this can disturb the behavior of the other calls. The list of registers is specific to each flash, see the documentation of the flash for more information. A task must be specified in order to specify how the caller should be notified when the operation is finished.

Parameters
deviceThe device structure of the flash.
reg_addrThe register address.
valueA pointer to the value to be set. The size of this variable depends on the register being accessed.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.