drivers/eeprom: Retrieve the geometry

Add EEPIOC_GEOMETRY IOCTL command to retrieve the
EEPROM geometry.

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
This commit is contained in:
Antoine Juckler 2025-07-03 13:36:36 +09:00 committed by Alan C. Assis
parent f1506c6212
commit 934dfdf645
12 changed files with 425 additions and 223 deletions

View file

@ -1,97 +0,0 @@
======
EEPROM
======
EEPROMs are a form of Memory
Technology Device (MTD). EEPROMs are non-volatile memory like FLASH, but
differ in underlying memory technology and differ in usage in many respects:
They may not be organized into blocks (at least from the standpoint of the
user) and it is not necessary to erase the EEPROM memory before re-writing
it. In addition, EEPROMs tend to be much smaller than FLASH parts, usually
only a few kilobytes vs megabytes for FLASH. EEPROM tends to be used to
retain a small amount of device configuration information; FLASH tends
to be used for program or massive data storage. For these reasons, it may
not be convenient to use the more complex MTD interface but instead use
the simple character interface provided by the EEPROM drivers.
EEPROM Device Support
=====================
drivers/eeprom/spi_xx25xx.c
---------------------------
This is a driver for SPI EEPROMs that use the same commands as the
25AA160::
Manufacturer Device Bytes PgSize AddrLen
Microchip
25xx010A 128 16 1
25xx020A 256 16 1
25AA02UID 256 16 1
25AA02E48 256 16 1
25AA02E64 256 16 1
25xx040 512 16 1+bit
25xx040A 512 16 1+bit
25xx080 1024 16 1
25xx080A 1024 16 2
25xx080B 1024 32 2
25xx080C 1024 16 x
25xx080D 1024 32 x
25xx160 2048 16 2
25xx160A/C 2048 16 2 TESTED
25xx160B/D 2048 32 2
25xx160C 2048 16 2
25xx160D 2048 32 2
25xx320 4096 32 2
25xx320A 4096 32 2
25xx640 8192 32 2
25xx640A 8192 32 2
25xx128 16384 64 2
25xx256 32768 64 2
25xx512 65536 128 2
25xx1024 131072 256 3
Atmel
AT25010B 128 8 1
AT25020B 256 8 1
AT25040B 512 8 1+bit
AT25080B 1024 32 2
AT25160B 2048 32 2
AT25320B 4096 32 2
AT25640B 8192 32 2
AT25128B 16384 64 2
AT25256B 32768 64 2
AT25512 65536 128 2
AT25M01 131072 256 3
drivers/mtd/at24xx.c
--------------------
This is a driver for I2C-based at24cxx EEPROM (at24c32, at24c64, at24c128,
at24c256, at24c512). This driver is currently provided as an MTD driver
but could easily be modified to support the character driver interface.
File Systems
============
Most EEPROM parts are too small to be candidates for use with a file
system. The character driver interface is optimal for these small parts
because you can open and access the EEPROM part as if it were a single,
fixed size file.
It is also possible to use these character drivers with a file system.
The character driver can converted to a block device using the NuttX loop
device. The loop device can be found the file drivers/loop.c. Interface
function prototypes can be found in include/nuttx/fs/fs.h::
int losetup(FAR const char *devname, FAR const char *filename,
uint16_t sectsize, off_t offset, bool readonly);
Given a file or character devices at 'filename', losetup will create the
block device 'devname' using a bogus sector size of sectsize. 'offset' is
normally zero but can be used to provide an offset into the EEPROM where
the block driver data starts; The EEPROM block driver can also be read-
only.
There is a corresponding function that will destroy the loop device::
int loteardown(FAR const char *devname);

View file

@ -5,7 +5,6 @@ Block Device Drivers
.. toctree::
:maxdepth: 1
eeprom.rst
ramdisk.rst

View file

