Memory Technology Device

Low level Memory Technology Device interface. More...

Detailed Description

Generic memory technology device interface

Modules

 Native MTD
 mtd flash emulation for native
 

Files

file  mtd.h
 

Data Structures

struct  mtd_dev_t
 MTD device descriptor. More...
 
struct  mtd_desc
 MTD driver interface. More...
 

Typedefs

typedef struct mtd_desc mtd_desc_t
 MTD driver interface. More...
 

Enumerations

enum  mtd_power_state { MTD_POWER_UP, MTD_POWER_DOWN }
 MTD power states. More...
 

Functions

int mtd_init (mtd_dev_t *mtd)
 mtd_init Initialize a MTD device More...
 
int mtd_read (mtd_dev_t *mtd, void *dest, uint32_t addr, uint32_t count)
 mtd_read Read data from a MTD device More...
 
int mtd_write (mtd_dev_t *mtd, const void *src, uint32_t addr, uint32_t count)
 mtd_read write data to a MTD device More...
 
int mtd_erase (mtd_dev_t *mtd, uint32_t addr, uint32_t count)
 mtd_erase Erase sectors of a MTD device More...
 
int mtd_power (mtd_dev_t *mtd, enum mtd_power_state power)
 mtd_power Set power mode on a MTD device More...
 

Variables

const vfs_file_ops_t mtd_vfs_ops
 MTD driver for VFS.
 

Typedef Documentation

◆ mtd_desc_t

typedef struct mtd_desc mtd_desc_t

This define the functions to access a MTD.

A MTD is composed of pages combined into sectors. A sector is the smallest erasable unit. The number of pages in a sector must be constant for the whole MTD.

The erase operation is available only for entire sectors.

Definition at line 53 of file mtd.h.

Enumeration Type Documentation

◆ mtd_power_state

Enumerator
MTD_POWER_UP 

Power up.

MTD_POWER_DOWN 

Power down.

Definition at line 38 of file mtd.h.

Function Documentation

◆ mtd_erase()

int mtd_erase ( mtd_dev_t mtd,
uint32_t  addr,
uint32_t  count 
)

addr must be aligned on a sector boundary. count must be a multiple of a sector size.

Parameters
mtdthe device to erase
[in]addrthe address of the first sector to erase
[in]countthe number of bytes to erase
Returns
0 if erase successful
< 0 if an error occured
-ENODEV if mtd is not a valid device
-ENOTSUP if operation is not supported on mtd
-EOVERFLOW if addr or count are not valid, i.e. outside memory
-EIO if I/O error occured

◆ mtd_init()

int mtd_init ( mtd_dev_t mtd)
Parameters
mtdthe device to initialize
Returns

◆ mtd_power()

int mtd_power ( mtd_dev_t mtd,
enum mtd_power_state  power 
)
Parameters
mtdthe device to access
[in]powerthe power mode to set
Returns
0 if power mode successfully set
< 0 if an error occured
-ENODEV if mtd is not a valid device
-ENOTSUP if operation or power state is not supported on mtd
-EIO if I/O error occured

◆ mtd_read()

int mtd_read ( mtd_dev_t mtd,
void *  dest,
uint32_t  addr,
uint32_t  count 
)

No alignment is required on addr and count.

Parameters
mtdthe device to read from
[out]destthe buffer to fill in
[in]addrthe start address to read from
[in]countthe number of bytes to read
Returns
the number of byte actually read
< 0 if an error occured
-ENODEV if mtd is not a valid device
-ENOTSUP if operation is not supported on mtd
-EOVERFLOW if addr or count are not valid, i.e. outside memory
-EIO if I/O error occured

◆ mtd_write()

int mtd_write ( mtd_dev_t mtd,
const void *  src,
uint32_t  addr,
uint32_t  count 
)

addr + count must be inside a page boundary. addr can be anywhere but the buffer cannot overlap two pages.

Parameters
mtdthe device to write to
[in]srcthe buffer to write
[in]addrthe start address to write to
[in]countthe number of bytes to write
Returns
the number of byte actually written
< 0 if an error occured
-ENODEV if mtd is not a valid device
-ENOTSUP if operation is not supported on mtd
-EOVERFLOW if addr or count are not valid, i.e. outside memory, or overlapping two pages
-EIO if I/O error occured