Low level Memory Technology Device interface.
More...
Low level Memory Technology Device interface.
Generic memory technology device interface
|
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) |
| Read data from a MTD device. More...
|
|
int | mtd_read_page (mtd_dev_t *mtd, void *dest, uint32_t page, uint32_t offset, uint32_t size) |
| Read data from a MTD device with pagewise addressing. More...
|
|
int | mtd_write (mtd_dev_t *mtd, const void *src, uint32_t addr, uint32_t count) |
| Write data to a MTD device. More...
|
|
int | mtd_write_page (mtd_dev_t *mtd, const void *src, uint32_t page, uint32_t offset, uint32_t size) |
| Write data to a MTD device with pagewise addressing. More...
|
|
int | mtd_erase (mtd_dev_t *mtd, uint32_t addr, uint32_t count) |
| Erase sectors of a MTD device. More...
|
|
int | mtd_erase_sector (mtd_dev_t *mtd, uint32_t sector, uint32_t num) |
| Erase sectors of a MTD device. More...
|
|
int | mtd_power (mtd_dev_t *mtd, enum mtd_power_state power) |
| Set power mode on a MTD device. More...
|
|
◆ mtd_desc_t
MTD driver interface.
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.
◆ mtd_power_state
MTD power states.
Enumerator |
---|
MTD_POWER_UP | Power up.
|
MTD_POWER_DOWN | Power down.
|
Definition at line 38 of file mtd.h.
◆ mtd_erase()
int mtd_erase |
( |
mtd_dev_t * |
mtd, |
|
|
uint32_t |
addr, |
|
|
uint32_t |
count |
|
) |
| |
Erase sectors of a MTD device.
addr
must be aligned on a sector boundary. count
must be a multiple of a sector size.
- Parameters
-
| mtd | the device to erase |
[in] | addr | the address of the first sector to erase |
[in] | count | the number of bytes to erase |
- Returns
- 0 if erase successful
-
< 0 if an error occurred
-
-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 occurred
◆ mtd_erase_sector()
int mtd_erase_sector |
( |
mtd_dev_t * |
mtd, |
|
|
uint32_t |
sector, |
|
|
uint32_t |
num |
|
) |
| |
Erase sectors of a MTD device.
- Parameters
-
| mtd | the device to erase |
[in] | sector | the first sector number to erase |
[in] | num | the number of sectors to erase |
- Returns
- 0 if erase successful
-
< 0 if an error occurred
-
-ENODEV if
mtd
is not a valid device
-
-ENOTSUP if operation is not supported on
mtd
-
-EOVERFLOW if
addr
or sector
are not valid, i.e. outside memory
-
-EIO if I/O error occurred
◆ mtd_init()
mtd_init Initialize a MTD device
- Parameters
-
mtd | the device to initialize |
- Returns
◆ mtd_power()
Set power mode on a MTD device.
- Parameters
-
| mtd | the device to access |
[in] | power | the power mode to set |
- Returns
- 0 if power mode successfully set
-
< 0 if an error occurred
-
-ENODEV if
mtd
is not a valid device
-
-ENOTSUP if operation or
power
state is not supported on mtd
-
-EIO if I/O error occurred
◆ mtd_read()
int mtd_read |
( |
mtd_dev_t * |
mtd, |
|
|
void * |
dest, |
|
|
uint32_t |
addr, |
|
|
uint32_t |
count |
|
) |
| |
Read data from a MTD device.
No alignment is required on addr
and count
.
- Parameters
-
| mtd | the device to read from |
[out] | dest | the buffer to fill in |
[in] | addr | the start address to read from |
[in] | count | the number of bytes to read |
- Returns
- 0 on success
-
< 0 if an error occurred
-
-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 occurred
◆ mtd_read_page()
int mtd_read_page |
( |
mtd_dev_t * |
mtd, |
|
|
void * |
dest, |
|
|
uint32_t |
page, |
|
|
uint32_t |
offset, |
|
|
uint32_t |
size |
|
) |
| |
Read data from a MTD device with pagewise addressing.
The MTD layer will take care of splitting up the transaction into multiple reads if it is required by the underlying storage media.
offset
must be smaller than the page size
- Parameters
-
| mtd | the device to read from |
[out] | dest | the buffer to fill in |
[in] | page | Page number to start reading from |
[in] | offset | offset from the start of the page (in bytes) |
[in] | size | the number of bytes to read |
- Returns
- 0 on success
-
< 0 if an error occurred
-
-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 occurred
◆ mtd_write()
int mtd_write |
( |
mtd_dev_t * |
mtd, |
|
|
const void * |
src, |
|
|
uint32_t |
addr, |
|
|
uint32_t |
count |
|
) |
| |
Write data to a MTD device.
addr
+ count
must be inside a page boundary. addr
can be anywhere but the buffer cannot overlap two pages. Though some devices might enforce alignment on both addr
and buf
.
- Parameters
-
| mtd | the device to write to |
[in] | src | the buffer to write |
[in] | addr | the start address to write to |
[in] | count | the number of bytes to write |
- Returns
- 0 on success
-
< 0 if an error occurred
-
-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 occurred
-
-EINVAL if parameters are invalid (invalid alignment for instance)
◆ mtd_write_page()
int mtd_write_page |
( |
mtd_dev_t * |
mtd, |
|
|
const void * |
src, |
|
|
uint32_t |
page, |
|
|
uint32_t |
offset, |
|
|
uint32_t |
size |
|
) |
| |
Write data to a MTD device with pagewise addressing.
The MTD layer will take care of splitting up the transaction into multiple writes if it is required by the underlying storage media.
offset
must be smaller than the page size
- Parameters
-
| mtd | the device to write to |
[in] | src | the buffer to write |
[in] | page | Page number to start writing to |
[in] | offset | byte offset from the start of the page |
[in] | size | the number of bytes to write |
- Returns
- 0 on success
-
< 0 if an error occurred
-
-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 occurred
-
-EINVAL if parameters are invalid