@ -0,0 +1,169 @@
======
EEPROM
======
.. warning::
This page describes EEPROM interfacing using a character driver. For the
more standard MTD interface, refer to the
:doc:`MTD documentation <../special/mtd>`.
See `MTD vs character driver <mtd_vs_char_>`_ for when to use each interface.
EEPROMs are a form of Memory Technology Device (MTD).
EEPROMs are non-volatile memory like FLASH, but differ in underlying memory
technology and differ in usage in many respects: They may not be organized into
blocks (at least from the standpoint of the user) and it is not necessary to
erase the EEPROM memory before re-writing it.
In addition, EEPROMs tend to be much smaller than FLASH parts, usually only a
few kilobytes vs megabytes for FLASH. EEPROM tends to be used to retain a small
amount of device configuration information; FLASH tends to be used for program
or massive data storage. For these reasons, it may not be convenient to use the
more complex MTD interface but instead use the simple character interface
provided by the EEPROM drivers.
.. _mtd_vs_char:
MTD driver vs character driver
==============================
MTD driver
Used when the EEPROM should appear as a block device (`/dev/mtdX`) and is
intended to be mounted with a filesystem. The MTD layer handles erase, read
and write granularity.
Character driver
Used when direct, random-access reads and writes to the raw EEPROM are
desired, without the overhead of a filesystem. This is suitable for storing a
handful of configuration parameters, calibration data, or any small blob that
does not justify a full filesystem.
EEPROM Device Support
=====================
drivers/eeprom/spi_xx25xx.c
---------------------------
This is a driver for SPI EEPROMs that use the same commands as the
25AA160::
Manufacturer Device Bytes PgSize SecSize AddrLen
Microchip
25xx010A 128 16 16 1
25xx020A 256 16 16 1
25AA02UID 256 16 16 1
25AA02E48 256 16 16 1
25AA02E64 256 16 16 1
25xx040 512 16 16 1+bit
25xx040A 512 16 16 1+bit
25xx080 1024 16 16 1
25xx080A 1024 16 16 2
25xx080B 1024 32 32 2
25xx080C 1024 16 16 x
25xx080D 1024 32 32 x
25xx160 2048 16 16 2
25xx160A/C 2048 16 16 2
25xx160B/D 2048 32 32 2
25xx160C 2048 16 16 2
25xx160D 2048 32 32 2
25xx320 4096 32 32 2
25xx320A 4096 32 32 2
25xx640 8192 32 32 2
25xx640A 8192 32 32 2
25xx128 16384 64 64 2
25xx256 32768 64 64 2
25xx512 65536 128 16384 2
25xx1024 131072 256 32768 3
Atmel
AT25010B 128 8 8 1
AT25020B 256 8 8 1
AT25040B 512 8 8 1+bit
AT25080B 1024 32 32 2
AT25160B 2048 32 32 2
AT25320B 4096 32 32 2
AT25640B 8192 32 32 2
AT25128B 16384 64 64 2
AT25256B 32768 64 64 2
AT25512 65536 128 128 2
AT25M01 131072 256 256 3
ST Microelectronics
M95010 128 16 16 1
M95020 256 16 16 1
M95040 512 16 16 1+bit
M95080 1024 32 32 2
M95160 2048 32 32 2
M95320 4096 32 32 2
M95640 8192 32 32 2
M95128 16384 64 64 2
M95256 32768 64 64 2
M95512 65536 128 128 2
M95M01 131072 256 256 3
M95M02 262144 256 256 3
drivers/eeprom/i2c_xx24xx.c
---------------------------
This is a driver for I2C EEPROMs that use the same commands as the xx24xx::
Manufacturer Device Bytes PgSize AddrLen DevAddr
Microchip
24xx00 16 1 1 1010000 Special case
24xx01 128 8 1 1010000
24xx02 256 8 1 1010000
24xx04 512 16 1 101000P
24xx08 1024 16 1 10100PP
24xx16 2048 16 1 1010PPP
24xx32 4096 32 2 1010AAA
24xx64 8192 32 2 1010AAA
24xx128 16384 64 2 1010AAA
24xx256 32768 64 2 1010AAA
24xx512 65536 128 2 1010AAA
24xx1025 131072 128 2 1010PAA Special case: address
bit is shifted.
24xx1026 131072 128 2 1010AAP
Atmel
AT24C01 128 8 1 1010AAA
AT24C02 256 8 1 1010AAA
AT24C04 512 16 1 1010AAP P bits = word address
AT24C08 1024 16 1 1010APP
AT24C16 2048 16 1 1010PPP
AT24C32 4096 32 2 1010AAA
AT24C64 8192 32 2 1010AAA
AT24C128 16384 64 2 10100AA
AT24C256 32768 64 2 10100AA
AT24C512 65536 128 2 10100AA
AT24C1024 131072 256 2 10100AP
ST Microelectronics
M24C01 128 16 1 1010AAA
M24C02 256 16 1 1010AAA
M24C04 512 16 1 1010AAP
M24C08 1024 16 1 1010APP
M24C16 2048 16 1 1010PPP
M24C32 4096 32 2 1010AAA ID pages supported
as a separate device
M24C64 8192 32 2 1010AAA
M24128 16384 64 2 1010AAA
M24256 32768 64 2 1010AAA
M24512 65536 128 2 1010AAA
M24M01 131072 256 2 1010AAP
M24M02 262144 256 2 1010APP
IOCTL Commands
==============
The full list of ``ioctl()`` commands can be found in
``include/nuttx/eeprom/eeprom.h``.
- ``EEPIOC_GEOMETRY``: Get the EEPROM geometry
File Systems
============
Most EEPROM parts are too small to be candidates for use with a file
system. The character driver interface is optimal for these small parts
because you can open and access the EEPROM part as if it were a single,
fixed size file.
To use them with a file system, it is preferable to use the
:doc:`MTD driver <../special/mtd>`.

View file

@ -60,6 +60,7 @@ Character device drivers have these properties:
can.rst
contactless.rst
crypto/index.rst
eeprom.rst
efuse.rst
i2s.rst
input/index.rst

View file

@ -84,20 +84,10 @@ Subdirectories of ``nuttx/drivers``
DMA drivers support.
* ``eeprom/`` :doc:`block/eeprom`
* ``eeprom/`` :doc:`character/eeprom`
An EEPROM is a form of Memory Technology Device (see ``drivers/mtd``).
EEPROMs are non-volatile memory like FLASH, but differ in underlying
memory technology and differ in usage in many respects: They may not
be organized into blocks (at least from the standpoint of the user)
and it is not necessary to erase the EEPROM memory before re-writing
it. In addition, EEPROMs tend to be much smaller than FLASH parts,
usually only a few kilobytes vs megabytes for FLASH. EEPROM tends to
be used to retain a small amount of device configuration information;
FLASH tends to be used for program or massive data storage. For these
reasons, it may not be convenient to use the more complex MTD
interface but instead use the simple character interface provided by
the EEPROM drivers.
EEPROM support as character drivers. Support as Memory Technology Device
(MTD) is located in the ``mtd/`` directory.
* ``efuse/`` :doc:`character/efuse`

View file

@ -127,17 +127,23 @@ FTL behavior:
EEPROM
======
EEPROMs are a form of Memory Technology Device (MTD). EEPROMs are non-
volatile memory like FLASH, but differ in underlying memory technology and
differ in usage in many respects: They may not be organized into blocks
(at least from the standpoint of the user) and it is not necessary to
erase the EEPROM memory before re-writing it. In addition, EEPROMs tend
to be much smaller than FLASH parts, usually only a few kilobytes vs
megabytes for FLASH. EEPROM tends to be used to retain a small amount of
device configuration information; FLASH tends to be used for program or
massive data storage. For these reasons, it may not be convenient to use
the more complex MTD interface but instead use the simple character
interface provided by the EEPROM drivers. See drivers/eeprom.
SPI EEPROMs using the same commands as the Microchip 25xxxx family, and I2C
EEPROMs using the same commands as the Microchip 24xxxx family can be
interfaced using the `drivers/mtd/at25ee.c` and `drivers/mtd/at24xx.c` driver
respectively.
Refer to the :doc:`EEPROM character driver reference <../character/eeprom>`
for
- the differences between EEPROM and FLASH memory;
- the list of supported EEPROM variants;
- interfacing EEPROM using a character driver.
The MTD interface should be preferred over the character driver interface in
most cases, unless finer control is desired over the EEPROM operations. The
character driver interface may also be preferred to reduce footprint or for
very trivial usage of the EEPROM (e.g. storing parameters without having to
rely on a filesystem).
CFI FLASH
=========

View file

@ -84,12 +84,13 @@
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <nuttx/fs/fs.h>
#include <nuttx/eeprom/eeprom.h>
#include <nuttx/eeprom/i2c_xx24xx.h>
#include <nuttx/fs/fs.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/eeprom/i2c_xx24xx.h>
/****************************************************************************
* Pre-processor Definitions
@ -605,7 +606,7 @@ static ssize_t at24cs_read_uuid(FAR struct file *filep, FAR char *buffer,
/* Write data address */
finfo("READ %d bytes at pos %d\n", len, filep->f_pos);
finfo("READ %zu bytes at pos %" PRIdOFF "\n", len, filep->f_pos);
regindx = 0x80; /* reg index of UUID[0] */
@ -779,14 +780,33 @@ static int ee24xx_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct ee24xx_dev_s *eedev;
FAR struct inode *inode = filep->f_inode;
int ret = 0;
int ret = -EINVAL;
DEBUGASSERT(inode->i_private);
eedev = inode->i_private;
UNUSED(eedev);
switch (cmd)
{
case EEPIOC_GEOMETRY:
{
FAR struct eeprom_geometry_s *geo =
(FAR struct eeprom_geometry_s *)arg;
if (geo != NULL)
{
geo->npages = 0;
geo->pagesize = eedev->pgsize;
geo->sectsize = eedev->pgsize;
if (eedev->pgsize > 0)
{
geo->npages = eedev->size / eedev->pgsize;
}
ret = OK;
}
}
break;
default:
ret = -ENOTTY;
}

View file

@ -43,58 +43,58 @@
*
* The following devices should be supported:
*
* Manufacturer Device Bytes PgSize AddrLen
* Manufacturer Device Bytes PgSize SecSize AddrLen
* Microchip
* 25xx010A 128 16 1
* 25xx020A 256 16 1
* 25AA02UID 256 16 1
* 25AA02E48 256 16 1
* 25AA02E64 256 16 1
* 25xx040 512 16 1+bit
* 25xx040A 512 16 1+bit
* 25xx080 1024 16 1
* 25xx080A 1024 16 2
* 25xx080B 1024 32 2
* 25xx080C 1024 16 x
* 25xx080D 1024 32 x
* 25xx160 2048 16 2
* 25xx160A/C 2048 16 2 TESTED
* 25xx160B/D 2048 32 2
* 25xx160C 2048 16 2
* 25xx160D 2048 32 2
* 25xx320 4096 32 2
* 25xx320A 4096 32 2
* 25xx640 8192 32 2
* 25xx640A 8192 32 2
* 25xx128 16384 64 2
* 25xx256 32768 64 2
* 25xx512 65536 128 2
* 25xx1024 131072 256 3
* 25xx010A 128 16 16 1
* 25xx020A 256 16 16 1
* 25AA02UID 256 16 16 1
* 25AA02E48 256 16 16 1
* 25AA02E64 256 16 16 1
* 25xx040 512 16 16 1+bit
* 25xx040A 512 16 16 1+bit
* 25xx080 1024 16 16 1
* 25xx080A 1024 16 16 2
* 25xx080B 1024 32 32 2
* 25xx080C 1024 16 16 x
* 25xx080D 1024 32 32 x
* 25xx160 2048 16 16 2
* 25xx160A/C 2048 16 16 2
* 25xx160B/D 2048 32 32 2
* 25xx160C 2048 16 16 2
* 25xx160D 2048 32 32 2
* 25xx320 4096 32 32 2
* 25xx320A 4096 32 32 2
* 25xx640 8192 32 32 2
* 25xx640A 8192 32 32 2
* 25xx128 16384 64 64 2
* 25xx256 32768 64 64 2
* 25xx512 65536 128 16384 2
* 25xx1024 131072 256 32768 3
* Atmel
* AT25010B 128 8 1
* AT25020B 256 8 1
* AT25040B 512 8 1+bit
* AT25080B 1024 32 2
* AT25160B 2048 32 2
* AT25320B 4096 32 2
* AT25640B 8192 32 2
* AT25128B 16384 64 2
* AT25256B 32768 64 2
* AT25512 65536 128 2
* AT25M01 131072 256 3
* AT25010B 128 8 8 1
* AT25020B 256 8 8 1
* AT25040B 512 8 8 1+bit
* AT25080B 1024 32 32 2
* AT25160B 2048 32 32 2
* AT25320B 4096 32 32 2
* AT25640B 8192 32 32 2
* AT25128B 16384 64 64 2
* AT25256B 32768 64 64 2
* AT25512 65536 128 128 2
* AT25M01 131072 256 256 3
* ST Microelectronics
* M95010 128 16 1
* M95020 256 16 1
* M95040 512 16 1+bit
* M95080 1024 32 2
* M95160 2048 32 2
* M95320 4096 32 2
* M95640 8192 32 2
* M95128 16384 64 2
* M95256 32768 64 2
* M95512 65536 128 2
* M95M01 131072 256 3
* M95M02 262144 256 3
* M95010 128 16 16 1
* M95020 256 16 16 1
* M95040 512 16 16 1+bit
* M95080 1024 32 32 2
* M95160 2048 32 32 2
* M95320 4096 32 32 2
* M95640 8192 32 32 2
* M95128 16384 64 64 2
* M95256 32768 64 64 2
* M95512 65536 128 128 2
* M95M01 131072 256 256 3
* M95M02 262144 256 256 3
*/
/****************************************************************************
@ -107,8 +107,10 @@
#include <assert.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/fs/fs.h>
#include <stdio.h>
#include <nuttx/eeprom/eeprom.h>
#include <nuttx/fs/fs.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/signal.h>
@ -165,6 +167,7 @@ struct ee25xx_geom_s
{
uint8_t bytes : 4; /* Power of two of 128 bytes (0:128 1:256 2:512 etc) */
uint8_t pagesize : 4; /* Power of two of 8 bytes (0:8 1:16 2:32 3:64 etc) */
uint8_t secsize : 4; /* Power of two of the page size */
uint8_t addrlen : 4; /* Number of bytes in command address field */
uint8_t flags : 4; /* Special address management for 25xx040, 1=A8 in inst */
};
@ -176,6 +179,7 @@ struct ee25xx_dev_s
struct spi_dev_s *spi; /* SPI device where the EEPROM is attached */
uint32_t size; /* in bytes, expanded from geometry */
uint16_t pgsize; /* write block size, in bytes, expanded from geometry */
uint32_t secsize; /* write sector size, in bytes, expanded from geometry */
uint16_t addrlen; /* number of BITS in data addresses */
mutex_t lock; /* file access serialization */
uint8_t refs; /* The number of times the device has been opened */
@ -210,62 +214,68 @@ static const struct ee25xx_geom_s g_ee25xx_devices[] =
/* Microchip devices */
{
0, 1, 1, 0
}, /* 25xx010A 128 16 1 */
0, 1, 0, 1, 0
}, /* 25xx010A 128 16 16 1 */
{
1, 1, 1, 0
}, /* 25xx020A 256 16 1 */
1, 1, 0, 1, 0
}, /* 25xx020A 256 16 16 1 */
{
2, 1, 1, 1
}, /* 25xx040 512 16 1+bit */
2, 1, 0, 1, 1
}, /* 25xx040 512 16 16 1+bit */
{
3, 1, 1, 0
}, /* 25xx080 1024 16 1 */
3, 1, 0, 1, 0
}, /* 25xx080 1024 16 16 1 */
{
3, 2, 2, 0
}, /* 25xx080B 1024 32 2 */
3, 2, 0, 2, 0
}, /* 25xx080B 1024 32 32 2 */
{
4, 1, 2, 0
}, /* 25xx160 2048 16 2 */
4, 1, 0, 2, 0
}, /* 25xx160 2048 16 16 2 */
{
4, 2, 2, 0
}, /* 25xx160B/D 2048 32 2 */
4, 2, 0, 2, 0
}, /* 25xx160B/D 2048 32 32 2 */
{
5, 2, 2, 0
}, /* 25xx320 4096 32 2 */
5, 2, 0, 2, 0
}, /* 25xx320 4096 32 32 2 */
{
6, 2, 2, 0
}, /* 25xx640 8192 32 2 */
6, 2, 0, 2, 0
}, /* 25xx640 8192 32 32 2 */
{
7, 3, 2, 0
}, /* 25xx128 16384 64 2 */
7, 3, 0, 2, 0
}, /* 25xx128 16384 64 64 2 */
{
8, 3, 2, 0
}, /* 25xx256 32768 64 2 */
8, 3, 0, 2, 0
}, /* 25xx256 32768 64 64 2 */
{
9, 4, 2, 0
}, /* 25xx512 65536 128 2 */
9, 4, 7, 2, 0
}, /* 25xx512 65536 128 16384 2 */
{
10, 5, 3, 0
}, /* 25xx1024 131072 256 3 */
10, 5, 7, 3, 0
}, /* 25xx1024 131072 256 32768 3 */
/* Atmel devices */
{
0, 0, 1, 0
}, /* AT25010B 128 8 1 */
0, 0, 0, 1, 0
}, /* AT25010B 128 8 8 1 */
{
1, 0, 1, 0
}, /* AT25020B 256 8 1 */
1, 0, 0, 1, 0
}, /* AT25020B 256 8 8 1 */
{
2, 0, 1, 1
}, /* AT25040B 512 8 1+bit */
2, 0, 0, 1, 1
}, /* AT25040B 512 8 8 1+bit */
{
9, 4, 0, 2, 0
}, /* AT25512 65536 128 128 2 */
{
10, 5, 0, 3, 0
}, /* AT25M01 131072 256 256 3 */
/* STM devices */
{
11, 5, 3, 0
}, /* M95M02 262144 256 3 */
11, 5, 0, 3, 0
}, /* M95M02 262144 256 256 3 */
};
/* Driver operations */
@ -765,14 +775,33 @@ static int ee25xx_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct ee25xx_dev_s *eedev;
FAR struct inode *inode = filep->f_inode;
int ret = 0;
int ret = -EINVAL;
DEBUGASSERT(inode->i_private);
eedev = inode->i_private;
UNUSED(eedev);
switch (cmd)
{
case EEPIOC_GEOMETRY:
{
FAR struct eeprom_geometry_s *geo =
(FAR struct eeprom_geometry_s *)arg;
if (geo != NULL)
{
geo->npages = 0;
geo->pagesize = eedev->pgsize;
geo->sectsize = eedev->secsize;
if (eedev->pgsize > 0)
{
geo->npages = eedev->size / eedev->pgsize;
}
ret = OK;
}
}
break;
default:
ret = -ENOTTY;
}
@ -816,9 +845,10 @@ int ee25xx_initialize(FAR struct spi_dev_s *dev, FAR char *devname,
nxmutex_init(&eedev->lock);
eedev->spi = dev;
eedev->size = 128 << g_ee25xx_devices[devtype].bytes;
eedev->pgsize = 8 << g_ee25xx_devices[devtype].pagesize;
eedev->addrlen = g_ee25xx_devices[devtype].addrlen << 3;
eedev->size = 128 << g_ee25xx_devices[devtype].bytes;
eedev->pgsize = 8 << g_ee25xx_devices[devtype].pagesize;
eedev->secsize = eedev->pgsize << g_ee25xx_devices[devtype].secsize;
eedev->addrlen = g_ee25xx_devices[devtype].addrlen << 3;
if ((g_ee25xx_devices[devtype].flags & 1))
{
eedev->addrlen = 9;

View file

@ -221,6 +221,12 @@ static const struct at25ee_geom_s g_at25ee_devices[] =
{
2, 0, 1, 1
}, /* AT25040B 512 8 1+bit */
{
9, 4, 2, 0
}, /* AT25512 65536 128 2 */
{
10, 5, 3, 0
}, /* AT25M01 131072 256 3 */
/* STM devices */

View file

@ -0,0 +1,69 @@
/************************************************************************************
* include/nuttx/eeprom/eeprom.h
*
* SPDX-License-Identifier: Apache-2.0
*
* EEPROM IOCTL commands
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
************************************************************************************/
/* This file includes common definitions to be used in all EEPROM drivers
* (when applicable).
*/
#ifndef __INCLUDE_NUTTX_EEPROM_EEPROM_H
#define __INCLUDE_NUTTX_EEPROM_EEPROM_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <sys/types.h>
#include <nuttx/fs/ioctl.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* EEPROM IOCTL Commands ************************************************************/
#define EEPIOC_GEOMETRY _EEPIOC(0x000) /* Similar to BIOC_GEOMETRY:
* Return the geometry of the EEPROM
* device.
* IN: Pointer to writable instance of
* struct eeprom_geometry_s in which
* to return the geometry.
* OUT: Data return in user-provided
* buffer. */
/************************************************************************************
* Type Definitions
************************************************************************************/
struct eeprom_geometry_s
{
blkcnt_t npages; /* Number of pages on the device */
blksize_t sectsize; /* Size of one sector in bytes */
blksize_t pagesize; /* Size of one page in bytes */
};
#endif /* __INCLUDE_NUTTX_EEPROM_EEPROM_H */

View file

@ -46,14 +46,16 @@ enum eeprom_25xx_e
EEPROM_25XX640,
EEPROM_25XX128,
EEPROM_25XX256,
EEPROM_25XX512,
EEPROM_25XX1024,
EEPROM_25XX512, /* Additional erase commands */
EEPROM_25XX1024, /* Additional erase commands */
/* Atmel geometries */
EEPROM_AT25010B,
EEPROM_AT25020B,
EEPROM_AT25040B,
EEPROM_AT25512,
EEPROM_AT25M01,
/* STM geometries */
@ -67,7 +69,6 @@ enum eeprom_25xx_e
EEPROM_AT25640B = EEPROM_25XX640,
EEPROM_AT25128B = EEPROM_25XX128,
EEPROM_AT225256B = EEPROM_25XX256,
EEPROM_AT25512 = EEPROM_25XX512,
EEPROM_AT25M02 = EEPROM_25XX1024,
EEPROM_M95010 = EEPROM_25XX010,
EEPROM_M95020 = EEPROM_25XX020,
@ -78,8 +79,8 @@ enum eeprom_25xx_e
EEPROM_M95640 = EEPROM_25XX640,
EEPROM_M95128 = EEPROM_25XX128,
EEPROM_M95256 = EEPROM_25XX256,
EEPROM_M95512 = EEPROM_25XX512,
EEPROM_M95M01 = EEPROM_25XX1024,
EEPROM_M95512 = EEPROM_AT25512,
EEPROM_M95M01 = EEPROM_AT25M01,
};
/****************************************************************************

View file

@ -111,6 +111,7 @@
#define _MSIOCBASE (0x4300) /* Mouse ioctl commands */
#define _I2SOCBASE (0x4400) /* I2S driver ioctl commands */
#define _1WIREBASE (0x4500) /* 1WIRE ioctl commands */
#define _EEPIOCBASE (0x4600) /* EEPROM driver ioctl commands */
#define _WLIOCBASE (0x8b00) /* Wireless modules ioctl network commands */
/* boardctl() commands share the same number space */
@ -247,7 +248,7 @@
* OUT: None
*/
/* NuttX file system ioctl definitions **************************************/
/* NuttX character driver ioctl definitions *********************************/
#define _DIOCVALID(c) (_IOC_TYPE(c)==_DIOCBASE)
#define _DIOC(nr) _IOC(_DIOCBASE,nr)
@ -791,6 +792,13 @@
#define _1WIREIOCVALID(c) (_IOC_TYPE(c)==_1WIREBASE)
#define _1WIREIOC(nr) _IOC(_1WIREBASE,nr)
/* EEPROM driver ioctl definitions ******************************************/
/* (see nuttx/include/eeprom/eeprom.h */
#define _EEPIOCVALID(c) (_IOC_TYPE(c)==_EEPIOCBASE)
#define _EEPIOC(nr) _IOC(_EEPIOCBASE,nr)
/****************************************************************************
* Public Type Definitions
****************************************************************************/